Re: [PHP] Template system in PHP
REST is the new SOAP. Yaml is the new XML. I'm guessing this news just hasn't made it into any PHP frameworks yet. that's a very oversimplifying statement. REST is good for small requests and stuff but there are cases when SOAP is needed (at least in cases when you have to connect to some external app with SOAP interface) YAML is good for configuration files and stuff like that, but in no way is replacement for XML, which is much more flexible and has the DOM API which is very powerful. and by the way, symfony has YAML configuration files and a plugin for REST services. greets Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Template system in PHP
On Thu, 2008-02-14 at 09:29 +0100, Zoltán Németh wrote: and by the way, symfony has YAML configuration files and a plugin for REST services. and Chisimba does YAML configs in the blog module, REST, SOAP and XML-RPC services as well as a whole whack of XML-ish things. --Paul -- . | Chisimba PHP5 Framework - http://avoir.uwc.ac.za | :: All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XSLTProcessor without validation
Hi, i still got no answer. Maybe i did not see it, altough i'm trying to read any single post. But may be i overlooked it due to high traffic. So now i have set up a filter (hopefully) copying answers to another folder. Here is the question: Is it possible to disable validation when using XSLTProcessor? If yes, how? When i use xsltproc, the command line tool for the libxslt, i can use the switch --novalid to subpress validation. This makes a huge difference in speed. Without validation it is fast enough. With validation it takes far too long to be acceptable. So how do i use XSLTProcessor from within PHP to achieve the same result as if using xsltproc --novalid? Regards Siegfried -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static variable in a class method
Pauau schreef: I have a class method which declares a static variable within.However, across all the instances of the class, the current value on that variable replicates. Is it the intended functionality? Example: class A {public function foo() {static $i=0;$i++;}}$obj1 = new A();$obj1-foo(); //$i = 1 $obj2 = new A();$obj2-foo(); //$i = 2 where I think it should be 1, becaue it's a new instance. the engine doesn't give 2 hoots about what you think it should be of course. 'static' doesn't do what you think. chances are you want to use a private instance property: ?php class Foo { private $i = 0; public function bar() { echo $this-i, \n; $this-i++; } } $a = new Foo; $b = new Foo; $a-bar(); $a-bar(); $a-bar(); $b-bar(); $b-bar(); ? do please read the OO sections of the manual, some functionality, although named similarly to other languages, works quite differently - you'll avoid alot of assumption biting you in the a$$. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static variable in a class method
Nathan Nobbe schreef: On Feb 13, 2008 8:44 PM, Nirmalya Lahiri [EMAIL PROTECTED] wrote: --- Pauau [EMAIL PROTECTED] wrote: I have a class method which declares a static variable within.However, across all the instances of the class, the current value on that variable replicates. Is it the intended functionality? Example: class A { public function foo() {static $i=0;$i++;}}$obj1 = new A();$obj1-foo(); //$i = 1 $obj2 = new A();$obj2-foo(); //$i = 2 where I think it should be 1, becaue it's a new instance. Pauau, Please visit the link below for help.. http://www.php.net/manual/en/language.oop5.static.php what you are using is potentially not what you think it is. you are using a 'static variable' which is not a static class member. actually it pretty much *is* the same - the static class member will exhibit the same behaviour, only the scope is different. you can find the doc on static variables here, http://www.php.net/manual/en/language.variables.scope.php im not sure if their behavior is well defined when they are used in classes, or objects. behaviour is indentical to usage inside standalone functions. as Nirmalya, has alluded, you should check out the docs on static class members. im sure that you can achieve whatever you need to by using some combination of static class members and instance variables. -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session and Multi Server Architecture
On Mon, February 11, 2008 1:53 pm, Per Jessen wrote: Paul Scott wrote: Either that or in a db, but if you are already in clustering, you probably have a memcached instance already right? Am I right in thinking that memcached will replicate session information across a cluster, and that your application is only safe as long as you stick _all_ session-related info in $_SESSION? Yes and yes... Tho I suppose you might have some extra info in the replicated DB about the user that would not be crucial to be up-to-the-second accurate that could be considered part of your session data... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Copying 1000s files and showing the progress
Ritesh Nadhani schreef: On Feb 13, 2008 6:03 PM, Richard Lynch [EMAIL PROTECTED] wrote: On Wed, February 13, 2008 4:28 am, Ritesh Nadhani wrote: I have a situation where I have to copy something like 1000 files one by one to a temporary folder. Tar it using the system tar command and let the user download the tar file. Now while the copy is going on at server, I want to show some progress to the user at client side. Most of the tutorial I found on net was about showing progress while a file is being uploaded from client to server. In this case the client has the info but for my case, the client has no info. A similar was problem was solved at http://menno.b10m.net/blog/blosxom/perl/cgi-upload-hook.html but its in PERL and uses some form of hook. I have no clue how to do it in PHP. Any clues or right direction would be awesome. First of all, don't do that. :-) Instead, set up a job system of what should be copied/tarred, and then notify the user via email. Don't make the user sit there waiting for the computer! If you absolutely HAVE to do this due to a pointy-haired boss... ?php $path = /full/path/to/1000s/of/files; $dir = opendir($path) or die(Change that path); $tmp = tmpname(); //or whatever... while (($file = readdir($dir)) !== false){ echo $filebr /\n; copy($path/$file, /tmp/$tmp/$path); } exec(tar -cf /tmp/$tmp.tar /tmp/$tmp/, $output, $error); echo implode(br /\n, $output); if ($error){ //handle error here! die(OS Error: $error); } ? shameless plug: //handle error here could perhaps use this: http://l-i-e.com/perror. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? I was actually doing what you just gave the code for. As of now, I was doing something like: for file in files: copy from source to folder echo Copying files encapsulated in ob_flush() tar the file which hardly takes time on the filessyetm but does take some time Provide the link to the tar So at the client side it was like: Copying file #1 Copying file #2 Download link I though I could apply some funkiness to it by using some AJAX based progress bar for which the example showed some sort of hooking and all which I thought was too much for such a job. I will talk to my boss regarding this and do the necessary. BTW, whats the issue with AJAX based approach? Any particular reason other then it seems to be a hack rather then an elegant solution (which is more then enough reason not to implement it...but I wonder if there is a technical reason to it too)? the problem with the AJAX approach is the fact that there is absolutely no reason for a user to sit staring at the screen. hit 'Go' get an email when it's done, do something else in the mean time. of course a PHB might demand functionality that gives him/her an excuse to watch a progress bar ... in which case why not waste man hours making it a funky web2.0 deal ... heck go the whole hog and use 'comet technique' to push update info to the browser. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generate xls file on fly
On Fri, 8 Feb 2008, Per Jessen wrote: Hiep Nguyen wrote: let say that user searched and found 10 records, in the meantime, other users may change any of these 10 records, so if we saved mysql statement and re-run mysql statement again, the result might be different. to prevent this problem, i only want to download records that returned on this page only. This is more of a caching issue - then you determine how long you want to keep the results for, and only re-run the mysql query when the results have gone stale. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php in the last couple days, i've looked into php $_SESSION and kinda get the concept. my question is can i use $_SESSION to store mysql statement? what is the pro/con to store mysql statement in $_SESSION? with $_COOKIE, i can use setrawcookie to avoid urlencoding. is ther anything similar in $_SESSION? thanks, t. hiep -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php+mail+TLS/SSL
Hi, I am using phpmailer currently to send email from my applications. My ISP is restricting the usage of email without SSL/TLS and my SMTP connections have started to fail... Any hints on the best approach to send email from php appplciations ?, I wish I could use my standard gmail/yahoo accounts like my desktop email program... Any help appreciated. Thanks. JCG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php+mail+TLS/SSL
julian wrote: I am using phpmailer currently to send email from my applications. My ISP is restricting the usage of email without SSL/TLS and my SMTP connections have started to fail... Any hints on the best approach to send email from php appplciations ?, I think the best way is to have a local MTA (e.g. postfix), to which mail()/sendmail can simply drop emails in the filesystem. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static variable in a class method
On Thu, Feb 14, 2008 at 6:37 AM, Jochem Maas [EMAIL PROTECTED] wrote: Nathan Nobbe schreef: what you are using is potentially not what you think it is. you are using a 'static variable' which is not a static class member. actually it pretty much *is* the same - the static class member will exhibit the same behaviour, only the scope is different. you can find the doc on static variables here, http://www.php.net/manual/en/language.variables.scope.php im not sure if their behavior is well defined when they are used in classes, or objects. behaviour is indentical to usage inside standalone functions. thats a gamble since there is no description of how the static keyword behaves inside class member functions. i for one will stick to static class variables and instance variables, and avoid this static variable feature altogether. -nathan
Re: [PHP] generate xls file on fly
--- Hiep Nguyen [EMAIL PROTECTED] wrote: On Fri, 8 Feb 2008, Per Jessen wrote: Hiep Nguyen wrote: let say that user searched and found 10 records, in the meantime, other users may change any of these 10 records, so if we saved mysql statement and re-run mysql statement again, the result might be different. to prevent this problem, i only want to download records that returned on this page only. This is more of a caching issue - then you determine how long you want to keep the results for, and only re-run the mysql query when the results have gone stale. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php in the last couple days, i've looked into php $_SESSION and kinda get the concept. my question is can i use $_SESSION to store mysql statement? what is the pro/con to store mysql statement in $_SESSION? with $_COOKIE, i can use setrawcookie to avoid urlencoding. is ther anything similar in $_SESSION? thanks, t. hiep Hiep, There is no need to use setraw in case of session. Because every session variable keeps its value as it is assign to it. Where as in case of cookie by default browser encode the cookie in urlencoding format. To stop this feature of browser we use setrawcookie() function. --- Nirmalya Lahiri [+91-9433113536] Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] generate xls file on fly
On Thu, Feb 14, 2008 at 9:23 AM, Hiep Nguyen [EMAIL PROTECTED] wrote: On Fri, 8 Feb 2008, Per Jessen wrote: Hiep Nguyen wrote: let say that user searched and found 10 records, in the meantime, other users may change any of these 10 records, so if we saved mysql statement and re-run mysql statement again, the result might be different. to prevent this problem, i only want to download records that returned on this page only. This is more of a caching issue - then you determine how long you want to keep the results for, and only re-run the mysql query when the results have gone stale. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php in the last couple days, i've looked into php $_SESSION and kinda get the concept. my question is can i use $_SESSION to store mysql statement? what is the pro/con to store mysql statement in $_SESSION? with $_COOKIE, i can use setrawcookie to avoid urlencoding. is ther anything similar in $_SESSION? thanks, t. hiep You can easily store a SQL statement in $_SESSION since the statement is just a string. Are you asking if you can store the *result* of the statement execution in $_SESSION? You shouldn't store the SQL statement in cookies. It gives the end user way too much insight into your DB implementation if they can see the actual statement that you will be issuing to the database and it's an even bigger security risk for SQL injection than simply using raw, unescaped form input in a statement without validation! The attacker doesn't even have to think how to create a parameter to escape out of your statement - they can send you DELETE FROM mysql.user or any other wonderful thing they like. Granted, your script should not be using a db user account that has privileges to execute such a statement, but that should give you a clue that this would be a VERY bad idea. URL encoding/decoding isn't really an issue with sessions since the session data is stored internally on the server and does not have to be urlencoded to be sent between the server and the browser in an HTTP header. Andrew
[PHP] Re: Copying 1000s files and showing the progress
Am 2008-02-13 04:28:46, schrieb Ritesh Nadhani: Now while the copy is going on at server, I want to show some progress to the user at client side. Most of the tutorial I found on net was You can use a resized window (JS required) which automaticaly refresh all 2 seconds and show the status of the taring... Thanks, Greetings and nice Day Michelle Konzack Systemadministrator Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # Michelle Konzack Apt. 917 ICQ #328449886 +49/177/935194750, rue de Soultz MSN LinuxMichi +33/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com) signature.pgp Description: Digital signature
Re: [PHP] Static variable in a class method
Nathan Nobbe schreef: On Thu, Feb 14, 2008 at 6:37 AM, Jochem Maas [EMAIL PROTECTED] wrote: Nathan Nobbe schreef: what you are using is potentially not what you think it is. you are using a 'static variable' which is not a static class member. actually it pretty much *is* the same - the static class member will exhibit the same behaviour, only the scope is different. you can find the doc on static variables here, http://www.php.net/manual/en/language.variables.scope.php im not sure if their behavior is well defined when they are used in classes, or objects. behaviour is indentical to usage inside standalone functions. thats a gamble since there is no description of how the static keyword behaves inside class member functions. i for one will stick to static class variables and instance variables, and avoid this static variable feature altogether. they work the same because they are the same thing. no gamble. nada. -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Copying 1000s files and showing the progress
Jochem Maas wrote: Ritesh Nadhani schreef: On Feb 13, 2008 6:03 PM, Richard Lynch [EMAIL PROTECTED] wrote: On Wed, February 13, 2008 4:28 am, Ritesh Nadhani wrote: I have a situation where I have to copy something like 1000 files one by one to a temporary folder. Tar it using the system tar command and let the user download the tar file. Now while the copy is going on at server, I want to show some progress to the user at client side. Most of the tutorial I found on net was about showing progress while a file is being uploaded from client to server. In this case the client has the info but for my case, the client has no info. A similar was problem was solved at http://menno.b10m.net/blog/blosxom/perl/cgi-upload-hook.html but its in PERL and uses some form of hook. I have no clue how to do it in PHP. Any clues or right direction would be awesome. First of all, don't do that. :-) Instead, set up a job system of what should be copied/tarred, and then notify the user via email. Don't make the user sit there waiting for the computer! If you absolutely HAVE to do this due to a pointy-haired boss... ?php $path = /full/path/to/1000s/of/files; $dir = opendir($path) or die(Change that path); $tmp = tmpname(); //or whatever... while (($file = readdir($dir)) !== false){ echo $filebr /\n; copy($path/$file, /tmp/$tmp/$path); } exec(tar -cf /tmp/$tmp.tar /tmp/$tmp/, $output, $error); echo implode(br /\n, $output); if ($error){ //handle error here! die(OS Error: $error); } ? shameless plug: //handle error here could perhaps use this: http://l-i-e.com/perror. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? I was actually doing what you just gave the code for. As of now, I was doing something like: for file in files: copy from source to folder echo Copying files encapsulated in ob_flush() tar the file which hardly takes time on the filessyetm but does take some time Provide the link to the tar So at the client side it was like: Copying file #1 Copying file #2 Download link I though I could apply some funkiness to it by using some AJAX based progress bar for which the example showed some sort of hooking and all which I thought was too much for such a job. I will talk to my boss regarding this and do the necessary. BTW, whats the issue with AJAX based approach? Any particular reason other then it seems to be a hack rather then an elegant solution (which is more then enough reason not to implement it...but I wonder if there is a technical reason to it too)? the problem with the AJAX approach is the fact that there is absolutely no reason for a user to sit staring at the screen. hit 'Go' get an email when it's done, do something else in the mean time. of course a PHB might demand functionality that gives him/her an excuse to watch a progress bar ... in which case why not waste man hours making it a funky web2.0 deal ... heck go the whole hog and use 'comet technique' to push update info to the browser. Can't see any problem with going down the ajax route myself (depending on how many concurrent users you expect) - A simple ajax style poll every second would suffice. You could always use the fancily named yet really old comet technique aswell.. slap the script in a magic iframe and ob_flush whenever you have new data to send. To be honeswt, both are trade-offs on a technology which isn't around yet. With ajax you've got to spawn a new thread for every request (say 1 per second, 100 concurrent users, that's 100 requests per second minimum on your server) OR with comet you've got 100 long lasting worker threads going. If you do go comet, it's worth investigating mod event for apache 2.* http://httpd.apache.org/docs/2.2/mod/event.html Nath -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static variable in a class method
On Thu, Feb 14, 2008 at 9:50 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Thu, Feb 14, 2008 at 6:37 AM, Jochem Maas [EMAIL PROTECTED] wrote: Nathan Nobbe schreef: what you are using is potentially not what you think it is. you are using a 'static variable' which is not a static class member. actually it pretty much *is* the same - the static class member will exhibit the same behaviour, only the scope is different. you can find the doc on static variables here, http://www.php.net/manual/en/language.variables.scope.php im not sure if their behavior is well defined when they are used in classes, or objects. behaviour is indentical to usage inside standalone functions. thats a gamble since there is no description of how the static keyword behaves inside class member functions. i for one will stick to static class variables and instance variables, and avoid this static variable feature altogether. -nathan Just FYI the static keyword was quite popular in PHP4 for the singleton pattern. You could do something like: function getInstance() { static $instance; if (empty($instance)) { $instance = new Instance; } return $instance; } I've used it across multiple classes without any real conflicts so it was fine. Of course I wouldn't do such a thing now that I am working in 5, but I just thought I'd throw that out there. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static variable in a class method
On Thu, Feb 14, 2008 at 12:10 PM, Eric Butera [EMAIL PROTECTED] wrote: On Thu, Feb 14, 2008 at 9:50 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Thu, Feb 14, 2008 at 6:37 AM, Jochem Maas [EMAIL PROTECTED] wrote: Nathan Nobbe schreef: what you are using is potentially not what you think it is. you are using a 'static variable' which is not a static class member. actually it pretty much *is* the same - the static class member will exhibit the same behaviour, only the scope is different. you can find the doc on static variables here, http://www.php.net/manual/en/language.variables.scope.php im not sure if their behavior is well defined when they are used in classes, or objects. behaviour is indentical to usage inside standalone functions. thats a gamble since there is no description of how the static keyword behaves inside class member functions. i for one will stick to static class variables and instance variables, and avoid this static variable feature altogether. -nathan Just FYI the static keyword was quite popular in PHP4 for the singleton pattern. You could do something like: function getInstance() { static $instance; if (empty($instance)) { $instance = new Instance; } return $instance; } I've used it across multiple classes without any real conflicts so it was fine. Of course I wouldn't do such a thing now that I am working in 5, but I just thought I'd throw that out there. and im certain it was used heavily that way in php4 as well. its also great for those people who dont want to use classes in their php. i mainly avoid it as a matter of preference. all im saying from earlier, is that even if it does work inside class methods, theres no doc out there that gives the green light on such usage (at least not to my knowledge). -nathan
Re: [PHP] Copying 1000s files and showing the progress
Thanks all. I will work on all the options and let you know how it went :) On Thu, Feb 14, 2008 at 10:37 AM, Nathan Rixham [EMAIL PROTECTED] wrote: Jochem Maas wrote: Ritesh Nadhani schreef: On Feb 13, 2008 6:03 PM, Richard Lynch [EMAIL PROTECTED] wrote: On Wed, February 13, 2008 4:28 am, Ritesh Nadhani wrote: I have a situation where I have to copy something like 1000 files one by one to a temporary folder. Tar it using the system tar command and let the user download the tar file. Now while the copy is going on at server, I want to show some progress to the user at client side. Most of the tutorial I found on net was about showing progress while a file is being uploaded from client to server. In this case the client has the info but for my case, the client has no info. A similar was problem was solved at http://menno.b10m.net/blog/blosxom/perl/cgi-upload-hook.html but its in PERL and uses some form of hook. I have no clue how to do it in PHP. Any clues or right direction would be awesome. First of all, don't do that. :-) Instead, set up a job system of what should be copied/tarred, and then notify the user via email. Don't make the user sit there waiting for the computer! If you absolutely HAVE to do this due to a pointy-haired boss... ?php $path = /full/path/to/1000s/of/files; $dir = opendir($path) or die(Change that path); $tmp = tmpname(); //or whatever... while (($file = readdir($dir)) !== false){ echo $filebr /\n; copy($path/$file, /tmp/$tmp/$path); } exec(tar -cf /tmp/$tmp.tar /tmp/$tmp/, $output, $error); echo implode(br /\n, $output); if ($error){ //handle error here! die(OS Error: $error); } ? shameless plug: //handle error here could perhaps use this: http://l-i-e.com/perror. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? I was actually doing what you just gave the code for. As of now, I was doing something like: for file in files: copy from source to folder echo Copying files encapsulated in ob_flush() tar the file which hardly takes time on the filessyetm but does take some time Provide the link to the tar So at the client side it was like: Copying file #1 Copying file #2 Download link I though I could apply some funkiness to it by using some AJAX based progress bar for which the example showed some sort of hooking and all which I thought was too much for such a job. I will talk to my boss regarding this and do the necessary. BTW, whats the issue with AJAX based approach? Any particular reason other then it seems to be a hack rather then an elegant solution (which is more then enough reason not to implement it...but I wonder if there is a technical reason to it too)? the problem with the AJAX approach is the fact that there is absolutely no reason for a user to sit staring at the screen. hit 'Go' get an email when it's done, do something else in the mean time. of course a PHB might demand functionality that gives him/her an excuse to watch a progress bar ... in which case why not waste man hours making it a funky web2.0 deal ... heck go the whole hog and use 'comet technique' to push update info to the browser. Can't see any problem with going down the ajax route myself (depending on how many concurrent users you expect) - A simple ajax style poll every second would suffice. You could always use the fancily named yet really old comet technique aswell.. slap the script in a magic iframe and ob_flush whenever you have new data to send. To be honeswt, both are trade-offs on a technology which isn't around yet. With ajax you've got to spawn a new thread for every request (say 1 per second, 100 concurrent users, that's 100 requests per second minimum on your server) OR with comet you've got 100 long lasting worker threads going. If you do go comet, it's worth investigating mod event for apache 2.* http://httpd.apache.org/docs/2.2/mod/event.html Nath -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Ritesh http://www.riteshn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static variable in a class method
Nathan Nobbe wrote: On Thu, Feb 14, 2008 at 12:10 PM, Eric Butera [EMAIL PROTECTED] wrote: On Thu, Feb 14, 2008 at 9:50 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Thu, Feb 14, 2008 at 6:37 AM, Jochem Maas [EMAIL PROTECTED] wrote: Nathan Nobbe schreef: what you are using is potentially not what you think it is. you are using a 'static variable' which is not a static class member. actually it pretty much *is* the same - the static class member will exhibit the same behaviour, only the scope is different. you can find the doc on static variables here, http://www.php.net/manual/en/language.variables.scope.php im not sure if their behavior is well defined when they are used in classes, or objects. behaviour is indentical to usage inside standalone functions. thats a gamble since there is no description of how the static keyword behaves inside class member functions. i for one will stick to static class variables and instance variables, and avoid this static variable feature altogether. -nathan Just FYI the static keyword was quite popular in PHP4 for the singleton pattern. You could do something like: function getInstance() { static $instance; if (empty($instance)) { $instance = new Instance; } return $instance; } I've used it across multiple classes without any real conflicts so it was fine. Of course I wouldn't do such a thing now that I am working in 5, but I just thought I'd throw that out there. and im certain it was used heavily that way in php4 as well. its also great for those people who dont want to use classes in their php. i mainly avoid it as a matter of preference. all im saying from earlier, is that even if it does work inside class methods, theres no doc out there that gives the green light on such usage (at least not to my knowledge). -nathan static variables save your scripts repeating themselves.. class used_all_over_the_place { private static $bigArrayOfThings; public function __construct() { if (!is_array(self::$bigArrayOfThings)) { $this-complicatedMethodThatFormsArray(); } } protected function complicatedMethodThatFormsArray() { #loads of stuff that would be best not to repeat to often } } #complicatedMethodThatFormsArray is called here $myclass = new used_all_over_the_place; function something() { #complicatedMethodThatFormsArray is NOT called here $myclass = new used_all_over_the_place; } maybe I've gone ot or missed the point of this thread.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XSLTProcessor without validation
On Thu, February 14, 2008 4:24 am, Siegfried Gipp wrote: i still got no answer. Maybe i did not see it, altough i'm trying to read any single post. But may be i overlooked it due to high traffic. So now i have set up a filter (hopefully) copying answers to another folder. Here is the question: Is it possible to disable validation when using XSLTProcessor? If yes, how? When i use xsltproc, the command line tool for the libxslt, i can use the switch --novalid to subpress validation. This makes a huge difference in speed. Without validation it is fast enough. With validation it takes far too long to be acceptable. So how do i use XSLTProcessor from within PHP to achieve the same result as if using xsltproc --novalid? You may want to try using http://php.net/exec to run your command line tool and ignore the PHP one, if it won't let you turn off validation. You could also consider filing a Feature Request in http://bugs.php.net/ -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Curl doesn't handle memory stream
On Wed, February 13, 2008 8:19 pm, Nathan Nobbe wrote: On Feb 13, 2008 6:52 PM, Richard Lynch [EMAIL PROTECTED] wrote: On Wed, February 13, 2008 4:11 pm, Nathan Nobbe wrote: You may or may not want to file a bug report with curl itself, depending on whether PHP is doing the stream file handling or curl is. At a wild guess, I would expect it would be buried in curl code, not PHP code... Perhaps you can dig around here and find out for sure: http://lxr.php.net http://cvs.php.net thanks richard, even tho im not proficient w/ c ill take a look at it this weekend and see if i can make any headway. i remember trying to look when this thread first started and i was like, u... yeah... but its worth another shot. and the lxr link is pretty sweet too. i like how they have links for all the line numbers of the source files :) Having seen your sample code, it probably IS within the PHP code, since you are passing a file handle to curl -- and it should behave as a proper file handle, in an ideal world, as far as curl is concerned... But then curl may be doing something funky with it and making invalid assumptions too... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static variable in a class method
On Thu, February 14, 2008 11:10 am, Eric Butera wrote: Just FYI the static keyword was quite popular in PHP4 for the singleton pattern. You could do something like: I have used and will continue to use the static keyword in functions, and will most likely never use a class in PHP... If a website is complicated enough to need a class hierarchy, then something is wrong in your Design. :-) :-) :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session and Multi Server Architecture
On Mon, February 11, 2008 1:30 pm, mike wrote: On 2/11/08, Per Jessen [EMAIL PROTECTED] wrote: Make sure all requests from the same client go to the same server. This is often done by IP-address. isn't that an archaic piece of advice? It can help reduce the amount of cross-server data, but it's not a solution since a user could have multiple IP addresses in a single session, and multiple users could have the same IP address. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Exception handling with file()
On Mon, February 11, 2008 6:34 am, John Papas wrote: I need to open a remote file with file() and I would like to put it inside a try-catch but as far as I can tell file() does not raise an exception if it fails. The following code: try { $data = file('http://myserver.com/myfile.txt'); $date = substr($data, 0); } catch (Exception $e) { $data = it failed; } echo $data; echoes a warning: Warning: file('http://myserver.com/myfile.txt') [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in. Old-school PHP functions do not (and will not) raise exceptions. Use http://php.net/set_error_handler -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] \n problems when creating an email
If the recipient is gmail, then you need to use \r\n because Gmail is following in the Windows way of ignoring standards... :-( On Mon, February 11, 2008 6:10 am, Angelo Zanetti wrote: Hi guys, I am making email text based on some fields the user fills in and then email the admin the details. I am having a problem where sometimes the \n (new line) works and sometimes it just does nothing. Im not sure the cause but I cant seem to figure it out. Here is a segment of code: .\nHow far would they be prepared to travel to .\n event venue? \n\t\t\t\t\t. $travel .\nDo you have a specific location . \n of preference? \n\t\t\t\t\t. $locationPref .\n City or country preference:\t. $cityPref Here is the output: How far would they be prepared to travel to event venue? Z Logic e Business Cape Do you have a specific location of preference? Z Logic e Business Cape City or country preference: Z Logic e Business Cape As you can see the first line doesn't go to the next row before event But it works fine for the location \n preference Is there any reason it works for the 1 piece of code and not the next? Do spaces affect anything? Kind regards, Angelo Zanetti Application Developer Telephone: +27 (021) 552 9799 Mobile: +27 (0) 72 441 3355 Fax:+27 (0) 86 681 5885 Web: http://www.elemental.co.za E-Mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] open source PHP/MySQL image viewing application
Did you Google for PHP MySQL photo album or PHP MySQL slideshow??? On Thu, February 14, 2008 2:12 pm, Bruce Gilbert wrote: can anyone reccomend an open source PHP/MySQL based image viewing application. I am looking to store the images in MySQL and have a viewer on the page with the option to click to the next image and back, possibly with the display of an enlarged image as well as the option to click on thumbnails below. this may also be somehting I could look into creating from scratch, but I dodn't want to re-invent the wheel if I don't have to... -- ::Bruce:: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static variable in a class method
On Thu, 2008-02-14 at 15:21 -0500, Eric Butera wrote: On Thu, Feb 14, 2008 at 3:07 PM, Richard Lynch [EMAIL PROTECTED] wrote: On Thu, February 14, 2008 11:10 am, Eric Butera wrote: Just FYI the static keyword was quite popular in PHP4 for the singleton pattern. You could do something like: I have used and will continue to use the static keyword in functions, and will most likely never use a class in PHP... If a website is complicated enough to need a class hierarchy, then something is wrong in your Design. :-) :-) :-) There's something wrong with re-usable components that are extended as separate classes? Weird, I thought that was half the purpose of OOP. 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] Static variable in a class method
2008. 02. 14, csütörtök keltezéssel 14.07-kor Richard Lynch ezt írta: On Thu, February 14, 2008 11:10 am, Eric Butera wrote: Just FYI the static keyword was quite popular in PHP4 for the singleton pattern. You could do something like: I have used and will continue to use the static keyword in functions, and will most likely never use a class in PHP... If a website is complicated enough to need a class hierarchy, then something is wrong in your Design. :-) :-) :-) who said we make websites with all those classes and frameworks? ;) greets Zoltán Németh -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Security scanner
On Mon, February 11, 2008 9:27 am, Emil Edeholt wrote: Thanks. Sure, I know how to escape and filter the input.. But since not all my sites use PDO yet, and I use some external code it would be a good idea to also use an sql injection scanner. Scanning for SQL injection is like a blacklist approach -- always bound to be another injection you didn't think of. Validating the data and using mysql_real_escape_string is the whitelist approach -- You specifically require the data to be of the correct format, and you get MySQL to delimit it properly as DATA and not SQL CODE. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] open source PHP/MySQL image viewing application
can anyone reccomend an open source PHP/MySQL based image viewing application. I am looking to store the images in MySQL and have a viewer on the page with the option to click to the next image and back, possibly with the display of an enlarged image as well as the option to click on thumbnails below. this may also be somehting I could look into creating from scratch, but I dodn't want to re-invent the wheel if I don't have to... -- ::Bruce:: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Trouble with PHP server script
On Sun, February 10, 2008 9:09 pm, Robert Cox wrote: Is it possible to use the $_SERVER['PHP_AUTH_USER']; construct in a URL forwarded site? I am trying to find the authorised user id so that I can access an SQL database with it. Anyone got some ideas? If you do a Location: with a FULL URL then the browser will forward POST and I think AUTH data. If you use a partial URL, it seems to work, but IE will decide not to forward that data. It is in the spec that you need the full URL, starting with http:// for a Location header. This may (or may not) be what is messing you up. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php+mail+TLS/SSL
On Thu, February 14, 2008 8:34 am, julian wrote: I am using phpmailer currently to send email from my applications. My ISP is restricting the usage of email without SSL/TLS and my SMTP connections have started to fail... Any hints on the best approach to send email from php appplciations ?, I wish I could use my standard gmail/yahoo accounts like my desktop email program... Often times, you can write a tiny shell script to connect using an authentication password to the mail server, and then the rest go through as you are already authenticated... Not sure this applies to TLS/SSL, but it's worth a try. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session and Multi Server Architecture
On Mon, February 11, 2008 3:07 pm, mike wrote: actually right now i have an issue on my system i'm working on resolving - and it does create some poor experience for users. when one of my webservers is taken out of the pool (softly due to a healthcheck failure, not via reboot) those clients can get connection refused, or connection reset (if mid-connection) - and if anyone is uploading or downloading a file, they're screwed too. persistence or not, that won't solve this, but it is my note about servers going down and the little bit of non-transparency of the failover... There is some kinda signal you can send to Apache to GRACEFULLY die out. New connections are refused, but old ones are finished and then the child exits. http://apache.org/ There is a graceful restart for sure. Perhaps it's just apachectl graceful stop??? -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static variable in a class method
On Thu, Feb 14, 2008 at 3:07 PM, Richard Lynch [EMAIL PROTECTED] wrote: On Thu, February 14, 2008 11:10 am, Eric Butera wrote: Just FYI the static keyword was quite popular in PHP4 for the singleton pattern. You could do something like: I have used and will continue to use the static keyword in functions, and will most likely never use a class in PHP... If a website is complicated enough to need a class hierarchy, then something is wrong in your Design. :-) :-) :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? Thanks for your opinion! I'll be filing that right into /dev/null. :D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql question
On Sun, February 10, 2008 11:52 am, Per Jessen wrote: nihilism machine wrote: $ret = mysql_result($r, 0); mysql_free_result($r); if ($this-auto_slashes) return stripslashes($ret); else return $ret; } what is $ret, an array? No, it's a mysql result object. No, it's a single field value from the database. $r is the result object. http://php.net/mysql_result -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] group by on mssql_query
$ford = mssql_query(SELECT name FROM Table GROUP BY name); while($mustang = mssql_fetch_array($ford)) { echo $mustang['name'] . /n; } OS 2003 Server PHP 5.2.5 Apache 2.2.8 SQL 2000 For some reason it is NOT clicking what I am missing here. Second set of eyes please -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] group by on mssql_query
On Thu, Feb 14, 2008 at 4:00 PM, [EMAIL PROTECTED] wrote: $ford = mssql_query(SELECT name FROM Table GROUP BY name); What do you see when you replace the above line with this? $ford = mssql_query(SELECT name FROM Table GROUP BY name) or die(mssql_get_last_message()); -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql question #2
At any rate, just seeing this tells me that you've got a real mess on your hands... Or you could say, You're going to have some fun cleaning that. -- Richard Heyes http://www.websupportsolutions.co.uk Knowledge Base and Helpdesk software hosted for you - no installation, no maintenance, new features automatic and free ** New Helpdesk demo now available ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Gzipped output
On Sun, February 10, 2008 7:45 am, Jakub wrote: is it possible to make something like gzipped echo?. My idea was: $gzOut = gzopen('php://output','w'); but it fails with an error: bWarning/b: gzopen(php://output) [a href='function.gzopen'function.gzopen/a]: could not make seekable - php://output That script generates a large text file to download, so I thought I can gzip it somehow to make the downloads faster. The buffered way (to load all the output to some $buffer and then echo gzencode($buffer,6);) consumes too much memory. Can anyone help me with this? Shove a bezoar down his throat and be done with it. Oh, wait, wrong list... Configure Apache to use gzip and be done with it. :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] group by on mssql_query
Column 'location_city.dst' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. Not fimilar with MSSQL to be honest. On Thu, Feb 14, 2008 at 4:00 PM, [EMAIL PROTECTED] wrote: $ford = mssql_query(SELECT name FROM Table GROUP BY name); What do you see when you replace the above line with this? $ford = mssql_query(SELECT name FROM Table GROUP BY name) or die(mssql_get_last_message()); -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Gzipped output
On Mon, February 11, 2008 9:59 am, Eric Butera wrote: On Feb 11, 2008 10:44 AM, Per Jessen [EMAIL PROTECTED] wrote: Eric Butera wrote: I like it from a coding point of view (it's neat and elegant), but I don't think it achieves anything else than my initial suggestion of using exec(gzip -c). Except for that little thing where you shouldn't be using execs in public facing code. Why not? You should never use exec friends when there is another way around the problem. It is a security concern. The only security concern I am aware of is if you pass in user supplied data to the exec() arg... And if you filter it properly, it is no more risky than anything else. If you don't filter properly, then you're in trouble no matter what external lib you are using... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql question #2
On Sun, February 10, 2008 12:12 pm, nihilism machine wrote: public function select_one($sql) { if ($this-auto_slashes) { return stripslashes($ret); If you have to call stripslashes() on data coming FROM MySQL, then you have really messed up... You've put in data that was escaped TWICE, probably with Magic Quotes ON followed by addslashes (or mysql_real_escape_string). At any rate, just seeing this tells me that you've got a real mess on your hands... } else { return $ret; } } how can i get the contents of a column in the returned row say for something called Email as the column name. here is my code now: Since it's only returning ONE piece of data, how confused can it be? $this-whatever['Email'] = $result; -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] group by on mssql_query
Sweet Mother it just clicked. I got it thank you dan. On Thu, Feb 14, 2008 at 4:00 PM, [EMAIL PROTECTED] wrote: $ford = mssql_query(SELECT name FROM Table GROUP BY name); What do you see when you replace the above line with this? $ford = mssql_query(SELECT name FROM Table GROUP BY name) or die(mssql_get_last_message()); -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session and Multi Server Architecture
On 2/14/08, Richard Lynch [EMAIL PROTECTED] wrote: There is some kinda signal you can send to Apache to GRACEFULLY die out. New connections are refused, but old ones are finished and then the child exits. http://apache.org/ There is a graceful restart for sure. Perhaps it's just apachectl graceful stop??? That assumes I am using Apache :) The issue that I'm having isn't me manually stopping the webservers though. This is a system issue somewhere so it is unpredictable and not planned. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strtotime
I would use date and mktime, personally, as strtotime often does things I consider strange On Sun, February 10, 2008 5:46 am, Ron Piggott wrote: I am trying to calculate what was the date 18 months ago. When I give the command: $18_months_ago = strtotime(-18 months); It comes back with: Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE How would you calculate 18 months ago from today? Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Create collections of objects
Hi people, I want a class that allows create objects that get the information consulting the DB. So, I am thinking to do something like this: class element { public __construct($id,$type = 'id') { switch($type) { case 'id': $where = sprintf( id = %d ,$id); break; case 'name': $where = sprintf( name = %s ,escape($id)); break; //... // get the row and call setName($row['name'])... } } } This works fine, but also I want a good way (efficient) of getting a collection of these objects. I can't figure a convenient way. A static function its a good posibility? I have some ideas but they imply public setters of the class `element'. Thanks for any help. -- Emilio Astarita [EMAIL PROTECTED] Gnus http://gnus.org/ http://www.gnu.org/philosophy/free-sw.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] group by on mssql_query
On Thu, Feb 14, 2008 at 4:13 PM, [EMAIL PROTECTED] wrote: Column 'location_city.dst' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. Not fimilar with MSSQL to be honest. Yes, MS SQL is strict and will not allow you to return columns as part of an aggregate query unless they are either part of the GROUP BY clause or aggregated with either a built-in aggregate function such as COUNT, SUM, AVG, MAX, MIN, etc., or else a user-defined function or subquery (as the error message indicates). If you're used to MySQL, it isn't so strict (but IMO should be). Andrew
Re: [PHP] Static variable in a class method
Richard Lynch wrote: If a website is complicated enough to need a class hierarchy, then something is wrong in your Design. :-) :-) :-) I don't think anything ever *needs* a class heirarchy, but I wouldn't say using one indicates a design flaw. Classes themselves are an invaluable tool for creating a logical modular system with reusable components, and IMHO not using them indicates an engineer stuck in the dark ages of software development. But each to their own. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Uploading PDF
Greetings, I am getting an error when I am trying to upload a PDF file through a script. When I do a print_r($_FILES) I get the following: Array ( [userfile] = Array ( [name] = document.pdf [type] = [tmp_name] = [error] = 2 [size] = 0 ) ) Docs and html will both upload. Anybody have an idea why? Here is the script that I am using: ?php // In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead // of $_FILES. $uploaddir = '../cms/documents/'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { $filename = $_FILES['userfile']['name']; echo bFile is valid, and was successfully uploaded./b\n br /Select and copy the link below to reference this file.p / prelt;a href=\documents/$filename\gt;$filenamelt;/agt;/prep / bWARNING:/b This link will not be available anywhere else. ; } else { echo Possible file upload attack!\n; } echo 'pre'; echo 'Here is some more debugging info:'; print_r($_FILES); print /pre; ? Thanks, -- Steve M. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fgets???
On Fri, February 8, 2008 11:54 am, Zoltán Németh wrote: 2008. 02. 8, péntek keltezéssel 12.46-kor Daniel Brown ezt Ãrta: On Feb 8, 2008 12:35 PM, Richard Lynch [EMAIL PROTECTED] wrote: I knew it. After silence, Lynch comes back with a vengeance three hours before the week's stats come out. And not only that he top-posts. ;-P Wait, this might not be the real Lynch, but his new AI instead, not programmed yet for bottom posting :) I top post when: The ordering is already so screwed up as to be pointless to not top post, or I'm in a super hurry and have only a tiny thing to add to a rather long post, or . . . I've had much longer silences on this list. And even longer stretches of posting WAY too much on a daily basis. ymmv ianal naiaa -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Trouble with PHP server script
Richard Lynch wrote: On Sun, February 10, 2008 9:09 pm, Robert Cox wrote: Is it possible to use the $_SERVER['PHP_AUTH_USER']; construct in a URL forwarded site? I am trying to find the authorised user id so that I can access an SQL database with it. Anyone got some ideas? If you do a Location: with a FULL URL then the browser will forward POST and I think AUTH data. Auth info is not passed on as such. HTTP authentication details are applied to all URLs where the browser already knows them (i.e. on the same domain where they have already authenticated). The redirect does not have anything to do with this. And I don't know where you're getting the idea that POST data is persisted when redirecting with the location header. This is certainly not the case in all browsers I've ever worked with. If it was then a fair number of scripts I've written over the years would not work correctly. One security note for the OP: it's generally a bad idea for the user credentials for your website to be the same as those used to access the database. I can think of few ideas where it would make the slightest bit of logical sense and most of those involve web-based DB admin such as phpMyAdmin. You might want to rethink your design from a security point of view. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Better DB Class MySQL
On Sun, February 10, 2008 9:31 am, Jochem Maas wrote: Larry Garfield schreef: http://www.php.net/pdo All the cool kids are doing it. not true - some of them use firebird ;-) And some have figured out that PDO does not quite live up to its promise (yet) and needs some more work... Particularly for the commercial DBs, as I understand it... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Order directory output
opendir/readdir does not promise to deliver the files in any particular order, no matter what it seems to do on any given day... Put them in an array and sort() if it's a small list of files. Or use exec and ls -als or somesuch for a large list of files. Or... glob *might* be documented to do things in a certain order, but I doubt it. On Fri, February 8, 2008 4:44 pm, Pastor Steve wrote: Hi, thanks for all your help today. I have the following code and I am trying to order the output. Currently it seems really random. Can anyone point me in the right direction? ?php $dir = content/current/breaking_news/; // set pattern $pattern = .txt*|.TXT*; // open directory and parse file list if (is_dir($dir)) { if ($dh = opendir($dir)) { //This is the div that contains the wrap around for the breaking news section. echo div class=\spstory\ style=\font-family: Times New Roman, Times, serif; font-size: 12px; width: 290px;\ div style=\width: 285px; background-color: #CC; padding: 3px;\ span class=\NormalHeadRed\Breaking News/span br /Please check here often for breaking news stories. /div p / span class=\NomalText\ ul; // iterate over file list while (($filename = readdir($dh)) !== false) { // if filename matches search pattern, print it if (ereg($pattern, $filename)) if(strpos($filename,'.')0) { $fh = fopen($dir . $filename, r); $filehead = fgets($fh); fclose($fh); echo li class=\bn_bullet\ a href=\/breaking_news/$filename\$filehead/a /li; } } echo /ulp / /span /div; // close directory closedir($dh); } } ? Thank you, -- Steve Marquez -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static variable in a class method
On Thu, February 14, 2008 4:28 pm, Stut wrote: Richard Lynch wrote: If a website is complicated enough to need a class hierarchy, then something is wrong in your Design. :-) :-) :-) I don't think anything ever *needs* a class heirarchy, but I wouldn't say using one indicates a design flaw. Classes themselves are an invaluable tool for creating a logical modular system with reusable components, and IMHO not using them indicates an engineer stuck in the dark ages of software development. But each to their own. I used classes in Lisp a whole whole whole lot building AI research applications, so I don't think I qualify as stuck in the dark ages... :-) Perhaps it's just that I don't like to work on websites big/complicated enough to need giant class hierarchies... Or that I would rather simplify such a site to the point where it doesn't need said large hierarchy... Or that anything that's supposed to spit out a web page in a splintered second shouldn't be that complicated to start with... Or... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Source code protection
On Thu, February 7, 2008 8:35 pm, Andrés Robinet wrote: 1 - I believe the fact that we don't encode (read compile) our scripts is tightly related to the fact that we don't have a bytecode interpreter (say JIT compiler or something?) bundled into PHP. Er. PHP has a bytecode interpreter in the Zend Engine... That's kinda what it *does* It's not a JIT, however, at this time, though there's always talk on internals@ about making it more and more JIT-like. The various caching mechanisms (Zend Cache Accelerator, APC, etc) all store the bytecode version of the PHP script, not the original source. This provides a TINY performance benefit, which is completely dwarfed by not hitting the hard disk to read the PHP script, and costs almost nothing since it's basically the difference between this psuedo C code: . . . script = fread(fp, 10); cache(script); bytecode = parse(script); . . . and this: . . . script = fread(fp, 10); bytecode = parse(script); cache(bytecode); . . . You can rely on the bytecode interpreter being there, as that's what the Zend Engine *is*. This does not necessarily make your other points invalid -- but they cannot be based around the [incorrect] facts you stated. :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() and wrong timezone (or time)
On Wed, February 6, 2008 11:13 am, Martin Marques wrote: Nathan Nobbe escribió: On Feb 6, 2008 6:13 AM, Martin Marques [EMAIL PROTECTED] wrote: I got an update from tzdata on a Debian server due to a daylight saving change here in Argentina. The problem is that, even when the system sees the correct time, php keeps giving me the *old* hour. $ date mié feb 6 09:03:57 ARST 2008 $ echo ?php echo date('H:i') . \\n\; ?|php5 08:04 What can my problem be? see what you have as the value for the date.timezone ini setting. I've already checked that, and it's not set. Anyway, I found out that PHP uses an internal tz database (very bad IMHO) and it might be out of date. There was a thread on internals@ recently explaining why it has the internal tz database -- mainly that it runs on platforms which have no tz database at all... Also, many admins aren't updating their tz database as religiously as you, so it ends up being better in the opinion of the PHP Dev Team to embed the tz database. At least, this is my recollection of the thread. ymmv, and obviously does... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static variable in a class method
On Thu, February 14, 2008 5:14 pm, Stut wrote: I'm only guessing, but instead of classes I would expect you to have a fair few files that contain lots of functions, correct? No, just one file with a handful to a dozen functions, really... If the site is designed correctly, each page is doing something different enough that you'd only use the function in one place, and there's no point to using a function if it's only called/used in one place. :-) That's a bit of an exaggeration, but close enough for rock n roll. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static variable in a class method
Richard Lynch wrote: On Thu, February 14, 2008 4:28 pm, Stut wrote: Richard Lynch wrote: If a website is complicated enough to need a class hierarchy, then something is wrong in your Design. :-) :-) :-) I don't think anything ever *needs* a class heirarchy, but I wouldn't say using one indicates a design flaw. Classes themselves are an invaluable tool for creating a logical modular system with reusable components, and IMHO not using them indicates an engineer stuck in the dark ages of software development. But each to their own. I used classes in Lisp a whole whole whole lot building AI research applications, so I don't think I qualify as stuck in the dark ages... :-) Perhaps it's just that I don't like to work on websites big/complicated enough to need giant class hierarchies... Or that I would rather simplify such a site to the point where it doesn't need said large hierarchy... Or that anything that's supposed to spit out a web page in a splintered second shouldn't be that complicated to start with... Or... I'm only guessing, but instead of classes I would expect you to have a fair few files that contain lots of functions, correct? Given that non-heirarchical class libraries are effectively the same but with one extra organisational layer (plus access control) I really can't see why you think an application that uses classes would be any more complicated than one that doesn't. From where I'm sitting an application built using classes is likely to be (although not necessarily) better structured than one built without them. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] database design tool
On Feb 12, 2008 7:46 PM, Shawn McKenzie [EMAIL PROTECTED] wrote: Can anyone recommend a preferably visual DB design tool? I normally use mysql, but one that covered several types wood be cool. I'm on Linux, so the new mysql workbench is a dud. I used it in an alpha or prior version and it looked promising but crashed frequently. They say a Linux version in 2008, but I'm not holding my breath. Try DBDesigner4[1], MySQL based their workbench from DBDesigner. However, it won't allow you to connect to MySQL5 and sync your changes, but hey, you're looking for a graphical designer - and this tool is great for designing your DBs. You can install from source and tweak it a bit or you can install the win32 binary and let it run via wine (which works really well). [1] fabforce.net/dbdesigner4/ -- Dax Solomon Umaming http://knightlust.com/ GPG: 0x715C3547 signature.asc Description: This is a digitally signed message part.
[PHP] Re: Uploading PDF
Pastor Steve wrote: Greetings, I am getting an error when I am trying to upload a PDF file through a script. When I do a print_r($_FILES) I get the following: Array ( [userfile] = Array ( [name] = document.pdf [type] = [tmp_name] = [error] = 2 [size] = 0 ) ) Docs and html will both upload. Anybody have an idea why? Here is the script that I am using: ?php // In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead // of $_FILES. $uploaddir = '../cms/documents/'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { $filename = $_FILES['userfile']['name']; echo bFile is valid, and was successfully uploaded./b\n br /Select and copy the link below to reference this file.p / prelt;a href=\documents/$filename\gt;$filenamelt;/agt;/prep / bWARNING:/b This link will not be available anywhere else. ; } else { echo Possible file upload attack!\n; } echo 'pre'; echo 'Here is some more debugging info:'; print_r($_FILES); print /pre; ? Thanks, The error number tells you what is happening - check the values at http://php.net/manual/en/features.file-upload.errors.php Essentially, the file is bigger than the MAX_FILE_SIZE directive that was specified in the HTML form Cheers -- David Robley Couldn't myself have better it said. Today is Sweetmorn, the 46th day of Chaos in the YOLD 3174. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Unable to run my sample application from CakePHP
Hi all, CakePHP is a new tool for me, I never worked on any framework before..! To learn about CakePHP I already read http://manual.cakephp.org pages and copy the code sample from that manual. I installed cake in /var/www/html directory. In my Apache server webroot is /var/www/html. Now my question is how can run my application(What will be the URL to access my application? In one point I am sure that the database configuration is OK, because when I through the URL http://127.0.0.1/cake to the server, the server returns a CakePHP introductory page with a status Your database configuration file is present. Cake is able to connect to the database. --- Controller page name: users_controller.php having class name UsersControllers with member function login(). view page name: login.thtml model page name: user.php --- Please help me... --- Nirmalya Lahiri [+91-9433113536] Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unable to run my sample application from CakePHP
Nirmalya Lahiri wrote: CakePHP is a new tool for me, I never worked on any framework before..! To learn about CakePHP I already read http://manual.cakephp.org pages and copy the code sample from that manual. I installed cake in /var/www/html directory. In my Apache server webroot is /var/www/html. Now my question is how can run my application(What will be the URL to access my application? In one point I am sure that the database configuration is OK, because when I through the URL http://127.0.0.1/cake to the server, the server returns a CakePHP introductory page with a status Your database configuration file is present. Cake is able to connect to the database. --- Controller page name: users_controller.php having class name UsersControllers with member function login(). view page name: login.thtml model page name: user.php --- Please help me... Questions regarding specific frameworks should be directed towards the support resources for that framework. Check the Cake homepage for support details. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] question about database field-types and special characters
I've got a PHP application that pulls in data from a mySQL database. The data is a series of wine producers, and many of them have special foreign characters over the a's and o's. When I go and view the data from my database using myPHPAdmin, the characters look fine, but when I pull the data into my web-page the special characters get messed up. For whatever reason, when I first set up the database, someone told me to preserve special characters by setting my collation for the wine-producer field to latin1_swedish_ci. The data seems to be in there ok, so at least that works. Should I have used utf-8 instead? Can I set something in the doctype or header of my web-page to make it so that my website displays latin1_swedish_ci-based characters properly, or should I change my database field-type to be something different? My main fear is messing up the database (I'll back up first if I have to chance the field collation) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php+mail+TLS/SSL
Hello, on 02/14/2008 12:34 PM julian said the following: I am using phpmailer currently to send email from my applications. My ISP is restricting the usage of email without SSL/TLS and my SMTP connections have started to fail... Any hints on the best approach to send email from php appplciations ?, I wish I could use my standard gmail/yahoo accounts like my desktop email program... I am not sure if you can or cannot use SMTP with TLS. In any case, you may use this popular MIME message composing and sending class that comes with several alternative delivery methods. It supports SMTP deliveries with TLS enabled as required by Gmail and also mail() function/sendmail deliveries. Just use the appropriate sub-class that fit in your restrictions. http://www.phpclasses.org/mimemessage If you need to deliver via SMTP/TLS to Gmail, you also need these two classes in conjunction. mail() function/sendmail deliveries do not require additional classes: http://www.phpclasses.org/smtpclass http://www.phpclasses.org/sasl -- Regards, Manuel Lemos PHP professionals looking for PHP jobs http://www.phpclasses.org/professionals/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about database field-types and special characters
On Thu, 2008-02-14 at 18:47 -0800, Rob Gould wrote: I've got a PHP application that pulls in data from a mySQL database. The data is a series of wine producers, and many of them have special foreign characters over the a's and o's. When I go and view the data from my database using myPHPAdmin, the characters look fine, but when I pull the data into my web-page the special characters get messed up. For whatever reason, when I first set up the database, someone told me to preserve special characters by setting my collation for the wine-producer field to latin1_swedish_ci. The data seems to be in there ok, so at least that works. Should I have used utf-8 instead? Can I set something in the doctype or header of my web-page to make it so that my website displays latin1_swedish_ci-based characters properly, or should I change my database field-type to be something different? My main fear is messing up the database (I'll back up first if I have to chance the field collation) SOunds like your website is UTF8 and your DB as you say is latin1. You have a few choices. You can set the php.ini config value: default_charset = iso-8859-1 You can also set the meta tag (probably best to set the PHP config and the meta tag): meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 / Or, and this is what I would do, convetr your database to UTF-8. That way you're prepared for the rest of the world. In this day and age I would creat a site with anything but UTF-8. Here's some reading for you: http://www.joelonsoftware.com/articles/Unicode.html 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] question about database field-types and special characters
On Thu, 2008-02-14 at 23:59 -0500, Robert Cummings wrote: On Thu, 2008-02-14 at 18:47 -0800, Rob Gould wrote: I've got a PHP application that pulls in data from a mySQL database. The data is a series of wine producers, and many of them have special foreign characters over the a's and o's. When I go and view the data from my database using myPHPAdmin, the characters look fine, but when I pull the data into my web-page the special characters get messed up. For whatever reason, when I first set up the database, someone told me to preserve special characters by setting my collation for the wine-producer field to latin1_swedish_ci. The data seems to be in there ok, so at least that works. Should I have used utf-8 instead? Can I set something in the doctype or header of my web-page to make it so that my website displays latin1_swedish_ci-based characters properly, or should I change my database field-type to be something different? My main fear is messing up the database (I'll back up first if I have to chance the field collation) SOunds like your website is UTF8 and your DB as you say is latin1. You have a few choices. You can set the php.ini config value: default_charset = iso-8859-1 You can also set the meta tag (probably best to set the PHP config and the meta tag): meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 / Or, and this is what I would do, convetr your database to UTF-8. That way you're prepared for the rest of the world. In this day and age I would creat a site with anything but UTF-8. Wouldn't create a site with anything but UTF-8. :) 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] Better DB Class MySQL
On Thu, 2008-02-14 at 16:17 -0600, Richard Lynch wrote: And some have figured out that PDO does not quite live up to its promise (yet) and needs some more work... I am finding this out the hard way, but just with MySQL and PostgreSQL support (including MySQLi). Portable, kinda, stable, not so much. --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XSLTProcessor without validation
Am Donnerstag, 14. Februar 2008 21:01:42 schrieb Richard Lynch: You may want to try using http://php.net/exec to run your command line tool and ignore the PHP one, if it won't let you turn off validation. Yes, that's what i'm going to do for now. But that won't help if an internet provider does not have this or does not allow executing this. You could also consider filing a Feature Request in http://bugs.php.net/ Thanks for that link. I'll try. Regards Siegfried -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XSLTProcessor without validation
Am Donnerstag, 14. Februar 2008 21:01:42 schrieb Richard Lynch: You could also consider filing a Feature Request in http://bugs.php.net/ Well, the bug reporting page has a bug. A graphical captcha is needed, but there is no such captcha. Repetitive loading does not change this. From an accessibility point of view graphical captchas are a bad idea. Not existing, but required graphical captchas are an even worse idea. This way the bug report mechanism is essentially 100% inaccessible :) Regards Siegfried -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sending XML to MSIE7
Does anyone know if there's a way to send XML to MSIE7 and avoid having MSIE mangle the XML with CSS to display it pleasantly as HTML? I'm building a PHP web service that returns XML to a desktop app that uses the MSIE7 toolbox, and so it is not able to interpret the XML due to this Windows convenience. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sending XML to MSIE7
Brian Dunning wrote: Does anyone know if there's a way to send XML to MSIE7 and avoid having MSIE mangle the XML with CSS to display it pleasantly as HTML? Isn't it enough to send it with Content-Type: application/octet-stream ? /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php