[PHP] a question about user and permission on linux

2010-10-31 Thread Ryan Sun
which user it is executed as when request a php script on 
browser?(suppose we are on a shared LAMP hosting)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] editing a file

2010-05-24 Thread Ryan Sun
yea, file_get_contents and file_put_contents are the easiest, but play
with caution when dealing with large files, 'cause it loads the whole
file into memory, fopen() fread() fwrite() can be used for large
files.

On Mon, May 24, 2010 at 5:56 PM, Rene Veerman rene7...@gmail.com wrote:
 On Mon, May 24, 2010 at 11:16 PM, Andres Gonzalez
 and...@packetstorm.com wrote:
 I have a large C source file that is generated by a separate
 source-generating program. When the generated src file is compiled, it
 produces tons of warnings. I want to edit the generated src file and delete
 the offending lines.

 What is the easiest way using a PHP script to read in a file, search for a
 particular signature, and delete a couple of lines? Seems like this would be
 very easy in PHP.

 file_get_contents() to get the file into a $string.

 preg_match_all(,,$matches) to get to what you need,

 str_replace() to replace $matches with your chosen replacements

 and there you are :)

 file_put_contents() to save the results..


 Thanks,

 -Andres

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





 --
 -
 Greetings from Rene7705,

 My free open source webcomponents:
  http://code.google.com/u/rene7705/
  http://mediabeez.ws/downloads (and demos)

 http://www.facebook.com/rene7705
 -

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] localize string (date)

2010-05-21 Thread Ryan Sun
Its either ur title is misleading or I'm misunderstanding
is this what u want?

$subject = 21-05-2010 Ideo urbs Venerabile superb post 12-02-2010
efferatarum latasque 12-02-10 leges gentium cervicis oppressed and
fundamenta libertatis retinacula sempiterne Frugi velut parens and
prudent and dives Caesaribus tamquam 25-04-2010 liberis am regendi
patrimonii swore permitted21-05-2010;
$dateReg = '/[\D]\d{2}[.-]\d{2}[.-](\d{2}|\d{4})[\D]/';
preg_match_all($dateReg, ' '. $subject . ' ', $match);
array_walk($match[0], 'myGetDate');
var_dump($match[0], 1);
function myGetDate($str)
{
$str = substr($str, 1, strlen($str) - 2);
}

On Fri, May 21, 2010 at 3:12 PM, Mickael MONSIEUR
mickael.monsi...@gmail.com wrote:
 Le 21/05/10 21:00, Ashley Sheridan a écrit :

 On Fri, 2010-05-21 at 20:51 +0200, Mickael MONSIEUR wrote:

 hello
 I want to find a date in a text how to? format: XX-XX-

 Example:

 Ideo urbs Venerabile superb post 12-02-2010 efferatarum latasque leges
 gentium cervicis oppressed and fundamenta libertatis retinacula
 sempiterne Frugi velut parens and prudent and dives Caesaribus tamquam
 25-04-2010 liberis am regendi patrimonii swore permitted.

 Return:

 12-12-2010
 25-04-2010

 Thank you for your help.
 Mickael.


 What sort of format is that date, English or American?

 For example: dd-mm- or mm-dd-?

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk


 Hi,

 The principle is to detect the possible dates in French texts.

 The formats can be varied ...

 examples
 02.12.1991, 02/12/1991, 12-02-1991, ... or 2 digit (max 1 char ./-) 2 digit
 (max 1 char ./- ) 4 OR 2 digit (1991 Or 91) :-)

 Br,



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to get input from socket client

2010-05-20 Thread Ryan Sun
Thanks for your reply

 First, I don't think feof() will do what you think it does. I
 wouldn't expect it to show up until after the other end has actually
 closed the connection.

I found unread_bytes in stream_get_meta_data should be more reliable

 TCP is a stream protocol, there
 are no guarantees about delivering a complete message in one read, or
 that two writes won't be read together. It only guarantees that all
 octets will eventually be delivered in the same order they were sent, or
 you will get an error.

thanks 4 pointing out the difference between tcp and udp, I had learnt a lot ^^

The other problem has to do with thinking an fread() will always give
you everything you sent in an fwrite()
Interestingly, I use 'telnet 127.0.0.1 1037' for testing later(on
windows) and everything works, the php server got the input from
telnet client, so I assume there is something wrong in the php client,
the fwrite statement...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: how to overload accessible methods

2010-04-16 Thread Ryan Sun
thanks for all your reply, since all these classes have main entry in
cron.php, I have moved validation there.
Richard, your solution seems interesting, maybe I can use it later :)

On Thu, Apr 15, 2010 at 4:46 AM, Richard Quadling
rquadl...@googlemail.com wrote:
 On 13 April 2010 17:25, Ryan Sun ryansu...@gmail.com wrote:
 this is a class for corntab job, and the validation is very simple,
 just check if the status of user is active when cron job runs, if not,
 throws an exception, other developers won't want to overwrite this
 validation.
 which method of user class will be called is configurable via website
 backed page(we write the name of methods directly in to  schedule
 table).
 Using private methods will solve the problem but since we write public
 methods for all the other cron classes, I just want to keep the style
 to make less confusion.

 On Tue, Apr 13, 2010 at 12:11 PM, Nathan Rixham nrix...@gmail.com wrote:
 Ryan Sun wrote:
 I'm writing an abstract parent class which only contain a validate
 method, other developers will extend this class and add many new
 public methods, every new methods will need to perform a validate
 first.  Won't it be good if validate get called automatically before
 every method call so that they don't have to write more code and they
 won't miss this validate?

 This may call for a back to roots approach, what exactly are you trying
 to accomplish, as in: what is the validation doing?

 perhaps if we see the full picture, we can recommend another perhaps
 more suited approach to the full thing, feel free to post the full code
 if you want / can, the more info the better!

 Regards,

 Nathan


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



 Would this be better ...

 abstract class baseValidate() {
  final public function __construct($params) {
  // Determine if user is active.
  // If OK, then call abstract function postConstruct($params)
  }

  abstract function postConstruct($params);
 }


 You can't override the constructor, so the validation will always be
 called. The developer's can implement their own postConstruct as if
 they where extending __construct.



 --
 -
 Richard Quadling
 Standing on the shoulders of some very clever giants!
 EE : http://www.experts-exchange.com/M_248814.html
 EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
 Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
 ZOPA : http://uk.zopa.com/member/RQuadling


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Include security?

