Re: [PHP] question about a cron job
Erwin Kerk wrote: Al wrote: I've got a question about the following cronjob. #At 3:01 our time, run backups 1 0 * * * /usr/local/bin/php /www/r/rester/htdocs/auto_backup/back_em_up.php >/www/r/rester/htdocs/auto_backup/cron.log 2>&1 #At 3:02 clean up sessions folder 2 0 * * * (find /www/r/rester/htdocs/sessions/ -name 'sess_*' -mtime +1 -delete) #this is only for testing a new cronjob, every minute * * * * * /usr/local/bin/php /www/r/rester/htdocs/phpList_cronjob/process_cronjob.php >>/www/r/rester/htdocs/phpList_cronjob/cron.log 2>>&1 The new one doesn't seem to want to run until after 3:01 or 3:02. Shouldn't the sever just run it every minute? And, the every minute job doesn't add anything to its log file. Apache on a virtual host. The 3:01 and 3:02 jobs have been running fine for months. Thanks The CRON daemon only refreshes it's job list after a job in the current list is completed. Therefore, the CRON daemon won't notice the "every-minute" job until 3.01 pm. Erwin Wow, that is a key point and makes sense. Boy, I read several refs about cronjobs and not one of them mentioned this. So, if I put my 1 minute job first in the list, all should be well? Thanks.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about a cron job
Jay Blanchard wrote: [snip] I've got a question about the following cronjob. #At 3:01 our time, run backups 1 0 * * * /usr/local/bin/php /www/r/rester/htdocs/auto_backup/back_em_up.php /www/r/rester/htdocs/auto_backup/cron.log 2>&1 #At 3:02 clean up sessions folder 2 0 * * * (find /www/r/rester/htdocs/sessions/ -name 'sess_*' -mtime +1 -delete) #this is only for testing a new cronjob, every minute * * * * * /usr/local/bin/php /www/r/rester/htdocs/phpList_cronjob/process_cronjob.php /www/r/rester/htdocs/phpList_cronjob/cron.log 2>>&1 The new one doesn't seem to want to run until after 3:01 or 3:02. Shouldn't the sever just run it every minute? [/snip] You have to specify each minute... http://www.unixgeeks.org/security/newbie/unix/cron-1.html I thought the "*" in the minutes position meant to run the script for all minutes, 0 59. Am I wrong? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] question about a cron job
I've got a question about the following cronjob. #At 3:01 our time, run backups 1 0 * * * /usr/local/bin/php /www/r/rester/htdocs/auto_backup/back_em_up.php >/www/r/rester/htdocs/auto_backup/cron.log 2>&1 #At 3:02 clean up sessions folder 2 0 * * * (find /www/r/rester/htdocs/sessions/ -name 'sess_*' -mtime +1 -delete) #this is only for testing a new cronjob, every minute * * * * * /usr/local/bin/php /www/r/rester/htdocs/phpList_cronjob/process_cronjob.php >>/www/r/rester/htdocs/phpList_cronjob/cron.log 2>>&1 The new one doesn't seem to want to run until after 3:01 or 3:02. Shouldn't the sever just run it every minute? And, the every minute job doesn't add anything to its log file. Apache on a virtual host. The 3:01 and 3:02 jobs have been running fine for months. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Persistent PHP web application?
George Schlossnagle addresses exactly your requirement in his book "Advanced PHP Programming". Josh Whiting wrote: Dear list, My web application (an online classifieds server) requires a set of fairly large global arrays which contain vital information that most all the page scripts rely upon for information such as the category list, which fields belong to each category, and so on. Additionally, there are a large number of function definitions (more than 13,000 lines of code in all just for these global definitions). These global arrays and functions never change between requests. However, the PHP engine destroys and recreates them every time. After having spent some serious time doing benchmarking (using Apache Bench), I have found that this code takes at least 7ms to parse per request on my dual Xeon 2.4ghz server (Zend Accelerator in use*). This seriously cuts into my server's peak capacity, reducing it by more than half. My question is: is there a way to define a global set of variables and functions ONCE per Apache process, allowing each incoming hit to run a handler function that runs within a persistent namespace? OR, is it possible to create some form of shared variable and function namespace that each script can tap? AFAIK, mod_python, mod_perl, Java, etc. all allow you to create a persistent, long-running application with hooks/handlers for individual Apache requests. I'm surprised I haven't found a similar solution for PHP. In fact, according to my work in the past few days, if an application has a large set of global functions and variable definitions, mod_python FAR exceeds the performance of mod_php, even though Python code runs significantly slower than PHP code (because in mod_python you can put all these definitions in a module that is loaded only once per Apache process). The most promising prospect I've come across is FastCGI, which for Perl and other languages, allows you to run a while loop that sits and receives incoming requests (e.g. "while(FCGI::accept() >= 0) {..}"). However, the PHP/FastCGI modality seems to basically compare to mod_php: every request still creates and destroys the entire application (although the PHP interpreter itself does persist). Essentially I want to go beyond a persistent PHP *interpreter* (mod_php, PHP/FastCGI) and create a persistent PHP *application*... any suggestions? Thanks in advance for any help! Regards, J. Whiting * - Please note that I am using the Zend Accelerator (on Redhat Enterprise with Apache 1.3) to cache the intermediate compiled PHP code. My benchmarks (7ms+) are after the dramatic speedup provided by the accelerator. I wouldn't even bother benchmarking this without the compiler cache, but it is clear that a compiler cache does not prevent PHP from still having to run the (ableit precompiled) array and function definition code itself. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_FILE[user][error] = 6 ?
You nailed it Curt. Virtual Host "Powweb" removed the system default tmp directory without telling anyone. All file uploading services were broken. I fixed the problem in php.ini Thanks everyone. Curt Zirzow wrote: * Thus wrote Al: What is a $_FILE[user][error]=> 6 I can't find Error level 6 in the manual or on Google. Here is my files array: [userfile] => Array ( [name] => Readme.txt [type] => [tmp_name] => [error] => 6 [size] => 0 ) Doesn't make sense. Readme.txt is simply a small text file on my local HD. 6 == Missing /tmp or similar directory. Which means that your php.ini's upload_tmp_dir isn't set properly. Curt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_FILE[user][error] = 6 ?
I keyed "$_FILE[user][error]" from memory, and it's wrong. It really is "userfile"; Weird problem, eh! Sebastian wrote: not sure if its a typo but the array shows "userfile" and your variable array shows "user" it looks like the file isn't being passed at all, double check if you have any typos.. type is blank which should at least show the mime type.. - Original Message - From: "Al" <[EMAIL PROTECTED]> To: Sent: Tuesday, December 28, 2004 2:51 PM Subject: Re: [PHP] $_FILE[user][error] = 6 ? Doesn't work on any file type. I've checked the usual suspects. e.g. URL is my php file. On Wednesday 29 December 2004 01:40, Al wrote: What is a $_FILE[user][error]=> 6 I can't find Error level 6 in the manual or on Google. Here is my files array: [userfile] => Array ( [name] => Readme.txt [type] => [tmp_name] => [error] => 6 [size] => 0 ) Doesn't make sense. Readme.txt is simply a small text file on my local HD. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_FILE[user][error] = 6 ?
Doesn't work on any file type. I've checked the usual suspects. e.g. URL is my php file. Jason Wong wrote: On Wednesday 29 December 2004 01:40, Al wrote: What is a $_FILE[user][error]=> 6 I can't find Error level 6 in the manual or on Google. Here is my files array: [userfile] => Array ( [name] => Readme.txt [type] => [tmp_name] => [error] => 6 [size] => 0 ) Doesn't make sense. Readme.txt is simply a small text file on my local HD. Note, type doesn't register either. Does upload work at all, or does it only fail for that particular file? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $_FILE[user][error] = 6 ?
What is a $_FILE[user][error]=> 6 I can't find Error level 6 in the manual or on Google. Here is my files array: [userfile] => Array ( [name] => Readme.txt [type] => [tmp_name] => [error] => 6 [size] => 0 ) Doesn't make sense. Readme.txt is simply a small text file on my local HD. Note, type doesn't register either. Weird. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Newbie question? diagnosing a script
Hi Yall! I dont know if Im goin overboard askin this, but here goes... What /how does one use to diagnose a php script (for a link exchange) as to why it wont work/write to the file? With Cgi, one can use a telnet shell.. is there a thing to use for diagnosing php? Thank Mucho submit page http://www.arizona-commercial-real-estate.com/links/submit.php page script writes to http://www.arizona-commercial-real-estate.com/links/index.php zip file of entire php script folder http://www.arizona-commercial-real-estate.com/links.zip phpinfo http://www.arizona-commercial-real-estate.com/test.php
Re: [PHP] Coding Question
Richard Lynch wrote: Al wrote: Essentially, I'm creating warning reports for my users, not code errors. > The users can then email the warnings to our webmaster. Jason Wong wrote: On Monday 06 December 2004 14:19, Rory Browne wrote: $result = mysql_db_query($db,"select count(*) from $table") OR $values['msg']= $values['msg'] . "Could not connect to mySQL Table: $table"; //tech notes and db table stuff The calling page echoes $values['msg'] in nice red text. Here's what's wrong with this plan: #1. You are exposing the fact that you use MySQL to users. So malicous users don't need to figure out that you are using MySQL: They can just start trying all the MySQL things to break into your server. As a general rule, you do not want users to know what software/version you are running. While this does fall into the "security by obscurity" category, which is generally not "good" there are compelling arguments for making it harder for the bad guys to figure out what software you are using. #2. They won't. Oh, sorry. The USERS will *NOT* email your message to the webmaster. Oh, some will. Most, however, will email your webmaster with oh-so-usefull messages like. "I was on your website, and I got an error message, and it's broken. HELP!" Put the details you need to debug your software in a place where you webmaster can read them, no matter what the user does to mangle, shorten, or otherwise ruin the message. http://php.net/error_log is good for this. #3. It's just Bad Form to tell users a bunch of crap they don't understand, don't care about, and can only be puzzled by. The message the users see should be more like: "Website down for maintenance. Please try again later." The error messages you need to FIX the site are in the Apache log (or your own logfile) where they belong. There might be some exceptions to all this -- If you have only one or two admin people, whom you trust to actually copy &paste the error messages and send them to you, displaying them on those admin screens is not so bad. That user is probably your client who already knows what software is in use (or can find out easily) and isn't likely to sabotage their own site, and can maybe be trained to do the right thing... OTOH, logging to a file and giving them a message they understand ("Something broke. Call Rich and tell him what you were doing.") is probably better anyway. I greatly appreciate your taking an interest in my question. I didn't explain all the details since I was trying to keep my message short. My users are not public. They are a few selected individuals who only have access via an Apache authentication dialog. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Coding Question
Jason Wong wrote: On Monday 06 December 2004 14:19, Rory Browne wrote: If I'm not mistaken Al wanted to return something if the thing failed, without having to put it inside an if_block. I'm watching this with curiosity, because return is a language construct, and not a function, or anything that has a value. You can have: ... OR $error = "Oh dear"; But the say I see it, eventually, somewhere in your code you need to test for it. Essentially you're just moving the test somewhere else. Essentially, I'm creating warning reports for my users, not code errors. The users can then email the warnings to our webmaster. Here's what I ended up with: @$host_link= mysql_connect($host, $user, $pw) OR $values['msg']= $values['msg'] . "Could not connect to mySQL host "; if($host_link){ $db_link= mysql_select_db($db, $host_link) OR $values['msg']= $values['msg'] . "Could not connect to mySQL DB: $db"; } if($host_link AND $db_link){ $result = mysql_db_query($db,"select count(*) from $table") OR $values['msg']= $values['msg'] . "Could not connect to mySQL Table: $table"; } if($host_link AND $db_link AND $result){ $values['num_records'] = ($result>0) ? mysql_result($result,0,0) : 0; }//end if return $values; //tech notes and db table stuff The calling page echoes $values['msg'] in nice red text. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Coding Question
I've searched the PHP manual and can't find an answer for this question I'd like to use the "OR DIE" construct; but instead of "DIE" I'd like to use "RETURN FOO". I haven't found a way to do it. $string= file_get_contents($filename) OR die("Could not read file"); $db_link= mysql_connect($host, $user, $pw) OR die("Could not connect: " . mysql_error()); Seems like it would be nice to not have to test first, e.g., if(is_readable($filename)){ } Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is there a shorthand way to...?
When handling $_POST[] values that may or may not be assigned, I am forever using: if((isset($_POST['courses_list']) AND $_POST['courses_list']== 'Used')) Is there a shorthand way of doing this without causing notice errors? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Error logging problem
My site is on a virtual host and I'd like to log errors to a file while I'm debugging. Can't get it to work. Here is the code at the top of my script: ini_set("display_errors", "on"); //also tried "Off" ini_set("error_log", "/AutoSch/error.log"); $ini_array= ini_get_all(); error_reporting(E_ALL ^ E_WARNING ); //On for debuging only print_r($ini_array); Printing $ini_array shows my ini_set() statements are working; but, the errors are not being appended to error.log. I put a error.log in the folder, assuming the error handler needed one to append to. I don't want to turn on error logging for the whole site; just the folder I'm working on. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Multiple session_start()s / Is it a problem??
Is there a problem issuing multiple session_start()s for a given script? I can't find anything in the manual that says one way or the other. I have some scripts that call more than one functions include file and for convenience put a session_start() on each one. This gives me a "Notice" error. Of course I can simply use "@session_start()" to negate the Notice; but, I want to be certain this is good practice. Al. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error logging problem
Greg Donald wrote: On Wed, 10 Nov 2004 10:49:29 -0500, Al <[EMAIL PROTECTED]> wrote: ini_set("error_log", "/AutoSch/error.log"); Looks like this might be a path relative to your domain or your vhost definition? I'd go with a full system path if that's the case. Hey Greg, that did it. It's obvious now. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: blank function parameters
Giles Roadnight wrote: Hello If I defined a function with 4 parameters but only pass 3 I get an error. Is there anyway around this? I want to be able to set the missing parameter to a default value if it is not passed which works ok but How do I get rid of the error message? Thanks Giles Roadnight http://giles.roadnight.name It's in the manual. function foo($aaa, $bbb, $ccc, $ddd="") -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session_save_path
John Holmes wrote: Al wrote: Tried adding to htaccess: php_value session.save_path /www/u/username/htdoc/session Hoping it would override php.ini. Got a server error 500. Try putting quotes around the path and this should work, providing your ISP allows .htaccess files. I'm guessing that session_save_path has to be declared on page using session stuff. You can use session_save_path() to do this, but you'll need it in every script. Meant for this to reply to you: My declaration is simply appended to the end of a htaccess that has been running for a year. Here it is exactly: php_value session.save_path "/www/r/restonx/htdocs/sessions2" Also, tried it without the quotes. Also, echoed "session.save_path()" to make certain my path syntax was identical to the one in php.ini that works. Thanks... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session_save_path
Ed Lazor wrote: Can you do an .htaccess solution? If so, you could probably just set session save path with PHP_VALUE in the .htaccess file Note, from my original message: Tried adding to htaccess: php_value session.save_path /www/u/username/htdoc/session Hoping it would override php.ini. Got a server error 500. -Original Message- From: Al [mailto:[EMAIL PROTECTED] Sent: Thursday, October 07, 2004 8:25 AM To: [EMAIL PROTECTED] Subject: [PHP] session_save_path My virtual host eliminated the common session tmp folder which forces me to set up one in my area. I'm trying to come up with the best, considering: Custom php.ini; resisting because having to make certain it is always in sync with host's changes. Tried adding to htaccess: php_value session.save_path /www/u/username/htdoc/session Hoping it would override php.ini. Got a server error 500. Tried adding to a common functions file used by several pages: session_save_path /www/u/user/htdoc/session; and session_save_path $_SERVER['DOCUMENT_ROOT'] . "/SESSION"; Doesn't work, uses the path in php.ini; I'm guessing that session_save_path has to be declared on page using session stuff. That's a pain, if so. Haven't tried ini_set yet; is it a solution? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session_save_path
John Holmes wrote: Al wrote: Tried adding to htaccess: php_value session.save_path /www/u/username/htdoc/session Hoping it would override php.ini. Got a server error 500. Try putting quotes around the path and this should work, providing your ISP allows .htaccess files. I'm guessing that session_save_path has to be declared on page using session stuff. You can use session_save_path() to do this, but you'll need it in every script. My declaration is simply appended to the end of a htaccess that has been running for a year. Here it is exactly: php_value session.save_path "/www/r/restonx/htdocs/sessions2" Also, tried it without the quotes. Also, echoed "session.save_path()" to make certain my path syntax was identical to the one in php.ini that works. Thanks... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session_save_path
My virtual host eliminated the common session tmp folder which forces me to set up one in my area. I'm trying to come up with the best, considering: Custom php.ini; resisting because having to make certain it is always in sync with host's changes. Tried adding to htaccess: php_value session.save_path /www/u/username/htdoc/session Hoping it would override php.ini. Got a server error 500. Tried adding to a common functions file used by several pages: session_save_path /www/u/user/htdoc/session; and session_save_path $_SERVER['DOCUMENT_ROOT'] . "/SESSION"; Doesn't work, uses the path in php.ini; I'm guessing that session_save_path has to be declared on page using session stuff. That's a pain, if so. Haven't tried ini_set yet; is it a solution? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about error_reporting()
Greg Donald wrote: On Fri, 01 Oct 2004 10:36:28 -0400, Al <[EMAIL PROTECTED]> wrote: If I place this at the top of my script file, the page just hangs. error_reporting (E_ERROR | E_WARNING); A virtual host on a Unix/Apache system. Runs fine without the error_reporting(). The default system error reporting only shows E_ERRORS, so I wanted to see warnings also. Comment the entire script out starting below your call to error_reporting(), then start uncommenting and testing it from the top down until you find the issue. It's doubtful error_reporting() is causing the issue, it more likely it's uncovering an issue. You might try E_ALL, as it may help you discover the issue faster. Posting the script and getting some more eyes on it also an option. What's puzzling is that I can simply comment out the error_reporting line and the code runs fine. Also, the Apache error log doesn't show any errors. with or without the error_reporting. Is error_reporting() all that is necessary, or must I also have a error_log() statement? The manual is not clear on this point. Also, must I have a an existing error file for the errors to append to? Again, thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question about error_reporting()
If I place this at the top of my script file, the page just hangs. error_reporting (E_ERROR | E_WARNING); A virtual host on a Unix/Apache system. Runs fine without the error_reporting(). The default system error reporting only shows E_ERRORS, so I wanted to see warnings also. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Book recommendation
John Nichel wrote: Al wrote: How can get "Edit/Mail & Newsgroups/Composition/defaults for Html" to work? "Edit/Mail & Newsgroups/Send Format/Send in HTML is checked. All newsgroups and emails default to plain small text. Is this a bug, or am I missing something? Thanks.. Huh? Sorry everyone. I was composing 2 messages, one for here and one for a Mozilla group, at the time and screwed up. I immediately canceled this one; but, it apparently registered at you reader anyhow. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Book recommendation
How can get "Edit/Mail & Newsgroups/Composition/defaults for Html" to work? "Edit/Mail & Newsgroups/Send Format/Send in HTML is checked. All newsgroups and emails default to plain small text. Is this a bug, or am I missing something? Thanks.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need help with using htaccess to override php.ini error settings
Everything is working, thanks to you and Jason. The key was that I had to provide a seed file since error_log only appends messages to an existing file and doesn't create one if it does not exist. Al John Holmes wrote: From: "Al" <[EMAIL PROTECTED]> php_value error_log /home/jones/public_html/AutoSch/errors.txt #This doesn't work either. Anyone know how to write the errors to a file? The documentation says it should work. It should. What are the permissions on the above file? Does the apache/php user have permission to write to it? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need help with using htaccess to override php.ini error
test Al wrote: The php.ini is already set to log errors and it works; but, they are appended to the system log. Just for the heck of it I tried; but it doesn't work. php_value error_reporting 2047 php_value log_errors TRUE php_value error_log "./errors.txt"[and the full path string] John Holmes wrote: From: "Al" <[EMAIL PROTECTED]> Per the documentation, error_reporting must use the bitmask values form. And, that works great. However, I can't get the errors to log in a special file. They insist on being logged in the system's error log file. There is a "log_errors" setting and a "error_log" setting. Try setting the "log_errors" value. http://us3.php.net/manual/en/ref.errorfunc.php#ini.log-errors ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need help with using htaccess to override php.ini error settings
Here is what I having working so far: php_value error_reporting 2# Just warnings, which is what I want php_flag log_errors 1 #this turns logging on and off in the syslog php_flag display_errors 1 #this turns error display at client's browser on/off php_value error_log errors.txt#Doesn't work OR php_value error_log /home/jones/public_html/AutoSch/errors.txt #This doesn't work either. Anyone know how to write the errors to a file? The documentation says it should work. Jason Wong wrote: On Tuesday 24 August 2004 23:37, Al wrote: The php.ini is already set to log errors and it works; but, they are appended to the system log. Just for the heck of it I tried; but it doesn't work. php_value error_reporting 2047 php_value log_errors TRUE php_value error_log "./errors.txt"[and the full path string] "... Don't use php_value to set boolean values. ..." And you may have to specify an absolute path. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need help with using htaccess to override php.ini error settings
Here is what I having working so far: php_value error_reporting 2# Just warnings, which is what I want php_flag log_errors 1 #this turns logging on and off in the syslog php_flag display_errors 1 #this turns error display at client's browser on/off php_value error_log errors.txt#Doesn't work OR php_value error_log /home/jones/public_html/AutoSch/errors.txt #This doesn't work either. Anyone know how to write the errors to a file? The documentation says it should work. Jason Wong wrote: On Tuesday 24 August 2004 23:37, Al wrote: The php.ini is already set to log errors and it works; but, they are appended to the system log. Just for the heck of it I tried; but it doesn't work. php_value error_reporting 2047 php_value log_errors TRUE php_value error_log "./errors.txt"[and the full path string] "... Don't use php_value to set boolean values. ..." And you may have to specify an absolute path.
Re: [PHP] Need help with using htaccess to override php.ini error settings
Here is what I having working so far: php_value error_reporting 2# Just warnings, which is what I want php_flag log_errors 1 #this turns logging on and off in the syslog php_flag display_errors 1 #this turns error display at client's browser on/off php_value error_log errors.txt#Doesn't work OR php_value error_log /home/jones/public_html/AutoSch/errors.txt #This doesn't work either. Anyone know how to write the errors to a file? The documentation says it should work. Jason Wong wrote: On Tuesday 24 August 2004 23:37, Al wrote: The php.ini is already set to log errors and it works; but, they are appended to the system log. Just for the heck of it I tried; but it doesn't work. php_value error_reporting 2047 php_value log_errors TRUE php_value error_log "./errors.txt"[and the full path string] "... Don't use php_value to set boolean values. ..." And you may have to specify an absolute path.
Re: [PHP] Need help with using htaccess to override php.ini error settings
The php.ini is already set to log errors and it works; but, they are appended to the system log. Just for the heck of it I tried; but it doesn't work. php_value error_reporting 2047 php_value log_errors TRUE php_value error_log "./errors.txt"[and the full path string] John Holmes wrote: From: "Al" <[EMAIL PROTECTED]> Per the documentation, error_reporting must use the bitmask values form. And, that works great. However, I can't get the errors to log in a special file. They insist on being logged in the system's error log file. There is a "log_errors" setting and a "error_log" setting. Try setting the "log_errors" value. http://us3.php.net/manual/en/ref.errorfunc.php#ini.log-errors ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need help with using htaccess to override php.ini error settings
Thanks, that has me started. Per the documentation, error_reporting must use the bitmask values form. And, that works great. However, I can't get the errors to log in a special file. They insist on being logged in the system's error log file. I've tried: php_value error_log "errors.txt" with and without the quotes, etc. John Holmes wrote: From: "Al" <[EMAIL PROTECTED]> I need to active php error level "Warning" and log the errors in a file for my whole Apache virtual website. It is clear how to do everything on a script-by-script basis; but, I need to do it across the site. http://us2.php.net/manual/en/configuration.changes.php php_value error_reporting E_WARNING ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Need help with using htaccess to override php.ini error settings
I need to active php error level "Warning" and log the errors in a file for my whole Apache virtual website. It is clear how to do everything on a script-by-script basis; but, I need to do it across the site. I can't find any direct documentation to help. The php manual and Apache directives documentation point me in the right direction; but, leave out too much for me to get it to work. I want to set error reporting to "Warning" and log the errors in one file. Maybe, send an email with the errors. Can anyone help me get started or point me to some good lit on the subject? Thanks.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Code elegance and cleanliness
Not really knowing why you need to provide indexes for the array, since they are generated automatically if none are provided, I'd use: $imgBkgrnd = array( 'bkgrnd-default.gif', 'bkgrnd-positive.gif', 'bkgrnd-negative.gif' ); $imgNeeded = table['field']; $imgName = $imgBkgrnd[$imgNeeded]; The last two lines are a it doesn't matter. Note the use of single quotes in the array. The parser can simply treat the values as text rather than having to check for variables, etc. Robb Kerr wrote: Just a quick question. Does it really matter how long your code is or how many variables you use? For instance you can enter the following... $imgBkgrnd = array("1"=> "bkgrnd-default.gif", "2" => "bkgrnd-positive.gif", "3" => "bkgrnd-negative.gif"); $imgNeeded = table['field']; $imgName = $imgBkgrnd[$imgNeeded]; or, you can code the same thing as... $imgBkgrnd = array("1"=> "bkgrnd-default.gif", "2" => "bkgrnd-positive.gif", "3" => "bkgrnd-negative.gif"); $imgName = $imgBkgrnd[$table['field']]; The first example uses one more variable and a longer code block but is easier to read and debug. The second example uses one less variable and a shorter code block but is harder to debug later. Should I be striving for the shortest most compact code utilizing the fewest possible variables. Or, can I code in a style which is easier to read and debug? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: HTML Escaping
Look up heredoc in te php manual Robb Kerr wrote: I've got a conditional button that needs to appear/hide on my page depending upon the contents of a field in my database. The button is an image and has a long URL and JavaScript for image rotation attached to it. Needless to say, the href is quite long and includes several "'" characters. My conditional works great but I want to know if there is an easy way to escape the whole href so that the "'" characters will not be seen as PHP quote marks. See below... ; ?> Thanx in advance, Robb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: silly question: an IDE for php?
A terrific IDE editor. Is a low cost shareware. http://www.waterproof.fr/ Zhang Weiwu wrote: Not to start flame. I have been writing php using just vim for some time, it is a waste of time to put 'echo' statement everywhere to track variable values. I wonder what do the experienced users on php.net use for php development? Do you use IDE? Do you use Zend? Is there an alternative free (free as in 'beer') IDE rather than Zend that I can use to track variables, analize code and so like? I heard of bluefish, is it widely used? Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Determine whether $_GET has a value
You need to be specific about what you consider to be a legitimate value for your application. consider: $var= $_GET['myname']; if((preg_match("/([0-9]|[a-z]|[A-Z]/", $var) { Do something } No spaces and watch the "|" between the ] and the [ If $myname has at least one number or character, there will be a match. You can put any legit character(s) in []s, just OR them in. Terence wrote: Hi, Say you have a querystring - index.php?myname=joe To determine whether myname has a value I have come to the following conclusions / shortcomings when using one of the following: ISSET = as long as the variable myname exists it's set, but there's no guarantee of a value !EMPTY = if your name = 0 (zero) then it's considered empty, for all else it seems to work STRLEN = I have found this to be the only sure way to know. Is there any other way, or should we always use a combination of ISSET and STRLEN? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regular Expressions Tester/designer
Anyone know of a good regular expressions tester/designer for php coding running windows. I've looked at the Rad Software Regular Expressions Designer and it looks pretty good except that it is intended for .net and it really doesn't seem to be entirely PCRE compatible. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about isset and binary conditionals
That's a big help Mike. My server has the error level set such that my incorrect use of if($var) did not show undefined variables. Though everything seemed to work OK. I'm going my code and using if( TRUE or FALSE) isset() and empty() as appropriate. Al.. Mike Ford wrote: On 07 June 2004 14:04, Al wrote: I posted this previously; but the subject was misleading. You seem to have several possible misconceptions in your posting -- this may just be me misreading you, but anyway... I could use one additional clarification regarding good practice. As I understand the php manual the following is acceptable and I assume good practice. $foo= TRUE; Not only acceptable but encouraged. if($foo) do.. ; where $foo is a binary; but not a variable. $foo is always a variable -- it can contain values of several types, one of which is Boolean (not binary -- that's just a way of representing integers) TRUE/FALSE. isset should be used for variables, such as; isset($var) for variables and be careful with $var= ' '; etc. because $var is assigned, i.e., "set". To work out which test you need to use, it's crucial to understand what evaluates to FALSE in a Boolean context (which the test of an if() statement is. This is covered in precise detail in the PHP manual at http://www.php.net/manual/en/language.types.boolean.php#language.types.boole an.casting, but to summarize: the following are considered FALSE: Boolean FALSE, numeric zero (0 or 0.0), the strings "" and "0", an empty array or object, and NULL; all other values are TRUE. In addition to this, an unset variable will be evaluated as NULL, and hence considered FALSE, but PHP will also issue an undefined variable warning in this case (which may or may not be suppressed by your PHP configuration!). On the other hand, isset($var) will return TRUE if $var has been set to any value except NULL, and FALSE otherwise -- so an isset() test on all the other values listed above (including FALSE!) will be TRUE. Other tests you may want to look into are empty() http://www.php.net/empty and is_null() http://www.php.net/is-null; there are also some handy tables at http://uk.php.net/manual/en/types.comparisons.php to help you see what the various tests return. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Newbie question about isset and binary conditionals
I posted this previously; but the subject was misleading. I could use one additional clarification regarding good practice. As I understand the php manual the following is acceptable and I assume good practice. $foo= TRUE; if($foo) do.. ; where $foo is a binary; but not a variable. isset should be used for variables, such as; isset($var) for variables and be careful with $var= ' '; etc. because $var is assigned, i.e., "set". -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Newbie question about isset and binary conditionals
I posted this previously; but the subject was misleading. I could use one additional clarification regarding good practice. As I understand the php manual the following is acceptable and I assume good practice. $foo= TRUE; if($foo) do.. ; where $foo is a binary; but not a variable. isset should be used for variables, such as; isset($var) for variables and be careful with $var= ' '; etc. because $var is assigned, i.e., "set". -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] A follow up on my question about good coding practice [isset]
I could use one additional clarification regarding good practice. As I understand the php manual the following is acceptable. $foo= TRUE; if($foo) do.. ; where $foo is a binary; but not a variable. Use isset($var) for variables and be careful with $var= ' '; etc. because $var is assigned, i.e., "set". -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Newbie question about good coding practice [isset]
if($var) do something; verses if(isset($var)) do something; The simple form if($var) seems to work fine and I see it in code often. Is there a good reason for using isset? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: CONSTANTS and good coding practice
Many thanks everyone. Seems like I should be using constants a lot of places where I've been using globals. Al wrote: Can someone explain to me the value of using defined custom constants, in the context of good coding practice. I don't recall ever seeing define() used in the scripts I've seen and only the characteristics are described in the my php book and the php manual; but, not the use. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] CONSTANTS and good coding practice
Can someone explain to me the value of using defined custom constants, in the context of good coding practice. I don't recall ever seeing define() used in the scripts I've seen and only the characteristics are described in the my php book and the php manual; but, not the use. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie question about preg_match
If I have multiple instances that match the pattern, but only want the first one, which is the best way to handle it? Putting the "U" flag seems to work, but I don't understand the full implications of using it here. preg_match("|$start(.*?)$end |Ui", $contents, $text); Alternatively, I could use preg_match_all and use $text [1]. Thanks John W. Holmes wrote: From: "Al" <[EMAIL PROTECTED]> I'm trying to compose a general purpose text snip expression to extract a text segment from a string. Should this work for all reasonable cases? It seems to work for several test strings. $start= "str1"; $end= "str2"; preg_match ("|$start (.*) ? $end |i", $contents, $text); $segment= $text[1]; Looks like you have some extra spaces in there that'll mess it up. The '?' for example, is only applying to the space before it. You want preg_match("|$start(.*?)$end |i", $contents, $text); Note that this will only return one match when there could be more, depending upon your string. If you want all of them, use preg_match_all(). ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] newbie question about preg_match
I'm trying to compose a general purpose text snip expression to extract a text segment from a string. Should this work for all reasonable cases? It seems to work for several test strings. $start= "str1"; $end= "str2"; preg_match ("|$start (.*) ? $end |i", $contents, $text); $segment= $text[1]; Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: accessing $_POST from another page.
Save the POST variables in $_SESSION buffers. Don't forget to 'start_session" first thing on the page. Edward Peloke wrote: I have a page class which controls what happens within a given page. For example, the code in my index page is this: $page=new AdminPage(); $page->action($action); $page->paint($paint); The paint and action methods simply set include files Function action($action){ include_once($this->actionRoot.$action.".action.php"); } On my test page, my paint method paints an add client form. The action of the add client form recalls the page passing in the action: action="index.php?action=addNewClient". So, when this form is submitted, the page is reloaded and $page->action("addNewClient") is called which includes the addNewClient.action.php page which simply contains the insert into the database using the $_POST vars. The problem is, this page doesn't seem to have access to the $_POST vars. To help remedy this, I added this to the end of the form: '; ?> and added this in my addNewClient.action.php form: $posted = unserialize(base64_decode($_POST['posted'])); However the $_POST variables only come through after I have clicked submit twice. What's the best way to handle this? Do I simply need to pass in the $_POST array to my action script? THanks, Eddie WARNING: The information contained in this message and any attachments is intended only for the use of the individual or entity to which it is addressed. This message may contain information that is privileged, confidential and exempt from disclosure under applicable law. It may also contain trade secrets and other proprietary information for which you and your employer may be held liable for disclosing. You are hereby notified that any unauthorized dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify [EMAIL PROTECTED] by E-Mail and then destroy this communication in a manner appropriate for privileged information. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SQLite /how can I install on an Apache virtual host?
Many thanks. Several good points you made. I should recompile rather than use just any old binary. I found it on the net. I wasn't clear how to tell the php.ini how to interpret the extension. I can't to run command lines on the host, so its a bit of a bother to compile stuff there. I've had some success using phpshell. Curt Zirzow wrote: * Thus wrote Al ([EMAIL PROTECTED]): I've got a website on an Apache virtual host and would like to install the SQLite library. Can someone give me a brief outline of what I need to do or point me to a good writeup? some info on sqlite: http://php.net/sqlite You can compile and install the extension from the source located here: http://pecl.php.net/sqlite My host makes it tough to run command line code to make files, etc. I've found a a Linux binary [sqlite.so]. And, they provide a means to customize the php.ini. You found it on your virtual host machine? or somewhere on the internet? I wouldnt trust any old .so laying around somewhere. If its on your virtual host machine already then you can just add this to your php.ini (assuming its in your extension path) extension=sqlite.so Curt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SQLite /how can I install on an Apache virtual host?
I've got a website on an Apache virtual host and would like to install the SQLite library. Can someone give me a brief outline of what I need to do or point me to a good writeup? My host makes it tough to run command line code to make files, etc. I've found a a Linux binary [sqlite.so]. And, they provide a means to customize the php.ini. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Can I get varaibles from an include file without exectuting it?
I have a script that is run with a cronjob and would like to fetch some variables from it, using another file, without the script executing. I could resort to putting the variables in a third file, or reading the script as a text file and reconstructing the variables. But, I was hoping there is a better way. Any suggestions? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Finding orphan functions
Anyone have a suggestion for how I can determine if I have any orphan functions in a function file? I have a include file with about 30 functions that I have been adding to for several months. No doubt some have been superseded, etc. and are now obsolete. I could laboriously trace every path in my code and find the orphans; but, it would be nice to be able to automate the job a bit. Is there a neat way to run my applications and record which functions are used? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Another preg question
Thanks for the feedback. Here was my problem; I misunderstood how the "+" worked. It only applies to the last "\n", not both "n\n". Hans Juergen Von Lengerke wrote: From: Al <[EMAIL PROTECTED]> $text= preg_replace("/\n\n+/", "\n\n", $text); // remove excess This doesn't seem to do anything. Strange, your code works for me: [EMAIL PROTECTED]:~ > cat foo.php [EMAIL PROTECTED]:~ > php ./foo.php before: === foo bar === after: === foo bar === [EMAIL PROTECTED]:~ > php -v PHP 4.3.4 (cli) (built: Feb 12 2004 17:42:41) Copyright (c) 1997-2003 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies [EMAIL PROTECTED]:~ > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Apache+modssl+php problem??? possible IE bug?
Did you try print_r($_SESSION); to see if anything is getting into the buffer? Chris Wilson wrote: When in IE, submitting any form on our https page, the post variables intermittantly don't come through. The get variables come through fine. Just not the $_POST variables. I have tried everything to get this to work. Everything was working fine but it seems after we updated IE with the last critical updates this started to become an issue. We have rebuilt servers, and installed apache+modssl+php from /usr/ports, as well as manually and have been unable to resolv this issue. We are using a generic installation of apache+modssl+php with the included php.ini, only modifications being Register_globals on and safe_mode off We have also tried backing down to an earlier version of php and apache (php 4.3.1, modssl 2.8.15 and apache 1.3.28, which we were running before the rebuild) Netscape seems to work fine. Once again, this only seems to be happening on secure pages. We have tried on multiple workstations, and our customers seem to be effected by this too. Does anyone know what this might be? possibly an IE bug? Any help would be apreciated. Thanks! :) Chris Wilson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Another preg question
Didn't work. I'm beginning to think the problem is more involved. I am going to break out just the essentials of the code that is involved and debug just it. Thanks Matt Matijevich wrote: Next, I want to remove excessive CR/LF, [i.e. more than 2] $text= preg_replace("/\n\n+/", "\n\n", $text); // remove excess This doesn't seem to do anything. not 100% sure this is right but give it a try $text = preg_replace("/\n\n+|\n\r[\n\r]+|\r\r+/", "\n\n", $text); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Another preg question
I'm trying to clean up newline code received from a browser textarea. First, I'm normalizing the newline codes to Unix with: $text= preg_replace("/(\r\n|\r)/", "\n", $text); //this seems to work OK Next, I want to remove excessive CR/LF, [i.e. more than 2] $text= preg_replace("/\n\n+/", "\n\n", $text); // remove excess This doesn't seem to do anything. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] New Line code question \r\n etc.
I've got a php application running on a Unix system and need some help with the new line code. The application reads and saves text in a file from a browser textarea. Also, the text file is occassionally opened and edited via ftp and a regular plain text editor. It appears the new line code is getting screwed up because of the different programs handling the text. [i.e. "\r\n", "\n", "\r"] I'd like to have my code clean up the newline code every pass and standardize it. What new line should I use, "\n" Unix, or what? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP EDITORS
Great and it's free. http://phpedit.net John Jensen wrote: Hello everyone. I am new to PhP and MySQL. I was wondering what a good (Or Free) Php Editor is? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: content management
"Justin French" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Tuesday, January 27, 2004, at 04:23 PM, Al wrote: > > > This is one of the most frequently asked questions about the LAMP > > platform. > > A fantastic site that offers a comparison of all the different open > > source > > CMS systems out there and lets you test drive them all is > > http://www.opensourcecms.com/ . I highly recommend it. > > But chances are you'll try them all out, and still decide that there's > nothing to suit your needs (without being a bloated mess) and decide to > roll your own :) > > Justin So true. Everytime I sit down to choose a CMS for a project I usually go through the following steps: 1) Write down spec and design for the CMS ... which is usually simple and mundane except for one slightly unusual requirement. 2) Do some initial research and become excited by the dozens of open source CMS systems promising to cut my development time by 80%. 3) Realise that none of the simple CMS platforms can handle my one unusual requirement. Consider hacking it in, but realise just how much I hate having to work with other people's code ... espcially on big apps like CMSs with steep learning curves. Go back and do some more research. 4) Find a mothership CMS (e.g. ezpublish) that can handle my one unusual requirement, and could probably iron my shirts as well, but I run away when I realise I'll only use 3% of it's functionality but have to maintain and serve up CPU cycles for 100% of its code. 5) Start writing my own CMS. Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: content management
"Pupeno" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Does anybody know of an extremely simple CMS (to serve pages, documents, not news based like most of them) that can store pages in various languages and comes with interface in various languages (or that it is translatable) ? - -- This is one of the most frequently asked questions about the LAMP platform. A fantastic site that offers a comparison of all the different open source CMS systems out there and lets you test drive them all is http://www.opensourcecms.com/ . I highly recommend it. Hope it helps, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Ques: Conflicting functions in two include files.
I have a page that calls functions from two different include files. Unfortunately, some of the functions have the same name; but are slightly different. I know I can change the names of the conflicting functions; but, that is a bit of a chore. Is it possible to control from which include file the functions are used? I tried putting the include statement just before the function call, hoping the server would replace the functions with the new include. I'm using include_once. It didn't work. I tried putting the include file with the function call inside of a function. Didn't work, still executed the functions stated at the top of the page. Any suggestions? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Syntax Highlighting
"Richard Davey" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm after a technique/method that will allow me to syntax highlight > source code on my web site. PHP already does a brilliant job of this > for PHP code, but I need to extend this to ANY form of source code. Try http://www.beautifier.org/, a free PHP app that can syntax highlight a ridiculously large number of languages ... even Logo! Hope it helps, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Comparison PHP to Perl
"Warren Vail" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I am looking for a comparison of features supported by PHP vs those > supported by Perl. > [snip] Ah, this old chestnut. As someone who wrote a major application in Perl, and now (mostly) uses PHP, I can only reiterate what's been said a thousand times before: the language you choose depends on what features you want and the type of script you'll be writing. You've only identified session support as a requirement, and although PHP has native session support, Perl has similar functionality available via the Apache::Session CPAN module. Actually, this is true for almost all extra native functionality in PHP that Perl does not support -- it's there in Perl, but you need to download a CPAN module for it. Another example of this is PHP's native mail( ) support. (For the uninitiated, CPAN [http://www.cpan.org] is a fantastic collection of standardised Perl extensions with an easy install script that has evolved over many years). Unfortunately the same does not apply for PHP: although it has an impressive array of built-in functions (especially compared to Perl's paltry offering), if a particular feature is not handled natively then you'll probably have to write your own code to implement it. Although there *is* a CPAN equivalent in PHP called PEAR [http://pear.php.net] that boasts a decent number of modules (most of which are still in early development stages), PHP simply hasn't been around long enough attract as much module development as Perl. So in summary: list all the features you need and if PHP supports them all (or if a few are missing and PHP's ease-of-use and other benefits outweigh the cons) then go with PHP, otherwise take another look at Perl. For a list of PHP's features, take a look at the documentation ... it's very user-friendly. [http://www.php.net/manual/en/] You'll also find a ridiculously large number of articles online comparing PHP to Perl, just do a Google search such as: [http://www.google.com/search?q=php+perl+comparison] Hope it helps, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP $_SESSION Expiring in IE
IE and Moz have different JAVA script engines. Try turning off JAVA and see if IE maintains it's session. Tarrant Costelloe wrote: Hello, I have recently launched the new Planet-Tolkien.com, one would think that writing a message board from scratch and a dynamic weather system, a simple session login would be the least of my problems right? Wrong. It would appear that for Mozilla and Opera keep a $_SESSION is not an issue and the $_SESSION is continued until the member logs out. However when members are using Internet Explorer browser (most versions it seems), they can go around the site for varied amounts of time, usually less than five minutes and then their $_SESSION will expire!!?? I cannot for the life of me figure out why a server side $_SESSION would expire on IE but not for MOZ or Opera but it is, and I need to figure out why and how can I fix this. REF. All login information is saved as such: session_save_path("$path/sessions"); session_start(); $_SESSION['session_memberID']=$session_memberID; $_SESSION['session_username']=$session_username; $_SESSION['session_groupID']=$membergroup; In Fellowship, Tarrant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session logic question
Thanks for the reply. i just found the bug in my code. I had a statement in the second script: $_SESSION = $array; that obviously, completely replaced everything in the $_ SESSION buffer. These little I gotchas can be fun. Chris Shiflett wrote: --- Al <[EMAIL PROTECTED]> wrote: Everything works fine, except when I include another script file that also uses the $_SESSION buffer. What appears to be happening is that start_session() on the second script reinitializes the session buffer and I lose the data from the first session. Yes, as it should. You need to only start the session once. Hope that helps. Chris = Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session logic question
I use the $_SESSION buffer extensively on my site without a problem, except one. Maybe someone can help me understand the problem. I have a simple page counter with a test to see if the page has been counted for the user. start_session(); * * [additional code] * if($_SESSION['ctr_file']!==$counterFile) //See if visitor has already been counted for this page {$num = $num+1; $_SESSION['ctr_file'] = $counterFile;//set/reset counter file for next time Pages that use the counter function all have a start_session(); and a call to the counter function, Everything works fine, except when I include another script file that also uses the $_SESSION buffer. What appears to be happening is that start_session() on the second script reinitializes the session buffer and I lose the data from the first session. Yet, as I read php manual, it seems to say that start_session is suppose to simply restore the variables for the page it is on; not start a new session. many thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Another Session Question
Your'e right, that's a typo. If I put a echo $_SESSION['counter_file'] . ' testx ' . $counterFile; Before and after the conditional, $_SESSION['counter_file'] is set after the conditional, as it should be. But, it is gone from the before echo when the function is recalled. The Session buffer looses the value. session_start() is called again before returning to the function; but, I thought repeated session_starts() were ignored and thus should not restart the session. I use the session buffer extensively in other places without any problem. Matt Matijevich wrote: [snip] session_start(); if($_SESSION['counter_file'] !==$counterFile)//See if visitor has already been counted for this page {$num += 1; $_SESSION['counter_file'] = $counterFile; } echo $_SESSION['counterFile'] . ' testx ' . $counterFile; [/snip] might just be a typeo but do you mean: echo $_SESSION['counter_file'] . ' testx ' . $counterFile; instead of this: echo $_SESSION['counterFile'] . ' testx ' . $counterFile; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Another Session Question
There is a little code that worked before my virtual host before they updated to 4.3.1. First time the function is called session should be set, subsequent calls should be skipped. session_start(); if($_SESSION['counter_file'] !==$counterFile)//See if visitor has already been counted for this page {$num += 1; $_SESSION['counter_file'] = $counterFile; } echo $_SESSION['counterFile'] . ' testx ' . $counterFile; $_SESSION['counterFile'] shows nothing, even the first time through $counterFile shows just fine. Al.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Testing for Well-Formed XML
"Ian Williams" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi > I'm trying to build a validator in PHP, to check that XML documents are > well-formed. As a starting point I'd check out the excellent, open-source PEAR modules available for XML manipulation at http://pear.php.net/packages.php?catpid=22&catname=XML, and in particular the XML parser module at http://pear.php.net/package/XML_Parser. Hope that helps, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: HELP! -- Problem with imagejpeg()
Here is a complete function I wrote a few months ago. It should do it for you or give you hints for fixing your problem. René fournier wrote: Hello, I have a function that is meant to check if an image is greater than a certain width and height, and if it is, downsample it. The checking part works fine. Downsampling is not happening though. Here's what I've got (btw, $file = "/somedirectory/photo.jpg"): $src_img=imagecreatefromJPEG($file); $dst_img=imagecreatetruecolor($new_width,$new_height); imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_width,$new_height,$siz e[0],$size[1]); imagejpeg($dst_img,$file,$img_quality); Any ideas? Thanks. ...Rene 100, "new_width" => 200, "quality" =>100, "backup_org" => "no"); * * quality = percent [e.g. "quality" => 90] meaning 90% * width = pixels [e.g., "new_width" => 200] i.e., 200 pixels. * backup_org [original file] "yes" or "no". "no" is the default * * Use this to fetch $resize_stats: * foreach($resize_stats as $key => $value) * { * echo $key . " = " . $value; * } */ function resize_width($file_location, $resize_args, $auto) { global $DOCUMENT_ROOT; if (empty($resize_args)) die("Code error, argument(s) in \$resize_arg missing in resize_width. "); if($auto== "yes"){ if ($_FILES['username']['error'] == 0) { $name = key($_FILES); //could use the register variables, but this is safer. $org_img = $_FILES[$name]['name']; $org_img = filename_fixer($org_img); $org_img = $file_location . $org_img; } } else{$org_img = $file_location;} if ($resize_args['backup_org'] == "yes") { file_backup($org_img); } $org_img = $DOCUMENT_ROOT . $org_img; if (!file_exists($org_img))die("Code error, $org_img missing or incorrect file name in resize_width() "); $new_width = $resize_args['new_width']; $quality = $resize_args['quality']; $imagehw = GetImageSize($org_img); $org_width = $imagehw[0]; $org_height = $imagehw[1]; if ($new_width !== $org_width) { $imagevsize = $org_height * $new_width / $org_width; $new_height = ceil($imagevsize); $src_img = imagecreatefromjpeg($org_img); $dest_img = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($dest_img, $src_img, 0, 0, 0, 0, $new_width, $new_height, $org_width, $org_height); imagejpeg($dest_img, $org_img, $quality); imagedestroy($src_img); imagedestroy($dest_img); } else { $newheight = $org_height; } // see above how to use array $resize_stats = array("Orginal width" => $org_width, "Orginal height" => $org_height, "New width" => $new_width, "New height" => $new_height); if ($resize_args['show_stats'] == "yes") { foreach($resize_stats as $key => $value) { echo $key . " = " . $value . "\r\n"; } } return $resize_stats; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Where and how do i use $_post etc
"Piet" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi > > I am trying to find examples of how and where to use $_POST, $_GET etc. I > searched a lot of places, but cant seem to find decent examples or a > tutorial or something. $_POST and $_GET are associative arrays containing the form data sent by a user to a page. Whether your user's submitted form data is in $_POST or $_GET depends on what method attribute you've specified in the tag in your HTML code. Take a look at the following HTML example: Now in the file script.php you can access the submitted form values in the $_GET array, using the form field names as array keys. e.g: If you had set the in your HTML, then you could have accessed the form values from the $_POST array within PHP. Hope that helps, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP IDE?
I searched for weeks and tried about 8 php editors and settled on http://www.phpedit.net/products/PHPEdit/ Code hints and completion, and highlighting, etc. are superb. Has a few minor bugs, but they are not serious. The automatic documenter [they call it help, which it really isn't] is super. Has built-in debugger. Daniel Hahler wrote: on Sat, 13 Dec 2003 09:06:56 -0800 (PST) Jough Jeaux wrote: JJ> Was wondering what everyone's favortie IDE is for JJ> coding in PHP. I've got a big PHP project in the JJ> works. I'll be doing alot with it and am looking for JJ> ways to boost my productivity. Used to use UltraEdit some time, but now I'm with jEdit. It's an OpenSource Java editor and supports plugins.. so you can manage Projects and a lot more. It's main target (from the number of plugins) is Java development, but it's great for PHP/HTML also. http://www.jedit.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Trying to check for a valid URL String.
"Philip J. Newman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > so far i got ... > if (!ereg("^http:\/\/([_\.0-9a-zA-Z-]+\.)+[a-zA-Z]/i",$websiteUrl) { On a quick glance, three things stand out: 1) You allow underscores in the website domain, but these are not valid characters for domain names. 2) You allow dashes in the first pattern, but do not escape the dash character. 3) You have not provided a quantifier to the top-level domain pattern: [a-zA-Z], so it is only looking for one character fits the class [a-zA-Z]. Hope that helps, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Operation in an Array
"Harry.De" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > How can i make an operation like adding variables in an array for example > $array[$a+$b]; You'll have to be more specific. What exactly do you want to do? Add values of an array together? Their keys? Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How could I count the elements of each dimension of an array?
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >How could I count the elements of each dimension of an array? >I have this script, but it failed, thanks for any help >$ojpp[0] = "1"; >$ojpp[1] = "2"; >$ojpp[2] = "3"; >$ojpp[3] = "4"; >$ojpp[0][1] = "1"; >$ojpp[0][2] = "2"; >$ojpp[0][3] = "3"; >$ojpp[0][0][1] = "1"; >$ojpp[0][0][2] = "2"; >$test1 = count($ojpp); // first dimension >$test2 = count($ojpp[0]); // second dimension >$test3 = count($ojpp[0][0]); // third dimension >echo $test1; >echo $test2; >echo $test3; >echo ""; >print_r($ojpp); >echo ""; The problem with the code above isn't with how you count the dimensions of the array, but how you assign values to the second and third dimensions. Ordinarily, the code $ojpp[0][1] = "1" will create an array at $ojpp[0] and set it's second element to be "1". On the first line of your code, however you have *already* assigned the string value "1" to $ojpp[0]. So when PHP sees the code $ojpp[0][1] = "1" it thinks you're trying to use the 'curly braces' syntax for accessing single characters of a string. This syntax is not widely known, but essentially means you can access characters in a string like elements of an array, by using curly braces. For example, will print the third character in $string. For reasons unknown to me, PHP will also let you use square brackets on a string to perform the same action ... eg although this alternate syntax is being phased out. ( For more info see: http://us2.php.net/manual/en/language.types.string.php ). So essentially PHP intereperets $ojpp[0][1] = "1" as being an attempt to assign "1" as the second character to the string already assigned to $ojpp[0]. Which begs the question: why assign "1" to $ojpp in the first line of your code when you seem to want to reaplce it with an array on lines 5 - 8? This kind of coding bug is a by-product of a type-juggling, permissive languge that doesn't require you to pre-declare variables. To fix your code, change the first line of your code to read: $ojpp[0] = array(); Hope that helps, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: passing arrays?
> $level = '$level_' . $_SESSION['user']['level']; > //Where $_SESSION['user']['level'] can equal "1" or "2" > > $level_1 = array("PN", "GALUP", "VP", "PUBUP", "STATS", "MCI", "CONLIST", > "CP", "OAFS", "LO"); > $level_2 = array("PN", "GALUP", "VP", "PUBUP", "MCI", "CONLIST", "CP", > "OAFS", "LO"); I can see two problems with your code: 1) The syntax for assigning to $level is wrong. Rather than: $level = '$level_' . $_SESSION['user']['level']; your code should read: $level = ${'level_' . $_SESSION['user']['level']}; For more information on this syntax, see: http://us2.php.net/manual/en/language.variables.variable.php 2) You are assigning $level_1 or $level_2 (depending on the value of $_SESSION['user']['level']) to $level *before* you have assigned $level_1 or $level_2 any values. There's no point making $level = $level_1 if $level_1 hasn't been defined yet. Working code would be: $level_1 = array("PN", "GALUP", "VP", "PUBUP", "STATS", "MCI", "CONLIST", "CP", "OAFS", "LO"); $level_2 = array("PN", "GALUP", "VP", "PUBUP", "MCI", "CONLIST", "CP", "OAFS", "LO"); $level = ${'level_' . $_SESSION['user']['level']}; Hope it helps, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Write on image in faint color
>4) I'd love to see a PEAR IM module a la PerlMagick (but I haven't even >looked yet, so please don't flame me for missing something obvious). One >of these days I'll have The Great Rewrite and that will go in then. I'd >love to be rid of the system() calls to convert and mogrify. The closest thing out there at the moment (that I know of) is a PHP extension available through PECL, the PHP extension library. According to the docs, it "provides a wrapper to the ImageMagick/GraphicsMagick library." You can find it and download it at http://pecl.php.net/package/imagick. Hope that helps. Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Write on image in faint color
There's a command line, open-source utility called ImageMagick (http://www.imagemagick.org/) available for all major platforms that allows you to do lots of powerful image manipulation on one file, or one thousand. You crop, scale, rotate, colour, draw on, place text over, compose, transform and create montages of images using this program. It has quite a steep learning curve, but the results are worth it! You can run this using PHP shell_exec() function if you want to execute the program from a web page, although be careful of the obvious security consideration involved in doing this. Hope it helps, Al "Ryan A" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > This was asked some time ago but cant find it in the archive, anybody > remember how it was solved please write and tell me. > > Requirment: > Write domain name in faint color on picture (a kind of "watermark") > > Reason: > I have 3 directories full of images that are original to our site and I > spent a crapload of time scanning them and putting them up, I dont want > others to just "borrow" the images and use them without giving us some type > of credit... > > I found a package on google after searching that you just throw all the > images in a folder and it generates the thumbs for you in a folder called > "thumbs", can i do the same for this too? > ie. > throw all the images in a folder, run the program and get www.sitename.com > written on all the images? > > Any help and reminders appreciated. > > Cheers, > -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Sort Array by date
> I have a bunch of dates in the form: MM-DD- in an array and I want to > sort them and display them in descending order. I have tried the usort() > function below and it's not working. Can anyone help me out here? Your sorting function uses strtotime, which doesn't recognise data in the MM-DD- fomat. Generally speaking, dates are best stored in the ISO standard format -MM-DD so that they can be sorted easily with functions like strcmp. This format is also recognised by strtotime( ). Look in the code below to learn how to convert your date format to the ISO standard. If you can't change the date format, you can also modify your sorting function as following: // Note this is untested pseudo-code: function date_file_sort($a, $b) { list ($aMonth, $aDay, $aYear) = explode('-', $a); $aIsoDate = sprintf("%04d-%02d-%02d", $aYear, $aMonth, $aDay); list ($bMonth, $bDay, $bYear) = explode('-', $b); $bIsoDate = sprintf("%04d-%02d-%02d", $bYear, $bMonth, $bDay); return strcmp($aIsoDate, $bIsoDate); } Good luck with it, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: html stripping
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > No this is not some shaddy game or strip poker knock-off. My question has to > do with a person project I have started. I have a script that grabs names and > ids from a database, puts them in an array and then based on that grabs a URL > and parses that URL for this name, drops all the html crap, and takes the > information/stats and insert or updates the stats table. Problem is on > certain names the page that it is parsing is different, and so I get loads and > loads of extra HTML, and one name in particular doesnt return all the stats. In essence what you're trying to do is spider / trawl web pages that do not have consistent HTML formatting with inflexible functions like substr( ) and str_replace( ) that are incapable of adapting to inconsistent search text. You'd be much better off extracting the relevant data from HTML using functions such as preg_match( ) and preg_replace( ) which let you search over text using Perl-style regular expressions (aka regexes). Function documentation can be found at: http://au3.php.net/manual/en/function.preg-match.php and http://au3.php.net/manual/en/function.preg-replace.php If you have no idea what a regex is, think of it as powerful, wildcard-based searching. It allows you to write search expressions that are very tolerant of changing search text and can still extract the data you need. Regexes can be confusing when you start out. Try looking at this tutorial for some starters: http://www.phpfreaks.com/tutorials/52/0.php Good luck. Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question on sending PhP variable results to an HTML page to be displayed.
Hi Jay, This will not work because the page in question ends in .HTML but I did discover a way to do what I need and an answer to many other posts. Here is the answer: To make a PHP command to execute on a .html page create another page ending in .php with the code there. Where you need to display this in your .html page use the html tag. It works just fine. A person gave me this idea by emailing me and saying why not use a frameset to do this. This is kinda what IFRAME does but it is more like a little window. Same concept but it does not interfere with how a search engine indexes a website. Anyone interested in seeing the resulting code, it is located at: http://www.dynamicsubmission.com and a one line php program returns the date to the page. I would like to thank everyone for their ideas and this is a very useful resource to have. I may know a great deal about seach engines, but when it comes to php... well ... thanks for the help! Al Costanzo - Original Message - From: "Jay Blanchard" <[EMAIL PROTECTED]> To: "Al Costanzo" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, December 01, 2003 8:49 AM Subject: RE: [PHP] Question on sending PhP variable results to an HTML page to be displayed. [snip] If you use the date function in PhP you can get the date and it will not change in the cache since the actual code is not on the page that generated it. My question is how do I get the answer that I have in a PHP variable back to an HTML page and give it lets say to JavaScript to display. [/snip] Why do you need to give it to JavaScript to display? Consider this in your HTML -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Export data
> Is it possible to export some data to MSOffice format ( .doc and .xls ) , > OOffice ( .sxw and sxc ) or .rtf format with PHP The answer is sort of.. To write Excel files, you can use the Spreadsheet Excel Writer package available under the PEAR module. The module's site is at: http://pear.php.net/package/Spreadsheet_Excel_Writer The only RTF file generator for PHP that I know of is (appropriately) called RTF Generator, but it costs around $50. The website is: http://www.paggard.com/projects/rtf.generator/ Another commonly suggested method of creating RTF files with PHP, especially if your file format is not likely to change much, is to create the document in Word and format it as you like, using unique words as placeholders. Then open the file with a text editor find the placeholder words, and use PHP to substitute your data for the placeholder words. Yet another work around is to create your documents in HTML but then name them "filname.doc" When your users open the document, Word will launch and auto-convert the file, giving your users the option to save it as a normal Word document. You can also use this tactic with Excel, creative CSV file easily in PHP, and then serving them to your users as XLS files. Good luck, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question on sending PhP variable results to an HTML page to be displayed.
Hello, I know this may seem like the opposite approach but please let me explain the important reason I am trying to discover how to do this. Let us say you have a website www.example.com and you want to track and display information when a search engine scanned and stored the result into its database. Now you cannot change the home page name to whatever.php because this will alter the seach engines ranking of your site and you cannot display the date using JavaScript because the date will change even in the cache because the code is on the page. If you use the date function in PhP you can get the date and it will not change in the cache since the actual code is not on the page that generated it. My question is how do I get the answer that I have in a PHP variable back to an HTML page and give it lets say to JavaScript to display. Thanks for any help on this. Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Count online users question
> I am trying to figure an accurate way to calculate how many users are > viewing a site, at any particular time. This task is very simple except for > one part - How do you determine when a person has left the site...apache > hasn't served anymore requests from a particular ip for xx minutes ?? Hi Mike, There is no surefire way to measure the exact time a user leaves your site. The most accurate way I can think of would be to use a hidden frame on all your pages that refreshes itself every X seconds. When a user has not requested that special tracking page for more than X seconds, you can assume they have 'left' the site. However this solution seems like overkill for most purposes: you'll be wasitng server resources and slowing down your users' experience on your site. In response to your proposed method, most advertising associations (including the US-based Internet Advertising Bureau) and web analytics companies (such as Red Sherrif, Nielsens and Hitwise) define the end of a user session on a website when there is 30 minutes without a further request for a page from the site. And while you may be tempted to track only IP numbers, remember that many users are behind shared IP numbers (e.g. firewalls) which may skew your stats. You would be better off using cookies on user's machines to identify them and log their accesses to a DB. Hope that helps, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP to get mail headers
"Scott St. John" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > A search did not yield much in what I am trying to do: > 1)Open the mailbox and extract the Received, From and Subject headers. > 2)Drop those into a database that I can manage from the browser. There are two PEAR packages that can help you with this: 1) Mail_Mbox will parse and manipulate mbox files so you can traverse your mail file and pull out individual messages. http://pear.php.net/package/Mail_Mbox 2) Mail_Mime contains classes for decoding and parsing individual messages. http://pear.php.net/package/Mail_Mime Hope it helps. Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: String Manip. - Chop Equivalent
>From the PHP Manual notes (http://us2.php.net/manual/en/function.chop.php): $string = substr("$string", 0, -1); Al "Jed R. Brubaker" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Does PHP have an equivalent to PERL's chop - that is, a way to get rid of > the last character in a string? > > "Hello World" to "Hello Worl" > > Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: User/Pwd Management Package?
There are a number of open-source PEAR packages that can help you manage usernames, passwords, and user preferences. Check out: http://pear.php.net/packages.php?catpid=1&catname=Authentication Hope it helps, Al "Jonathan Rosenberg" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Friends, > > I'm interesting in finding a PHP package that implements functions for > managing user names & passwords & controlling access to specific parts of a > site. > > Of course, free is best. But cheap is good. And, even not-so-cheap is > fine, as long as it provides good functionality. > > Any pointers appreciated. > > -- > Jonathan Rosenberg > President & Founder, Tabby's Place > http://www.tabbysplace.org/ > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Get value between 2 strings
Here's what I use: /** * get_text() * * $t The total text string * $s starting text string [e.g. ] * $e ending text string [e.g. * * @return the extracted text string. [e.g., returns string between start and end texts. */ function get_text($text, $s, $e) // Get string out of text { $sp = strpos($text, $s, 0) + strlen($s); $ep = strpos($text, $e, 0); return substr($text, $sp, $ep - $sp); } Matt Palermo wrote: Hello. I was wondering if anyone knew of a function to get the value between 2 strings. For example, lets say I have the following line: $line = "I want the value between word ONE and word TWO. Please return it..."; Now, I want to get everything between "ONE" and "TWO". In this example it should return the value " and word ". Is there some sort of function I could use to easily do this? Please let me know if you have any ideas. Thanks, Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Good php WebMail Clients thru apache
"Jerry Alan Braga" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Any suggestions ? The best I've seen (by a long shot) is IMP, which is part of the open source Horde project. Product homepage is at: http://www.horde.org/imp/ Hope it helps, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: whois api's
There is a PEAR Project that does exactly what you want: http://pear.php.net/package/Net_Whois Al "Rolf Brusletto" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hey all - > > I'm currently working on a project which requires domain name > information. Has anybody used, or can anybody suggest php tools to get > whois information regarding any domain name? I'm trying to check out all > options before having to register as a registrar for get access to a > paid api. > > Rolf Brusletto > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PPTs and thumbnails
> In short: not with PHP. You're going to need a program that can read and > render PHP files, and save them as a static image (i.e. gif, jpg, etc). > Al Apologies, the 2nd sentence should read "You're going to need a program that can read and render PPT files ..." Arrrgh, I hate tpyos! :) Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PPTs and thumbnails
"Vijaya_manda" <[EMAIL PROTECTED]> wrote: > Is it possible to retrieve the first slide from a presentation and display > it as a thumbnail on my site. Users will upload ppt's which should be > displayed in form of thumbnails on my site. On clicking a particular > thumbnail the presentation (.ppt or .pps) file should be displayed. In short: not with PHP. You're going to need a program that can read and render PHP files, and save them as a static image (i.e. gif, jpg, etc). You can run this program (if you find one) using PHP, and then use PHP to resize and manipulate the output image, but PHP cannot natively manipulate PPT files, nor are there any PEAR packages for that purpose. Good luck, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Oh, for a "sureset()" (orthogonal to isset())
> function sureset($var) { > > if(!isset($var) || empty($var)) > return ''; > else > return $var; > } > > Of course, when you've got strict checking on, the above doesn't > work, because if the variable is unset you get caught on the fact > before the function call happens. One change will make your code work: just pass the $var argument by reference, ie. function sureset (&$var) { ...code... } I wrote a similar function a while ago, with a little added functionality: function get_if_set ( &$testVar, $falseValue = NULL) { if ( isset( $testVar ) ) { return $testVar; } else { return $falseValue; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Object Undefinded index
> I am just learning to use objects. I am messing around with a shopping cart > object, but am having confusing problems. I am getting an undefined index > error when trying to assign a key value pair to an array variable within an > object. I am confused becuase I believe this is how you assign array > variables outside an object. It acts like the variable is undefined. Thanks > for the help. My last post didn't actually address the error you mentioned though, so I might as well do that now... :) >From your example, the warning you received is cause by the add_item( ) method because it's attempting to add 1 to the value of $cart->items['10']. The only problem is that $cart->items['10'] hasn't been defined yet. Now PHP is smart enough to realise that if $cart->items['10'] doesn't exist, it should simply create the key and assign it a blank value (i.e. 0) and *then* add 1. So any subsequent calls to $cart->add_item("10", 1) won't generate an warning. It's also important to note that you only received a warning, not an error, and that code finished executing properly. You only received the warning because you had rerror reporting set to strict, which is normally a very good idea to help keep your code clean and bug free. The reason the code didn't work as expected was because of the bug addressed in my last post. To code the add_item( ) method in a way that won't trigger this warning, you can change it to: function add_item ($product_id, $quantity = 1) { if (!isset($this->items[$product_id])) { $this->items[$product_id] = 0; } $this->items[$product_id] += $quantity; } You can see that the code checks to see if the the key exists, and if it doesn't sets it to 0, before attempting to add to it's value. This is essentially replicating what PHP was doing anyway. Cheers, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Object Undefinded index
> foreach ($cart as $product_id => $quantity) > { > echo $product_id . "" . $quantity; > } The way you are accessing the array is incorrect. The $items array is a property of the Cart object. Since the Cart object may have many different array properties, the foreach statement above has to be sepcific about which array you want to iterate through. So the correct code would be: foreach ($cart->items as $product_id => $quantity) { echo $product_id . "" . $quantity; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem in 2 dimensional Array
> i have 2 problems in 2 dimensional array > > 1. how to declare global 2 dimensional array in php > 2. how to pass 2 dimensional array in function as an > arrgument In the context of your questions, 2-Dimensional arrays are no different to 1-dimensional arrays. All global vairables in PHP are stored in the predefined $GLOBALS associative array, which is automatically global in scope. Each key of the $GLOBALS array is a name of a global variable. For example, the following code will print "Hello World": Passing an array to a function is no different passing a scalar variable: Cheers, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Idea for new operator
Afternoon all, Is it just me, or would everybody else like to see a case-insensitive string comparison operator introduced into PHP? It is a type of comparison that I use a lot, and having to strtolower() everything before comparison can impact code readability, not to mention the angst, pain and trauma of having to repeatedly type 'strtolower()'. Assuming this new operator is something like '=*', the following two lines of code would be functionally identical. if (strtolower($a) == strtolower($b)) echo "The same!"; if ($a =* $b) echo "The same!"; Of course creating a new operator is only justified if the vast majority of PHP users do these comparisons as much as I do, and are as averse to work as I am ... :). Thoughts? Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Recommendation for Unique URL
> What is the best approach to the unique page ID? I thought I would store the > dept. mgrs. email address and the session ID in a db, and use the session ID in > the URL. Do I even need the mgr's email address? Is another approach better? > What have you used? I'd concatenate the employee's email and manager's email, and then use an MD5 hash of it as the unique string. i.e: $unique_id = md5 ( $employee_email . $manager_email ); For more info on what MD5 is, see http://us2.php.net/manual/en/function.md5.php Cheers, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about Class
I was afraid that was the case. Tom Rogers wrote: Hi, Thursday, October 16, 2003, 3:35:56 AM, you wrote: A> My question seems fundamental. I want to set a variable in one function A> in a class and then want to use the value in a second function. A> However, the functions are called a html page with two passes. Submit A> reloads the page and an if(...) calls the second function in the class. A> If I declare on the first run: A> $get_data = new edit_tag_file(); A> $edit_args= $get_data-> edit_prep(); A> The on the second pass, I'm stuck. I can't declare a new instance of A> "edit_tag_data". A> And, it appears the object is gone after I leave the page. A> Will the class structure do this for me or must I save the values in A> $GLOBAL or something? A> Thanks You need to pass the values to the next page or save them in a session -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Newbie question about Class
My question seems fundamental. I want to set a variable in one function in a class and then want to use the value in a second function. However, the functions are called a html page with two passes. Submit reloads the page and an if(...) calls the second function in the class. If I declare on the first run: $get_data = new edit_tag_file(); $edit_args= $get_data-> edit_prep(); The on the second pass, I'm stuck. I can't declare a new instance of "edit_tag_data". And, it appears the object is gone after I leave the page. Will the class structure do this for me or must I save the values in $GLOBAL or something? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php