Re: [PHP] Silly question - include vs. eval
On Wed, 2009-03-11 at 19:50 -0500, Shawn McKenzie wrote: Robert Cummings wrote: On Wed, 2009-03-11 at 16:16 -0500, Shawn McKenzie wrote: Shawn McKenzie wrote: Robert Cummings wrote: On Wed, 2009-03-11 at 13:20 -0500, Shawn McKenzie wrote: Robert Cummings wrote: On Wed, 2009-03-11 at 12:19 -0500, Shawn McKenzie wrote: Sándor Tamás (HostWare Kft . ) wrote: Yes, Rob is right. My original question is about the difference between the processing of a file-based site with include() OR eval(). In that case, if I understood it correctly, the results are the same. But! If the included pages contain functions, classes, etc. With eval(), can I use them? With include(), I know I should be able to use them. But in some mysterious cases I don't have access to a function. If I cut out from the included file, and put in on the file which includes that, just before (or after) the includ(), I don't have any problem with it. The next step, that if I include a file in a function, can I use the functions wrote in the included file? As I know, include just makes a copy-paste, so if I use it IN a function, then all function will be in function scope, am I right? Yes, if you use an include inside a function, then any functions / non global vars in the included file will only be available inside the including function. This is NOT, I repeat, NOT true for functions. Functions are ALWAYS global. Cheers, Rob. Yes, I was too hasty. The nested function will only be defined once the nesting function has been called. Then it will be available globally. Actually, you're wrong again. The nested function, AKA function defined in the included source, will be defined as soon as the source is included and is available to the function in which the source was included. In fact it is even available to the code within the included source that can be run during the include process and before the function performing the inclusion regains control. Cheers, Rob. Well I used the word defined, however what I meant was the included function would only be available globally after the including function has been called. But yes, it will be available to the including function. Actually, which would mean that the including function had been called if it was attempting to use any of the vars/functions in the included file :-) You need to work on your use of verb tenses :) Cheers, Rob. What? I didn't know you flamed people whose native language wasn't English! How can we get a break on this list? I speak Texan (sorta), and apologize for my poor English. :-( I wasn't flaming, I was providing insight into why your wording was confusing. If I had been flaming I would have used sarcasm or derogatory phrasing to demean your words. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP 5.2.9 - 5.2.9-1 and curl
Hi all, I'm using PHP 5.2.9 on a Windows dedicated server. Could you kindly confirm me that I have to update to PHP 5.2.9-1 (http://www.php.net/archive/2009.php#id2009-03-10-1) only if I have curl extension enabled (extension=php_curl.dll in php.ini) ? If I run a phpinfo() on my webserver, no curl section is shown (no extension=php_curl.dll in php.ini). So, is my configuration (Windows 2003 Server - PHP 5.2.9) safe? Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] FW: built-in objects APC or serializatio n
... nobody a clue? ... Hi everybody, I am a Certified Zend Engineer with almost 10 years of PHP development experience but for some reason I've never asked question to this ML. As subject says, I would like to know if there a generic extension/3rd parts/solution to save the state of a built-in PHP object. I perfectly know that __sleep and __wakeup or ... implements Serializable { ... } could allow me to store and retrieve serialized data but what I did not expect is that APC just behaves as serialize and nothing more than that. Here there is a quick explanation: $xsltp = new XSLTProcessor; $xsltp-importStylesheet( DomDocument::load('random.xsl') ); // no way to store the variable here with its live state // without re-importing stylesheet on __wakeup or unserialize echo$xsltp-transformToXML( DomDocument::load('random.xml') ); I agree that this built-in stuff could be consider a weird case but I cannot believe that with all these new classes there is no solution to truly hibernate instances state. As summary, I wonder if any of you knows a solution or, if any, when (and if) are you planning to add this feature. Best Regards _ Show them the way! Add maps and directions to your party invites. http://www.microsoft.com/windows/windowslive/products/events.aspx
Re: [PHP] Re: Include File Errors with Comments
On Wed, Mar 11, 2009 at 7:51 PM, Patrick Moloney webpa...@gmail.com wrote: OK, I think I've got the problem. I had to go back further than where the problem appeared to be. The 1st error was the comment code on the div line before the menu is Included. It had the -- in the comment. Oddly, it interacts with the same error in the comment in the mainmenu file. I saw some suggestion that these work in pairs but fail in odd numbers. So, I have many pages that work like this. Adding another bad comment to the mainmenu, causes it to fail (3 bad lines). Or, without a third line, fixing the only bad line in the mainmenu also fails! Now, correcting the bad line in the web page fixes that -- (whoops) - but causes all the other similar web site pages to start failing. I'll have to fix them all, but at least I know the problem. No wonder nobody comments code! mainmenu.php !-- Comment on the First Line -- !-- Comment on the -- Second Line -- Functional Menu code ... webpage.php ... Body div id=menu !-- Include the -- menu here -- ?php include 'mainmenu.php'; ? /div ... I do use PHP comments (probably not as much as I should), but I don't usually use HTML comments. This is partly (largely?) because HTML comments get passed on to the client which wastes (albeit usually a small amount of) extra space and bandwidth for each request, and they give out implementation details to people who least need to know them. I can sort of see adding the HTML comments when designing a full page template so it is easier to determine where dynamic content needs to be inserted when you start slicing the template apart, but even then I usually remove those comments later in the design process before I put the code out for production. Then again, I haven't included files for anything other than function/class libraries in years either. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Working directory of PHP pages?
On Thu, Mar 12, 2009 at 12:47 AM, Clancy clanc...@cybec.com.au wrote: On Wed, 11 Mar 2009 13:03:19 -0500, halip...@gmail.com (haliphax) wrote: On Wed, Mar 11, 2009 at 12:44 PM, Shawn McKenzie nos...@mckenzies.net wrote: Clancy wrote: It is my understanding that when you open a page the PHP server looks for index.php in the site root directory, and loads it. As a result the working directory of the page will be the root directory of the site. I have always worked on this assumption, and it has always been correct. On the other hand Stewart thinks that I cannot rely this, and am likely to get into trouble as a result. Are there any systems in which my assumption will not be correct? In many frameworks this assumption is not correct. I am using the default CakePHP layout as an example. Depending on your terminology, your DocumentRoot is /var/www/ and in this case is also the filesystem path of your site's root dir, however the sites root dir in a URL is /. Consider the CakePHP structure: /var/www/ .htaccess index.php /var/www/webroot index.php If you browse to http://example.com/ (in most cases), one of 2 things happens: 1. The webserver opens the /var/www/.htaccess and according to the rewrite rules there it rewrites to /var/www/webroot/. So any getcwd() would be /var/www/webroot/ 2. If not using modrewrite, the web server looks for index.html and then index.php in /var/www/ which has a require for webroot/index.php. So any getcwd() would be /var/www/. Consequently, CakePHP and the other frameworks that I've seen use basename() and dirname() in conjunction with __FILE__ to define the paths/relative dirs within the app. Come to think of it, this may very well be true for all MVC frameworks (unless the models, views, and controllers are all in the same directory as the launch script). I can at least vouch for the fact that CodeIgniter, like CakePHP, will fudge your directory estimation if you're expecting getcwd() to be right. Something Stewart said the other day made me realise that there was a fundamental error in the way I was thinking about this question. I had been thinking that opendir (.) opened the root directory, and that paths such as Joe/Nurg.com were relative to the root directory, but I now realise that they are relative to the current directory, whatever that might be. (Yes; I should have known better, but there is an awful swamp of burnt out brain cells at the bottom of my brain.) So the question I should have asked was When a web page is loaded, can I rely on the CWD being the directory containing index.php (or whichever file is actually loaded)? I believe the answer was No, not really, from several different people. -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ltrim behavior.
At 3:38 PM -0400 3/11/09, Robert Cummings wrote: Just because I'm a nice guy... :) Yeah, me too -- here are three routines I use for cutting the right, left and middle portions of strings. These were keyword routines I used in FutureBasic -- they seemed to make sense to me so I carried them into php. ?php // == returns the right-most number of characters from a string // $string = 123456789 // right($string, 3) returns 123 function right($string, $length) { $str = substr($string, -$length, $length); return $str; } // == returns the left-most number of characters from a string // $string = 123456789 // left($string, 3) returns 789 function left($string, $length) { $str = substr($string, 0, $length); return $str; } // == returns the middle number of characters from a string starting from the left // $string = 123456789 // mid($string, 3, 4) returns 4567 function mid($string, $left_start, $length) { $str = substr($string, $left_start, $length); return $str; } ? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ltrim behavior.
At 5:03 PM -0400 3/11/09, Peter van der Does wrote: Thanks and I apologize for the stupid question. The only stupid question is the one that's not asked. The ltrim() caught me the first time I used it too. I was thinking it was trim this string off the left when it was trim these characters off the left. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ltrim behavior.
On Thu, Mar 12, 2009 at 9:47 AM, tedd tedd.sperl...@gmail.com wrote: At 3:38 PM -0400 3/11/09, Robert Cummings wrote: Just because I'm a nice guy... :) Yeah, me too -- here are three routines I use for cutting the right, left and middle portions of strings. These were keyword routines I used in FutureBasic -- they seemed to make sense to me so I carried them into php. ?php // == returns the right-most number of characters from a string // $string = 123456789 // right($string, 3) returns 123 function right($string, $length) { $str = substr($string, -$length, $length); return $str; } // == returns the left-most number of characters from a string // $string = 123456789 // left($string, 3) returns 789 function left($string, $length) { $str = substr($string, 0, $length); return $str; } // == returns the middle number of characters from a string starting from the left // $string = 123456789 // mid($string, 3, 4) returns 4567 function mid($string, $left_start, $length) { $str = substr($string, $left_start, $length); return $str; } ? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Tedd, Just because I'm a nit-picker, your comments are wrong. Exchange the right and left comments and it's right. Steve.
Re: [PHP] PHP 5.2.9 - 5.2.9-1 and curl
Niki wrote: Hi all, I'm using PHP 5.2.9 on a Windows dedicated server. Could you kindly confirm me that I have to update to PHP 5.2.9-1 (http://www.php.net/archive/2009.php#id2009-03-10-1) only if I have curl extension enabled (extension=php_curl.dll in php.ini) ? Well nobody forces you to upgrade. But it would be wise. Now the bug in curl is still fresh in your mind. But if you forget and decide to enable it later. Big chance you vulnerable to some sort of attack. If I run a phpinfo() on my webserver, no curl section is shown (no extension=php_curl.dll in php.ini). So, is my configuration (Windows 2003 Server - PHP 5.2.9) safe? The bug only affects libcurl. So i guess when curl is disabled it's safe... Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5.2.9 - 5.2.9-1 and curl
Niki schreef: Hi all, I'm using PHP 5.2.9 on a Windows dedicated server. Could you kindly confirm me that I have to update to PHP 5.2.9-1 (http://www.php.net/archive/2009.php#id2009-03-10-1) only if I have curl extension enabled (extension=php_curl.dll in php.ini) ? If I run a phpinfo() on my webserver, no curl section is shown (no extension=php_curl.dll in php.ini). So, is my configuration (Windows 2003 Server - PHP 5.2.9) safe? as far as the curl issue is concerned, yes, I believe so. I'm sure that the php core doesn't use curl in it's core, you don't use it and it's not activated, so nothing to worry about. obviously some may say the 'Windows 2003 Server' part might not be so secure ... but that's a different flame war. Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5.2.9 - 5.2.9-1 and curl
Thijs Lensselink ha scritto: Niki wrote: Hi all, I'm using PHP 5.2.9 on a Windows dedicated server. Could you kindly confirm me that I have to update to PHP 5.2.9-1 (http://www.php.net/archive/2009.php#id2009-03-10-1) only if I have curl extension enabled (extension=php_curl.dll in php.ini) ? Well nobody forces you to upgrade. But it would be wise. Now the bug in curl is still fresh in your mind. But if you forget and decide to enable it later. Big chance you vulnerable to some sort of attack. (...) However, do you confirm that the vulnerability (with ext/curl activated) is exploitable running a malicious php script only? The attacker needs to upload to the server that uses the extension libcurl a php page that uses CURLOPT_FOLLOWLOCATION, isn't it? If FTP access is correctly protected and the other applications on the server do not allow uploading the malicious php script is not possibile to make an attack, even if libcurl is enabled. Is it correct? Thank you! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Include File Errors with Comments
Andrew Ballard wrote: I do use PHP comments (probably not as much as I should), but I don't usually use HTML comments. This is partly (largely?) because HTML comments get passed on to the client which wastes (albeit usually a small amount of) extra space and bandwidth for each request, and they give out implementation details to people who least need to know them. Andrew That's another issue, but a good point. I was thinking about that too, and I think it influenced some of my comments. This has been my first use of PHP so I'm still learning. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5.2.9 - 5.2.9-1 and curl
Niki schreef: Thijs Lensselink ha scritto: Niki wrote: Hi all, I'm using PHP 5.2.9 on a Windows dedicated server. Could you kindly confirm me that I have to update to PHP 5.2.9-1 (http://www.php.net/archive/2009.php#id2009-03-10-1) only if I have curl extension enabled (extension=php_curl.dll in php.ini) ? Well nobody forces you to upgrade. But it would be wise. Now the bug in curl is still fresh in your mind. But if you forget and decide to enable it later. Big chance you vulnerable to some sort of attack. (...) However, do you confirm that the vulnerability (with ext/curl activated) is exploitable running a malicious php script only? The attacker needs to upload to the server that uses the extension libcurl a php page that uses CURLOPT_FOLLOWLOCATION, isn't it? If FTP access is correctly protected and the other applications on the server do not allow uploading the malicious php script is not possibile to make an attack, even if libcurl is enabled. Is it correct? essentially, yes. note that if someone can upload a script and run it, a bug in curl in the least of your worries. you have already been owned. the curl issue is more pertinent to situations where one is using curl with CURLOPT_FOLLOWLOCATION (which seems like you'd want to use it normally) and an attacker has some idea about how to be on the receiving end of the curl call ... there by allowing them to make your curl call eat some nasty url (which may cause you to disclose sensitive info the the callee, that was intended, for example, for a ligitemate webservice ... at least that's the way I understand it (hopefully someone will correct me if I've got my wires crossed) P.S. please use a valid email address. Thank you! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dynamic Date List Newbie Problem
Hi folks, My goal was to create a dynamic date related list as follows: - take the current date (3/12/2009) - create a new date from it which would be the *1st* of that month - (3/1/2009) - then create a list that shows the current and previous 11 months like: 03/1/09 02/1/09 01/1/09 12/1/08 11/1/08 etc... --- so I did this (not fancy but was working) $nowts = strtotime(date(m)./1/.date(y)); $m01 = date('m',$nowts-(0))./1/.date('y',$nowts-(0)); $m02 = date('m',$nowts-(86400*30))./1/.date('y',$nowts-(86400*30)); $m03 = date('m',$nowts-(86400*60))./1/.date('y',$nowts-(86400*60)); $m04 = date('m',$nowts-(86400*90))./1/.date('y',$nowts-(86400*90)); $m05 = date('m',$nowts-(86400*120))./1/.date('y',$nowts-(86400*120)); $m06 = date('m',$nowts-(86400*150))./1/.date('y',$nowts-(86400*150)); $m07 = date('m',$nowts-(86400*180))./1/.date('y',$nowts-(86400*180)); $m08 = date('m',$nowts-(86400*210))./1/.date('y',$nowts-(86400*210)); $m09 = date('m',$nowts-(86400*240))./1/.date('y',$nowts-(86400*240)); $m10 = date('m',$nowts-(86400*270))./1/.date('y',$nowts-(86400*270)); $m11 = date('m',$nowts-(86400*300))./1/.date('y',$nowts-(86400*300)); $m12 = date('m',$nowts-(86400*330))./1/.date('y',$nowts-(86400*330)); PROBLEM: all was fine for the last few months but several days back the 1st few months were wrong - like this... 03/1/09 02/1/09 12/1/08 * wrong 12/1/08 11/1/08 etc... * I think the math went wrong because FEB had 28 days - not 30 (not sure why just 1 month JANUARY was wrong...) I temporarily fixed it with less than 30 day jumps like: $m01 = date('m',$nowts-(0))./1/.date('y',$nowts-(0)); $m02 = date('m',$nowts-(86400*28))./1/.date('y',$nowts-(86400*28)); $m03 = date('m',$nowts-(86400*58))./1/.date('y',$nowts-(86400*58)); $m04 = date('m',$nowts-(86400*88))./1/.date('y',$nowts-(86400*88)); $m05 = date('m',$nowts-(86400*118))./1/.date('y',$nowts-(86400*118)); $m06 = date('m',$nowts-(86400*150))./1/.date('y',$nowts-(86400*150)); $m07 = date('m',$nowts-(86400*180))./1/.date('y',$nowts-(86400*180)); Q: Any ideas how to fix this issue? (please try to keep it simple - 'cause I ain't no math wiz either) -- Thanks - RevDave Cool @ hosting4days . com [db-lists 09] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Date List Newbie Problem
$currmonth = date(m); for ($i = 1; $i = 11; $i++) { $m[$i] = date(m/d/y), mktime(0,0,0,$currmonth-$i, 1, 2009)); } Something like that. mktime() is remarkably flexible. If you start on month 3 and you subtract 5, you get month = -2. So that would be -2/1/2009, which mktime will translate to 11/1/2008. This is totally off the top of my head, but you get the idea. Works with days and years too. Sometimes it's useful when going backwards and not sure how many days the previous month had (without doing another call to find out). -TG - Original Message - From: revDAVE c...@hosting4days.com To: php-general@lists.php.net Date: Thu, 12 Mar 2009 09:24:48 -0700 Subject: [PHP] Dynamic Date List Newbie Problem Hi folks, My goal was to create a dynamic date related list as follows: - take the current date (3/12/2009) - create a new date from it which would be the *1st* of that month - (3/1/2009) - then create a list that shows the current and previous 11 months like: 03/1/09 02/1/09 01/1/09 12/1/08 11/1/08 etc... --- so I did this (not fancy but was working) $nowts = strtotime(date(m)./1/.date(y)); $m01 = date('m',$nowts-(0))./1/.date('y',$nowts-(0)); $m02 = date('m',$nowts-(86400*30))./1/.date('y',$nowts-(86400*30)); $m03 = date('m',$nowts-(86400*60))./1/.date('y',$nowts-(86400*60)); $m04 = date('m',$nowts-(86400*90))./1/.date('y',$nowts-(86400*90)); $m05 = date('m',$nowts-(86400*120))./1/.date('y',$nowts-(86400*120)); $m06 = date('m',$nowts-(86400*150))./1/.date('y',$nowts-(86400*150)); $m07 = date('m',$nowts-(86400*180))./1/.date('y',$nowts-(86400*180)); $m08 = date('m',$nowts-(86400*210))./1/.date('y',$nowts-(86400*210)); $m09 = date('m',$nowts-(86400*240))./1/.date('y',$nowts-(86400*240)); $m10 = date('m',$nowts-(86400*270))./1/.date('y',$nowts-(86400*270)); $m11 = date('m',$nowts-(86400*300))./1/.date('y',$nowts-(86400*300)); $m12 = date('m',$nowts-(86400*330))./1/.date('y',$nowts-(86400*330)); PROBLEM: all was fine for the last few months but several days back the 1st few months were wrong - like this... 03/1/09 02/1/09 12/1/08 * wrong 12/1/08 11/1/08 etc... * I think the math went wrong because FEB had 28 days - not 30 (not sure why just 1 month JANUARY was wrong...) I temporarily fixed it with less than 30 day jumps like: $m01 = date('m',$nowts-(0))./1/.date('y',$nowts-(0)); $m02 = date('m',$nowts-(86400*28))./1/.date('y',$nowts-(86400*28)); $m03 = date('m',$nowts-(86400*58))./1/.date('y',$nowts-(86400*58)); $m04 = date('m',$nowts-(86400*88))./1/.date('y',$nowts-(86400*88)); $m05 = date('m',$nowts-(86400*118))./1/.date('y',$nowts-(86400*118)); $m06 = date('m',$nowts-(86400*150))./1/.date('y',$nowts-(86400*150)); $m07 = date('m',$nowts-(86400*180))./1/.date('y',$nowts-(86400*180)); Q: Any ideas how to fix this issue? (please try to keep it simple - 'cause I ain't no math wiz either) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5.2.9 - 5.2.9-1 and curl
Jochem Maas ha scritto: essentially, yes. note that if someone can upload a script and run it, a bug in curl in the least of your worries. you have already been owned. Yes, obviously. :D I agree with you. :) the curl issue is more pertinent to situations where one is using curl with CURLOPT_FOLLOWLOCATION (which seems like you'd want to use it normally) and an attacker has some idea about how to be on the receiving end of the curl call ... there by allowing them to make your curl call eat some nasty url (which may cause you to disclose sensitive info the the callee, that was intended, for example, for a ligitemate webservice ... at least that's the way I understand it (hopefully someone will correct me if I've got my wires crossed) I'm not so sure that I've understood... The attack could be successful when libcurl extension is activated and there a php page on the server that accepts an URL from the client passing it to cURL function. Is it correct? If so, I think this could be considered only as an example of awful programming. Isn't it? P.S. please use a valid email address. I never use valid e-mail address in order to protect me from spam. If there is a sort of manifesto that users must follow to send messages here I will surely specify my true e-mail address. Thank you very much again! ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Date List Newbie Problem
On Thu, Mar 12, 2009 at 12:24 PM, revDAVE c...@hosting4days.com wrote: Hi folks, My goal was to create a dynamic date related list as follows: - take the current date (3/12/2009) - create a new date from it which would be the *1st* of that month - (3/1/2009) - then create a list that shows the current and previous 11 months like: 03/1/09 02/1/09 01/1/09 12/1/08 11/1/08 etc... --- so I did this (not fancy but was working) $nowts = strtotime(date(m)./1/.date(y)); $m01 = date('m',$nowts-(0))./1/.date('y',$nowts-(0)); $m02 = date('m',$nowts-(86400*30))./1/.date('y',$nowts-(86400*30)); $m03 = date('m',$nowts-(86400*60))./1/.date('y',$nowts-(86400*60)); $m04 = date('m',$nowts-(86400*90))./1/.date('y',$nowts-(86400*90)); $m05 = date('m',$nowts-(86400*120))./1/.date('y',$nowts-(86400*120)); $m06 = date('m',$nowts-(86400*150))./1/.date('y',$nowts-(86400*150)); $m07 = date('m',$nowts-(86400*180))./1/.date('y',$nowts-(86400*180)); $m08 = date('m',$nowts-(86400*210))./1/.date('y',$nowts-(86400*210)); $m09 = date('m',$nowts-(86400*240))./1/.date('y',$nowts-(86400*240)); $m10 = date('m',$nowts-(86400*270))./1/.date('y',$nowts-(86400*270)); $m11 = date('m',$nowts-(86400*300))./1/.date('y',$nowts-(86400*300)); $m12 = date('m',$nowts-(86400*330))./1/.date('y',$nowts-(86400*330)); PROBLEM: all was fine for the last few months but several days back the 1st few months were wrong - like this... 03/1/09 02/1/09 12/1/08 * wrong 12/1/08 11/1/08 etc... * I think the math went wrong because FEB had 28 days - not 30 (not sure why just 1 month JANUARY was wrong...) I temporarily fixed it with less than 30 day jumps like: $m01 = date('m',$nowts-(0))./1/.date('y',$nowts-(0)); $m02 = date('m',$nowts-(86400*28))./1/.date('y',$nowts-(86400*28)); $m03 = date('m',$nowts-(86400*58))./1/.date('y',$nowts-(86400*58)); $m04 = date('m',$nowts-(86400*88))./1/.date('y',$nowts-(86400*88)); $m05 = date('m',$nowts-(86400*118))./1/.date('y',$nowts-(86400*118)); $m06 = date('m',$nowts-(86400*150))./1/.date('y',$nowts-(86400*150)); $m07 = date('m',$nowts-(86400*180))./1/.date('y',$nowts-(86400*180)); Q: Any ideas how to fix this issue? (please try to keep it simple - 'cause I ain't no math wiz either) -- Thanks - RevDave Cool @ hosting4days . com [db-lists 09] Unless you are in a timezone that does not observe DST, you can't use a constant 86400 as the number of seconds in a day. You could try something like this: ?php $date = strtotime('-' . (date('d') - 1) . ' days'); for ($i = -11; $i = 0; ++$i) { $list[] = date('m/d/Y', strtotime($i months, $date)); } var_dump($list); ? Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ltrim behavior.
At 10:18 AM -0400 3/12/09, Steve Holmes wrote: On Thu, Mar 12, 2009 at 9:47 AM, tedd mailto:tedd.sperl...@gmail.comtedd.sperl...@gmail.com wrote: Tedd, Just because I'm a nit-picker, your comments are wrong. Exchange the right and left comments and it's right. Steve. Steve: No, my routines work for me -- I'm dyslexic. :-) Seriously, I use these routines all the time and never realized that they were reversed. Thanks (I think), tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5.2.9 - 5.2.9-1 and curl
On Thu, Mar 12, 2009 at 12:39 PM, Niki u...@domain.invalid wrote: Jochem Maas ha scritto: essentially, yes. note that if someone can upload a script and run it, a bug in curl in the least of your worries. you have already been owned. Yes, obviously. :D I agree with you. :) the curl issue is more pertinent to situations where one is using curl with CURLOPT_FOLLOWLOCATION (which seems like you'd want to use it normally) and an attacker has some idea about how to be on the receiving end of the curl call ... there by allowing them to make your curl call eat some nasty url (which may cause you to disclose sensitive info the the callee, that was intended, for example, for a ligitemate webservice ... at least that's the way I understand it (hopefully someone will correct me if I've got my wires crossed) I'm not so sure that I've understood... The attack could be successful when libcurl extension is activated and there a php page on the server that accepts an URL from the client passing it to cURL function. Is it correct? If so, I think this could be considered only as an example of awful programming. Isn't it? P.S. please use a valid email address. I never use valid e-mail address in order to protect me from spam. If there is a sort of manifesto that users must follow to send messages here I will surely specify my true e-mail address. Thank you very much again! ;) Not a manifesto, but the standard advice given to people who post to this list is to use Reply-All when replying to the list. If your address is invalid, people will have to manually remove it from the list of recipients or else they will get a bounce response when it tries to send to your u...@domain.invalid address. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ltrim behavior.
On Thu, 2009-03-12 at 12:46 -0400, tedd wrote: At 10:18 AM -0400 3/12/09, Steve Holmes wrote: On Thu, Mar 12, 2009 at 9:47 AM, tedd mailto:tedd.sperl...@gmail.comtedd.sperl...@gmail.com wrote: Tedd, Just because I'm a nit-picker, your comments are wrong. Exchange the right and left comments and it's right. Steve. Steve: No, my routines work for me -- I'm dyslexic. :-) *lol* Job security through dyslexic obscurity!! ;) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Copy Non-Text file from One Server to Another Issues
Hi, I have a simple code as shown in the following: ?php //original file $file = http://remote_server/copy/play.txt;; $file2 = http://remote_server/copy/test.jpg;; $file3 = http://remote_server/copy/sample.pdf;; //directory to copy to (must be CHMOD to 777) $copydir = .; $data = file_get_contents($file); $file2 = fopen($copydir . /play.txt, w+); fputs($file2, $data); fclose($file2); $data2 = file_get_contents($file2); $file3 = fopen($copydir . /test.jpg, w+); fputs($file3, $data2); fclose($file3); $data3 = file_get_contents($file3); $file4 = fopen($copydir . /sample.pdf, w+); fputs($file4, $data3); fclose($file4); $data5= file_get_contents(play.txt); echo $data5 . br; $data6= file_get_contents(test.jpg); echo $data6 . br; $data7= file_get_contents(sample.pdf); echo $data7 . br; ? The first one, $file, has no problems, and I did get the contents copied correctly. However, the second and third one, I get this error: Warning: file_get_contents() expects parameter 1 to be string, resource given in C:\Inetpub\wwwroot\test\hello.php on line 18 ./test.jpg Warning: file_get_contents() expects parameter 1 to be string, resource given in C:\Inetpub\wwwroot\test\hello.php on line 25 ./sample.pdf I notice that the empty file gets created correctly, but I cannot put in the file contents. If file_get_contents only supports text, could anyone please give me some suggestions on what type of function I should use to put in the file contents so that it is readable? Thanks in advance. Alice _ Use Messenger to talk to your IM friends, even those on Yahoo! http://ideas.live.com/programpage.aspx?versionId=7adb59de-a857-45ba-81cc-685ee3e858fe
Re: [PHP] Copy Non-Text file from One Server to Another Issues
On Thu, Mar 12, 2009 at 14:51, Alice Wei aj...@alumni.iu.edu wrote: Warning: file_get_contents() expects parameter 1 to be string, resource given in C:\Inetpub\wwwroot\test\hello.php on line 18 Freshman mistake. $file2 = fopen($copydir . /play.txt, w+); You're trying to read a data stream in file_get_contents() that was opened with fopen(). Don't. Instead, replace the line of code above with: $file2 = $copydir.'/play.txt'; and then RTFM on how to use file_get_contents(). -- /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] Re: Copy Non-Text file from One Server to Another Issues
Alice Wei wrote: Hi, I have a simple code as shown in the following: ?php //original file $file = http://remote_server/copy/play.txt;; $file2 = http://remote_server/copy/test.jpg;; $file3 = http://remote_server/copy/sample.pdf;; //directory to copy to (must be CHMOD to 777) $copydir = .; $data = file_get_contents($file); $file2 = fopen($copydir . /play.txt, w+); fputs($file2, $data); fclose($file2); $data2 = file_get_contents($file2); $file3 = fopen($copydir . /test.jpg, w+); fputs($file3, $data2); fclose($file3); $data3 = file_get_contents($file3); $file4 = fopen($copydir . /sample.pdf, w+); fputs($file4, $data3); fclose($file4); $data5= file_get_contents(play.txt); echo $data5 . br; $data6= file_get_contents(test.jpg); echo $data6 . br; $data7= file_get_contents(sample.pdf); echo $data7 . br; ? The first one, $file, has no problems, and I did get the contents copied correctly. However, the second and third one, I get this error: Warning: file_get_contents() expects parameter 1 to be string, resource given in C:\Inetpub\wwwroot\test\hello.php on line 18 ./test.jpg Warning: file_get_contents() expects parameter 1 to be string, resource given in C:\Inetpub\wwwroot\test\hello.php on line 25 ./sample.pdf I notice that the empty file gets created correctly, but I cannot put in the file contents. If file_get_contents only supports text, could anyone please give me some suggestions on what type of function I should use to put in the file contents so that it is readable? Thanks in advance. Alice _ Use Messenger to talk to your IM friends, even those on Yahoo! http://ideas.live.com/programpage.aspx?versionId=7adb59de-a857-45ba-81cc-685ee3e858fe Well, that's because you are probably thinking that $file2 = http://remote_server/copy/test.jpg;; because you assigned it at the beginning of your code. However, later in your code you do $file2 = fopen($copydir . /play.txt, w+); which assigns a file pointer resource to $file2, which overwrites what you previously assigned. Try not using the same variable name for4 multiple things ;-) Same for $file3. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] password field validation
Hi All, I have an input field with type=password. I am trying to do some error checking to see if the user puts a value in after they submit the form (i.e not left it blank) Here is what I have: on form: Password: input id=PASSWORD name=PASSWORD type=password size=15 In PHP error checking: if (empty($_POST[PASSSWORD])) { $GERROR=TRUE;} even though I am putting characters in the field before I submit I am always getting TRUE returned. This same tactic works for other fields I have that I need to make sure they put values in, just I have never done this before with a password field. What am I doing wrong? I just want to make sure they put something there! -Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: password field validation
Jason Todd Slack-Moehrle wrote: Hi All, I have an input field with type=password. I am trying to do some error checking to see if the user puts a value in after they submit the form (i.e not left it blank) Here is what I have: on form: Password: input id=PASSWORD name=PASSWORD type=password size=15 In PHP error checking: if (empty($_POST[PASSSWORD])) { $GERROR=TRUE;} even though I am putting characters in the field before I submit I am always getting TRUE returned. This same tactic works for other fields I have that I need to make sure they put values in, just I have never done this before with a password field. What am I doing wrong? I just want to make sure they put something there! -Jason Could it be that your $_POST[PASSSWORD] has three Ss in it and your form field name=PASSWORD only has 2? -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password field validation
On Thu, Mar 12, 2009 at 3:05 PM, Jason Todd Slack-Moehrle mailingli...@mailnewsrss.com wrote: Hi All, I have an input field with type=password. I am trying to do some error checking to see if the user puts a value in after they submit the form (i.e not left it blank) Here is what I have: on form: Password: input id=PASSWORD name=PASSWORD type=password size=15 In PHP error checking: if (empty($_POST[PASSSWORD])) { $GERROR=TRUE;} even though I am putting characters in the field before I submit I am always getting TRUE returned. This same tactic works for other fields I have that I need to make sure they put values in, just I have never done this before with a password field. What am I doing wrong? I just want to make sure they put something there! -Jason If that's a direct copy/paste from your actual code, there is an extra S in PASSWORD. Also, you should enclose the array key in quotes: if (empty($_POST['PASSWORD'])) { $GERROR='TRUE'; } Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password field validation
On Thu, Mar 12, 2009 at 15:05, Jason Todd Slack-Moehrle mailingli...@mailnewsrss.com wrote: if (empty($_POST[PASSSWORD])) { $GERROR=TRUE;} [snip!] What am I doing wrong? Spelling. Password only has two S's. -- /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] Dynamic Date List Newbie Problem
Crap, I hit the wrong button and sent this only to the OP... On Thu, Mar 12, 2009 at 09:24:48AM -0700, revDAVE wrote: Hi folks, My goal was to create a dynamic date related list as follows: - take the current date (3/12/2009) - create a new date from it which would be the *1st* of that month - (3/1/2009) - then create a list that shows the current and previous 11 months like: 03/1/09 02/1/09 01/1/09 12/1/08 11/1/08 etc... --- so I did this (not fancy but was working) $nowts = strtotime(date(m)./1/.date(y)); $m01 = date('m',$nowts-(0))./1/.date('y',$nowts-(0)); $m02 = date('m',$nowts-(86400*30))./1/.date('y',$nowts-(86400*30)); $m03 = date('m',$nowts-(86400*60))./1/.date('y',$nowts-(86400*60)); $m04 = date('m',$nowts-(86400*90))./1/.date('y',$nowts-(86400*90)); $m05 = date('m',$nowts-(86400*120))./1/.date('y',$nowts-(86400*120)); $m06 = date('m',$nowts-(86400*150))./1/.date('y',$nowts-(86400*150)); $m07 = date('m',$nowts-(86400*180))./1/.date('y',$nowts-(86400*180)); $m08 = date('m',$nowts-(86400*210))./1/.date('y',$nowts-(86400*210)); $m09 = date('m',$nowts-(86400*240))./1/.date('y',$nowts-(86400*240)); $m10 = date('m',$nowts-(86400*270))./1/.date('y',$nowts-(86400*270)); $m11 = date('m',$nowts-(86400*300))./1/.date('y',$nowts-(86400*300)); $m12 = date('m',$nowts-(86400*330))./1/.date('y',$nowts-(86400*330)); PROBLEM: all was fine for the last few months but several days back the 1st few months were wrong - like this... 03/1/09 02/1/09 12/1/08 * wrong 12/1/08 11/1/08 etc... * I think the math went wrong because FEB had 28 days - not 30 (not sure why just 1 month JANUARY was wrong...) I temporarily fixed it with less than 30 day jumps like: $m01 = date('m',$nowts-(0))./1/.date('y',$nowts-(0)); $m02 = date('m',$nowts-(86400*28))./1/.date('y',$nowts-(86400*28)); $m03 = date('m',$nowts-(86400*58))./1/.date('y',$nowts-(86400*58)); $m04 = date('m',$nowts-(86400*88))./1/.date('y',$nowts-(86400*88)); $m05 = date('m',$nowts-(86400*118))./1/.date('y',$nowts-(86400*118)); $m06 = date('m',$nowts-(86400*150))./1/.date('y',$nowts-(86400*150)); $m07 = date('m',$nowts-(86400*180))./1/.date('y',$nowts-(86400*180)); Q: Any ideas how to fix this issue? (please try to keep it simple - 'cause I ain't no math wiz either) Here is working code to do it better: // get your starting date $darray = getdate(); $month = $darray['mon']; $year = $darray['year']; // create your months $dt = array(); for ($i = $month; $i = 1; $i--) { $dt[] = date('m/d/y', mktime(0, 0, 0, $i, 1, $year)); } $year--; for ($i = 12; $i $month; $i--) { $dt[] = date('m/d/y', mktime(0, 0, 0, $i, 1, $year)); } // print the dates, just as a check for ($i = 0; $i count($dt); $i++) { print $dt[$i] . br\n; } This gives you a decending array from the current 1st of the month to twelve months prior. The $dt array has mm/dd/yy date strings in it. Change as needed. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password field validation
Andrew Ballard wrote: On Thu, Mar 12, 2009 at 3:05 PM, Jason Todd Slack-Moehrle mailingli...@mailnewsrss.com wrote: Hi All, I have an input field with type=password. I am trying to do some error checking to see if the user puts a value in after they submit the form (i.e not left it blank) Here is what I have: on form: Password: input id=PASSWORD name=PASSWORD type=password size=15 In PHP error checking: if (empty($_POST[PASSSWORD])) { $GERROR=TRUE;} even though I am putting characters in the field before I submit I am always getting TRUE returned. This same tactic works for other fields I have that I need to make sure they put values in, just I have never done this before with a password field. What am I doing wrong? I just want to make sure they put something there! -Jason If that's a direct copy/paste from your actual code, there is an extra S in PASSWORD. Also, you should enclose the array key in quotes: if (empty($_POST['PASSWORD'])) { $GERROR='TRUE'; } Andrew try if trim() gives you any different result: if (empty(trim($_POST['PASSWORD']))) { $GERROR='TRUE'; } afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5.2.9 - 5.2.9-1 and curl
Andrew Ballard schreef: On Thu, Mar 12, 2009 at 12:39 PM, Niki u...@domain.invalid wrote: Jochem Maas ha scritto: essentially, yes. note that if someone can upload a script and run it, a bug in curl in the least of your worries. you have already been owned. Yes, obviously. :D I agree with you. :) the curl issue is more pertinent to situations where one is using curl with CURLOPT_FOLLOWLOCATION (which seems like you'd want to use it normally) and an attacker has some idea about how to be on the receiving end of the curl call ... there by allowing them to make your curl call eat some nasty url (which may cause you to disclose sensitive info the the callee, that was intended, for example, for a ligitemate webservice ... at least that's the way I understand it (hopefully someone will correct me if I've got my wires crossed) I'm not so sure that I've understood... The attack could be successful when libcurl extension is activated and there a php page on the server that accepts an URL from the client passing it to cURL function. Is it correct? If so, I think this could be considered only as an example of awful programming. Isn't it? yes, but the problem could also be due to DNS spoofing or some hijacking technique used on the server that one is talking to via curl, i.e. it's likely not something you can necessarily control via your own code. P.S. please use a valid email address. I never use valid e-mail address in order to protect me from spam. If there is a sort of manifesto that users must follow to send messages here I will surely specify my true e-mail address. Thank you very much again! ;) Not a manifesto, but the standard advice given to people who post to this list is to use Reply-All when replying to the list. If your address is invalid, people will have to manually remove it from the list of recipients or else they will get a bounce response when it tries to send to your u...@domain.invalid address. which is annoying. people are fickle, you'd rather they didn't skip past your questions. we use Reply-All because hitting Reply doesn't reply to the list but to the OP ... and discussions should generally stay on the list. it basically comes down to 'just live with it', the spam that is, and make sure you have some decent filtering in place. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password field validation
if (empty($_POST[PASSSWORD])) { $GERROR=TRUE;} If that's a direct copy/paste from your actual code, there is an extra S in PASSWORD. Also, you should enclose the array key in quotes: if (empty($_POST['PASSWORD'])) { $GERROR='TRUE'; } It is official I am a DOPE! Thank you, yes, I did not see the SSS in an hour of looking! Why enclose in quotes? I have never done this! -Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password field validation
Afan Pasalic schreef: Andrew Ballard wrote: On Thu, Mar 12, 2009 at 3:05 PM, Jason Todd Slack-Moehrle mailingli...@mailnewsrss.com wrote: Hi All, I have an input field with type=password. I am trying to do some error checking to see if the user puts a value in after they submit the form (i.e not left it blank) Here is what I have: on form: Password: input id=PASSWORD name=PASSWORD type=password size=15 In PHP error checking: if (empty($_POST[PASSSWORD])) { $GERROR=TRUE;} even though I am putting characters in the field before I submit I am always getting TRUE returned. This same tactic works for other fields I have that I need to make sure they put values in, just I have never done this before with a password field. What am I doing wrong? I just want to make sure they put something there! -Jason If that's a direct copy/paste from your actual code, there is an extra S in PASSWORD. Also, you should enclose the array key in quotes: if (empty($_POST['PASSWORD'])) { $GERROR='TRUE'; } Andrew try if trim() gives you any different result: if (empty(trim($_POST['PASSWORD']))) { $GERROR='TRUE'; } definitely gives a different result. $ php -r ' $r = ; var_dump(empty(trim($r)));' PHP Fatal error: Can't use function return value in write context in Command line code on line 2 you can only pass variables to empty() *not* expressions. afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password field validation
On Thu, Mar 12, 2009 at 2:39 PM, Jason Todd Slack-Moehrle mailingli...@mailnewsrss.com wrote: if (empty($_POST[PASSSWORD])) { $GERROR=TRUE;} If that's a direct copy/paste from your actual code, there is an extra S in PASSWORD. Also, you should enclose the array key in quotes: if (empty($_POST['PASSWORD'])) { $GERROR='TRUE'; } It is official I am a DOPE! Thank you, yes, I did not see the SSS in an hour of looking! Why enclose in quotes? I have never done this! Because if it's not in quotes, you run the risk of colliding with one of PHP's reserved words/constants/etc. -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password field validation
Jochem Maas wrote: Afan Pasalic schreef: Andrew Ballard wrote: On Thu, Mar 12, 2009 at 3:05 PM, Jason Todd Slack-Moehrle mailingli...@mailnewsrss.com wrote: Hi All, I have an input field with type=password. I am trying to do some error checking to see if the user puts a value in after they submit the form (i.e not left it blank) Here is what I have: on form: Password: input id=PASSWORD name=PASSWORD type=password size=15 In PHP error checking: if (empty($_POST[PASSSWORD])) { $GERROR=TRUE;} even though I am putting characters in the field before I submit I am always getting TRUE returned. This same tactic works for other fields I have that I need to make sure they put values in, just I have never done this before with a password field. What am I doing wrong? I just want to make sure they put something there! -Jason If that's a direct copy/paste from your actual code, there is an extra S in PASSWORD. Also, you should enclose the array key in quotes: if (empty($_POST['PASSWORD'])) { $GERROR='TRUE'; } Andrew try if trim() gives you any different result: if (empty(trim($_POST['PASSWORD']))) { $GERROR='TRUE'; } definitely gives a different result. $ php -r ' $r = ; var_dump(empty(trim($r)));' PHP Fatal error: Can't use function return value in write context in Command line code on line 2 you can only pass variables to empty() *not* expressions. :-) yup... didn't think that way... though, I was giving an idea $password = trim($_POST['PASSWORD']); if (empty($password) { $GERROR='TRUE'; } ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password field validation
On Thu, Mar 12, 2009 at 3:39 PM, Jason Todd Slack-Moehrle mailingli...@mailnewsrss.com wrote: if (empty($_POST[PASSSWORD])) { $GERROR=TRUE;} If that's a direct copy/paste from your actual code, there is an extra S in PASSWORD. Also, you should enclose the array key in quotes: if (empty($_POST['PASSWORD'])) { $GERROR='TRUE'; } It is official I am a DOPE! Thank you, yes, I did not see the SSS in an hour of looking! Why enclose in quotes? I have never done this! -Jason If you don't enclose them in quotes, PHP first looks for a constant with that name. Thus, it the constant PASSWORD was defined as 'some silly string', your code would evaluate to $_POST['some silly string'] instead of the string 'PASSWORD' that you probably intended it to use. That, and it generates an E_NOTICE. On a production server, these are usually hidden from public view, but it is still good practice to avoid them. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password field validation
haliphax wrote: On Thu, Mar 12, 2009 at 2:39 PM, Jason Todd Slack-Moehrle mailingli...@mailnewsrss.com wrote: if (empty($_POST[PASSSWORD])) { $GERROR=TRUE;} If that's a direct copy/paste from your actual code, there is an extra S in PASSWORD. Also, you should enclose the array key in quotes: if (empty($_POST['PASSWORD'])) { $GERROR='TRUE'; } It is official I am a DOPE! Thank you, yes, I did not see the SSS in an hour of looking! Why enclose in quotes? I have never done this! Because if it's not in quotes, you run the risk of colliding with one of PHP's reserved words/constants/etc. I would use $GERROR = false; if (empty($_POST['PASSWORD'])) { $GERROR = true;} -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Knowledge Base software - looking for opinions
http://puresw.com/products/lore/ - paid http://www.knowledgebase-script.com/ - paid http://68kb.com/ - free Free is good. Just needs to be basic, nothing crazy. A Wiki -almost- meets the needs but a) I hate wikis and b) they don't match up 100% -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password field validation
prueba con trim() : $pass=trim($_POST[PASSSWORD]); if (empty($pass)) { $GERROR=TRUE; } Atte. Rodrigo (09) 7 7996571 On Thu, Mar 12, 2009 at 4:05 PM, Jason Todd Slack-Moehrle mailingli...@mailnewsrss.com wrote: Hi All, I have an input field with type=password. I am trying to do some error checking to see if the user puts a value in after they submit the form (i.e not left it blank) Here is what I have: on form: Password: input id=PASSWORD name=PASSWORD type=password size=15 In PHP error checking: if (empty($_POST[PASSSWORD])) { $GERROR=TRUE;} even though I am putting characters in the field before I submit I am always getting TRUE returned. This same tactic works for other fields I have that I need to make sure they put values in, just I have never done this before with a password field. What am I doing wrong? I just want to make sure they put something there! -Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Knowledge Base software - looking for opinions
On Thu, Mar 12, 2009 at 2:55 PM, mike mike...@gmail.com wrote: http://puresw.com/products/lore/ - paid http://www.knowledgebase-script.com/ - paid http://68kb.com/ - free Free is good. Just needs to be basic, nothing crazy. A Wiki -almost- meets the needs but a) I hate wikis and b) they don't match up 100% -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Have you considered TRAC? I know it wasn't built specifically for Knowledge Base articles, but it can be leveraged as such--and has been by many organizations. -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Knowledge Base software - looking for opinions
Yeah, I have.. but it's just another wiki. Does integrate with its own style of bug tracking + svn, but I think an actual KB system would be neat. Especially if it had the capability to have page level security. So I can make KB articles just for admins... On Thu, Mar 12, 2009 at 1:05 PM, haliphax halip...@gmail.com wrote: On Thu, Mar 12, 2009 at 2:55 PM, mike mike...@gmail.com wrote: http://puresw.com/products/lore/ - paid http://www.knowledgebase-script.com/ - paid http://68kb.com/ - free Free is good. Just needs to be basic, nothing crazy. A Wiki -almost- meets the needs but a) I hate wikis and b) they don't match up 100% -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Have you considered TRAC? I know it wasn't built specifically for Knowledge Base articles, but it can be leveraged as such--and has been by many organizations. -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password field validation
On Thu, Mar 12, 2009 at 16:04, Rodrigo Escares rodrigo.esca...@gmail.com wrote: prueba con trim() : $pass=trim($_POST[PASSSWORD]); if (empty($pass)) { $GERROR=TRUE; } Incorrecto, Rodrigo. Tambien, utilice por favor solamente el ingles en esta lista --- usted puede encontrar la lista de usuario espanola en: http://php.net/mailinglists iGracias! -- /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] Copy Non-Text file from One Server to Another Issues
Date: Thu, 12 Mar 2009 14:55:52 -0400 Subject: Re: [PHP] Copy Non-Text file from One Server to Another Issues From: danbr...@php.net To: aj...@alumni.iu.edu CC: php-general@lists.php.net On Thu, Mar 12, 2009 at 14:51, Alice Wei aj...@alumni.iu.edu wrote: Warning: file_get_contents() expects parameter 1 to be string, resource given in C:\Inetpub\wwwroot\test\hello.php on line 18 Freshman mistake. $file2 = fopen($copydir . /play.txt, w+); You're trying to read a data stream in file_get_contents() that was opened with fopen(). Don't. Instead, replace the line of code above with: $file2 = $copydir.'/play.txt'; and then RTFM on how to use file_get_contents(). -- /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 Hi, Daniel: Thanks, it turned out that other than using your suggestion, it turned out that using copy() works great. However, is it possible for me not to use the actual physical url as I have provided in my code to access the information I intend to copy? My goal is to be able to search through the remote directory, and find the matched files of a certain format and copy it to another server. Is this possible? Alice _ Check the weather nationwide with MSN Search: Try it now! http://search.msn.com/results.aspx?q=weatherFORM=WLMTAG
[PHP] Replies to list - Was (Re: [PHP] PHP 5.2.9 - 5.2.9-1 and curl)
Jochem Maas wrote: we use Reply-All because hitting Reply doesn't reply to the list but to the OP ... and discussions should generally stay on the list. This is true unless you're reading the list as a newsgroup. :) -- Micah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Knowledge Base software - looking for opinions
On Thu, 2009-03-12 at 13:24 -0700, mike wrote: Yeah, I have.. but it's just another wiki. Does integrate with its own style of bug tracking + svn, but I think an actual KB system would be neat. Especially if it had the capability to have page level security. So I can make KB articles just for admins... On Thu, Mar 12, 2009 at 1:05 PM, haliphax halip...@gmail.com wrote: On Thu, Mar 12, 2009 at 2:55 PM, mike mike...@gmail.com wrote: http://puresw.com/products/lore/ - paid http://www.knowledgebase-script.com/ - paid http://68kb.com/ - free Free is good. Just needs to be basic, nothing crazy. A Wiki -almost- meets the needs but a) I hate wikis and b) they don't match up 100% -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Have you considered TRAC? I know it wasn't built specifically for Knowledge Base articles, but it can be leveraged as such--and has been by many organizations. -- // Todd I'm looking for something similar myself to implement at work as a way of documenting things we need. I've lost count of the number of times someone has gone on holiday only for us to then find out that they were the only one with access details to this server or that system! I've already set up Mantis at work, and had considered using the docs section of that, but I think the documentation we're likely to need will go beyond the project scope, and we might need some way of linking documents together in a mesh-type way. Does anyone use anything like this already? Sorry if it seems I've hijacked this thread, but I felt I wasn't deviating from the topic really... :p Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Knowledge Base software - looking for opinions
that's kind of what i was going with here. a general purpose knowledgebase, and i can organize info hierarchically, and also be searchable, but also have the ability to limit pages to only specific user groups, so i can put in sensitive server details and such only admins can see.. On Thu, Mar 12, 2009 at 1:32 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Thu, 2009-03-12 at 13:24 -0700, mike wrote: Yeah, I have.. but it's just another wiki. Does integrate with its own style of bug tracking + svn, but I think an actual KB system would be neat. Especially if it had the capability to have page level security. So I can make KB articles just for admins... On Thu, Mar 12, 2009 at 1:05 PM, haliphax halip...@gmail.com wrote: On Thu, Mar 12, 2009 at 2:55 PM, mike mike...@gmail.com wrote: http://puresw.com/products/lore/ - paid http://www.knowledgebase-script.com/ - paid http://68kb.com/ - free Free is good. Just needs to be basic, nothing crazy. A Wiki -almost- meets the needs but a) I hate wikis and b) they don't match up 100% -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Have you considered TRAC? I know it wasn't built specifically for Knowledge Base articles, but it can be leveraged as such--and has been by many organizations. -- // Todd I'm looking for something similar myself to implement at work as a way of documenting things we need. I've lost count of the number of times someone has gone on holiday only for us to then find out that they were the only one with access details to this server or that system! I've already set up Mantis at work, and had considered using the docs section of that, but I think the documentation we're likely to need will go beyond the project scope, and we might need some way of linking documents together in a mesh-type way. Does anyone use anything like this already? Sorry if it seems I've hijacked this thread, but I felt I wasn't deviating from the topic really... :p Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Knowledge Base software - looking for opinions
On Thu, 2009-03-12 at 13:32 -0700, mike wrote: that's kind of what i was going with here. a general purpose knowledgebase, and i can organize info hierarchically, and also be searchable, but also have the ability to limit pages to only specific user groups, so i can put in sensitive server details and such only admins can see.. On Thu, Mar 12, 2009 at 1:32 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Thu, 2009-03-12 at 13:24 -0700, mike wrote: Yeah, I have.. but it's just another wiki. Does integrate with its own style of bug tracking + svn, but I think an actual KB system would be neat. Especially if it had the capability to have page level security. So I can make KB articles just for admins... On Thu, Mar 12, 2009 at 1:05 PM, haliphax halip...@gmail.com wrote: On Thu, Mar 12, 2009 at 2:55 PM, mike mike...@gmail.com wrote: http://puresw.com/products/lore/ - paid http://www.knowledgebase-script.com/ - paid http://68kb.com/ - free Free is good. Just needs to be basic, nothing crazy. A Wiki -almost- meets the needs but a) I hate wikis and b) they don't match up 100% -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Have you considered TRAC? I know it wasn't built specifically for Knowledge Base articles, but it can be leveraged as such--and has been by many organizations. -- // Todd I'm looking for something similar myself to implement at work as a way of documenting things we need. I've lost count of the number of times someone has gone on holiday only for us to then find out that they were the only one with access details to this server or that system! I've already set up Mantis at work, and had considered using the docs section of that, but I think the documentation we're likely to need will go beyond the project scope, and we might need some way of linking documents together in a mesh-type way. Does anyone use anything like this already? Sorry if it seems I've hijacked this thread, but I felt I wasn't deviating from the topic really... :p Ash www.ashleysheridan.co.uk Yeah, something just like that. I didn't want to have to go to all the effort of knocking something up myself which will never be used in the future by anyone at work! Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Knowledge Base software - looking for opinions
On Thu, Mar 12, 2009 at 3:32 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Thu, 2009-03-12 at 13:24 -0700, mike wrote: Yeah, I have.. but it's just another wiki. Does integrate with its own style of bug tracking + svn, but I think an actual KB system would be neat. Especially if it had the capability to have page level security. So I can make KB articles just for admins... On Thu, Mar 12, 2009 at 1:05 PM, haliphax halip...@gmail.com wrote: On Thu, Mar 12, 2009 at 2:55 PM, mike mike...@gmail.com wrote: http://puresw.com/products/lore/ - paid http://www.knowledgebase-script.com/ - paid http://68kb.com/ - free Free is good. Just needs to be basic, nothing crazy. A Wiki -almost- meets the needs but a) I hate wikis and b) they don't match up 100% -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Have you considered TRAC? I know it wasn't built specifically for Knowledge Base articles, but it can be leveraged as such--and has been by many organizations. -- // Todd I'm looking for something similar myself to implement at work as a way of documenting things we need. I've lost count of the number of times someone has gone on holiday only for us to then find out that they were the only one with access details to this server or that system! I've already set up Mantis at work, and had considered using the docs section of that, but I think the documentation we're likely to need will go beyond the project scope, and we might need some way of linking documents together in a mesh-type way. Does anyone use anything like this already? Sorry if it seems I've hijacked this thread, but I felt I wasn't deviating from the topic really... :p http://wkb.sourceforge.net/ http://kbpublisher.sourceforge.net/ http://twiki.org/ (wiki with granular security) http://www.smartertools.com/SmarterTrack/Free-Customer-Service-Software.aspx (single-user) http://freemind.sourceforge.net/ http://freshmeat.net/projects/phpkb/ -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Knowledge Base software - looking for opinions
On Thu, Mar 12, 2009 at 12:55:54PM -0700, mike wrote: http://puresw.com/products/lore/ - paid http://www.knowledgebase-script.com/ - paid http://68kb.com/ - free Free is good. Just needs to be basic, nothing crazy. A Wiki -almost- meets the needs but a) I hate wikis and b) they don't match up 100% Out of curiosity, why do you dislike wikis? Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Knowledge Base software - looking for opinions
On Thu, Mar 12, 2009 at 3:44 PM, Paul M Foster pa...@quillandmouse.com wrote: On Thu, Mar 12, 2009 at 12:55:54PM -0700, mike wrote: http://puresw.com/products/lore/ - paid http://www.knowledgebase-script.com/ - paid http://68kb.com/ - free Free is good. Just needs to be basic, nothing crazy. A Wiki -almost- meets the needs but a) I hate wikis and b) they don't match up 100% Out of curiosity, why do you dislike wikis? It may be the lack of access permissions in a lot of the wiki systems out there right now... though some of them have an access control layer (such as TWiki). -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Date List Newbie Problem
On 3/12/2009 9:39 AM, TG tg-...@gryffyndevelopment.com wrote: $currmonth = date(m); for ($i = 1; $i = 11; $i++) { $m[$i] = date(m/d/y), mktime(0,0,0,$currmonth-$i, 1, 2009)); } Something like that. mktime() is remarkably flexible. If you start on month 3 and you subtract 5, you get month = -2. So that would be -2/1/2009, which mktime will translate to 11/1/2008. This is totally off the top of my head, but you get the idea. Works with days and years too. Sometimes it's useful when going backwards and not sure how many days the previous month had (without doing another call to find out). -TG SOLVED - Thanks so much Andrew TG From your examples - I was able to create this working table going back 2 years - thanks again! table border=1 cellspacing=2 cellpadding=2 tr tdDates/td /tr ?php $currmonth = date(m); $curryear = date(y); $i = 0; do { ? tr td?php $m[$i] = date(m/d/y, mktime(0,0,0,$currmonth-$i, 1, $curryear)); echo $m[$i].'br /'; $i++ ? /td /tr ?php } while ($i 25); ? /table -- Thanks - RevDave Cool @ hosting4days . com [db-lists 09] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Date List Newbie Problem
On 3/12/2009 12:25 PM, Paul M Foster pa...@quillandmouse.com wrote: Crap, I hit the wrong button and sent this only to the OP... On Thu, Mar 12, 2009 at 09:24:48AM -0700, revDAVE wrote: Thanks for your help Paul - that makes sense! Here is working code to do it better: // get your starting date $darray = getdate(); $month = $darray['mon']; $year = $darray['year']; // create your months $dt = array(); for ($i = $month; $i = 1; $i--) { $dt[] = date('m/d/y', mktime(0, 0, 0, $i, 1, $year)); } $year--; for ($i = 12; $i $month; $i--) { $dt[] = date('m/d/y', mktime(0, 0, 0, $i, 1, $year)); } // print the dates, just as a check for ($i = 0; $i count($dt); $i++) { print $dt[$i] . br\n; } This gives you a decending array from the current 1st of the month to twelve months prior. The $dt array has mm/dd/yy date strings in it. Change as needed. Paul -- Thanks - RevDave Cool @ hosting4days . com [db-lists 09] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Knowledge Base software - looking for opinions
http://kbpublisher.sourceforge.net/ - actually is almost perfect i think but $398 ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Daily and Weekly Calendar classes
Hi All, Does anyone have classes for creating a nice daily calendar? I can put the data in MySQL and be queried, etc. Something that when I add events to the calendar it puts them in the right time slot, etc, etc. I can do the rest of the coding Free is best! -Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] htmlentities is incomplete: does not cover rsquo etc
The string function htmlentities seems to have very incomplete coverage of the HTML entities listed in the HTML 4 spec. For example, it does not know about rsquo, lsquo, rdquo, ldquo, etc. This is confirmed by looking at the output of get_html_translation_table, which does not list these entities. My impression is that it covers those HTML entities that are in ISO-8859-1, but not the others. Is this deliberate? If so, the Manual is misleading because it suggests that all HTML entities are covered. Otherwise, is this a bug? Eddie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Daily and Weekly Calendar classes
On Thu, Mar 12, 2009 at 9:05 PM, Jason Todd Slack-Moehrle mailingli...@mailnewsrss.com wrote: Hi All, Does anyone have classes for creating a nice daily calendar? I can put the data in MySQL and be queried, etc. Something that when I add events to the calendar it puts them in the right time slot, etc, etc. I can do the rest of the coding Free is best! -Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php check www.hotscripts.com www.phpclasses.org http://sourceforge.net -- Bastien Cat, the other other white meat
Re: [PHP] RE: non-auto increment question
PJ wrote: am resending as this was erroneously ccd to mysql. sorry! Ashley Sheridan wrote: On Thu, 2009-02-26 at 11:27 -0500, PJ wrote: Jerry Schwartz wrote: Being rather new to all this, I understood from the MySql manual that the auto_increment is to b e used immediately after an insertion not intermittently. My application is for administrators (the site owner designates) to update the database from and administration directory, accessed by user/password login... so there's really very little possibility of 2 people accessing at the same time. By using MAX + 1 I keep the id number in the $idIn and can reuse it in other INSERTS [JS] Are you looking for something like LAST_INSERT_ID()? If you INSERT a record that has an auto-increment field, you can retrieve the value that got inserted with SELECT LAST_INSERT_ID(). It is connection-specific, so you'll always have your own value. You can then save it to reuse, either as a session variable or (more easily) as a hidden field on your form. Thanks, Jerry, You hit the nail on the head.:) To refine my problem (and reduce my ignorance),here's what is happening on the form page: There is a series of INSERTs. The first inserts all the columns of book table except for the id, which I do not specify as it if auto-insert. In subsequent tables I have to reference the book.id (for transitional tables like book_author(refers authors to book) etc. If I understand it correctly, I must retrieve (SELECT LAST_INSERT_ID()) after the first INSERT and before the following insert; and save the id as a string ($id)...e.g. $sql = SELECT LAST_INSERT_ID() AS $id I need clarification on the AS $id - should this be simply id(does this have to be turned into a value into $id or does $id contain the value? And how do I retrieve it to use the returned value for the next $sql = INSERT ... - in other words, is the id or $id available for the next directive or do I have to do something like $id = id? I'm trying to figure this out with some trials but my insert does not work from a php file - but it works from command-line... that's another post. Here's how I mostly do it (albeit simplified): $query = INSERT INTO `sometable`(`title`,`content`) VALUES('$title','$content'); $result = mysql_query($query); $autoId = mysql_insert_id($result); $query = INSERT INTO `another_table`(`link_id`,`value`) VALUES($autoId,'$value'); $result = mysql_query($query); No need to call another query to retrieve the last inserted id, as it is tied to the last query executed within this session. Ash www.ashleysheridan.co.uk For some reason or other $autoId = mysql_insert_id($result); just does not work for me... Yet some of the data is inserted correctly... I did find that it does not work on tables that are empty... so you can't start with an empty table. I entered data it still did not work. I tried on another duplicate database... doesn't work. I have checked double checked the database, I have added checks to see what is returned and the returns are 0 or null - as I get different responses for slightly different functions. sessions is on mysql is 5.1.28 php5 here's what is parsed: else { $sql1 = INSERT INTO book ( title, sub_title, descr, comment, bk_cover, copyright, ISBN, language, sellers ) VALUES ('$titleIN', '$sub_titleIN', '$descrIN', '$commentIN', '$bk_coverIN', '$copyrightIN', '$ISBNIN', '$languageIN', '$sellersIN'); $result1 = mysql_query($sql1, $db); $autoid = mysql_insert_id($result1); $sql2 = INSERT INTO author (first_name, last_name) VALUES ('$first_nameIN', '$last_nameIN'); $result2 = mysql_query($sql2, $db); $authorID = mysql_insert_id($result2); $sql2a = INSERT INTO book_author (authID, bookID, ordinal) VALUES ( '$authorID', '$autoid', '1'); $result2a = mysql_query($sql2a, $db); $sql2b = INSERT INTO author (first_name, last_name) VALUES ('$first_name2IN', '$last_name2IN'); $result2b = mysql_query($sql2b, $db); $author2ID = mysql_insert_id($result2b); $sql2c = INSERT INTO book_author (authID, bookID, ordinal) VALUES ( '$author2ID', '$autoid', '2'); $result2c = mysql_query($sql2c, $db); $sql3 = INSERT INTO publishers (publisher) VALUES ('$publisherIN'); $result3 = mysql_query($sql3, $db); $publisherID = mysql_insert_id($result3); $sql3a = INSERT INTO book_publisher (bookID, publishers_id) VALUES ( '$autoid', '$publisherID' ); $result3a = mysql_query($sql3a, $db); foreach($_POST['categoriesIN'] as $category){ $sql4 = INSERT INTO book_categories (book_id, categories_id) VALUES ($autoid, $category); $result4 = mysql_query($sql4,$db); } echo $autoid; // shows: blank echo $authorID; // shows: blank echo $author2ID; // shows: blank echo $publisherID; // shows: blank
[PHP] Re: [PHP-DEV] How expensive are function_exists() calls?
For templating ideas ... Would bytecode caches (APC) be able to work properly with this: function print_something($args, $output = 'html') { switch($output) { 'iphone': print_something_iphone($args); break; default: print_something_html($args); break; } } or something like this: function print_something($args, $output = 'html') { if(function_exists('print_something_'.$output)) { call_user_func('print_something_'.$output); } } On Wed, Mar 4, 2009 at 12:45 PM, mike mike...@gmail.com wrote: On Wed, Mar 4, 2009 at 4:01 AM, Jochem Maas joc...@iamjochem.com wrote: ..not an internals question me thinks ... redirecting to generals mailing list Actually, I do think it is somewhat internals related. I want to know from the internals/experts angle if this is a good function to be relying on, or if it is one of those things like the @ operator which I've been told is expensive and to me is one of those things to stay away from. Now if this breaks opcode caches like APC, I will have to find another way. Also - I write procedural, not OOP. So that won't help here. Would creating functions such as output_foo_html() output_foo_rss() output_foo_json() Then depending on the output, using something like this? Would this be breaking opcode caches as well then? if(function_exists('output_foo_'.$format)) { call_user_func('output_foo_'.$format); } else { output_foo_html(); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [PHP-DEV] How expensive are function_exists() calls?
On Thu, 2009-03-12 at 21:55 -0700, mike wrote: For templating ideas ... Would bytecode caches (APC) be able to work properly with this: function print_something($args, $output = 'html') { switch($output) { 'iphone': print_something_iphone($args); break; default: print_something_html($args); break; } } or something like this: function print_something($args, $output = 'html') { if(function_exists('print_something_'.$output)) { call_user_func('print_something_'.$output); } } I thought we covered a question just like this a week ago... yes this will not pose a problem for a bytecode cache. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [PHP-DEV] How expensive are function_exists() calls?
On Thu, Mar 12, 2009 at 10:10 PM, Robert Cummings rob...@interjinn.com wrote: I thought we covered a question just like this a week ago... yes this will not pose a problem for a bytecode cache. Apologies. I saw an example of some OOP thing from internals before it moved to -general. So even using call_user_func() with dynamic functions won't break the usefulness of APC? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [PHP-DEV] How expensive are function_exists() calls?
On Thu, 2009-03-12 at 22:27 -0700, mike wrote: On Thu, Mar 12, 2009 at 10:10 PM, Robert Cummings rob...@interjinn.com wrote: I thought we covered a question just like this a week ago... yes this will not pose a problem for a bytecode cache. Apologies. I saw an example of some OOP thing from internals before it moved to -general. So even using call_user_func() with dynamic functions won't break the usefulness of APC? The only thing that should defeat the usefulness of a bytecode cache is the use of eval since the cache has no reference point upon which to determine if the eval'd code has been previously compiled and has changed since. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php