2010-04-16 Thread Ryan Sun
if allow_url_include is turned off, you don't have to worry much about http,
if '.' is a invalide char, you can't include *.php...
the include path probably should be the inc(whatever the name)
folder(not accessible from web) instead of the web root and '..'
should be disallowed

On Fri, Apr 16, 2010 at 4:09 PM, Micky Hulse mickyhulse.li...@gmail.com wrote:
 Hi,

 Code:

 =

 ob_start();
 switch ($this-command)
 {
       case 'include':
               @include($x);
               break;
       default:
               @readfile($x);
 }
 $data = ob_get_contents();
 ob_end_clean();

 =

 The above code snippet is used in a class which would allow developers
 (of a specific CMS) to include files without having to put php include
 tags on the template view.

 The include path will be using the server root path, and the include
 files will probably be stored above the web root.

 My question:

 What would be the best way to clean and secure the include string?

 Maybe something along these lines (untested):

 $invalidChars=array(.,\\,\,;); // things to remove.
 $include_file = strtok($include_file,'?'); // No need for query string.
 $include_file=str_replace($invalidChars,,$include_file);

 What about checking to make sure the include path is root relative,
 vs. http://...?

 What do ya'll think? Any suggestions?

 Many thanks in advance!

 Cheers,
 Micky

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP and schedules tasks/events

2010-04-16 Thread Ryan Sun
you can setup a schedule table in db
and have a cron php script check the db every time
and send email if the current time is around the scheduled_at time
and close the schedule after you send the email

On Fri, Apr 16, 2010 at 5:35 PM, Adam Richardson simples...@gmail.com wrote:
 On Fri, Apr 16, 2010 at 5:15 PM, Don Wieland d...@dwdataconcepts.comwrote:

 On Apr 16, 2010, at 1:26 PM, Bastien Koert wrote:

  Run a cronjob at midnight and send the email. Track who it got sent
 to, so you don't duplicate it. Easy peasy!


 This is fine if the email is to be sent at midnight.

 I am looking for more refinement.

 For example:

 A user signs up for an event - 4/16/2010 @ 10:45am

 There is an option:

 Send me a reminder email X minutes/hours/days/weeks/months/years prior to
 the Event.

 so:

 30 minute(s) = email sent at 4/16/2010 @ 10:15am
 2 hour(s) = email sent at 4/16/2010 @ 8:45am
 3 day(s) = email sent at 4/13/2010 @ 10:45am
 1 week(s) = email sent at 4/9/2010 @ 10:45am
 1 month(s) = email sent at 3/16/2010 @ 10:45am
 1 year(s) = email sent at 4/16/2009 @ 10:45am

 This is really what I need...


 Don Wieland
 D W   D a t a   C o n c e p t s
 ~
 d...@dwdataconcepts.com
 Direct Line - (949) 305-2771

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


 What about making ics files available for download?  Users could easily
 import the event into the calendar of choice, and they could also (using the
 calendar software they're already familiar with) set the alarm.  For
 instance, I can set the calendar on my cell to ring my phone to alert me to
 events (my preference over email reminders for important events because I
 sometimes get flooded with email.)

 Your scripts could generate the files containing event info and then
 automatically start the download.

 This allows the users to determine the mode of alarm that works best for
 them in their native calendar app, and you're still greatly facilitating the
 process by providing all of the info so they merely have to drag and drop
 for many apps.

 I realize you asked specifically for a server-side email alarm solution (I
 apologize for the tangent if your needs preclude this type of approach), but
 I thought I'd toss out the idea as this approach has proved more effective
 and efficient for websites I maintain.

 Adam

 --
 Nephtali:  PHP web framework that functions beautifully
 http://nephtaliproject.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Array differences

2010-04-14 Thread Ryan Sun
Maybe this one works?
array_diff(array_unique($array1 + $array2), array_intersect($array1, $array2))

On Wed, Apr 14, 2010 at 4:39 AM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:
 On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote:

 I have the following scenario:



      $array1 = array(12, 34, 56, 78, 90);

      $array2 = array(12, 23, 56, 78, 89);



      $result = array_diff($array1, $array2);



      print_r($result);





 This returns:



      Array

      (

          [1] = 34

          [4] = 90

      )





 However what I really want is a two-way comparison.  I want elements that
 don't exist in either to be returned:



 34 and 90 because they don't exist in $array2, AND 23 and 89 because they
 don't exist in $array1.  So, is that a two step process of first doing an
 array_diff($array1, $array2) then reverse it by doing array_diff($array2,
 $array1) and merge/unique the results?  Any caveats with that?



      $array1 = array(12, 34, 56, 78, 90);

      $array2 = array(12, 23, 56, 78, 89);



      $diff1 = array_diff($array1, $array2);

      $diff2 = array_diff($array2, $array1);



      $result = array_unique(array_merge($diff1, $diff2));



      print_r($result);





 -- A



 I don't see any problems with doing it that way. This will only work as
 you intended if both arrays have the same number of elements I believe,
 otherwise you might end up with a situation where your final array has
 duplicates of the same number:

 $array1 = $array(1, 2, 3, 4, 5, 6);
 $array2 = $aray(1, 3, 2, 5);

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] how to overload accessible methods

2010-04-13 Thread Ryan Sun
As we all know, __call() can overload non-accessible methods,
eg.
Class User
{
public function __call($name, $args)
{
//validate user
$this-_validate();

$this-_{$name}($args);
}
private function _validate()
{
//
}
private function _update($args)
{
//
}
}

$user = new User();
$user-update() // will call _validate before _update automatically

BUT, if I want to make this update a public function, how can I call
the validate without call it inside update function explicitly?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: how to overload accessible methods

2010-04-13 Thread Ryan Sun
I'm writing an abstract parent class which only contain a validate
method, other developers will extend this class and add many new
public methods, every new methods will need to perform a validate
first.  Won't it be good if validate get called automatically before
every method call so that they don't have to write more code and they
won't miss this validate?

