php-general Digest 12 May 2012 13:22:02 -0000 Issue 7811
php-general Digest 12 May 2012 13:22:02 - Issue 7811 Topics (messages 317847 through 317858): Variables via url 317847 by: Ashley M. Kirchner 317858 by: Jim Giner Re: Converting date string to unix timestamp 317848 by: Jim Lucas 317849 by: Karl DeSaulniers 317850 by: Karl DeSaulniers 317851 by: Jim Lucas 317852 by: Karl DeSaulniers alias address in REMOTE_ADDR 317853 by: Tóth Csaba 317854 by: shiplu 317855 by: shiplu 317856 by: Jim Lucas SOLVED: [PHP] alias address in REMOTE_ADDR 317857 by: Tóth Csaba 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--- Can someone point me at examples or directions on how I can pass a variable via a URL in the following way: http://server.domain.com//script///variable/ I will only be passing one single /variable/. And I want the /script/ to use that. I don't want to see what the script is, for example I don't want it to say 'script.php' or 'script.html' ... Is this possible through PHP only, or do I have to write a rewrite directive in Apache to accomplish this? ---End Message--- ---BeginMessage--- Ashley M. Kirchner ash...@pcraft.com wrote in message news:4fad9d8b.4020...@pcraft.com... Can someone point me at examples or directions on how I can pass a variable via a URL in the following way: http://server.domain.com//script///variable/ I will only be passing one single /variable/. And I want the /script/ to use that. I don't want to see what the script is, for example I don't want it to say 'script.php' or 'script.html' ... Is this possible through PHP only, or do I have to write a rewrite directive in Apache to accomplish this? A URL has to point to a script - how will your server know what to do with the incoming URL if it doesn't point to something? That said - format your URL as a GET string and there's your variable. Ex.: http://server.domain.com/(scriptname)?variableanothervariableanothervariable Or - if this url is coming from an already running script, you could post the var to a session var and then send a url without the script name and let your server's default document (index.php ?) receive it and look up the session var, but that's a pretty silly way to handle things just to hide the scriptname. Of course, someone here with much more knowledge than I could very soon make me look stupid :) ---End Message--- ---BeginMessage--- On 05/11/2012 04:11 PM, Karl DeSaulniers wrote: Hello everyone, Got a quick one (I hope), and probably an easy one. For some reason it is eluding me at the moment. Hoping someone can help. I am building an ics file with PHP and the form that is submitting to create this ics file has a jQuery date picker on it. The date furnished comes to me like this Saturday, January 1, 2012, and a time furnished like 4:20 pm with no seconds. Now for the ics file, I need the date/time combo to be.. Ymd\THis\Z or in the case of the above date and time, 20120101T042000Z Here is the block of code that I am using for this. Why do you have so much code to do such a simple thing? This works for me. ?php $date = Saturday, January 1, 2012; $time = 4:20 pm; echo date('Ymd\THis\Z', strtotime($date.' '.$time)); // Outputs 20120107T162000Z ? Check it out in action: http://www.cmsws.com/examples/php/jquery_time_stamp.php http://www.cmsws.com/examples/php/jquery_time_stamp.phps Jim CODE [ ... } else { $dt_start = $_POST[field20] ? $_POST[field20] : $_POST[field21]; //Saturday, January 1, 2012 $dt_end = $_POST[field22]; //Saturday, January 1, 2012 $t_start = $_POST[field24]; //4:20 pm $t_end = $_POST[field25]; //5:55 pm //date_default_timezone_set('UTC'); try { $start_DT = new DateTime($dt_start . . $t_start); $st_date_fmt = new DateTime($start_DT-format(l, F d, Y\TH:ia T)); //$startdate_stamp = strtotime($st_date_fmt); $startdate = $st_date_fmt-format('U'); //$startdate = date('Ymd\THis\Z', $startdate_stamp); } catch (Exception $e) { trigger_error(startdate error: . $e-getMessage(), E_USER_ERROR); exit(1); } try { if(empty($dt_end)) { $enddate = $startdate + (60 * 60); //If no end date provided, enddate is 1 hour after startdate. } else { $end_DT = new DateTime($dt_end . . $t_end); $end_date_fmt = new DateTime($end_DT-format(l, F d, Y\TH:ia T)); //$enddate_stamp = strtotime($end_date_fmt); $enddate = $end_date_fmt-format('U'); //$enddate = date('Ymd\THis\Z', $enddate_stamp); } } catch (Exception $e) { trigger_error(enddate error: . $e-getMessage(), E_USER_ERROR); exit(1); } $stampnow = date('Ymd\THis\Z', time()); //$datestampnow = strtotime($stampnow);
[PHP] alias address in REMOTE_ADDR
Hi Everyone, I've run into a curious problem, not even really sure it's PHP, but that's where I caught it, so here it is: I have two servers hanging on the net, without proxies. Let's call them Server1 and Server2. Server1 has multiple IP addresses, configured as aliases. My problem: When I do a wget --spider from 1 to 2, I get the eth0 (not alias) address in Apache's accesslog on Server2. But when I do a file_get_contents(http://server2.tld), and observe the $_SERVER['REMOTE_ADDR'] on Server2, I get one of the alias IP addresses back. What can cause this? I really need the eth0 IP address back in REMOTE_ADDR. Regards, Csaba -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] alias address in REMOTE_ADDR
On Saturday, May 12, 2012, Tóth Csaba wrote: Hi Everyone, I've run into a curious problem, not even really sure it's PHP, but that's where I caught it, so here it is: I have two servers hanging on the net, without proxies. Let's call them Server1 and Server2. Server1 has multiple IP addresses, configured as aliases. My problem: When I do a wget --spider from 1 to 2, I get the eth0 (not alias) address in Apache's accesslog on Server2. But when I do a file_get_contents( http://server2.tld), and observe the $_SERVER['REMOTE_ADDR'] on Server2, I get one of the alias IP addresses back. What can cause this? I really need the eth0 IP address back in REMOTE_ADDR. On server2 make sure the metric of both interface in the routing table is not same. Same metric can cause this behavior. Change the metric of eth0 to a lower value than the other. Then try again. Regards, Csaba -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader
Re: [PHP] alias address in REMOTE_ADDR
On Saturday, May 12, 2012, shiplu wrote: On Saturday, May 12, 2012, Tóth Csaba wrote: Hi Everyone, I've run into a curious problem, not even really sure it's PHP, but that's where I caught it, so here it is: I have two servers hanging on the net, without proxies. Let's call them Server1 and Server2. Server1 has multiple IP addresses, configured as aliases. My problem: When I do a wget --spider from 1 to 2, I get the eth0 (not alias) address in Apache's accesslog on Server2. But when I do a file_get_contents( http://server2.tld), and observe the $_SERVER['REMOTE_ADDR'] on Server2, I get one of the alias IP addresses back. What can cause this? I really need the eth0 IP address back in REMOTE_ADDR. On server2 make sure the metric of both interface in the routing table is not same. Same metric can cause this behavior. Change the metric of eth0 to a lower value than the other. Then try again. Correction. On server2 should be On server1. -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader
Re: [PHP] alias address in REMOTE_ADDR
On 5/11/2012 10:57 PM, Tóth Csaba wrote: Hi Everyone, I've run into a curious problem, not even really sure it's PHP, but that's where I caught it, so here it is: I have two servers hanging on the net, without proxies. Let's call them Server1 and Server2. Server1 has multiple IP addresses, configured as aliases. My problem: When I do a wget --spider from 1 to 2, I get the eth0 (not alias) address in Apache's accesslog on Server2. But when I do a file_get_contents(http://server2.tld), and observe the $_SERVER['REMOTE_ADDR'] on Server2, I get one of the alias IP addresses back. What can cause this? I really need the eth0 IP address back in REMOTE_ADDR. Regards, Csaba What IP address is your Apache bound to? You eth0 or one of the alias IPs? Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SOLVED: [PHP] alias address in REMOTE_ADDR
Hi, shiplu and Jim, many thanks for the hints, I solved it; wasn't related to PHP, but I will write it down so if others search for this problem, at least they will have one solution that worked. Jim: the Apache was configured to listen on all interfaces - I had to, because I have multiple SSL-enabled hosts with different keys shiplu: it was the metric! Only problem, because these are alias interfaces, a simple ifmetric doesn't cut it: #~ ifmetric eth0:1 20 SIOCSIFMETRIC: operation not supported So I had to disable the alias interfaces with ifconfig down, the re-enable them; after that, add the gateways like this: #~ route add default gw GATEWAYIP metric 10 so now my routing table has a metric 0 gateway for eth0, and a metric 10 for both aliases. Many thanks again, and have a nice weekend! Regards, Csaba On Fri, 11 May 2012 23:54:56 -0700, Jim Lucas wrote: On 5/11/2012 10:57 PM, Tóth Csaba wrote: Hi Everyone, I've run into a curious problem, not even really sure it's PHP, but that's where I caught it, so here it is: ... Regards, Csaba What IP address is your Apache bound to? You eth0 or one of the alias IPs? Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Variables via url
Ashley M. Kirchner ash...@pcraft.com wrote in message news:4fad9d8b.4020...@pcraft.com... Can someone point me at examples or directions on how I can pass a variable via a URL in the following way: http://server.domain.com//script///variable/ I will only be passing one single /variable/. And I want the /script/ to use that. I don't want to see what the script is, for example I don't want it to say 'script.php' or 'script.html' ... Is this possible through PHP only, or do I have to write a rewrite directive in Apache to accomplish this? A URL has to point to a script - how will your server know what to do with the incoming URL if it doesn't point to something? That said - format your URL as a GET string and there's your variable. Ex.: http://server.domain.com/(scriptname)?variableanothervariableanothervariable Or - if this url is coming from an already running script, you could post the var to a session var and then send a url without the script name and let your server's default document (index.php ?) receive it and look up the session var, but that's a pretty silly way to handle things just to hide the scriptname. Of course, someone here with much more knowledge than I could very soon make me look stupid :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Variables via url
On Sat, 2012-05-12 at 09:21 -0400, Jim Giner wrote: Ashley M. Kirchner ash...@pcraft.com wrote in message news:4fad9d8b.4020...@pcraft.com... Can someone point me at examples or directions on how I can pass a variable via a URL in the following way: http://server.domain.com//script///variable/ I will only be passing one single /variable/. And I want the /script/ to use that. I don't want to see what the script is, for example I don't want it to say 'script.php' or 'script.html' ... Is this possible through PHP only, or do I have to write a rewrite directive in Apache to accomplish this? A URL has to point to a script - how will your server know what to do with the incoming URL if it doesn't point to something? That said - format your URL as a GET string and there's your variable. Ex.: http://server.domain.com/(scriptname)?variableanothervariableanothervariable Or - if this url is coming from an already running script, you could post the var to a session var and then send a url without the script name and let your server's default document (index.php ?) receive it and look up the session var, but that's a pretty silly way to handle things just to hide the scriptname. Of course, someone here with much more knowledge than I could very soon make me look stupid :) I think what you're looking for is URL rewriting. PHP by itself can't do that, you need to do it at the server level, so an .htaccess file would be along the right lines. -- Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Re: Variables via url
On May 12, 2012, at 9:47 AM, Ashley Sheridan wrote: On Sat, 2012-05-12 at 09:21 -0400, Jim Giner wrote: Ashley M. Kirchner ash...@pcraft.com wrote in message news:4fad9d8b.4020...@pcraft.com... Can someone point me at examples or directions on how I can pass a variable via a URL in the following way: http://server.domain.com//script///variable/ I will only be passing one single /variable/. And I want the /script/ to use that. I don't want to see what the script is, for example I don't want it to say 'script.php' or 'script.html' ... Is this possible through PHP only, or do I have to write a rewrite directive in Apache to accomplish this? A URL has to point to a script - how will your server know what to do with the incoming URL if it doesn't point to something? That said - format your URL as a GET string and there's your variable. Ex.: http://server.domain.com/(scriptname)?variableanothervariableanothervariable Or - if this url is coming from an already running script, you could post the var to a session var and then send a url without the script name and let your server's default document (index.php ?) receive it and look up the session var, but that's a pretty silly way to handle things just to hide the scriptname. Of course, someone here with much more knowledge than I could very soon make me look stupid :) I think what you're looking for is URL rewriting. PHP by itself can't do that, you need to do it at the server level, so an .htaccess file would be along the right lines. Ash is right; however you can leverage off of the index page So your script would be in index.php and the url would be: http://server.domain.com/some_optional_directory_path/?variable Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables via url
On Sun, 2012-05-13 at 01:57 +1000, Tom Rogers wrote: Hello Ashley, Saturday, May 12, 2012, 9:15:23 AM, you wrote: Can someone point me at examples or directions on how I can pass a variable via a URL in the following way: http://server.domain.com//script///variable/ I will only be passing one single /variable/. And I want the /script/ to use that. I don't want to see what the script is, for example I don't want it to say 'script.php' or 'script.html' ... Is this possible through PHP only, or do I have to write a rewrite directive in Apache to accomplish this? You can add this to apache conf: FilesMatch ^phpscript$ ForceType application/x-httpd-php /FilesMatch Then make a file called phpscript without extension and drop it in the web root. ?php $info = explode('/', $_SERVER['PATH_INFO']); Then your url would look like: http://server.domain.com/phpscript/variable1/variable2 -- Best regards, Tom As this method requires an Apache restart, I don't see what advantage you have over using an .htaccess file? -- Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] alias address in REMOTE_ADDR
On May 12, 2012, at 2:54, Jim Lucas li...@cmsws.com wrote: On 5/11/2012 10:57 PM, Tóth Csaba wrote: Hi Everyone, I've run into a curious problem, not even really sure it's PHP, but that's where I caught it, so here it is: I have two servers hanging on the net, without proxies. Let's call them Server1 and Server2. Server1 has multiple IP addresses, configured as aliases. My problem: When I do a wget --spider from 1 to 2, I get the eth0 (not alias) address in Apache's accesslog on Server2. But when I do a file_get_contents(http://server2.tld), and observe the $_SERVER['REMOTE_ADDR'] on Server2, I get one of the alias IP addresses back. What can cause this? I really need the eth0 IP address back in REMOTE_ADDR. Regards, Csaba What IP address is your Apache bound to? You eth0 or one of the alias IPs? Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Do a netstat -ab and see what ip/ports apache is listening on. Mike Mackintosh ZCE PHP5.3 www.highonphp.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables via url
On Sat, May 12, 2012 at 12:25 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: As this method requires an Apache restart, I don't see what advantage you have over using an .htaccess file? Performance: http://httpd.apache.org/docs/current/howto/htaccess.html You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance. ...putting this configuration in your server configuration file will result in less of a performance hit, as the configuration is loaded once when httpd starts, rather than every time a file is requested. Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Time out issue
I am running Windows 2008 R2, IIS 7 I am running into an issue where no matter what I set the script time out to be the server is Giving me a 500 error after like 60 seconds when the process exceeds the configured activity timeout. Here is the example script ? set_time_limit(120); sleep(100); Echo PASSED THE TIME OUT; ? I fully understand this may not be a PHP error but if anyone has ran into this issue with a windows server and can explain in detail how I can adjust the timeout, I would be very grateful. Everything I have read online points to a fcgiext.ini file that does not exist on my server. Anyone know how to help ?
Re: [PHP] Time out issue
On Sat, May 12, 2012 at 9:42 PM, admin ad...@buskirkgraphics.com wrote: I am running Windows 2008 R2, IIS 7 I am running into an issue where no matter what I set the script time out to be the server is Giving me a 500 error after like 60 seconds when the process exceeds the configured activity timeout. Here is the example script ? set_time_limit(120); sleep(100); Echo PASSED THE TIME OUT; ? I fully understand this may not be a PHP error but if anyone has ran into this issue with a windows server and can explain in detail how I can adjust the timeout, I would be very grateful. Everything I have read online points to a fcgiext.ini file that does not exist on my server. Anyone know how to help ? Didn't use windows server in about 10 years (Go linux ;)), but did you try this? http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/44ebc761-ac76-4b44-8894-551c9315af6c.mspx - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Time out issue
-Original Message- From: Matijn Woudt [mailto:tijn...@gmail.com] Sent: Saturday, May 12, 2012 3:54 PM To: admin Cc: php-general@lists.php.net Subject: Re: [PHP] Time out issue On Sat, May 12, 2012 at 9:42 PM, admin ad...@buskirkgraphics.com wrote: I am running Windows 2008 R2, IIS 7 I am running into an issue where no matter what I set the script time out to be the server is Giving me a 500 error after like 60 seconds when the process exceeds the configured activity timeout. Here is the example script ? set_time_limit(120); sleep(100); Echo PASSED THE TIME OUT; ? I fully understand this may not be a PHP error but if anyone has ran into this issue with a windows server and can explain in detail how I can adjust the timeout, I would be very grateful. Everything I have read online points to a fcgiext.ini file that does not exist on my server. Anyone know how to help ? Didn't use windows server in about 10 years (Go linux ;)), but did you try this? http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/44ebc761-ac76-4b44-8894-551c9315af6c.mspx - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I had to get Microsoft on the phone to resolve this issue with IIS and FAST-CGI seems you can adjust the Request Timeout and Activity Timeout within the IIS manager and for some reason no documentation leads you to this point. Sorry to bother issue resolved. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Variables via url
On 5/12/2012 7:21 AM, Jim Giner wrote: Of course, someone here with much more knowledge than I could very soon make me look stupid :) Meh, I don't call that looking stupid. I call it a different way of skinning the cat. :) We're all here to learn from one another, right? Thanks for the suggestion. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time out issue
On Sat, May 12, 2012 at 10:19 PM, admin ad...@buskirkgraphics.com wrote: -Original Message- From: Matijn Woudt [mailto:tijn...@gmail.com] Sent: Saturday, May 12, 2012 3:54 PM To: admin Cc: php-general@lists.php.net Subject: Re: [PHP] Time out issue On Sat, May 12, 2012 at 9:42 PM, admin ad...@buskirkgraphics.com wrote: I am running Windows 2008 R2, IIS 7 I am running into an issue where no matter what I set the script time out to be the server is Giving me a 500 error after like 60 seconds when the process exceeds the configured activity timeout. Here is the example script ? set_time_limit(120); sleep(100); Echo PASSED THE TIME OUT; ? I fully understand this may not be a PHP error but if anyone has ran into this issue with a windows server and can explain in detail how I can adjust the timeout, I would be very grateful. Everything I have read online points to a fcgiext.ini file that does not exist on my server. Anyone know how to help ? Didn't use windows server in about 10 years (Go linux ;)), but did you try this? http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/44ebc761-ac76-4b44-8894-551c9315af6c.mspx - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I had to get Microsoft on the phone to resolve this issue with IIS and FAST-CGI seems you can adjust the Request Timeout and Activity Timeout within the IIS manager and for some reason no documentation leads you to this point. Sorry to bother issue resolved. Again, Go linux.. Hehehe ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php