php-general Digest 27 Jun 2011 15:01:17 -0000 Issue 7378

2011-06-27 Thread php-general-digest-help

php-general Digest 27 Jun 2011 15:01:17 - Issue 7378

Topics (messages 313742 through 313754):

Re: asynchronous launch of a script
313742 by: Jim Giner
313743 by: Jim Lucas
313744 by: Tamara Temple
313746 by: Stuart Dallas
313749 by: Richard Quadling

Re: Php filter validate url
313745 by: Tim Streater
313754 by: Plamen Ivanov

Re: [PHP-DB] Re: radio form submission
313747 by: Richard Quadling
313748 by: Steve Staples
313751 by: Tim Streater

Re: Memory limit Problem
313750 by: Graham Drabble
313752 by: Lester Caine
313753 by: Richard Quadling

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
You mean - you want a second thread to run independently of your current 
running script?  A wonderful thing to do and helpful for long intenesive 
processes but do you really want to go thru the hassles of managing two 
processes?  Won't you have to verify the results of your offshoot and react 
to unexpected circumstances?  Otherwise, what are  you doing that would not 
require such complex management? 


---End Message---
---BeginMessage---

On 6/26/2011 7:58 PM, Jim Giner wrote:

You mean - you want a second thread to run independently of your current
running script?  A wonderful thing to do and helpful for long intenesive
processes but do you really want to go thru the hassles of managing two
processes?  Won't you have to verify the results of your offshoot and react
to unexpected circumstances?  Otherwise, what are  you doing that would not
require such complex management?



Having an OpenBSD server I use a thing called nohup.

I have a shell script that starts/stops things for me

nohup /usr/bin/ssh -2 -N -f -L $L_IP:$L_PORT:$R_IP:$R_PORT 
root@localhost 1/dev/null


This starts a ssh tunnel port forwarding for me with a from and to port 
assignment.


But, one crucial thing you haven't told us is what OS you are trying to 
do this on.


Jim
---End Message---
---BeginMessage---


On Jun 26, 2011, at 11:52 PM, Jim Lucas wrote:


On 6/26/2011 7:58 PM, Jim Giner wrote:
You mean - you want a second thread to run independently of your  
current
running script?  A wonderful thing to do and helpful for long  
intenesive
processes but do you really want to go thru the hassles of managing  
two
processes?  Won't you have to verify the results of your offshoot  
and react
to unexpected circumstances?  Otherwise, what are  you doing that  
would not

require such complex management?



Having an OpenBSD server I use a thing called nohup.

I have a shell script that starts/stops things for me

nohup /usr/bin/ssh -2 -N -f -L $L_IP:$L_PORT:$R_IP:$R_PORT  
root@localhost 1/dev/null


This starts a ssh tunnel port forwarding for me with a from and to  
port assignment.


But, one crucial thing you haven't told us is what OS you are trying  
to do this on.


Jim

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



Wow, that's really getting complex. All I want is for a php script to  
get launched and the calling script to return immediately. I don't  
necessarily have to know or care when the called script ends, just  
want the user to get an immediate return instead of waiting around for  
the lengthy script to run. I'm not talking AJAX or anything like that  
where the page depends on the eventual output from the called script.



---End Message---
---BeginMessage---
On Monday, 27 June 2011 at 07:10, Tamara Temple wrote:
 
 On Jun 26, 2011, at 11:52 PM, Jim Lucas wrote:
 
  On 6/26/2011 7:58 PM, Jim Giner wrote:
   You mean - you want a second thread to run independently of your 
   current
   running script? A wonderful thing to do and helpful for long 
   intenesive
   processes but do you really want to go thru the hassles of managing 
   two
   processes? Won't you have to verify the results of your offshoot 
   and react
   to unexpected circumstances? Otherwise, what are you doing that 
   would not
   require such complex management?
  
  Having an OpenBSD server I use a thing called nohup.
  
  I have a shell script that starts/stops things for me
  
  nohup /usr/bin/ssh -2 -N -f -L $L_IP:$L_PORT:$R_IP:$R_PORT 
  root@localhost 1/dev/null
  
  This starts a ssh tunnel port forwarding for me with a from and to 
  port assignment.
  
  But, one crucial thing you haven't told us is what OS you are trying 
  to do this on.
 Wow, that's really getting complex. All I want is for a php script to 
 get launched and the calling script to return immediately. I don't 
 necessarily have to know or care when the called script ends, just 
 want the user to get an 

php-general Digest 28 Jun 2011 03:07:49 -0000 Issue 7379

2011-06-27 Thread php-general-digest-help

php-general Digest 28 Jun 2011 03:07:49 - Issue 7379

Topics (messages 313755 through 313770):

Re: Php filter validate url
313755 by: Shawn McKenzie
313756 by: Plamen Ivanov
313757 by: Jim Lucas
313760 by: Plamen Ivanov

How to implement Authentication of UNIX users?
313758 by: With No Name
313759 by: vikash.iitb.gmail.com
313761 by: With No Name
313763 by: Stuart Dallas

Benchmark two functions against each other?
313762 by: Scott Baker
313766 by: Stuart Dallas
313767 by: Scott Baker
313768 by: Stuart Dallas

PHP as  CGI-CLI on FreeBSD/Apache22
313764 by: Grant Peel
313765 by: Nilesh Govindarajan