On Tue, Apr 13, 2010 at 11:46 AM, Nathan Rixham nrix...@gmail.com wrote:
 Ryan Sun wrote:
 As we all know, __call() can overload non-accessible methods,
 eg.
 Class User
 {
     public function __call($name, $args)
     {
         //validate user
         $this-_validate();

         $this-_{$name}($args);
     }
     private function _validate()
     {
         //
     }
     private function _update($args)
     {
         //
     }
 }

 $user = new User();
 $user-update() // will call _validate before _update automatically

 BUT, if I want to make this update a public function, how can I call
 the validate without call it inside update function explicitly?


 why would you want to, is there a technical reason for wanting magic
 functionality instead of normal functionality (+ wouldn't it make the
 code much easier to maintain and debug if developers can see what is
 called where, instead of just magic).

 to answer though, you're best bet is probably to make an abstract class
 with magic functionality and then extend with an implementing public class.

 abstract class MagicUser
 {
    public function __call($name, $args)
    {
        //validate user
        $this-_validate();
        $this-_{$name}($args);
    }

    private function _validate()
    {
        //
    }
    private function _update($args)
    {
        //
    }
 }

 class User extends MagicUser
 {
    public function update($args)
    {
        parent::update($args);
    }
 }



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: how to overload accessible methods

2010-04-13 Thread Ryan Sun
this is a class for corntab job, and the validation is very simple,
just check if the status of user is active when cron job runs, if not,
throws an exception, other developers won't want to overwrite this
validation.
which method of user class will be called is configurable via website
backed page(we write the name of methods directly in to  schedule
table).
Using private methods will solve the problem but since we write public
methods for all the other cron classes, I just want to keep the style
to make less confusion.

On Tue, Apr 13, 2010 at 12:11 PM, Nathan Rixham nrix...@gmail.com wrote:
 Ryan Sun wrote:
 I'm writing an abstract parent class which only contain a validate
 method, other developers will extend this class and add many new
 public methods, every new methods will need to perform a validate
 first.  Won't it be good if validate get called automatically before
 every method call so that they don't have to write more code and they
 won't miss this validate?

 This may call for a back to roots approach, what exactly are you trying
 to accomplish, as in: what is the validation doing?

 perhaps if we see the full picture, we can recommend another perhaps
 more suited approach to the full thing, feel free to post the full code
 if you want / can, the more info the better!

 Regards,

 Nathan


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Sort two coupled arrays {my solution]

2010-04-07 Thread Ryan Sun
rsort(array_combine(array2, array1));

you should expect array(
  'Personal Email' = 75,
  'USPS mail' = 40,
  'Personal Phone' = 31,
  'Web site' = 31,
  'Text Message' = 31
)

logically, the items are your key but not the count of votes


On Wed, Apr 7, 2010 at 6:29 PM, tedd tedd.sperl...@gmail.com wrote:
 At 5:35 PM -0400 4/7/10, Andrew Ballard wrote:

 On Wed, Apr 7, 2010 at 5:02 PM, Paul M Foster pa...@quillandmouse.com
 wrote:
 Array indexes have to be unique regardless of whether they are numeric
 or strings.

 Ahhh, so you start to see the problem, eh?

 Let's look at the problem again (a vote collection problem):

 Array 1
 (
    [1] = 75
    [2] = 31
    [3] = 31
    [4] = 31
    [5] = 40
 )

 Array 1 is an array that contains the count of votes ($votes[] ) for the
 index. IOW, index 1 received 75 votes.

 Array 2
 (
    [1] = Personal Email
    [2] = Personal Phone
    [3] = Web site
    [4] = Text Message
    [5] = USPS mail
 )

 Array 2 is an array that contains the names for the items ($items[] ) voted
 upon. As such, index 1 (Personal Email) received 75 votes.

 Now, I have this data in two different arrays and I wanted to combine the
 data into one array and then preform a descend sort.

 This is the way I solved it:

 $final = array();

 for($i =1; $i =5; $i++)
   {
   $final[$i][] = $votes[$i];
   $final[$i][] = $items[$i];
   }

 echo(pre);
 echo('br');
 print_r($final);
 echo('br');

 array_multisort($final, SORT_DESC);

 echo('br');
 print_r($final);
 echo('br');
 echo(/pre);

 I was hoping that someone might present something clever.

 Cheers,

 tedd


 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP MySQL Insert Statements

2010-03-16 Thread Ryan Sun
Always make sure your dynamic sql string in php code are as expected
var_dump($sql) before query

On Thu, Mar 11, 2010 at 10:13 PM, Martine Osias webi...@gmail.com wrote:
 Hi,

 My insert statements on this web page don't execute. The select statements
 do work. This tells me that the database connection is working. The username
 and password are the administrator's. What else could prevent the insert
 statements from executing?

 Thank you.


 Martine

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] best way to set up an include path for a multi-level project?

2010-03-16 Thread Ryan Sun
On Tue, Mar 16, 2010 at 1:57 PM, Robert P. J. Day rpj...@crashcourse.ca wrote:

 and all PHP scripts would start off with something like:

 set_include_path(get_include_path() . PATH_SEPARATOR . getenv('PROJ_DIR'));


just utilize include_path directive in php.ini

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Database vs. Array

2010-03-16 Thread Ryan Sun
Maybe you want to optimize your script first, and I don't think read 
entire data set into array would save you much time.
Don't create new variables when its unnecessary, cache data when its 
necessary, try memcached,
and I think heavy php cli scripts are always likely to resume a lot of 
resource, I think GC of php is not so reliable... or maybe I don't know 
how to use it.


On 3/16/2010 7:13 PM, Richard S. Crawford wrote:

I have a script that connects to an external database to process about 4,000
records. Each record needs to be operated on pretty heavily, and the script
overall takes about half an hour to execute. We've hit a wall where the
script's memory usage exceeds the amount allocated to PHP. I've increased
the allotted memory to 32MB, but that's not ideal for our purposes.

So my thought is, would it be more efficient, memory-wise, to read the
database entries into an array and process the array records, rather than
maintain the database connection for the entire run of the script. This is
not an issue I've come across before, so any thoughts would be much
appreciated.

Thanks in advance.

   



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] long polling solution for LAMP with limited privilege

