php-general Digest 22 Aug 2008 10:49:33 -0000 Issue 5638
php-general Digest 22 Aug 2008 10:49:33 - Issue 5638 Topics (messages 278490 through 278506): Quick question regarding getcwd() and directory location. 278490 by: Ólafur Waage 278492 by: Micah Gersten 278501 by: Ashley Sheridan 278502 by: Ólafur Waage Restore Leading Zeros in Zip Codes 278491 by: Keith Spiller 278493 by: Micah Gersten 278494 by: Micah Gersten 278496 by: Warren Vail 278497 by: Warren Vail 278498 by: Warren Vail Re: Forward slashes and header requests 278495 by: Dave M G Re: php not reading file properly 278499 by: sean greenslade 278500 by: Ashley Sheridan Re: Licensing 278503 by: Richard Heyes 278504 by: Carlos Medina 278505 by: Richard Heyes stream_select 278506 by: Damien Churchill Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage ---End Message--- ---BeginMessage--- Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage ---End Message--- ---BeginMessage--- How are you browsing to it from within PHP? Depending on how you are doing it, the way to get the cwd is different Ash www.ashleysheridan.co.uk ---BeginMessage--- I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory
Re: Fwd: [PHP] php not reading file properly
So I made a cron jop to copy the log to the web folder every 5 minutes. That worked fine. It seems that php can't read the /var/log/httpd folder without root perms. On Wed, Aug 20, 2008 at 7:53 PM, Ashley Sheridan [EMAIL PROTECTED]wrote: Yeah, Apache is still running, but it is the access log you are trying to read, at the same time that you are Apache is being accessed. Accessing the log from the terminal will be fine while Apache is running, as it is unlikely it is being accessed at the very same instant. Are you able to access other files? Also, have you tried copying the file to another temporary version from within PHP an accessing that? If that doesn't work, try executing a Bash script that copies it someplace. Make sure to run the script in the background, and maybe add a sleep period to it so that it doesn't interfere with Apache accessing things. Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: Micah Gersten [EMAIL PROTECTED] Date: Wed, 20 Aug 2008 19:41:54 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Ashley Sheridan wrote: As it's the Apache access log that you are trying to read in, are you sure that Apache is not in the process of writing to it as you are attempting to read from it? That might explain why it seems to be empty, although I would have thought it would just append the data to the end of the file, rather than rewriting the whole thing. I dunno. Like I said, I can read it thru the terminal. Apache is still running then. As for Micah's response, that function won't work either. On Wed, Aug 20, 2008 at 7:34 PM, Micah Gersten [EMAIL PROTECTED] wrote: If the directory above it doesn't have execute privileges, it won't be able to read it either. Also, why not use the PHP5 function file_get_contents()? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com sean greenslade wrote: Thanks for the advice. I changed the perms to 777 and changed the user and group to apache, but it still won't open. On Wed, Aug 20, 2008 at 3:35 PM, Robbert van Andel [EMAIL PROTECTED]wrote: Does the user your PHP instance runs as have access to the file? It's possible that it runs under a different users depending on if you're running the script on the terminal or in a web browser. The function fopen will return false if the file fails to open. Find out if $fh is equal to false. While you're debugging, you might consider changing the display errors setting to see what warning fopen generates if the file fails to open. From http://us.php.net/fopen Errors/Exceptions If the open fails, the function an error of level *E_WARNING* is generated. You may use @ http://us.php.net/manual/en/language.operators.errorcontrol.phpto suppress this warning. On Wed, Aug 20, 2008 at 12:15 PM, sean greenslade [EMAIL PROTECTED]wrote: I have this snippet of code that is supposed to read the apache access log and display it: ?php $myFile = /var/log/httpd/access_log; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); fclose($fh); echo This weeks apache log (clears every sunday morning):. substr($theData,0,2000); ? For some reason, it displays the logs when I run the php file thru terminal: php -f /web/apache.php but not when I access it thru the web. when I browse to it, it just displays the static text (This weeks apache log (clears every sunday morning):), not the log text. Very confused, zootboy -- Feh. -- Feh.
Re: Fwd: [PHP] php not reading file properly
You can change the permissions on the file, which I believe you said you did. If that didn't work, it must be because you are trying to read from the file at the very same instant that Apache is writing to it logging that you are trying to access it, if that makes sense? Ash www.ashleysheridan.co.uk ---BeginMessage--- So I made a cron jop to copy the log to the web folder every 5 minutes. That worked fine. It seems that php can't read the /var/log/httpd folder without root perms. On Wed, Aug 20, 2008 at 7:53 PM, Ashley Sheridan [EMAIL PROTECTED]wrote: Yeah, Apache is still running, but it is the access log you are trying to read, at the same time that you are Apache is being accessed. Accessing the log from the terminal will be fine while Apache is running, as it is unlikely it is being accessed at the very same instant. Are you able to access other files? Also, have you tried copying the file to another temporary version from within PHP an accessing that? If that doesn't work, try executing a Bash script that copies it someplace. Make sure to run the script in the background, and maybe add a sleep period to it so that it doesn't interfere with Apache accessing things. Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: Micah Gersten [EMAIL PROTECTED] Date: Wed, 20 Aug 2008 19:41:54 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Ashley Sheridan wrote: As it's the Apache access log that you are trying to read in, are you sure that Apache is not in the process of writing to it as you are attempting to read from it? That might explain why it seems to be empty, although I would have thought it would just append the data to the end of the file, rather than rewriting the whole thing. I dunno. Like I said, I can read it thru the terminal. Apache is still running then. As for Micah's response, that function won't work either. On Wed, Aug 20, 2008 at 7:34 PM, Micah Gersten [EMAIL PROTECTED] wrote: If the directory above it doesn't have execute privileges, it won't be able to read it either. Also, why not use the PHP5 function file_get_contents()? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com sean greenslade wrote: Thanks for the advice. I changed the perms to 777 and changed the user and group to apache, but it still won't open. On Wed, Aug 20, 2008 at 3:35 PM, Robbert van Andel [EMAIL PROTECTED]wrote: Does the user your PHP instance runs as have access to the file? It's possible that it runs under a different users depending on if you're running the script on the terminal or in a web browser. The function fopen will return false if the file fails to open. Find out if $fh is equal to false. While you're debugging, you might consider changing the display errors setting to see what warning fopen generates if the file fails to open. From http://us.php.net/fopen Errors/Exceptions If the open fails, the function an error of level *E_WARNING* is generated. You may use @ http://us.php.net/manual/en/language.operators.errorcontrol.phpto suppress this warning. On Wed, Aug 20, 2008 at 12:15 PM, sean greenslade [EMAIL PROTECTED]wrote: I have this snippet of code that is supposed to read the apache access log and display it: ?php $myFile = /var/log/httpd/access_log; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); fclose($fh); echo This weeks apache log (clears every sunday morning):. substr($theData,0,2000); ? For some reason, it displays the logs when I run the php file thru terminal: php -f /web/apache.php but not when I access it thru the web. when I browse to it, it just displays the static text (This weeks apache log (clears every sunday morning):), not the log text. Very confused, zootboy -- Feh. -- Feh. ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
How are you browsing to it from within PHP? Depending on how you are doing it, the way to get the cwd is different Ash www.ashleysheridan.co.uk ---BeginMessage--- I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
Thanks for the reply Micah but i have no interest in the URL. I am looking for the servers local path to the directory. (example: /var/www/directory/ or C:\apache\htdocs\directory\) Also the HTTP_REFERER is empty unless you are linked in from another location. And then it gives you the URL you came from. Ólafur Waage. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Licensing
Hi Per, License costs in EUR, CHF and DKK? Seriously, I would quote the price in one currency only, and leave it for people to convert. Yes I've quoted it in UK pounds, but since the almighty dollah is more well known, I've got an approximate conversion there too. There's one 'm' too many in commmercial. Thanks. My eyesight strikes again. :-) -- Richard Heyes http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Licensing
Richard Heyes schrieb: Hi Per, License costs in EUR, CHF and DKK? Seriously, I would quote the price in one currency only, and leave it for people to convert. Yes I've quoted it in UK pounds, but since the almighty dollah is more well known, I've got an approximate conversion there too. There's one 'm' too many in commmercial. Thanks. My eyesight strikes again. :-) Hi, do not forget the OT on the Subject. Regards Carlos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Licensing
do not forget the OT on the Subject. That results in messages being blocked by the list server? -- Richard Heyes http://www.phpguru.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] stream_select
Is there a known issue with using stream_select with apache2 mod_php? I have a script (http://php.pastebin.com/m601965d) that when run with mod_php doesn't work, but when run with php-cgi from the command line works fine. Thanks in advance, Damien
[PHP] Unsubscribe issues
The guy who wrote the guide lines for unsubscribing must be a lawyer or so. To make a page to find out where the unsubscribe link is in each kind of email type is paranoid. I mean the link is coming from the mail server, so just to say: [EMAIL PROTECTED] would be sufficient, wouldn't it? Maybe some (other lawyer) could clean up that unsubscribe page. (Replies would not reach me, save your energy!) bye Ronald
Re: [PHP] Unsubscribe issues
I assume Ronald won't see this, but I've mentioned it before. The emails coming from the mailing list all have an unsubscribe link in the header information. Just my 2p (I'm British, we don't do cents ;) ) Ash www.ashleysheridan.co.uk ---BeginMessage--- The guy who wrote the guide lines for unsubscribing must be a lawyer or so. To make a page to find out where the unsubscribe link is in each kind of email type is paranoid. I mean the link is coming from the mail server, so just to say: [EMAIL PROTECTED] would be sufficient, wouldn't it? Maybe some (other lawyer) could clean up that unsubscribe page. (Replies would not reach me, save your energy!) bye Ronald ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unsubscribe issues
On Fri, Aug 22, 2008 at 9:10 AM, Ashley Sheridan [EMAIL PROTECTED] wrote: I assume Ronald won't see this, but I've mentioned it before. The emails coming from the mailing list all have an unsubscribe link in the header information. Just my 2p (I'm British, we don't do cents ;) ) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: Ronald Wiplinger [EMAIL PROTECTED] To: php-general php-general@lists.php.net Date: Fri, 22 Aug 2008 21:02:54 +0800 Subject: [PHP] Unsubscribe issues The guy who wrote the guide lines for unsubscribing must be a lawyer or so. To make a page to find out where the unsubscribe link is in each kind of email type is paranoid. I mean the link is coming from the mail server, so just to say: [EMAIL PROTECTED] would be sufficient, wouldn't it? Maybe some (other lawyer) could clean up that unsubscribe page. (Replies would not reach me, save your energy!) bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'm NOT looking to unsubscribe, but I am curious about something. How come Ash's message has the list footer (complete with the unsubscribe link) and Ronald's does not? I thought it was supposed to get appended to all messages from the list. (Actually, looking back at some other messages in my box, it seems kind of hit and miss.) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unsubscribe issues
That is strange. I hadn't noticed anything, so I just assumed everyone had these headers attached. Ash www.ashleysheridan.co.uk ---BeginMessage--- On Fri, Aug 22, 2008 at 9:10 AM, Ashley Sheridan [EMAIL PROTECTED] wrote: I assume Ronald won't see this, but I've mentioned it before. The emails coming from the mailing list all have an unsubscribe link in the header information. Just my 2p (I'm British, we don't do cents ;) ) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: Ronald Wiplinger [EMAIL PROTECTED] To: php-general php-general@lists.php.net Date: Fri, 22 Aug 2008 21:02:54 +0800 Subject: [PHP] Unsubscribe issues The guy who wrote the guide lines for unsubscribing must be a lawyer or so. To make a page to find out where the unsubscribe link is in each kind of email type is paranoid. I mean the link is coming from the mail server, so just to say: [EMAIL PROTECTED] would be sufficient, wouldn't it? Maybe some (other lawyer) could clean up that unsubscribe page. (Replies would not reach me, save your energy!) bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'm NOT looking to unsubscribe, but I am curious about something. How come Ash's message has the list footer (complete with the unsubscribe link) and Ronald's does not? I thought it was supposed to get appended to all messages from the list. (Actually, looking back at some other messages in my box, it seems kind of hit and miss.) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unsubscribe issues
Actually, I just checked Rons message, and it does have the right headers attached. What email client are you using to view the headers? Ash www.ashleysheridan.co.uk ---BeginMessage--- On Fri, Aug 22, 2008 at 9:10 AM, Ashley Sheridan [EMAIL PROTECTED] wrote: I assume Ronald won't see this, but I've mentioned it before. The emails coming from the mailing list all have an unsubscribe link in the header information. Just my 2p (I'm British, we don't do cents ;) ) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: Ronald Wiplinger [EMAIL PROTECTED] To: php-general php-general@lists.php.net Date: Fri, 22 Aug 2008 21:02:54 +0800 Subject: [PHP] Unsubscribe issues The guy who wrote the guide lines for unsubscribing must be a lawyer or so. To make a page to find out where the unsubscribe link is in each kind of email type is paranoid. I mean the link is coming from the mail server, so just to say: [EMAIL PROTECTED] would be sufficient, wouldn't it? Maybe some (other lawyer) could clean up that unsubscribe page. (Replies would not reach me, save your energy!) bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'm NOT looking to unsubscribe, but I am curious about something. How come Ash's message has the list footer (complete with the unsubscribe link) and Ronald's does not? I thought it was supposed to get appended to all messages from the list. (Actually, looking back at some other messages in my box, it seems kind of hit and miss.) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unsubscribe issues
Andrew Ballard wrote: On Fri, Aug 22, 2008 at 9:10 AM, Ashley Sheridan [EMAIL PROTECTED] wrote: I assume Ronald won't see this, but I've mentioned it before. The emails coming from the mailing list all have an unsubscribe link in the header information. Just my 2p (I'm British, we don't do cents ;) ) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: Ronald Wiplinger [EMAIL PROTECTED] To: php-general php-general@lists.php.net Date: Fri, 22 Aug 2008 21:02:54 +0800 Subject: [PHP] Unsubscribe issues The guy who wrote the guide lines for unsubscribing must be a lawyer or so. To make a page to find out where the unsubscribe link is in each kind of email type is paranoid. I mean the link is coming from the mail server, so just to say: [EMAIL PROTECTED] would be sufficient, wouldn't it? Maybe some (other lawyer) could clean up that unsubscribe page. (Replies would not reach me, save your energy!) bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'm NOT looking to unsubscribe, but I am curious about something. How come Ash's message has the list footer (complete with the unsubscribe link) and Ronald's does not? I thought it was supposed to get appended to all messages from the list. (Actually, looking back at some other messages in my box, it seems kind of hit and miss.) Andrew It's because some use the newsserver and some are subscribed to the mailinglist directly. Newsserver subscriptions don't have them attached, while mailinglist-mails do I believe. - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unsubscribe issues
On Fri, Aug 22, 2008 at 9:50 AM, Ashley Sheridan [EMAIL PROTECTED] wrote: Actually, I just checked Rons message, and it does have the right headers attached. What email client are you using to view the headers? Ash www.ashleysheridan.co.uk -- Forwarded message -- From: Andrew Ballard [EMAIL PROTECTED] To: PHP General list php-general@lists.php.net Date: Fri, 22 Aug 2008 09:38:31 -0400 Subject: Re: [PHP] Unsubscribe issues On Fri, Aug 22, 2008 at 9:10 AM, Ashley Sheridan [EMAIL PROTECTED] wrote: I assume Ronald won't see this, but I've mentioned it before. The emails coming from the mailing list all have an unsubscribe link in the header information. Just my 2p (I'm British, we don't do cents ;) ) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: Ronald Wiplinger [EMAIL PROTECTED] To: php-general php-general@lists.php.net Date: Fri, 22 Aug 2008 21:02:54 +0800 Subject: [PHP] Unsubscribe issues The guy who wrote the guide lines for unsubscribing must be a lawyer or so. To make a page to find out where the unsubscribe link is in each kind of email type is paranoid. I mean the link is coming from the mail server, so just to say: [EMAIL PROTECTED] would be sufficient, wouldn't it? Maybe some (other lawyer) could clean up that unsubscribe page. (Replies would not reach me, save your energy!) bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'm NOT looking to unsubscribe, but I am curious about something. How come Ash's message has the list footer (complete with the unsubscribe link) and Ronald's does not? I thought it was supposed to get appended to all messages from the list. (Actually, looking back at some other messages in my box, it seems kind of hit and miss.) Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'm just using G-mail's default website. I just looked, and I do see the unsubscribe in the headers of both your and Ronald's original messages, but I was talking about the footer that should be in the message body. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unsubscribe issues
I think people here are talking about the message footers, not the message headers, which are totally different things. I'm not sure how you'd go about viewing them on Outlook, as I use Evolution, and it has a nice convenient, View All Message Headers option. Ash www.ashleysheridan.co.uk ---BeginMessage--- Andrew Ballard wrote: On Fri, Aug 22, 2008 at 9:10 AM, Ashley Sheridan [EMAIL PROTECTED] wrote: I assume Ronald won't see this, but I've mentioned it before. The emails coming from the mailing list all have an unsubscribe link in the header information. Just my 2p (I'm British, we don't do cents ;) ) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: Ronald Wiplinger [EMAIL PROTECTED] To: php-general php-general@lists.php.net Date: Fri, 22 Aug 2008 21:02:54 +0800 Subject: [PHP] Unsubscribe issues The guy who wrote the guide lines for unsubscribing must be a lawyer or so. To make a page to find out where the unsubscribe link is in each kind of email type is paranoid. I mean the link is coming from the mail server, so just to say: [EMAIL PROTECTED] would be sufficient, wouldn't it? Maybe some (other lawyer) could clean up that unsubscribe page. (Replies would not reach me, save your energy!) bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'm NOT looking to unsubscribe, but I am curious about something. How come Ash's message has the list footer (complete with the unsubscribe link) and Ronald's does not? I thought it was supposed to get appended to all messages from the list. (Actually, looking back at some other messages in my box, it seems kind of hit and miss.) Andrew It's because some use the newsserver and some are subscribed to the mailinglist directly. Newsserver subscriptions don't have them attached, while mailinglist-mails do I believe. - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unsubscribe issues
On Fri, Aug 22, 2008 at 9:51 AM, Maciek Sokolewicz [EMAIL PROTECTED] wrote: Andrew Ballard wrote: On Fri, Aug 22, 2008 at 9:10 AM, Ashley Sheridan [EMAIL PROTECTED] wrote: I assume Ronald won't see this, but I've mentioned it before. The emails coming from the mailing list all have an unsubscribe link in the header information. Just my 2p (I'm British, we don't do cents ;) ) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: Ronald Wiplinger [EMAIL PROTECTED] To: php-general php-general@lists.php.net Date: Fri, 22 Aug 2008 21:02:54 +0800 Subject: [PHP] Unsubscribe issues The guy who wrote the guide lines for unsubscribing must be a lawyer or so. To make a page to find out where the unsubscribe link is in each kind of email type is paranoid. I mean the link is coming from the mail server, so just to say: [EMAIL PROTECTED] would be sufficient, wouldn't it? Maybe some (other lawyer) could clean up that unsubscribe page. (Replies would not reach me, save your energy!) bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'm NOT looking to unsubscribe, but I am curious about something. How come Ash's message has the list footer (complete with the unsubscribe link) and Ronald's does not? I thought it was supposed to get appended to all messages from the list. (Actually, looking back at some other messages in my box, it seems kind of hit and miss.) Andrew It's because some use the newsserver and some are subscribed to the mailinglist directly. Newsserver subscriptions don't have them attached, while mailinglist-mails do I believe. - Tul Interesting. I just wondered, since I've noticed that a frequent response to people who ask how they can unsubscribe is Read the footer on every single mail posted to this list to unsubscribe. It appears that the footer is NOT actually on every single mail posted to this list. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Fwd: [PHP] php not reading file properly
Yeah, I tried changing the perms, and that didn't work. I originally made the cron job put the temp copy in the same logs folder, but it refused to open that. I changed it to put the temp copy in the web folder, and it can read that. I think apache and/or php may have certain restrictions that keep them from accessing important system folders. On Fri, Aug 22, 2008 at 3:09 AM, Ashley Sheridan [EMAIL PROTECTED]wrote: You can change the permissions on the file, which I believe you said you did. If that didn't work, it must be because you are trying to read from the file at the very same instant that Apache is writing to it logging that you are trying to access it, if that makes sense? Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: php-general@lists.php.net Date: Fri, 22 Aug 2008 02:31:47 -0400 Subject: Re: Fwd: [PHP] php not reading file properly So I made a cron jop to copy the log to the web folder every 5 minutes. That worked fine. It seems that php can't read the /var/log/httpd folder without root perms. On Wed, Aug 20, 2008 at 7:53 PM, Ashley Sheridan [EMAIL PROTECTED]wrote: Yeah, Apache is still running, but it is the access log you are trying to read, at the same time that you are Apache is being accessed. Accessing the log from the terminal will be fine while Apache is running, as it is unlikely it is being accessed at the very same instant. Are you able to access other files? Also, have you tried copying the file to another temporary version from within PHP an accessing that? If that doesn't work, try executing a Bash script that copies it someplace. Make sure to run the script in the background, and maybe add a sleep period to it so that it doesn't interfere with Apache accessing things. Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: Micah Gersten [EMAIL PROTECTED] Date: Wed, 20 Aug 2008 19:41:54 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Ashley Sheridan wrote: As it's the Apache access log that you are trying to read in, are you sure that Apache is not in the process of writing to it as you are attempting to read from it? That might explain why it seems to be empty, although I would have thought it would just append the data to the end of the file, rather than rewriting the whole thing. I dunno. Like I said, I can read it thru the terminal. Apache is still running then. As for Micah's response, that function won't work either. On Wed, Aug 20, 2008 at 7:34 PM, Micah Gersten [EMAIL PROTECTED] wrote: If the directory above it doesn't have execute privileges, it won't be able to read it either. Also, why not use the PHP5 function file_get_contents()? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com sean greenslade wrote: Thanks for the advice. I changed the perms to 777 and changed the user and group to apache, but it still won't open. On Wed, Aug 20, 2008 at 3:35 PM, Robbert van Andel [EMAIL PROTECTED]wrote: Does the user your PHP instance runs as have access to the file? It's possible that it runs under a different users depending on if you're running the script on the terminal or in a web browser. The function fopen will return false if the file fails to open. Find out if $fh is equal to false. While you're debugging, you might consider changing the display errors setting to see what warning fopen generates if the file fails to open. From http://us.php.net/fopen Errors/Exceptions If the open fails, the function an error of level *E_WARNING* is generated. You may use @ http://us.php.net/manual/en/language.operators.errorcontrol.phpto suppress this warning. On Wed, Aug 20, 2008 at 12:15 PM, sean greenslade [EMAIL PROTECTED]wrote: I have this snippet of code that is supposed to read the apache access log and display it: ?php $myFile = /var/log/httpd/access_log; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); fclose($fh); echo This weeks apache log (clears every sunday morning):. substr($theData,0,2000); ? For some reason, it displays the logs when I run the php file thru terminal: php -f /web/apache.php but not when I access it thru the web. when I browse to it, it just displays the static text (This weeks apache log (clears every sunday morning):), not the log text. Very confused, zootboy -- Feh. -- Feh. -- Feh.
Re: [PHP] Unsubscribe issues
Hence my response of read the headers ;) Ash www.ashleysheridan.co.uk ---BeginMessage--- On Fri, Aug 22, 2008 at 9:51 AM, Maciek Sokolewicz [EMAIL PROTECTED] wrote: Andrew Ballard wrote: On Fri, Aug 22, 2008 at 9:10 AM, Ashley Sheridan [EMAIL PROTECTED] wrote: I assume Ronald won't see this, but I've mentioned it before. The emails coming from the mailing list all have an unsubscribe link in the header information. Just my 2p (I'm British, we don't do cents ;) ) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: Ronald Wiplinger [EMAIL PROTECTED] To: php-general php-general@lists.php.net Date: Fri, 22 Aug 2008 21:02:54 +0800 Subject: [PHP] Unsubscribe issues The guy who wrote the guide lines for unsubscribing must be a lawyer or so. To make a page to find out where the unsubscribe link is in each kind of email type is paranoid. I mean the link is coming from the mail server, so just to say: [EMAIL PROTECTED] would be sufficient, wouldn't it? Maybe some (other lawyer) could clean up that unsubscribe page. (Replies would not reach me, save your energy!) bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'm NOT looking to unsubscribe, but I am curious about something. How come Ash's message has the list footer (complete with the unsubscribe link) and Ronald's does not? I thought it was supposed to get appended to all messages from the list. (Actually, looking back at some other messages in my box, it seems kind of hit and miss.) Andrew It's because some use the newsserver and some are subscribed to the mailinglist directly. Newsserver subscriptions don't have them attached, while mailinglist-mails do I believe. - Tul Interesting. I just wondered, since I've noticed that a frequent response to people who ask how they can unsubscribe is Read the footer on every single mail posted to this list to unsubscribe. It appears that the footer is NOT actually on every single mail posted to this list. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Fwd: [PHP] php not reading file properly
The log file was in the process of being written to as you were trying to read it. It's a bit like trying to look at a quark. By doing so, you've already affected its position. Although, unlike a quark, you can create a copy of the log file ;) Ash www.ashleysheridan.co.uk ---BeginMessage--- Yeah, I tried changing the perms, and that didn't work. I originally made the cron job put the temp copy in the same logs folder, but it refused to open that. I changed it to put the temp copy in the web folder, and it can read that. I think apache and/or php may have certain restrictions that keep them from accessing important system folders. On Fri, Aug 22, 2008 at 3:09 AM, Ashley Sheridan [EMAIL PROTECTED]wrote: You can change the permissions on the file, which I believe you said you did. If that didn't work, it must be because you are trying to read from the file at the very same instant that Apache is writing to it logging that you are trying to access it, if that makes sense? Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: php-general@lists.php.net Date: Fri, 22 Aug 2008 02:31:47 -0400 Subject: Re: Fwd: [PHP] php not reading file properly So I made a cron jop to copy the log to the web folder every 5 minutes. That worked fine. It seems that php can't read the /var/log/httpd folder without root perms. On Wed, Aug 20, 2008 at 7:53 PM, Ashley Sheridan [EMAIL PROTECTED]wrote: Yeah, Apache is still running, but it is the access log you are trying to read, at the same time that you are Apache is being accessed. Accessing the log from the terminal will be fine while Apache is running, as it is unlikely it is being accessed at the very same instant. Are you able to access other files? Also, have you tried copying the file to another temporary version from within PHP an accessing that? If that doesn't work, try executing a Bash script that copies it someplace. Make sure to run the script in the background, and maybe add a sleep period to it so that it doesn't interfere with Apache accessing things. Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: Micah Gersten [EMAIL PROTECTED] Date: Wed, 20 Aug 2008 19:41:54 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Ashley Sheridan wrote: As it's the Apache access log that you are trying to read in, are you sure that Apache is not in the process of writing to it as you are attempting to read from it? That might explain why it seems to be empty, although I would have thought it would just append the data to the end of the file, rather than rewriting the whole thing. I dunno. Like I said, I can read it thru the terminal. Apache is still running then. As for Micah's response, that function won't work either. On Wed, Aug 20, 2008 at 7:34 PM, Micah Gersten [EMAIL PROTECTED] wrote: If the directory above it doesn't have execute privileges, it won't be able to read it either. Also, why not use the PHP5 function file_get_contents()? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com sean greenslade wrote: Thanks for the advice. I changed the perms to 777 and changed the user and group to apache, but it still won't open. On Wed, Aug 20, 2008 at 3:35 PM, Robbert van Andel [EMAIL PROTECTED]wrote: Does the user your PHP instance runs as have access to the file? It's possible that it runs under a different users depending on if you're running the script on the terminal or in a web browser. The function fopen will return false if the file fails to open. Find out if $fh is equal to false. While you're debugging, you might consider changing the display errors setting to see what warning fopen generates if the file fails to open. From http://us.php.net/fopen Errors/Exceptions If the open fails, the function an error of level *E_WARNING* is generated. You may use @ http://us.php.net/manual/en/language.operators.errorcontrol.phpto suppress this warning. On Wed, Aug 20, 2008 at 12:15 PM, sean greenslade [EMAIL PROTECTED]wrote: I have this snippet of code that is supposed to read the apache access log and display it: ?php $myFile = /var/log/httpd/access_log; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); fclose($fh); echo This weeks apache log (clears every sunday morning):. substr($theData,0,2000); ? For some reason, it displays the logs when I run the php file thru terminal: php -f /web/apache.php but not when I access it thru the web. when I browse to it, it just displays the static text (This weeks apache log (clears every sunday
Re: [PHP] Unsubscribe issues
On Fri, Aug 22, 2008 at 10:10 AM, Ashley Sheridan [EMAIL PROTECTED] wrote: Hence my response of read the headers ;) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: Andrew Ballard [EMAIL PROTECTED] To: PHP General list php-general@lists.php.net Date: Fri, 22 Aug 2008 10:03:08 -0400 Subject: Re: [PHP] Unsubscribe issues On Fri, Aug 22, 2008 at 9:51 AM, Maciek Sokolewicz [EMAIL PROTECTED] wrote: Andrew Ballard wrote: On Fri, Aug 22, 2008 at 9:10 AM, Ashley Sheridan [EMAIL PROTECTED] wrote: I assume Ronald won't see this, but I've mentioned it before. The emails coming from the mailing list all have an unsubscribe link in the header information. Just my 2p (I'm British, we don't do cents ;) ) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: Ronald Wiplinger [EMAIL PROTECTED] To: php-general php-general@lists.php.net Date: Fri, 22 Aug 2008 21:02:54 +0800 Subject: [PHP] Unsubscribe issues The guy who wrote the guide lines for unsubscribing must be a lawyer or so. To make a page to find out where the unsubscribe link is in each kind of email type is paranoid. I mean the link is coming from the mail server, so just to say: [EMAIL PROTECTED] would be sufficient, wouldn't it? Maybe some (other lawyer) could clean up that unsubscribe page. (Replies would not reach me, save your energy!) bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'm NOT looking to unsubscribe, but I am curious about something. How come Ash's message has the list footer (complete with the unsubscribe link) and Ronald's does not? I thought it was supposed to get appended to all messages from the list. (Actually, looking back at some other messages in my box, it seems kind of hit and miss.) Andrew It's because some use the newsserver and some are subscribed to the mailinglist directly. Newsserver subscriptions don't have them attached, while mailinglist-mails do I believe. - Tul Interesting. I just wondered, since I've noticed that a frequent response to people who ask how they can unsubscribe is Read the footer on every single mail posted to this list to unsubscribe. It appears that the footer is NOT actually on every single mail posted to this list. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Well, technically, I don't see it in ALL the headers either. Like I said - I do see it in your and Ronald's first messages in this thread, but it seems not to be in the headers of many replies. I wonder if that's because the replies often already have the headers buried in them from one or more of the quoted messages. At any rate, I'm not trying to start anything here. I just wanted to make an observation since in the past (not in your response) I've seen people reply rather curtly when the question is asked. I know the answer is out there and isn't too difficult to find, but it seems that perhaps the answer isn't QUITE as obvious as some people think. Andrew Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Fwd: [PHP] php not reading file properly
Yeah, but it wouldn't read access_log.tmp, which wasn't being written to at the time of loading. I think the whole logs folder is restricted from php access. On Fri, Aug 22, 2008 at 10:13 AM, Ashley Sheridan [EMAIL PROTECTED]wrote: The log file was in the process of being written to as you were trying to read it. It's a bit like trying to look at a quark. By doing so, you've already affected its position. Although, unlike a quark, you can create a copy of the log file ;) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: php-general@lists.php.net Date: Fri, 22 Aug 2008 10:04:07 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Yeah, I tried changing the perms, and that didn't work. I originally made the cron job put the temp copy in the same logs folder, but it refused to open that. I changed it to put the temp copy in the web folder, and it can read that. I think apache and/or php may have certain restrictions that keep them from accessing important system folders. On Fri, Aug 22, 2008 at 3:09 AM, Ashley Sheridan [EMAIL PROTECTED]wrote: You can change the permissions on the file, which I believe you said you did. If that didn't work, it must be because you are trying to read from the file at the very same instant that Apache is writing to it logging that you are trying to access it, if that makes sense? Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: php-general@lists.php.net Date: Fri, 22 Aug 2008 02:31:47 -0400 Subject: Re: Fwd: [PHP] php not reading file properly So I made a cron jop to copy the log to the web folder every 5 minutes. That worked fine. It seems that php can't read the /var/log/httpd folder without root perms. On Wed, Aug 20, 2008 at 7:53 PM, Ashley Sheridan [EMAIL PROTECTED]wrote: Yeah, Apache is still running, but it is the access log you are trying to read, at the same time that you are Apache is being accessed. Accessing the log from the terminal will be fine while Apache is running, as it is unlikely it is being accessed at the very same instant. Are you able to access other files? Also, have you tried copying the file to another temporary version from within PHP an accessing that? If that doesn't work, try executing a Bash script that copies it someplace. Make sure to run the script in the background, and maybe add a sleep period to it so that it doesn't interfere with Apache accessing things. Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: Micah Gersten [EMAIL PROTECTED] Date: Wed, 20 Aug 2008 19:41:54 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Ashley Sheridan wrote: As it's the Apache access log that you are trying to read in, are you sure that Apache is not in the process of writing to it as you are attempting to read from it? That might explain why it seems to be empty, although I would have thought it would just append the data to the end of the file, rather than rewriting the whole thing. I dunno. Like I said, I can read it thru the terminal. Apache is still running then. As for Micah's response, that function won't work either. On Wed, Aug 20, 2008 at 7:34 PM, Micah Gersten [EMAIL PROTECTED] wrote: If the directory above it doesn't have execute privileges, it won't be able to read it either. Also, why not use the PHP5 function file_get_contents()? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com sean greenslade wrote: Thanks for the advice. I changed the perms to 777 and changed the user and group to apache, but it still won't open. On Wed, Aug 20, 2008 at 3:35 PM, Robbert van Andel [EMAIL PROTECTED]wrote: Does the user your PHP instance runs as have access to the file? It's possible that it runs under a different users depending on if you're running the script on the terminal or in a web browser. The function fopen will return false if the file fails to open. Find out if $fh is equal to false. While you're debugging, you might consider changing the display errors setting to see what warning fopen generates if the file fails to open. From http://us.php.net/fopen Errors/Exceptions If the open fails, the function an error of level *E_WARNING* is generated. You may use @ http://us.php.net/manual/en/language.operators.errorcontrol.phpto suppress this warning. On Wed, Aug 20, 2008 at 12:15 PM, sean greenslade [EMAIL PROTECTED]wrote: I have this snippet of code that is supposed to read the apache access log
Re: Fwd: [PHP] php not reading file properly
Are you sure they are both not accessed at around about the same time? Look at the timestamps. The only analysis I've ever done with logs has been offline, so I've not run into this problem before. Ash www.ashleysheridan.co.uk ---BeginMessage--- Yeah, but it wouldn't read access_log.tmp, which wasn't being written to at the time of loading. I think the whole logs folder is restricted from php access. On Fri, Aug 22, 2008 at 10:13 AM, Ashley Sheridan [EMAIL PROTECTED]wrote: The log file was in the process of being written to as you were trying to read it. It's a bit like trying to look at a quark. By doing so, you've already affected its position. Although, unlike a quark, you can create a copy of the log file ;) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: php-general@lists.php.net Date: Fri, 22 Aug 2008 10:04:07 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Yeah, I tried changing the perms, and that didn't work. I originally made the cron job put the temp copy in the same logs folder, but it refused to open that. I changed it to put the temp copy in the web folder, and it can read that. I think apache and/or php may have certain restrictions that keep them from accessing important system folders. On Fri, Aug 22, 2008 at 3:09 AM, Ashley Sheridan [EMAIL PROTECTED]wrote: You can change the permissions on the file, which I believe you said you did. If that didn't work, it must be because you are trying to read from the file at the very same instant that Apache is writing to it logging that you are trying to access it, if that makes sense? Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: php-general@lists.php.net Date: Fri, 22 Aug 2008 02:31:47 -0400 Subject: Re: Fwd: [PHP] php not reading file properly So I made a cron jop to copy the log to the web folder every 5 minutes. That worked fine. It seems that php can't read the /var/log/httpd folder without root perms. On Wed, Aug 20, 2008 at 7:53 PM, Ashley Sheridan [EMAIL PROTECTED]wrote: Yeah, Apache is still running, but it is the access log you are trying to read, at the same time that you are Apache is being accessed. Accessing the log from the terminal will be fine while Apache is running, as it is unlikely it is being accessed at the very same instant. Are you able to access other files? Also, have you tried copying the file to another temporary version from within PHP an accessing that? If that doesn't work, try executing a Bash script that copies it someplace. Make sure to run the script in the background, and maybe add a sleep period to it so that it doesn't interfere with Apache accessing things. Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: Micah Gersten [EMAIL PROTECTED] Date: Wed, 20 Aug 2008 19:41:54 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Ashley Sheridan wrote: As it's the Apache access log that you are trying to read in, are you sure that Apache is not in the process of writing to it as you are attempting to read from it? That might explain why it seems to be empty, although I would have thought it would just append the data to the end of the file, rather than rewriting the whole thing. I dunno. Like I said, I can read it thru the terminal. Apache is still running then. As for Micah's response, that function won't work either. On Wed, Aug 20, 2008 at 7:34 PM, Micah Gersten [EMAIL PROTECTED] wrote: If the directory above it doesn't have execute privileges, it won't be able to read it either. Also, why not use the PHP5 function file_get_contents()? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com sean greenslade wrote: Thanks for the advice. I changed the perms to 777 and changed the user and group to apache, but it still won't open. On Wed, Aug 20, 2008 at 3:35 PM, Robbert van Andel [EMAIL PROTECTED]wrote: Does the user your PHP instance runs as have access to the file? It's possible that it runs under a different users depending on if you're running the script on the terminal or in a web browser. The function fopen will return false if the file fails to open. Find out if $fh is equal to false. While you're debugging, you might consider changing the display errors setting to see what warning fopen generates if the file fails to open. From http://us.php.net/fopen Errors/Exceptions If the open fails, the function an error of level *E_WARNING* is generated. You may use @
Re: Fwd: [PHP] php not reading file properly
What are the permssions of /var/log and /var/log/httpd? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com sean greenslade wrote: Yeah, but it wouldn't read access_log.tmp, which wasn't being written to at the time of loading. I think the whole logs folder is restricted from php access. On Fri, Aug 22, 2008 at 10:13 AM, Ashley Sheridan [EMAIL PROTECTED]wrote: The log file was in the process of being written to as you were trying to read it. It's a bit like trying to look at a quark. By doing so, you've already affected its position. Although, unlike a quark, you can create a copy of the log file ;) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: php-general@lists.php.net Date: Fri, 22 Aug 2008 10:04:07 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Yeah, I tried changing the perms, and that didn't work. I originally made the cron job put the temp copy in the same logs folder, but it refused to open that. I changed it to put the temp copy in the web folder, and it can read that. I think apache and/or php may have certain restrictions that keep them from accessing important system folders. On Fri, Aug 22, 2008 at 3:09 AM, Ashley Sheridan [EMAIL PROTECTED]wrote: You can change the permissions on the file, which I believe you said you did. If that didn't work, it must be because you are trying to read from the file at the very same instant that Apache is writing to it logging that you are trying to access it, if that makes sense? Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: php-general@lists.php.net Date: Fri, 22 Aug 2008 02:31:47 -0400 Subject: Re: Fwd: [PHP] php not reading file properly So I made a cron jop to copy the log to the web folder every 5 minutes. That worked fine. It seems that php can't read the /var/log/httpd folder without root perms. On Wed, Aug 20, 2008 at 7:53 PM, Ashley Sheridan [EMAIL PROTECTED]wrote: Yeah, Apache is still running, but it is the access log you are trying to read, at the same time that you are Apache is being accessed. Accessing the log from the terminal will be fine while Apache is running, as it is unlikely it is being accessed at the very same instant. Are you able to access other files? Also, have you tried copying the file to another temporary version from within PHP an accessing that? If that doesn't work, try executing a Bash script that copies it someplace. Make sure to run the script in the background, and maybe add a sleep period to it so that it doesn't interfere with Apache accessing things. Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: Micah Gersten [EMAIL PROTECTED] Date: Wed, 20 Aug 2008 19:41:54 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Ashley Sheridan wrote: As it's the Apache access log that you are trying to read in, are you sure that Apache is not in the process of writing to it as you are attempting to read from it? That might explain why it seems to be empty, although I would have thought it would just append the data to the end of the file, rather than rewriting the whole thing. I dunno. Like I said, I can read it thru the terminal. Apache is still running then. As for Micah's response, that function won't work either. On Wed, Aug 20, 2008 at 7:34 PM, Micah Gersten [EMAIL PROTECTED] wrote: If the directory above it doesn't have execute privileges, it won't be able to read it either. Also, why not use the PHP5 function file_get_contents()? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com sean greenslade wrote: Thanks for the advice. I changed the perms to 777 and changed the user and group to apache, but it still won't open. On Wed, Aug 20, 2008 at 3:35 PM, Robbert van Andel [EMAIL PROTECTED]wrote: Does the user your PHP instance runs as have access to the file? It's possible that it runs under a different users depending on if you're running the script on the terminal or in a web browser. The function fopen will return false if the file fails to open. Find out if $fh is equal to false. While you're debugging, you might consider changing the display errors setting to see what warning fopen generates if the file fails to open. From http://us.php.net/fopen Errors/Exceptions If the open fails, the function an
Re: [PHP] Unsubscribe issues
Ashley Sheridan wrote: I think people here are talking about the message footers, not the message headers, which are totally different things. I'm not sure how you'd go about viewing them on Outlook, as I use Evolution, and it has a nice convenient, View All Message Headers option. Ash www.ashleysheridan.co.uk Subject: Re: [PHP] Unsubscribe issues From: Maciek Sokolewicz [EMAIL PROTECTED] Date: Fri, 22 Aug 2008 15:51:38 +0200 To: Andrew Ballard [EMAIL PROTECTED] To: Andrew Ballard [EMAIL PROTECTED] CC: PHP General list php-general@lists.php.net Andrew Ballard wrote: On Fri, Aug 22, 2008 at 9:10 AM, Ashley Sheridan [EMAIL PROTECTED] wrote: I assume Ronald won't see this, but I've mentioned it before. The emails coming from the mailing list all have an unsubscribe link in the header information. Just my 2p (I'm British, we don't do cents ;) ) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: Ronald Wiplinger [EMAIL PROTECTED] To: php-general php-general@lists.php.net Date: Fri, 22 Aug 2008 21:02:54 +0800 Subject: [PHP] Unsubscribe issues The guy who wrote the guide lines for unsubscribing must be a lawyer or so. To make a page to find out where the unsubscribe link is in each kind of email type is paranoid. I mean the link is coming from the mail server, so just to say: [EMAIL PROTECTED] would be sufficient, wouldn't it? Maybe some (other lawyer) could clean up that unsubscribe page. (Replies would not reach me, save your energy!) bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'm NOT looking to unsubscribe, but I am curious about something. How come Ash's message has the list footer (complete with the unsubscribe link) and Ronald's does not? I thought it was supposed to get appended to all messages from the list. (Actually, looking back at some other messages in my box, it seems kind of hit and miss.) Andrew It's because some use the newsserver and some are subscribed to the mailinglist directly. Newsserver subscriptions don't have them attached, while mailinglist-mails do I believe. - Tul Both are added by the mailinglist-software before resending them. Thunderbird can view all headers easily aswell; I don't use outlook either, but I believe I did see an option to view them there once... some time ago... - Tul P.S. Please don't top-post. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Which Exception to use ....
here is a list of built in Exception classes, I'd figured I'd start using them, and save on rolling my own: Exception ErrorException DOMException LogicException BadFunctionCallException BadMethodCallException DomainException InvalidArgumentException LengthException OutOfRangeException RuntimeException OutOfBoundsException OverflowException RangeException UnderflowException UnexpectedValueException PDOException SQLiteException ReflectionException mysqli_sql_exception PharException for starters, what is meant by DomainException? and ErrorException? secondly if you wanted to throw an exception for a missing config file in your app, which would you choose? if you ask me only Exception is really correct in this instance, but it's not very descriptive is it. the last five in the list are only handy if you use those extensions, and then only in terms of catching. anyone actually using these built-ins in their work? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restore Leading Zeros in Zip Codes
At 8:44 PM -0600 8/21/08, Keith Spiller wrote: Hi, RE: Restore Leading Zeros in Zip Codes Does anyone happen to have a script that will restore the leading zeros in a mixed data set of 5 digit zip codes and 10 digit zip+4 codes? Any suggestions? Thanks, Keith Keith: Why take them out in the first place? Keep the zip code as a string. After all, not all countries use just numbers. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
You might want to try a Redirect Rule or rewrite which would tell you the HTTP PATH. AFAIK, there is no way to know which directory they tried to access unless you write your own index.php and store it in a session variable. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: Thanks for the reply Micah but i have no interest in the URL. I am looking for the servers local path to the directory. (example: /var/www/directory/ or C:\apache\htdocs\directory\) Also the HTTP_REFERER is empty unless you are linked in from another location. And then it gives you the URL you came from. Ólafur Waage. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: Sale 79% OFF !!!
At 2:26 PM +0100 8/21/08, Ashley Sheridan wrote: I don't understand how people can fall for this kind of thing, all those Nigerian scams and the like. For every person that falls for it, a million more emails get sent, making everyone elses lives hell :( Ash www.ashleysheridan.co.uk I hate to admit to this, but some 15 years ago I was consulting for a company doing oil exploration in Nigeria and I received a very elaborate and believable Nigerian scam. It was complete with signed and official documents from both the Nigerian Government and the Bank of Nigeria. I passed the proposal through two attorneys and the decision was to participate. Of course nothing happened and we did not lose anything. But the first Nigerian scams were very believable. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unsubscribe issues
At 4:28 PM +0200 8/22/08, Maciek Sokolewicz wrote: Ashley Sheridan wrote: I think people here are talking about the message footers, not the message headers, which are totally different things. I'm not sure how you'd go about viewing them on Outlook, as I use Evolution, and it has a nice convenient, View All Message Headers option. Ash www.ashleysheridan.co.uk -snip- - Tul Both are added by the mailinglist-software before resending them. Thunderbird can view all headers easily aswell; I don't use outlook either, but I believe I did see an option to view them there once... some time ago... - Tul P.S. Please don't top-post. PS: Please trim your post. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Which Exception to use ....
//sorry for my english Firstly, this list of exception show only registered in system exceptions, which (excluding one-two) are exceptions of some php mobules:mysqli,sqllite and so on... I use only Exception class and my extends on it (so and exceptions from your list are extends...). -- === С уважением, Манылов Павел aka [R-k] icq: 949-388-0 mailto:[EMAIL PROTECTED] === А ещё говорят так: Наш народ вот yже 80 лет качает права... скачать yдалось пока только процентов 10... [fortune]
[PHP] Simple tiny php template
Hello Can any one direct to very very tiny simple php template code. I want to use it for 5-6 pages website. Thank you -- OOzy Ubuntu-Hard
Re: [PHP] Restore Leading Zeros in Zip Codes
tedd wrote: At 8:44 PM -0600 8/21/08, Keith Spiller wrote: Hi, RE: Restore Leading Zeros in Zip Codes Does anyone happen to have a script that will restore the leading zeros in a mixed data set of 5 digit zip codes and 10 digit zip+4 codes? Any suggestions? Thanks, Keith Keith: Why take them out in the first place? Keep the zip code as a string. After all, not all countries use just numbers. Cheers, tedd or, if you use US zip codes only, use ZEROFILL feature in mysql? -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple tiny php template
define('TPL_DIR', dirname(__FILE__).'/tpl/'); function TPL($__filename, $__data = array(), $__return = false) { $__retval = ''; $__tplfilename = TPL_DIR.$__filename; if (file_exists($__tplfilename)) { if ($__return) ob_start(); extract($__data); require($__tplfilename); if ($__return) { $__retval = ob_get_contents(); ob_end_clean(); } } else { trigger_error('Template not found: '.$__filename, E_USER_ERROR); } return $__retval; } // Example usage TPL('layout/header.tpl.php', array('title' = 'This is the page title')); TPL('index.tpl.php'); TPL('layout/footer.tpl.php'); -Stut On 22 Aug 2008, at 17:26, OOzy Pal wrote: Hello Can any one direct to very very tiny simple php template code. I want to use it for 5-6 pages website. Thank you -- OOzy Ubuntu-Hard -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restore Leading Zeros in Zip Codes
On Fri, Aug 22, 2008 at 12:28 PM, Afan Pasalic [EMAIL PROTECTED] wrote: tedd wrote: At 8:44 PM -0600 8/21/08, Keith Spiller wrote: Hi, RE: Restore Leading Zeros in Zip Codes Does anyone happen to have a script that will restore the leading zeros in a mixed data set of 5 digit zip codes and 10 digit zip+4 codes? Any suggestions? Thanks, Keith Keith: Why take them out in the first place? Keep the zip code as a string. After all, not all countries use just numbers. Cheers, tedd or, if you use US zip codes only, use ZEROFILL feature in mysql? -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php From a recent experience, you should all listen to Tedd's advice. I inhereited an application when I came to work at my current job where the developer used an INT(11) mysql column type for zipcodes. Its turned things into a nightmare. We pulll quotes based off distance and calculate that off zip codes. First I found that there are some 4 digit zip codes in other counties, and shipping from Ohio to New Jersey quotes were coming up as thousands of miles and thousands of dollars, when they shouldn't have. Then there was the announcement of expanding into Canada. Then came digging thru all the code trying to redo how zip codes are happening, and ultimately its lead to a rewrite of the system. Do yourself a favor, and use a string type, fix the ones you have with a sprintf() function and be glad you won't have to suffer in the future. -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life.
Re: [PHP] Which Exception to use ....
Pavel schreef: //sorry for my english Firstly, this list of exception show only registered in system exceptions, yes I know, I wrote exactly that in the first line of my post. which (excluding one-two) are exceptions of some php mobules:mysqli,sqllite and so on... it's 5 actually, I mentioned that also. I use only Exception class and my extends on it (so and exceptions from your list are extends...). yes, I know. they have to, it's an engine requirement, if you STW you can even find a class heirarchy diagram that documents them. the point is I'm writing a small site/app and I can't be arsed to write a stack of custom Exceptions and an autoloader etc because it's too much hassle for the simplistic nature of what I'm putting together ... so I figured I'd use built-in exceptions where I can because being able to differentiate certain 'types' of exception is quite handy, making everything a plain Exception is rather blunt (rather like doing surgery with a spoon). ... which is where my original question(s) come in. personally I find the built-ins rather useless unless you fancy being super pendantic with your exceptions (UnderflowException anyone?!?), seems the built-in exceptions don't really cover (m)any general situations. maybe a missing config file should be a RunTimeException ... still leaves the questions as to what a DomainException and a ErrorException is meant to model. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restore Leading Zeros in Zip Codes
On Fri, Aug 22, 2008 at 12:28 PM, Afan Pasalic [EMAIL PROTECTED] wrote: tedd wrote: At 8:44 PM -0600 8/21/08, Keith Spiller wrote: Hi, RE: Restore Leading Zeros in Zip Codes Does anyone happen to have a script that will restore the leading zeros in a mixed data set of 5 digit zip codes and 10 digit zip+4 codes? Any suggestions? Thanks, Keith Keith: Why take them out in the first place? Keep the zip code as a string. After all, not all countries use just numbers. Cheers, tedd or, if you use US zip codes only, use ZEROFILL feature in mysql? -afan Definitely not. Tedd and Dan are correct; the zeros are significant, not just filler. Keep in mind that ZIP codes ARE NOT numbers at all, even if they look like numbers in the US. They are postal codes, which are a string of character data even if all the characters are numeric digits. Just expand your database to include Canada and it will become abundantly clear that a numeric data type is not correct for postal codes. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Which Exception to use ....
On Fri, Aug 22, 2008 at 12:35 PM, Jochem Maas [EMAIL PROTECTED] wrote: Pavel schreef: //sorry for my english Firstly, this list of exception show only registered in system exceptions, yes I know, I wrote exactly that in the first line of my post. which (excluding one-two) are exceptions of some php mobules:mysqli,sqllite and so on... it's 5 actually, I mentioned that also. I use only Exception class and my extends on it (so and exceptions from your list are extends...). yes, I know. they have to, it's an engine requirement, if you STW you can even find a class heirarchy diagram that documents them. the point is I'm writing a small site/app and I can't be arsed to write a stack of custom Exceptions and an autoloader etc because it's too much hassle for the simplistic nature of what I'm putting together ... so I figured I'd use built-in exceptions where I can because being able to differentiate certain 'types' of exception is quite handy, making everything a plain Exception is rather blunt (rather like doing surgery with a spoon). ... which is where my original question(s) come in. personally I find the built-ins rather useless unless you fancy being super pendantic with your exceptions (UnderflowException anyone?!?), seems the built-in exceptions don't really cover (m)any general situations. maybe a missing config file should be a RunTimeException ... still leaves the questions as to what a DomainException and a ErrorException is meant to model. I have no idea on those two, but I can see use for things like InvalidArgumentException, OutOfRangeException or the like in some cases. In no case would I send something so low-level back to the user, but they can be useful in input validation for functions to make sure the data you are processing is what it should be. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Fwd: [PHP] php not reading file properly
The cron job only runs every 5 minutes, so not likely On Fri, Aug 22, 2008 at 10:22 AM, Ashley Sheridan [EMAIL PROTECTED]wrote: Are you sure they are both not accessed at around about the same time? Look at the timestamps. The only analysis I've ever done with logs has been offline, so I've not run into this problem before. Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: Fri, 22 Aug 2008 10:13:37 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Yeah, but it wouldn't read access_log.tmp, which wasn't being written to at the time of loading. I think the whole logs folder is restricted from php access. On Fri, Aug 22, 2008 at 10:13 AM, Ashley Sheridan [EMAIL PROTECTED] wrote: The log file was in the process of being written to as you were trying to read it. It's a bit like trying to look at a quark. By doing so, you've already affected its position. Although, unlike a quark, you can create a copy of the log file ;) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: php-general@lists.php.net Date: Fri, 22 Aug 2008 10:04:07 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Yeah, I tried changing the perms, and that didn't work. I originally made the cron job put the temp copy in the same logs folder, but it refused to open that. I changed it to put the temp copy in the web folder, and it can read that. I think apache and/or php may have certain restrictions that keep them from accessing important system folders. On Fri, Aug 22, 2008 at 3:09 AM, Ashley Sheridan [EMAIL PROTECTED]wrote: You can change the permissions on the file, which I believe you said you did. If that didn't work, it must be because you are trying to read from the file at the very same instant that Apache is writing to it logging that you are trying to access it, if that makes sense? Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: php-general@lists.php.net Date: Fri, 22 Aug 2008 02:31:47 -0400 Subject: Re: Fwd: [PHP] php not reading file properly So I made a cron jop to copy the log to the web folder every 5 minutes. That worked fine. It seems that php can't read the /var/log/httpd folder without root perms. On Wed, Aug 20, 2008 at 7:53 PM, Ashley Sheridan [EMAIL PROTECTED]wrote: Yeah, Apache is still running, but it is the access log you are trying to read, at the same time that you are Apache is being accessed. Accessing the log from the terminal will be fine while Apache is running, as it is unlikely it is being accessed at the very same instant. Are you able to access other files? Also, have you tried copying the file to another temporary version from within PHP an accessing that? If that doesn't work, try executing a Bash script that copies it someplace. Make sure to run the script in the background, and maybe add a sleep period to it so that it doesn't interfere with Apache accessing things. Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: Micah Gersten [EMAIL PROTECTED] Date: Wed, 20 Aug 2008 19:41:54 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Ashley Sheridan wrote: As it's the Apache access log that you are trying to read in, are you sure that Apache is not in the process of writing to it as you are attempting to read from it? That might explain why it seems to be empty, although I would have thought it would just append the data to the end of the file, rather than rewriting the whole thing. I dunno. Like I said, I can read it thru the terminal. Apache is still running then. As for Micah's response, that function won't work either. On Wed, Aug 20, 2008 at 7:34 PM, Micah Gersten [EMAIL PROTECTED] wrote: If the directory above it doesn't have execute privileges, it won't be able to read it either. Also, why not use the PHP5 function file_get_contents()? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com sean greenslade wrote: Thanks for the advice. I changed the perms to 777 and changed the user and group to apache, but it still won't open. On Wed, Aug 20, 2008 at 3:35 PM, Robbert van Andel [EMAIL PROTECTED]wrote: Does the user your PHP instance runs as have access to the file? It's possible that it runs under a different users depending on if you're running the script on the terminal or in a web browser. The function fopen will return false if the file fails to open. Find out if $fh is equal to false. While you're debugging, you might
Re: Fwd: [PHP] php not reading file properly
Hey! That worked! Turns out, the folder needs exec perms to read the files. Thanks! On Fri, Aug 22, 2008 at 10:28 AM, Micah Gersten [EMAIL PROTECTED] wrote: What are the permssions of /var/log and /var/log/httpd? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com sean greenslade wrote: Yeah, but it wouldn't read access_log.tmp, which wasn't being written to at the time of loading. I think the whole logs folder is restricted from php access. On Fri, Aug 22, 2008 at 10:13 AM, Ashley Sheridan [EMAIL PROTECTED]wrote: The log file was in the process of being written to as you were trying to read it. It's a bit like trying to look at a quark. By doing so, you've already affected its position. Although, unlike a quark, you can create a copy of the log file ;) Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: php-general@lists.php.net Date: Fri, 22 Aug 2008 10:04:07 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Yeah, I tried changing the perms, and that didn't work. I originally made the cron job put the temp copy in the same logs folder, but it refused to open that. I changed it to put the temp copy in the web folder, and it can read that. I think apache and/or php may have certain restrictions that keep them from accessing important system folders. On Fri, Aug 22, 2008 at 3:09 AM, Ashley Sheridan [EMAIL PROTECTED]wrote: You can change the permissions on the file, which I believe you said you did. If that didn't work, it must be because you are trying to read from the file at the very same instant that Apache is writing to it logging that you are trying to access it, if that makes sense? Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: php-general@lists.php.net Date: Fri, 22 Aug 2008 02:31:47 -0400 Subject: Re: Fwd: [PHP] php not reading file properly So I made a cron jop to copy the log to the web folder every 5 minutes. That worked fine. It seems that php can't read the /var/log/httpd folder without root perms. On Wed, Aug 20, 2008 at 7:53 PM, Ashley Sheridan [EMAIL PROTECTED]wrote: Yeah, Apache is still running, but it is the access log you are trying to read, at the same time that you are Apache is being accessed. Accessing the log from the terminal will be fine while Apache is running, as it is unlikely it is being accessed at the very same instant. Are you able to access other files? Also, have you tried copying the file to another temporary version from within PHP an accessing that? If that doesn't work, try executing a Bash script that copies it someplace. Make sure to run the script in the background, and maybe add a sleep period to it so that it doesn't interfere with Apache accessing things. Ash www.ashleysheridan.co.uk -- Forwarded message -- From: sean greenslade [EMAIL PROTECTED] To: Micah Gersten [EMAIL PROTECTED] Date: Wed, 20 Aug 2008 19:41:54 -0400 Subject: Re: Fwd: [PHP] php not reading file properly Ashley Sheridan wrote: As it's the Apache access log that you are trying to read in, are you sure that Apache is not in the process of writing to it as you are attempting to read from it? That might explain why it seems to be empty, although I would have thought it would just append the data to the end of the file, rather than rewriting the whole thing. I dunno. Like I said, I can read it thru the terminal. Apache is still running then. As for Micah's response, that function won't work either. On Wed, Aug 20, 2008 at 7:34 PM, Micah Gersten [EMAIL PROTECTED] wrote: If the directory above it doesn't have execute privileges, it won't be able to read it either. Also, why not use the PHP5 function file_get_contents()? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com sean greenslade wrote: Thanks for the advice. I changed the perms to 777 and changed the user and group to apache, but it still won't open. On Wed, Aug 20, 2008 at 3:35 PM, Robbert van Andel [EMAIL PROTECTED]wrote: Does the user your PHP instance runs as have access to the file? It's possible that it runs under a different users depending on if you're running the script on the terminal or in a web browser. The function fopen will return false if the file fails to open. Find out if $fh is equal to false. While you're debugging, you might consider changing the display errors setting to see what warning fopen generates if the file fails to open. From http://us.php.net/fopen Errors/Exceptions If the open fails, the function an error of level
[PHP] Sorting Arrays
I'm having a problem sorting my array and wondered if anybody had experience sorting arrays by their values. What I need to do is resort the array below where the most expensive product shipping price starts at position zero no matter how big the array is. array(2) { [0] = array(48) { [product_id] = string(2) 34 [product_name] = string(29) Bears Ball Cap [product_ordered_size] = string(5) ADULT [product_sales_price] = string(8) 11.90 [product_shipping_price] = string(4) 7.85 [product_shipping_extra] = string(4) 0.06 } [1] = array(48) { [product_id] = string(2) 37 [product_name] = string(21) Baldwin L Grand Piano [product_ordered_size] = string(5) Grand [product_sales_price] = string(8) 11671.90 [product_shipping_price] = string(6) 500.00 [product_shipping_extra] = string(6) 450.00 } Thanks [EMAIL PROTECTED]
Re: [PHP] Sorting Arrays
I believe you'll need a custom sorting function for this. http://us.php.net/usort Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Tom Shaw wrote: I'm having a problem sorting my array and wondered if anybody had experience sorting arrays by their values. What I need to do is resort the array below where the most expensive product shipping price starts at position zero no matter how big the array is. array(2) { [0] = array(48) { [product_id] = string(2) 34 [product_name] = string(29) Bears Ball Cap [product_ordered_size] = string(5) ADULT [product_sales_price] = string(8) 11.90 [product_shipping_price] = string(4) 7.85 [product_shipping_extra] = string(4) 0.06 } [1] = array(48) { [product_id] = string(2) 37 [product_name] = string(21) Baldwin L Grand Piano [product_ordered_size] = string(5) Grand [product_sales_price] = string(8) 11671.90 [product_shipping_price] = string(6) 500.00 [product_shipping_extra] = string(6) 450.00 } Thanks [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple tiny php template
Stut schreef: define('TPL_DIR', dirname(__FILE__).'/tpl/'); function TPL($__filename, $__data = array(), $__return = false) { $__retval = ''; $__tplfilename = TPL_DIR.$__filename; if (file_exists($__tplfilename)) { if ($__return) ob_start(); extract($__data); require($__tplfilename); if ($__return) { $__retval = ob_get_contents(); ob_end_clean(); } else { ob_end_flush(); return; } // I'm guessing this should be in there too } else { trigger_error('Template not found: '.$__filename, E_USER_ERROR); } return $__retval; } // Example usage TPL('layout/header.tpl.php', array('title' = 'This is the page title')); TPL('index.tpl.php'); TPL('layout/footer.tpl.php'); -Stut On 22 Aug 2008, at 17:26, OOzy Pal wrote: Hello Can any one direct to very very tiny simple php template code. I want to use it for 5-6 pages website. Thank you -- OOzy Ubuntu-Hard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Developing a game using Ming
Yasir Malik schreef: If you're trying to be cheap and/or Open Sourcy about it, have a look at OpenLazlo. It's an XML/JS framework, all open source, that compiles to SWF and plays in a normal Flash 9 browser plugin. I've only recently started looking into it, but it looks impressive. And of course I should probably include a link: http://www.openlaszlo.org/ Thanks, Larry. I'll check that out, too, and choose the best one. The replies to my post are greatly appreciated. Also, can the email addresses be removed when top quoting? I was surprised to see my email address showing up in plain in http://marc.info/?t=12192374021r=1w=2 get used to it. marc is only one of a zillion sites that replicate btw, most dump out email addrs as is. what is 'top quoting' when it's at home anyway? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: Sale 79% OFF !!!
Sorry, but I can't understand why anyone would suddenly give me money out of the blue, especially money to the tune of many thousands of pounds, and by that reckoning, I fail to see however legitimate it might look, how anyone could be duped... Ash www.ashleysheridan.co.uk ---BeginMessage--- At 2:26 PM +0100 8/21/08, Ashley Sheridan wrote: I don't understand how people can fall for this kind of thing, all those Nigerian scams and the like. For every person that falls for it, a million more emails get sent, making everyone elses lives hell :( Ash www.ashleysheridan.co.uk I hate to admit to this, but some 15 years ago I was consulting for a company doing oil exploration in Nigeria and I received a very elaborate and believable Nigerian scam. It was complete with signed and official documents from both the Nigerian Government and the Bank of Nigeria. I passed the proposal through two attorneys and the decision was to participate. Of course nothing happened and we did not lose anything. But the first Nigerian scams were very believable. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sorting Arrays
Yeah, a bubble sorting algorithm should fix it, as it essentially only a very simple sort required. Ash www.ashleysheridan.co.uk ---BeginMessage--- I believe you'll need a custom sorting function for this. http://us.php.net/usort Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Tom Shaw wrote: I'm having a problem sorting my array and wondered if anybody had experience sorting arrays by their values. What I need to do is resort the array below where the most expensive product shipping price starts at position zero no matter how big the array is. array(2) { [0] = array(48) { [product_id] = string(2) 34 [product_name] = string(29) Bears Ball Cap [product_ordered_size] = string(5) ADULT [product_sales_price] = string(8) 11.90 [product_shipping_price] = string(4) 7.85 [product_shipping_extra] = string(4) 0.06 } [1] = array(48) { [product_id] = string(2) 37 [product_name] = string(21) Baldwin L Grand Piano [product_ordered_size] = string(5) Grand [product_sales_price] = string(8) 11671.90 [product_shipping_price] = string(6) 500.00 [product_shipping_extra] = string(6) 450.00 } Thanks [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sorting Arrays
On Fri, 2008-08-22 at 21:04 +0100, Ashley Sheridan wrote: Yeah, a bubble sorting algorithm should fix it, as it essentially only a very simple sort required. Why use bubble sort when you can use usort() function with an arbitrary handler? Cheers, Rob. Ash www.ashleysheridan.co.uk email message attachment, Forwarded message - Re: [PHP] Sorting Arrays Forwarded Message From: Micah Gersten [EMAIL PROTECTED] To: Tom Shaw [EMAIL PROTECTED] Cc: php-general@lists.php.net Subject: Re: [PHP] Sorting Arrays Date: Fri, 22 Aug 2008 14:18:53 -0500 I believe you'll need a custom sorting function for this. http://us.php.net/usort Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Tom Shaw wrote: I'm having a problem sorting my array and wondered if anybody had experience sorting arrays by their values. What I need to do is resort the array below where the most expensive product shipping price starts at position zero no matter how big the array is. array(2) { [0] = array(48) { [product_id] = string(2) 34 [product_name] = string(29) Bears Ball Cap [product_ordered_size] = string(5) ADULT [product_sales_price] = string(8) 11.90 [product_shipping_price] = string(4) 7.85 [product_shipping_extra] = string(4) 0.06 } [1] = array(48) { [product_id] = string(2) 37 [product_name] = string(21) Baldwin L Grand Piano [product_ordered_size] = string(5) Grand [product_sales_price] = string(8) 11671.90 [product_shipping_price] = string(6) 500.00 [product_shipping_extra] = string(6) 450.00 } Thanks [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple tiny php template
On 22 Aug 2008, at 20:48, Jochem Maas wrote: Stut schreef: define('TPL_DIR', dirname(__FILE__).'/tpl/'); function TPL($__filename, $__data = array(), $__return = false) { $__retval = ''; $__tplfilename = TPL_DIR.$__filename; if (file_exists($__tplfilename)) { if ($__return) ob_start(); extract($__data); require($__tplfilename); if ($__return) { $__retval = ob_get_contents(); ob_end_clean(); } else { ob_end_flush(); return; } // I'm guessing this should be in there too Nope, not even a little bit. The output buffer is only opened if we are returning the output from the template. -Stut } else { trigger_error('Template not found: '.$__filename, E_USER_ERROR); } return $__retval; } // Example usage TPL('layout/header.tpl.php', array('title' = 'This is the page title')); TPL('index.tpl.php'); TPL('layout/footer.tpl.php'); -Stut On 22 Aug 2008, at 17:26, OOzy Pal wrote: Hello Can any one direct to very very tiny simple php template code. I want to use it for 5-6 pages website. Thank you -- OOzy Ubuntu-Hard -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sorting Arrays
Robert Cummings wrote: On Fri, 2008-08-22 at 21:04 +0100, Ashley Sheridan wrote: Yeah, a bubble sorting algorithm should fix it, as it essentially only a very simple sort required. Why use bubble sort when you can use usort() function with an arbitrary handler? Cheers, Rob. Exactly. That's one reason why I love PHP. They have functions that do things you have to write subroutines for in other languages. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restore Leading Zeros in Zip Codes
At 12:35 PM -0400 8/22/08, Dan Joseph wrote: tedd wrote: Why take them out in the first place? Keep the zip code as a string. After all, not all countries use just numbers. From a recent experience, you should all listen to Tedd's advice. I inhereited an application when I came to work at my current job where the developer used an INT(11) mysql column type for zipcodes. Its turned things into a nightmare. We pulll quotes based off distance and calculate that off zip codes. First I found that there are some 4 digit zip codes in other counties, and shipping from Ohio to New Jersey quotes were coming up as thousands of miles and thousands of dollars, when they shouldn't have. Then there was the announcement of expanding into Canada. Then came digging thru all the code trying to redo how zip codes are happening, and ultimately its lead to a rewrite of the system. Do yourself a favor, and use a string type, fix the ones you have with a sprintf() function and be glad you won't have to suffer in the future. -- -Dan Joseph Back-side I told the OP to convert to sting, add zeros to the left, and left-trim as necessary. There is much more here than what meets the eye with international addresses. As a word of caution, don't make anything a number and also open address forms to accept multiple strings for international addressing. There's a big world out there of people who don't conform to what we think is the standard. Remember, if you speak/write English then you're only 4 percent of the world's population. We're hardly the standard for anything. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Which Exception to use ....
Jochem Maas wrote: here is a list of built in Exception classes, I'd figured I'd start using them, and save on rolling my own: Exception ErrorException DOMException LogicException BadFunctionCallException BadMethodCallException DomainException InvalidArgumentException LengthException OutOfRangeException RuntimeException OutOfBoundsException OverflowException RangeException UnderflowException UnexpectedValueException PDOException SQLiteException ReflectionException mysqli_sql_exception PharException for starters, what is meant by DomainException? and ErrorException? secondly if you wanted to throw an exception for a missing config file in your app, which would you choose? if you ask me only Exception is really correct in this instance, but it's not very descriptive is it. the last five in the list are only handy if you use those extensions, and then only in terms of catching. anyone actually using these built-ins in their work? I've been using the php5 exception try/catch feature for several months and find it most useful. e.g., try { $flagsArray = getHideAndMarkFlagsFromPost(); //Get the records flagged mark and hide $recordsArray = getRegistryTable(); $userDataArray = $recordsArray[$flagsArray['marks'][0]]; } catch (Exception $e) { $errorMsg = $e-getMessage(); } In my getHideAndMarkFlagsFromPost() function, I have: if(empty($flagsArray)) throw new Exception(No records were flagged); For your missing config file, simply use something like: if(!file_exists('foo') throw new Exception(Config file missing); return $file-string; // or whatever. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: Sale 79% OFF !!!
At 9:02 PM +0100 8/22/08, Ashley Sheridan wrote: Sorry, but I can't understand why anyone would suddenly give me money out of the blue, especially money to the tune of many thousands of pounds, and by that reckoning, I fail to see however legitimate it might look, how anyone could be duped... Ash Ash: If you have ever worked in another country where bribes are the way of getting things done, you'll quickly see that those types of things are not as farfetched as one might think. Hell, I've even had to pay bribes in this country (USA) to local government officials to be able to work. Of course, they called it something else, such as fees, taxes, bonds, overtime, or contributions, but it was still Pay me or I won't allow you to work. The difference here is only in magnitude. You see, I was confronted with conducting literally millions of dollars of oil and gas exploration in Nigeria. The last project I worked on was over 22 million dollars (in my other life, I'm a Geophysicist -- see http://geophysics.com). My client was approached with lifting oil as part of their payment. The term lifting is simply selling you oil for less than the going price and therein you get payment when you resale. The practice not unheard of and ranges in the 20-50 million dollar transactions. In any event, Nigerian officials provided documents claiming that they could deliver provided that a US Corporation would participate -- that's how I got into it. However, when I demanded up-front money, the deal dissolved. I didn't think that much of it because many of these overseas official types are easily offended when you question their word. It wasn't until years later that we started hearing that these types of deals as being Nigerian scams. I think it was WC Fields who said You can't cheat an honest man and that might have been the case here. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
That is the brick wall i faced. There is no way to know where exactly you are (via DirectoryIndex) locally on the machine. Thanks though. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: You might want to try a Redirect Rule or rewrite which would tell you the HTTP PATH. AFAIK, there is no way to know which directory they tried to access unless you write your own index.php and store it in a session variable. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: Thanks for the reply Micah but i have no interest in the URL. I am looking for the servers local path to the directory. (example: /var/www/directory/ or C:\apache\htdocs\directory\) Also the HTTP_REFERER is empty unless you are linked in from another location. And then it gives you the URL you came from. Ólafur Waage. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Restore Leading Zeros in Zip Codes
On Fri, 2008-08-22 at 17:16 -0400, tedd wrote: At 12:35 PM -0400 8/22/08, Dan Joseph wrote: tedd wrote: Why take them out in the first place? Keep the zip code as a string. After all, not all countries use just numbers. From a recent experience, you should all listen to Tedd's advice. I inhereited an application when I came to work at my current job where the developer used an INT(11) mysql column type for zipcodes. Its turned things into a nightmare. We pulll quotes based off distance and calculate that off zip codes. First I found that there are some 4 digit zip codes in other counties, and shipping from Ohio to New Jersey quotes were coming up as thousands of miles and thousands of dollars, when they shouldn't have. Then there was the announcement of expanding into Canada. Then came digging thru all the code trying to redo how zip codes are happening, and ultimately its lead to a rewrite of the system. Do yourself a favor, and use a string type, fix the ones you have with a sprintf() function and be glad you won't have to suffer in the future. -- -Dan Joseph Back-side I told the OP to convert to sting, add zeros to the left, and left-trim as necessary. There is much more here than what meets the eye with international addresses. As a word of caution, don't make anything a number and also open address forms to accept multiple strings for international addressing. There's a big world out there of people who don't conform to what we think is the standard. Remember, if you speak/write English then you're only 4 percent of the world's population. We're hardly the standard for anything. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com Not to mention, but of the two major English speaking countries, both America and England have different address standards. All too often an American site seems to think that a postcode is the same thing as a zip code, and then rejects it in a form for being in the wrong format! Ash www.ashleysheridan.co.uk
Re: [PHP] Quick question regarding getcwd() and directory location.
On Fri, 2008-08-22 at 21:56 +, Ólafur Waage wrote: That is the brick wall i faced. There is no way to know where exactly you are (via DirectoryIndex) locally on the machine. Thanks though. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: You might want to try a Redirect Rule or rewrite which would tell you the HTTP PATH. AFAIK, there is no way to know which directory they tried to access unless you write your own index.php and store it in a session variable. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: Thanks for the reply Micah but i have no interest in the URL. I am looking for the servers local path to the directory. (example: /var/www/directory/ or C:\apache\htdocs\directory\) Also the HTTP_REFERER is empty unless you are linked in from another location. And then it gives you the URL you came from. Ólafur Waage. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage Are you just trying to find the current working directory, or are you navigating to a directory with PHP and want to know where you've ended up? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
I am within a certain directory of the server via the browser. Example: http://www.example.com/foo/bar would be /var/www/example.com/foo/bar And Apache's DirectoryIndex feature is opening a index.php file that is located at /var/www/example.com/test/index.php And from that file i need to figure out the full local path of /foo/bar (which would be /var/www/example.com/foo/bar ) or any other directory i browse too. Ólafur Waage 2008/8/22 Ashley Sheridan [EMAIL PROTECTED]: On Fri, 2008-08-22 at 21:56 +, Ólafur Waage wrote: That is the brick wall i faced. There is no way to know where exactly you are (via DirectoryIndex) locally on the machine. Thanks though. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: You might want to try a Redirect Rule or rewrite which would tell you the HTTP PATH. AFAIK, there is no way to know which directory they tried to access unless you write your own index.php and store it in a session variable. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: Thanks for the reply Micah but i have no interest in the URL. I am looking for the servers local path to the directory. (example: /var/www/directory/ or C:\apache\htdocs\directory\) Also the HTTP_REFERER is empty unless you are linked in from another location. And then it gives you the URL you came from. Ólafur Waage. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage Are you just trying to find the current working directory, or are you navigating to a directory with PHP and want to know where you've ended up? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
On Thu, Aug 21, 2008 at 8:50 PM, Ólafur Waage [EMAIL PROTECTED] wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe dirname(__FILE__) will help.
Re: [PHP] Quick question regarding getcwd() and directory location.
On Fri, 2008-08-22 at 22:13 -0400, Eric Butera wrote: On Thu, Aug 21, 2008 at 8:50 PM, Ólafur Waage [EMAIL PROTECTED] wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe dirname(__FILE__) will help. When I'm looking for candidates to determine stuff like this I usually do print_r( $_SERVER ) and see what's what. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sorting Arrays
Tom Shaw wrote: I'm having a problem sorting my array and wondered if anybody had experience sorting arrays by their values. What I need to do is resort the array below where the most expensive product shipping price starts at position zero no matter how big the array is. array(2) { [0] = array(48) { [product_id] = string(2) 34 [product_name] = string(29) Bears Ball Cap [product_ordered_size] = string(5) ADULT [product_sales_price] = string(8) 11.90 [product_shipping_price] = string(4) 7.85 [product_shipping_extra] = string(4) 0.06 } [1] = array(48) { [product_id] = string(2) 37 [product_name] = string(21) Baldwin L Grand Piano [product_ordered_size] = string(5) Grand [product_sales_price] = string(8) 11671.90 [product_shipping_price] = string(6) 500.00 [product_shipping_extra] = string(6) 450.00 } Thanks [EMAIL PROTECTED] Everything can be done with three custom lines of code, the rest is PHP existing function calls. http://us3.php.net/manual/en/function.array-multisort.php Example #3 Sorting database results I expanded your list below and randomly added some data... Anyways, replace my $ar array definition with your array and you should be good to go. One question though, is this coming from a DB? If so, why not do the sorting in the SQL call instead of PHP? Just a thought. plaintext?php $ar = array( array( product_id = 34, product_name = Bears Ball Cap #34, product_ordered_size = ADULT, product_sales_price = 11.90, product_shipping_price = 7.85, product_shipping_extra = 0.06, ), array( product_id = 35, product_name = Baldwin L Grand Piano #35, product_ordered_size = Grand, product_sales_price = 11671.90, product_shipping_price = 51.00, product_shipping_extra = 450.00, ), array( product_id = 36, product_name = Baldwin L Grand Piano #36, product_ordered_size = Grand, product_sales_price = 11671.90, product_shipping_price = 500.00, product_shipping_extra = 450.00, ), array( product_id = 37, product_name = Baldwin L Grand Piano #37, product_ordered_size = Grand, product_sales_price = 11671.90, product_shipping_price = 5000.00, product_shipping_extra = 450.00, ), array( product_id = 38, product_name = Baldwin L Grand Piano #38, product_ordered_size = Grand, product_sales_price = 11671.90, product_shipping_price = 50.00, product_shipping_extra = 450.00, ), array( product_id = 39, product_name = Baldwin L Grand Piano #39, product_ordered_size = Grand, product_sales_price = 11671.90, product_shipping_price = 1.00, product_shipping_extra = 450.00, ) ); foreach ( $ar AS $k = $v ) { $p_shipping_price[$k] = $v['product_shipping_price']; } array_multisort($p_shipping_price, SORT_DESC, $ar); var_dump($ar); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php