help for memcached Segmentation fault
313769 by: xucheng
313770 by: xucheng

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
On 06/27/2011 10:01 AM, Plamen Ivanov wrote:
 On Sun, Jun 26, 2011 at 5:44 PM, Shawn McKenzie nos...@mckenzies.net wrote:

 On 06/26/2011 12:31 PM, Adam Tong wrote:
 Hi,

 I wanted tu use php filters for validation to avoid regular expresions.
 Is it possible that FILTER_VALIDATE_URL only checks if the string has
 http:// and do not check for the format domain.something?
 
 $url = 'http://wwwtestcom';
 $url = filter_var($url,FILTER_VALIDATE_URL);
 echo $url;
 -

 Or I am doing something wrong

 Thank you

 Unless I'm totally misunderstanding what you want (validate that a
 string starts with http://) try:

 if(strpos($url, 'http://') === 0) {
   //starts with http://
 } esle {
   // does not start with http://
 }

 --
 Thanks!
 -Shawn
 http://www.spidean.com

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

 
 Another possible solution could be:
 
 $ary = explode('://', $url);
 if (1 = count($ary)) {
 echo 'No schema specified!';
 } else {
 // Schema specified.
 // $ary[0] is the protocol
 $allowed = array('http', 'https');
 if (FALSE == in_array($ary[0], $allowed) {
 // Protocol not valid!
 exit(1); // or return FALSE; whatever...
 }
 // $ary[1] is the uri, validate with filter_var().
 }
 
 Hope this helps.

May make more sense to use parse_url() than explode.

-- 
Thanks!
-Shawn
http://www.spidean.com
---End Message---
---BeginMessage---
On Mon, Jun 27, 2011 at 11:14 AM, Shawn McKenzie nos...@mckenzies.net wrote:
 On 06/27/2011 10:01 AM, Plamen Ivanov wrote:
 On Sun, Jun 26, 2011 at 5:44 PM, Shawn McKenzie nos...@mckenzies.net wrote:

 On 06/26/2011 12:31 PM, Adam Tong wrote:
 Hi,

 I wanted tu use php filters for validation to avoid regular expresions.
 Is it possible that FILTER_VALIDATE_URL only checks if the string has
 http:// and do not check for the format domain.something?
 
 $url = 'http://wwwtestcom';
 $url = filter_var($url,FILTER_VALIDATE_URL);
 echo $url;
 -

 Or I am doing something wrong

 Thank you

 Unless I'm totally misunderstanding what you want (validate that a
 string starts with http://) try:

 if(strpos($url, 'http://') === 0) {
   //starts with http://
 } esle {
   // does not start with http://
 }

 --
 Thanks!
 -Shawn
 http://www.spidean.com

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


 Another possible solution could be:

 $ary = explode('://', $url);
 if (1 = count($ary)) {
     echo 'No schema specified!';
 } else {
     // Schema specified.
     // $ary[0] is the protocol
     $allowed = array('http', 'https');
     if (FALSE == in_array($ary[0], $allowed) {
         // Protocol not valid!
         exit(1); // or return FALSE; whatever...
     }
     // $ary[1] is the uri, validate with filter_var().
 }

 Hope this helps.

 May make more sense to use parse_url() than explode.

 --
 Thanks!
 -Shawn
 http://www.spidean.com


http://php.net/manual/en/function.parse-url.php
This function is not meant to validate the given URL...

I would use parse_url() after URL validation.
---End Message---
---BeginMessage---
On 6/27/2011 8:25 AM, Plamen Ivanov wrote:
 On Mon, Jun 27, 2011 at 11:14 AM, Shawn McKenzie nos...@mckenzies.net wrote:
 On 06/27/2011 10:01 AM, Plamen Ivanov wrote:
 On Sun, Jun 26, 2011 at 5:44 PM, Shawn McKenzie nos...@mckenzies.net 
 wrote:

 On 06/26/2011 12:31 PM, Adam Tong wrote:
 Hi,

 I wanted tu use php filters for validation to avoid regular expresions.
 Is it possible that FILTER_VALIDATE_URL only checks if the string has
 http:// and do not check for the format domain.something?
 
 $url = 'http://wwwtestcom';
 $url = filter_var($url,FILTER_VALIDATE_URL);
 echo $url;
 -

 Or I am doing something wrong

 Thank you

 Unless I'm 

Re: [PHP] Re: asynchronous launch of a script

2011-06-27 Thread Tamara Temple


On Jun 26, 2011, at 11:52 PM, Jim Lucas wrote:


On 6/26/2011 7:58 PM, Jim Giner wrote:
You mean - you want a second thread to run independently of your  
current
running script?  A wonderful thing to do and helpful for long  
intenesive
processes but do you really want to go thru the hassles of managing  
two
processes?  Won't you have to verify the results of your offshoot  
and react
to unexpected circumstances?  Otherwise, what are  you doing that  
would not

require such complex management?



Having an OpenBSD server I use a thing called nohup.

I have a shell script that starts/stops things for me

nohup /usr/bin/ssh -2 -N -f -L $L_IP:$L_PORT:$R_IP:$R_PORT  
root@localhost 1/dev/null


This starts a ssh tunnel port forwarding for me with a from and to  
port assignment.


But, one crucial thing you haven't told us is what OS you are trying  
to do this on.


Jim

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



Wow, that's really getting complex. All I want is for a php script to  
get launched and the calling script to return immediately. I don't  
necessarily have to know or care when the called script ends, just  
want the user to get an immediate return instead of waiting around for  
the lengthy script to run. I'm not talking AJAX or anything like that  
where the page depends on the eventual output from the called script.




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



Re: [PHP] Re: Php filter validate url

2011-06-27 Thread Tim Streater
On 27 Jun 2011 at 00:15, Richard Riley rile...@googlemail.com wrote: 

 In addition your content type in your post is incorrect.

 Your header contains

 Content-Type: multipart/alternative;
 boundary=00151747b53cf2927204a6a46ebb

 But its not multipart. This happens a lot in this group and I dont
 experience it elsewhere so I dont know if its a php programmer thing,
 an gmane artifact or something the mailing list does.

I couldn't see anything in RFC2046, section 5.1.4, to suggest that 
multipart/alternative *requires* that there be more than one part. And why does 
it matter, anyway?

--
Cheers  --  Tim

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

Re: [PHP] Re: asynchronous launch of a script

2011-06-27 Thread Stuart Dallas
On Monday, 27 June 2011 at 07:10, Tamara Temple wrote:
 
 On Jun 26, 2011, at 11:52 PM, Jim Lucas wrote:
 
  On 6/26/2011 7:58 PM, Jim Giner wrote:
   You mean - you want a second thread to run independently of your 
   current
   running script? A wonderful thing to do and helpful for long 
   intenesive
   processes but do you really want to go thru the hassles of managing 
   two
   processes? Won't you have to verify the results of your offshoot 
   and react
   to unexpected circumstances? Otherwise, what are you doing that 
   would not
   require such complex management?
  
  Having an OpenBSD server I use a thing called nohup.
  
  I have a shell script that starts/stops things for me
  
  nohup /usr/bin/ssh -2 -N -f -L $L_IP:$L_PORT:$R_IP:$R_PORT 
  root@localhost 1/dev/null
  
  This starts a ssh tunnel port forwarding for me with a from and to 
  port assignment.
  
  But, one crucial thing you haven't told us is what OS you are trying 
  to do this on.
 Wow, that's really getting complex. All I want is for a php script to 
 get launched and the calling script to return immediately. I don't 
 necessarily have to know or care when the called script ends, just 
 want the user to get an immediate return instead of waiting around for 
 the lengthy script to run. I'm not talking AJAX or anything like that 
 where the page depends on the eventual output from the called script.

In my experience it's best to separate the processes and pass jobs to be done 
via a database, IPC, socket or other mechanism from the HTTP handler to the 
offline process. I use a job queueing system to accomplish this in most of my 
projects, where I can either schedule a repeating job or queue one-off jobs 
when needed. I wrote a post on my blog a little while ago describing that 
system...

http://stut.net/2009/05/29/php-job-queue/

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/


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



Re: [PHP] Re: [PHP-DB] Re: radio form submission

2011-06-27 Thread Richard Quadling
On 25 June 2011 22:11, Tamara Temple tamouse.li...@gmail.com wrote:
 On Jun 24, 2011, at 1:35 PM, Richard Quadling wrote:

 On 24 June 2011 18:23, Tamara Temple tamouse.li...@gmail.com wrote:

 On Jun 24, 2011, at 10:28 AM, Richard Quadling wrote:

 On 24 June 2011 15:44, Vitalii Demianets vi...@nppfactor.kiev.ua
 wrote:

 And furthermore, I think Carthage must be destroyed.

 Let's haul out the PHP war wagons!

 http://xkcd.com/327/

 I so wanted to rename my daughter Little Chelsea Tables after I read
 that one. Randall is one mean mofo.

 And because it is so relevant, I added it to the docs...

 http://docs.php.net/manual/en/security.database.sql-injection.php

 Well played, sir, well played. I think we should go through all the xkcd
 comics that relate to programming somehow and insert them in the php.net
 documentation :)

If you find them, ...

-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

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



Re: [PHP] Re: [PHP-DB] Re: radio form submission

2011-06-27 Thread Steve Staples
On Sat, 2011-06-25 at 16:11 -0500, Tamara Temple wrote:
 On Jun 24, 2011, at 1:35 PM, Richard Quadling wrote:
  On 24 June 2011 18:23, Tamara Temple tamouse.li...@gmail.com wrote:
  On Jun 24, 2011, at 10:28 AM, Richard Quadling wrote:
  On 24 June 2011 15:44, Vitalii Demianets vi...@nppfactor.kiev.ua  
  wrote:
  And furthermore, I think Carthage must be destroyed.
  Let's haul out the PHP war wagons!
  http://xkcd.com/327/
  I so wanted to rename my daughter Little Chelsea Tables after I  
  read that one. Randall is one mean mofo.
 
  And because it is so relevant, I added it to the docs...
 
  http://docs.php.net/manual/en/security.database.sql-injection.php
 
 Well played, sir, well played. I think we should go through all the  
 xkcd comics that relate to programming somehow and insert them in the  
 php.net documentation :)
 
 