2010-03-15 Thread Ryan Sun
I wonder if you guys have a
long-polling(http://meteorserver.org/interaction-modes/) solution for
a shared hosting(eg. hostmonster)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] how to download files require login

2010-03-01 Thread Ryan Sun
For URLs like 
'http://download.fotolia.com/DownloadContent/1/h7G0bWGsGof8VvSqw32xFZ0KvD5eqbvN',
it requires user login to download.
Then how do I download it remotely via php server if I have the
username and password in hand?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help preserving sentence structure

2010-02-26 Thread Ryan Sun
http://us.php.net/manual/en/function.htmlentities.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] FTP Site

2010-02-16 Thread Ryan Sun
I think you will need the help from a client side app, like java
applet or flash, php can transfer file from your web server to your
ftp server but people will have difficulty uploading file via bare
browser

On Tue, Feb 16, 2010 at 3:12 PM, Ben Miller biprel...@gmail.com wrote:
 Hi,



 I'm building a site for a client that has a need to allow their users to
 upload large files (up to 100mb or more) and store them on the server.  I've
 never had a need to work with PHP's FTP functions until now and, before I go
 reading the manual to learn how, I wanted to see if this something that I
 can handle with just PHP, or if I'm going to need to adopt a third party
 Ajax app or something like that?  Any thoughts or even a point in the right
 direction would be greatly appreciated.  Thanks,



 Ben



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to secure this

2010-02-12 Thread Ryan Sun
authenticate by remote domain name or remote ip

$_SERVER['HTTP_REFERER']

then your clients will not have to put their username/password in clear text
http://www.mydomain.com?h=300w=250
and you will just check if you have their domain on your list

I'm not sure if there is better one but
 'HTTP_REFERER'
The address of the page (if any) which referred the user agent to
the current page. This is set by the user agent. Not all user agents
will set this, and some provide the ability to modify HTTP_REFERER as
a feature. In short, it cannot really be trusted. 


On Fri, Feb 12, 2010 at 4:26 PM, Robert Cummings rob...@interjinn.com wrote:
 Ashley Sheridan wrote:

 On Fri, 2010-02-12 at 16:12 -0500, Robert Cummings wrote:

 John Allsopp wrote:

 Hi everyone

 There may be blinding bits of total ignorance in this so don't ignore
 the obvious.

 This is a security question, but a sentence of background: I'm writing
 software for a mapping/location website and I want to be able to provide
 something others can plug into their website that would display their map.

 So I'm providing a URL like
 http://www.mydomain.com?h=300w=250username=namepassword=password

 The idea is they can define their own height and width and it plugs in
 as an iframe.

 That takes the username and password and throws it over web services to
 get back the data from which we can create the map.

 My question (and it might be the wrong question) is how can I not give
 away the password to all and sundry yet still provide a self-contained URL?

 MD5() (or SHA()) hash the information and supply that along with the
 settings. Then you know it was generated by your site. So you can do the
 following:

 ?php

 $height = 300;
 $width = 250;
 $username = 'username';
 $key = md5( SECRET_SALT-$heigh-$width-$username );

 $url =
 http://www.mydomain.com?h=$heightw=$widthusername=$usernamekey=$key;;

 ?

 Then when you get this URL via the iframe, you re-compute the expected
 key and then compare it against the given key. Since only you know the
 SECRET_SALT value then nobody should be able to forge the key.

 Cheers,
 Rob.
 --
 http://www.interjinn.com
 Application and Templating Framework for PHP



 What about requiring them to sign in the first time to use your service,
 and then give them a unique id which i tied to their details. You could
 then get them to pass across this id in the url. You could link their
 account maybe to some sorts of limits with regards to what they can
 access maybe?

 Presumably they ARE logged in when you create this URL for them... otherwise
 someone else could generate it :)

 Cheers,
 Rob.
 --
 http://www.interjinn.com
 Application and Templating Framework for PHP

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to secure this

2010-02-12 Thread Ryan Sun
In that case, referer is for authentication, and id is for authorization, I
think

On Fri, Feb 12, 2010 at 6:23 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

  On Fri, 2010-02-12 at 18:25 -0500, Ryan Sun wrote:

 authenticate by remote domain name or remote ip

 $_SERVER['HTTP_REFERER']

 then your clients will not have to put their username/password in clear 
 texthttp://www.mydomain.com?h=300w=250
 and you will just check if you have their domain on your list

 I'm not sure if there is better one but
  'HTTP_REFERER'
 The address of the page (if any) which referred the user agent to
 the current page. This is set by the user agent. Not all user agents
 will set this, and some provide the ability to modify HTTP_REFERER as
 a feature. In short, it cannot really be trusted. 


 On Fri, Feb 12, 2010 at 4:26 PM, Robert Cummings rob...@interjinn.com wrote:
  Ashley Sheridan wrote:
 
  On Fri, 2010-02-12 at 16:12 -0500, Robert Cummings wrote:
 
  John Allsopp wrote:
 
  Hi everyone
 
  There may be blinding bits of total ignorance in this so don't ignore
  the obvious.
 
  This is a security question, but a sentence of background: I'm writing
  software for a mapping/location website and I want to be able to provide
  something others can plug into their website that would display their 
  map.
 
  So I'm providing a URL like
  http://www.mydomain.com?h=300w=250username=namepassword=password
 
  The idea is they can define their own height and width and it plugs in
  as an iframe.
 
  That takes the username and password and throws it over web services to
  get back the data from which we can create the map.
 
  My question (and it might be the wrong question) is how can I not give
  away the password to all and sundry yet still provide a self-contained 
  URL?
 
  MD5() (or SHA()) hash the information and supply that along with the
  settings. Then you know it was generated by your site. So you can do the
  following:
 
  ?php
 
  $height = 300;
  $width = 250;
  $username = 'username';
  $key = md5( SECRET_SALT-$heigh-$width-$username );
 
  $url =
  http://www.mydomain.com?h=$heightw=$widthusername=$usernamekey=$key;;
 
  ?
 
  Then when you get this URL via the iframe, you re-compute the expected
  key and then compare it against the given key. Since only you know the
  SECRET_SALT value then nobody should be able to forge the key.
 
  Cheers,
  Rob.
  --
  http://www.interjinn.com
  Application and Templating Framework for PHP
 
 
 
  What about requiring them to sign in the first time to use your service,
  and then give them a unique id which i tied to their details. You could
  then get them to pass across this id in the url. You could link their
  account maybe to some sorts of limits with regards to what they can
  access maybe?
 
  Presumably they ARE logged in when you create this URL for them... otherwise
  someone else could generate it :)
 
  Cheers,
  Rob.
  --
  http://www.interjinn.com
  Application and Templating Framework for PHP
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 



 I think Google does both the referrer check coupled with an id passed in
 the URL. At least, this is what it did the last time I embedded one of their
 maps.


   Thanks,
 Ash
 http://www.ashleysheridan.co.uk





