[PHP] parsin XML with DOM
hello, could somebody give me some direction here. i am trying to build a RSS 2.0 parser using DOM. what puzzles me is the following - i get the XML - $RSS_XML = file_get_contents($params['uri']); then i instantiate a DOM object - $RSS_DOM = new DomDocument(); then i load the XML - $RSS_DOM-loadXML($RSS_XML); then i get the first node - $NODE = $RSS_DOM-firstChild; here $NODE-tagName is rss, so far OK but then if i get the first child of rss, which is channel - $NODE = $NODE-firstChild; its type is not DomNode, but DomText. Only the 2nd child - $NODE = $NODE-nextSibling; has $NODE-tagName channel. My question is - why is the first child after rss DomText? Thank you, Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Handling animated GIFs with GD?
Hello all again, Is it possible to parse animated GIFs with GD, just frame by frame? Tijnema -- Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] generate letter combination..
i made a mistake when i say i can solve this problem to a friend. finally i realize it is not as simple as i appear to be. what he ask me to do is write a simple script that, given a word.. the script will generate a list of words combinaton from the each character in in that word. i am tired thinking. to make it clear. i give a simple scenario. i don't have an idea what i should name my baby. so, i took my wife name and me and input to the script.(i want a name that is from our name combination). later the output will present many words that i can choose. the input string can be of any length. anyone have an idea?
[PHP] PHP5 TUTORIAL
BlankHi, Need to have a kick start on PHP5. Kindly suggest me the good online tutorial for PHP5. Am already working on php4. Need to migrate from php4 to php5. Regards, Preethi. Extn No: 4099 Some of the greatest science comes from those unaware of established rules and theories.
Re: [PHP] PHP5 TUTORIAL
Hi Preethi Kindly suggest me the good online tutorial for PHP5. Am already working on php4. Need to migrate from php4 to php5. i think this is very important for OOP: http://www.php.net/manual/en/language.oop5.php and this one: http://www.php.net/manual/en/language.exceptions.php regards, Hagen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database administration framework
I just need a framework for administrating tables in a database. These are simple add/edit/remove operations from tables. Can you suggest a framework for this kind of job? Cause there are a lot of tables and I hope I can find a nice tool to work with. What database are you working with? phpMyAdmin is probably the most ubiquitous when working with MySQL databases. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Disadvantages of output buffering
Hi! My php project would get a much cleaner code if I could set cookies anywhere in the code. So I thought of output buffering. But I can't find any articles on the cons of output buffering. I mean it most be a reason for it being off by default? Kind Regards Emil Edeholt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Database administration framework
Hi, I just need a framework for administrating tables in a database. These are simple add/edit/remove operations from tables. Can you suggest a framework for this kind of job? Cause there are a lot of tables and I hope I can find a nice tool to work with. Look at Qcodo (http://www.qcodo.com). Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Database administration framework
The DB ist mysql. No, you didn't understand me clearly. I need a framework, toolkit, class call it how you want, with wich I develop an application that administrates the data's in the database. Something like Smarty but more specific for what I need. The ideea is the following: I have 20 tables that have data's in them. And these table data's must be edited with this admin tool. There are very few joins but there are references between the tables. Regards, Andy. -Original Message- From: Chris Boget [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 26, 2007 3:29 PM To: Andy; php-general@lists.php.net Subject: Re: [PHP] Database administration framework I just need a framework for administrating tables in a database. These are simple add/edit/remove operations from tables. Can you suggest a framework for this kind of job? Cause there are a lot of tables and I hope I can find a nice tool to work with. What database are you working with? phpMyAdmin is probably the most ubiquitous when working with MySQL databases. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database administration framework
The DB ist mysql. No, you didn't understand me clearly. I need a framework, toolkit, class call it how you want, with wich I develop an application that administrates the data's in the database. Something like Smarty but more specific for what I need. The ideea is the following: I have 20 tables that have data's in them. And these table data's must be edited with this admin tool. There are very few joins but there are references between the tables. You could try MySQL TableEditor: http://www.phpguru.org/static/TableEditor.html It's a (big) one file class which is good for editing the tables, though it's not phpMyAdmin; you can't administer the database. -- Richard Heyes 0844 801 1072 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Database administration framework
Hi, I just need a framework for administrating tables in a database. These are simple add/edit/remove operations from tables. Can you suggest a framework for this kind of job? Cause there are a lot of tables and I hope I can find a nice tool to work with. Thank you.
Re: [PHP] Disadvantages of output buffering
On Tue, 2007-06-26 at 14:33 +0200, Emil Edeholt wrote: Hi! My php project would get a much cleaner code if I could set cookies anywhere in the code. So I thought of output buffering. But I can't find any articles on the cons of output buffering. I mean it most be a reason for it being off by default? Cons of output buffering: - tncy weency time overhead - memory overhead since buffered content remains in memory until flushed. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Disadvantages of output buffering
Thanks for your help Dave and Rob. I will start using output buffering a lot more now. Regards Emil Robert Cummings wrote: Cons of output buffering: - tncy weency time overhead - memory overhead since buffered content remains in memory until flushed. Cheers, Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Disadvantages of output buffering
Robert Cummings wrote: On Tue, 2007-06-26 at 14:33 +0200, Emil Edeholt wrote: Hi! My php project would get a much cleaner code if I could set cookies anywhere in the code. So I thought of output buffering. But I can't find any articles on the cons of output buffering. I mean it most be a reason for it being off by default? Cons of output buffering: - tncy weency time overhead Compared to the time taken to flush to the client more often? This is incorrect in most cases, and even when it's not it really really is tncy weency. - memory overhead since buffered content remains in memory until flushed. Indeed, but memory is cheap and you're likely to run out of memory for other reasons way before output buffering causes it. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Disadvantages of output buffering
On Tue, 2007-06-26 at 14:09 +0100, Stut wrote: Robert Cummings wrote: On Tue, 2007-06-26 at 14:33 +0200, Emil Edeholt wrote: Hi! My php project would get a much cleaner code if I could set cookies anywhere in the code. So I thought of output buffering. But I can't find any articles on the cons of output buffering. I mean it most be a reason for it being off by default? Cons of output buffering: - tncy weency time overhead Compared to the time taken to flush to the client more often? This is incorrect in most cases, and even when it's not it really really is tncy weency. - memory overhead since buffered content remains in memory until flushed. Indeed, but memory is cheap and you're likely to run out of memory for other reasons way before output buffering causes it. Agreed, I was hard pressed to come up with cons in the first place :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 TUTORIAL
if you want to spend a little i would recommend this book from php|arch http://www.phparch.com/shop_product.php?itemid=135 -nathan On 6/26/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi Preethi Kindly suggest me the good online tutorial for PHP5. Am already working on php4. Need to migrate from php4 to php5. i think this is very important for OOP: http://www.php.net/manual/en/language.oop5.php and this one: http://www.php.net/manual/en/language.exceptions.php regards, Hagen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Disadvantages of output buffering
On 26/06/07, Robert Cummings [EMAIL PROTECTED] wrote: On Tue, 2007-06-26 at 14:09 +0100, Stut wrote: Robert Cummings wrote: On Tue, 2007-06-26 at 14:33 +0200, Emil Edeholt wrote: Hi! My php project would get a much cleaner code if I could set cookies anywhere in the code. So I thought of output buffering. But I can't find any articles on the cons of output buffering. I mean it most be a reason for it being off by default? Cons of output buffering: - tncy weency time overhead Compared to the time taken to flush to the client more often? This is incorrect in most cases, and even when it's not it really really is tncy weency. - memory overhead since buffered content remains in memory until flushed. Indeed, but memory is cheap and you're likely to run out of memory for other reasons way before output buffering causes it. Agreed, I was hard pressed to come up with cons in the first place :) Modern browsers often start partially rendering HTML as soon as it arrives rather than waiting for the page to load completely. Obviously, if you're waiting until the end of the script before actually sending any HTML, they can't do that so your page might appear less responsive. -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Disadvantages of output buffering
These two reasons are in fact of little impact. The real problem I have with output buffering in my web app is that it doesn't handle .xls and .pdf files generated on the fly with PHP. Every time the browser is going to download those kind of files it will get corrupted. The only solution I could find for this was to disable output buffering. Another thing: you can even compress the buffer before sending it so it will help a lot if a user have little bandwidth. Text files have a very good compression ratio. Cheers, -William On Tue, 2007-06-26 at 09:04 -0400, Robert Cummings wrote: On Tue, 2007-06-26 at 14:33 +0200, Emil Edeholt wrote: Hi! My php project would get a much cleaner code if I could set cookies anywhere in the code. So I thought of output buffering. But I can't find any articles on the cons of output buffering. I mean it most be a reason for it being off by default? Cons of output buffering: - tncy weency time overhead - memory overhead since buffered content remains in memory until flushed. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DOM support
Hey! I have been looking through the docs writing test code and am going a little bit mad trying to work this out. Does anyone know where I can find a definitive list of DOM XML functions that are supported in specific versions of PHP? I write my code in Zend and it has 5.2.0, so everything works as per the manual but when I try to run on our production environment (5.0.4) then things go very, very wrong. In particular there doesn't seem to be a DOMXPath object. Failing a list of methods/versions - does anyone know what I can use in lieu of a DOMXPath object? TIA, Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: parsin XML with DOM
[EMAIL PROTECTED] wrote: [snip] its type is not DomNode, but DomText. Only the 2nd child - $NODE = $NODE-nextSibling; has $NODE-tagName channel. My question is - why is the first child after rss DomText? Thank you, Iv My guess is the whitespace between the nodes :o) HTH, Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: parsin XML with DOM
Mikey wrote: [EMAIL PROTECTED] wrote: [snip] its type is not DomNode, but DomText. Only the 2nd child - $NODE = $NODE-nextSibling; has $NODE-tagName channel. My question is - why is the first child after rss DomText? Thank you, Iv My guess is the whitespace between the nodes :o) HTH, Mikey You are correct on that guess. In xml everything is (part of) a node. So if you have: node node2 / /node You'll actually have: DomNode(node) DomText( ) DomNode(node2) DomText( ) Same goes for newlines, as they are seen as text, thus part of a DomText node. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create .php file with php
I can not believe how stupid I can be sometime. I was trying to create a file, but a file with the same name already existed on the server - and I did not have the write permission to it, so from here I got the error message saying that I can not create the file :( Thank for your time, Marius -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create .php file with php
On 6/26/07, Marius Toma [EMAIL PROTECTED] wrote: I can not believe how stupid I can be sometime. I was trying to create a file, but a file with the same name already existed on the server - and I did not have the write permission to it, so from here I got the error message saying that I can not create the file :( Thank for your time, Marius Don't worry, you're not the only one who posts to this list, and just a little time later finds out that it was a little stupid thing... Tijnema -- Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create .php file with php
On 6/26/07, Marius Toma [EMAIL PROTECTED] wrote: I can not believe how stupid I can be sometime. I was trying to create a file, but a file with the same name already existed on the server - and I did not have the write permission to it, so from here I got the error message saying that I can not create the file :( Thank for your time, Marius -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If you absolutely *must* create PHP files on-the-fly, and only need them for a one-off thing, put them in a specific directory that only the web server has access to read, write, and execute, and then delete the files immediately after you've used them as needed. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create .php file with php
On 6/26/07, Daniel Brown [EMAIL PROTECTED] wrote: On 6/26/07, Marius Toma [EMAIL PROTECTED] wrote: I can not believe how stupid I can be sometime. I was trying to create a file, but a file with the same name already existed on the server - and I did not have the write permission to it, so from here I got the error message saying that I can not create the file :( Thank for your time, Marius -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If you absolutely *must* create PHP files on-the-fly, and only need them for a one-off thing, put them in a specific directory that only the web server has access to read, write, and execute, and then delete the files immediately after you've used them as needed. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 If you absolutely *must* create PHP files on-the-fly, and only need them for a one-off thing, put them in a specific directory that only the web server has access to read, write, and execute, and then delete the files immediately after you've used them as needed. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create .php file with php
On 6/26/07, Marius Toma [EMAIL PROTECTED] wrote: I can not believe how stupid I can be sometime. I was trying to create a file, but a file with the same name already existed on the server - and I did not have the write permission to it, so from here I got the error message saying that I can not create the file :( Thank for your time, Marius -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If you absolutely *must* create PHP files on-the-fly, and only need them for a one-off thing, put them in a specific directory that only the web server has access to read, write, and execute, and then delete the files immediately after you've used them as needed. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: DOM support
Mikey wrote: Hey! I have been looking through the docs writing test code and am going a little bit mad trying to work this out. Does anyone know where I can find a definitive list of DOM XML functions that are supported in specific versions of PHP? I write my code in Zend and it has 5.2.0, so everything works as per the manual but when I try to run on our production environment (5.0.4) then things go very, very wrong. In particular there doesn't seem to be a DOMXPath object. Failing a list of methods/versions - does anyone know what I can use in lieu of a DOMXPath object? TIA, Mikey Talking of stupid mistakes that get found moments later... I had $xp = DOMPath ($dom); Funny how it doesn't work without the new keyword, eh? lol Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create .php file with php
You might also consider looking at variable variables and dynamic PHP (writing and evaluating php expressions on the fly). http://us.php.net/variables.variable http://us.php.net/eval Writing the PHP to a file could be a potential security vulnerability. Especially if this was going to go into usage within a high usage web app. =) Adam Daniel Brown wrote: On 6/26/07, Marius Toma [EMAIL PROTECTED] wrote: I can not believe how stupid I can be sometime. I was trying to create a file, but a file with the same name already existed on the server - and I did not have the write permission to it, so from here I got the error message saying that I can not create the file :( Thank for your time, Marius -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If you absolutely *must* create PHP files on-the-fly, and only need them for a one-off thing, put them in a specific directory that only the web server has access to read, write, and execute, and then delete the files immediately after you've used them as needed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create .php file with php
Would it not be better to create the file with tmpfile() and to put it in the system /tmp dir; which, I believe, is generally not in the webspace? Daniel Brown wrote: On 6/26/07, Marius Toma [EMAIL PROTECTED] wrote: I can not believe how stupid I can be sometime. I was trying to create a file, but a file with the same name already existed on the server - and I did not have the write permission to it, so from here I got the error message saying that I can not create the file :( Thank for your time, Marius -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php If you absolutely *must* create PHP files on-the-fly, and only need them for a one-off thing, put them in a specific directory that only the web server has access to read, write, and execute, and then delete the files immediately after you've used them as needed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create .php file with php
On 6/26/07, Al [EMAIL PROTECTED] wrote: Would it not be better to create the file with tmpfile() and to put it in the system /tmp dir; which, I believe, is generally not in the webspace? The problem here, though, Al, is that it relies on the server admin not to be lazy, and to have the box properly configured. Else, any files in the /tmp directory can easily be ready by anyone on the same machine. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Brain Teasers
What the hell? Why not start a thread that can be fun and challenging for all of us. It's something I haven't seen done anywhere else yet, but I wouldn't be surprised if it has been. Let's put together some names, phrases, and other stuff expressed as PHP code and see who can come up with a real stumper. For example: ? while($u_work) { whistle(); } ? would be Whistle While You Work. Try to use some really common phrases that all of us around the world should recognize, but feel free to get really elaborate with the code. So here's the first one (it's simple): ? function at($level) { $level == 10 ? $ret = winner : ''; $level == 15 ? $ret = try : ''; $level == 20 ? $ret = first : ''; $level == 25 ? $ret = user : ''; $level == 30 ? $ret = place : ''; $level == 35 ? $ret = again : ''; $level == 40 ? $ret = succeed : ''; $level == 45 ? $ret = last : ''; $level == 50 ? $ret = finish : ''; return $ret; } if(at(20) != succeed) { try { $e = again; throw new Exception($e); } catch(Exception $e) { echo Try .$e-getMessage().\n; } } ? -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create .php file with php
On 6/26/07, Al Rider [EMAIL PROTECTED] wrote: I thought that the php engine took care of deleting tmp files when the script ended. Thus, if his script is terminated before his code deletes the file, the engine will insure it's deleted. Otherwise, he should use an ignore_user_abort(). You're right, and good point about ignore_user_abort();. I'd actually never used that function before, but there are several places where I could (and probably should). The point I was making is that, unless the server is set up properly, as the files exist on the server, they'll be readable, clone-able, and possibly even executable. All a malicious user would need to do is watch the /tmp directory for files being written and immediately copy or read them. This doesn't take into account proper usage of suexec, correct chmod'ing of /tmp (and mounting, if you're like myself), et cetera, but keep in mind that not all (perhaps even most) hosting providers out there are one-man operations, and a gross majority of those are run by people with almost no knowledge of - or maybe concern for - best practices regarding their customer's security. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 6/26/07, Daniel Brown [EMAIL PROTECTED] wrote: What the hell? Why not start a thread that can be fun and challenging for all of us. It's something I haven't seen done anywhere else yet, but I wouldn't be surprised if it has been. Let's put together some names, phrases, and other stuff expressed as PHP code and see who can come up with a real stumper. For example: ? while($u_work) { whistle(); } ? would be Whistle While You Work. Try to use some really common phrases that all of us around the world should recognize, but feel free to get really elaborate with the code. So here's the first one (it's simple): Yes, of course, call it simple... :P It took me 20 minutes to figure it out :S :P ? function at($level) { $level == 10 ? $ret = winner : ''; $level == 15 ? $ret = try : ''; $level == 20 ? $ret = first : ''; $level == 25 ? $ret = user : ''; $level == 30 ? $ret = place : ''; $level == 35 ? $ret = again : ''; $level == 40 ? $ret = succeed : ''; $level == 45 ? $ret = last : ''; $level == 50 ? $ret = finish : ''; return $ret; } if(at(20) != succeed) { try { $e = again; throw new Exception($e); } catch(Exception $e) { echo Try .$e-getMessage().\n; } } ? -- Daniel P. Brown Oh, and how do we make such things? Is there a manual about them? :P TIjnema -- Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
So here's the first one (it's simple): ? function at($level) { $level == 10 ? $ret = winner : ''; $level == 15 ? $ret = try : ''; $level == 20 ? $ret = first : ''; $level == 25 ? $ret = user : ''; $level == 30 ? $ret = place : ''; $level == 35 ? $ret = again : ''; $level == 40 ? $ret = succeed : ''; $level == 45 ? $ret = last : ''; $level == 50 ? $ret = finish : ''; return $ret; } if(at(20) != succeed) { try { $e = again; throw new Exception($e); } catch(Exception $e) { echo Try .$e-getMessage().\n; } } ? The correct answer is: Parse error: parse error, unexpected '{' in /var/www/html/m.php on line 17 Oh well, you know what they say: If at first you don't succeed... JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 6/26/07, Tijnema [EMAIL PROTECTED] wrote: On 6/26/07, Daniel Brown [EMAIL PROTECTED] wrote: What the hell? Why not start a thread that can be fun and challenging for all of us. It's something I haven't seen done anywhere else yet, but I wouldn't be surprised if it has been. Let's put together some names, phrases, and other stuff expressed as PHP code and see who can come up with a real stumper. For example: ? while($u_work) { whistle(); } ? would be Whistle While You Work. Try to use some really common phrases that all of us around the world should recognize, but feel free to get really elaborate with the code. So here's the first one (it's simple): Yes, of course, call it simple... :P It took me 20 minutes to figure it out :S :P ? function at($level) { $level == 10 ? $ret = winner : ''; $level == 15 ? $ret = try : ''; $level == 20 ? $ret = first : ''; $level == 25 ? $ret = user : ''; $level == 30 ? $ret = place : ''; $level == 35 ? $ret = again : ''; $level == 40 ? $ret = succeed : ''; $level == 45 ? $ret = last : ''; $level == 50 ? $ret = finish : ''; return $ret; } if(at(20) != succeed) { try { $e = again; throw new Exception($e); } catch(Exception $e) { echo Try .$e-getMessage().\n; } } ? -- Daniel P. Brown Oh, and how do we make such things? Is there a manual about them? :P TIjnema -- Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info No, I just made some stuff up. I thought it could be fun, and a decent exercise in coding. Jim, I didn't get any parse errors when I tested it, it just output the stuff. You're right though that is what they say -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create .php file with php [POC CODE INCLUDED]
On 6/26/07, Al Rider [EMAIL PROTECTED] wrote: I think most systems have a /tmp directory above the web dir, so outsiders can't watch it anyhow. True, but on an unsecured box, this becomes possible, as Apache will most likely be running universally as `nobody`, `httpd`, `apache`, or `daemon` for all scripts, including all web-based scripts writing to the /tmp directory. This includes session information, temporary .php files (as Marius requested), et cetera. Proof of concept: ? if(is_dir('/tmp')) { $handle = opendir('/tmp'); while(False !== ($ls_file = readdir($handle))) { if(is_file('/tmp/'.$ls_file)) { echo /tmp/.$ls_file.: \n; $filename = fopen('/tmp/'.$ls_file,r); fread($filename,filesize($filename)); echo END .$ls_file. \n; } } } closedir($handle); ? -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
Jim, I didn't get any parse errors when I tested it, it just output the stuff. You're right though that is what they say Bah - thwarted (again) by PHP4. :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 6/26/07, Jim Moseby [EMAIL PROTECTED] wrote: Jim, I didn't get any parse errors when I tested it, it just output the stuff. You're right though that is what they say Bah - thwarted (again) by PHP4. :( How so? I didn't use any 5th Generation-specific code -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
Daniel Brown wrote: On 6/26/07, Jim Moseby [EMAIL PROTECTED] wrote: Jim, I didn't get any parse errors when I tested it, it just output the stuff. You're right though that is what they say Bah - thwarted (again) by PHP4. :( How so? I didn't use any 5th Generation-specific code er? catch, throw, try (again ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create .php file with php [POC CODE INCLUDED]
On Wednesday 27 June 2007 03:53, Daniel Brown wrote: On 6/26/07, Al Rider [EMAIL PROTECTED] wrote: I think most systems have a /tmp directory above the web dir, so outsiders can't watch it anyhow. True, but on an unsecured box, this becomes possible, as Apache will most likely be running universally as `nobody`, `httpd`, `apache`, or `daemon` for all scripts, including all web-based scripts writing to the /tmp directory. This includes session information, temporary .php files (as Marius requested), et cetera. How is this different from: put them in a specific directory that only the web server has access to read, write, and execute -- Crayon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
On 6/26/07, Jim Moseby [EMAIL PROTECTED] wrote: Jim, I didn't get any parse errors when I tested it, it just output the stuff. You're right though that is what they say Bah - thwarted (again) by PHP4. :( How so? I didn't use any 5th Generation-specific code http://us.php.net/try says: PHP 5 has an exception model similar to that of other programming languages I take that to mean that the throw/catch/try stuff is specific to PHP5, no? Maybe its a cut/paste error? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 6/26/07, Jim Moseby [EMAIL PROTECTED] wrote: On 6/26/07, Jim Moseby [EMAIL PROTECTED] wrote: Jim, I didn't get any parse errors when I tested it, it just output the stuff. You're right though that is what they say Bah - thwarted (again) by PHP4. :( How so? I didn't use any 5th Generation-specific code http://us.php.net/try says: PHP 5 has an exception model similar to that of other programming languages I take that to mean that the throw/catch/try stuff is specific to PHP5, no? Maybe its a cut/paste error? Yes, defenitly for PHP5 only, to be 100% sure, I tested it on my PHP4 server (parse error) and then run the same server with PHP5 module, and it says: Try again Tijnema -- Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Brain Teasers
Daniel Brown wrote: What the hell? Why not start a thread that can be fun and challenging for all of us. How about this: ?php define('MONY', 20); $mickle = 0 while(++$mickle) { if (MONY == $mickle) { echo Muckle; exit; } } ? It's a bit more obscure ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Brain Teasers
How are we going to respond to these? Should we answer or just kepe them to ourselves. SPOILER** Answer: Many a mickle makes a muckle? Colin Guthrie [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Daniel Brown wrote: What the hell? Why not start a thread that can be fun and challenging for all of us. How about this: ?php define('MONY', 20); $mickle = 0 while(++$mickle) { if (MONY == $mickle) { echo Muckle; exit; } } ? It's a bit more obscure ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create .php file with php [POC CODE INCLUDED]
On 6/26/07, Crayon Shin Chan [EMAIL PROTECTED] wrote: On Wednesday 27 June 2007 03:53, Daniel Brown wrote: On 6/26/07, Al Rider [EMAIL PROTECTED] wrote: I think most systems have a /tmp directory above the web dir, so outsiders can't watch it anyhow. True, but on an unsecured box, this becomes possible, as Apache will most likely be running universally as `nobody`, `httpd`, `apache`, or `daemon` for all scripts, including all web-based scripts writing to the /tmp directory. This includes session information, temporary .php files (as Marius requested), et cetera. How is this different from: put them in a specific directory that only the web server has access to read, write, and execute -- Crayon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php There were more posts that someone hadn't sent to the list, whereas I replied to the list. I didn't pay attention to see if the posts were included or not. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Brain Teasers
On 6/26/07, Dan [EMAIL PROTECTED] wrote: How are we going to respond to these? Should we answer or just kepe them to ourselves. SPOILER** Answer: Many a mickle makes a muckle? Colin Guthrie [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Daniel Brown wrote: What the hell? Why not start a thread that can be fun and challenging for all of us. How about this: ?php define('MONY', 20); $mickle = 0 while(++$mickle) { if (MONY == $mickle) { echo Muckle; exit; } } ? It's a bit more obscure ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php It should be fun either way, even if it's a spoiler (though I didn't know the muckle phrase), because then everyone can look back through the code anyway. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create .php file with php [POC CODE INCLUDED]
On Jun 26, 2007, at 3:31 PM, Crayon Shin Chan wrote: On Wednesday 27 June 2007 03:53, Daniel Brown wrote: On 6/26/07, Al Rider [EMAIL PROTECTED] wrote: I think most systems have a /tmp directory above the web dir, so outsiders can't watch it anyhow. True, but on an unsecured box, this becomes possible, as Apache will most likely be running universally as `nobody`, `httpd`, `apache`, or `daemon` for all scripts, including all web-based scripts writing to the /tmp directory. This includes session information, temporary .php files (as Marius requested), et cetera. How is this different from: put them in a specific directory that only the web server has access to read, write, and execute Most /tmp directories are world rwx. So anyone that can log into the server through a shell, or any account running on the server, has at least read access to anything in the /tmp directory. They wouldn't need to do it through a web script. At least if the temp directory is rwx web server only, shell logins and other accoounts are denied access. Any web script can still get to it though. Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Brain Teasers (SPOILER)
Dan wrote: How are we going to respond to these? Should we answer or just kepe them to ourselves. SPOILER** Answer: Many a mickle makes a muckle? SPOILER in the title is a good idea! I was going for Mony a mickle maks a muckle hence the name of my constant, but I'll give you it :p Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Brain Teasers
Daniel Brown wrote: What the hell? Why not start a thread that can be fun and challenging for all of us. It's something I haven't seen done Here's another quickie: Dead simple one! ?php function x($x) { switch ($x) { case 1: return 'bitten'; case 2: return 'shy'; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create .php file with php [POC CODE INCLUDED]
... if you really couldn't write it as dynamic PHP -- you could also save it in a database. Edward Vermillion wrote: On Jun 26, 2007, at 3:31 PM, Crayon Shin Chan wrote: On Wednesday 27 June 2007 03:53, Daniel Brown wrote: On 6/26/07, Al Rider [EMAIL PROTECTED] wrote: I think most systems have a /tmp directory above the web dir, so outsiders can't watch it anyhow. True, but on an unsecured box, this becomes possible, as Apache will most likely be running universally as `nobody`, `httpd`, `apache`, or `daemon` for all scripts, including all web-based scripts writing to the /tmp directory. This includes session information, temporary .php files (as Marius requested), et cetera. How is this different from: put them in a specific directory that only the web server has access to read, write, and execute Most /tmp directories are world rwx. So anyone that can log into the server through a shell, or any account running on the server, has at least read access to anything in the /tmp directory. They wouldn't need to do it through a web script. At least if the temp directory is rwx web server only, shell logins and other accoounts are denied access. Any web script can still get to it though. Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Brain Teasers
On Wed, 2007-06-27 at 00:24 +0100, Colin Guthrie wrote: Daniel Brown wrote: What the hell? Why not start a thread that can be fun and challenging for all of us. It's something I haven't seen done Here's another quickie: Dead simple one! ?php function x($x) { switch ($x) { case 1: return 'bitten'; case 2: return 'shy'; } } Hmmm... would be better as (: ?php function x( $x ) { echo 'bitten'; echo 'shy'; echo 'shy'; } ? Here's another one: ?php class money { var $pennies = 0; function money( $amount=0 ) { $this-pennies = $amount; } function save() { return true; } } class account { var $total = 0; function account( $init=0 ) { $this-total = $init; } function add( $money ) { $this-total += $money-pennies; } } $earned = new account(); $penny = new money( 1 ); if( $penny-save() ) { $earned-add( $penny ); } ? Cheers, Rob -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Brain Teasers
Daniel Brown wrote: What the hell? Why not start a thread that can be fun and challenging for all of us. One more before bed: class pin { private $mVisible; private $mInstantiateTime; public function __construct() { $this-mInstantiateTime = floor(time() / 86400) * 86400; $this-mVisible = rand() % 2; } public function isVisible() { return $this-mVisible; } public function pickup() { if ($this-mVisible) { $now = time(); if (($now - $this-mInstantiateTime) 86400) return 'Good Luck!'; } return ''; } } $pin = new pin(); if ($pin-isVisible()) $have = $pin-pickup(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Brain Teasers
Colin Guthrie wrote: Daniel Brown wrote: What the hell? Why not start a thread that can be fun and challenging for all of us. One more before bed: class pin { private $mVisible; private $mInstantiateTime; public function __construct() { $this-mInstantiateTime = floor(time() / 86400) * 86400; $this-mVisible = rand() % 2; } public function isVisible() { return $this-mVisible; } public function pickup() { if ($this-mVisible) { $now = time(); if (($now - $this-mInstantiateTime) 86400) return 'Good Luck!'; } return ''; } } $pin = new pin(); if ($pin-isVisible()) $have = $pin-pickup(); PS I KNOW this is not LC_TIME aware and I know I double check a condition but it's needed in the context I think ;) Night all. /me should have gone to be ages ago. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Brain Teasers
Robert Cummings wrote: On Wed, 2007-06-27 at 00:24 +0100, Colin Guthrie wrote: Daniel Brown wrote: What the hell? Why not start a thread that can be fun and challenging for all of us. It's something I haven't seen done Here's another quickie: Dead simple one! ?php function x($x) { switch ($x) { case 1: return 'bitten'; case 2: return 'shy'; } } Hmmm... would be better as (: ?php function x( $x ) { echo 'bitten'; echo 'shy'; echo 'shy'; } ? I guess you could call that different syntax, same semantics! Here's another one: ?php class money { var $pennies = 0; function money( $amount=0 ) { $this-pennies = $amount; } function save() { return true; } } class account { var $total = 0; function account( $init=0 ) { $this-total = $init; } function add( $money ) { $this-total += $money-pennies; } } $earned = new account(); $penny = new money( 1 ); if( $penny-save() ) { $earned-add( $penny ); } ? Nice :p Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
I think I have to answer to this one: 'If at first you don't succeed try, try again'. Eric ? function at($level) { $level == 10 ? $ret = winner : ''; $level == 15 ? $ret = try : ''; $level == 20 ? $ret = first : ''; $level == 25 ? $ret = user : ''; $level == 30 ? $ret = place : ''; $level == 35 ? $ret = again : ''; $level == 40 ? $ret = succeed : ''; $level == 45 ? $ret = last : ''; $level == 50 ? $ret = finish : ''; return $ret; } if(at(20) != succeed) { try { $e = again; throw new Exception($e); } catch(Exception $e) { echo Try .$e-getMessage().\n; } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On Tue, 2007-06-26 at 17:00 -0700, Eric Newberry wrote: I think I have to answer to this one: 'If at first you don't succeed try, try again'. Here's another one... ?php $x = rand( 1, 20 ); for( $i = 0; $i $x; $i++ ); while( --$i 0 ); ? Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with mirror site script
Hi. I am currently writing a script to put on my site so people can browse other sites by using my site as a mirror therefore the contents of a webpage would be retrieved and echoed on my site. I am having some problems with placing my ad at the top of the page that is echoed when a user browses a site so that it doesn't interfere with the headers. I am having problems with where to place the link e.g. after the body tag, and how to find out what type of page it is i.e. html, xhtml, etc. so I know if I can use specific effects with my ads. Also, when a user clicks on a link on the mirrored page the link should be mysite.com/index.php?go=http://othersite.com/othersitepage.htm and not mysite.com/othersitepage.htm I have tried to use str_replace in the contents of the retrieved webpage but it doesn't seam to work. Here is the simple piece of code that I have started with without security etc: ? // $http is the page that the user wants to browse $handle = fopen($http, r); ///get contents of webpage $contents = fread($handle, 50); fclose($handle); $replace = explode(mysite.com/, $contents); str_replace(mysite.com, mysite.com/index.php?http=$http/$replace[1], $contents); if(strstr($contents, !DOCTYPE html PUBLIC \-//W3C//DTD HTML)) { $ads = ads_html(); $contents2 = explode(/body , $contents); } if(strstr($contents, !DOCTYPE html PUBLIC \-//W3C//DTD XHTML)) { $ads = ads_xhtml(); $contents2 = explode(/body , $contents); } echo $contents2[0] . $ads . $contents2[1]; ? Please advise me if there is another better way to place my ad and check the type of page because this coding is just wrong and error-prone. Thanks Wikus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
- Original Message - From: Robert Cummings [EMAIL PROTECTED] To: Eric Newberry [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Tuesday, June 26, 2007 5:14 PM Subject: Re: [PHP] PHP Brain Teasers On Tue, 2007-06-26 at 17:00 -0700, Eric Newberry wrote: I think I have to answer to this one: 'If at first you don't succeed try, try again'. Here's another one... ?php $x = rand( 1, 20 ); for( $i = 0; $i $x; $i++ ); while( --$i 0 ); ? Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- 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] Aggressive PHP Smart Caching
Thank you for your reply Nathan. You are right that this method of caching is different than the two types you have outlined below. I would not say that it is a new method though, in fact, pushing static files to the server is very common. If it weren't for the fact that this method, as I have designed it, allows a very tiny PHP overhead to handle dynamic updating of the cache I could have even gone the extra mile to push html files that would be loaded directly by the end user without PHP being initialized at all. (My reasons for not taking this last step should become apparent to those who read the wishlist I produced at http://technologies.babywhale.net/cache/ ) Understand that this method does not *exclude* using the other two methods you have outlined. In fact, I personally make use of memcached and APC where I feel it is appropriate in my application design. This does not mean that I can not also write a cache layer that makes the application itself and its variables irrelevant and not required for most site hits (hence a major optimization). To answer your other questions: 1) Caching on disk could easily be handled instead by caching in memory, but this approach is meant to be ultra-portable and work everywhere. There are situations where a viable memory storage mechanism is simply not available, and other cases where it is not desirable to consume memory for this purpose and plenty of hard drive storage space is a good alternative. I think you will find this caching method is intensely speed-tuned and a fast implementation of a portable file system based method. I would also point out that in my line of work, where I chiefly have to adopt environments that are configured under rather political circumstances, it is consistently this type of caching that the system administrators argue for. As someone has already pointed out, there may not even be a significant difference between disk and memory based storage mechanisms on your server. 2) Again, one of the main theories behind this method is portability. In order to not rely on cron, server queries, or other external checks for a stale cache, I have gone with a refresh interval which has been proposed on this list in the past. It proposes that dynamic content should be refreshed once every X seconds/minutes/hours. This script avoids PHP date manipulations and instead performs some basic math to handle the refresh rate, but also to *sync* content to some degree, so portions of dynamic content are less likely to haphazardly refresh independently and therefore not match. I think this is a slight improvement over code that has been posted here before. In a practical sense, this means that your application fires and produces content only once every X minutes, and not each and every time the page is hit. Furthermore, because in this case it is known ahead of time when that page will expire, a cache header can be sent with an exact expiration time so repeated hits by the same end user will not even trigger a transmission of cached content from the server. 3) In regards to daily purging: for one, if you are going for a scheduled refresh of content, then you probably already have a refresh rate that is less than 24 hours, so accepting an additional daily trigger of recaching should not be unacceptable. But more specifically, the reason behind this is that a file system based caching method does not natively support a TTL on cached files, and there has to be some way to handle a cache of a script that has since been deleted. Note that if 24 hours is not acceptable for some reason, this script can easily be modified to increase that without negatively affecting anything else. On Jun 24, 2007, at 11:55 PM, Nathan Nobbe wrote: Alexander, sorry to see nobody has replied to your post, im sure you worked very hard on the cache system and are eager for feedback.. so to me it looks like youve introduced a somewhat new style of caching here (though im sure there are other such approaches); for instance i know of 2 main uses for caches at this time [as caching pertains to php]. caching php intermediate code caching application variables both of these caching techniques are designed to overcome limitations of the language as it ships out of the box, more or less; afaik. it appears you are interested in caching the output of php scripts, which is, i suppose, a third technique that could be added to the list. so i have a criticism about your system and a couple questions as well. criticism why cache script output on disk? if a fast cache is your goal, why not store the result of script output in memory rather than on disk; that would be much faster questions how does your cache system know when cached output is stale and allow fresh contents to be delivered from the original script rather than being served from the cache?