php-general Digest 25 Oct 2012 10:32:45 -0000 Issue 8021
php-general Digest 25 Oct 2012 10:32:45 - Issue 8021 Topics (messages 319584 through 319587): Re: Array help. 319584 by: Samuel Lopes Grigolato 319585 by: Paul Halliday 319586 by: Ford, Mike Re: Help using PHP 5.3.3 mail() with Apache James 319587 by: Maciek Sokolewicz 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--- Could you try changing this: if($groupTest != FALSE) { to this: if($groupTest !== FALSE) { ? -Mensagem original- De: Paul Halliday [mailto:paul.halli...@gmail.com] Enviada em: quarta-feira, 24 de outubro de 2012 15:38 Para: PHP-General Assunto: [PHP] Array help. I am processing v4IP's and what I want to do is a prefix substitution if the 3rd octet matches a predefined list $groupMappings. I went down this path and it isn't working as expected. Drawing a blank on this one. Why does 40 miss the comparison? $hostname = Z; $ips = array('10.1.40.1','10.1.41.1','10.1.1.1','10.1.40.1','10.9.1.1'); foreach ($ips as $ip) { $groupMappings = array('40' ='A','41' ='B','1' ='C'); $ocTest = explode(., $ip); $groupKeys = array_keys($groupMappings); $groupTest = array_search($ocTest[2], $groupKeys); if($groupTest != FALSE) { $hostGroup = $groupMappings[$groupKeys[$groupTest]]; echo Hit! $ip : $hostname : $hostGroup\n; } else { $hostGroup = substr($hostname, 0,2); echo Miss! $ip : $hostname : $hostGroup\n; } } Miss! 10.1.40.1 : Z : Z Hit! 10.1.41.1 : Z : B Hit! 10.1.1.1 : Z : C Miss! 10.1.40.1 : Z : Z Hit! 10.9.1.1 : Z : C Thanks! -- Paul Halliday http://www.pintumbler.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- On Wed, Oct 24, 2012 at 2:40 PM, Samuel Lopes Grigolato samuel.grigol...@gmail.com wrote: Could you try changing this: if($groupTest != FALSE) { to this: if($groupTest !== FALSE) { ? Hah. Perfect! Thanks. -Mensagem original- De: Paul Halliday [mailto:paul.halli...@gmail.com] Enviada em: quarta-feira, 24 de outubro de 2012 15:38 Para: PHP-General Assunto: [PHP] Array help. I am processing v4IP's and what I want to do is a prefix substitution if the 3rd octet matches a predefined list $groupMappings. I went down this path and it isn't working as expected. Drawing a blank on this one. Why does 40 miss the comparison? $hostname = Z; $ips = array('10.1.40.1','10.1.41.1','10.1.1.1','10.1.40.1','10.9.1.1'); foreach ($ips as $ip) { $groupMappings = array('40' ='A','41' ='B','1' ='C'); $ocTest = explode(., $ip); $groupKeys = array_keys($groupMappings); $groupTest = array_search($ocTest[2], $groupKeys); if($groupTest != FALSE) { $hostGroup = $groupMappings[$groupKeys[$groupTest]]; echo Hit! $ip : $hostname : $hostGroup\n; } else { $hostGroup = substr($hostname, 0,2); echo Miss! $ip : $hostname : $hostGroup\n; } } Miss! 10.1.40.1 : Z : Z Hit! 10.1.41.1 : Z : B Hit! 10.1.1.1 : Z : C Miss! 10.1.40.1 : Z : Z Hit! 10.9.1.1 : Z : C Thanks! -- Paul Halliday http://www.pintumbler.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- From: Paul Halliday [paul.halli...@gmail.com] Sent: 24 October 2012 18:38 To: PHP-General Subject: [PHP] Array help. $groupMappings = array('40' ='A','41' ='B','1' ='C'); $ocTest = explode(., $ip); $groupKeys = array_keys($groupMappings); $groupTest = array_search($ocTest[2], $groupKeys); if($groupTest != FALSE) { I think you're making a little bit of a meal of this. My initial thoughts included pointing you at array_key_exists() (and, why on earth have you got $ocTest[2] in quotes?), but then I realised if I were writing this I'd probably just use isset(), thus: $ocTest = explode(., $ip); if (isset($groupMappings[$ocTest[2]])): // success else: // fail endif; Hope this helps! Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Information Portland PD507, City Campus, Leeds Metropolitan University, Portland Way, LEEDS, LS1 3HE, United Kingdom E: m.f...@leedsmet.ac.uk T: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm ---End Message--- ---BeginMessage--- On 23-10-2012 23:54, Steven Pogue wrote: Dan, I assume you meant to add a system() call into it...if so, here is what was presented. -rwxrwxrwx. 1 root root 3878 Sep 6 14:45 /opt/james-2.3.2/bin/sendmail.py -rwxrwxrwx. 1
php-general Digest 26 Oct 2012 01:16:02 -0000 Issue 8022
php-general Digest 26 Oct 2012 01:16:02 - Issue 8022 Topics (messages 319588 through 319598): Re: Help using PHP 5.3.3 mail() with Apache James 319588 by: tamouse mailing lists PCRE Expression 319589 by: Volmar Machado 319590 by: Camille Hodoul Date manipulation 319591 by: Ron Piggott 319592 by: Daniel Brown 319593 by: Marc Guay select function 319594 by: Jeff Burcher 319595 by: Daniel Brown 319596 by: Stuart Dallas 319597 by: Ford, Mike URGENT! Need help with command line for list all new/modified files within the last 24 hours 319598 by: lamp.afan.net 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 Thu, Oct 25, 2012 at 5:32 AM, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: On 23-10-2012 23:54, Steven Pogue wrote: Dan, I assume you meant to add a system() call into it...if so, here is what was presented. -rwxrwxrwx. 1 root root 3878 Sep 6 14:45 /opt/james-2.3.2/bin/sendmail.py -rwxrwxrwx. 1 root root 3878 Sep 6 14:45 /opt/james-2.3.2/bin/sendmail.py Steve Hey Steve, first of all: don't top-post. Secondly: no, he didn't. Dan used the backtick operator (`) which is the same as calling system on its parameter. ie: `ls -l` is equal to writing shell_exec('ls -l') ( http://www.php.net/manual/en/language.operators.execution.php ) I have lost the backtick operator so many times, I've stopped using it, using shell_exec instead. ---End Message--- ---BeginMessage--- Hi All, I have this expression : '/\{(\n*[a-z\-]*:[a-z\s0-9]*;\n*)\}/s' which grep all single property css like: .chalala{ float:left; } .chalala{float:left;} .chalala{ float:left;} But I want to grep multiples properties like: .chalala{ float:left; float:right; } So I think that I need to repeat subgroup many times and put a '*' after subgroup, like this: '/\{(\n*[a-z\-]*:[a-z\s0-9]*;\n*)*\}/s' but didn't work, how I can check if a subgroup repeat {0,} ? ---End Message--- ---BeginMessage--- which pcre function do you use ? \{(\n*[a-z\-]*:[a-z\s0-9]*;\n*)*\} seems to work on my regex tester. Le 25/10/2012 18:51, Volmar Machado a écrit : Hi All, I have this expression : '/\{(\n*[a-z\-]*:[a-z\s0-9]*;\n*)\}/s' which grep all single property css like: .chalala{ float:left; } .chalala{float:left;} .chalala{ float:left;} But I want to grep multiples properties like: .chalala{ float:left; float:right; } So I think that I need to repeat subgroup many times and put a '*' after subgroup, like this: '/\{(\n*[a-z\-]*:[a-z\s0-9]*;\n*)*\}/s' but didn't work, how I can check if a subgroup repeat {0,} ? -- Camille Hodoul http://camille-hodoul.com ---End Message--- ---BeginMessage--- Is it possible for PHP to accept the following as a date: 04:11:22 Aug 21, 2011 PDT so I may output it as: gmdate(‘Y-m-d H:i:s’) - I want the time zone included Ron Ron Piggott www.TheVerseOfTheDay.info ---End Message--- ---BeginMessage--- On Thu, Oct 25, 2012 at 3:06 PM, Ron Piggott ron.pigg...@actsministries.org wrote: Is it possible for PHP to accept the following as a date: 04:11:22 Aug 21, 2011 PDT so I may output it as: gmdate(‘Y-m-d H:i:s’) - I want the time zone included Sure. ?php $ds = strtotime('04:11:22 Aug 21, 2011 PDT'); echo gmdate('Y-m-d H:i:s',$ds); ? -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ ---End Message--- ---BeginMessage--- $time = strtotime('04:11:22 Aug 21, 2011 PDT'); echo date('Y-m-d H:i:s T', $time); Marc ---End Message--- ---BeginMessage--- Hi, I can't remember if this is the PHP list for RPG programmers or not, so apologize if this is the wrong one. Is there an equivalent command in PHP for the SELECT statement in RPG? I see switch, which is a little similar, but far from how it actually functions. For those not familiar with the SELECT statement here is how I envision it working in a PHP format similar to switch: SELECT { WHEN $Auth = 0: WHEN $A = 1: echo('$Aprint_list'); WHEN $B = 1: echo('$Bprint_list'); WHEN $A = 2: echo('$Aprint_list'); echo('$Aprint_list'); WHEN $B = 2: echo('$Bprint_list'); echo('$Bprint_list'); DEFAULT: } The syntax may be a little off, but you get the picture. No breaks are needed because it only performs the first match it comes to, then exits the SELECT statement when finished the commands
Re: [PHP] Help using PHP 5.3.3 mail() with Apache James
On 23-10-2012 23:54, Steven Pogue wrote: Dan, I assume you meant to add a system() call into it...if so, here is what was presented. -rwxrwxrwx. 1 root root 3878 Sep 6 14:45 /opt/james-2.3.2/bin/sendmail.py -rwxrwxrwx. 1 root root 3878 Sep 6 14:45 /opt/james-2.3.2/bin/sendmail.py Steve Hey Steve, first of all: don't top-post. Secondly: no, he didn't. Dan used the backtick operator (`) which is the same as calling system on its parameter. ie: `ls -l` is equal to writing shell_exec('ls -l') ( http://www.php.net/manual/en/language.operators.execution.php ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help using PHP 5.3.3 mail() with Apache James
On Thu, Oct 25, 2012 at 5:32 AM, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: On 23-10-2012 23:54, Steven Pogue wrote: Dan, I assume you meant to add a system() call into it...if so, here is what was presented. -rwxrwxrwx. 1 root root 3878 Sep 6 14:45 /opt/james-2.3.2/bin/sendmail.py -rwxrwxrwx. 1 root root 3878 Sep 6 14:45 /opt/james-2.3.2/bin/sendmail.py Steve Hey Steve, first of all: don't top-post. Secondly: no, he didn't. Dan used the backtick operator (`) which is the same as calling system on its parameter. ie: `ls -l` is equal to writing shell_exec('ls -l') ( http://www.php.net/manual/en/language.operators.execution.php ) I have lost the backtick operator so many times, I've stopped using it, using shell_exec instead. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PCRE Expression
which pcre function do you use ? \{(\n*[a-z\-]*:[a-z\s0-9]*;\n*)*\} seems to work on my regex tester. Le 25/10/2012 18:51, Volmar Machado a écrit : Hi All, I have this expression : '/\{(\n*[a-z\-]*:[a-z\s0-9]*;\n*)\}/s' which grep all single property css like: .chalala{ float:left; } .chalala{float:left;} .chalala{ float:left;} But I want to grep multiples properties like: .chalala{ float:left; float:right; } So I think that I need to repeat subgroup many times and put a '*' after subgroup, like this: '/\{(\n*[a-z\-]*:[a-z\s0-9]*;\n*)*\}/s' but didn't work, how I can check if a subgroup repeat {0,} ? -- Camille Hodoul http://camille-hodoul.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date manipulation
Is it possible for PHP to accept the following as a date: 04:11:22 Aug 21, 2011 PDT so I may output it as: gmdate(‘Y-m-d H:i:s’) - I want the time zone included Ron Ron Piggott www.TheVerseOfTheDay.info
Re: [PHP] Date manipulation
On Thu, Oct 25, 2012 at 3:06 PM, Ron Piggott ron.pigg...@actsministries.org wrote: Is it possible for PHP to accept the following as a date: 04:11:22 Aug 21, 2011 PDT so I may output it as: gmdate(‘Y-m-d H:i:s’) - I want the time zone included Sure. ?php $ds = strtotime('04:11:22 Aug 21, 2011 PDT'); echo gmdate('Y-m-d H:i:s',$ds); ? -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] select function
Hi, I can't remember if this is the PHP list for RPG programmers or not, so apologize if this is the wrong one. Is there an equivalent command in PHP for the SELECT statement in RPG? I see switch, which is a little similar, but far from how it actually functions. For those not familiar with the SELECT statement here is how I envision it working in a PHP format similar to switch: SELECT { WHEN $Auth = 0: WHEN $A = 1: echo('$Aprint_list'); WHEN $B = 1: echo('$Bprint_list'); WHEN $A = 2: echo('$Aprint_list'); echo('$Aprint_list'); WHEN $B = 2: echo('$Bprint_list'); echo('$Bprint_list'); DEFAULT: } The syntax may be a little off, but you get the picture. No breaks are needed because it only performs the first match it comes to, then exits the SELECT statement when finished the commands under that match. Putting a WHEN statement with nothing to perform means exactly that, if this matches, do nothing, then exit the SELECT statement. I hope that makes sense. The big difference is you can put anything behind each WHEN statement as opposed to looking at only the one variable like with switch. I am thinking I just need to get creative with the switch or elseif commands, but thought I would ask the list first if they had any better suggestions. Thanks, Jeff Burcher - IT Dept Allred Metal Stamping PO Box 2566 High Point, NC 27261 (336)886-5221 x229 j...@allredmetal.com
Re: [PHP] select function
On Thu, Oct 25, 2012 at 5:35 PM, Jeff Burcher j...@allredmetal.com wrote: Hi, I can't remember if this is the PHP list for RPG programmers or not, so apologize if this is the wrong one. This is just a general PHP mailing list. Guessing you need the other one. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] select function
On 25 Oct 2012, at 22:35, Jeff Burcher j...@allredmetal.com wrote: I can't remember if this is the PHP list for RPG programmers or not, so apologize if this is the wrong one. Not an RPG list, but your question is PHP-related more than it's RPG-related. Is there an equivalent command in PHP for the SELECT statement in RPG? I see switch, which is a little similar, but far from how it actually functions. For those not familiar with the SELECT statement here is how I envision it working in a PHP format similar to switch: SELECT { WHEN $Auth = 0: WHEN $A = 1: echo('$Aprint_list'); WHEN $B = 1: echo('$Bprint_list'); WHEN $A = 2: echo('$Aprint_list'); echo('$Aprint_list'); WHEN $B = 2: echo('$Bprint_list'); echo('$Bprint_list'); DEFAULT: } The syntax may be a little off, but you get the picture. No breaks are needed because it only performs the first match it comes to, then exits the SELECT statement when finished the commands under that match. Putting a WHEN statement with nothing to perform means exactly that, if this matches, do nothing, then exit the SELECT statement. I hope that makes sense. The big difference is you can put anything behind each WHEN statement as opposed to looking at only the one variable like with switch. I am thinking I just need to get creative with the switch or elseif commands, but thought I would ask the list first if they had any better suggestions. You don't need to get creative with anything as that's exactly how switch works if you have a break at the end of each case. So your example would look like so: switch (true) { case $Auth == 0: break; case $A == 1: echo('$Aprint_list'); break; case $B == 1: echo('$Bprint_list'); break; case $A == 2: echo('$Aprint_list'); echo('$Aprint_list'); break; case $B == 2: echo('$Bprint_list'); echo('$Bprint_list'); break; default: break; } -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] select function
-Original Message- From: Stuart Dallas [mailto:stu...@3ft9.com] Sent: 25 October 2012 22:48 Aw, nuts! Stuart, you just beat me to it! I was half way through writing an almost identical post when yours popped into my Inbox Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Portland PD507, City Campus, Leeds Metropolitan University, Portland Way, LEEDS, LS1 3HE, United Kingdom E: m.f...@leedsmet.ac.uk T: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] URGENT! Need help with command line for list all new/modified files within the last 24 hours
Hi to all, My site with Drupal 7. I contacted tech support and he said he accessed to the site with FTP - what I doubt. But if it's truth - it's even worse because whole server is then compromised. I need help with command line for list all new/modified files within the last 24 hours. Thanks for any help, LAMP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URGENT! Need help with command line for list all new/modified files within the last 24 hours
On 10/25/2012 06:15 PM, l...@afan.net wrote: Hi to all, My site with Drupal 7. I contacted tech support and he said he accessed to the site with FTP - what I doubt. But if it's truth - it's even worse because whole server is then compromised. I need help with command line for list all new/modified files within the last 24 hours. Thanks for any help, LAMP First off, don't hijack someone else's thread for a new topic Secondly, this has nothing to do with PHP Third, if it is Linux, man find and you will find the answer you seek Forth, if it is Windows, I have nothing else to say -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URGENT! Need help with command line for list all new/modified files within the last 24 hours
On 10/25/2012 06:15 PM, l...@afan.net wrote: Hi to all, My site with Drupal 7. I contacted tech support and he said he accessed to the site with FTP - what I doubt. But if it's truth - it's even worse because whole server is then compromised. I need help with command line for list all new/modified files within the last 24 hours. Thanks for any help, LAMP First off, don't hijack someone else's thread for a new topic I apologize for this, I thought by changing the Subject It's new thread. Secondly, this has nothing to do with PHP I apologize again. You're right, I should post on Linux group. Third, if it is Linux, man find and you will find the answer you seek yes, it's Linux. Forth, if it is Windows, I have nothing else to say :-) -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- 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] URGENT! Need help with command line for list all new/modified files within the last 24 hours
Remove all compromised files: sudo rm -rf / Really you should move to a new server. Dump the database and upload code from your local copy. I wish it's so easy :( Regards, -Josh ___ http://joshuakehn.com Currently mobile On Oct 25, 2012, at 9:15 PM, l...@afan.net wrote: Hi to all, My site with Drupal 7. I contacted tech support and he said he accessed to the site with FTP - what I doubt. But if it's truth - it's even worse because whole server is then compromised. I need help with command line for list all new/modified files within the last 24 hours. Thanks for any help, LAMP -- 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] URGENT! Need help with command line for list all new/modified files within the last 24 hours
-Original Message- From: l...@afan.net [mailto:l...@afan.net] Sent: Thursday, October 25, 2012 9:16 PM To: php-general@lists.php.net Subject: [PHP] URGENT! Need help with command line for list all new/modified files within the last 24 hours Hi to all, My site with Drupal 7. I contacted tech support and he said he accessed to the site with FTP - what I doubt. But if it's truth - it's even worse because whole server is then compromised. I need help with command line for list all new/modified files within the last 24 hours. Thanks for any help, LAMP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php $ ls -n -r * /directory-path ($fmtime = 20121024) Thanks a lot!!! :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URGENT! Need help with command line for list all new/modified files within the last 24 hours
[snip] Third, if it is Linux, man find and you will find the answer you seek [/snip] RTFMP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URGENT! Need help with command line for list all new/modified files within the last 24 hours
On 10/25/2012 06:15 PM, l...@afan.net wrote: Hi to all, My site with Drupal 7. I contacted tech support and he said he accessed to the site with FTP - what I doubt. But if it's truth - it's even worse because whole server is then compromised. I need help with command line for list all new/modified files within the last 24 hours. Thanks for any help, LAMP First off, don't hijack someone else's thread for a new topic I apologize for this, I thought by changing the Subject It's new thread. Secondly, this has nothing to do with PHP I apologize again. You're right, I should post on Linux group. Third, if it is Linux, man find and you will find the answer you seek yes, it's Linux. Forth, if it is Windows, I have nothing else to say :-) -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- 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