[PHP] create archive file in memory with zipArchive class

2010-02-09 Thread Ryan Sun
I want to generate credential zip file for user on the fly with
zipArchive and render it for download, so I created following code
-
$zip = new ZipArchive();
$filename = '/tmp/xxx.zip';
if ($zip-open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
 throw new Exception();
}
if($zip)
{
    $zip-addFromString('xxx.xx', $fileString);
}
$zip-close();
$fileString = file_get_contents($filename);
unlink($filename);

$this-getResponse()-setHeader('Content-Type', 'application/zip');
$this-getResponse()-setHeader('Content-Disposition','attachment;filename=xxx.zip');
$this-getResponse()-setBody($fileString);
-
it works, but I think creating the file in memory is a better
approach, so I changed the 2nd lineI(using php 5.2.0) to
$filename = 'php://temp/xxx.zip';
then the php just won't archive the file and the file downloaded is
just a plain text file.

so
question 1, how to create zip Archive file in memory on the fly and
download it (I don't have to save it on disk)?
question 2, if there is no way to create in memory, is it safe to just
unlink() the file?

thanks in advance.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] create archive file in memory with zipArchive class

2010-02-09 Thread Ryan Sun
thanks, Richard, maybe you are right, the actual file name is not my job
I changed it to 'php://temp' but its still the same, nothing has been changed...

On Tue, Feb 9, 2010 at 11:13 AM, Richard Quadling
rquadl...@googlemail.com wrote:
 On 9 February 2010 15:42, Ryan Sun ryansu...@gmail.com wrote:
 I want to generate credential zip file for user on the fly with
 zipArchive and render it for download, so I created following code
 -
 $zip = new ZipArchive();
 $filename = '/tmp/xxx.zip';
 if ($zip-open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
  throw new Exception();
 }
 if($zip)
 {
     $zip-addFromString('xxx.xx', $fileString);
 }
 $zip-close();
 $fileString = file_get_contents($filename);
 unlink($filename);

 $this-getResponse()-setHeader('Content-Type', 'application/zip');
 $this-getResponse()-setHeader('Content-Disposition','attachment;filename=xxx.zip');
 $this-getResponse()-setBody($fileString);
 -
 it works, but I think creating the file in memory is a better
 approach, so I changed the 2nd lineI(using php 5.2.0) to
 $filename = 'php://temp/xxx.zip';
 then the php just won't archive the file and the file downloaded is
 just a plain text file.

 so
 question 1, how to create zip Archive file in memory on the fly and
 download it (I don't have to save it on disk)?
 question 2, if there is no way to create in memory, is it safe to just
 unlink() the file?

 thanks in advance.

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



 According to http://docs.php.net/manual/en/wrappers.php.php, it looks
 like you should be using ...

 $filename = 'php://temp';

 That's it.

 The actual file name is not your job.



 --
 -
 Richard Quadling
 Standing on the shoulders of some very clever giants!
 EE : http://www.experts-exchange.com/M_248814.html
 EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
 Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
 ZOPA : http://uk.zopa.com/member/RQuadling


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Magento shopping cart

2010-02-02 Thread Ryan Sun
Your designer will definitely be able to skin it, it has multi template and
skin system, is easy to customize css, images, and html code for each block

However, for changing the layout (position of each block), it will require
your designer have a little knowledge on Mage's xml layout system (magento
had published a book for designer), or you can leave this job to your
developer...

On Tue, Feb 2, 2010 at 6:04 PM, Skip Evans s...@bigskypenguin.com wrote:

 Hey all,

 So I'm more comfortable all the time with using Magento, more I read, and
 Ryan said, Its great, I have been using it for over 2 years very flexible
 platform very easy to manipulate, and the end user admin is second to none
 mate. ... Mate?...

 Are there Aussies on this list? ;)

 Anyway, what about skinning this animal. If I install it will our designer
 be able to put the site's custom look and feel into it?

 Ryan, what do you think?

 Skip


 Nathan Nobbe wrote:

 On Mon, Feb 1, 2010 at 3:22 PM, Skip Evans s...@bigskypenguin.com
 wrote:

  I'm not totally opposed to using Magento, though I can see my comments,
 especially if it's what the client wants.

 I have been looking over the site and it does have a lot of features so I
 can see it saving some serious time, especially given the extras he
 wants.

 So Nathan, having used it, do you have any tips for a Magento newbie when
 it comes to integrating it with a custom site?


 I havent used it yet, but we are considering using it as a second-gen
 platform at my new place of biz.  initial glimpses are promising, but it
 appears to be a somewhat complex offering compared to say wordpress w/ an
 e-commerce plugin.

 i imagine there may be other tradeoffs as well, like a number of general
 purpose plugins and probly more look  feel options in wordpress than
 magento.


  I haven't found any integration documentation for programmers yet.


 google for magento extension and it looks like you may have to hit the
 appropriate mailing list for more details.

 fwiw, afaik, x-cart is one of those older e-commerce platforms circa
 os-commerce / zencart days.  the code is ass, but frankly that damn thing
 has installations up all over the net (or did once upon a time, lol).

 -nathan


 --
 
 Skip Evans
 PenguinSites.com, LLC
 503 S Baldwin St, #1
 Madison WI 53703
 608.250.2720
 http://penguinsites.com
 
 Those of you who believe in
 telekinesis, raise my hand.
  -- Kurt Vonnegut

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Multiple Class Inheritance

2010-01-27 Thread Ryan Sun
1, you can implement multiple interfaces