Tamara, kind of like this one?

http://ca3.php.net/manual/en/control-structures.goto.php

I love that comic :)

Steve.


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



Re: [PHP] asynchronous launch of a script

2011-06-27 Thread Richard Quadling
On 27 June 2011 03:42, Tamara Temple tamouse.li...@gmail.com wrote:
 How do I launch a php script from another running php script asynchronously?

I'm a windows user. One of the things I wanted to to was to create
non-blocking process which I could communicate with using PHP.

I use pecl/wincache to allow me to read/write data (can't use the
pipes as these are blocking and no support for non-blocking).
I also use ...

$WshShell = new COM(WScript.Shell);
$oExec = $WshShell-Run(...);

To create a new instance of a non blocking PHP script.

By using ...

$appID = ini_get('wincache.setappid');

I can supply do something like this ...

$s_Task = C:\\PHP5\\php.exe -d wincache.setappid={$appID} -f  

to set the appid for the new instance, so it can communicate with this
instance via wincache.

All because there is no IPC in php for windows natively.

And it works for me really well.

I use pecl/win32service to create slow/long running tasks which have a
task controller controlling the work load.

I think I've re-invented a form of gearman in this work, but it works for me.


If you are on Windows and just want to get a script to run and really
don't care about when/how it ends, then

$WshShell = new COM(WScript.Shell);
$WshShell-Run(C:\\PHP5\\php-win.exe -f C:\\Scripts\\script.php, 0, false);

