Re: [PHP] Get a PAGE
just use file_get_contents() or fopen() On Thu, 2005-01-27 at 22:52, Louie Miranda wrote: Im trying to capture the whole page of a certain courier service. What i want to do is, after i got the form to query the AWB (Air Way Bill No.) It will dump on my local folder the page containing the details on it. Im going to try PEAR HTTP_Download Is there another application or syntax on php that can do this? -- Louie Miranda http://www.axishift.com -- Regards, Matthew Fonda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail problem at interland
On Friday 28 January 2005 16:32, Jason Wong wrote: On Friday 28 January 2005 10:09, David Edwards wrote: I have a fairly simple script written that uses the mail() function on a client site hosted at Interland. I have used a similar script quite a few times before with no problem. However although the script generates no errors, no emails appear at their intended destination. Interland support has not been that helpful and they did suggest I try the '-f' option in the header. That did not work either. Has anyone seen this before, I am running out of ideas. The mail portion of the script is below: $headers .= MIME-Version: 1.0\n; $headers .= Content-type: text/plain; charset=iso-8859-1\n; $headers .= X-Priority: 1\n; $headers .= X-MSMail-Priority: High\n; $headers .= X-Mailer: php\n; $headers .= From: $emailfrom\n; $mailsent = mail($emailto, $subject, $msg, $headers,-f . $emailfrom); 1) Use the proper delimiters between headers -- \r\n 2) Check your mailserver logs 3) The From address may cause the mesage to be rejected if it does not have the same domain as the mailserver. Cheers -- David Robley Even the Holodeck women turn me down: Wesley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: debug_backtrace trick
On Friday 28 January 2005 17:09, Gerard Samuel wrote: There used to be a link in the manual user notes, I believe under debug_backtrace(). Where, there was some javascript voodoo, that would hide/unhide the backtrace. Does anyone have a link to this site? Thanks Maybe http://www.interactionarchitect.com/articles/toggle.htm ?? Cheers -- David Robley Those who can't write, write manuals. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail problem at interland
Hi David, On Thu, January 27, 2005 9:09 pm, David Edwards said: Hi, $headers .= MIME-Version: 1.0\n; $headers .= Content-type: text/plain; charset=iso-8859-1\n; $headers .= X-Priority: 1\n; $headers .= X-MSMail-Priority: High\n; $headers .= X-Mailer: php\n; $headers .= From: $emailfrom\n; I believe the headers have to end with a blank line? If I remeber correctly, the last line in the $headers should have two new lines like $headers .= From: $emailfrom\n\n; HTH -R'twick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [NEWBIE] Trying to create a function from an existing script
Jon, As recommended before, I have added global $HTTP_POST_FILES; to my function. The upload directory has a permission setting of 777 and the directory specified ends in a slash.I don't know what the server logs say, however, as I don't know where they are or how to check them. I am, after all, a PHP newbie. But I should mention that the script works perfectly when I use this syntax: if( copy($HTTP_POST_FILES['upfile']['tmp_name'],$store_dir. imagefile.jpg) However, I wanted to change it to use move_uploaded_file() instead of copy() because Marek suggested it would be more secure that way. So because the script stops working when I switch copy() for move_uploaded_file(), I feel it's a safe bet that the error is somehow in the syntax of the move_uploaded_file() command. Again, for reference, here is the whole if() statement: if(move_uploaded_file($_HTTP_POST_FILES['upfile']['tmp_name'],rawurlencode($store_dir. imagefile.jpg))) { echo(Uploaded .$HTTP_POST_FILES['upfile']['name']. successfully.); } // If the copy function fails output a message. else { echo(Upload of .$HTTP_POST_FILES['upfile']['name']. to .$store_dir. failed.); } -- Dave Gutteridge [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] help needed on imagettftext()
Hi Marek Kilimajer, Thank You Marek it worked for me also. -Harish Rao K -Original Message- From: Marek Kilimajer [mailto:[EMAIL PROTECTED] Sent: Thursday, January 27, 2005 9:19 PM To: Harish Rao K Cc: php-general@lists.php.net Subject: Re: [PHP] help needed on imagettftext() Harish Rao K wrote: Hello, While working with some CAPTCHA stuff I get the following error: Fatal error: Call to undefined function imagettftext(). I have compiled with GD support and all the supporting libraries (Freetype, TTF, jpeg, X11R6 etc). What am I missing? Below is the configure command that I have used. './configure' '--with-gd' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-pgsql' '--with-jpeg-dir=/usr/local/jpeg-6b' '--with-zlib-dir=/usr/local/zlib-1.2.1' '--enable-gd-native-ttf' '--with-png' '--with-ttf' '--with-freetype-dir=/usr/local/freetype-2.1.9' '--with-xpm-dir=/usr/X11R6' Thanks Regards, Harish Rao K, make clean make make install this helped me. I guess there are wrong dependencies in the Makefiles -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Nous Infosystems This e-mail transmission may contain confidential or legally privileged information that is intended only for the individual(s) or entity(ies) named in the e-mail address. If you are not the intended recipient, please reply to the [EMAIL PROTECTED], so that arrangements can be made for proper delivery, and then please delete all copies and attachments.Any disclosure, copying, distribution, or reliance upon the contents of this e-mail, by any other than the intended recipients, is strictly prohibited. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_pconnect / persistent database conections
Ben Edwards wrote: Been meaning to investigate persistent database connections for a while. Coming from a rdbms background (oracle with a bit of whatcom sqlanywhare) I have always felt that the overhead of opening a connection at the beginning of each page was a little resource intensive. MySQL is not remotely the same beast as oracle - take pure session create times. I have a machine that runs both. Creating an oracle session with sqlplus command line takes in the region of 2 seconds (get around this for web apps by connection pooling). Creating a mysql connection (c client) takes in the region of 5 mS. You also need to consider the memory / processor implications of caching connections (or keeping persistent connections) from your web server. Anyway, I found mysql_pconnect and this sounds like just the ticket. Seems that I can just change my connect method from mysql_connect to mysql_pconnect and it will just work. I do have a couple of questions. Firstly what is the story with mysql_close. There is no mysql_pclose. I guess you don't need to close the connection at the end of each page but what if you do. Is mysql_close ignored if the connection was made with mysql_pconnect or douse it close the connection and next time mysql_pconnect is run it reconnects causing no benefit over mysql_pconnect. also what is the timeout likely to be? My other question is what happens if lots of people connect using the same user/password. I tend to do my own user management so everybody douse. Is doing my own user management really dodge, if we were talking about oracle I would probably say it is. Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DB] Developer needed in London
Underodog H.R. wrote: Sorry for using the list in this way, wont happen again. wtf. 'they' posted it twice with the same message... thats the definition of 'again'. the fact that 'they' can't even spell their company name correctly would make me think twice about working there ;-) Underodog H.R. [EMAIL PROTECTED] ^ !!! And why is a degree so important if 'all' they want if a monkey who can do D/HTML, PHP MySQL - these are the easiest IT wotsits on the planet, ok playing minesweeper is easier :-). I mean easy as in accessible not easy as in 'no hard work or study needed' anyone can go to the local college and train to be an electrician but you need a degree to write php code?? --- nuff of that, I've had too much coffee and too many traffic jams this morning. PLEASE DON¹T REPLY TO THIS MESSAGE THROUGH THE LIST RESPOND DIRECT TO [EMAIL PROTECTED] Job Opportunity: Web Developer/Designer In-house in London (not outsourced). A great opportunity to join a young vibrant company working on exciting high profile projects. Would suit recent graduates and experienced pro's alike. A strong background in web technologies and programming is essential, good working knowledge of; D/HTML, PHP, MySQL is necessary, other technologies (Flash etc) are a bonus. Please apply by sending your CV to [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [PHP-DB] Developer needed in London
Jochem Maas wrote: Underodog H.R. wrote: Sorry for using the list in this way, wont happen again. wtf. 'they' posted it twice with the same message... thats the definition of 'again'. I just noticed that they crossposted rather than post twice. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 Class problem
I'm using PHP 5.0.3 and if a problem if a class method. I'm initializing a class like that: $o_SessionHandler = new SessionHandler(); var_dump($o_SessionHandler-getOrgSession());exit; Now it get the error message: Fatal error: Using $this when not in object context in /srv/www/htdocs/SessionHandler.class.php on line 68 I try to debug that but that looks like a bug in the parser. The class looks like that: ?php //-- interface for SessionHandler Class interface SessionHandlerI { //-- functions static public function checkTime(); static public function checkSession(); static public function defineVar(); static public function getVar(); static public function isLogined(); static public function getOrgSession(); } //-- define SessionHandler Class class SessionHandler implements SessionHandlerI { //-- define var that keeps the original Session alive private $a_session_org; //-- initialize function public function SessionHandler() { $this-a_session_org = $_SESSION; } //-- function that checks how long the user don't do something static public function checkTime() { //-- check if time var exists if(isset($_SESSION['time_last_clicked'])) { //-- check the time differents if(time() - $_SESSION['time_last_clicked'] TIME_LOGOUT_IF_NO_CLICK) { //-- set new time $_SESSION['time_last_clicked'] = time(); } else { //-- block to login site Blocker::BlockToLoginSite(); } } else { //-- set var $_SESSION['time_last_clicked'] = time(); } } //-- function that checks if the Session Structur is correct static public function checkSession(){} //-- function that defines a var in the Session static public function defineVar(){} //-- functino that returns a session var static public function getVar(){} //-- check if the user is logined based on the session static public function isLogined(){} //-- returns the original login static public function getOrgSession() { //-- return var return $this-a_session_org; } } The getOrgSession() function is inside of a class so the $this should be avaible... any ideas? thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [PHP-DB] Developer needed in London
On Friday 28 January 2005 18:20, Jochem Maas wrote: Jochem Maas wrote: Underodog H.R. wrote: Sorry for using the list in this way, wont happen again. wtf. 'they' posted it twice with the same message... thats the definition of 'again'. I just noticed that they crossposted rather than post twice. Add thread hijacking to the list of transgressions as well! -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail problem at interland
On Friday 28 January 2005 10:54, R'twick Niceorgaw wrote: I believe the headers have to end with a blank line? If I remeber correctly, the last line in the $headers should have two new lines like $headers .= From: $emailfrom\n\n; No, the mail() function will automatically take care of the separation of the mail headers and the mail body. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Class problem
Thomas Munz wrote: I'm using PHP 5.0.3 and if a problem if a class method. I'm initializing a class like that: $o_SessionHandler = new SessionHandler(); var_dump($o_SessionHandler-getOrgSession());exit; ... //-- returns the original login static public function getOrgSession() { //-- return var return $this-a_session_org; } } The getOrgSession() function is inside of a class so the $this should be avaible... $this is defined only if the following 2 things are true. 1. you are calling the method on a object (i.e. not as a static call like SessionHandler::getOrgSession()) 2. the function (method) you are calling is _NOT_ defined as static. in your case you have defined all your methods as static so the engine will not make $this available even if you call the method/function on an instantiated object. solution - remove 'static' from the function definitions that you wish to use $this in. any ideas? thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Best way to execute actions within a class
I have been building a lightweight PHP4 based, hopefully PHP5 OO structure where each page or php file contains its own class which is then executed using the constructor like so new SomeProject_SomeSubProject(); within the subclasses contructor I then call a method called start which is in a base class called Page which is extended from the main project class called SomeProject. Within start it calls a method to check action page get uri's ie ?action=view , what i used to within procedural code is use switch statements but seem taxing. Within this now will check if its a get or post method and execute a method in the class with the same name ie public function action_view() or if its a post method i have chosen to call it post_action_view(). Now is this a good setup I would like some feedback on how people in an OO world would achieve this. Now that i have started executing constructors within the main page files, I have come to think of better ways passing around a url possibly like something like this someurl/index/someproject_somesubproject/view or someurl/someproject_somesubproject/view or someurl/index/aliasofclass/view or someurl/aliasofclass/view and for adding keys to the end for db stuff something like someurl/index/aliasofclass/view?ID=1 or someurl/index/aliasofclass/view/ID/1 i think then all u need is the main index.php file which works out which class to load and execute ? And possibly peristist the objects loads too via shm maybe ? And if you need other files it could be like someurl/otherfile/aliasofclass/view/ID/1 I'm sure this is all mod_rewrite stuff, is this taxing to do ? Let me know always open to suggestions especially ways to do caching better. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Class problem
1. you are calling the method on a object (i.e. not as a static call like SessionHandler::getOrgSession()) 2. the function (method) you are calling is _NOT_ defined as static. in your case you have defined all your methods as static so the engine will not make $this available even if you call the method/function on an instantiated object. solution - remove 'static' from the function definitions that you wish to use $this in. how odd, i have assumed having a class static you could still throw around variables inside it, or its only meant to stay in the one static method so executing it like Class::staticMethod(); and Class::otherStaticMethod() ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 stable enough for webapps ?
I am in the midst of getting work to implement PHP5 onto a new server for a web based app I am doing using PEAR's DB_DataObject plus some other fancy OO. To give them the piece of mind I would like to know if its stable enough to run for an intranet based app running on Federo Linux. The extensions I am trying to get are DOM XML, XSL , GD, getext + a heap of PEAR packages. I have been developing under PHP5 on Mac OSX so no know issues as yet, but I was the one that did the compiling. Its always a querky finnaky thing when someone else does it for you :| Let me know. Dan (also wondering when php will be apache2 ready, Rusmas care to answer without having to repeat yourself though ?? :)) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Extended Mail
Partial message is available. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] rss feeder using php?
Dear friends, we are looking for a RSS feeder implemented in php. Is there anything good out there (something you have tried + tested). Please, do not answer do a google search, because I ALREADY know how to do a google search. What we are interested is some feedback on real products you have tested. -- symbulos partners -.- symbulos - ethical services for your organisation http://www.symbulos.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] rss feeder using php?
[snip] we are looking for a RSS feeder implemented in php. Is there anything good out there (something you have tried + tested). [/snip] I have used the following - http://www.phpinsider.com/php/code/ContentFeeder/ - is worth a go... [snip] Please, do not answer do a google search, because I ALREADY know how to do a google search. What we are interested is some feedback on real products you have tested. [snip] Why not google search? Nothing wrong with doing some experimenting yourself... Chris Ramsay - Web Developer - The Danwood Group Ltd. T: +44 (0) 1522 834482 F: +44 (0) 1522 884488 e: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] w: http://www.danwood.co.uk - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Class problem
[EMAIL PROTECTED] wrote: 1. you are calling the method on a object (i.e. not as a static call like SessionHandler::getOrgSession()) 2. the function (method) you are calling is _NOT_ defined as static. in your case you have defined all your methods as static so the engine will not make $this available even if you call the method/function on an instantiated object. solution - remove 'static' from the function definitions that you wish to use $this in. how odd, i have assumed having a class static you could still throw around variables inside it, or its only meant to stay in the one static method so executing it like Class::staticMethod(); and Class::otherStaticMethod() ? #2 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 stable enough for webapps ?
[EMAIL PROTECTED] wrote / napsal (a): I am in the midst of getting work to implement PHP5 onto a new server for a web based app I am doing using PEAR's DB_DataObject plus some other fancy OO. To give them the piece of mind I would like to know if its stable enough to run for an intranet based app running on Federo Linux. The extensions I am trying to get are DOM XML, XSL , GD, getext + a heap of PEAR packages. I have been developing under PHP5 on Mac OSX so no know issues as yet, but I was the one that did the compiling. Its always a querky finnaky thing when someone else does it for you :| Let me know. Dan (also wondering when php will be apache2 ready, Rusmas care to answer without having to repeat yourself though ?? :)) Under GNU/Linux you can compile it too, you don't have to use th pre-compiled packages. I think GNU/Linux is stable enough but it is up to you. trobi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 stable enough for webapps ?
On 28/01/2005, at 11:26 PM, trobi wrote: Under GNU/Linux you can compile it too, you don't have to use th pre-compiled packages. I think GNU/Linux is stable enough but it is up to you. trobi Heh is that for PHP5 or Apache2 ? I think PHP5 is stable enough for what i need it to do, no bugs hangs or crashes., Convincing others that it isnt bleeding edge anymore is a different story. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 stable enough for webapps ?
[EMAIL PROTECTED] wrote: I am in the midst of getting work to implement PHP5 onto a new server for a web based app I am doing using PEAR's DB_DataObject plus some other fancy OO. To give them the piece of mind I would like to know if its stable enough to run for an intranet based app running on Federo Linux. The extensions I am trying to get are DOM XML, XSL , GD, getext + a heap of PEAR packages. I have been developing under PHP5 on Mac OSX so no know issues as yet, but I was the one that did the compiling. Its always a querky finnaky thing when someone else does it for you :| Let me know. well if you have been working fine on MacOSX then I reckon thats a good indication! ...and if you want to run redhat thats your problem ;-) Yes PHP5 is stable enough to use IMHO, just don't rely on updates to std packages always working (like the redhat packages - which _ahem_ suck). (I have been writing a PHP5 framework since around 11-2003 and I haven't been able to get it to segfault since around May last year.) ...so it runs on Apache2 quite nicely - there is the fact that you must use the prefork apache2 worker module, other than that there are no overwhelming problems (I assume that there are bugs that could crop up - but this is just going on the assumption that bugless software is only made on other planets :-) - at any rate I have pushed PHP5 quite far on Apache2 and nothing is breaking - e.g. many cyclic-object-references, which was something that sometimes caused segfaults in the 'early' days) good luck with the setup, Jochem Dan (also wondering when php will be apache2 ready, Rusmas care to answer bad form Dan!!! you spelt his name wrong. tut tut ;-) without having to repeat yourself though ?? :)) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Class problem
[EMAIL PROTECTED] wrote: 1. you are calling the method on a object (i.e. not as a static call like SessionHandler::getOrgSession()) 2. the function (method) you are calling is _NOT_ defined as static. in your case you have defined all your methods as static so the engine will not make $this available even if you call the method/function on an instantiated object. solution - remove 'static' from the function definitions that you wish to use $this in. how odd, i have assumed having a class static you could still throw around classes cannot be defined as static - defining them as abstract has the effect of being able to only use a given class statically (unless you subclass it and the subclass is not abstract). variables inside it, or its only meant to stay in the one static method so yes you can use variables - but not member variables because $this is not defined in functions that are declared static - bare in mind you can call a method statically even though its not marked as static (just be sure you don't reference $this). sidenote: the php4 trick of overwriting $this does not work in PHP5. executing it like Class::staticMethod(); and Class::otherStaticMethod() ? I don't really understand what your asking. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp_put and ftp_fput both failing me
Wayne Zeller wrote: Marek Kilimajer wrote: 30 seconds? This must be your firewall blocking connections from outside world. Use ftp_pasv() to turn on passive mode. That did the trick. Thanks s much! Marek shoots, Marek scores :-) Wayne -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 stable enough for webapps ?
On 28/01/2005, at 11:56 PM, Jochem Maas wrote: well if you have been working fine on MacOSX then I reckon thats a good indication! Well umm, its a standard setup really, i install all the libraries needed for the extensions via fink, i compile php via source. ...and if you want to run redhat thats your problem ;-) Not my decsision what would you suggest ? We need pretty standard stuff for it to be supported. I dont work for a web company, i'm in an IT department of a government Tv station or i wouldnt need to go through all this hassle to get it. Yes PHP5 is stable enough to use IMHO, just don't rely on updates to std packages always working (like the redhat packages - which _ahem_ suck). As before the systems guy will be doing it from source fk rpm's. (I have been writing a PHP5 framework since around 11-2003 and I haven't been able to get it to segfault since around May last year.) Yeh right interested what your view is on framework ...so it runs on Apache2 quite nicely - there is the fact that you must use the prefork apache2 worker module, other than that there are no overwhelming problems (I assume that there are bugs that could crop up - but this is just going on the assumption that bugless software is only made on other planets :-) - at any rate I have pushed PHP5 quite far on Apache2 and nothing is breaking - e.g. many cyclic-object-references, which was something that sometimes caused segfaults in the 'early' days) I think we could start a flame here, but I have been told the problem isnt with php c code directly but the c libraries it hooks into that instead thread safe ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] rss feeder using php?
On Fri, 2005-01-28 at 11:49 +, Chris Ramsay wrote: [snip] we are looking for a RSS feeder implemented in php. Is there anything good out there (something you have tried + tested). [/snip] I used to code a PHP5 rss-parsing class some time ago, but I haven't finished it (stopped at caching and atom support) because I haven't got enough free time (the school-term has ended ;-(). Take a look at MagpieRSS ( http://magpierss.sourceforge.net/ ). -- Josip Dzolonga, dzolonga at mt dot net dot mk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Class problem
electroteque wrote: On 29/01/2005, at 12:02 AM, Jochem Maas wrote: classes cannot be defined as static - defining them as abstract has the effect of being able to only use a given class statically (unless you subclass it and the subclass is not abstract). abstract as in it is the final base class ? no abstract as in 'cannot be instantiated' try running the following: abstract class MyClass { public function __construct() { echo boo!; } } $mc = new MyClass; the 'final' keyword is used to declare that a class or method cannot be overridden by (or in) a subclass. variables inside it, or its only meant to stay in the one static method so yes you can use variables - but not member variables because $this is not defined in functions that are declared static - bare in mind you can call a method statically even though its not marked as static (just be sure you don't reference $this). i meant member vars , what is the point of static methods anyway ? difficult question. a start would be to say that static methods offer a neat way to organise your code (sort of cheapmans namespace). PHP5 also offers static class vars: abstract class MyClass { static private $val; static public function set($v) { self::$val = $v; } static public function speak() { if (!is_null(self::$val)) { echo self::$val.\n; } else { echo silence\n; } } } MyClass::set(yeah); MyClass::speak(); sidenote: the php4 trick of overwriting $this does not work in PHP5. that i cant live with good ;-) ... the reason it doesn't work is the same reason PHP5 objects are s much cooler, namely a rewritten object model. thank the gods! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 stable enough for webapps ?
electroteque wrote: On 28/01/2005, at 11:56 PM, Jochem Maas wrote: well if you have been working fine on MacOSX then I reckon thats a good indication! Well umm, its a standard setup really, i install all the libraries needed for the extensions via fink, i compile php via source. was not meant as a a dig - its merely that MacOSX is less used and therefore per definition less tested, statistically you have more chance of finding a (platform specific) bug there. at least that was my reasoning. ...and if you want to run redhat thats your problem ;-) Not my decsision what would you suggest ? We need pretty standard stuff for it to be supported. I dont work for a web company, i'm in an IT department of a government Tv station or i wouldnt need to go through all this hassle to get it. what do you classify as std? (most gov orgs I know of think std == Microsoft). redhat is shite, if you need professional support/indemnity/etc I would recommend Novell/SuSE. if you can go for a minimal setup like debian or gentoo (2 distros that I like) which take the 'less is more' approach and gives you control - rather than some redhat webserver 1500 miles away which thinks it knows better than you whether you want to upgrade to the latest version of xyz. Yes PHP5 is stable enough to use IMHO, just don't rely on updates to std packages always working (like the redhat packages - which _ahem_ suck). As before the systems guy will be doing it from source fk rpm's. I pity the man - I have a friend who is _really_ ace at the sort of thing and he used the word 'nightmare' (php5/apache2/firebird1.5 on a redhat v3 enterprise server). yum yum not. () (I have been writing a PHP5 framework since around 11-2003 and I haven't been able to get it to segfault since around May last year.) Yeh right interested what your view is on framework framework == 'bunch of code that I can reuse to form the basis of a site' basically its a data-object setup specific to Firebird DB - basically you design a DB (day or 2), write the objects (day or 2 again), boom instant CMS - and then I spend countless hours doing the custom magic for a given client. There is a lot of work done on relating data entities and on the generic/generated CMS interface. (3 types of relation: Reference, Vector, Association - each is implements as a Field object - fields objects make up the structure of data-object). Its pretty cool, but the stuff that really makes it stand out (IMHO) is the generic management/editing screens...e.g. 1. highlight rows (ala phpmyAdmin but better) and then edit all the highlighted rows (no use of checkboxes) with a single click 2. drag'n'drop columns (to change the order) with the ability to store the changes (the system is capable of storing custom view settings for each user) Actually I have wanted to make the code open source - but its really a quite a complex beast to setup i.e. I can't just give someone a file and say run it, theres your demo. which means I need to write an install file, a help file and make a test DBstructure for people to play with as soon as I have time I will get my ass into gear, then you (and the rest of the world) will be able to see if its any good. ...so it runs on Apache2 quite nicely - there is the fact that you must use the prefork apache2 worker module, other than that there are no overwhelming problems (I assume that there are bugs that could crop up - but this is just going on the assumption that bugless software is only made on other planets :-) - at any rate I have pushed PHP5 quite far on Apache2 and nothing is breaking - e.g. many cyclic-object-references, which was something that sometimes caused segfaults in the 'early' days) I think we could start a flame here, but I have been told the problem isnt with php c code directly but the c libraries it hooks into that instead thread safe ? correct as far as I understand it. to paraphrase Rasmus (answering a post on threading) 'your in uncharted territory, good luck' I see you sneakily snipped off the misspelling of Rasmus' name ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error log
Richard Lynch wrote: Benson wrote: could anyone please help me on how to display all the errors to the browser, but not to file? I have tried modifying php.ini and httpd.conf (apache), but I am not sure how to modify... You would be MUCH MUCH MUCH better off to train yourself to use 'tail -f /usr/local/apache/logs/error_log' instead. yes indeed. 'tail -f' is your friend although new users might not realise that the place apache stores its log files is not the same on every system - often sharedhosting setups have seperate logfiles per client - and some dump access/errors into 1 combined log (annoying!!!), and then you have redhat setups (but I won't go into that again today). for instance my err.logfile (on my main dev server) is at /var/log/apache/error_log admittedly all these paths (and cmdline crap in general) may seem daunting at first - a few months hardlabor in a linux shell will have you feeling right at home :-) Honest. That said, you should have only needed to change php.ini in a rather obvious way -- but you need to re-start Apache after changing it, which was probably what you missed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Best method to store shopping cart contents
I've written some nice shopping carts in Cold Fusion that use a session variable to hold an array of structures. I need to convert the shopping cart to PHP but I'm unsure of how to store the cart's contents using PHP. Should I create a multi-dimensional array and store it a session variable? Any good tutorials/examples on creating shopping cart apps using PHP? Thanks, Dave HTC Disclaimer: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you.
[PHP] Check Url Exists
Hi, In my php file, I want to check whether the url(residing on another server) is existing or not. Thanks in advance. Binoy __ __ __ __ Sent via the WebMail system at softwareassociates.co.uk --- Scanned by MessageExchange.net (14:23:58 SPITFIRE) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [NEWBIE] Trying to create a function from an existing script [SOLVED]
Jon and all, Please disregard my posting just before this. After a night's sleep and looking at my code with fresh eyes, I noticed that I had an extra under bar character in my $HTTP_POST_FILES variable which was causing all the trouble. The script is now working perfectly. Thanks Marek, Mike, Jon and everyone for helping me with my code. -- Dave Gutteridge [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best method to store shopping cart contents
Bosky, Dave wrote: I've written some nice shopping carts in Cold Fusion that use a session variable to hold an array of structures. I need to convert the shopping cart to PHP but I'm unsure of how to store the cart's contents using PHP. Should I create a multi-dimensional array and store it a session variable? I currently store an object (called Basket ;-) in the Session (for one of my projects) which is in effect the same thing - works great - just remember that if you have objects stored in your session then you must include the class definitions _before_ you start the session. Any good tutorials/examples on creating shopping cart apps using PHP? if your a list member then you should have received an email from Richard Lynch - he posted a link to a page he setup that lists pro/cons for LOTS of commerce apps. that would be a good place to start looking! Thanks, Dave HTC Disclaimer: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. not if you send to a mailing list it aint ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Check Url Exists
Binoy AV wrote: Hi, In my php file, I want to check whether the url(residing on another server) is existing or not. is that I question? (PS I want a car with 200BHP) in case it was a question then have a look at the cURL extension - it allows you to 'hit' another server as if your script is a regular browser, you can then check the returned headers to see if the page was found. Thanks in advance. Binoy __ __ __ __ Sent via the WebMail system at softwareassociates.co.uk --- Scanned by MessageExchange.net (14:23:58 SPITFIRE) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 stable enough for webapps ?
On Fri, 28 Jan 2005 23:43:54 +1100, electroteque [EMAIL PROTECTED] wrote: Heh is that for PHP5 or Apache2 ? I think PHP5 is stable enough for what i need it to do, no bugs hangs or crashes., Convincing others that it isnt bleeding edge anymore is a different story. I wouldn't say it has no bugs.. especially when you look at the other 5.0.x releases: http://www.php.net/ChangeLog-5.php Sure PHP 5 is getting better all the time, but bug free I seriously doubt. That said, I'm using it for new development and it does appear to work fine. -- Greg Donald Zend Certified Engineer http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_pconnect / persistent database conections
On Thu, 27 Jan 2005 22:14:52 -0800, Steve Slater [EMAIL PROTECTED] wrote: At 10:43 AM 1/27/2005, Richard Lynch wrote: Ben Edwards wrote: Been meaning to investigate persistent database connections for a while. Coming from a rdbms background (oracle with a bit of whatcom sqlanywhare) I have always felt that the overhead of opening a connection at the beginning of each page was a little resource intensive. The mysql_pconnect() function should work well to solve the wasted resource/overhead you describe. But you should be aware that the pconnect function does not exist in the mysqli set of PHP functions. The mysqli functions allow you to access newer features of MySQL 4.1 and higher...like prepared statements. Here is the blurb from Zend: http://www.zend.com/php5/articles/php5-mysqli.php#fn1 So basicaly they are saying that as the connection is hot closed at the end of eatch page you will need mysql to be able to hold a lot more open connections concurently. I guess its something that needs checking with the ISP of the site in question. Ta, ben Steve -- Steve Slater [EMAIL PROTECTED] Information Security Training and Consulting PHP / MySQL / Web App Security (LAMP) Training: http://www.handsonsecurity.com/training.html -- Ben Edwards - Poole, UK, England WARNING:This email contained partisan views - dont ever accuse me of using the veneer of objectivity If you have a problem emailing me use http://www.gurtlush.org.uk/profiles.php?uid=4 (email address this email is sent from may be defunct) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] replace
I have a section of my site that uses HTMLArea to allow the users to manage content. For one certain section, they want all of their links to pop up in another window. I know they can use HTMLArea and add this code themselves but they don't want to get to the code side of it. Currently, I just pull out the entire contents and echo them to the screen: echo $sql-getField('content'); but now I need to replace each anchor tag from A href=http://www.something.com/; to A href=javascript:pop('http://www.something.com/') I can easily use str_replace() to replace a href=javascript:pop( but how do I add the last )? Hope this made sense. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Check Url Exists
Or you can use fopen() - http://us3.php.net/manual/en/function.fopen.php - check the file handle to see if it worked and then close the handle. Just remember you need allow_url_fopen allowed in your php.ini file. -M -Original Message- From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: Friday, January 28, 2005 10:09 AM To: [EMAIL PROTECTED] Cc: php-general@lists.php.net Subject: Re: [PHP] Check Url Exists Binoy AV wrote: Hi, In my php file, I want to check whether the url(residing on another server) is existing or not. is that I question? (PS I want a car with 200BHP) in case it was a question then have a look at the cURL extension - it allows you to 'hit' another server as if your script is a regular browser, you can then check the returned headers to see if the page was found. Thanks in advance. Binoy __ __ __ __ Sent via the WebMail system at softwareassociates.co.uk --- Scanned by MessageExchange.net (14:23:58 SPITFIRE) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Multiple jobs in crontab
I'm trying to run 3 jobs in a crontab and only one job will run. I can rearrange the order and only the first one runs. Here is my code, the command line may show wrapped, but it is not: #phpList PQ This job replaces its log and error files. Runs at 3:03am, 3:18, etc. 3,18,33,48 0 * * * /usr/local/bin/php /www/r/rester/htdocs/phpList/PQ/PQutility.php /www/r/rester/htdocs/phpList/PQ/cron.log 2/www/r/rester/htdocs/phpList/PQ/cron.err #At 4:01 our time, run backups. This job replaces its log and error files. 7 1 * * * /usr/local/bin/php /www/r/rester/htdocs/auto_backup/back_em_up.php /www/r/rester/auto_backup/cron.log 2/www/r/rester/auto_backup/cron.err #At 4:02 clean up sessions folder 8 1 * * * (find /www/r/rester/htdocs/sessions/ -name 'sess_*' -mtime +1 -delete) I've tried removing the blank lines between jobs, doesn't help. Anyone see anything wrong with my syntax? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: debug_backtrace trick
David Robley wrote: On Friday 28 January 2005 17:09, Gerard Samuel wrote: There used to be a link in the manual user notes, I believe under debug_backtrace(). Where, there was some javascript voodoo, that would hide/unhide the backtrace. Does anyone have a link to this site? Thanks Maybe http://www.interactionarchitect.com/articles/toggle.htm ?? Its not the site that I remember, but I should be able to modify the voodoo, presented on that page, to get the effect Im after. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regular expressions ?
On Thu, 27 Jan 2005 11:36:39 -0800, Rick Fletcher [EMAIL PROTECTED] wrote: /^(1?[1-9]|[12]0)$/ works too. The first part covers 1-9, 11-19; the second part gets you 10 and 20. Plus, it's ever so slightly shorter! And isnt' that what's most important? :P absolutely, and you managed it without a typo, unlike me :( -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple jobs in crontab
Al wrote: I'm trying to run 3 jobs in a crontab and only one job will run. I can rearrange the order and only the first one runs. Try setting the MAILTO and check the output -- Perhaps that will tell you something useful... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace
blackwater dev wrote: I have a section of my site that uses HTMLArea to allow the users to manage content. For one certain section, they want all of their links to pop up in another window. I know they can use HTMLArea and add this code themselves but they don't want to get to the code side of it. Currently, I just pull out the entire contents and echo them to the screen: echo $sql-getField('content'); but now I need to replace each anchor tag from A href=http://www.something.com/; to A href=javascript:pop('http://www.something.com/') I can easily use str_replace() to replace a href=javascript:pop( but how do I add the last )? http://php.net/preg_replace would probably be easiest. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Check Url Exists
Binoy AV wrote: In my php file, I want to check whether the url(residing on another server) is existing or not. Depending on configuration and settings, either: http://php.net/file_exists http://php.net/curl Be aware that due to connectivity or dog-slow servers, you will get false negatives fairly often. You may want to record the existence with several checks spread out over a few days before deciding that a URL truly doesn't exist. With a slow server at the other end, that still won't be completely reliable... Also note that just because a URL exists, does not guarantee that it's any good -- Domain name squatters and their link farms abound. So you may also want to compare the actual output of the file with expected results to see if it's valid or not. This can get really complex really fast, as you might imagine. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best method to store shopping cart contents
Bosky, Dave wrote: I've written some nice shopping carts in Cold Fusion that use a session variable to hold an array of structures. I need to convert the shopping cart to PHP but I'm unsure of how to store the cart's contents using PHP. Should I create a multi-dimensional array and store it a session variable? Sounds like a plan to me. Any good tutorials/examples on creating shopping cart apps using PHP? There are a few zillion, actually... Just Google for PHP shopping cart and you should find a ton of source code, or a hundred carts you could just start using instead of re-inventing the wheel. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace
thanks...I will look that up. Not very good with regular expressions though. On Fri, 28 Jan 2005 08:11:59 -0800 (PST), Richard Lynch [EMAIL PROTECTED] wrote: blackwater dev wrote: I have a section of my site that uses HTMLArea to allow the users to manage content. For one certain section, they want all of their links to pop up in another window. I know they can use HTMLArea and add this code themselves but they don't want to get to the code side of it. Currently, I just pull out the entire contents and echo them to the screen: echo $sql-getField('content'); but now I need to replace each anchor tag from A href=http://www.something.com/; to A href=javascript:pop('http://www.something.com/') I can easily use str_replace() to replace a href=javascript:pop( but how do I add the last )? http://php.net/preg_replace would probably be easiest. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Best method to store shopping cart contents
Do you have a simple example of how to create a multi-dimensional array and store it in a session variable? Regards, ~Dave - Play more pool! www.mbpoolplayers.com - -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Friday, January 28, 2005 11:35 AM To: Bosky, Dave Cc: php-general@lists.php.net Subject: Re: [PHP] Best method to store shopping cart contents Bosky, Dave wrote: I've written some nice shopping carts in Cold Fusion that use a session variable to hold an array of structures. I need to convert the shopping cart to PHP but I'm unsure of how to store the cart's contents using PHP. Should I create a multi-dimensional array and store it a session variable? Sounds like a plan to me. Any good tutorials/examples on creating shopping cart apps using PHP? There are a few zillion, actually... Just Google for PHP shopping cart and you should find a ton of source code, or a hundred carts you could just start using instead of re-inventing the wheel. -- Like Music? http://l-i-e.com/artists.htm HTC Disclaimer: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Class problem
[EMAIL PROTECTED] wrote: 1. you are calling the method on a object (i.e. not as a static call like SessionHandler::getOrgSession()) 2. the function (method) you are calling is _NOT_ defined as static. in your case you have defined all your methods as static so the engine will not make $this available even if you call the method/function on an instantiated object. solution - remove 'static' from the function definitions that you wish to use $this in. how odd, i have assumed having a class static you could still throw around variables inside it, or its only meant to stay in the one static method so executing it like As I understand it... It's not that you can't use any variables at all -- It's that $this doesn't make any sense in that context. $this refers to the particular instance of the object you have created with new XYZ $xyz = new XYZ(); $xyz-bar(); When bar refers to $this it means the same as the $xyz instance. If you are calling a static method XYZ::foo() then, really, there *IS* no object inside of foo() to be called $this -- You didn't create an instance of XYZ, so there is no instance to be named $this -- There is only the class definition and the method. It's an object that's not there -- more like the idea of an object without having an actual concrete object to hang on to. Hope that helps make sense of it all. Hell, hope that's actually correct! :-^ -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to execute actions within a class
[EMAIL PROTECTED] wrote: I have been building a lightweight PHP4 based, hopefully PHP5 OO structure where each page or php file contains its own class which is then executed using the constructor like so What I would do at this point, if I were you, would be to take a step back and look at the Design Goals that OO excels at achieving: Code re-use, through inheritence of common behaviour Modularization, through class segregation/API Maintainability, through having objects that mirror real-world expectations . . . and see where and how you succeeded and where you need room for improvement. My *personal* take would be that you've done an awful lot of coding, and while you've got some of the benefits above, you're not really leveraging the power of OOP all that much, and I'm wondering if you wouldn't be better off with a structured procedural approach -- particularly since your OOP code has led you down a path where you've got this big 'switch' you don't care for at the heart of your code... Just my skewed take on things. YMMV -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Re: thanks!
Your file is attached. +++ Attachment: No Virus found +++ Panda AntiVirus - www.pandasoftware.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail problem at interland
R'twick Niceorgaw wrote: Hi David, On Thu, January 27, 2005 9:09 pm, David Edwards said: Hi, $headers .= MIME-Version: 1.0\n; $headers .= Content-type: text/plain; charset=iso-8859-1\n; $headers .= X-Priority: 1\n; $headers .= X-MSMail-Priority: High\n; $headers .= X-Mailer: php\n; $headers .= From: $emailfrom\n; I believe the headers have to end with a blank line? If I remeber correctly, the last line in the $headers should have two new lines like $headers .= From: $emailfrom\n\n; mail() will take care of that. You might want to use \r\n instead of just \n, as that's what it's technically supposed to be -- Though I think it works just fine on Un*x-like boxes to use just \n... You might want to add Reply-to: as well as From with the same setting to keep more email clients happy. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getid3
Daniel Lahey wrote: I found a really great utility for getting info on music files that I thought I'd share. Here's the info: / /// getID3() by James Heinrich [EMAIL PROTECTED] // // available at http://getid3.sourceforge.net // //or http://www.getid3.org/// / Very cool stuff. What I found even more cool, at least for me, was that one could create the ID3 data independent of the actual MP3 and then smush them together on-the-fly. So, like, I have this database on-line of who played which night at a music venue, and then I have their MP3s encoded, but not tagged. When you ask to hear a file, I snag the artist/title stuff and make the ID3 tag, then push that out right before the MP3 stream. Why? Because I've got NO IDEA what the song titles are when I make the MP3 (the night of the show) and the artists log in and input song titles later. So I'd have to re-encode the MP3 from .wav every time an artist gets around to logging in and giving me the Title. But the .wav isn't even available at that point -- It's off-line on CDR only by then. Oh yeah. You can also throw in a small thumbnail of the artist before the stream, which is pretty cool. http://uncommonground.com/ has a radio station with files composed this way. None of the MP3 files have any ID3 info in them, really. PHP/getID3 just lets me make it LOOK like they have it. NOTE: WinAmp doesn't support ID3 in streaming MP3s, only local. G. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Best method to store shopping cart contents
Bosky, Dave wrote: Do you have a simple example of how to create a multi-dimensional array and store it in a session variable? E. Okay. ?php session_start(); $foo['whatever']['you']['want']['dimensions'] = 42; $_SESSION['foo'] = $foo; ? For your penance you now must read: http://php.net/session_start http://php.net/manual/en/language.types.array.php -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace
blackwater dev wrote: thanks...I will look that up. Not very good with regular expressions though. this is your chance to get a bit better. have a go, if you get stuck post your code :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple jobs in crontab
Richard Lynch wrote: Al wrote: I'm trying to run 3 jobs in a crontab and only one job will run. I can rearrange the order and only the first one runs. Try setting the MAILTO and check the output -- Perhaps that will tell you something useful... Super suggestion. It clearly showed I had a syntax error, forgot the /htdocs/. Betcha, I looked at the command 50 times and didn't see it. The MAILTO only seems to work when the cronjob doesn't run satisfactory. I assume this is because I have a log and error specified. I plan to add MAILTO to all my future cronjobs, it can help greatly when debugging. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best method to store shopping cart contents
Bosky, Dave wrote: Do you have a simple example of how to create a multi-dimensional array and store it in a session variable? ... you also asked for a class example, seeing as your asking for this I don't think your ready for the class example... $_SESSION['mycart'] = array(); $_SESSION['mycart'][] = array('Product 1', 5.99); $_SESSION['mycart'][] = array('Product 2', 4.99); $_SESSION['mycart'][] = array('Product 3', 7.99); print_r($_SESSION['mycart']); --- this works due to the superglobal $_SESSION; in order to use the $_SESSION var (accessable everywhere without the use of global keyword) you must first call session_start(), which in turn must be called before any output is sent to the browser. a quote from the following URL: (read it) http://nl2.php.net/session As of PHP 4.1.0, $_SESSION is available as a global variable just like $_POST, $_GET, $_REQUEST and so on. Unlike $HTTP_SESSION_VARS, $_SESSION is always global. Therefore, you do not need to use the global keyword for $_SESSION. Please note that this documentation has been changed to use $_SESSION everywhere. You can substitute $HTTP_SESSION_VARS for $_SESSION, if you prefer the former. Also note that you must start your session using session_start() before use of $_SESSION becomes available. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Multi-language in script
Zoran Lorkovic [EMAIL PROTECTED] writes: Hi I'm interested, which is the best way to include multi-language support in scripts? By this I mean that with new version of script/program end-user don't need to translate whole site again... See http://www.php.net/gettext or have a look at http://www.onlamp.com/pub/a/php/2002/06/13/php.html for a gentle introduction -- Raj Shekhar System Administrator, programmer and slacker home : http://rajshekhar.net blog : http://rajshekhar.net/blog/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP4/Apache2 Content-Length stripped?
Hi all, I'm writing a wap download script involving dynamic image resizing and so on. I've notice that some phones are quitting in the mids of http transfer. After looking further I found out that headers() is sometimes ignored or stripped. I've googled around and found in a perl forum that flush-ing helps but in PHP4.3.10/Apache2/Gentoo/linux2.6 it seems to not help (at least in my configuration) Is there a work-around or something... (I'm going to post same question in apache's mailiing list..) Thanks in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Looking for ideas on scheduling
Hello, I'm looking to make a simple scheduler for myself and I'd like to get some feedback on how to handle the events and their being executed at the right time. The two options I've come up with both involve adding a job(s) to crontab. 1. Individual jobs are added to the users crontab file. This could result in LOTS of entries in crontab, but less load on the server. 2. There is one job put in the crontab file that is executed every five minutes. This job will be executing a PHP file that runs through the database for the current user and checks to see if any events need to go off at that time. This will result in only one event in crontab with a greater potential for load on the server. I'm leaning towards Option 2*. What do you think? What other options do I have? Chris. * Hurray for Option magazine! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Class problem
Richard Lynch wrote: [EMAIL PROTECTED] wrote: ... how odd, i have assumed having a class static you could still throw around variables inside it, or its only meant to stay in the one static method so executing it like As I understand it... It's not that you can't use any variables at all -- It's that $this doesn't make any sense in that context. $this refers to the particular instance of the object you have created with new XYZ $xyz = new XYZ(); $xyz-bar(); When bar refers to $this it means the same as the $xyz instance. If you are calling a static method XYZ::foo() then, really, there *IS* no object inside of foo() to be called $this -- You didn't create an instance of XYZ, so there is no instance to be named $this -- There is only the class definition and the method. It's an object that's not there -- more like the idea of an object without having an actual concrete object to hang on to. Hope that helps make sense of it all. Hell, hope that's actually correct! :-^ its correct. only thing it gets a little more complicated, personally I kind of got lost in all the internals discussion surround this behaviour... I just code so that I don't use or accidentally trigger it... in some cases this means using a protected/private method for an object. It easiest to see what I'm talking about if you run some code (tested php5): class XYZ { function doit() { var_dump( isset($this)); } } class ABC { function doit() { var_dump( isset($this)); } function doMore() { XYZ::doit(); $this-doit(); ABC::doit(); } } XYZ::doit();echo--\n; ABC::doit();echo--\n; $x = new XYZ; $a = new ABC; $x-doit();echo--\n; $a-doit();echo--\n; $a-doMore(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Looking for ideas on scheduling
Chris W. Parker wrote: Hello, I'm looking to make a simple scheduler for myself and I'd like to get some feedback on how to handle the events and their being executed at the right time. The two options I've come up with both involve adding a job(s) to crontab. 1. Individual jobs are added to the users crontab file. This could result in LOTS of entries in crontab, but less load on the server. 2. There is one job put in the crontab file that is executed every five minutes. This job will be executing a PHP file that runs through the database for the current user and checks to see if any events need to go off at that time. This will result in only one event in crontab with a greater potential for load on the server. I'm leaning towards Option 2*. What do you think? What other options do I have? while(1) { if ($fiveMinuteHavePast == true) { // check/run jobs } } but my guess is it will leak... which means you'd have to restart it again... probably with a cronjob :-) Chris. * Hurray for Option magazine! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SPL DirectoryIterator
I'm not sure if this is a feature request, a Oh, I didn't know that, or That's the way it is, deal with it kind of problem. foreach(new DirectoryIterator($sDir) as $oFile) { if($oFile-isDot() || 'hidden.txt' == $oFile-getFilename()) continue; echo $oFile,\n; } In the code above, I am echoing $oFile, which internally is recognizing it's being used in a string context, so calling the __toString method on itself (which then returns the result of -getFilename()). Now, what my question is, is why won't it do that when I'm comparing values? 'hidden.txt' == $oFile Is never true, because $oFile doesn't seem to recognize it's being compared in a string context. I'm not sure I *want* it to do this, but at the moment I can't think of any reason why it couldn't behave like this. Any thoughts? http://www.php.net/~helly/php/ext/spl/classDirectoryIterator.html Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Looking for ideas on scheduling
On Fri, 28 Jan 2005 10:49:35 -0800, Chris W. Parker [EMAIL PROTECTED] wrote: 2. There is one job put in the crontab file that is executed every five minutes. This job will be executing a PHP file that runs through the database for the current user and checks to see if any events need to go off at that time. This will result in only one event in crontab with a greater potential for load on the server. I'm leaning towards Option 2*. What do you think? What other options do I have? That's pretty much how I do it. -- Greg Donald Zend Certified Engineer http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SPL DirectoryIterator
Chris wrote: I'm not sure if this is a feature request, a Oh, I didn't know that, or That's the way it is, deal with it kind of problem. iMHO its pretty much the last one, but I don't see the problem with what you have written, ok its a little longer, but you don't have to know that the magic (see below) occurs in order to understand the expression - i.e. $oFile-getFilename() is pretty obvious :-), that nice when you get a call twelve months from now can you please? foreach(new DirectoryIterator($sDir) as $oFile) { if($oFile-isDot() || 'hidden.txt' == $oFile-getFilename()) continue; echo $oFile,\n; } In the code above, I am echoing $oFile, which internally is recognizing it's being used in a string context, so calling the __toString method on itself (which then returns the result of -getFilename()). Now, what my question is, is why won't it do that when I'm comparing values? 'hidden.txt' == $oFile Is never true, because $oFile doesn't seem to here you are comparing two things - what is there to say that the string type has precedence (and therefore force $oFile to a string(cue magic))? basically this is very hard to do correctly and so that everyone agrees on how it should work exactly. AFAICT. only echo print trigger the magic at this point in time AFAICR. --- class XYZ { function __toString() { return xyz; } } $x = new XYZ;$a = sprintf(%s,$x); echo $x,\n;var_dump($a);print($x);echo\n;print_r($x); recognize it's being compared in a string context. I'm not sure I *want* it to do this, but at the moment I can't think of any reason why it couldn't behave like this. Any thoughts? http://www.php.net/~helly/php/ext/spl/classDirectoryIterator.html Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Looking for ideas on scheduling
Chris W. Parker wrote: I'm looking to make a simple scheduler for myself and I'd like to get some feedback on how to handle the events and their being executed at the right time. The two options I've come up with both involve adding a job(s) to crontab. 1. Individual jobs are added to the users crontab file. This could result in LOTS of entries in crontab, but less load on the server. Actually, probably MORE load, as you'll be firing off *WAY* too many php processes, as soon as the schedule gets at all busy. 2. There is one job put in the crontab file that is executed every five minutes. This job will be executing a PHP file that runs through the database for the current user and checks to see if any events need to go off at that time. This will result in only one event in crontab with a greater potential for load on the server. Actually, you might even want to create a special user with limited access/ability (or just use 'nobody') and have THAT user handle all the scheduler notifications et al. Unless you *NEED* to have the scheduler doing things on that user can do with the OS, it would be better to limit it to doing only what it NEEDS to do. Plus, you then just need one script to handle everybody, and need not worry about changes to environment settings altering script behaviour, nor permissions abuse, nor... And, of course, it's probably going to be more efficient to run just one script every five minutes that takes care of all scheduling tasks. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP4/Apache2 Content-Length stripped?
Stoian Ivanov wrote: I'm writing a wap download script involving dynamic image resizing and so on. I've notice that some phones are quitting in the mids of http transfer. After looking further I found out that headers() is sometimes ignored or stripped. I've googled around and found in a perl forum that flush-ing helps but in PHP4.3.10/Apache2/Gentoo/linux2.6 it seems to not help (at least in my configuration) Is there a work-around or something... (I'm going to post same question in apache's mailiing list..) WILD GUESS It sounds like the phones are simply ignoring any image larger than X bytes. Seems to me, then, that your best option is to set up your dynamic resizing to down-sample, shrink, or color-reduce your image until it hits X or lower for that phone -- maybe even all phones. In other words, if your current script only gets an image down to 2X bytes, have it call another script to be even more aggressive in shrinking that image down -- Or iterate down through a series of changes until you get the size down. 'Twould be nice if imagepeg() and friends had an imagejpegestimatedsize() but you'll just have to play with imagejpeg and ob_start to capture the size and find out if it's small enough. Do phone users ever really want to download an image larger than X? Probably not. So don't ask them to. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Looking for ideas on scheduling
Richard Lynch mailto:[EMAIL PROTECTED] on Friday, January 28, 2005 11:36 AM said: Chris W. Parker wrote: The two options I've come up with both involve adding a job(s) to crontab. 1. Individual jobs are added to the users crontab file. This could result in LOTS of entries in crontab, but less load on the server. Actually, probably MORE load, as you'll be firing off *WAY* too many php processes, as soon as the schedule gets at all busy. Ahh yes. Very true. Actually, you might even want to create a special user with limited access/ability (or just use 'nobody') and have THAT user handle all the scheduler notifications et al. Unless you *NEED* to have the scheduler doing things on that user can do with the OS, it would be better to limit it to doing only what it NEEDS to do. Actually it would just be sending out emails and updating the DB. Thanks for the ideas! Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple jobs in crontab
Al wrote: Richard Lynch wrote: Al wrote: I'm trying to run 3 jobs in a crontab and only one job will run. I can rearrange the order and only the first one runs. Try setting the MAILTO and check the output -- Perhaps that will tell you something useful... Super suggestion. It clearly showed I had a syntax error, forgot the /htdocs/. Betcha, I looked at the command 50 times and didn't see it. The MAILTO only seems to work when the cronjob doesn't run satisfactory. I assume this is because I have a log and error specified. I believe the default is to email to the username (on the local machine) any output from that user's cron file. But, if you're not READING the email on that machine as that username, it don't do much good. Or, if that machine doesn't have sendmail running to actually SEND the email... I have that on one machine, and keep forgetting to fix it, and then every once in awhile have to go un-clog /var/mail/mqueue or whatever it is. So I need a cron job to run sendmail every once in a while, I guess... I plan to add MAILTO to all my future cronjobs, it can help greatly when debugging. I actually leave it on, so that if something BREAKS in my cron jobs, I hear about it. Got a whole email mailbox set up with filtering just to sort the cron jobs into it. Every day I delete the cron jobs that are in progress or where I use the output to give me a status message of what's going on in the long-term projects that are being fueled by cron. Deleting an email is easy. Knowing that a cron job suddenly stopped working is very difficult, unless you got that email about it. :-) Ideally, you write your cron scripts to produce *NO* output unless something is wrong. And useful debugging output when something does go wrong. Another Tip: When things aren't working, use crontab -l to see the crontab, and then copy paste the command and see what happens. Oooh, and be sure you did 'cd' to be in your home directory before you do that, just to be sure you have full pathnames everywhere. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Validating input
I've been looking at the docs and found preg_match and preg_match_all but these functions only seem to match 1 specific search item. I want to make sure a variable (say $mlsnumber) contains only numbers and no spaces. What would I use to accomplish this? Thanks Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating input
Ed Curtis wrote / napsal (a): I've been looking at the docs and found preg_match and preg_match_all but these functions only seem to match 1 specific search item. I want to make sure a variable (say $mlsnumber) contains only numbers and no spaces. What would I use to accomplish this? Thanks Ed whatabout trim? left or right? trobi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating input
Ed Curtis wrote: I've been looking at the docs and found preg_match and preg_match_all but these functions only seem to match 1 specific search item. I want to make sure a variable (say $mlsnumber) contains only numbers and no spaces. What would I use to accomplish this? Thanks Ed You really don't need a regex for this Can it be a float? is_numeric() http://us4.php.net/is_numeric Only a float? is_float() http://us4.php.net/is_float Only an integer? is_int() http://us4.php.net/is_int -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Looking for ideas on scheduling
Chris W. Parker wrote: Hello, I'm looking to make a simple scheduler for myself and I'd like to get some feedback on how to handle the events and their being executed at the right time. The two options I've come up with both involve adding a job(s) to crontab. 1. Individual jobs are added to the users crontab file. This could result in LOTS of entries in crontab, but less load on the server. 2. There is one job put in the crontab file that is executed every five minutes. This job will be executing a PHP file that runs through the database for the current user and checks to see if any events need to go off at that time. This will result in only one event in crontab with a greater potential for load on the server. I'm leaning towards Option 2*. What do you think? What other options do I have? I'd go with option 2 also. Option one wouldn't really be less load, as it would be more for cron to parse, and pretty much execute the same amount of times. Option 1 also brings into question security and access. To add entries to the users crontab, your script would have to have permission to do so (suexec?), and giving it that much access could be dangerous. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating input
John Nichel wrote: Ed Curtis wrote: I've been looking at the docs and found preg_match and preg_match_all but these functions only seem to match 1 specific search item. I want to make sure a variable (say $mlsnumber) contains only numbers and no spaces. What would I use to accomplish this? Thanks Ed There's also ctype_digit... http://us4.php.net/ctype_digit And if you really want to use a regex to check for just digits... /^\d{1,}$/ -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Class declaration, constants and array
php5 class { const _SOMETHING_ = 'test'; private $abc=_SOMETHING_; // fails, well actually anything fails similar to this. var $test=$test2;// also fails So since I can not use dynamic var assignment within the class declaration, what are some of the easy solutions to this ? without making anything global to the script ? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Vars with flash
It ain't a dumb question, and is most easily answered by sending you to pp 576 of Colin Mook's ActionScript for Flash - The Definitive Guide. If you're doing a lot of Flash work this book is practically a must have. Are you using LoadVars class(Flash MX) or the LoadVariables (Flash 4) method? I'll assume the former, as that's where your problem is addressed. Without doing a lot of typing, here's the relative bit, regarding formatting of variables transferred by load() or SendandLoad(): . . . Any character that is not a space, a number (1-9), or an unaccented Latin 1 letter (a-z or A-Z) is replaced as follows: - If system.useCodepage is false, the default, the character is replaced by one or more hexadecimal escape sequences of the form %xx, representing the UTF-8 sequence for the character. ... . . . And it goes on for another 3/4 page. Try Googling for Flash System.useCodePage UTF-8 There are a number of combinations of conditions which the book addresses. You can evaluate this yourself in Flash with trace(escape(é)); which should display %C3%A9 - two characters to PHP. Feed that to PHP without some kind of transforming function and guess what you come up with! Flash is encoding your string, PHP receives it, and then translates it to what it knows/is working in. We were sending very simple date values, so the LoadVars class worked, but were receiving unpredictable text. For that we used the XML() class. Have a look at http://ca3.php.net/manual/en/function.utf8-decode.php and other PHP functions associated with unicode. You will have a bit of futzing to do here. Hope this steers you in the right direction - Miles At 02:00 PM 1/27/2005, Carolina Silva wrote: Hello everybody! This might be a dumb question but i'm having a bit of trouble here: I'm making a contact form in flash MX: the swf sends a string with the variables through a loadVariables function. The string is read by a php file. All the vars get their value through a $HTTP_POST_VARS [] function and are sent to an email. The thing is that the special characters such as ñ or á are changed. If I write méxico id the swf file... the php send the email with the value méxico. Can someone please tell what can I do to fix this? Thanks for your help, Carolina -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] display imap inline image?
Hi! I have rewritten the script and now the output appers in a text form $testbody = imap_body($mbox, $msgno, IMAGE/JPEG); $testbody = base64_encode($testbody); // header('Content-Type: image/jpeg'); echo $testbody; This is a sample of the script how can i convert the ouput to an image/jpeg? The output look like this.. LS0tLS0tPV9QYXJ0XzEyNzk4NjFfNTUz... and so on The reason the header line above is comment out is that when enable it doesn't print out anything but an little frame whith the text image. /Fredrik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regex help
OK, this is off-topic like every other regex help post, but I know some of you enjoy these puzzles :) I need a validation regex that will pass a string. The string can be no longer than some maximum length, and it can contain any characters except two consecutive ampersands () anywhere in the string. I'm stumped - ideas? TIA Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Class declaration, constants and array
t'isnt good OOP practice to do what you want to do in the first place perhaps use the constructor to do it On Fri, 2005-01-28 at 12:50, Marek wrote: php5 class { const _SOMETHING_ = 'test'; private $abc=_SOMETHING_; // fails, well actually anything fails similar to this. var $test=$test2;// also fails So since I can not use dynamic var assignment within the class declaration, what are some of the easy solutions to this ? without making anything global to the script ? Thanks -- Regards, Matthew Fonda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating input
--- Ed Curtis [EMAIL PROTECTED] wrote: I've been looking at the docs and found preg_match and preg_match_all but these functions only seem to match 1 specific search item. I want to make sure a variable (say $mlsnumber) contains only numbers and no spaces. What would I use to accomplish this? You mean only numerics? You can use ctype_digit(): http://php.net/manual/function.ctype-digit.php I write more about the character type functions here: http://shiflett.org/archive/84 There is also is_numeric(), if you want to allow any valid representation of a numeric: http://php.net/manual/function.is-numeric.php Be careful with functions like is_int(): http://php.net/manual/function.is-int.php They check the actual data type. If you're filtering data from the client (POST, GET, or cookies), then it's going to be a string, even if it looks like a number. However, you can use an approach like the following to make sure something is an integer: ?php $clean = array(); if ($_POST['num'] === strval(intval($_POST['num']))) { $clean['num'] = $_POST['num']; } ? Hope that helps. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly HTTP Developer's Handbook - Sams Coming Soon http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex help
On 28 Jan 2005 [EMAIL PROTECTED] wrote: I need a validation regex that will pass a string. The string can be no longer than some maximum length, and it can contain any characters except two consecutive ampersands () anywhere in the string. This is an example of something that is easier to do (and probably faster) without using a regexp: if ((strlen($str) = $maxlen) (strstr($str, '') === FALSE)) str is valid else str is not valid -- Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex help
[EMAIL PROTECTED] wrote on 01/28/2005 03:19:14 PM: On 28 Jan 2005 [EMAIL PROTECTED] wrote: I need a validation regex that will pass a string. The string can be no longer than some maximum length, and it can contain any characters except two consecutive ampersands () anywhere in the string. This is an example of something that is easier to do (and probably faster) without using a regexp: if ((strlen($str) = $maxlen) (strstr($str, '') === FALSE)) str is valid else str is not valid -- Tom Thanks, Tom. I agree, but not an option at this time - other parts of the design require this to be a regex. Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Creating a webpage from an HTML form via PHP
I'm have a PHP created HTML form that I want a user to be able to enter data into, then see it as the PHP/HTML will format it, then post it to an HTML file. I've been trying all day to find something similar on your site, but to no avail. I am really new to PHP so I may not have done things the easy way. The code below outputs the proper data, but it does it without user concent. I'd like to have the user review what they typed prior to posting it to dates.htm. Any help would be appreciated. Thanks. Mike code as follows: ?php //-INITIALIZE VARIABLES $filename = 'dates.htm'; $handle = fopen($filename, rb); $old = fread($handle, filesize($filename)); fclose($handle); $date = $_REQUEST['date'] ; $title = $_REQUEST['title'] ; $desc = $_REQUEST['desc'] ; $place = $_REQUEST['place'] ; $cost = $_REQUEST['cost'] ; $info = $_REQUEST['info'] ; //-DISPLAY FORM if (!isset($_REQUEST['date'])) { ? html head titleAdd New Event/title /head body bgcolor=#FF form method=get action=calendar.php table style=border-collapse: collapse; bordercolor=#00 cellspacing=0 cellpadding=2 border=0 tr td valign=top align=left width=18% divEvent Date: /div/td td valign=top div input type=text name=date/div/td tdnbsp;/td/tr tr td valign=top align=left width=18% divEvent Title: /div/td td valign=top div input type=text name=title/div/td tdnbsp;/td/tr tr td valign=top align=left width=18% divEvent Description: /div/td td valign=top colspan=2 divtextarea name=desc rows=15 cols=50% /textarea/div/td/tr tr td valign=top align=left width=18% divLocation: /div/td td valign=top div input type=text name=place/div/td tdnbsp;/td tr td valign=top align=left width=18% divCost: /div/td td valign=top div input type=text name=cost/div/td tdnbsp;/td/tr tr td valign=top align=left width=18% divAdditional Information: /div/td td valign=top colspan=2 divtextarea name=info rows=6 cols=50% /textarea/div/td/tr /table input type=submit value=Add New Event input type=reset value=Clear Form name=reset /FORM /body /html ? } //CHECK FOR EMPTY FIELDS elseif (empty($date) || empty($desc)) { header( Expires: Mon, 20 Dec 1998 01:00:00 GMT ); header( Last-Modified: . gmdate(D, d M Y H:i:s) . GMT ); header( Cache-Control: no-cache, must-revalidate ); header( Pragma: no-cache ); ? html headtitleError/title/head body h1Incomplete Form/h1 p The date and description of the event are required fields. Press your BACK button and try again./p /body /html ? } //---PROCESS FORM elseif(!empty($date) || !empty($desc)) { //SET FORM VARIABLES $a = 'strongfont color=#99 size=4 face=Arial, Helvetica, sans-serif'; $b = '/font/strong/pblockquotepfont color=#99 face=Arial, Helvetica, sans-serifstrongb'; $c = '/b/strong/font/ppfont color=#99 face=Arial, Helvetica, sans-serif'; $d = '/font/ppfont color=#99 face=Arial, Helvetica, sans-serif'; $e = 'br/fontfont color=#99 face=Arial, Helvetica, sans-serif'; $f = '/font/p/blockquote'; //JOIN VARIABLES $all = array($a,$date,$b,$title,$c,$desc,$d,$place,$e,'Price: ',$cost,$d,'Additional Information: ',$info,$f); $new = implode($all); $array = array($new,$old); $joined = implode($array); //CONFIRM ADDITION ?html head titleEntry Verification/title /head body bgcolor=#FF h1Please check your new entry!/h1p Correct errors by hitting your BACK button.p ? echo $new; ? form method=post action=calendar.php input type=submit value=Submit /FORM /body /html ? //FILE ACCESS WRITING //OPEN FILE if (!$handle = fopen($filename, 'w')) { echo Cannot open file ($filename); exit; } //WRITE TO FILE if (fwrite($handle, $joined) === FALSE) { echo Cannot write to file ($filename); exit; } echo Success, wrote ($joined) to file ($filename); fclose($handle); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Class declaration, constants and array
Marek wrote: php5 class { const _SOMETHING_ = 'test'; private $abc=_SOMETHING_; // fails, well actually anything fails similar to this. var $test=$test2;// also fails So since I can not use dynamic var assignment within the class declaration, what are some of the easy solutions to this ? without making anything global to the script ? private $abc = 'test'; Now, if you NEED to use some kind of constant, you could write a PHP script to create your class definition, and then you'd have what you want... That can't be too hard, since I once had a guy I was working for who thought he had laid out a couple months' work for me, only I was done in 3 days, since it was all building classes to mirror MySQL table/fields in a very brain-dead straight-forward fashion, and I wrote code like this, and I don't even really grok PHP classes all that well. Not that I think that made for a particularly good Design, but that's what he wanted, so who am I to say? But I sure wasn't gonna sit there typing like a monkey when I could just script the same thing. Or I guess you could hack something up with eval() if you really worked at it... That would be pretty nasty code, though, I think. It would be nice if PHP allowed constants there, but it doesn't, so there it is. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] display imap inline image?
Fredrik Hampus wrote: I have rewritten the script and now the output appers in a text form $testbody = imap_body($mbox, $msgno, IMAGE/JPEG); $testbody = base64_encode($testbody); // header('Content-Type: image/jpeg'); echo $testbody; This is a sample of the script how can i convert the ouput to an image/jpeg? The output look like this.. LS0tLS0tPV9QYXJ0XzEyNzk4NjFfNTUz... and so on That's not a valid JPEG. It might be a valid JPEG encoded with base64, but browsers aren't gonna display that correctly. Or, maybe you should have been using base64_DEcode() to get the JPEG out of the email, more likely... The reason the header line above is comment out is that when enable it doesn't print out anything but an little frame whith the text image. That's a broken image icon. When you finally get it right, it should start with, errr, yoya or something like that for a valid JPEG. Only the o will have an umlat over it, I think. I know it when I see it :-) After that, you put the header back in, and it all works, unless it's Internet Explorer which will ignore the changed header() -- because it already cached it as non-image data -- so just quit and re-start to see it as an image. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex help
[EMAIL PROTECTED] wrote: OK, this is off-topic like every other regex help post, but I know some of you enjoy these puzzles :) I need a validation regex that will pass a string. The string can be no longer than some maximum length, and it can contain any characters except two consecutive ampersands () anywhere in the string. $text = $_REQUEST['text']; if (strlne($text) 42 !strstr($text, '')){ //kosher } else{ trigger_error(Invalid input, E_USER_ERROR); } Oh, wait, that's not Regex. Oh well. Too bad. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex help
[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote on 01/28/2005 03:19:14 PM: On 28 Jan 2005 [EMAIL PROTECTED] wrote: I need a validation regex that will pass a string. The string can be no longer than some maximum length, and it can contain any characters except two consecutive ampersands () anywhere in the string. This is an example of something that is easier to do (and probably faster) without using a regexp: if ((strlen($str) = $maxlen) (strstr($str, '') === FALSE)) str is valid else str is not valid -- Tom Thanks, Tom. I agree, but not an option at this time - other parts of the design require this to be a regex. Gr. Okay, how about that regex callback thingie thing thing, and you can use a function that pretty much does: (strlen($1) 42 !strstr($1, '')) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating a webpage from an HTML form via PHP
Mike Milligan wrote: I'm have a PHP created HTML form that I want a user to be able to enter data into, then see it as the PHP/HTML will format it, then post it to an HTML file. I've been trying all day to find something similar on your site, but to no avail. I am really new to PHP so I may not have done things the easy way. The code below outputs the proper data, but it does it without user concent. I'd like to have the user review what they typed prior to posting it to dates.htm. In stage one, use a INPUT TYPE=HIDDEN NAME=CONFIRMED VALUE=0 Then, in the review page, change the 0 to 1, so you know they have seen it and confirmed it. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex help
On 28 Jan 2005 [EMAIL PROTECTED] wrote: Thanks, Tom. I agree, but not an option at this time - other parts of the design require this to be a regex. It is pretty easy to do with two regexps, one to check the length and another to see if there is a double . Would that work? I don't know off hand how to do it with a single regexp. If the design requires that every possible condition be checked with a single regexp then I would say, no offense intended, that the design is faulty. Regexps are good tools but are not universal for all possible conditions one might want to test. -- Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating a webpage from an HTML form via PHP
Richard - I tried something like that in the past. Just for Sgiggles I tried it again. Still doesn't work. It does go through the fwrite() process, but it doesn't write the $joined contents, or $joined is being reset to NULL after the first submit button is clicked. Any suggestions? Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex help
[EMAIL PROTECTED] wrote on 01/28/2005 04:13:38 PM: On 28 Jan 2005 [EMAIL PROTECTED] wrote: Thanks, Tom. I agree, but not an option at this time - other parts of the design require this to be a regex. It is pretty easy to do with two regexps, one to check the length and another to see if there is a double . Would that work? I don't know off hand how to do it with a single regexp. If the design requires that every possible condition be checked with a single regexp then I would say, no offense intended, that the design is faulty. Regexps are good tools but are not universal for all possible conditions one might want to test. Thanks Tom and Richard. No offense taken. The design isn't mine, I am plugging in to another system that expects a regex. I think I may have to push back on this one :) Kirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] __toString() Magic Method (Was: SPL DirectoryIterator)
Heh, I didn't realize, unitl it was too late, that I mislabeled my subject, I've fixed it. Jochem Maas wrote: iMHO its pretty much the last one, but I don't see the problem with what you have written, ok its a little longer, but you don't have to know that the magic (see below) occurs in order to understand the expression - i.e. $oFile-getFilename() is pretty obvious :-), that nice when you get a call twelve months from now can you please? Most of my question was stemming from the fact that I was working with DirectoryIterator for the first time, and thought the filename was the output, not an object. My first attempt at seeing it was working was just to echo $oFile (which, btw, was $sFile at that point). When I went to add in the 'hidden.txt' check, it didn't work as expected. here you are comparing two things - what is there to say that the string type has precedence (and therefore force $oFile to a string(cue magic))? basically this is very hard to do correctly and so that everyone agrees on how it should work exactly. AFAICT. only echo print trigger the magic at this point in time AFAICR. --- class XYZ { function __toString() { return xyz; } } $x = new XYZ;$a = sprintf(%s,$x); echo $x,\n;var_dump($a);print($x);echo\n;print_r($x); Ahhh, I realize __toString is still in it's infancy (relatively). I remember first hearing about it awhile back, then attempting to use it in a class I was writing at the time. It wasn't working as expected, and the fact that it was working in the DirectoryIterator caught me off guard. Thanks for the reponse. Seems like I'll need to further investigate it's uses. http://www.php.net/oop5.magic Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Class declaration, constants and array
Matthew Fonda wrote: t'isnt good OOP practice to do what you want to do in the first place Im not too hot on 'good practice' - if I understand the code and its neatly laid out then Im happy... but there is no point setting this value here if the value is to be used in an instantiated object (which it must be as its not declared 'static'). here is the declaration of a member var of 'result set' class, its maybe bad practice but its worked since php5 was in beta. /** * the IBASE_ fetch modifiers; * * @var array * @access private */ private $fetchArgs = IBASE_UNIXTIME; perhaps use the constructor to do it On Fri, 2005-01-28 at 12:50, Marek wrote: php5 class { const _SOMETHING_ = 'test'; private $abc=_SOMETHING_; // fails, well actually anything fails this wont work, for starters your referencing a non-existant constant. try: (all code is tested on php5.0.2 cli) php -r ' class MyClass { const _SOMETHING_ = test; public $abc = MyClass::_SOMETHING_; // } $a = new Myclass; echo $a-abc,\n; ' really you should use the constructor: php -r ' class MyClass { const _SOMETHING_ = test; private $abc; function __construct() { $this-abc = self::_SOMETHING_; echo $this-abc,\n; } } $a = new MyClass; ' although setting a private member var to the value of a constant belonging to the class of the object _seems_ silly - there may be a good reason to, alternatively you could consider referencing the class constant directly e.g. MyClass::_SOMETHING_ or if the code is inside the class MyClass: self::_SOMETHING_ alternatively you may wish to set the var as a static member variable php -r ' class MyClass { const _SOMETHING_ = test; private static $abc = MyClass::_SOMETHING_; // public static function speak() { echo self::$abc,\n; } } $a = new Myclass; $a-speak(); ' similar to this. var $test=$test2;// also fails So since I can not use dynamic var assignment within the class declaration, what does this mean? what are some of the easy solutions to this ? without making anything global to the script ? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] __toString() Magic Method (Was: SPL DirectoryIterator)
Chris wrote: Heh, I didn't realize, unitl it was too late, that I mislabeled my subject, I've fixed it. Jochem Maas wrote: iMHO its pretty much the last one, but I don't see the problem with what you have written, ok its a little longer, but you don't have to know that the magic (see below) occurs in order to understand the expression - i.e. $oFile-getFilename() is pretty obvious :-), that nice when you get a call twelve months from now can you please? Most of my question was stemming from the fact that I was working with DirectoryIterator for the first time, and thought the filename was the output, not an object. My first attempt at seeing it was working was just to echo $oFile (which, btw, was $sFile at that point). When I went to add in the 'hidden.txt' check, it didn't work as expected. I didn't realise that you didn't realise it was an object not a string. which indeed would be confused by the output of echo! here you are comparing two things - what is there to say that the string type has precedence (and therefore force $oFile to a string(cue magic))? basically this is very hard to do correctly and so that everyone agrees on how it should work exactly. AFAICT. only echo print trigger the magic at this point in time AFAICR. --- class XYZ { function __toString() { return xyz; } } $x = new XYZ;$a = sprintf(%s,$x); echo $x,\n;var_dump($a);print($x);echo\n;print_r($x); Ahhh, I realize __toString is still in it's infancy (relatively). I remember first hearing about it awhile back, then attempting to use it in a class I was writing at the time. It wasn't working as expected, and the fact that it was working in the DirectoryIterator caught me off guard. Thanks for the reponse. Seems like I'll need to further investigate it's uses. I only use it on Exceptions. not that I rely on the magic currently - my output class calls the __toString() function explicitly. http://www.php.net/oop5.magic Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mail problem at interland
Hello, on 01/28/2005 12:09 AM David Edwards said the following: I have a fairly simple script written that uses the mail() function on a client site hosted at Interland. I have used a similar script quite a few times before with no problem. However although the script generates no errors, no emails appear at their intended destination. Interland support has not been that helpful and they did suggest I try the '-f' option in the header. That did not work either. Has anyone seen this before, I am running out of ideas. The mail portion of the script is below: $headers .= MIME-Version: 1.0\n; $headers .= Content-type: text/plain; charset=iso-8859-1\n; $headers .= X-Priority: 1\n; $headers .= X-MSMail-Priority: High\n; $headers .= X-Mailer: php\n; $headers .= From: $emailfrom\n; $mailsent = mail($emailto, $subject, $msg, $headers,-f . $emailfrom); The headers seem to be fine, except maybe for those priority headers that are useless and may be the cause of some spam filters understand it as a pattern of spam. Other than that, you are not telling what exactly you are putting in the $emailto, $subject and $msg, and there you may because commiting a fault that may cause that your message be discarded. Without telling what you are putting there, it is hard to help further. -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Class declaration, constants and array
On Fri, 2005-01-28 at 14:50, Marek wrote: php5 class { const _SOMETHING_ = 'test'; private $abc=_SOMETHING_; // fails, well actually anything fails similar to this. var $test=$test2;// also fails So since I can not use dynamic var assignment within the class declaration, what are some of the easy solutions to this ? without making anything global to the script ? Thanks I believe you will have to establish stuff like this in the constructor. jsut create a function the same name as the class and it will be run on object instantiation. I had to do the a couple of years ago for an array. Check out the manual it used to explain this. Bret -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP5 stable enough for webapps ?
* [EMAIL PROTECTED] [EMAIL PROTECTED]: I am in the midst of getting work to implement PHP5 onto a new server for a web based app I am doing using PEAR's DB_DataObject plus some other fancy OO. To give them the piece of mind I would like to know if its stable enough to run for an intranet based app running on Federo Linux. The extensions I am trying to get are DOM XML, XSL , GD, getext + a heap of PEAR packages. I have been developing under PHP5 on Mac OSX so no know issues as yet, but I was the one that did the compiling. Its always a querky finnaky thing when someone else does it for you :| We've been using it on a production server now for three weeks, and have had no issues as of yet -- no segfaults, no memory leaks. It just performs. We're using GD to a small extent, and quite a lot of PEAR. We've been using it in development since July 2004, and I've seen very few issues. The only issue I have seen has been with overriding error handling -- a few bugs we had created some cascading errors that ended up segfaulting our systems, but those were probably errors of ours, not of PHP's. (That's why they're _development_ servers, right?) I'd say, go for it. -- Matthew Weier O'Phinney | mailto:[EMAIL PROTECTED] Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Regex help
On Fri, 28 Jan 2005 14:59:29 -0700, [EMAIL PROTECTED] wrote: OK, this is off-topic like every other regex help post, but I know some of you enjoy these puzzles :) I need a validation regex that will pass a string. The string can be no longer than some maximum length, and it can contain any characters except two consecutive ampersands () anywhere in the string. I'm stumped - ideas? TIA Kirk if(preg_match(/^([^]|(?!)){1,42}$/,$string)) { This one will work I think. Returns false if it finds two consecutive or exceeds 42 chars. -- Stian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Best way to execute actions within a class
* [EMAIL PROTECTED] [EMAIL PROTECTED]: I have been building a lightweight PHP4 based, hopefully PHP5 OO structure where each page or php file contains its own class which is then executed using the constructor like so new SomeProject_SomeSubProject(); within the subclasses contructor I then call a method called start which is in a base class called Page which is extended from the main project class called SomeProject. Within start it calls a method to check action page get uri's ie ?action=view , what i used to within procedural code is use switch statements but seem taxing. Within this now will check if its a get or post method and execute a method in the class with the same name ie public function action_view() or if its a post method i have chosen to call it post_action_view(). Now is this a good setup I would like some feedback on how people in an OO world would achieve this. Okay, let's go into self_promotion_mode: This sounds exactly like how Cgiapp works, a class I ported from perl, and available at: http://freshmeat.net/projects/cgiapp/ Cgiapp is basically a do-nothing class that makes creating application classes that work similar to how you describe very simple to code. Such applications are then trivially re-usable, extensible, and customizable (through instance scripts). And it provides all this in a mere few-hundred lines of code. I bring it up because you asked (a) if your setup is a good setup (probably), and (b) how people in an OO world would achieve this (Cgiapp). You might check out the code and the docs to see if you can glean some ideas for your projects. /self_promotion_mode (Man, I hate doing that... buy I *am* proud of that bit o' code, even if it isn't completely original.) -- Matthew Weier O'Phinney | mailto:[EMAIL PROTECTED] Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help with references?
This script only outputs the top level. i.e. -/ | - folder1 | - folder2 | - folder3 it should be - / | - folder1 | | | - subdir1 | | | - file1.ext | - folder2 | | | - subdir2 | | | - file2.ext | - folder3 | - subdir3 | - file3.ext I really don't know what I am doing here ;) It looks like something is creating a new class instead of working with $tree, after the foreach loop $branch has the intended value. After $branch = tree; the added subdirs exist but the files array beneath the subdirs is empty. I'm in way over my head here so if someone could bail me out I would be eternally greatful! Thanks, Jon class dir { var $name; var $subdirs; var $files; var $num; var $prio; function dir($name,$num,$prio) { $this-name = $name; $this-num = $num; $this-prio = $prio; $this-files = array(); $this-subdirs = array(); } function addFile($file) { $this-files[] = $file; return $file; } function addDir($dir) { $this-subdirs[] = $dir; return $dir; } function findDir($name) { foreach($this-subdirs as $v){ if($v-name == $name) return $v; } return false; } function draw($parent) { echo('d.add('.$this-num.','.$parent.','.$this-name.\,.$this-prio.);\n); foreach($this-subdirs as $v) { $v-draw($this-num); echo // Name: .$v-name.\n// Number: .$this-num.\n// Subdirs: .count($v-subdirs).\n// Files .count($v-files).\n; } foreach($this-files as $v) if(is_object($v)) { echo(d.add(.$v-num.,.$this-num., \.$v-name.\,.$v-prio.);\n); } } } class file { var $name; var $prio; var $size; var $num; function file($name,$num,$size,$prio) { $this-name = $name; $this-num = $num; $this-size = $size; $this-prio = $prio; } } $arFiles = array( array['file1']( array( ['path] = array( [0] = 'folder1', [1] = 'subfolder1' [2] = 'file1.ext' ), ['length'] = 5464, ['size'] = 8765 ), array['file2']( array( ['path] = array( [0] = 'folder2', [1] = 'subfolder2' [2] = 'file2.ext' ), ['length'] = 5464, ['size'] = 8765 ), array['file3']( array( ['path] = array( [0] = 'folder3', [1] = 'subfolder3' [2] = 'file3.ext' ), ['length'] = 5464, ['size'] = 8765 ) ) $prio = array(); for($i=0;$icount($arFiles);$i++) $prio[$i] = -1; $dirnum = count($arFiles); $tree = new dir(/,$dirnum,isset($prio[$dirnum])?$prio[$dirnum]:-1); foreach( $arFiles as $filenum = $file) { $depth = count($file['path']); $branch = $tree; for($i=0; $i $depth; $i++){ if ($i != $depth-1){ $d = $branch-findDir($file['path'][$i]); if($d) $branch = $d; else{ $dirnum++; $d = $branch-addDir(new dir($file['path'][$i], $dirnum, (isset($prio[$dirnum])?$prio[$dirnum]:-1))); $branch = $d; } }else $branch-addFile(new file($file['path'][$i]. (.$file['length'].),$filenum,$file['size'], $prio[$filenum])); } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php