2, you may want to return object instead of extending classes,
eg.
class Small_Class_Abstract
{
  public function getFormGeneration()
  {
return new Form_Generation();
  }
}
class Small_Class_A extends Small_Class_Abstract
{
}
$A = new Small_Class_A();
$form = $A-getFormGeneration()-newForm();

On Wed, Jan 27, 2010 at 7:52 AM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 Hi All,

 I know that a class can only inherit from one other single class in PHP,
 but how would I go about simulating a multiple class inheritance? For
 example, if I had several small classes that dealt with things like form
 generation, navbar generation, etc, how could I create a class in which
 these all existed?

 Or am I thinking about this the wrong way? Should I have keep the
 smaller classes, and have one larger object containing instances of each
 as and how are necessary?

 I've used classes before, but I'm fairly new to class inheritance, and
 more particularly, the complex inheritance like I describe here.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk





Re: [PHP] Creating an Entire .html page with PHP

2010-01-26 Thread Ryan Sun
Isn't there a framework doing that?

On Mon, Jan 25, 2010 at 8:00 PM, deal...@gmail.com deal...@gmail.comwrote:

 Hi Folks,

 I would like to create an entire .html page gathered from database content
 mixed with html etc. and be able to save the page...


 like:

 --- save all this pre made content as .html page

 html
 head
 ...  stuff
 /head
 body
 ...  stuff
 ...  stuff with database query results...
 ...  stuff
 /body
 /html

 Q: Is there a function that might help with saving the whole content as
 .html page?



 Thanks,
 deal...@gmail.com
 [db-10]



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] MySQL ID -- what happens when you run out of range?

2010-01-25 Thread Ryan Sun
For such a large data set, they would split into several sub tables,
otherwise the performance will be horrible

On Mon, Jan 25, 2010 at 3:39 PM, Robert Cummings rob...@interjinn.comwrote:

 Parham Doustdar wrote:

 Hello there,
 A friend called me today and was wondering what happens if the ID colomn
 of an MYSQL database, set to autoinc reaches the int limit. Will it return
 and begin choosing the ID's that have been deleted, or... what?
 Thanks!


 Ask Slashdot... I believe they hit the limit one day (several actually) for
 comments :)

 Cheers,
 Rob.
 --
 http://www.interjinn.com
 Application and Templating Framework for PHP


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] integrating shipping with shopping cart site - OT

2010-01-20 Thread Ryan Sun
Just use the shipping rate web service of your client's shipping carrier
why border building a custom shipping rate calculator

On Wed, Jan 20, 2010 at 10:24 AM, Angelo Zanetti ang...@zlogic.co.zawrote:

 Thanks guys, yes in general we will go with a lookup for each country, it
 wont be accurate but in future we can build rates for each province / state
 for each country which an admin would have to complete for each product
 (time consuming) but for now the solution will work.

 Thanks for the responses and thoughts, they are much appreciated.

 I see the UPS class is also quite interesting but its only if you using
 them
 :)

 Cheers
 Angelo


 -Original Message-
 From: Jochem Maas [mailto:joc...@iamjochem.com]
 Sent: 19 January 2010 04:53 AM
 To: Angelo Zanetti
 Cc: 'php-general'
 Subject: Re: [PHP] integrating shipping with shopping cart site - OT

 Op 1/18/10 10:47 AM, Angelo Zanetti schreef:
  Hi all,
 
  We are about to start a new project. Custom written shopping cart - quite
  simple actually. However we have a concern when it comes to calculating
 the
  shipping cost for an order.
 
  For each product we can determine the base cost based on weight,
 therefore
  we can determine the total weight of an order.
 
  However we are struggling to determine how to calculate the shipping
 based
  on where the delivery is going.
 
  In terms of DB and PHP would the best way to calculate it be done by
 having
  a list of countries to ship to and a rate for each? Then you can apply
 the
  rate to the current order (calculate according to the order weight).
 
  Problems arise when shipping to different parts of a country EG:
 
  New York vs California (quite far apart). Perhaps we should have a list
 of
  cities but that could be massive?
 
  I know there is a PHP class / system that integrates with UPS but I don't
  think the client is going to use UPS.
 
  Perhaps you can tell me how you have handled this issue in the past.
 
  Apologies if it is slightly off topic but it does still relate to PHP
  indirectly.

 I'd start with defining shippingcost 'sets', each defining a number of
 costs by weight bands, some 'table defs':

 set:
 -
 id  name

 set_bands:
 --
 set_id  upper_weightcost


 then it would be a case of linking (many-to-many relation) 'regions' to
 sets,
 if you approach this with a tree of regions you can effectively set values
 at
 a continent, country, state/province level ... as such you would only need
 to
 relate a 'shippingcostset' to a state if the shippingcosts are different to
 the given country's shippingcosts.

 world
  - north america
   - california
  - south america
  - europe
   - france
   - UK

 then your left with the problem of determining the smallest defined region
 a
 given
 address physically falls into .. using geo-spatial magic in the DB would be
 one
 way to do it.

 this is a hard problem (unless, maybe, the client is willing to sacrifice
 precision
 and instead using highly averaged shipping cost definitions to cover the
 real differences
 in costs - i.e. a fixed fee for all of europe, whereby such fee is just
 above the
 average real cost the client pays for shipping).

 my guess would be that building such a thing is hard, and would take lots
 of
 time ... best bet is to hook into the webservice of whatever shipping
 company the
 client intends to use ... even if you have to build your end of the
 webservice from
 scratch it will be many factors less hard that building a user-manageable,
 shipping cost
 algorythm.

 - sorry it's all a bit vague, I'm very tired :) my eyes are starting to
 bleed.


 
  Thanks in advance.
  Angelo
 
 
  http://www.wapit.co.za
  http://www.elemental.co.za
 
 
 


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP and javascript

2010-01-15 Thread Ryan Sun
I don't think you can call php cli from client javascript unless you have a
wrapper http interface

On Fri, Jan 15, 2010 at 2:07 PM, Andres Gonzalez and...@packetstorm.comwrote:

 How do I call PHP code that will run server side, from javascript code that
 is running client side?

 I have a lot of PHP server side code written and working within
 CodeIgniter.  Now, my project
 has changed and (for reasons unimportant to this discussion) we are now NOT
 going to
 use apache and CodeIgniter, but instead, we are going to have to use an
 http server that does
 not support PHP internally.  But I want to reuse my original PHP code. So I
 am thinking that I
 can execute the PHP code via a command line interface using the PHP cli
 interface instead of
 the PHP cgi interface. But, I will have to initiate this serversid call via
 javascript code running
 on the client.

 I know...kind of convoluted. But how would one do this if necessary?

 -Andres

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Display just 1 record in a query

