[PHP] clearstatcache, how to use?
I have this code that checks for a file if it exists and do something if it doesnt exist. Problem exist when im updating my data on the directory, even if i did upload it. it still shows the non-existent data. I have read that i should add the clearstatcache();, how am i going to use it? after the file_exists? or before? here's my code ## $itemCode_SHOW = $row[2]; $filename =(/www/images/stockprod/$itemCode_SHOW.jpg); if (file_exists($filename)) { $itemCode_SHOW = $row[2]; } else { $itemCode_SHOW = noimage; } clearstatcache(); ## -- Louie Miranda http://www.axishift.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with file_exists() and clearstatcache()...
i also hve a similar problem like yours, and i dont know how can we solve this. On Wed, 21 Jul 2004 17:22:16 -0400, Scott Fletcher [EMAIL PROTECTED] wrote: I noticed the problem with the php functions, file_exists() and clearstatcache(). When I load a webpage, the php do the file_exists() and attempt to create one if the file does not exist. Then when I go to the next webpage, that file is removed. It is working pretty well. When I press refresh, it work okay. (removed the file upon unloading and create a new file upon loading). It work okay if I go from this page to a neutral webpage (with no file checking feature) then back to this page. It work great. But if I go from this page to the other webpage (with file checking), it showed the existance of the file even though there isn't one. So, I add the sleep() to see how long does it take for it to recognize that there is really no file itself. There I found that it take 40 or 45 seconds for PHP to finally see that even though it was already removed from the last webpage. Why is that? I tried with without clearstatcache() and it have no effect. Is there some alternative to file_exists() that I can use?? I hope I'm explaining it clearly... FletchSOD -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Louie Miranda http://www.axishift.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: clearstatcache, how to use?
Louie Miranda wrote: I have this code that checks for a file if it exists and do something if it doesnt exist. Problem exist when im updating my data on the directory, even if i did upload it. it still shows the non-existent data. I have read that i should add the clearstatcache();, how am i going to use it? after the file_exists? or before? here's my code ## $itemCode_SHOW = $row[2]; $filename =(/www/images/stockprod/$itemCode_SHOW.jpg); if (file_exists($filename)) { $itemCode_SHOW = $row[2]; } else { $itemCode_SHOW = noimage; } clearstatcache(); ## clearstatcache() is very descriptive for php, actually :). Most filesystem functions make use of statistics about a file. Gathering this information is expensive, so it is cached. If something changes, you have to clear the cache to see the change, so: clearstatcache(); if (file_exists($filename)) { is what you need if (file_exists($filename)) { ... } clearstatcache(); will have no impact on the problem, because you are clearing the cache *after* the function that relies on the cache has been called. Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Tutorials...?
Here: http://www.zend.com/php5/ Am Sonntag, 24. Oktober 2004 21:01 schrieb Michael Lauzon: Where can I find detailed PHP5 tutorials, but written for the beginner...they must be online tutorials as I cannot afford any computer books at the moment?! -- Michael Lauzon http://phantasyrpg.com/main.php?view=9898 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL Scalability, part 2
* Thus wrote Kevin Grigorenko: Zareef Ahmed [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] -Original Message- From: Kevin Grigorenko [mailto:[EMAIL PROTECTED] Sent: Monday, October 25, 2004 12:36 AM To: [EMAIL PROTECTED] Subject: [PHP] MySQL Scalability, part 2 Hi, First, sorry for posting an attachment. Second, I fixed my problem to use files, but I just had a general question: Is it really scalable to use MySQL on every page hit as compared to writing to files? Is it true that it only has a certain number of connections it can open at a time (20-30?), and the contention is larger? [] Yes mysql is much faster than file writing. And you can open multiple connection to it. What is this statement based on? I'm absolutely not questioning you, I am just skeptical (if you have any websites or performance benchmarks, please provide). It's hard for me to imagine that a file system access (let alone appending one line to the end of a file) is slower than a MySQL execution. Even if we assume that MySQL does everything in memory, here are just some of the things that have to happen: 1. A MySQL connection may be opened. Perhaps there is connection pooling, and this isn't too bad, just finds a reference to an already open MySQL connection. Performance hit ~ 0 Using a file, a file handle must be otbained, depending on OS, Filesystem, hardware, etc. introduces many variables. 2. mysql_query is executed, which first must go through the PHP library, then connect to a socket (perhaps on another server, but we'll assume on the same server for now). Performance hit ~ negligible if the mysql daemon is on the same server 3. The mysql daemon then has to process this request along with whatever load is already on the daemon, then needs to get locks on the table to insert into it. Performance hit ~ could be a lot, I doubt MySQL is faster at locking than flock() I'm not sure how you come up with that belief, but you forget one important thing, the client does not have to wait for the insert to actually occur before returning. 4. MySQL has to probably do a lot of in memory operations and then send the result back over the socket. It sounds like you are almost trying to make up excuses not to use mysql. But if you have some webpages that prove otherwise, i will be VERY GLAD to see them, because mysql sure makes everything much easier. I just can't see it yet based on such a simple statement as above. Well just the other day, one of my webservers was gettting 150 hits per second. Each page has several queries, at least one insert, and mabey an update or two. Load on the database: 0.10. The bottle neck occured at the webserver, the number of processes that were running used up more RAM than it had. so in theory if I gave the webserver enough power so it could handle 1,500 hits per second, the database server might actually start using 100% of its cpu. Seeking advice on a mysql list might help. Curt -- Quoth the Raven, Nevermore. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] A problem about urlencode
I have a url containing some multi-byte characters. So I need urlencode() to change these characters into the %xx form. However, when I encode the whole url string, / is also be encoded as %2F. How to solve this problem? I don't want to analyze the url string before/after urlencode(). Thanks a lot. eruisi 10/25/2004 03:19:55 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] clearstatcache, how to use?
* Thus wrote Louie Miranda: I have this code that checks for a file if it exists and do something if it doesnt exist. Problem exist when im updating my data on the directory, even if i did upload it. it still shows the non-existent data. I have read that i should add the clearstatcache();, how am i going to use it? after the file_exists? or before? before. but you only need to issue that if you've done one of the file operations listed in the 'Affected' list on http://php.net/clearstatcache Another reason why file_exists() could fail is due to the fact that the user php is running as my not have access to the path of the file. PHP will issue a warning about that but if you may have your errors suppressed. Curt -- Quoth the Raven, Nevermore. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need function to process tab delimited file using associative array
On 25/10/2004, at 12:22 PM, Eric Wood wrote: Does anyone have a function stored away that can selectively let me trim out only the columns *by name* I need from a delimited text file? For Example: FNametabLNametabPhone JohntabSmithtab345335 JamestabSmithtab2345223533 JudytabSmithtab5474574544 I think (at least for clarity and reusability), you're better off breaking the process into two parts: 1. get the data into an associative array 2. loop through the array and print what you need The added bonus here is that #1 can be re-used over and over again! Here's a function for #1: ? function csvToArrayByName($file,$delim=',',$enclosure='') { $rows = array(); $handle = fopen($file, r); while(($data = fgetcsv($handle, 1000, $delim, $enclosure='')) !== FALSE) { if(!count($labels)) { $labels = $data; } else { foreach($data as $k = $v) $row[$labels[$k]] = $v; $rows[] = $row; } } fclose($handle); return $rows; } ? And you use it like this to achieve #2: ? $people = csvToArrayByName(names.csv,\t); foreach($people as $person) { echo {$person['FName']} {$person['Phone']}br /; } ? Or: ? $books = csvToArrayByName(books.csv,\t); foreach($books as $book) { echo {$book['Title']} {$book['ISBN']} {$book['price']}br /; } ? The disadvantage is that you have to loop through the data twice (once as a tab-delimited file, once as an assoc. array), which would have obvious problems when there's a large set of data that needs to be looped through often. In which case I'd just be looping though the data once and using numeric keys instead of named keys. Obviously there's a lot more error checking and code that could be added to the above function, but hopefully it gives you enough to get started. Justin French -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] transfer file
How to transfer text file from one machine to another using php Please give the code if possible akshay -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] transfer file
How to transfer text file from one machine to another using php Please give the code if possible akshay -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Most efficient way of fetching 1,000 records from MySQL ?
Hello, In my script I have generated an array of 1,000 userIDs for example. Now for I need to fetch each user's record and I am wondering what is the best way to go about it: 1) 1000 sql queries // code is sort of pseudo for clarity foreach($users as $userID) { $user = sql(select * from users where userID = '$userID'); // bla bla } 2) 1 query $users = sql(select * from users where userID='1' or userID='2' or userID='5' or userID='10'); I imagine the 2nd one would be a bit of a nightmare for MySQL to parse, if it gets too long? Or am I missing a more efficient 3rd / 4th option? Many thanks in advance for your help. Steve McGill -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Most efficient way of fetching 1,000 records from MySQL ?
I think you'll find that your first approach is not only more correct, it's the only manageable one. Ian On Mon, 2004-10-25 at 10:15 +0200, Steve McGill wrote: Hello, In my script I have generated an array of 1,000 userIDs for example. Now for I need to fetch each user's record and I am wondering what is the best way to go about it: 1) 1000 sql queries // code is sort of pseudo for clarity foreach($users as $userID) { $user = sql(select * from users where userID = '$userID'); // bla bla } 2) 1 query $users = sql(select * from users where userID='1' or userID='2' or userID='5' or userID='10'); I imagine the 2nd one would be a bit of a nightmare for MySQL to parse, if it gets too long? Or am I missing a more efficient 3rd / 4th option? Many thanks in advance for your help. Steve McGill -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] transfer file
Akshay wrote: How to transfer text file from one machine to another using php Please give the code if possible It depends on what protocol you want to use. Please pick from FTP, HTTP, NFS etc and let us know. akshay -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Most efficient way of fetching 1,000 records from MySQL ?
Ian Firla wrote: I think you'll find that your first approach is not only more correct, it's the only manageable one. No, it will be very slow. The biggest overhead is in transfering data to and from sql server. It's always better to get the results in one sql query. Use this aproach: $users = sql('select * from users where userID IN ('. implode(', ',$users) .')'); Ian On Mon, 2004-10-25 at 10:15 +0200, Steve McGill wrote: Hello, In my script I have generated an array of 1,000 userIDs for example. Now for I need to fetch each user's record and I am wondering what is the best way to go about it: 1) 1000 sql queries // code is sort of pseudo for clarity foreach($users as $userID) { $user = sql(select * from users where userID = '$userID'); // bla bla } 2) 1 query $users = sql(select * from users where userID='1' or userID='2' or userID='5' or userID='10'); I imagine the 2nd one would be a bit of a nightmare for MySQL to parse, if it gets too long? Or am I missing a more efficient 3rd / 4th option? Many thanks in advance for your help. Steve McGill -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sessions problem bug
Some days ago I asked some questions concerning php and sessions Apparently it seems to be a bug: 'When you use a session name that has only numbers, each call to session_start seems to regenerate a new session id, so the session does not persist.' http://bugs.php.net/search.php?search_for=sessionboolean=0limit=10ord er_by=direction=ASCcmd=displaystatus=Openbug_type%5B%5D=Session+rela tedphp_os=phpver=assign=author_email=bug_age=0 And there you pick bug with ID 27688 Just to let everyone know. Greetz, Reinhart Viane Reinhart Viane [EMAIL PROTECTED] Domos || D-Studio Graaf Van Egmontstraat 15/3 -- B 2800 Mechelen -- tel +32 15 44 89 01 -- fax +32 15 43 25 26 STRICTLY PERSONAL AND CONFIDENTIAL This message may contain confidential and proprietary material for the sole use of the intended recipient. Any review or distribution by others is strictly prohibited. If you are not the intended recipient please contact the sender and delete all copies. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] chm file for tutorial
Hello all, I am new to PHP programming.. It will be nice to have a chm file on php tutorial. Can anyone point me to that location ? Also I would like to know how how to code the following line ? a href='http://www.geocities.com/murugesangct/index.html'Mail http://www.geocities.com/murugesangct/index.html /a Regards, Dinesh_P_V
Re: [PHP] chm file for tutorial
[EMAIL PROTECTED] wrote: Hello all, I am new to PHP programming.. It will be nice to have a chm file on php tutorial. Can anyone point me to that location ? http://www.php.net/download-docs.php Also I would like to know how how to code the following line ? a href='http://www.geocities.com/murugesangct/index.html'Mail http://www.geocities.com/murugesangct/index.html /a You just did. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] chm file for tutorial
Thanks Marek... a href='http://www.geocities.com/murugesangct/index.html'Mail http://www.geocities.com/murugesangct/index.html /a You just did. and got the answer from the tutorial... Regards, Dinesh_P_V -Original Message- From: Marek Kilimajer [mailto:[EMAIL PROTECTED] Sent: Monday, October 25, 2004 4:58 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] chm file for tutorial [EMAIL PROTECTED] wrote: Hello all, I am new to PHP programming.. It will be nice to have a chm file on php tutorial. Can anyone point me to that location ? http://www.php.net/download-docs.php Also I would like to know how how to code the following line ? a href='http://www.geocities.com/murugesangct/index.html'Mail http://www.geocities.com/murugesangct/index.html /a You just did.
RE: [PHP] Most efficient way of fetching 1,000 records from MySQL ?
I would certainly agree with Marek. I recently changed a query from using 20 or so 'OR' conditions to use the 'IN' statement and it drastically improved the performance of the query. Graham -Original Message- From: Marek Kilimajer [mailto:[EMAIL PROTECTED] Sent: 25 October 2004 11:37 To: Ian Firla Cc: Steve McGill; [EMAIL PROTECTED] Subject: Re: [PHP] Most efficient way of fetching 1,000 records from MySQL ? Ian Firla wrote: I think you'll find that your first approach is not only more correct, it's the only manageable one. No, it will be very slow. The biggest overhead is in transfering data to and from sql server. It's always better to get the results in one sql query. Use this aproach: $users = sql('select * from users where userID IN ('. implode(', ',$users) .')'); [snip] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Most efficient way of fetching 1,000 records from MySQL ?
I think you'll find that your first approach is not only more correct, it's the only manageable one. No, it will be very slow. The biggest overhead is in transfering data to and from sql server. It's always better to get the results in one sql query. Use this aproach: $users = sql('select * from users where userID IN ('. implode(', ',$users) .')'); That is precisely what I wanted, many thanks for your help guys. Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Convert an array in an object instance
Hi, Is it possible to convert an array in an object instance? I can convert an object in an array as follows: $Test = new MyClass (); $TestArray = (array) $Test; Then I've an array with all members of the object $Test, but it seems that I cannot simply do: $TestObject = (MyClass) $TestArray; To recover the object in the inverse way, so... is there any manner to do this? Thanks a lot in advance, -- PHP Internals - PHP Runtime Development Mailing List 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] Passing regexp substrings to a function
Hi there, I have a few e-mail templates in a file that should be parsed. A template can include also some module codes that should be replaced by a return value of a certain function. For example, if the template include a text {ProductInfo:1032}, the value 1032 would be passed as an argument to a function mdlProductInfo() and the whole string would be replaced by the return value of the function. One possible way is to loop the string like this: while(eregi({([a-z])(:[a-z0-9])+}, $template, $regs)) { list($whole, $function, $valuestring) = $regs; $values = explode(:, substr($valuestring, 1)); unset($retval); eval($retval = mdl.$function.(.join(,, $values).);); $template = str_replace($whole, $retval, $template); } Any other ideas on this? Ville -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Convert an array in an object instance
Francisco M. Marzoa Alonso wrote: Hi, Is it possible to convert an array in an object instance? I can convert an object in an array as follows: $Test = new MyClass (); $TestArray = (array) $Test; Then I've an array with all members of the object $Test, but it seems that I cannot simply do: $TestObject = (MyClass) $TestArray; $TestObject = (object) $TestArray; To recover the object in the inverse way, so... is there any manner to do this? Thanks a lot in advance, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Substr
Hi, I have a string as follows: pid_1_date_2004_10_25 pid tells me the Project_ID and date tells me the date(!). I need to extract this information from the string so to get the date I need everything after 'date_' as follows: substr(strstr($key, 'date_'), 4) However, to get the Project ID I need to extract everything after 'pid_' and everything before 'date_'. Can someone help me with this please as PHP doesn't seem to provide a function for extracting information from a string that occurs before the 'needle'? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Substr
Shaun wrote: However, to get the Project ID I need to extract everything after 'pid_' and everything before 'date_'. Can someone help me with this please as PHP doesn't seem to provide a function for extracting information from a string that occurs before the 'needle'? yes it doe. look under regular expressions. -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Substr
Use regular expresions: ?php $string = pid_1_date_2004_10_25; preg_match ( '/^pid_(.*?)_date_(.*?)$/', $string, $regs ); print_r ($regs); ? Shaun wrote: Hi, I have a string as follows: pid_1_date_2004_10_25 pid tells me the Project_ID and date tells me the date(!). I need to extract this information from the string so to get the date I need everything after 'date_' as follows: substr(strstr($key, 'date_'), 4) However, to get the Project ID I need to extract everything after 'pid_' and everything before 'date_'. Can someone help me with this please as PHP doesn't seem to provide a function for extracting information from a string that occurs before the 'needle'? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A problem about urlencode
Teng Wang wrote: I have a url containing some multi-byte characters. So I need urlencode() to change these characters into the %xx form. However, when I encode the whole url string, / is also be encoded as %2F. How to solve this problem? I don't want to analyze the url string before/after urlencode(). According to my understanding this is the correct behaviour for url encode. The fact that your string is multibyte or not has little relevence in convertin '/' to %2f. You are unly supposed to use the urlencode() function on the query string or to be more precise on each value that you pass via the query string and NOT on the whole URL. -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Substr
You can also use split function if you do not know about regular expressions and do not want to learn: ?php $string = pid_1_date_2004_10_25; $regs = split (_, $string ); print_r ($regs); ? I think its autoexplicative. Shaun wrote: Hi, I have a string as follows: pid_1_date_2004_10_25 pid tells me the Project_ID and date tells me the date(!). I need to extract this information from the string so to get the date I need everything after 'date_' as follows: substr(strstr($key, 'date_'), 4) However, to get the Project ID I need to extract everything after 'pid_' and everything before 'date_'. Can someone help me with this please as PHP doesn't seem to provide a function for extracting information from a string that occurs before the 'needle'? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Substr
What about using explode()? $array = explode('_', 'pid_1_date_2004_10_25'); $pid = $array[1]; $yr = $array[3]; $mn = $array[4]; $dy = $array[5]; Graham -Original Message- From: Shaun [mailto:[EMAIL PROTECTED] Sent: 25 October 2004 14:00 To: [EMAIL PROTECTED] Subject: [PHP] Substr Hi, I have a string as follows: pid_1_date_2004_10_25 pid tells me the Project_ID and date tells me the date(!). I need to extract this information from the string so to get the date I need everything after 'date_' as follows: substr(strstr($key, 'date_'), 4) However, to get the Project ID I need to extract everything after 'pid_' and everything before 'date_'. Can someone help me with this please as PHP doesn't seem to provide a function for extracting information from a string that occurs before the 'needle'? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need function to process tab delimited file using associative array
- Original Message - From: Justin French The disadvantage is that you have to loop through the data twice (once as a tab-delimited file, once as an assoc. array), which would have obvious problems when there's a large set of data that needs to be looped through often. Justin French Justin, Your fgetcsv() function was what I was needing. I found this in it notes: snip_from_fgetcsv Quick and dirty script to take a csv file and turn it into a multidimensional associative array structure using the first line of the csv as the hash key names. ? $i = 0; $handle = fopen (file.csv,r); while($data = fgetcsv ($handle, 1000, ,)) { if ($i == 0) { $key_arr = $data; } reset($key_arr); while(list($index,$name) = each($key_arr)) { $temp_arr[$name] = $data[$index]; } $result_arr[$i] = $temp_arr; $i++; } fclose ($handle); ? /snip_from_fgetcsv Thanks! -eric wood -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Passing regexp substrings to a function
Hi, In perl, you can do something like: $string =~ s/---piece of text that contains a certain (VALUE) in it---/function($1)/gse; This expression replaces its first part with the result of the function function called with the parameter VALUE. Is this what you want? Maybe you can do something like that using perl regular expressions in PHP... Teddy - Original Message - From: Ville Mattila [EMAIL PROTECTED] To: PHP General Mailing List [EMAIL PROTECTED] Sent: Monday, October 25, 2004 2:33 PM Subject: [PHP] Passing regexp substrings to a function Hi there, I have a few e-mail templates in a file that should be parsed. A template can include also some module codes that should be replaced by a return value of a certain function. For example, if the template include a text {ProductInfo:1032}, the value 1032 would be passed as an argument to a function mdlProductInfo() and the whole string would be replaced by the return value of the function. One possible way is to loop the string like this: while(eregi({([a-z])(:[a-z0-9])+}, $template, $regs)) { list($whole, $function, $valuestring) = $regs; $values = explode(:, substr($valuestring, 1)); unset($retval); eval($retval = mdl.$function.(.join(,, $values).);); $template = str_replace($whole, $retval, $template); } Any other ideas on this? Ville -- 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] Php files with .html extension?
Hi, How can i do a php script with a html extensionsuch as http://www.blinds-wise.com/shop/p/blind/bid/1/venetian_blinds.html Thanks
Re: [PHP] Substr
split() uses the POSIX regular expressions engine, and thus also uses regular expressions. The loading of this engine is a massive overhead when dealing with simple splitting of a string. To do basic things like this it's a lot faster to use explode(). - Tul Francisco M. Marzoa Alonso wrote: You can also use split function if you do not know about regular expressions and do not want to learn: ?php $string = pid_1_date_2004_10_25; $regs = split (_, $string ); print_r ($regs); ? I think its autoexplicative. Shaun wrote: Hi, I have a string as follows: pid_1_date_2004_10_25 pid tells me the Project_ID and date tells me the date(!). I need to extract this information from the string so to get the date I need everything after 'date_' as follows: substr(strstr($key, 'date_'), 4) However, to get the Project ID I need to extract everything after 'pid_' and everything before 'date_'. Can someone help me with this please as PHP doesn't seem to provide a function for extracting information from a string that occurs before the 'needle'? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Php files with .html extension?
Phpu wrote: Hi, How can i do a php script with a html extensionsuch as http://www.blinds-wise.com/shop/p/blind/bid/1/venetian_blinds.html Thanks when using eg. apache, you can add a .htaccess file with the following line: AddType application/x-httpd-php .html That will overwrite the normal way apache handles .html files, and it will let the php engine parse them in that and all subdirectories (which don't reset this behavious using another .htaccess file with different Type-related options) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: overiding functions (constructors mostly)
M Saleh Eg wrote: OR you could control ur method and have optional arguments in ur argument list and decide what to do according to that. e.g. public function _construct($param1=0, $param2=, $param3=null) { if($param1) if($param2) if($param3) } $obj=new className(1); //Or $obj=new className(1,hello); //Or $obj=new className(0,,some_value); Bottom Line: Optional arguments might be a workaround lack of polymorphism sometimes ! Better use if (isset($param1)) { ... then, otherwise values such as 0 will cause difficulties. -- Daniel Schierbeck Help spread Firefox (www.getfirefox.com): http://www.spreadfirefox.com/?q=user/registerr=6584 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Convert an array in an object instance
[EMAIL PROTECTED] wrote: No. You need to remember that in most cases where you cast a variable from one type to another, you will experience data (precision) loss. This is also the case in converting an object to an array. Only the properties are copied over (since functions can not be part of an array). The point is interesting, but as far as I do not need to store class methods I think there's nothing lost between conversion. I'll store the name of the class of the instance, so the methods of the instance will be those of that class. I only need some manner to tell PHP that the object is an instance of MyClass (following the original example) to have the object exactly equal as it was before conversions. Perl has a function to to that, that's called bless: http://www.perldoc.com/perl5.6/pod/func/bless.html FYI, the reason I need this is because I'm creating my own object's serialization routines. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php files with .html extension?
On Mon, 25 Oct 2004 16:37:52 +0300, Phpu [EMAIL PROTECTED] wrote: How can i do a php script with a html extensionsuch as http://www.blinds-wise.com/shop/p/blind/bid/1/venetian_blinds.html If you use Apache you can edit you httpd.conf and add: AddType application/x-httpd-php .html -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php files with .html extension?
On Mon, 2004-10-25 at 09:37, Phpu wrote: Hi, How can i do a php script with a html extensionsuch as http://www.blinds-wise.com/shop/p/blind/bid/1/venetian_blinds.html AddType application/x-httpd-php .php .php3 .html -- s/:-[(/]/:-)/g BrianGnuPG - KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu == gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC Key Info: http://gfx-design.com/keys Linux Registered User #339825 at http://counter.li.org aGEhIGJldCB5b3UgdGhpbmsgeW91IHByZXR0eSBzbGljayBmb3IgZmlndXJpbmcgb3V0I GhvdyB0byBkZWNvZGUgdGhpcy4gVG9vIGJhZCBpdCBoYXMgbm8gc2VjcmV0IGluZm8gaW 4gaXQgaGV5Pwo= -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Php files with .html extension?
[snip] How can i do a php script with a html extensionsuch as http://www.blinds-wise.com/shop/p/blind/bid/1/venetian_blinds.html [/snip] You set it up in your httpd.conf You should have AddType application/x-httpd-php .php change it to AddType application/x-httpd-php .php .html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php files with .html extension?
How can i do a php script with a html extensionsuch as http://www.blinds-wise.com/shop/p/blind/bid/1/venetian_blinds.html apache could do this a couple ways http://httpd.apache.org/docs/mod/mod_mime.html#addhandler http://httpd.apache.org/docs-2.0/mod/core.html#setinputfilter http://httpd.apache.org/docs-2.0/mod/core.html#setoutputfilter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] cant override session variables
Hi all, This is drving me insane... I have a logout script, logout.php: ? $_SESSION['validlogin']=; $_SESSION['username']=; $_SESSION['password']=; unset($_SESSION['validlogin']); unset($_SESSION['username']); unset($_SESSION['password']); session_unset(); print(username=.$_SESSION['username']); print(password=.$_SESSION['password']); if(session_id()){ session_destroy();} ? that effectively cleans the session variables. However, when i try to set them again, they won't take the new values: ? session_start(); $_SESSION['validlogin']=true; $_SESSION['username']=$username; $_SESSION['password']=$password; print(username_session .$_SESSION['username']); exit(); ? will print: username_session blank... I know globals are on...what's a happening? why the variables are cleaned fine why there's no override? tia, lizet
Re: [PHP] Re: Convert an array in an object instance
Francisco M. Marzoa Alonso wrote: [EMAIL PROTECTED] wrote: No. You need to remember that in most cases where you cast a variable from one type to another, you will experience data (precision) loss. This is also the case in converting an object to an array. Only the properties are copied over (since functions can not be part of an array). The point is interesting, but as far as I do not need to store class methods I think there's nothing lost between conversion. I'll store the name of the class of the instance, so the methods of the instance will be those of that class. I only need some manner to tell PHP that the object is an instance of MyClass (following the original example) to have the object exactly equal as it was before conversions. Perl has a function to to that, that's called bless: http://www.perldoc.com/perl5.6/pod/func/bless.html FYI, the reason I need this is because I'm creating my own object's serialization routines. $obj = new MyClass; foreach($array as $key = $val) $obj-$key = $val; Not very elegant but the only way as far as I know -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Convert an array in an object instance
Marek Kilimajer wrote: Francisco M. Marzoa Alonso wrote: [EMAIL PROTECTED] wrote: No. You need to remember that in most cases where you cast a variable from one type to another, you will experience data (precision) loss. This is also the case in converting an object to an array. Only the properties are copied over (since functions can not be part of an array). The point is interesting, but as far as I do not need to store class methods I think there's nothing lost between conversion. I'll store the name of the class of the instance, so the methods of the instance will be those of that class. I only need some manner to tell PHP that the object is an instance of MyClass (following the original example) to have the object exactly equal as it was before conversions. Perl has a function to to that, that's called bless: http://www.perldoc.com/perl5.6/pod/func/bless.html FYI, the reason I need this is because I'm creating my own object's serialization routines. $obj = new MyClass; foreach($array as $key = $val) $obj-$key = $val; Not very elegant but the only way as far as I know Its an interesting workaround, but that doesn't work with classes that has mandatory arguments on its constructors. :-( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Convert an array in an object instance
* Thus wrote Francisco M. Marzoa Alonso: FYI, the reason I need this is because I'm creating my own object's serialization routines. Why would you want to do this? Curt -- Quoth the Raven, Nevermore. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Convert an array in an object instance
Curt Zirzow wrote: * Thus wrote Francisco M. Marzoa Alonso: FYI, the reason I need this is because I'm creating my own object's serialization routines. Why would you want to do this? I was walking through the forest when, suddenly, a white light comes from the west through the trees calling me. Who are you? What do you want from me? -I said- You!, bastard!!!, do your own serialization routines!!... That, and the fact that PHP standard serialization functions does not fit my needs, did finally convince me to do it ;-) but I did not find a way to bless O:-) my objects as in Perl... wait a minute! perhaps that Holy voice wants to show me that objects cannot be blessed in PHP!... I'm scared... Curt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Php files with .html extension?
Do not forget that if you do this ALL files with the .html extension will be parsed by PHP whether they are PHP scripts or not which could be something you need to consider from a performance perspective. -Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: 25 October 2004 14:59 To: [EMAIL PROTECTED] Subject: RE: [PHP] Php files with .html extension? [snip] How can i do a php script with a html extensionsuch as http://www.blinds-wise.com/shop/p/blind/bid/1/venetian_blinds.html [/snip] You set it up in your httpd.conf You should have AddType application/x-httpd-php .php change it to AddType application/x-httpd-php .php .html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Php files with .html extension?
That's definitely a good point. I'm curious though, would it really be a significant performance issue? Even if a lot of HTML files are being processed by PHP? I mean, if the PHP parser goes through and never sees a ? Or ?php, does it do any more than just output the file? True, that's something, but is it anything really significant. The only thing I can think of that'd be an issue is, what happens if you have a bad compile of PHP, or what happens to a system after PHP is run 180,000 times? Small programming issues can create minute instability issues for systems. Or in the case of outright memory leaks, sometimes a major issue. That's the only thing that'd really concern me, but it's still definitely a good question to ask. -TG -Original Message- From: Graham Cossey [mailto:[EMAIL PROTECTED] Sent: Monday, October 25, 2004 11:30 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] Php files with .html extension? Do not forget that if you do this ALL files with the .html extension will be parsed by PHP whether they are PHP scripts or not which could be something you need to consider from a performance perspective. -Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: 25 October 2004 14:59 To: [EMAIL PROTECTED] Subject: RE: [PHP] Php files with .html extension? [snip] How can i do a php script with a html extensionsuch as http://www.blinds-wise.com/shop/p/blind/bid/1/venetian_blinds.html [/snip] You set it up in your httpd.conf You should have AddType application/x-httpd-php .php change it to AddType application/x-httpd-php .php .html -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cant override session variables
Hello, Monday, October 25, 2004, 3:13:02 PM, you wrote: LPdS I know globals are on...what's a happening? why the LPdS variables are cleaned fine why there's no override? Are you trying to do all of that in the same script? Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services I am not young enough to know everything. - Oscar Wilde -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Crypt on MacOSX
I recently moved a site to a MacOSX based Apache/PHP server. Apparently crypt only uses DES. I read somewhere that there is no way to get it use use MD5, which sounds hard to beleive considering the OS is BSD based. So.. here is my dilema.. My db contains usernames and passwords. The passwords are MD5 $1ljdslkjdsf$lkjdsaflkjdsf (created by crypt().) So on this new box, new accounts created get DES passwords. I just as well prefer to not see any DES encryptions used in this db. Any Mac OSX'ers in here that may have a solution? All my users recreating new passwords for their account is not an option. Thanks for any ideas, Kris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: overiding functions (constructors mostly)
Exactly Daniel ! I should've mentioned that too. Thanx for making it clear. On Mon, 25 Oct 2004 15:45:36 +0200, Daniel Schierbeck [EMAIL PROTECTED] wrote: M Saleh Eg wrote: OR you could control ur method and have optional arguments in ur argument list and decide what to do according to that. e.g. public function _construct($param1=0, $param2=, $param3=null) { if($param1) if($param2) if($param3) } $obj=new className(1); //Or $obj=new className(1,hello); //Or $obj=new className(0,,some_value); Bottom Line: Optional arguments might be a workaround lack of polymorphism sometimes ! Better use if (isset($param1)) { ... then, otherwise values such as 0 will cause difficulties. -- Daniel Schierbeck Help spread Firefox (www.getfirefox.com): http://www.spreadfirefox.com/?q=user/registerr=6584 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- M.Saleh.E.G 97150-4779817 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php extension problem
Hi ! I am having some trouble creating a php extension. as show in the documentation i did a ./ext_skel --extname=mymodule which created the directory mymodule i edited the config.m4 file to tune it to something very basic : PHP_ARG_WITH(mymodule, for mymodule support, [ --with-mymodule Include mymodule support]) if test $PHP_MYMODULE != no; then PHP_NEW_EXTENSION(mymodule, mymodule.c, $ext_shared) fi saved and went to the base of the source tree... [EMAIL PROTECTED]:/usr/src/php4-4.3.9$ ./buildconf You should not run buildconf in a release package. use buildconf --force to override this check. [EMAIL PROTECTED]:/usr/src/php4-4.3.9$ ./buildconf --force Forcing buildconf using default Zend directory buildconf: checking installation... buildconf: autoconf version 2.59 (ok) buildconf: Your version of autoconf likely contains buggy cache code. Running cvsclean for you. To avoid this, install autoconf-2.13 and automake-1.5. buildconf: libtool version 1.5.6 (ok) rebuilding configure autoconf/programs.m4:438: AC_DECL_YYTEXT is expanded from... configure.in:147: the top level [EMAIL PROTECTED]:/usr/src/php4-4.3.9$ then, i been looking up if the module was taken [EMAIL PROTECTED]:/usr/src/php4-4.3.9$ ./configure --help | grep -i mymodule [EMAIL PROTECTED]:/usr/src/php4-4.3.9$ and no, it's not any idea ? something i did wrong ? thank you :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Php files with .html extension?
Hello Trevor, Monday, October 25, 2004, 4:47:53 PM, you wrote: GT processed by PHP? I mean, if the PHP parser goes through and never sees GT a ? Or ?php, does it do any more than just output the file? True, GT that's something, but is it anything really significant. True, it doesn't do anything other than output the HTML. But it's that load - scan - determine - output that takes up CPU time and memory. Sure, on most sites it doesn't matter one bit. But on popular sites.. well, you can do the math I'm sure. I guess at the end of the day it comes down to don't do un-necessary things. That goes for your code as well as your server set-up, but it's true to say that if you don't actually need to parse HTML as PHP, then don't. Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services I am not young enough to know everything. - Oscar Wilde -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Content-Type header required for POST?
Hi, Since which version does PHP require the Content-Type header in POST requests? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP] Php files with .html extension?
True, it doesn't do anything other than output the HTML. But it's that load - scan - determine - output that takes up CPU time and memory. Sure, on most sites it doesn't matter one bit. But on popular sites.. well, you can do the math I'm sure. I guess at the end of the day it comes down to don't do un-necessary things. That goes for your code as well as your server set-up, but it's true to say that if you don't actually need to parse HTML as PHP, then don't. Well yeah. I fully agree. Keep it simple, don't put any more load on a server than you have to, don't run anything you don't have to, don't provide any opportunity for the system to become unstable or slow... if you don't have to. Going on the assumption that someone might have a requirement to use .html, I was wondering what the impact would be. I could see someone wanting to use .html to obscure the fact that they were using PHP scripts (for various reason), but if that's intended as a security measure, then it's classic security through obscurity, which will fool some people, but not the people you really have to worry about. -TG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: overiding functions (constructors mostly)
M Saleh Eg wrote: Exactly Daniel ! I should've mentioned that too. Thanx for making it clear. No problem 8) -- Daniel Schierbeck Help spread Firefox (www.getfirefox.com): http://www.spreadfirefox.com/?q=user/registerr=6584 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Crypt on MacOSX
Kris wrote: I recently moved a site to a MacOSX based Apache/PHP server. Apparently crypt only uses DES. I read somewhere that there is no way to get it use use MD5, which sounds hard to beleive considering the OS is BSD based. So.. here is my dilema.. My db contains usernames and passwords. The passwords are MD5 $1ljdslkjdsf$lkjdsaflkjdsf (created by crypt().) So on this new box, new accounts created get DES passwords. I just as well prefer to not see any DES encryptions used in this db. Any Mac OSX'ers in here that may have a solution? All my users recreating new passwords for their account is not an option. Thanks for any ideas, Kris Can't you just use the db's (i assume you use MySQL, most do) built-in MD5 function? SELECT id, username FROM users WHERE username LIKE 'myuser' AND password = MD5('mypass') LIMIT 1 -- Daniel Schierbeck Help spread Firefox (www.getfirefox.com): http://www.spreadfirefox.com/?q=user/registerr=6584 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[4]: [PHP] Php files with .html extension?
Hello Trevor, Monday, October 25, 2004, 6:31:07 PM, you wrote: GT I could see someone wanting to use .html to obscure the fact that GT they were using PHP scripts (for various reason), but if that's GT intended as a security measure, then it's classic security through GT obscurity, which will fool some people, but not the people you GT really have to worry about. Absolutely. Which begs the question - why bother? One of the only reasons I can think of is if you were moving from a static HTML site to a PHP site and you were already well indexed on Google, etc - you may want to retain those links and not cause 404's all over the place, in which case it makes business sense. But for most people the obscurity is simply fooling the wrong folks. I don't think you'll find any real benchmarks on this because they're so subjective and rely more on your hosting arrangement than PHP itself. But I'm sure you could simulate a stress-test for this quite easily. Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services I am not young enough to know everything. - Oscar Wilde -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php files with .html extension?
On Mon, 25 Oct 2004 16:30:14 +0100, Graham Cossey [EMAIL PROTECTED] wrote: Do not forget that if you do this ALL files with the .html extension will be parsed by PHP whether they are PHP scripts or not which could be something you need to consider from a performance perspective. I setup a simple benchmark test because I was curious how much overhead parsing .html files as PHP files actually caused. Here are those results: Server specs: Debain Sarge (testing) uname -a Linux netpc0378 2.6.7-1-686 #1 Thu Jul 8 05:36:53 EDT 2004 i686 GNU/Linux php4 -v PHP 4.3.4 (cli) (built: Mar 27 2004 08:04:22) Copyright (c) 1997-2003 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies apache -v Server version: Apache/1.3.31 (Debian GNU/Linux) Server built: Sep 9 2004 07:31:19 cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 8 model name : Celeron (Coppermine) stepping: 10 cpu MHz : 997.253 cache size : 128 KB fdiv_bug: no hlt_bug : no f00f_bug: no coma_bug: no fpu : yes fpu_exception : yes cpuid level : 2 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse bogomips: 1978.36 free -m total used free sharedbuffers cached Mem: 249189 59 0 1 54 -/+ buffers/cache:134115 Swap: 486 29456 The index.html test file is very simple: html head titleBenchmark Test/title /head body bgcolor=white Benchmark Me! /body /html Then the actual tests: 1) Apache not parsing .html files as PHP: ab -n1 http://localhost/benchmark/ This is ApacheBench, Version 1.3d $Revision: 1.73 $ apache-1.3 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Finished 1 requests Server Software:Apache/1.3.31 Server Hostname:localhost Server Port:80 Document Path: /benchmark/ Document Length:270 bytes Concurrency Level: 1 Time taken for tests: 27.134 seconds Complete requests: 1 Failed requests:0 Broken pipe errors: 0 Non-2xx responses: 1 Total transferred: 449 bytes HTML transferred: 270 bytes Requests per second:368.54 [#/sec] (mean) Time per request: 2.71 [ms] (mean) Time per request: 2.71 [ms] (mean, across all concurrent requests) Transfer rate: 165.48 [Kbytes/sec] received Connnection Times (ms) min mean[+/-sd] median max Connect:0 00.0 0 2 Processing: 1 2 19.8 1 810 Waiting:0 2 19.8 1 810 Total: 1 2 19.8 1 810 Percentage of the requests served within a certain time (ms) 50% 1 66% 1 75% 1 80% 1 90% 2 95% 3 98% 3 99% 14 100%810 (last request) 2) Apache parsing .html files as PHP: (I edited /etc/apache/mime.types and added html to the application/x-httpd-php line, and then I restarted Apache.) ab -n1 http://localhost/benchmark/ This is ApacheBench, Version 1.3d $Revision: 1.73 $ apache-1.3 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Finished 1 requests Server Software:Apache/1.3.31 Server Hostname:localhost Server Port:80 Document Path: /benchmark/ Document Length:270 bytes Concurrency Level: 1 Time taken for tests: 30.215 seconds Complete requests: 1 Failed requests:0 Broken pipe errors: 0 Non-2xx responses: 1 Total transferred: 449 bytes HTML transferred: 270 bytes Requests per second:330.96 [#/sec] (mean) Time per request: 3.02 [ms] (mean) Time per request: 3.02 [ms] (mean, across all concurrent requests) Transfer rate: 148.60 [Kbytes/sec] received Connnection Times (ms) min mean[+/-sd] median max Connect:0 00.0 0 1 Processing: 1 2 23.9 1 919 Waiting:0 2 23.9 1 918 Total: 1 2 23.9 1 919 ERROR: The median and mean for the
Re: [PHP] Content-Type header required for POST?
--- Olaf van der Spek [EMAIL PROTECTED] wrote: Since which version does PHP require the Content-Type header in POST requests? Content-Type is required for any request that has content. It's an HTTP requirement and has very little to do with PHP. Can you explain what you're talking about? Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly HTTP Developer's Handbook - Sams Coming December 2004http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php files with .html extension?
* Thus wrote Greg Donald: The summary results: For 10K local requests: 27.1 seconds with .html not parsed as PHP vs. 30.2 seconds with .html parsed as PHP. I only ran these tests locally, and only on the one server.. so it's definatly not very scientific. I think we all sorta knew the results anyway. Nice work! I wonder what the stats would be like with apache2 :) Curt -- Quoth the Raven, Nevermore. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Register Globals
I just signed up with a new hosting site. So first thing I did was check what phpinfo() had to say. I see that register_globals is turned on. Now I always use the $_GET and $_POST vars but will this still affect me? -- --Matthew Sims --http://killermookie.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Register Globals
[snip] I just signed up with a new hosting site. So first thing I did was check what phpinfo() had to say. I see that register_globals is turned on. Now I always use the $_GET and $_POST vars but will this still affect me? [/snip] Nope, you can keep using, and should keep using, the $_GET and $_POST arrays. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Compiling PHP with extension; CLI works, Apache doesn't
I just compiled PHP with an extension for testing purposes (mnoGoSearch). After all was said and done, the CLI version sees the mnogosearch extension just fine (php -m), but the Apache module doesn't see it at all (nothing mnogosearch related at all in PHPINFO()). I've added extension=mnogosearch.so to php.ini. I'm pretty sure that with other extensions I've tried in the past, there was nothing special necessary to make an extension work among the different PHP APIs. My PHP compile line: ./configure --prefix=/usr/local/php \ --with-apxs=/usr/local/apache/bin/apxs --with-mysql=/usr \ --with-gettext --enable-ftp --with-zlib --with-pspell --with-curl \ --with-mcrypt --with-mnogosearch=shared,/usr/local/mnogosearch \ --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --disable-cgi The vital server software: PHP 5.0.2 Apache 1.3.31 RH Enterprise Linux 3 (Update 3) Am I missing something? -- Aaron Gould Parts Canada - Web Developer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] @session_start generates a new session_id
Hi Sadeq, Check your PHP config file. You may enable auto session start. I think this is the reasone of problem. sorry for the delay and indeed your suggestion solves now my problem. Thank's a lot :-) -- Best Regards, Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Register Globals
[snip] I just signed up with a new hosting site. So first thing I did was check what phpinfo() had to say. I see that register_globals is turned on. Now I always use the $_GET and $_POST vars but will this still affect me? [/snip] Nope, you can keep using, and should keep using, the $_GET and $_POST arrays. And this won't pose as a security risk to me? Just for kicks I tried using the .htaccess to turn it off locally but the hosting site doesn't have the AllowOverride option set for me. -- --Matthew Sims --http://killermookie.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Register Globals
On Monday 25 October 2004 02:50 pm, Matthew Sims wrote: [snip] I see that register_globals is turned on. Now I always use the $_GET and $_POST vars but will this still affect me? [snip] Matthew, Although it shouldn't affect you, I had a terrible time trying to get anything to pass via sessions with register_globals=on with a site I had rebuilt. All sorts of strange behavior -- if you look back in the archives you see what I mean. Once register_globals was switched to 'off' everything worked as expected. Sorry to throw a wrench into the works! Hth, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php files with .html extension?
On a related note I was wondering what people thought of php files with no extensions? So if I changed index.php to just index then I can create url like www.mydomain.com/index/articleid/29 so it's search engine friendly. # .htaccess file DefaultType application/x-httpd-php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Register Globals
Jay Blanchard wrote: [snip] I just signed up with a new hosting site. So first thing I did was check what phpinfo() had to say. I see that register_globals is turned on. Now I always use the $_GET and $_POST vars but will this still affect me? [/snip] Nope, you can keep using, and should keep using, the $_GET and $_POST arrays. You may be able to turn off register_globals for your site using an .htaccess file, also. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: http request using fsockopen
Hello, On 10/25/2004 09:46 AM, Rob wrote: I have a form on page A which is submitted trough a POST method to page B. On the start of page B I check var $foo. If true I want to forward the request to page C. Sending the POST data also though the POST method. I manually create a HTTP request to page C and use the fsockopen method to sent the request. As a result I get the requested page C (status code 200 OK is returned) but the POST data is not received/parsed(?). I mean the $_POST array is empty in page C. All other PHP scripts in page C is executed as expected though. My questions: 1 Is what I am doing possible in the first place? Sure. 2 If so, what is the correct syntax to sent the POST data ($query) in the entity body of the request? It is hard to tell but you may not be sending the request data correctly. You may want to try this HTTP client class that you can be sure that it can compose and send your POST requests properly. http://www.phpclasses.org/httpclient -- 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] Register Globals
And this won't pose as a security risk to me? It will. You could emulate namespaces in php. Do something like this: function init_namespace() { // all your script code goes here } init_namespace(); // notice the call This way any globally registered post/get/cookie etc variables wont be accessible by your code without extra global keywords. Or go another way to write your code register_globals independant. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What is better ROs or pdflib and why?
What is better ROs or pdflib and why? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] @session_start generates a new session_id
How can I set session_auto_start On, I have a similar problem and I think it's because my web hosting has that feature off. -Original Message- From: Sadeq Naqashzade [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 19, 2004 11:47 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] @session_start generates a new session_id Hi, Check your PHP config file. You may enable auto session start. I think this is the reasone of problem. Sadeq On Tue, 19 Oct 2004 18:21:29 +0200, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi Matt, @session_start(); session_name(userauth); $_SESSION['SESS_CUS'] = $user_id; I am not 100% sure what the problem is, but if you are trying to change the session name to userauth, I think you need to do that before session_start session_name() works ok so far. For example: ? @session_start; $session = session_id(); /* index.php */ $_SESSION['SESS_CUS'] == $user_id; echo $session; ? OUTPUT in the browser: 34f321149ee49d20e0e223f3020c1f77 In the case a new page is loaded it changes to a new value: ? $session = session_id(); /* userauth.php */ echo PHPSESSID: $session; echo SESSION:.$_SESSION['SESS_CUS']; ? OUTPUT in the browser: PHPSESSID: b65de73df8d327a4e15627ccfd14968d SESSION: A new request over http generates a new session and $_SESSION['XYZ'] is not available anymore. -- Best Regards, Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- - Yazd, 8917954894 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php files with .html extension?
You would probably brake a heck of a lot of things. CGI scripts, etc. On a related note I was wondering what people thought of php files with noextensions? So if I changed index.php to just index then I can create urllike www.mydomain.com/index/articleid/29 so it's search engine friendly. # .htaccess file DefaultType application/x-httpd-php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Content-Type header required for POST?
Chris Shiflett wrote: --- Olaf van der Spek [EMAIL PROTECTED] wrote: Since which version does PHP require the Content-Type header in POST requests? Content-Type is required for any request that has content. It's an HTTP requirement and has very little to do with PHP. Can you explain what you're talking about? I was talking about the request, not about the response. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly HTTP Developer's Handbook - Sams Coming December 2004http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file upload
Hi, I'm trying to submit a file from index.php to index2.php. I know how to do file upload in PHP. On index.php I have: FORM ACTION=index2.php METHOD=POST ENCTYPE=multipart/form-data INPUT TYPE=file NAME=myfile SIZE=30 INPUT TYPE=submit NAME=Upload File /FORM The next page would only need to use $HTTP_POST_FILES['myfile'] to access the submitted file. My question is: if I already know which file I want to submit, say file1.xml. How can I just ask index.php to submit file1.xml to index2.php? Without asking the users to pick the file to upload? Thanks a lot in advance! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php files with .html extension?
I don't use cgi scripts. - Original Message - From: The Snake from Hell! [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, October 25, 2004 4:25 PM Subject: Re: [PHP] Php files with .html extension? You would probably brake a heck of a lot of things. CGI scripts, etc. On a related note I was wondering what people thought of php files with noextensions? So if I changed index.php to just index then I can create urllike www.mydomain.com/index/articleid/29 so it's search engine friendly. # .htaccess file DefaultType application/x-httpd-php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file upload
You can't, at least you SHOULDN'T. Just think about what you're asking for, you want to download a file from a users computer, without them knowing about it. Major security/privacy issues there that browsers try to prevent. Chris Victor C. wrote: Hi, I'm trying to submit a file from index.php to index2.php. I know how to do file upload in PHP. On index.php I have: FORM ACTION=index2.php METHOD=POST ENCTYPE=multipart/form-data INPUT TYPE=file NAME=myfile SIZE=30 INPUT TYPE=submit NAME=Upload File /FORM The next page would only need to use $HTTP_POST_FILES['myfile'] to access the submitted file. My question is: if I already know which file I want to submit, say file1.xml. How can I just ask index.php to submit file1.xml to index2.php? Without asking the users to pick the file to upload? Thanks a lot in advance! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Content-Type header required for POST?
--- Olaf van der Spek [EMAIL PROTECTED] wrote: Content-Type is required for any request that has content. It's an HTTP requirement and has very little to do with PHP. Can you explain what you're talking about? I was talking about the request, not about the response. As was I. That's why I used the word request. :-) You'll have a very tough time getting an answer if you can't explain your question. That's the only helpful hint I can provide. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly HTTP Developer's Handbook - Sams Coming December 2004http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Register Globals
Simas Toleikis wrote: And this [register globals] won't pose as a security risk to me? It will. No, it won't. register_globals is not a security risk. Poorly written code that does not adequately initialize variables or account for variables from outside sources can present security risks. You can write secure code with register globals ON and OFF. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP 5 abstract method and class type hints of extending classes
The quesion is: how would one make an abstract method that can be compatible with all extending classes that define the method using different class type hints? The php block below is how I thought it should work, but will give this error at parse time: errorFatal error: Declaration of DisplayObjectOne::display() must be compatible with that of DisplayBase::display()/error because the hint in the concrete method is different from that in the abstract method. ?php // base display class abstract class DisplayBase { abstract public function display(ObjectBase $object); } // display ObjectOne class DisplayObjectOne extends DisplayBase { public function display(ObjectOne $object){ print_r($object); } } // display ObjectTwo class DisplayObjectTwo extends DisplayBase { public function display(ObjectTwo $object){ var_export($object); } } // ObjectBase class ObjectBase { } // ObjectOne class ObjectOne extends ObjectBase { public $prop = 'I am one'; } // ObjectTwo class ObjectTwo extends ObjectBase { public $prop = 'I am two'; } ? According to the doc ?php function foo(ClassName $object) { // ... } ? is equivalent to: ?php function foo($object) { if (!($object instanceof ClassName)) die(Argument 1 must be an instance of ClassName); } ? but if you were to run this ?php // ObjectBase class ObjectBase { } // ObjectTwo class ObjectTwo extends ObjectBase { public $prop = 'I am two'; } $ot = new ObjectTwo(); var_dump($ot instanceof ObjectBase); var_dump($ot instanceof ObjectTwo); ? you would see : bool(true) bool(true) so in theory, you should be able to rewrite the display classes as (I know abstract classes can't have a body, but image this made sense): ?php // base display class abstract class DisplayBase { abstract public function display($object){ if (!($object instanceof ObjectBase)) die(Argument 1 must be an instance of ObjectBase); } } // display ObjectOne class DisplayObjectOne extends DisplayBase { public function display($object){ if (!($object instanceof ObjectOne)) die(Argument 1 must be an instance of ObjectOne); print_r($object); } } // display ObjectTwo class DisplayObjectTwo extends DisplayBase { public function display($object){ if (!($object instanceof ObjectTwo)) die(Argument 1 must be an instance of ObjectTwo); var_export($object); } } ? does anyone agree this is a bug, if not, can you explain why this voilates the OO-model of PHP5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Pure PHP menu tree
Hi, I have been searching on the net for the past 2 hours without success, so need a recommendation now :-) Basically i am looking for a PHP menu tree, looking on google I have found many but most of them use Javascript with php, or are pure JS or DHTML, I want one that is pure php so it will work accross all browsers. Nothing overly complicated, something such as this would be perfect: [+]expand1 [-]expanded2 [something 1] [something 2] [something 3] [+]expand 3 Other requirements: -It should work in frames -you can expand more than one at a time eg: [+]expand1 [-]expanded2 [something 1] [something 2] [-]expand 3 [something x] [something y] [+]expand 4 I have seen something like this somewhere, problem is, I dont really remember where. The idea is not new and I have also been exploring the php classes site to check over there as i'm quite sure something like this HAS been done...(I dont want to sit and recreate the whole thing as I am already in the middle of another project) if anybody can point me in the right direction as to where i can get thismucho gracias :-) Cheers, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Register Globals
On Mon, 25 Oct 2004 11:50:39 -0700 (PDT), Matthew Sims [EMAIL PROTECTED] wrote: I see that register_globals is turned on. Now I always use the $_GET and $_POST vars but will this still affect me? .htaccess php_flag register_globals off -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is flock() necessary on a simple file append?
On 10/24/2004 5:11 PM, Kevin Grigorenko [EMAIL PROTECTED] wrote: I am appending to a file one line of text on every page hit, so there could be many occurrences of this append simultaneously. I am not opening for write (w) but for append (a). Do I need to use flock() to be sure there are no issues? I am running on Solaris. On 10/24/2004 5:39 PM, Hristo Yankov [EMAIL PROTECTED] wrote: append is the same as write (it requires write access for example), so if you are gonna use flock for w, use it for a too. According to this post, you do not need to use flock() if you open a file in append mode: http://marc.theaimsgroup.com/?l=php-generalm=105165806915109w=2 Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file upload
Thanks for answering Chris.. What if I want to send a file from my web server to another site for them to parse? I already know what file I want to send and I do not want to have to select the file by doing browsing. Chris [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] You can't, at least you SHOULDN'T. Just think about what you're asking for, you want to download a file from a users computer, without them knowing about it. Major security/privacy issues there that browsers try to prevent. Chris Victor C. wrote: Hi, I'm trying to submit a file from index.php to index2.php. I know how to do file upload in PHP. On index.php I have: FORM ACTION=index2.php METHOD=POST ENCTYPE=multipart/form-data INPUT TYPE=file NAME=myfile SIZE=30 INPUT TYPE=submit NAME=Upload File /FORM The next page would only need to use $HTTP_POST_FILES['myfile'] to access the submitted file. My question is: if I already know which file I want to submit, say file1.xml. How can I just ask index.php to submit file1.xml to index2.php? Without asking the users to pick the file to upload? Thanks a lot in advance! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] @session_start generates a new session_id
On Mon, 25 Oct 2004 15:59:18 -0400, Lizet Peña de Sola [EMAIL PROTECTED] wrote: How can I set session_auto_start On, I have a similar problem and I think it's because my web hosting has that feature off. .htaccess php_flag session.auto_start on -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php files with .html extension?
On Mon, 25 Oct 2004 18:44:41 +, Curt Zirzow [EMAIL PROTECTED] wrote: Nice work! I wonder what the stats would be like with apache2 :) Suse 9.1 box: cat /proc/cpuinfo processor : 0 vendor_id : AuthenticAMD cpu family : 6 model : 4 model name : AMD Athlon(tm) Processor stepping: 2 cpu MHz : 909.168 cache size : 256 KB fdiv_bug: no hlt_bug : no f00f_bug: no coma_bug: no fpu : yes fpu_exception : yes cpuid level : 1 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr syscall mmxext 3dnowext 3dnow bogomips: 1794.04 free -m total used free sharedbuffers cached Mem: 504497 6 0164 47 -/+ buffers/cache:285219 Swap: 1023 0 1023 httpd -v Server version: Apache/2.0.51 Server built: Sep 19 2004 15:44:02 php -v PHP 5.0.2 (cgi) (built: Sep 24 2004 20:55:59) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.2, Copyright (c) 1998-2004 Zend Technologies 1) Apache 2 not parsing .html as PHP: ab -n1 http://localhost/benchmark/ This is ApacheBench, Version 2.0.41-dev $Revision: 1.121.2.12 $ apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Finished 1 requests Server Software:Apache/2.0.51 Server Hostname:localhost Server Port:80 Document Path: /benchmark/ Document Length:105 bytes Concurrency Level: 1 Time taken for tests: 11.234968 seconds Complete requests: 1 Failed requests:0 Write errors: 0 Total transferred: 379 bytes HTML transferred: 105 bytes Requests per second:890.08 [#/sec] (mean) Time per request: 1.123 [ms] (mean) Time per request: 1.123 [ms] (mean, across all concurrent requests) Transfer rate: 329.42 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect:00 0.0 0 1 Processing: 00 1.4 1 108 Waiting:00 0.8 0 70 Total: 00 1.4 1 108 Percentage of the requests served within a certain time (ms) 50% 1 66% 1 75% 1 80% 1 90% 1 95% 1 98% 1 99% 1 100%108 (longest request) 2) Apache 2 parsing .html as PHP: ab -n1 http://localhost/benchmark/ This is ApacheBench, Version 2.0.41-dev $Revision: 1.121.2.12 $ apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Finished 1 requests Server Software:Apache/2.0.51 Server Hostname:localhost Server Port:80 Document Path: /benchmark/ Document Length:105 bytes Concurrency Level: 1 Time taken for tests: 30.532746 seconds Complete requests: 1 Failed requests:0 Write errors: 0 Total transferred: 311 bytes HTML transferred: 105 bytes Requests per second:327.52 [#/sec] (mean) Time per request: 3.053 [ms] (mean) Time per request: 3.053 [ms] (mean, across all concurrent requests) Transfer rate: 99.47 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect:00 0.0 0 0 Processing: 22 0.5 2 9 Waiting:02 0.4 2 9 Total: 22 0.5 2 9 Percentage of the requests served within a certain time (ms) 50% 2 66% 2 75% 2 80% 3 90% 3 95% 3 98% 3 99% 3 100% 9 (longest request) Summary for 10K local requests: 11.2 seconds for .html not parsed as PHP vs. 30.5 seconds as .html parsed as PHP. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Pure PHP menu tree
snip Basically i am looking for a PHP menu tree, looking on google I have found many but most of them use Javascript with php, or are pure JS or DHTML, I want one that is pure php so it will work accross all browsers. snip http://phplayersmenu.sourceforge.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file upload
Server to Server transfers are a bit different. There are MANY ways to do it. You can put the file in the document root of one server, and download it with the other server. Or you could FTP the file from one server to the other. Just 2 examples. And, you could even POST the file from one to the other. That solution seems a bit icky to me, but it all really depends on what you need. Pulling is generally easier than pushing. Chris Victor C. wrote: Thanks for answering Chris.. What if I want to send a file from my web server to another site for them to parse? I already know what file I want to send and I do not want to have to select the file by doing browsing. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Pure PHP menu tree
Do you really want to have every single click go back to the server and then have the browser need to reload your entire page just to expand a limb (not sure limb is the right term) of the tree? That is what you would have to do to be pure PHP solution since the only place PHP can execute is on the server. JavaScript is generally accepted as the solution that will produce the fastest user interface response, because it runs in the browser machine, and does not require the trip to the server and back just to expand a part of the tree. There are a couple of really good js solutions available, blueshoes has a good one. http://www.blueshoes.org/en/javascript/tree/ If you are willing to distribute PHP to each workstation along with your code, you could consider creating a PHP GUI (Windows type) application that does not execute through a browser. PHP-GTK provides a tree widget, but if you are not used to developing for a windows (non-web) type environment it could prove quite tough. http://gtk.php.net Hope this helps, Warren Vail -Original Message- From: Ryan A [mailto:[EMAIL PROTECTED] Sent: Monday, October 25, 2004 3:08 PM To: [EMAIL PROTECTED] Subject: [PHP] Pure PHP menu tree Hi, I have been searching on the net for the past 2 hours without success, so need a recommendation now :-) Basically i am looking for a PHP menu tree, looking on google I have found many but most of them use Javascript with php, or are pure JS or DHTML, I want one that is pure php so it will work accross all browsers. Nothing overly complicated, something such as this would be perfect: [+]expand1 [-]expanded2 [something 1] [something 2] [something 3] [+]expand 3 Other requirements: -It should work in frames -you can expand more than one at a time eg: [+]expand1 [-]expanded2 [something 1] [something 2] [-]expand 3 [something x] [something y] [+]expand 4 I have seen something like this somewhere, problem is, I dont really remember where. The idea is not new and I have also been exploring the php classes site to check over there as i'm quite sure something like this HAS been done...(I dont want to sit and recreate the whole thing as I am already in the middle of another project) if anybody can point me in the right direction as to where i can get thismucho gracias :-) Cheers, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file upload
See... basically, I have two sites. One site provides user authentication and another one requests the authentication. The requesting site need to send to the authentication site its request in an XML. The authentication site is suppose to get the XML file using $HTTP_POST_FILES. I'm using PHP to dynamically generate the request XML file and I need to submit it to the authenticating site; but I don't want to use file upload and browse functionality, because the authentication process is suppose to be transparent to the end users. Again, thanx for the help and any insights would be greatly appreciated. :) Chris [EMAIL PROTECTED] ??:[EMAIL PROTECTED] Server to Server transfers are a bit different. There are MANY ways to do it. You can put the file in the document root of one server, and download it with the other server. Or you could FTP the file from one server to the other. Just 2 examples. And, you could even POST the file from one to the other. That solution seems a bit icky to me, but it all really depends on what you need. Pulling is generally easier than pushing. Chris Victor C. wrote: Thanks for answering Chris.. What if I want to send a file from my web server to another site for them to parse? I already know what file I want to send and I do not want to have to select the file by doing browsing. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Good Class/API Design ?
Hey all, I just got my hands on the excellent books PHP Anthology 1 2 and am wanting to start playing around with classes. My question to the list is, what, in your opinion, constitutes good class/api design? Is it better to design several smaller classes that each focus on one task and do that task well, or to build more general classes that handle a number of related tasks? Also, when you are beginning a new project, what methods do you find helpful to follow in taking your project from concept to finished? The books also mention ways to use phpDocumentor to document your code and SimpleTest to test your code as it is written. These along with some XP techniques I read about seem like good practices to follow. Does anyone have any other ideas/practices that it would be good for a new oop developer like myself to make a habit it of? Thanks!! -- Adam Reiswig Accelerating into the unknown... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP 5 abstract method and class type hints of extending classes
Jeremy Weir wrote: The quesion is: how would one make an abstract method that can be compatible with all extending classes that define the method using different class type hints? The php block below is how I thought it should work, but will give this error at parse time: errorFatal error: Declaration of DisplayObjectOne::display() must be compatible with that of DisplayBase::display()/error because the hint in the concrete method is different from that in the abstract method. ?php // base display class abstract class DisplayBase { abstract public function display(ObjectBase $object); } // display ObjectOne class DisplayObjectOne extends DisplayBase { public function display(ObjectOne $object){ print_r($object); } } // display ObjectTwo class DisplayObjectTwo extends DisplayBase { public function display(ObjectTwo $object){ var_export($object); } } If you use type-hinting, this is a more strict contract. You're telling PHP that this method must receive an object that is of this class or any subclass in DisplayObjectTwo, you're saying this method CANNOT accept a DisplayBase or any child object unless it extends ObjectTwo In other words, imagine if what you want to do was allowed. Someone comes along who writes a method that uses an instanceof test like: $b = new ObjectOne; $a = new DisplayObjectTwo; if ($a instanceof DisplayBase) { $a-display($b); } to display another object, you get a serious problem, because the code will fail with all DisplayObject* that aren't DisplayObjectOne, but the instanceof test will succeed! In other words, your display() function is in fact not a generic function, but is specific to each class, so the use of a DisplayBase class makes absolutely no sense at all. Better is to implement a method inside ObjectBase called getDefaultDisplayObject() which will instantiate the display object that is needed. Custom classes can then override this method to return the custom display object. Even though it is better, this still isn't great design. What you probably want is this: abstract class DisplayBase { public static function factory(ObjectBase $o) { $class = 'Display' . get_class($o); if (!class_exists($class)) { throw new Exception('No display object for ' . get_class($o) . ''); } $disp = new $class($o); } abstract public function __construct($o); abstract public function display($options); // might want this } class DisplayObjectOne extends DisplayBase { private $object; public function __construct($o) { if (!$o instanceof ObjectOne) { throw new Exception('parameter must be an ObjectOne'); } $this-object = $o; } public function display($options) { print_r($this-object); } } class DisplayObjectTwo extends DisplayBase { private $object; public function __construct($o) { if (!$o instanceof ObjectTwo) { throw new Exception('parameter must be an ObjectTwo'); } $this-object = $o; } public function display($options) { print_r($this-object); } } Now, your hypothetical user can do try { if ($d instanceof DisplayBase) { $d-display($options); } } catch (Exception $e) { // handle problems } and rest assured that the code will work under all circumstances. Hope this helps :) Regards, Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Pure PHP menu tree
Ryan A wrote: Hi, I have been searching on the net for the past 2 hours without success, so need a recommendation now :-) Basically i am looking for a PHP menu tree, looking on google I have found many but most of them use Javascript with php, or are pure JS or DHTML, I want one that is pure php so it will work accross all browsers. http://pear.php.net/package/HTML_Menu Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Good Class/API Design ?
Adam Reiswig wrote: Hey all, I just got my hands on the excellent books PHP Anthology 1 2 and am wanting to start playing around with classes. My question to the list is, what, in your opinion, constitutes good class/api design? Is it better to design several smaller classes that each focus on one task and do that task well, or to build more general classes that handle a number of related tasks? Also, when you are beginning a new project, what methods do you find helpful to follow in taking your project from concept to finished? Do as much of the design away from the keyboard as you can. Use prose, questions like what do the users of this program need? are a good starting point, or what is the problem that needs solving? Draw pictures and flowcharts for complex things you want to do (you don't have to use UML, but its methodology is helpful). There are several excellent and free UML modelling programs out there. The books also mention ways to use phpDocumentor to document your code and SimpleTest to test your code as it is written. These along with some XP techniques I read about seem like good practices to follow. Does anyone have any other ideas/practices that it would be good for a new oop developer like myself to make a habit it of? The main advice I can offer as one of the primary authors of phpDocumentor, the next incarnation of the PEAR installer (not out yet), and a few other small packages is to start small, and use code that others have written wherever possible. When code I've written gets old, the first thing I notice is that the best code has been split up so that methods are no longer than a page, and classes don't try to group more than one thing. A great rule of thumb for all functions is to ask yourself What is the one thing I want this to do? If your function starts doing more than one thing, split it up. It will also get to be much longer than a page, so that's a good warning sign. I've also gone the other route, which is to say I tried to over-OO things with my defunct first attempt at the PEAR package Games_Chess. Initially, each piece was an object, and so was each square on the chessboard. Calculation is virtually impossible in this situation. Then, I realized that pieces don't need to do any actions, and only possess two properties, their color and their name. Changing the design to use properties of a chess object to represent the board as an array and each piece as an index in this array suddenly made it possible to do very fast calculations using the array functions built into PHP, and suddenly it took only a week to come up with a working first draft. The other thing I've learned the hard way is for God's sake, don't write code like this: class Common { function utilitythingo() { } } and extend every other class from Common. This instantly cuts down on future expandability options. It means when you realize that you've designed the application to solve the X problem, and the more important problem was Y, modifications will take you forever. Or, when you find code that someone else has written, you won't be able to easily integrate it into your own code. The single most important design decision is not just how you split up the tasks, but how you design the communication between them. You can have methods instantiate objects directly, pass in objects, use a proxy/router object to communicate between classes using messages or simply call methods directly - the choices are endless. For instance, logging is a common idea for most web applications. If you design all classes that do logging so that they simply accept an instantiated logging object, this will allow you to plug and play ANY object that has the same API as your preferred logging object. The same is true of database access, or other critical design choices. Patterns can often be useful in deciding how to do things, such as the faddish MVC (model-view-controller) or singleton, factory, observer patterns. Go to http://www.phppatterns.com to see Harry Fuecks's excellent site devoted to these subjects. However, most important is to simply try it out, make mistakes and have fun trying to fix them (or get an ulcer, but that's how we look at things, isn't it :) Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php extension problem
fixed. i downloaded the source from php.net and it works now... the previous source i had came from apt system. maybe the source is patched ? if i'm not the only one to have had this problem, let me know, i'll mail the debian maintener thanks, On Monday 25 October 2004 19:19, Pierre Ancelot wrote: Hi ! I am having some trouble creating a php extension. as show in the documentation i did a ./ext_skel --extname=mymodule which created the directory mymodule i edited the config.m4 file to tune it to something very basic : PHP_ARG_WITH(mymodule, for mymodule support, [ --with-mymodule Include mymodule support]) if test $PHP_MYMODULE != no; then PHP_NEW_EXTENSION(mymodule, mymodule.c, $ext_shared) fi saved and went to the base of the source tree... [EMAIL PROTECTED]:/usr/src/php4-4.3.9$ ./buildconf You should not run buildconf in a release package. use buildconf --force to override this check. [EMAIL PROTECTED]:/usr/src/php4-4.3.9$ ./buildconf --force Forcing buildconf using default Zend directory buildconf: checking installation... buildconf: autoconf version 2.59 (ok) buildconf: Your version of autoconf likely contains buggy cache code. Running cvsclean for you. To avoid this, install autoconf-2.13 and automake-1.5. buildconf: libtool version 1.5.6 (ok) rebuilding configure autoconf/programs.m4:438: AC_DECL_YYTEXT is expanded from... configure.in:147: the top level [EMAIL PROTECTED]:/usr/src/php4-4.3.9$ then, i been looking up if the module was taken [EMAIL PROTECTED]:/usr/src/php4-4.3.9$ ./configure --help | grep -i mymodule [EMAIL PROTECTED]:/usr/src/php4-4.3.9$ and no, it's not any idea ? something i did wrong ? thank you :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Good Class/API Design ?
* Thus wrote Greg Beaver: Adam Reiswig wrote: Hey all, I just got my hands on the excellent books PHP Anthology 1 2 and am wanting to start playing around with classes. My question to the list is, what, in your opinion, constitutes good class/api design? Is it better to design several smaller classes that each focus on one task and do that task well, or to build more general classes that handle a number of related tasks? Also, when you are beginning a new project, what methods do you find helpful to follow in taking your project from concept to finished? Do as much of the design away from the keyboard as you can. Use prose, questions like what do the users of this program need? are a good starting point, or what is the problem that needs solving? Draw pictures and flowcharts for complex things you want to do (you don't have to use UML, but its methodology is helpful). There are several excellent and free UML modelling programs out there. Also, make sure the objects are not doing tasks they shouldn't be doing. A car object shouldn't have any methods that perform flying tasks, unless of course it implements the FlyingCar interface :) Curt -- Quoth the Raven, Nevermore. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File uploads and handling
Hi all. I have a form to upload a file from a user's computer to the server. I want to then modify the file, and then let the user save it back. However, I am having troubles opening the file. It says it doesn't exist. Any suggestions? --- if (is_uploaded_file($_FILES['userfile']['name'])) $handle = fopen($_FILES['userfile']['name'], r); else echo $filename . was not uploaded properly; --- I know the actual filename shows up... but somehow it's not uploading. Ideas? ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file upload
Ahh, if you *have* to push the data (which you obviously do) and the authentication site has no other authentication methods then you have to POST the file with PHP. It can be done, there are many classes for it, I can't recommend any specific class, but I'm sure someone else here could. I would surprise me if something in PEAR ( http://pear.php.net/ ) couldn't do it. Just look for an HTTP class that can POST files. Chris Victor C. wrote: See... basically, I have two sites. One site provides user authentication and another one requests the authentication. The requesting site need to send to the authentication site its request in an XML. The authentication site is suppose to get the XML file using $HTTP_POST_FILES. I'm using PHP to dynamically generate the request XML file and I need to submit it to the authenticating site; but I don't want to use file upload and browse functionality, because the authentication process is suppose to be transparent to the end users. Again, thanx for the help and any insights would be greatly appreciated. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] not _that_ fixed....
On Tue, 2004-10-26 at 00:37, Pierre Ancelot wrote: in fact i got it in the ./configure --help : [EMAIL PROTECTED]:~/phpsource/php-4.3.9$ ./configure --help | grep -i spider --enable-spider Enable spider support [EMAIL PROTECTED]:~/phpsource/php-4.3.9$ which is okay. but if i run make, i got a few lines about it like : gcc -Iext/spider/ -I/home/pierre/phpsource/php-4.3.9/ext/spider/ -DPHP_ATOM_INC -I/home/pierre/phpsource/php-4.3.9/include -I/home/pierre/phpsource/php-4.3.9/main -I/home/pierre/phpsource/php-4.3.9 -I/home/pierre/phpsource/php-4.3.9/Zend -I/home/pierre/phpsource/php-4.3.9/ext/xml/expat -I/home/pierre/phpsource/php-4.3.9/TSRM -g -O2 -c /home/pierre/phpsource/php-4.3.9/ext/spider/spider.c -o ext/spider/spider.o echo ext/spider/spider.lo and it goes without any error about my module. so, as the tutorial specifies it, i run the script created with my extension : [EMAIL PROTECTED]:~/phpsource/php-4.3.9$ php -f ext/spider/spider.php Warning: dl(): Unable to load dynamic library '/usr/lib/php4/20020429/spider.so' - /usr/lib/php4/20020429/spider.so: cannot open shared object file: No such file or directory in /home/pierre/phpsource/php-4.3.9/ext/spider/spider.php on line 3 Functions available in the test extension:br Warning: Invalid argument supplied for foreach() in /home/pierre/phpsource/php-4.3.9/ext/spider/spider.php on line 8 br Module spider is not compiled into PHP [EMAIL PROTECTED]:~/phpsource/php-4.3.9$ after checking, i see this: [EMAIL PROTECTED]:~/phpsource/php-4.3.9$ ls ext/spider/ CREDITS EXPERIMENTAL config.m4 php_spider.h spider.c spider.lo spider.o spider.php tests [EMAIL PROTECTED]:~/phpsource/php-4.3.9$ The module is NOT created :'( Did i forget something in config.m4 ??? something i didn't get in the tutorial ??? http://www.php.net/manual/fr/zend.build.php no idea... The 'make' command does not compile shared object extensions. You need to do something different for that. However if PHP compiled properly with the extension enabled then you shouldn't need to load your extension via dl() since it should already be a part of the PHP binary. That said, if you still wish to compile a shared object module of your extension then you can run this from the PHP source directory (with suitable changes for your extension): cc -fpic -DCOMPILE_DL_INTERJINN=1 \ -Iext/interjinn/ -Iinclude -Imain -I. -IZend -ITSRM \ -c -o ext/interjinn/interjinn.o ext/interjinn/interjinn.c cc -shared -L/usr/local/lib -rdynamic -o \ ext/interjinn/interjinn.so \ ext/interjinn/interjinn.o I don't recall if it's necessary, but I compile PHP as a CGI binary first and then run the above commands. If you want to allow support for your extension as both a dl()'d module or as a built-in extension, then you can check for the existence of one of your modules functions with function_exists() and if it doesn't exist then use dl() to try and load the shared module. HTH, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Specifying Variable Document Path in PHP
Hey Folks, My first post to this list and forgive me if this is ground that's been trod before, but this has been bugging me for a bit. I'm developing a site that's going to be running on a staging environment and a production environment. Have a number of PHP includes in the production site that specifically call the file pathname (thus): ?php include '/home/production_site/public_html/pagename.php' ? The problem here is that the path will vary slightly depending on whether it's the staging server or production server. I'd ideally like to set a single global variable that can handle this so I don't have to hard-code paths across the site (as I'm doing now). Is there any easy way to accomplish this? Thanks in advance, Anthony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php