This will create an invisible non-blocking thread and return
immediately upon creating the thread.


-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

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



Re: [PHP] Memory limit Problem

2011-06-27 Thread Graham Drabble
On 23 Jun 2011 usene...@drabble.me.uk (Graham Drabble) wrote in 
news:xns9f0d980579291grahamdrabbleline...@id-77355.user.dfncis.de:

 On 23 Jun 2011 ja...@nixsecurity.org wrote in
 news:23a261c.efc7a3a4b4a0468ab221437b2018e...@webmail.lomag.net: 
 
 
 Check the value of the upload_max_filesize and post_max_size
 directives in the php.ini. 
 
 From phpinfo()
 
 upload_max_filesize 800M 800M 
 post_max_size 1000M 1000M 
 
 (fwiw the file I'm uploading is ~85MB)

Any ideas from anyone?

FWIW, the setup works on another server but doesn't work on this 
server. The upload_max_filesize, post_max_size and memory_limit are the 
same on both servers.

Both are PHP Version 5.2.6-1+lenny9 

-- 
Graham Drabble
http://www.drabble.me.uk/

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



Re: Re: [PHP] Re: [PHP-DB] Re: radio form submission

2011-06-27 Thread Tim Streater
On 27 Jun 2011 at 13:18, Steve Staples sstap...@mnsi.net wrote: 

 On Sat, 2011-06-25 at 16:11 -0500, Tamara Temple wrote:

 Well played, sir, well played. I think we should go through all the
 xkcd comics that relate to programming somehow and insert them in the
 php.net documentation :)


 Tamara, kind of like this one?

 http://ca3.php.net/manual/en/control-structures.goto.php

I haven't used a goto since I stopped writing FORTRAN in 1978.

--
Cheers  --  Tim

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

Re: [PHP] Memory limit Problem

2011-06-27 Thread Lester Caine