2010-01-12 Thread Ryan Sun
though you can fetch twice to get the 2nd row
$row_cur = mysql_fetch_assoc($cur); //skip 1st row
$row_cur = mysql_fetch_assoc($cur);
echo $row_cur['tid'];

you should really modify your sql statement, like 'select xxx from xx order
by xx limit 1, 1'  (limit 1,1 retrieve your 2nd row if you are using mysql)

On Tue, Jan 12, 2010 at 4:52 PM, deal...@gmail.com deal...@gmail.comwrote:

 I did a query... then I display records like:

 table
  ?php do { ?
tr
  td?php echo $row_cur['tid']; ?/td
  tdnbsp;/td
/tr
?php } while ($row_cur = mysql_fetch_assoc($cur)); ?
 /table


 Q: but how I i just display a particular record with out the do / while
 loop?

 like just the 2nd record only:

 i tried
 ?php echo $row_cur['tid',2]; ?
 but this makes an error

 or $row_cur('tid',2) --- hmmm what's the syntax?



 Thanks,
 deal...@gmail.com
 [db-10]


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Formatting Decimals

2010-01-11 Thread Ryan Sun
$newprice =  sprintf($%.2f, 15.109);

On Sun, Jan 10, 2010 at 8:36 PM, Rick Dwyer rpdw...@earthlink.net wrote:

 Hello List.

 Probably an easy question, but I am not able to format a number to round up
 from 3 numbers after the decimal to just 2.

 My code looks like this:

 $newprice = $.number_format($old_price, 2, ., ,);

 and this returns $0.109 when I am looking for $0.11.


 I tried:

 $newprice = $.round(number_format($old_price, 2, ., ,),2);
 But no luck.

 Any help is appreciated.

 Thanks,

  --Rick



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Question about using JSON_ENCODE()

2010-01-08 Thread Ryan Sun
Yup,

you put result in an array
$result = array('status' = 'good');
and return encoded string
return Json_Encode($result);

your client will get a string
'{status: good}'
and you use your client tech(eg. javascrpt) to decode this string and finall
get an object

On Fri, Jan 8, 2010 at 3:43 PM, Anthony Papillion papill...@gmail.comwrote:

 I'm developing a basic webservice to compliment a mobile application I'm
 developing or iPhone. While I know how to encode simple variables and
 arrays, I'm not sure how to do what I'm needing to do. Basically, I want to
 encode a status message to return to the mobile client. Something like

 status good_request

 Right now, I'm thinking I should put this in an array and encode/return
 that. But is that the right way of thinking? Is there a more correct or
 better way to do this?

 Thanks!
 Anthony

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] POLL: To add the final ? or not...

2010-01-08 Thread Ryan Sun
if you use the newest PDT, you will find that a new php file has no final ?
I vote for your co-worker [?]

On Fri, Jan 8, 2010 at 3:49 PM, LinuxManMikeC linuxmanmi...@gmail.comwrote:


 http://framework.zend.com/manual/en/coding-standard.html#coding-standard.overview.scope
 This document provides guidelines for code formatting and
 documentation to individuals and teams contributing to Zend
 Framework.

 So as far as anything other than code being contributed to Zend
 Framework, its just a suggestion.  For your programming team, you're
 the boss, you make the decision.  The only benefit I see is preventing
 the white space mistake (as your co-worker's quote mentioned), but I
 agree with you on that point.  Just don't put any white space
 there... moron... :-)  Its an inconsequential option, pull rank, get
 back to work.

 On Fri, Jan 8, 2010 at 1:24 PM, Daevid Vincent dae...@daevid.com wrote:
  I'm having a debate with a co-worker about adding the final ? on a PHP
  page...
 
  To be honest, I am the lead, and I could pull rank and be done with the
  discussion, however I don't like to be that way. I would rather do the
  right thing. If my way of thinking is old-school (I've been coding since
  PHP/FI), and what he says is the newfangled proper PHP/Zend way, then I'd
  rather adopt that, despite how icky it makes me feel to leave an unclosed
  ?php just dangling and alone, all sad-like. In my mind, nobody gets
 left
  behind! :)
 
  Is there ANY side-effects to leaving the end ? off? Is it any more work
  for the compiler? And yes I know computers are hella-fast and all that,
 but
  I come from the gaming industry where squeeking out an extra FPS matters,
  and shaving off 0.01s per row of data in a table matters if you have more
  than 100 rows. A 1 second wait IS noticeable and a 10 second is even
 moreso
  -- just try to talk for 10 seconds straight without a pause. Or sit there
  and stare at a screen for 10 seconds!
 
  If the main argument is that it's to prevent white-space after the code,
  then most modern editors that I'm aware of will automatically trim
  white-space (or have a setting to do so). Plus this is ONLY a factor when
  you're trying to output a header and things like that. In 90% of your
 code,
  you don't deal with that. It's also obvious enough when you have an extra
  character/space because PHP pukes on the screen and TELLS you something
  about blah blah sent before header output or something to that effect.
 
  What do you guys all do?
 
  I also created a poll here http://www.rapidpoll.net/arc1opy
 
  -Original Message-
  From: Co-worker
  To: Daevid Vincent
 
  Actually, Zend states that you should omit the final ? on include pages.
  There is no harm in the action, and it prevents you from accidentally
  adding white space after the tag which will break the code.
 
 
 http://framework.zend.com/manual/en/coding-standard.php-file-formatting.htm
  l
 
 
  -Original Message-
  From: Daevid Vincent
  To: Co-worker
 
  Please DO include the final ? I noticed on several of your files that
 you
  have purposely omitted it. Yes, I know the files work without them, but
 it
  makes things easier to see the pairings for matching ?php . Plus it
 keeps
  things consistent and I'm not a big fan of special cases as this is,
  especially if it's a bad habit to get into since in all other cases it's
  required except this one lazy one. If you are concerned about white
 space
  sending in a header or something, well then just make sure there isn't
 any.
  I've had no problems and it makes you a more careful coder.
 
  Thanks,
 
  Daevid.
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] json_last_error

