[PHP] Script execution after window close
Hello, I need to run a few commands when a user close the browser tab. That is, I have a php page ( index.php ) and it will create a temporary file to track some stuffs. That temporary file should be removed, when the user close the browser tab. Is there any way to achieve this? Thank you, -- Regards Nibin. http://TechsWare.in
Re: [PHP] Script execution after window close
On Sun, 2012-03-04 at 20:49 +0530, Nibin V M wrote: Hello, I need to run a few commands when a user close the browser tab. That is, I have a php page ( index.php ) and it will create a temporary file to track some stuffs. That temporary file should be removed, when the user close the browser tab. Is there any way to achieve this? Thank you, Not reliably. There are events in Javascript that you can use to trigger an Ajax call (such as onbeforeunload and onunload) but these work slightly differently from browser to browser and may not allow you to execute anything on the browser if the user is navigating away from the site or closing the tab/window. Why can't you use the session for this, and allow the session to expire after a certain period of inactivity, which would be better than reinventing what sounds like session behaviour. -- Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Script execution after window close
in factI really need to remove the file ( which will be created for every access - making a copy from another location ). I can't leave that file alone for ever in the user disk space! :( On Sun, Mar 4, 2012 at 9:01 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: ** On Sun, 2012-03-04 at 20:49 +0530, Nibin V M wrote: Hello, I need to run a few commands when a user close the browser tab. That is, I have a php page ( index.php ) and it will create a temporary file to track some stuffs. That temporary file should be removed, when the user close the browser tab. Is there any way to achieve this? Thank you, Not reliably. There are events in Javascript that you can use to trigger an Ajax call (such as onbeforeunload and onunload) but these work slightly differently from browser to browser and may not allow you to execute anything on the browser if the user is navigating away from the site or closing the tab/window. Why can't you use the session for this, and allow the session to expire after a certain period of inactivity, which would be better than reinventing what sounds like session behaviour. -- Thanks, Ash http://www.ashleysheridan.co.uk -- Regards Nibin. http://TechsWare.in
Re: [PHP] Script execution after window close
in factI really need to remove the file ( which will be created for every access - making a copy from another location ). I can't leave that file alone for ever in the user disk space! :( Fine, so delete it after a period of inactivity -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution after window close
On 4 Mar 2012, at 15:31, Nibin V M wrote: in factI really need to remove the file ( which will be created for every access - making a copy from another location ). I can't leave that file alone for ever in the user disk space! :( Ash is right in that this is exactly what sessions are used for, so unless the data you are storing for the user is fairly large you'd be better off using them: http://php.net/session Why do you need to copy the file? Might be an idea to describe what you're actually doing rather than focus on this particular part. Do you make changes to the file after you've copied it? If not, why not use the original copy? If you do modify is, how and why? I'll bet there's a better way to do what you're doing. If you absolutely need to make these copies, your best bet is to have a script executed by cron periodically to clean up files with a last modified timestamp older than n seconds, and make sure each page request calls the touch function for that user's file to updated the file's timestamp. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ On Sun, Mar 4, 2012 at 9:01 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: ** On Sun, 2012-03-04 at 20:49 +0530, Nibin V M wrote: Hello, I need to run a few commands when a user close the browser tab. That is, I have a php page ( index.php ) and it will create a temporary file to track some stuffs. That temporary file should be removed, when the user close the browser tab. Is there any way to achieve this? Thank you, Not reliably. There are events in Javascript that you can use to trigger an Ajax call (such as onbeforeunload and onunload) but these work slightly differently from browser to browser and may not allow you to execute anything on the browser if the user is navigating away from the site or closing the tab/window. Why can't you use the session for this, and allow the session to expire after a certain period of inactivity, which would be better than reinventing what sounds like session behaviour. -- Thanks, Ash http://www.ashleysheridan.co.uk -- Regards Nibin. http://TechsWare.in -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution after window close
ok..I have script which will run based on some values in user's homedir. In fact I have tried to run the script from a various locations; but it didn't work as expected like it run from each users homedir. So, when the user access the page, it will copy the actual script to the user's homedir and executes it. I don't want to leave it there for ever; so I have to remove it from there when the user close the browser ( or after a period of in activity ). But I don't know how to code it :( On Sun, Mar 4, 2012 at 9:08 PM, Govinda govinda.webdnat...@gmail.comwrote: in factI really need to remove the file ( which will be created for every access - making a copy from another location ). I can't leave that file alone for ever in the user disk space! :( Fine, so delete it after a period of inactivity -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards Nibin. http://TechsWare.in
Re: [PHP] Script execution after window close
in factI really need to remove the file ( which will be created for every access - making a copy from another location ). I can't leave that file alone for ever in the user disk space! :( Fine, so delete it after a period of inactivity ok..I have script which will run based on some values in user's homedir. In fact I have tried to run the script from a various locations; but it didn't work as expected like it run from each users homedir. So, when the user access the page, it will copy the actual script to the user's homedir and executes it. I don't want to leave it there for ever; so I have to remove it from there when the user close the browser ( or after a period of in activity ). But I don't know how to code it :( My suggestion is to sort out the real issue, rather than try to fix it with the workaround of copying that file to each user's homedir. It sounds like you are just adding unnecessary complexity to your work. Maybe make a new post/thread where you describe THAT issue very carefully.. and what you have tried that is not working the way you thought it should. So far it is not clear enough to me anyway - to help. But that could be because of my shortcomings more than your post's shortcoming; I am not expert on many topics covered on this list, especially in the area of managing your webserver. -Govinda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution after window close
On Sun, 2012-03-04 at 11:29 -0500, Govinda wrote: in factI really need to remove the file ( which will be created for every access - making a copy from another location ). I can't leave that file alone for ever in the user disk space! :( Fine, so delete it after a period of inactivity ok..I have script which will run based on some values in user's homedir. In fact I have tried to run the script from a various locations; but it didn't work as expected like it run from each users homedir. So, when the user access the page, it will copy the actual script to the user's homedir and executes it. I don't want to leave it there for ever; so I have to remove it from there when the user close the browser ( or after a period of in activity ). But I don't know how to code it :( My suggestion is to sort out the real issue, rather than try to fix it with the workaround of copying that file to each user's homedir. It sounds like you are just adding unnecessary complexity to your work. Maybe make a new post/thread where you describe THAT issue very carefully.. and what you have tried that is not working the way you thought it should. So far it is not clear enough to me anyway - to help. But that could be because of my shortcomings more than your post's shortcoming; I am not expert on many topics covered on this list, especially in the area of managing your webserver. -Govinda To add to what Govinda said, the real problem does indeed seem to be that you're using this hack in order to make your code work, and sorting that would be far more beneficial to you in the long run. On first thoughts, it sounds like a path issue somewhere. If the script isn't run as the user but is just run as the same user from different users directories, then it's probably not a problem with the PATH environment variable (assuming your secondary script is some kind of Bash script). Let's see what you're doing with that and see if we can help. -- Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Script execution after window close
ok..thanks guys...I will check further then. thanks for your inputs :) On Sun, Mar 4, 2012 at 9:59 PM, Govinda govinda.webdnat...@gmail.comwrote: in factI really need to remove the file ( which will be created for every access - making a copy from another location ). I can't leave that file alone for ever in the user disk space! :( Fine, so delete it after a period of inactivity ok..I have script which will run based on some values in user's homedir. In fact I have tried to run the script from a various locations; but it didn't work as expected like it run from each users homedir. So, when the user access the page, it will copy the actual script to the user's homedir and executes it. I don't want to leave it there for ever; so I have to remove it from there when the user close the browser ( or after a period of in activity ). But I don't know how to code it :( My suggestion is to sort out the real issue, rather than try to fix it with the workaround of copying that file to each user's homedir. It sounds like you are just adding unnecessary complexity to your work. Maybe make a new post/thread where you describe THAT issue very carefully.. and what you have tried that is not working the way you thought it should. So far it is not clear enough to me anyway - to help. But that could be because of my shortcomings more than your post's shortcoming; I am not expert on many topics covered on this list, especially in the area of managing your webserver. -Govinda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Regards Nibin. http://TechsWare.in
Re: [PHP] Script execution
On Tue, Mar 10, 2009 at 01:23, Paul M Foster pa...@quillandmouse.com wrote: (Dan, make the check out to... ;-) Paul I prefer PayPal. Thanks to the Postal Service, the cost of a stamp is probably more than a bribery or endorsement payment. :-\ -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Script execution
Hi everybody. The problem that I'm having is probably because I've got more of a Windows background -- and it isn't so much a problem as a point of curiosity. I've recently noticed that when I write a script that they seem to have different permissions when executed at the command line. Two that I have written recently run just fine when you execute 'php scriptname.php' but they are unable, at least, to write the data if I browse to them on localhost. Am I imagining things? If not, how would I properly make them able to run through a browser? Thanks! G
Re: [PHP] Script execution
On Mon, 2009-03-09 at 16:59 -0400, George Larson wrote: Hi everybody. The problem that I'm having is probably because I've got more of a Windows background -- and it isn't so much a problem as a point of curiosity. I've recently noticed that when I write a script that they seem to have different permissions when executed at the command line. Two that I have written recently run just fine when you execute 'php scriptname.php' but they are unable, at least, to write the data if I browse to them on localhost. Am I imagining things? If not, how would I properly make them able to run through a browser? Thanks! G This is to do with the fact that the web browser runs as a different user from you (usually apache, apache2 or wwwrun) What you could do is make the directory where you want to write files with the script part of a new group. Add the apache user to this group and you should then be able to get it to run. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution
On Mon, Mar 9, 2009 at 16:59, George Larson george.g.lar...@gmail.com wrote: Am I imagining things? If not, how would I properly make them able to run through a browser? You're not imagining things. In general, unless set up with SuExec privileges, Apache (which is probably the HTTP server you're using) will run as 'nobody,' 'apache,' 'www,' or 'daemon.' If you can't configure it to SuExec (check Google for some ideas on this you'll need root access), you could use the less-secure (this, not recommended) options of changing the file mode permissions to 0777 or change the file ownership (if you have the right permissions yourself) to be owned by the same user and/or group as which Apache runs. It may sound a little confusing at first glance, but it's really not. Just keep in mind that UNIX and Linux (Mac and similar OS'es fall in here, too) are simultaneous multi-user systems, meaning that many users (including virtual users that the system uses as aliases for individualized permissions) can be logged in and run processes concurrently. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution
On Mon, Mar 9, 2009 at 4:04 PM, Daniel Brown danbr...@php.net wrote: On Mon, Mar 9, 2009 at 16:59, George Larson george.g.lar...@gmail.com wrote: Am I imagining things? If not, how would I properly make them able to run through a browser? You're not imagining things. In general, unless set up with SuExec privileges, Apache (which is probably the HTTP server you're using) will run as 'nobody,' 'apache,' 'www,' or 'daemon.' If you can't configure it to SuExec (check Google for some ideas on this you'll need root access), you could use the less-secure (this, not recommended) options of changing the file mode permissions to 0777 or change the file ownership (if you have the right permissions yourself) to be owned by the same user and/or group as which Apache runs. It may sound a little confusing at first glance, but it's really not. Just keep in mind that UNIX and Linux (Mac and similar OS'es fall in here, too) are simultaneous multi-user systems, meaning that many users (including virtual users that the system uses as aliases for individualized permissions) can be logged in and run processes concurrently. OP is a Windows user. I am assuming that they are using Windows. George, if you are using IIS as your web server, PHP will be executed (by default, anyway) under the IUSR_your computer name user account (pre-Vista). The directories and files your PHP script will need to mess with should be given the appropriate permissions as related to that user. HTH, -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution
On Mon, Mar 9, 2009 at 17:17, haliphax halip...@gmail.com wrote: OP is a Windows user. I am assuming that they are using Windows. Re-read the context of that first paragraph from the OP and you'll see why I presume (as opposed to *ass*ume) that, despite his experience with Windows, this is a *NIX-like setup. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution
Thanks everybody! I guess I was a little vague. I'm working on an OpenSUSE setup with Apache, MySQL and PHP. I just knew that my confusion was because of my Windows up-bringing. The writing I referred to was to a file. One example is I had a script that was pulling data from a database and using it to generate PDF files. This would work fine from the command line but _not_ if I pointed a browser at it. It wasn't an important difference because that script is a cronjob anyway. I just wanted to understand what was going on and how I could change it -- if I find later that I need to. Again, that's for the rapid and thorough help! G On Mon, Mar 9, 2009 at 5:17 PM, haliphax halip...@gmail.com wrote: On Mon, Mar 9, 2009 at 4:04 PM, Daniel Brown danbr...@php.net wrote: On Mon, Mar 9, 2009 at 16:59, George Larson george.g.lar...@gmail.com wrote: Am I imagining things? If not, how would I properly make them able to run through a browser? You're not imagining things. In general, unless set up with SuExec privileges, Apache (which is probably the HTTP server you're using) will run as 'nobody,' 'apache,' 'www,' or 'daemon.' If you can't configure it to SuExec (check Google for some ideas on this you'll need root access), you could use the less-secure (this, not recommended) options of changing the file mode permissions to 0777 or change the file ownership (if you have the right permissions yourself) to be owned by the same user and/or group as which Apache runs. It may sound a little confusing at first glance, but it's really not. Just keep in mind that UNIX and Linux (Mac and similar OS'es fall in here, too) are simultaneous multi-user systems, meaning that many users (including virtual users that the system uses as aliases for individualized permissions) can be logged in and run processes concurrently. OP is a Windows user. I am assuming that they are using Windows. George, if you are using IIS as your web server, PHP will be executed (by default, anyway) under the IUSR_your computer name user account (pre-Vista). The directories and files your PHP script will need to mess with should be given the appropriate permissions as related to that user. HTH, -- // Todd
Re: [PHP] Script execution
On Mon, Mar 9, 2009 at 17:21, Daniel Brown paras...@gmail.com wrote: Re-read the context of that first paragraph from the OP and you'll see why I presume (as opposed to *ass*ume) that, despite his experience with Windows, this is a *NIX-like setup. DISCLAIMER: This was supposed to be added to my seemingly-gruff response: ;-P Todd's alright by me. George, a cron - if run as the same user that owns the files - should work with no problem. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution
On Mon, Mar 9, 2009 at 4:28 PM, Daniel Brown paras...@gmail.com wrote: On Mon, Mar 9, 2009 at 17:21, Daniel Brown paras...@gmail.com wrote: Re-read the context of that first paragraph from the OP and you'll see why I presume (as opposed to *ass*ume) that, despite his experience with Windows, this is a *NIX-like setup. DISCLAIMER: This was supposed to be added to my seemingly-gruff response: ;-P Todd's alright by me. George, a cron - if run as the same user that owns the files - should work with no problem. No worries, Daniel... though I appreciate the gesture. :) What I meant in my message was that I couldn't tell if he was talking POSIX or Win, but I would offer my Windows information on the off-chance that he was referring to Windows... so I suppose I'm guilty of being obscure. Too many meetings today. Brain is turning to pudding. -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution
That's funny! I've been watching this and a few other lists (MySQL, local Linux Users' Group) for a few days - weeks and I had wondered why the PHP list seemed more hostile. :) On Mon, Mar 9, 2009 at 5:28 PM, Daniel Brown paras...@gmail.com wrote: On Mon, Mar 9, 2009 at 17:21, Daniel Brown paras...@gmail.com wrote: Re-read the context of that first paragraph from the OP and you'll see why I presume (as opposed to *ass*ume) that, despite his experience with Windows, this is a *NIX-like setup. DISCLAIMER: This was supposed to be added to my seemingly-gruff response: ;-P Todd's alright by me. George, a cron - if run as the same user that owns the files - should work with no problem. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1
Re: [PHP] Script execution
George Larson wrote: Thanks everybody! I guess I was a little vague. I'm working on an OpenSUSE setup with Apache, MySQL and PHP. I just knew that my confusion was because of my Windows up-bringing. The writing I referred to was to a file. One example is I had a script that was pulling data from a database and using it to generate PDF files. This would work fine from the command line but _not_ if I pointed a browser at it. It wasn't an important difference because that script is a cronjob anyway. I just wanted to understand what was going on and how I could change it -- if I find later that I need to. Give the user apache runs as permission to write to the directory where the PDF files are generated. I don't know what use apache run as on SuSE but if it was, say, www - as root: chown www /path/to/directory/where/you/want/the/output -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution
On Mon, Mar 9, 2009 at 4:36 PM, George Larson george.g.lar...@gmail.com wrote: That's funny! I've been watching this and a few other lists (MySQL, local Linux Users' Group) for a few days - weeks and I had wondered why the PHP list seemed more hostile. :) In a word, I think familiarity sums it up. That, or ***holes. :-D -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution
On Mon, Mar 9, 2009 at 17:39, haliphax halip...@gmail.com wrote: That, or ***holes. That's what my name tag says. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution
Daniel Brown wrote: On Mon, Mar 9, 2009 at 17:39, haliphax halip...@gmail.com wrote: That, or ***holes. That's what my name tag says. you got shot in the nametag 3 times? i dunno if that's good or bad luck! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution
On Mon, Mar 9, 2009 at 4:55 PM, Nathan Rixham nrix...@gmail.com wrote: Daniel Brown wrote: On Mon, Mar 9, 2009 at 17:39, haliphax halip...@gmail.com wrote: That, or ***holes. That's what my name tag says. you got shot in the nametag 3 times? i dunno if that's good or bad luck! Yep. Now nobody can tell it used to say ear holes anymore! :( -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution
George Larson wrote: That's funny! I've been watching this and a few other lists (MySQL, local Linux Users' Group) for a few days - weeks and I had wondered why the PHP list seemed more hostile. :) may be something to do with the fact 95% of posts here could be covered by: - a 5 question faq - rtfm the only way to stay sane round here would be to develop alzheimer's [zero offence intended in any way] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution
haliphax wrote: On Mon, Mar 9, 2009 at 4:55 PM, Nathan Rixham nrix...@gmail.com wrote: Daniel Brown wrote: On Mon, Mar 9, 2009 at 17:39, haliphax halip...@gmail.com wrote: That, or ***holes. That's what my name tag says. you got shot in the nametag 3 times? i dunno if that's good or bad luck! Yep. Now nobody can tell it used to say ear holes anymore! :( warhole ^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script execution
On Monday 09 March 2009 15:38:37 Michael A. Peters wrote: George Larson wrote: Thanks everybody! I guess I was a little vague. I'm working on an OpenSUSE setup with Apache, MySQL and PHP. I just knew that my confusion was because of my Windows up-bringing. The writing I referred to was to a file. One example is I had a script that was pulling data from a database and using it to generate PDF files. This would work fine from the command line but not if I pointed a browser at it. It wasn't an important difference because that script is a cronjob anyway. I just wanted to understand what was going on and how I could change it -- if I find later that I need to. Give the user apache runs as permission to write to the directory where the PDF files are generated. I don't know what use apache run as on SuSE but if it was, say, www - as root: chown www /path/to/directory/where/you/want/the/output I only scanned the thread, So apologies if someone else already said this. Another problem I've come across is that the path variable is not the same when run under the browser as on the command line, so instead of issuing command you need /path/to/command Ray -- 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] Script execution
On Mon, Mar 09, 2009 at 05:36:05PM -0400, George Larson wrote: That's funny! I've been watching this and a few other lists (MySQL, local Linux Users' Group) for a few days - weeks and I had wondered why the PHP list seemed more hostile. :) Wow! This list is pretty cordial. I've been on some LUG lists where drawing and quartering is the norm! SVLUG comes to mind, though I haven't been on their list in a few years. Actually, despite disagreements, there seems to be a mutual respect amongst the list members here, and a congenial sense of humor. Extra kudos to Dan for setting the tone of the list. His replies are generally very helpful, his expression precise, and he's usually not wrong. (Dan, make the check out to... ;-) Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Script Execution Time
This is what I use.. simple.. (someone from this list contributed it) function stopwatch_init() { list($usec, $sec) = explode( , microtime()); return ( (float)$usec + (float)$sec ); } Cheers, Mun Heng, Ow H/M Engineering Western Digital M'sia DID : 03-7870 5168 -Original Message- From: Jeff Harris [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 29, 2003 9:17 AM To: Petya A Shushpanov Cc: Radek Zajkowski; PHP GENERAL Subject: Re: [PHP] Script Execution Time On Jul 29, 2003, Petya A Shushpanov claimed that: |? |class jTimer { |[snip] | |$timer-stop(); |echo round($timer-elapsed(),5); |? | |-- |Petya A Shushpanov | Or, you could use http://pear.php.net/package-info.php?package=Benchmark -- Registered Linux user #304026. lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED Responses to this message should conform to RFC 1855. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Script Execution Time
Could someone pass on a snippet, a function or a technique for measuring script times. It appears the host I am with is having some PHP engine performance problems and I need to send them the figures. Thanks in advance R -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script Execution Time
Radek Zajkowski wrote: Could someone pass on a snippet, a function or a technique for measuring script times. It appears the host I am with is having some PHP engine performance problems and I need to send them the figures. Check out the user contributed notes on php.net for microtime(). http://us4.php.net/microtime - Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script Execution Time
* Thus wrote Radek Zajkowski ([EMAIL PROTECTED]): Could someone pass on a snippet, a function or a technique for measuring script times. It appears the host I am with is having some PHP engine performance problems and I need to send them the figures. So I'm suppose to take my timeout and search what was posted on this list (probably a dozen times within the last two months) then compose a message to the list and repeating what others have posted. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script Execution Time
Hi Radek, This has been posted before...around once every 2 weeks I guess :-)...check the archive or you will/may get flamed. Cheers, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script Execution Time
? class jTimer { var $start = 0; var $stop = 0; var $elapsed = 0; function start() { $this-start = microtime(); } function stop() { $this-stop= microtime(); } function elapsed() { if ($this-elapsed) { return $this-elapsed; } else { $start_u = substr($this-start,0,10); $start_s = substr($this-start,11,10); $stop_u = substr($this-stop,0,10); $stop_s = substr($this-stop,11,10); $start_total = doubleval($start_u) + $start_s; $stop_total = doubleval($stop_u) + $stop_s; $this-elapsed = $stop_total - $start_total; return $this-elapsed; } } } $timer = new jTimer; $timer-start(); #your code here $timer-stop(); echo round($timer-elapsed(),5); ? -- Petya A Shushpanov tel.: (+7 916) 556 16 27 mail: [EMAIL PROTECTED] site: www.eastof.ru - Original Message - From: Radek Zajkowski [EMAIL PROTECTED] To: PHP GENERAL [EMAIL PROTECTED] Sent: Tuesday, July 29, 2003 1:09 AM Subject: [PHP] Script Execution Time Could someone pass on a snippet, a function or a technique for measuring script times. It appears the host I am with is having some PHP engine performance problems and I need to send them the figures. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Script Execution Time
Petya A Shushpanov mailto:[EMAIL PROTECTED] on Monday, July 28, 2003 3:41 PM said: ? class jTimer { [snip] } $timer = new jTimer; $timer-start(); #your code here $timer-stop(); echo round($timer-elapsed(),5); You could one up this class by creating another method that automatically performs the last line. i.e. $timer-stop(); $timer-report(); Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script Execution Time
Tnx. I`ve it fixed jet. - Original Message - From: Chris W. Parker [EMAIL PROTECTED] To: Petya A Shushpanov [EMAIL PROTECTED]; Radek Zajkowski [EMAIL PROTECTED]; PHP GENERAL [EMAIL PROTECTED] Sent: Tuesday, July 29, 2003 3:50 AM Subject: RE: [PHP] Script Execution Time Petya A Shushpanov mailto:[EMAIL PROTECTED] on Monday, July 28, 2003 3:41 PM said: ? class jTimer { [snip] } $timer = new jTimer; $timer-start(); #your code here $timer-stop(); echo round($timer-elapsed(),5); You could one up this class by creating another method that automatically performs the last line. i.e. $timer-stop(); $timer-report(); Chris. -- 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] Script Execution Time
On Jul 29, 2003, Petya A Shushpanov claimed that: |? |class jTimer { |[snip] | |$timer-stop(); |echo round($timer-elapsed(),5); |? | |-- |Petya A Shushpanov | Or, you could use http://pear.php.net/package-info.php?package=Benchmark -- Registered Linux user #304026. lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED Responses to this message should conform to RFC 1855. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php script execution by linux automated task
Hello, I have some web application which is on some rented server. I have not root privilege just FTP access to application web folder. OS is Linux, web server Apache/1.3.27 and PHP version is 4.3.1 I need to define Linux task which will, in defined time, execute some PHP script (`somepage.php`). This script is under web folder. Does anybody can give me useful hint? Best regards, Nenad Djordjevic mailto:[EMAIL PROTECTED] Diyomi Soft http://www.diyomisoft.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php script execution by linux automated task
look up cron Nenad Djordjevic [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, I have some web application which is on some rented server. I have not root privilege just FTP access to application web folder. OS is Linux, web server Apache/1.3.27 and PHP version is 4.3.1 I need to define Linux task which will, in defined time, execute some PHP script (`somepage.php`). This script is under web folder. Does anybody can give me useful hint? Best regards, Nenad Djordjevic mailto:[EMAIL PROTECTED] Diyomi Soft http://www.diyomisoft.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script Execution via URL
This would work if the script you wished to call was default.php / index.php / etc etc... what I mean to say is site.com/index.php?var=foo is the same as site.com/?var=foo, as long as your server works that way. leaving out PHP_SELF will give different results if the script you wish to call ISN'T the default for that directory. PHP forms are just HTML forms. That is to say that once the code gets to the browser, it's just HTML code. So once the code is at the browser, it works just like any other page, where a user (or a javascript program) has to submit the form. justin on 01/09/02 12:08 AM, Sascha Braun ([EMAIL PROTECTED]) wrote: Hi everybody, i wrote a script which will be executed by HREF's. If a command is going to be executed by a click on a link the page reloads itself and jumps in the part of the script, which should be executed. Normaly I wrote some like this for doing this: echo 'a href='.$PHP_SELF.'?action=deleteid='.$arrResult['id'].' class=text01'; but now in a very special case i forgot to write $PHP_SELF like this a href=?action=deleteid='.$arrResult['id'].' class=text01 without knowing that I have forgotten to write this $PHP_SELF thing I clicked on the Link and i did execute the Script, like i wanted it to. Is it normal that it works so fine? Can I use this everytime I link on the same page for script execusion? Can I send Forms via an PHP Function like the submit() statement in Javascript? Have a nice day, and please answer. Sascha Braun -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Script Execution via URL
Hi everybody, i wrote a script which will be executed by HREF's. If a command is going to be executed by a click on a link the page reloads itself and jumps in the part of the script, which should be executed. Normaly I wrote some like this for doing this: echo 'a href='.$PHP_SELF.'?action=deleteid='.$arrResult['id'].' class=text01'; but now in a very special case i forgot to write $PHP_SELF like this a href=?action=deleteid='.$arrResult['id'].' class=text01 without knowing that I have forgotten to write this $PHP_SELF thing I clicked on the Link and i did execute the Script, like i wanted it to. Is it normal that it works so fine? Can I use this everytime I link on the same page for script execusion? Can I send Forms via an PHP Function like the submit() statement in Javascript? Have a nice day, and please answer. Sascha Braun
[PHP] script execution stops after mail()
Hi, I've been skipping a night over this strange error: after execution of a mail() command, de rest of the script just gets ignored and my browser displays a Cannot find server or DNS Error page instead. Ideas about how to make this baby work would be very welcome; thanks in advance. I'm using PHP 4.0.6 on Apache/1.3.20 and sendmail -t -i. Just in case that helps. Vincent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] script execution stops after mail()
Hi, Well the PHP script is timing out after it executes a no. of (or all the mail() commands). So what you got todo is either set the PHP's timeout limit to 0 or infinite. set_time_limit(0); Or you could invoke another program in the background disconnect PHP (terminal) from it, and voila. But if you want the mail command to be executed before anything else you will have to set the execution limit to infinite, or increase it to a very big limit, and also use ignore_user_abort(1); --- Vincent [EMAIL PROTECTED] wrote: Hi, I've been skipping a night over this strange error: after execution of a mail() command, de rest of the script just gets ignored and my browser displays a Cannot find server or DNS Error page instead. Ideas about how to make this baby work would be very welcome; thanks in advance. I'm using PHP 4.0.6 on Apache/1.3.20 and sendmail -t -i. Just in case that helps. Vincent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] = * http://www.geocities.com/mimodit * __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] script execution stops after mail()
Hey, It can be issues that PHP doesn't have control over for example if your systems' sendmail is being used by 100's of users, maybe it's taking for your request to be processed. So it could be more than just PHP, but you should basically when sending mail just but the mail in background. --- Vincent [EMAIL PROTECTED] wrote: Thanks, but for now the mail()-function is only used once. I already found the timeout-issue in the manual and will use your tip when I expand it to serve a mailing list. Have you ever heard of this problem before, so it could be a bug? Or is there something special with the quotes to do? I remember an earlier website I built that had problems too, but they were solved when I replaced single quotes by doubles. Back then, the error-page didn't appear also. Vincent -Original Message- From: Mukul Sabharwal [mailto:[EMAIL PROTECTED]] Sent: donderdag 16 augustus 2001 13:57 To: Vincent; [EMAIL PROTECTED] Subject: Re: [PHP] script execution stops after mail() Hi, Well the PHP script is timing out after it executes a no. of (or all the mail() commands). So what you got todo is either set the PHP's timeout limit to 0 or infinite. set_time_limit(0); Or you could invoke another program in the background disconnect PHP (terminal) from it, and voila. But if you want the mail command to be executed before anything else you will have to set the execution limit to infinite, or increase it to a very big limit, and also use ignore_user_abort(1); --- Vincent [EMAIL PROTECTED] wrote: Hi, I've been skipping a night over this strange error: after execution of a mail() command, de rest of the script just gets ignored and my browser displays a Cannot find server or DNS Error page instead. Ideas about how to make this baby work would be very welcome; thanks in advance. I'm using PHP 4.0.6 on Apache/1.3.20 and sendmail -t -i. Just in case that helps. Vincent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] = * http://www.geocities.com/mimodit * __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ = * http://www.geocities.com/mimodit * __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Script Execution Time
I have a php script that returns about 1.5Mb of data in text format to the user. I am wondering if there is a way for php to display the time it took to execute the script at the end of the file. Put this at the top of the script: code function getmicrotime(){ list($usec, $sec) = explode( ,microtime()); return ((float)$usec + (float)$sec); } $time_start = getmicrotime(); /code ..and this at the end: code $time_end = getmicrotime(); $time = $time_end - $time_start; $foo = round ($time, 2); echo Execution took $foo seconds.; /code Hope this helps. Best regards, Jome -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Script execution Speed
depends on the underlying FS - you might find yourself bitten by disk hits that could've been avoided... How about writing a small test suite and benching the server? At 00:29 13.1. 2001, Randy Johnson wrote the following: -- Is it faster and more efficient to have smaller scripts that only do one specific thing when it is executed or can I have a script perform to different tasks based on a variable sent to it? It will be a high user website so I am thinking that the smaller the script the better? Am I right? Randy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] --end of quote-- Cynic: A member of a group of ancient Greek philosophers who taught that virtue constitutes happiness and that self control is the essential part of virtue. [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]