Graham Drabble wrote:

 From phpinfo()

  upload_max_filesize 800M 800M
  post_max_size 1000M 1000M

  (fwiw the file I'm uploading is ~85MB)

Any ideas from anyone?

FWIW, the setup works on another server but doesn't work on this
server. The upload_max_filesize, post_max_size and memory_limit are the
same on both servers.

Both are PHP Version 5.2.6-1+lenny9


Memory the same size on both machines? The error message you gave was certainly 
one of being 'out of resources' rather than hitting the file size limits ...


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

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



Re: [PHP] Memory limit Problem

2011-06-27 Thread Richard Quadling
On 27 June 2011 14:16, Graham Drabble usene...@drabble.me.uk wrote:
 On 23 Jun 2011 usene...@drabble.me.uk (Graham Drabble) wrote in
 news:xns9f0d980579291grahamdrabbleline...@id-77355.user.dfncis.de:

 On 23 Jun 2011 ja...@nixsecurity.org wrote in
 news:23a261c.efc7a3a4b4a0468ab221437b2018e...@webmail.lomag.net:


 Check the value of the upload_max_filesize and post_max_size
 directives in the php.ini.

 From phpinfo()

 upload_max_filesize 800M 800M
 post_max_size 1000M 1000M

 (fwiw the file I'm uploading is ~85MB)

 Any ideas from anyone?

 FWIW, the setup works on another server but doesn't work on this
 server. The upload_max_filesize, post_max_size and memory_limit are the
 same on both servers.

 Both are PHP Version 5.2.6-1+lenny9

I'd check for other differences in the phpinfo() output.

Anything that is different should be examined and verified as being appropriate.

-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

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



Re: [PHP] Re: Php filter validate url

2011-06-27 Thread Plamen Ivanov
On Sun, Jun 26, 2011 at 5:44 PM, Shawn McKenzie nos...@mckenzies.net wrote:

 On 06/26/2011 12:31 PM, Adam Tong wrote:
  Hi,
 
  I wanted tu use php filters for validation to avoid regular expresions.
  Is it possible that FILTER_VALIDATE_URL only checks if the string has
  http:// and do not check for the format domain.something?
  
  $url = 'http://wwwtestcom';
  $url = filter_var($url,FILTER_VALIDATE_URL);
  echo $url;
  -
 
  Or I am doing something wrong
 
  Thank you

 Unless I'm totally misunderstanding what you want (validate that a
 string starts with http://) try:

 if(strpos($url, 'http://') === 0) {
   //starts with http://
 } esle {
   // does not start with http://
 }

 --
 Thanks!
 -Shawn
 http://www.spidean.com

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


Another possible solution could be:

$ary = explode('://', $url);
if (1 = count($ary)) {
    echo 'No schema specified!';
} else {
    // Schema specified.
    // $ary[0] is the protocol
$allowed = array('http', 'https');
if (FALSE == in_array($ary[0], $allowed) {
// Protocol not valid!
exit(1); // or return FALSE; whatever...
}
    // $ary[1] is the uri, validate with filter_var().
}

Hope this helps.

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



Re: [PHP] Re: Php filter validate url

2011-06-27 Thread Shawn McKenzie
On 06/27/2011 10:01 AM, Plamen Ivanov wrote:
 On Sun, Jun 26, 2011 at 5:44 PM, Shawn McKenzie nos...@mckenzies.net wrote:

 On 06/26/2011 12:31 PM, Adam Tong wrote:
 Hi,

 I wanted tu use php filters for validation to avoid regular expresions.
 Is it possible that FILTER_VALIDATE_URL only checks if the string has
 http:// and do not check for the format domain.something?
 
 $url = 'http://wwwtestcom';
 $url = filter_var($url,FILTER_VALIDATE_URL);
 echo $url;
 -

 Or I am doing something wrong

 Thank you

 Unless I'm totally misunderstanding what you want (validate that a
 string starts with http://) try:

 if(strpos($url, 'http://') === 0) {
   //starts with http://
 } esle {
   // does not start with http://
 }

 --
 Thanks!
 -Shawn
 http://www.spidean.com

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

 
 Another possible solution could be:
 
 $ary = explode('://', $url);
 if (1 = count($ary)) {
 echo 'No schema specified!';
 } else {
 // Schema specified.
 // $ary[0] is the protocol
 $allowed = array('http', 'https');
 if (FALSE == in_array($ary[0], $allowed) {
 // Protocol not valid!
 exit(1); // or return FALSE; whatever...
 }
 // $ary[1] is the uri, validate with filter_var().
 }
 
 Hope this helps.

May make more sense to use parse_url() than explode.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Re: Php filter validate url

2011-06-27 Thread Plamen Ivanov
On Mon, Jun 27, 2011 at 11:14 AM, Shawn McKenzie nos...@mckenzies.net wrote:
 On 06/27/2011 10:01 AM, Plamen Ivanov wrote:
 On Sun, Jun 26, 2011 at 5:44 PM, Shawn McKenzie nos...@mckenzies.net wrote:

 On 06/26/2011 12:31 PM, Adam Tong wrote:
 Hi,

 I wanted tu use php filters for validation to avoid regular expresions.
 Is it possible that FILTER_VALIDATE_URL only checks if the string has
 http:// and do not check for the format domain.something?
 
 $url = 'http://wwwtestcom';
 $url = filter_var($url,FILTER_VALIDATE_URL);
 echo $url;
 -

 Or I am doing something wrong

 Thank you

 Unless I'm totally misunderstanding what you want (validate that a
 string starts with http://) try:

 if(strpos($url, 'http://') === 0) {
   //starts with http://
 } esle {
   // does not start with http://
 }

 --
 Thanks!
 -Shawn
 http://www.spidean.com

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


 Another possible solution could be:

 $ary = explode('://', $url);
 if (1 = count($ary)) {
     echo 'No schema specified!';
 } else {
     // Schema specified.
     // $ary[0] is the protocol
     $allowed = array('http', 'https');
     if (FALSE == in_array($ary[0], $allowed) {
         // Protocol not valid!
         exit(1); // or return FALSE; whatever...
     }
     // $ary[1] is the uri, validate with filter_var().
 }

 Hope this helps.

 May make more sense to use parse_url() than explode.

 --
 Thanks!
 -Shawn
 http://www.spidean.com


http://php.net/manual/en/function.parse-url.php
This function is not meant to validate the given URL...

I would use parse_url() after URL validation.

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



Re: [PHP] Re: Php filter validate url

2011-06-27 Thread Jim Lucas
On 6/27/2011 8:25 AM, Plamen Ivanov wrote:
 On Mon, Jun 27, 2011 at 11:14 AM, Shawn McKenzie nos...@mckenzies.net wrote:
 On 06/27/2011 10:01 AM, Plamen Ivanov wrote:
 On Sun, Jun 26, 2011 at 5:44 PM, Shawn McKenzie nos...@mckenzies.net 
 wrote:

 On 06/26/2011 12:31 PM, Adam Tong wrote:
 Hi,

 I wanted tu use php filters for validation to avoid regular expresions.
 Is it possible that FILTER_VALIDATE_URL only checks if the string has
 http:// and do not check for the format domain.something?
 
 $url = 'http://wwwtestcom';
 $url = filter_var($url,FILTER_VALIDATE_URL);
 echo $url;
 -

 Or I am doing something wrong

 Thank you

 Unless I'm totally misunderstanding what you want (validate that a
 string starts with http://) try:

 if(strpos($url, 'http://') === 0) {
   //starts with http://
 } esle {
   // does not start with http://
 }

 --
 Thanks!
 -Shawn
 http://www.spidean.com

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


 Another possible solution could be:

 $ary = explode('://', $url);
 if (1 = count($ary)) {
 echo 'No schema specified!';
 } else {
 // Schema specified.
 // $ary[0] is the protocol
 $allowed = array('http', 'https');
 if (FALSE == in_array($ary[0], $allowed) {
 // Protocol not valid!
 exit(1); // or return FALSE; whatever...
 }
 // $ary[1] is the uri, validate with filter_var().
 }

 Hope this helps.

 May make more sense to use parse_url() than explode.

 --
 Thanks!
 -Shawn
 http://www.spidean.com

 
 http://php.net/manual/en/function.parse-url.php
 This function is not meant to validate the given URL...
 
 I would use parse_url() after URL validation.
 

Shawn meant to use parse_url() in place of your explode statement.  He didn't
say to use parse_url() as a method to validate the url.

He said it would make more sense to do the following.

Also, use strict type matching if you want to compare against boolean(FALSE)

$allowed = array('http', 'https');

$scheme = parse_url($url, PHP_URL_SCHEME);

if (FALSE === in_array($scheme, $allowed) {
  // Protocol not valid!
  exit(1); // or return FALSE; whatever...
}

Seems a little less muddy to me.

Jim Lucas

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



[PHP] How to implement Authentication of UNIX users?

2011-06-27 Thread With No Name
Hello,

I try to code a Webinterface to access my Server @home which has a
couple of UNIX users.

However, I like to have only one website where users must go to whatch
the content of there Folders, which mean, I need a maping which is not
the problem but how must I make the Login/Passwd process, that I get
the right users ${HOME} and can work on it?

I have found one suggestion in the php-general archive, but this is a
very huge monster I do not want to use (40 MByte only to authentcate?)

Thanks


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



Re: [PHP] How to implement Authentication of UNIX users?

2011-06-27 Thread vikash . iitb
This may help: http://php.net/manual/en/book.ssh2.php

Thanks,
Vikash Kumar
--
http://vika.sh


On 27 June 2011 21:07, With No Name withnon...@tdwave.net wrote:

 Hello,

 I try to code a Webinterface to access my Server @home which has a
 couple of UNIX users.

 However, I like to have only one website where users must go to whatch
 the content of there Folders, which mean, I need a maping which is not
 the problem but how must I make the Login/Passwd process, that I get
 the right users ${HOME} and can work on it?

 I have found one suggestion in the php-general archive, but this is a
 very huge monster I do not want to use (40 MByte only to authentcate?)

 Thanks


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




Re: [PHP] Re: Php filter validate url

2011-06-27 Thread Plamen Ivanov
On Mon, Jun 27, 2011 at 11:34 AM, Jim Lucas li...@cmsws.com wrote:
 On 6/27/2011 8:25 AM, Plamen Ivanov wrote:
 On Mon, Jun 27, 2011 at 11:14 AM, Shawn McKenzie nos...@mckenzies.net 
 wrote:
 On 06/27/2011 10:01 AM, Plamen Ivanov wrote:
 On Sun, Jun 26, 2011 at 5:44 PM, Shawn McKenzie nos...@mckenzies.net 
 wrote:

 On 06/26/2011 12:31 PM, Adam Tong wrote:
 Hi,

 I wanted tu use php filters for validation to avoid regular expresions.
 Is it possible that FILTER_VALIDATE_URL only checks if the string has
 http:// and do not check for the format domain.something?
 
 $url = 'http://wwwtestcom';
 $url = filter_var($url,FILTER_VALIDATE_URL);
 echo $url;
 -

 Or I am doing something wrong

 Thank you

 Unless I'm totally misunderstanding what you want (validate that a
 string starts with http://) try:

 if(strpos($url, 'http://') === 0) {
   //starts with http://
 } esle {
   // does not start with http://
 }

 --
 Thanks!
 -Shawn
 http://www.spidean.com

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


 Another possible solution could be:

 $ary = explode('://', $url);
 if (1 = count($ary)) {
     echo 'No schema specified!';
 } else {
     // Schema specified.
     // $ary[0] is the protocol
     $allowed = array('http', 'https');
     if (FALSE == in_array($ary[0], $allowed) {
         // Protocol not valid!
         exit(1); // or return FALSE; whatever...
     }
     // $ary[1] is the uri, validate with filter_var().
 }

 Hope this helps.

 May make more sense to use parse_url() than explode.

 --
 Thanks!
 -Shawn
 http://www.spidean.com


 http://php.net/manual/en/function.parse-url.php
 This function is not meant to validate the given URL...

 I would use parse_url() after URL validation.


 Shawn meant to use parse_url() in place of your explode statement.  He didn't
 say to use parse_url() as a method to validate the url.

 He said it would make more sense to do the following.

 Also, use strict type matching if you want to compare against boolean(FALSE)

 $allowed = array('http', 'https');

 $scheme = parse_url($url, PHP_URL_SCHEME);

 if (FALSE === in_array($scheme, $allowed) {
  // Protocol not valid!
  exit(1); // or return FALSE; whatever...
 }

 Seems a little less muddy to me.

 Jim Lucas


Makes sense now.

Thanks guys.

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



Re: [PHP] How to implement Authentication of UNIX users?

2011-06-27 Thread With No Name
On Mon, June 27, 2011 5:41 pm, vikash.i...@gmail.com wrote:
 This may help: http://php.net/manual/en/book.ssh2.php

Unfortunately not, I have only one server on my DSL and using
ssh on the same host has a poor performance.  I have tried it
already and each download or directory change takes ages...

SSH need arround 2-7 seconds to respond to a new connect.

Thanks


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



[PHP] Benchmark two functions against each other?

2011-06-27 Thread Scott Baker
I have functions that I'd like to benchmark and compare. What are the
best PHP libraries or websites to do that? Something like jsperf.com but
for PHP would be ideal.

- Scott

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



Re: [PHP] How to implement Authentication of UNIX users?

2011-06-27 Thread Stuart Dallas
On Mon, Jun 27, 2011 at 5:27 PM, With No Name withnon...@tdwave.net wrote:

 SSH need arround 2-7 seconds to respond to a new connect.


Not PHP-related, but you might want to try adding UseDNS no to your
sshd_config file on the server. SSH connection delays are commonly caused by
SSHd doing an rDNS lookup for a non-existant record. Turn that off and you
might see an improvement in connect speed.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/


[PHP] PHP as CGI-CLI on FreeBSD/Apache22

2011-06-27 Thread Grant Peel
Hi all,

Up to this point we have been running PHP as an Apache 22 module.

We would like to rebuild PHP over the next few weeks to run it as a CGI/CLI 
PHPSuexec system.

I am hoping there may be others that have made this migration and might have a 
step by step how to (so far research shows it should be reasonably simple to 
do), and would be willing to share it.

Right now we have 

FreeBSD 8.0
Apache22 built from ports, with apache suexec enabled,
PHP5 Built from ports,

Any hints are appreciated,

-G

Re: [PHP] PHP as CGI-CLI on FreeBSD/Apache22

2011-06-27 Thread Nilesh Govindarajan
On 06/27/2011 10:13 PM, Grant Peel wrote:
 Hi all,

 Up to this point we have been running PHP as an Apache 22 module.

 We would like to rebuild PHP over the next few weeks to run it as a CGI/CLI 
 PHPSuexec system.

 I am hoping there may be others that have made this migration and might have 
 a step by step how to (so far research shows it should be reasonably simple 
 to do), and would be willing to share it.

 Right now we have 

 FreeBSD 8.0
 Apache22 built from ports, with apache suexec enabled,
 PHP5 Built from ports,

 Any hints are appreciated,

 -G

PHP in CGI sucks at performance, you should give a thought to fastcgi +
php + suexec as in here: http://forum.linode.com/viewtopic.php?t=2982
Though its written for ubuntu, you can derive some tricks from there.
I don't know if php-fpm + suexec is possible. php-fpm is best for fastcgi.

-- 
Regards,
Nilesh Govindarajan
@nileshgr


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



Re: [PHP] Benchmark two functions against each other?

2011-06-27 Thread Stuart Dallas
On Mon, Jun 27, 2011 at 5:34 PM, Scott Baker bak...@canbytel.com wrote:

 I have functions that I'd like to benchmark and compare. What are the
 best PHP libraries or websites to do that? Something like jsperf.com but
 for PHP would be ideal.


You're not going to find a service that will let you do that - allowing
arbitrary PHP to be entered into a website to be executed is far too
dangerous.

Just knocked this up, should do what you want:
https://gist.github.com/1049335

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/


Re: [PHP] Benchmark two functions against each other?

2011-06-27 Thread Scott Baker
On 06/27/2011 10:33 AM, Stuart Dallas wrote:
 
 You're not going to find a service that will let you do that - allowing
 arbitrary PHP to be entered into a website to be executed is far too
 dangerous.

I would have thought so too but I found these:

http://codepad.viper-7.com/
http://codepad.org/
http://ideone.com/

 Just knocked this up, should do what you
 want:Â https://gist.github.com/1049335

Thanks I'll check it out!

-- 
Scott Baker - Canby Telcom
System Administrator - RHCE - 503.266.8253

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



Re: [PHP] Benchmark two functions against each other?

2011-06-27 Thread Stuart Dallas
On Mon, Jun 27, 2011 at 6:39 PM, Scott Baker bak...@canbytel.com wrote:

 On 06/27/2011 10:33 AM, Stuart Dallas wrote:
 
  You're not going to find a service that will let you do that - allowing
  arbitrary PHP to be entered into a website to be executed is far too
  dangerous.

 I would have thought so too but I found these:

 http://codepad.viper-7.com/
 http://codepad.org/
 http://ideone.com/


That's surprising, but reading around those sites a little it seems they're
running the code in isolated virtual machines which are firewalled to
prevent outgoing network connections. Very nice!

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/


[PHP] help for memcached Segmentation fault

2011-06-27 Thread xucheng
Hi all,
   I wrap pecl-memcache into a class used as a sigleton class .
the code is :
==code===
   class Mem{

private static $_instance = null ;//singlton object instance

private function __construct(){

global $config ;
$servers = $config['memcached'] ;
$mem = new Memcache ;
foreach($servers as $server){
$mem-addServer($server['host'],
$server['port'], intval($server['persistent'])  0 ? 1 : 0,
intval($server['weight'])  0 ? intval($server['weight']) : 1 ) ;
}
return $mem ;

}

private static function getInstance(){

if(self::$_instance === null || !(
self::$_instance instanceof Mem ) ){

self::$_instance = new Mem() ;

}

return true ;

}

public static function get($key){

self::getInstance() ;
return self::$_instance-get(md5(strtolower($key))) ;

}

public static function set($key, $value, $ttl=0){
self::getInstance() ;
$compress = (is_bool($value) || is_int($value)
|| is_float($value)) ? false : MEMCACHE_COMPRESSED ;
return
self::$_instance-set(md5(strtolower($key)), $value, $compress, $ttl)
;

}

public static function rm($key){
self::getInstance() ;
return
self::$_instance-delete(md5(strtolower($key)),0) ;
}
}

===code==

and $config['memcached'] is an array contains info about the server .
$config['memcached'] = array('host'='localhost', port=11211,
persistent=1,weight=1) ;

when i run this , i got Segmentation fault ! I cannot figure out
what's the problem . any commet appreciate .

and i used memcached 1.4.5 , and libevent-1.4.13-1
php 5.2.16

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



[PHP] Re: help for memcached Segmentation fault

2011-06-27 Thread xucheng
sorry, the right $config['memcached'] variable is

$config['memcached']=array(array('host'='localhost', port=11211,
persistent=1,weight=1));

2011/6/28 xucheng xuch...@sankuai.com:
 Hi all,
       I wrap pecl-memcache into a class used as a sigleton class .
 the code is :
 ==code===
       class Mem{

        private static $_instance = null ;//singlton object instance

        private function __construct(){

                        global $config ;
                        $servers = $config['memcached'] ;
                        $mem = new Memcache ;
                        foreach($servers as $server){
                                $mem-addServer($server['host'],
 $server['port'], intval($server['persistent'])  0 ? 1 : 0,
 intval($server['weight'])  0 ? intval($server['weight']) : 1 ) ;
                        }
                        return $mem ;

        }

        private static function getInstance(){

                        if(self::$_instance === null || !(
 self::$_instance instanceof Mem ) ){

                                        self::$_instance = new Mem() ;

                        }

                        return true ;

        }

        public static function get($key){

                        self::getInstance() ;
                        return self::$_instance-get(md5(strtolower($key))) ;

        }

        public static function set($key, $value, $ttl=0){
                        self::getInstance() ;
                        $compress = (is_bool($value) || is_int($value)
 || is_float($value)) ? false : MEMCACHE_COMPRESSED ;
                        return
 self::$_instance-set(md5(strtolower($key)), $value, $compress, $ttl)
 ;

        }

        public static function rm($key){
                        self::getInstance() ;
                        return
 self::$_instance-delete(md5(strtolower($key)),0) ;
        }
 }

 ===code==

 and $config['memcached'] is an array contains info about the server .
 $config['memcached'] = array('host'='localhost', port=11211,
 persistent=1,weight=1) ;

 when i run this , i got Segmentation fault ! I cannot figure out
 what's the problem . any commet appreciate .

 and i used memcached 1.4.5 , and libevent-1.4.13-1
 php 5.2.16



[PHP] header function odd behavior

2011-06-27 Thread H Rao
Hi,

I am trying to understand odd(different) behavior of the header function
under two different environments.

Here is the code which I am trying to execute from two different servers

?
header (Set-Cookie: c1=value1;path=/; domain=.domain.com);
header (Set-Cookie: c2=value2;path=/; domain=.domain.com);
?

When executed from server1(OS X), both cookies are set in browser, but when
executed from server2(Linux), only the second cookie is set.

server1 and server2 are running different OS and php version as below. I
know I could add $replace=false option on the Linux server, but I am trying
to understand the different behavior of header() function on these two
servers. Any thoughts?

server1 - OS X
--
PHP Version 5.2.4

System  Darwin host2.domain.com 8.8.4 Darwin Kernel Version 8.8.4: Sun Oct
29 15:26:54 PST 2006; root:xnu-792.16.4.obj~1/RELEASE_I386 i386
--
server2 - Linux
--
PHP Version 5.3.5

System  Linux host1.domain.com 2.6.18-164.15.1.0.1.el5 #1 SMP Wed Mar 17
01:10:06 EDT 2010 x86_64

-Rao


Re: [PHP] header function odd behavior

2011-06-27 Thread Nilesh Govindarajan
On 06/28/2011 09:10 AM, H Rao wrote:
 Hi,

 I am trying to understand odd(different) behavior of the header function
 under two different environments.

 Here is the code which I am trying to execute from two different servers

 ?
 header (Set-Cookie: c1=value1;path=/; domain=.domain.com);
 header (Set-Cookie: c2=value2;path=/; domain=.domain.com);
 ?

 When executed from server1(OS X), both cookies are set in browser, but when
 executed from server2(Linux), only the second cookie is set.

 server1 and server2 are running different OS and php version as below. I
 know I could add $replace=false option on the Linux server, but I am trying
 to understand the different behavior of header() function on these two
 servers. Any thoughts?

snip

I don't have a clear idea about this because I always use setcookie(),
but something tells me that this has something to do with output
buffering and friends.

-- 
Regards,
Nilesh Govindarajan
@nileshgr


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



[PHP] caching problem

2011-06-27 Thread Fatih P.
Hi guys,

the code files are being cached. and modifications in methods are skipped
and not executed. is there any parameter that i can pass it from ini file?
this has been so annoying for me. restarting apache, windows, etc does not
even help. im running apache 2.2.19, php ts 5.3.6 on windows 2003 r2
any ideas how to avoid this situation? thanks

Fatih


Re: [PHP] caching problem

2011-06-27 Thread Nilesh Govindarajan
On 06/28/2011 10:56 AM, Fatih P. wrote:
 Hi guys,

 the code files are being cached. and modifications in methods are skipped
 and not executed. is there any parameter that i can pass it from ini file?
 this has been so annoying for me. restarting apache, windows, etc does not
 even help. im running apache 2.2.19, php ts 5.3.6 on windows 2003 r2
 any ideas how to avoid this situation? thanks

 Fatih


It seems you have a wrongly configured opcode cache runnning about which
you're not aware of.

-- 
Regards,
Nilesh Govindarajan
@nileshgr on twitter/identica


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



Re: [PHP] caching problem

2011-06-27 Thread Fatih P.
On Tue, Jun 28, 2011 at 7:40 AM, Nilesh Govindarajan
cont...@nileshgr.comwrote:

 On 06/28/2011 10:56 AM, Fatih P. wrote:
  Hi guys,
 
  the code files are being cached. and modifications in methods are skipped
  and not executed. is there any parameter that i can pass it from ini
 file?
  this has been so annoying for me. restarting apache, windows, etc does
 not
  even help. im running apache 2.2.19, php ts 5.3.6 on windows 2003 r2
  any ideas how to avoid this situation? thanks
 
  Fatih
 

 It seems you have a wrongly configured opcode cache runnning about which
 you're not aware of.

 --
 Regards,
 Nilesh Govindarajan
 @nileshgr on twitter/identica


basically using default configuration, have not changed anything except the
path for extensions in php.ini.
and there is nothing installed/configured to cache anything.