2009-12-04 Thread Ryan Sun
json_decode
(PHP 5 = 5.2.0, PECL json = 1.2.0)

so json_decode will be avaliable for php 5.2.0+

php is open source, I believe you can get an idea from their C source

On Fri, Dec 4, 2009 at 2:16 PM, Jim Lucas li...@cmsws.com wrote:

 Kirby Bakken wrote:
  None of the servers I run on have PHP 5.3, and I have no idea when
  they'll be updated.  The json_last_error function is in 5.3.  What can I
  do to provide a temporary json_last_error function until my servers get
  updated to 5.3?  Is there source available for json_last_error somewhere?
 
  Thanks,
 
  Kirby
 

 I don't believe you will be able to provide this functionality without
 recreating the json_decode() function also.

 json_last_error() looks like it retrieves information that is from the last
 attempt to run json_decode() on a given string.  My guess is that
 json_decode()
 set an internal variable that json_last_error() picks up and returns.

 Without having json_decode() say what the problem was/is then you can never
 recreate the json_last_error() function.

 Jim Lucas

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Powerpoint from PHP?

2009-12-02 Thread Ryan Sun
php on windows server may have the capability...

On Wed, Dec 2, 2009 at 11:30 AM, Skip Evans s...@bigskypenguin.com wrote:

 Yeah, from Googling around I'm getting the impression there is not a PHP
 library capable of doing this. I guess the next best thing we can do is just
 let them download files with collections of slides and create the
 presentation themselves.

 Skip


 Ashley Sheridan wrote:


 I don't think that's possible. You could look at the Microsoft XML formats
 to see if you can take that apart, but it would be tricky. It might be far
 easier to do it with the Open Office presentation format, but again, I don't
 know of any libraries that are capable of doing this.

 Thanks,
 Ash
 http://www.ashleysheridan.co.uk



 --
 
 Skip Evans
 PenguinSites.com, LLC
 503 S Baldwin St, #1
 Madison WI 53703
 608.250.2720
 http://penguinsites.com
 
 Those of you who believe in
 telekinesis, raise my hand.
  -- Kurt Vonnegut

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Disabling button onclick in IE

2009-12-01 Thread Ryan Sun
Andrew is right, another solution is to move your code from onclick to
onsubmit event,
form name=ticket_form onsubmit=this.submit.disabled=true;

On Tue, Dec 1, 2009 at 4:06 PM, Skip Evans s...@bigskypenguin.com wrote:

 Hey all,

 You probably remember me asking about disabling a submit button when it is
 clicked to prevent double clicks submitting  a form for CC processing.

 I put the following code into the submit button and it works fine on
 FireFox, but... hold your breath... not on IE.

 The button gets disabled but the form just sits there, not submitting. At
 first I just had

 onclick=this.disabled=true;

 and that worked in FF also, but not in IE. Then I added the

 document.ticket_form.submit();

 But even that doesn't work with IE.

 Below is the whole snippet for the button.

 input type=submit name=submit value=Purchase Ticket(s)
 id=submit_tickets onclick=this.disabled=true;
 document.ticket_form.submit();

 Any suggestions would be greatly appreciated.

 Thanks,
 Skip

 --
 
 Skip Evans
 PenguinSites.com, LLC
 503 S Baldwin St, #1
 Madison WI 53703
 608.250.2720
 http://penguinsites.com
 
 Those of you who believe in
 telekinesis, raise my hand.
  -- Kurt Vonnegut




 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Create client certificate with openssl

2009-11-25 Thread Ryan Sun
check these options
*-pass arg, -passin arg*

the PKCS#12 file (i.e. input file) password source. For more information
about the format of *arg* see the *PASS PHRASE ARGUMENTS* section in *
openssl*(1) http://www.openssl.org/docs/apps/openssl.html#.
*-passout arg*

pass phrase source to encrypt any outputed private keys with. For more
information about the format of *arg* see the *PASS PHRASE ARGUMENTS*section in
*openssl*(1) http://www.openssl.org/docs/apps/openssl.html#.
I believe you can ask user their password on previous page and utilize the
'pass' option and it won't ask for a password again

HTH


On Wed, Nov 25, 2009 at 2:53 AM, Tanveer Chowdhury 
tanveer.chowdh...@gmail.com wrote:

 Hi all,

 I have an apache server and for that I created CA as the signing authority
 using openssl.

 Now I created a  php page which will generate client certificates with key
 and will sign by CA. Now the output is in .pem .
 Now how to convert it in .p12 for exporting it in client browser..

 Again, If using exec gives another problem which is it asks for export
 password so how to give this via php.

 Thanks in advance.
 Below is the code:

  ?
 Header(Content-Type: text/plain);
 $CA_CERT = /usr/local/openssl/misc/demoCA/cacert.pem;
 $CA_KEY  = /usr/local/openssl/misc/demoCA/private/cakey.pem;
 $req_key = openssl_pkey_new();
 if(openssl_pkey_export ($req_key, $out_key)) {
$dn = array(
countryName= AU,
stateOrProvinceName= AR,
organizationName   = Widget Ltd,
organizationalUnitName = Test,
commonName = John Smith
);
$req_csr  = openssl_csr_new ($dn, $req_key);
$req_cert = openssl_csr_sign($req_csr, file://$CA_CERT,
 file://$CA_KEY, 365);
if(openssl_x509_export ($req_cert, $out_cert)) {
echo $out_key\n;
echo $out_cert\n;
$myFile2 = /tmp/testFile.pem;
   // $myFile1 = /tmp/testKey.pem;

 $fh2 = fopen($myFile2, 'w') or die(can't open file);
 fwrite($fh2, $out_key);
 $fh1 = fopen($myFile2, 'a') or die(can't open file);
 fwrite($fh1, $out_cert);
 fclose($fh1);
 fclose($fh2);

 $command = `openssl pkcs12 -export test -in /tmp/testFile.pem -out
 client-cert.p12`;
 exec( $command );

}
 elseecho Failed Cert\n;
}
 else
echo FailedKey\n;
 ?