[PHP] Re: Graphics generation.
Carles Xavier Munyoz Baldó schrieb: Hi, Is there any free PHP class with which I can create lines and bars graphics ? For example, for represent temperature samples over time, population of a country over time, etc. Greegints. --- Carles Xavier Munyoz Baldó [EMAIL PROTECTED] http://www.unlimitedmail.net/ --- A very good one is: JPgraph http://www.aditus.nu/jpgraph/ Greets Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Getting an advanced foreach to work
I got the code as follows bellow. I'm having some problems to get it to work. Maybe some of you are able to help me a bit. First of all I got an array (salespersons) containing names of dynamic array names. For example it can contain Johan, Mark, Jenny, Bill etc. By calling for the possision in the array based on $count I'll get the name, and that's the name of another array. The problem is in the foreach with ( { } ). $count = 0; // Loopa så länge räknaren är mindre än storleken av arrayn $salespersons while ($count count($salespersons)) { foreach (${$($salespersons[$count])} AS $key = $value) { echo htmlentities($key).' - '.$value; $count++; } } Anyone? Thaks // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
SV: [PHP] Getting an advanced foreach to work SOLVED
-Ursprungligt meddelande- Från: Jonas Rosling [mailto:[EMAIL PROTECTED] Skickat: den 23 maj 2006 10:06 Till: PHP List Ämne: [PHP] Getting an advanced foreach to work Should look like this: foreach (${$salespersons[$count]} AS $key = $value) { -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting an advanced foreach to work
this shoul work: while ($count count($salespersons)) { foreach ($salespersons[$count] AS $key = $value) { echo htmlentities($key).' - '.$value; $count++; } } On 5/23/06, Jonas Rosling [EMAIL PROTECTED] wrote: I got the code as follows bellow. I'm having some problems to get it to work. Maybe some of you are able to help me a bit. First of all I got an array (salespersons) containing names of dynamic array names. For example it can contain Johan, Mark, Jenny, Bill etc. By calling for the possision in the array based on $count I'll get the name, and that's the name of another array. The problem is in the foreach with ( { } ). $count = 0; // Loopa så länge räknaren är mindre än storleken av arrayn $salespersons while ($count count($salespersons)) { foreach (${$($salespersons[$count])} AS $key = $value) { echo htmlentities($key).' - '.$value; $count++; } } Anyone? Thaks // Jonas -- 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] Getting an advanced foreach to work
Jonas Rosling wrote: ... while ($count count($salespersons)) { I see you have solved it - just one comment. This particular line will get evaluated every time. If you have a large number of elements in $salespersons, it will slow things down considerably. From a performance point of view you're much better off doing: $sales_count = count($salespersons); while($count $sales_count) { The only reason to leave the count in the while statement is if you are adding/removing to that array within the loop, otherwise chuck it in a temp variable and use that instead. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Security Concerns with Uploaded Images:
Use the unix command file to determiner what file you have. I have had the same problem... Don't depend on it. graphic.php GIF89 ?php do_bad_stuff(); ? ANY_GIF_FOOTERS_HERE should according to file be a gif, but contains embedded php. Many thanks! Greetings Michelle Konzack -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSM LinuxMichi 0033/6/6192519367100 Strasbourg/France IRC #Debian (irc.icq.com) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
SV: [PHP] Getting an advanced foreach to work
-Ursprungligt meddelande- Från: Chris [mailto:[EMAIL PROTECTED] Skickat: den 23 maj 2006 10:24 Till: Jonas Rosling Kopia: PHP List Ämne: Re: [PHP] Getting an advanced foreach to work From a performance point of view you're much better off doing: $sales_count = count($salespersons); while($count $sales_count) { The only reason to leave the count in the while statement is if you are adding/removing to that array within the loop, otherwise chuck it in a temp variable and use that instead. Thansk alot for the tip. // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date iteration
Hi all, I am writing an app that runs a prize draw, wherein the admin chooses the duration by adding a start date and number of days for the draw to run. These values are passed into a small function that generates an array holding the start date, end date and all dates in between as follows: function generateDates($first, $duration) { $dates = array(); $date = getdate(mktime($first)); $month = $date['mon'];$day = $date['mday'];$year = $date['year']; for ($i = 1;$i = $duration; $i++) { $added = getdate(mktime($day++ . - . $month . - . $year)); $dates[] = $added['mday'] . - . $added['mon'] . - . $added['year']; } return $dates; } $series = generateDates('23-05-2006', 20); var_dump($series); ...when I var_dump the array the iteration stops at May 24 - I am looking into it but does anyone have any ideas why this is sticking ie is my date arithmetic wrong? Cheers. -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon!
[PHP] One works, but the other doesn't
I find this problem very strange. I've got two parts of code (allmost the same) in different TD's with vars and arrays (with same name) but it's only the top code that gives result. I've allso tryied to rename the vars and TD's in the bottom without any luck. The only vars/arrays that I haven't mind changing name on yet are some dynamic, like: ${$row[0]} = array(); ${$row[0]}[$row[1]] = $row[2]; But I think this could be the main cause, but I'm not really sure. If I delete the top code the bottom works. Any idéas any one? Thanks // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date iteration
On 5/23/06, Dave Goodchild [EMAIL PROTECTED] wrote: Hi all, I am writing an app that runs a prize draw, wherein the admin chooses the duration by adding a start date and number of days for the draw to run. These values are passed into a small function that generates an array holding the start date, end date and all dates in between as follows: function generateDates($first, $duration) { $dates = array(); $date = getdate(mktime($first)); $month = $date['mon'];$day = $date['mday'];$year = $date['year']; for ($i = 1;$i = $duration; $i++) { $added = getdate(mktime($day++ . - . $month . - . $year)); $dates[] = $added['mday'] . - . $added['mon'] . - . $added['year']; } return $dates; } $series = generateDates('23-05-2006', 20); var_dump($series); ...when I var_dump the array the iteration stops at May 24 - I am looking into it but does anyone have any ideas why this is sticking ie is my date arithmetic wrong? Cheers. Your mktime() usage is off. I think you're confusing it with strtotime(). Please see the function arguments in the docs: php.net/mktime php.net/strtotime Also, inside the loop, instead of using getdate and then concatenating to form the date string, consider using the date() function to do it. php.net/date Rabin -- http://rab.in -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] One works, but the other doesn't
On 5/23/06, Jonas Rosling [EMAIL PROTECTED] wrote: I find this problem very strange. I've got two parts of code (allmost the same) in different TD's with vars and arrays (with same name) but it's only the top code that gives result. I've allso tryied to rename the vars and TD's in the bottom without any luck. The only vars/arrays that I haven't mind changing name on yet are some dynamic, like: ${$row[0]} = array(); ${$row[0]}[$row[1]] = $row[2]; But I think this could be the main cause, but I'm not really sure. If I delete the top code the bottom works. Any idéas any one? Without seeing the whole code involved, my guess is you're resetting the array with every loop. Guesses don't help but that's all we can do without seeing any actual code. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
SV: [PHP] One works, but the other doesn't
-Ursprungligt meddelande- Från: chris smith [mailto:[EMAIL PROTECTED] Skickat: den 23 maj 2006 13:38 Till: Jonas Rosling Kopia: PHP List Ämne: Re: [PHP] One works, but the other doesn't On 5/23/06, Jonas Rosling [EMAIL PROTECTED] wrote: I find this problem very strange. I've got two parts of code (allmost the same) in different TD's with vars and arrays (with same name) but it's only the top code that gives result. I've allso tryied to rename the vars and TD's in the bottom without any luck. The only vars/arrays that I haven't mind changing name on yet are some dynamic, like: ${$row[0]} = array(); ${$row[0]}[$row[1]] = $row[2]; But I think this could be the main cause, but I'm not really sure. If I delete the top code the bottom works. Any idéas any one? Without seeing the whole code involved, my guess is you're resetting the array with every loop. Guesses don't help but that's all we can do without seeing any actual code. Okej, all the code follows bellow. Remember that part 1 allways works. And they work all seperatly. ?php // Skapar variabel med host, användarnamn och lösenord $link = @mysql_connect(127.0.0.1, intranet, intranet0605) or die (Kunde inte ansluta); // Skapar variabel med aktuell databas $database=mysql_select_db(eitss_se_intranet); // PART 1 // SELECT-sats som tar fram alla rader för nyförsäljning grupperat per produkt och säljare $sql = SELECT c.salesperson_code, sl.description, SUM(sl.unit_price) AS totalt, COUNT(sl.description) AS antal FROM Sales_line AS sl JOIN Customer AS c WHERE sl.sell_to_customer_no = c.no AND (LEFT( sl.shipment_date, 2) = '$year' AND MID(sl.shipment_date, 4, 2) = '$month') AND RIGHT(sl.shipment_date, 2) = '$day' AND sl.quantity_invoiced =1 GROUP BY sl.description, c.salesperson_code ORDER BY c.salesperson_code, sl.description; // Utför SQL-satsen $result=mysql_query($sql); // Skapar en tom array för aktuella säljare $salespersons = array(); // Loppar igenom raderna while($row=mysql_fetch_array($result)) { // Kollar om arrayn för säljaren är deklarerad if (!${$row[0]}) { // Skapar array för säljaren ${$row[0]} = array(); // Lägger in värdena i arrayn - produkt och summering antal produkter ${$row[0]}[$row[1]] = $row[2]; // Lägger in säljaren i arrayn för aktuella sälljare array_push($salespersons, $row[0]); } // Om arrayn reda är deklarerad else { // Lägger in värdena i arrayn - produkt och summering antal produkter ${$row[0]}[$row[1]] = $row[2]; } } // Räknare $count = 0; // Storlek på arrayn innhållande säljare $sales_count = count($salespersons); echo 'b'.htmlentities('Nyförsäljning per produkt: ').'/bbr'; // Loopa så länge räknaren är mindre än storleken av arrayn $salespersons while ($count $sales_count) { echo 'brb'.htmlentities($salespersons[$count]).'/bbr'; foreach (${$salespersons[$count]} AS $key = $value) { if ($key == '') { echo 'Okauml;nd - '.$value.'br'; } else { echo htmlentities($key).' - '.$value.'br'; } } // Öka värdet på räknaren med 1 $count++; } // PART 2 // SELECT-sats som tar fram alla rader för nyförsäljning grupperat per produkt och säljare $sql = SELECT c.salesperson_code, sl.description, SUM(sl.unit_price) AS totalt, COUNT(sl.description) AS antal FROM Sales_line AS sl JOIN Customer AS c WHERE sl.sell_to_customer_no = c.no AND (sl.status LIKE '4%' OR sl.status LIKE '5%' OR sl.status LIKE '6%') AND ( LEFT( sl.shipment_date, 2 ) = '$year' AND MID( sl.shipment_date, 4, 2 ) = '$month' ) AND RIGHT( sl.shipment_date, 2 ) = '$day' AND sl.quantity_invoiced = 1 GROUP BY sl.description, c.salesperson_code ORDER BY c.salesperson_code, sl.description; // Utför SQL-satsen $result=mysql_query($sql); // Skapar en tom array för aktuella säljare $salespersons_g = array(); // Loppar igenom raderna while($row=mysql_fetch_array($result)) { // Kollar om arrayn för säljaren är deklarerad if (!${$row[0]}) { // Skapar array för säljaren
[PHP] Can a script run twice?
I'm having very occasional problems with my PHP5 applications which only seem to be explained if the script is run twice. Example - page has 'Add Ticket' button, which adds a record and marks it as being processed by the location that created it. 99.99% of the time no problems, but just now and again there are two records, with different primary keys - so the database bit worked - but with very close now times and identified as being at the same counter. The next page does not have the 'Add Ticket' button, so it would seem the first script was trigger twice? Am I simply going mad ( which is the logical choice ;) ), or is this something that can happen and needs to be handled? -- Lester Caine - G8HFL - L.S.Caine Electronic Services - http://home.lsces.co.uk Model Engineers Digital Workshop - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/ Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
On 5/23/06, Lester Caine [EMAIL PROTECTED] wrote: I'm having very occasional problems with my PHP5 applications which only seem to be explained if the script is run twice. Example - page has 'Add Ticket' button, which adds a record and marks it as being processed by the location that created it. 99.99% of the time no problems, but just now and again there are two records, with different primary keys - so the database bit worked - but with very close now times and identified as being at the same counter. The next page does not have the 'Add Ticket' button, so it would seem the first script was trigger twice? Am I simply going mad ( which is the logical choice ;) ), or is this something that can happen and needs to be handled? Someone hitting refresh prematurely? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
Lester Caine wrote: I'm having very occasional problems with my PHP5 applications which only seem to be explained if the script is run twice. Example - page has 'Add Ticket' button, which adds a record and marks it as being processed by the location that created it. 99.99% of the time no problems, but just now and again there are two records, with different primary keys - so the database bit worked - but with very close now times and identified as being at the same counter. The next page does not have the 'Add Ticket' button, so it would seem the first script was trigger twice? Am I simply going mad ( which is the logical choice ;) ), or is this something that can happen and needs to be handled? This can happen if a page contains a reference to an empty URL. For example, img src= / would cause the page to be loaded twice in some browsers. That'd be the first thing I'd check. Is the 'Add Ticket' button a GET or POST request? If it's a POST then chances are the script itself has a logic error since the user would get asked if they wanted to repost the data. If it's a get then you've violated one of the cardinal rules of web-based application development - GETs get, POSTs do. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] One works, but the other doesn't
On 5/23/06, Jonas Rosling [EMAIL PROTECTED] wrote: -Ursprungligt meddelande- Från: chris smith [mailto:[EMAIL PROTECTED] Skickat: den 23 maj 2006 13:38 Till: Jonas Rosling Kopia: PHP List Ämne: Re: [PHP] One works, but the other doesn't On 5/23/06, Jonas Rosling [EMAIL PROTECTED] wrote: I find this problem very strange. I've got two parts of code (allmost the same) in different TD's with vars and arrays (with same name) but it's only the top code that gives result. I've allso tryied to rename the vars and TD's in the bottom without any luck. The only vars/arrays that I haven't mind changing name on yet are some dynamic, like: ${$row[0]} = array(); ${$row[0]}[$row[1]] = $row[2]; But I think this could be the main cause, but I'm not really sure. If I delete the top code the bottom works. Any idéas any one? Without seeing the whole code involved, my guess is you're resetting the array with every loop. Guesses don't help but that's all we can do without seeing any actual code. Okej, all the code follows bellow. Remember that part 1 allways works. And they work all seperatly. Man you do things the hard way. Why use all those variable variables? $my_data = array(); // Loppar igenom raderna while($row=mysql_fetch_assoc($result)) { $code = $row['salesperson_code']; if (!isset($my_data[$code])) { $my_data[$code] = array( 'description' = $row['description'], 'total' = $row['totalt'], 'antal' = $row['antal'] ); } else { $my_data[$code]['description'] = $row['description']; } } var_dump($my_data); MUCH easier to read and you'll find debugging LOTS easier. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
SV: [PHP] One works, but the other doesn't
-Ursprungligt meddelande- Från: chris smith [mailto:[EMAIL PROTECTED] Skickat: den 23 maj 2006 14:13 Till: Jonas Rosling Kopia: PHP List Ämne: Re: [PHP] One works, but the other doesn't On 5/23/06, Jonas Rosling [EMAIL PROTECTED] wrote: -Ursprungligt meddelande- Från: chris smith [mailto:[EMAIL PROTECTED] Skickat: den 23 maj 2006 13:38 Till: Jonas Rosling Kopia: PHP List Ämne: Re: [PHP] One works, but the other doesn't On 5/23/06, Jonas Rosling [EMAIL PROTECTED] wrote: I find this problem very strange. I've got two parts of code (allmost the same) in different TD's with vars and arrays (with same name) but it's only the top code that gives result. I've allso tryied to rename the vars and TD's in the bottom without any luck. The only vars/arrays that I haven't mind changing name on yet are some dynamic, like: ${$row[0]} = array(); ${$row[0]}[$row[1]] = $row[2]; But I think this could be the main cause, but I'm not really sure. If I delete the top code the bottom works. Any idéas any one? Without seeing the whole code involved, my guess is you're resetting the array with every loop. Guesses don't help but that's all we can do without seeing any actual code. Okej, all the code follows bellow. Remember that part 1 allways works. And they work all seperatly. Man you do things the hard way. Why use all those variable variables? $my_data = array(); // Loppar igenom raderna while($row=mysql_fetch_assoc($result)) { $code = $row['salesperson_code']; if (!isset($my_data[$code])) { $my_data[$code] = array( 'description' = $row['description'], 'total' = $row['totalt'], 'antal' = $row['antal'] ); } else { $my_data[$code]['description'] = $row['description']; } } - Well, I'm kind of a newbie at this. So you think this will solve my problem? // Jonas -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Can a script run twice?
OK I found this out last week... if its not a coding error... its this.. There is a bug with IE7, I have some billing scripts for a large Sydney ISP and I was working on a script on my laptop which I recently updated to IE7... after tipping my hair out for a few hours cause I was certain it was not a coding error I decided the run the script from my PC which was still IE6 and would u believe it, the script only run once I did some searching on (good old faithful) google and did discover a few bugs with IE7... whats this have to do with PHP u ask... one was a session bug.. and with my double script running bug which I could not find any information on... I decided to lock the site to IE7 with javascript and told the ISP to roll back or stay locked out A lot of money @ stake... damn u Micro$oft... CK -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Tuesday, 23 May 2006 10:06 PM To: Lester Caine Cc: PHP List Subject: Re: [PHP] Can a script run twice? Lester Caine wrote: I'm having very occasional problems with my PHP5 applications which only seem to be explained if the script is run twice. Example - page has 'Add Ticket' button, which adds a record and marks it as being processed by the location that created it. 99.99% of the time no problems, but just now and again there are two records, with different primary keys - so the database bit worked - but with very close now times and identified as being at the same counter. The next page does not have the 'Add Ticket' button, so it would seem the first script was trigger twice? Am I simply going mad ( which is the logical choice ;) ), or is this something that can happen and needs to be handled? This can happen if a page contains a reference to an empty URL. For example, img src= / would cause the page to be loaded twice in some browsers. That'd be the first thing I'd check. Is the 'Add Ticket' button a GET or POST request? If it's a POST then chances are the script itself has a logic error since the user would get asked if they wanted to repost the data. If it's a get then you've violated one of the cardinal rules of web-based application development - GETs get, POSTs do. -Stut -- 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] One works, but the other doesn't
On 5/23/06, Jonas Rosling [EMAIL PROTECTED] wrote: -Ursprungligt meddelande- Från: chris smith [mailto:[EMAIL PROTECTED] Skickat: den 23 maj 2006 14:13 Till: Jonas Rosling Kopia: PHP List Ämne: Re: [PHP] One works, but the other doesn't On 5/23/06, Jonas Rosling [EMAIL PROTECTED] wrote: -Ursprungligt meddelande- Från: chris smith [mailto:[EMAIL PROTECTED] Skickat: den 23 maj 2006 13:38 Till: Jonas Rosling Kopia: PHP List Ämne: Re: [PHP] One works, but the other doesn't On 5/23/06, Jonas Rosling [EMAIL PROTECTED] wrote: I find this problem very strange. I've got two parts of code (allmost the same) in different TD's with vars and arrays (with same name) but it's only the top code that gives result. I've allso tryied to rename the vars and TD's in the bottom without any luck. The only vars/arrays that I haven't mind changing name on yet are some dynamic, like: ${$row[0]} = array(); ${$row[0]}[$row[1]] = $row[2]; But I think this could be the main cause, but I'm not really sure. If I delete the top code the bottom works. Any idéas any one? Without seeing the whole code involved, my guess is you're resetting the array with every loop. Guesses don't help but that's all we can do without seeing any actual code. Okej, all the code follows bellow. Remember that part 1 allways works. And they work all seperatly. Man you do things the hard way. Why use all those variable variables? $my_data = array(); // Loppar igenom raderna while($row=mysql_fetch_assoc($result)) { $code = $row['salesperson_code']; if (!isset($my_data[$code])) { $my_data[$code] = array( 'description' = $row['description'], 'total' = $row['totalt'], 'antal' = $row['antal'] ); } else { $my_data[$code]['description'] = $row['description']; } } - Well, I'm kind of a newbie at this. So you think this will solve my problem? Look at it this way - Which one is easier to read? Which one do you think will be easier to work out what's going wrong? Readability of your code will help you so much. If you come back to this in a week, will you understand what's going on? I don't know if my code will give you *exactly* what you want - test it and see (backup your existing php file, change this code, see what you get). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: SV: [PHP] One works, but the other doesn't
- Well, I'm kind of a newbie at this. So you think this will solve my problem? Why don't you test it? -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Can a script run twice?
Futher to this... I found thatit does not do it with all my scripts... well as far as I am aware... how much is IE7 stuffing up I have NFI CK -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Tuesday, 23 May 2006 10:06 PM To: Lester Caine Cc: PHP List Subject: Re: [PHP] Can a script run twice? Lester Caine wrote: I'm having very occasional problems with my PHP5 applications which only seem to be explained if the script is run twice. Example - page has 'Add Ticket' button, which adds a record and marks it as being processed by the location that created it. 99.99% of the time no problems, but just now and again there are two records, with different primary keys - so the database bit worked - but with very close now times and identified as being at the same counter. The next page does not have the 'Add Ticket' button, so it would seem the first script was trigger twice? Am I simply going mad ( which is the logical choice ;) ), or is this something that can happen and needs to be handled? This can happen if a page contains a reference to an empty URL. For example, img src= / would cause the page to be loaded twice in some browsers. That'd be the first thing I'd check. Is the 'Add Ticket' button a GET or POST request? If it's a POST then chances are the script itself has a logic error since the user would get asked if they wanted to repost the data. If it's a get then you've violated one of the cardinal rules of web-based application development - GETs get, POSTs do. -Stut -- 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] Getting an advanced foreach to work
Chris wrote: Jonas Rosling wrote: ... while ($count count($salespersons)) { I see you have solved it - just one comment. This particular line will get evaluated every time. If you have a large number of elements in $salespersons, it will slow things down considerably. Quick amendment to this statement: PHP stores the number of elements in a userspace array directly in the internal zval, so calling count() simply reads that value no matter how big the array is (in algorithmic terms, it is O(1)). In other words, count(array(1)) is every bit as efficient as count(array_pad(array(1), 100, 1)) if you eliminate the cost of creating the 100 element array. Having said this, there is potentially significant overhead involved in calling a function as opposed to a variable lookup, and so you might end up saving a few microseconds. However, because count() is O(1), it will be a constant amount per loop. If you need to eke out that much extra performance, you may be better off using a profiler to see where the real bottlenecks in the code are. Greg From a performance point of view you're much better off doing: $sales_count = count($salespersons); while($count $sales_count) { The only reason to leave the count in the while statement is if you are adding/removing to that array within the loop, otherwise chuck it in a temp variable and use that instead. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
SV: SV: [PHP] One works, but the other doesn't
-Ursprungligt meddelande- Från: Barry [mailto:[EMAIL PROTECTED] Skickat: den 23 maj 2006 14:24 Till: php-general@lists.php.net Ämne: Re: SV: [PHP] One works, but the other doesn't - Well, I'm kind of a newbie at this. So you think this will solve my problem? Why don't you test it? -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Okej, now I've tested it. I just changed the while part for the rows with the code I got from Chris. But just doing that doesn't make the same result as my code. Do I need to put in $my_data in the foreach part as well? // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
Stut wrote: Lester Caine wrote: I'm having very occasional problems with my PHP5 applications which only seem to be explained if the script is run twice. Example - page has 'Add Ticket' button, which adds a record and marks it as being processed by the location that created it. 99.99% of the time no problems, but just now and again there are two records, with different primary keys - so the database bit worked - but with very close now times and identified as being at the same counter. The next page does not have the 'Add Ticket' button, so it would seem the first script was trigger twice? Am I simply going mad ( which is the logical choice ;) ), or is this something that can happen and needs to be handled? This can happen if a page contains a reference to an empty URL. For example, img src= / would cause the page to be loaded twice in some browsers. That'd be the first thing I'd check. Is the 'Add Ticket' button a GET or POST request? If it's a POST then chances are the script itself has a logic error since the user would get asked if they wanted to repost the data. If it's a get then you've violated one of the cardinal rules of web-based application development - GETs get, POSTs do. a class=button accesskey=A href=ticketaddserve.php?enqno=0Add Ticket/a Just change enqno= for a different queue. Found the simple answer - Double click - two records ! And I'm with you on the problems with IE7 Chris - but in this case even Moz does the Double Click - two records :( So next problem - how do I stop it ! -- Lester Caine - G8HFL - L.S.Caine Electronic Services - http://home.lsces.co.uk Model Engineers Digital Workshop - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/ Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Need Help Please
[snip] While tabindex is a neat thing to use it does not necessarily give focus to the first element of the form, it merely dictates the order in which form elements will be given focus when the tab key is pressed. The action may vary from browser to browser. Likely, when going to a form with tabindex defined, none of the elements will have focus until the tab key is pressed once, at which time the element with tabindex=1 will get focus. If you want to give focus to the first input element of a form you must still use a JavaScript widget to place the focus there after the entire page has loaded, tabindex will make sure that the cursor goes in the order you wish to go in after that.[/snip] [snip] Try to use Firefox to debug your javascript. I guess, there are some javascript error. [/snip] I confirmed before I sent the above e-mail that tabindex did not work in Firefox or Opera either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 3DES w/ openssl_{csr,pkey}_new ?
Does anyone know how to specify the encryption cipher used in this funciton as documented in OpenSSL's genrsa(1)? Why isn't the encryption method a value in [array configargs] ? -des|-des3|-idea These options encrypt the private key with the DES, triple DES, or the IDEA ciphers respectively before outputting it. If none of these options is specified no encryption is used. Or is the encryption method a value that can be specified in config= and req_extensions= ? Right now generated private keys look like: -BEGIN RSA PRIVATE KEY- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,FA81C573DFD21B7D Which is 3DES, but some systems support AES, IDEA, Blowfish, Twofish, It depends on the OpenSSL config. Idea? TIA, ~BAS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
Lester Caine wrote: Stut wrote: Lester Caine wrote: I'm having very occasional problems with my PHP5 applications which only seem to be explained if the script is run twice. Example - page has 'Add Ticket' button, which adds a record and marks it as being processed by the location that created it. 99.99% of the time no problems, but just now and again there are two records, with different primary keys - so the database bit worked - but with very close now times and identified as being at the same counter. The next page does not have the 'Add Ticket' button, so it would seem the first script was trigger twice? Am I simply going mad ( which is the logical choice ;) ), or is this something that can happen and needs to be handled? This can happen if a page contains a reference to an empty URL. For example, img src= / would cause the page to be loaded twice in some browsers. That'd be the first thing I'd check. Is the 'Add Ticket' button a GET or POST request? If it's a POST then chances are the script itself has a logic error since the user would get asked if they wanted to repost the data. If it's a get then you've violated one of the cardinal rules of web-based application development - GETs get, POSTs do. a class=button accesskey=A href=ticketaddserve.php?enqno=0Add Ticket/a if add ticket actually does an insert then it should be a form button - and use POST. no arguments. Just change enqno= for a different queue. Found the simple answer - Double click - two records ! And I'm with you on the problems with IE7 Chris - but in this case even Moz does the Double Click - two records :( So next problem - how do I stop it ! the answer is on the firebird list (you know the one ;-) obviously it assumes you use a POST - but the same disabling trick could be performed on the link with various bits of javascript. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: SV: SV: [PHP] One works, but the other doesn't
some one is about to run out of karma. Jonas Rosling wrote: -Ursprungligt meddelande- Från: Barry [mailto:[EMAIL PROTECTED] Skickat: den 23 maj 2006 14:24 Till: php-general@lists.php.net Ämne: Re: SV: [PHP] One works, but the other doesn't - Well, I'm kind of a newbie at this. So you think this will solve my problem? Why don't you test it? -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Okej, now I've tested it. I just changed the while part for the rows with the code I got from Chris. But just doing that doesn't make the same result as my code. Do I need to put in $my_data in the foreach part as well? // Jonas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Security Concerns with Uploaded Images:
At 9:45 AM +0100 5/23/06, Rory Browne wrote: Use the unix command file to determiner what file you have. I have had the same problem... Don't depend on it. graphic.php GIF89 ?php do_bad_stuff(); ? ANY_GIF_FOOTERS_HERE should according to file be a gif, but contains embedded php. Rory: I'm not disagreeing with you, but how would that work? The file would still have a suffix of .gif and as such wouldn't be recognized as code to execute. For example, I can place php code within a html document and it will not run because the document has a .html suffix -- unless I indicate such in my .htaccess. So, how does placing ?php do_bad_stuff(); ? within any image cause problems? However, if the problem is real, then why not just resample or alter the image in some fashion? Surely, that would cause any embedded code to not run properly, right? Thanks. tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
Is the 'Add Ticket' button a GET or POST request? If it's a POST then chances are the script itself has a logic error since the user would get asked if they wanted to repost the data. If it's a get then you've violated one of the cardinal rules of web-based application development - GETs get, POSTs do. a class=button accesskey=A href=ticketaddserve.php?enqno=0Add Ticket/a Just change enqno= for a different queue. Found the simple answer - Double click - two records ! Like the previous poster says, GET requests should not put, they should only get. Use POST to write to the database. -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Can php convert doc to HTML?
This may be far-fetched, but can php convert a doc file to HTML? I vaguely remember a thread that discussed converting pdf's, but I cannot find reference to either that or to doc in the manual. Any input would be appreciated. If php cannot do this, then could someone recommend a tool that runs on linux that can do the conversion in batch? I have ~200 files to convert. Thanks. Dotan Cohen http://what-is-what.com 623
RE: [PHP] Can php convert doc to HTML?
[snip] This may be far-fetched, but can php convert a doc file to HTML? [/snip] http://www.google.com/search?hl=enq=php+convert+word+doc+to+html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can php convert doc to HTML?
At 7:09 PM +0300 5/23/06, Dotan Cohen wrote: This may be far-fetched, but can php convert a doc file to HTML? I vaguely remember a thread that discussed converting pdf's, but I cannot find reference to either that or to doc in the manual. Any input would be appreciated. If php cannot do this, then could someone recommend a tool that runs on linux that can do the conversion in batch? I have ~200 files to convert. Thanks. Dotan Cohen Dotan: What kind of documents and how to do want to present them? PHP can generate html code and place any text file within in it -- it's simple a matter of arranging things the way you want it to look. For example, you might want to review: http://www.weberdev.com/get_example-1233.html In fact, you can do that without php by using a shtml and includes. But, more specifically, I need to know more about what documents you have and you what you want to do with them. tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Can php convert doc to HTML?
On 5/23/06, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] This may be far-fetched, but can php convert a doc file to HTML? [/snip] http://www.google.com/search?hl=enq=php+convert+word+doc+to+html Thanks, Jay. I mostly found Windows software on google that would do the job. So I decided to roll my own- but being the non-programmer that I am I would have to do it in php. I was half expecting to find that $html_code=doc_to_html($filename); would do it! Of course, that would run with make_coffee(black) running in the background... Dotan
[PHP] Re: Can php convert doc to HTML?
On 5/23/06, tedd [EMAIL PROTECTED] wrote: At 7:09 PM +0300 5/23/06, Dotan Cohen wrote: This may be far-fetched, but can php convert a doc file to HTML? I vaguely remember a thread that discussed converting pdf's, but I cannot find reference to either that or to doc in the manual. Any input would be appreciated. If php cannot do this, then could someone recommend a tool that runs on linux that can do the conversion in batch? I have ~200 files to convert. Thanks. Dotan Cohen Dotan: What kind of documents and how to do want to present them? PHP can generate html code and place any text file within in it -- it's simple a matter of arranging things the way you want it to look. For example, you might want to review: http://www.weberdev.com/get_example-1233.html In fact, you can do that without php by using a shtml and includes. But, more specifically, I need to know more about what documents you have and you what you want to do with them. tedd Thanks for the example, Tedd. That script would work if I already had the files in HTML format. I have about two hundred .doc files that I have archived over the years. Now that I'm rid of windows I would still like to use them. I figure that the easiest way to still view the documents, and make them available for others in my faculty, would be to publish them on dotancohen.com . However, I'd need to convert them from .doc format to HTML before I can put them on the web. I know that I can just drag it all over to a winbox at the university and convert them one-by-one in Word, but I'd rather not do that to 200 individual files! Dotan Cohen http://gmail-com.com 56
Re: [PHP] Can php convert doc to HTML?
Dotan Cohen wrote: This may be far-fetched, but can php convert a doc file to HTML? I vaguely remember a thread that discussed converting pdf's, but I cannot find reference to either that or to doc in the manual. Any input would be appreciated. If php cannot do this, then could someone recommend a tool that runs on linux that can do the conversion in batch? I have ~200 files to convert. I looked at this briefly once, and you might find the OpenOffice.org libraries useful. Iirc, they allow one to use OpenOffice.Org functionality from other programs, but i don't know any details. You might want to browse their site a bit. Best, Koen -- K.F.J. Martens, Sonologic, http://www.sonologic.nl/ Networking, hosting, embedded systems, unix, artificial intelligence. Public PGP key: http://www.metro.cx/pubkey-gmc.asc Wondering about the funny attachment your mail program can't read? Visit http://www.openpgp.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Generating thumbnails from tiff images
mbneto wrote: Hi, I am looking for sample code/class that can generate a thumbnail (can be a png/jpeg) image from a tiff image. So far I've only found examples using png/jpg/gif as input. Any tips? ImageMagick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] getting subdirectory
how do I get the subdirectory that a page is being pulled from. say I have three sites running the same script and I need to determine which site is which. http://www.domain.com/subdir1 http://www.domain.com/subdir2 http://www.domain.com/subdir3 and subdir1, subdir2 and subdir3 all need different header and different db and so on. how would i get that I am in site subdir3 and not in subdir1?
Re: [PHP] getting subdirectory
Perhaps check out some of these http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server -Brad Dallas Cahker wrote: how do I get the subdirectory that a page is being pulled from. say I have three sites running the same script and I need to determine which site is which. http://www.domain.com/subdir1 http://www.domain.com/subdir2 http://www.domain.com/subdir3 and subdir1, subdir2 and subdir3 all need different header and different db and so on. how would i get that I am in site subdir3 and not in subdir1? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
Lester Caine wrote: I'm having very occasional problems with my PHP5 applications which only seem to be explained if the script is run twice. Example - page has 'Add Ticket' button, which adds a record and marks it as being processed by the location that created it. 99.99% of the time no problems, but just now and again there are two records, with different primary keys - so the database bit worked - but with very close now times and identified as being at the same counter. The next page does not have the 'Add Ticket' button, so it would seem the first script was trigger twice? Am I simply going mad ( which is the logical choice ;) ), or is this something that can happen and needs to be handled? OK this is getting interesting. I could not believe that double clicking a link would run the link twice. It just does not make any sense. So I've been round the browsers. IE does NOT process the link twice how ever I try and since all the user sites are IE they should be OK. Moz, Firefox and Sea Monkey *DO* run the link twice, and any code attached to that link. I can't believe that this has not surfaced before. I should not need to prevent duplicate actions, but it looks as that is required by the Mozilla browsers :( -- Lester Caine - G8HFL - L.S.Caine Electronic Services - http://home.lsces.co.uk Model Engineers Digital Workshop - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/ Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting subdirectory
At 02:29 PM 5/23/2006, Dallas Cahker wrote: how do I get the subdirectory that a page is being pulled from. say I have three sites running the same script and I need to determine which site is which. http://www.domain.com/subdir1 http://www.domain.com/subdir2 http://www.domain.com/subdir3 and subdir1, subdir2 and subdir3 all need different header and different db and so on. how would i get that I am in site subdir3 and not in subdir1? Check phpinfo(), particularly SCRIPT_FILENAME or REQUEST_URI or SCRIPT_FILENAME in the Apache Environment section, and everything following _SERVER[REQUEST_URI] in the PHP Variables section. But why not just put the appropriate header in the subdirectory you are using? Cheers - Miles -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.392 / Virus Database: 268.7.0/345 - Release Date: 5/22/2006 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting subdirectory
Dallas Cahker wrote: how do I get the subdirectory that a page is being pulled from. say I have three sites running the same script and I need to determine which site is which. http://www.domain.com/subdir1 http://www.domain.com/subdir2 http://www.domain.com/subdir3 and subdir1, subdir2 and subdir3 all need different header and different db and so on. how would i get that I am in site subdir3 and not in subdir1? $subdir = array_shift(preg_split('|/|', $_SERVER['PHP_SELF'], 0, PREG_SPLIT_NO_EMPTY)); Dante -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
On Tue, 2006-05-23 at 14:08, Lester Caine wrote: I can't believe that this has not surfaced before. I should not need to prevent duplicate actions, but it looks as that is required by the Mozilla browsers :( Why not? Why is it the browser's responsibility? Are you suggesting that when I click twice on a link that runs javascript on every link that it should only work once? Do you think javascript enabled links should work differently than standard links? Have you read the HTML spec for the anchor tag? This is deeper than the presumption that it should work one way and one way only. Personally I think IE does it wrong. Also I use linux and I'm very very likely to use the middle mouse button to popup a link into a new window, and I might do it twice. Or I might do it once, close the window, then proceed through the link. Either way, all these actions mimic a second click. You're server side code should be more robust and never ever trust the user or the browser to do what you want :) Also, just for giggles and farts, I might hold down ctrl+r on the target page. Is that any different than two clicks? Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP SNMP
Greetings, Seem to have a bit of a problem I can't figure out. I'm trying to query servers via SNMP with PHP's snmpget function. Everything seems to work fine, no problems at all - except I'd like the web page to print the string value instead of the numeric value (I.E. OK for the Compaq Drive Array vs 1). Now I've configured everything as best I can tell, and I have the page loading the appropriate MIB file ( snmp_read_mib(/usr/local/share/snmp/mibs/CPQIDA.MIB)). Running it from the terminal via 'php mypage.php' returns all the correct values, I see Ok, instead of 1. But accessing it via the web produces nothing - no output. It doesn't matter how I set the get, I've tried varying it with CPQIDA-MIB::cpqDaCntlrBoardStatus.0, cpqDaCntlrBoardStatus.0, .iso.org.dod.internet.private.enterprises.compaq.cpqDriveArray.cpqDaCom ponent.cpqDaCntlr.cpqDaCntlrTable.cpqDaCntlrEntry.cpqDaCntlrBoardStatus. 0 - all work fine running it via the terminal, but not via the web page. Does anyone have any ideas at all about this? Anything else I can check? If I snmpget the numeric OID (.1.3.6.1.4.1.232.3.2.2.1.1.10.0) it does work, but only returns the numeric value. System Info: PHP 5.0.5 Net-SNMP 5.1.1 Php compiled with --with-snmp and --enable-ucd-snmp-hack Thanks. Jeremy Pavleck Network Engineer - Systems Management IT Networks and Infrastructure Direct Line: 612-977-5881 Toll Free: 1-888-CAPELLA ext. 5881 Fax: 612-977-5053 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Capella University 225 South 6th Street, 9th Floor Minneapolis, MN 55402 www.capella.edu http://www.capella.edu/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] New PostgreSQL
A new version on PostgreSQL came out with a security SQL-injection hole fixed. Reading the docs, I find that clients have to be rebuilt, and with changes in regard to the use of the libpq library. Is there going to be a new version of PHP4 and 5 to ajust to this? Here is the data: http://www.postgresql.org/docs/techdocs.49 -- 21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18 - Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática| '@' || 'unl.edu.ar'; Universidad Nacional| DBA, Programador, del Litoral | Administrador - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] storing single and double quote in MySQL
On Mon, 22 May 2006, John Nichel wrote: Brad Bonkoski wrote: Looks good to me, just make sure you use: http://www.php.net/manual/en/function.stripslashes.php if you have to dump that information back to the users. (you might want to check out: addslashes() to add the slashes before your DB insert, just to keep those things under your command) -Brad No, no, no. Bad coder. I was about to say the same! ;-) Always, always, always... mysql_real_escape_string() The best way is to use PEAR::DB and work with quoteSmart() :-D -- 21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18 - Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática| '@' || 'unl.edu.ar'; Universidad Nacional| DBA, Programador, del Litoral | Administrador - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] storing single and double quote in MySQL
On Mon, 22 May 2006, Richard Lynch wrote: On Mon, May 22, 2006 11:25 am, [EMAIL PROTECTED] wrote: After the form is submitted, some fields are filled with single and/or double quote info (like: 1'2x2'4, or sky's blue, or cool stuff). I validate what I got using mysql_real_escape_string() and then store the result in MySQL. And, it will be stored as:1\'2\x2\'4\, and sky\'s blue, and \cool\ stuff. Is this correct way No. If you still see \' in your data after it's in MySQL, then you have done TWO escapes, and should have only done ONE. By the way, the right way to escape single quotes is by adding anothe single quote (this is SQL standard). Somthing like: O'Conner -- O''Conner -- 21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18 - Lic. Martín Marqués | SELECT 'mmarques' || Centro de Telemática| '@' || 'unl.edu.ar'; Universidad Nacional| DBA, Programador, del Litoral | Administrador - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Can php convert doc to HTML?
2006/5/23, Dotan Cohen [EMAIL PROTECTED]: On 5/23/06, tedd [EMAIL PROTECTED] wrote: At 7:09 PM +0300 5/23/06, Dotan Cohen wrote: This may be far-fetched, but can php convert a doc file to HTML? I vaguely remember a thread that discussed converting pdf's, but I cannot find reference to either that or to doc in the manual. Any input would be appreciated. If php cannot do this, then could someone recommend a tool that runs on linux that can do the conversion in batch? I have ~200 files to convert. Thanks. Dotan Cohen Dotan: What kind of documents and how to do want to present them? PHP can generate html code and place any text file within in it -- it's simple a matter of arranging things the way you want it to look. For example, you might want to review: http://www.weberdev.com/get_example-1233.html In fact, you can do that without php by using a shtml and includes. But, more specifically, I need to know more about what documents you have and you what you want to do with them. tedd Thanks for the example, Tedd. That script would work if I already had the files in HTML format. I have about two hundred .doc files that I have archived over the years. Now that I'm rid of windows I would still like to use them. I figure that the easiest way to still view the documents, and make them available for others in my faculty, would be to publish them on dotancohen.com . However, I'd need to convert them from .doc format to HTML before I can put them on the web. I know that I can just drag it all over to a winbox at the university and convert them one-by-one in Word, but I'd rather not do that to 200 individual files! Dotan Cohen http://gmail-com.com 56 If that's the case, why don't you just use the export as web page or save as web page tools of MS Word (if you don't have it anymore you can as someone who still has it, or I think OpenOffice also has a similar tool).
Re: [PHP] Can a script run twice?
At 11:08 AM 5/23/2006, Lester Caine wrote: I could not believe that double clicking a link would run the link twice. It just does not make any sense. So I've been round the browsers. IE does NOT process the link twice how ever I try and since all the user sites are IE they should be OK. Moz, Firefox and Sea Monkey *DO* run the link twice, and any code attached to that link. I can't believe that this has not surfaced before. I should not need to prevent duplicate actions, but it looks as that is required by the Mozilla browsers :( Just to clarify, there's a difference between double-clicking and clicking more than once before the form completely submits. Double-clicking is a GUI event, the two mouse clicks bound together as a single event as defined by your mouse properties in your computer's operating system. It is certainly possible to single-click once to submit a form, then single-click again to submit the same form a second time before the first request has completed. This sends two submissions to the server and is a common problem on pages that have left this door wide open. Before I wandered off into the dense jungle of possible browser bugs, I'd make absolutely sure my users can't submit the form more than once. There is no way you can prevent your users from clicking more than once unless you visit them and physically restrain them, a strategy which would quickly exhaust your resources and soon curtail your personal freedom. Instead, you have to assume that some of your users WILL multiply click (whether deliberately or accidentally) and plan for that contingency. Multiple submissions can happen for a variety of reasons: - maliciousness; - accidentally clicking twice (happens to me when I've been working too long: my mouse button finger sometimes just clicks of its own accord); - getting impatient with a form submission that takes more than a few seconds and either clicking again or reloading the form to try again. A client-side solution is for Javascript to disable the submit button onsubmit(), however this wouldn't prevent the user from reloading the page and submitting a second time and wouldn't work at all if scripting were disabled. A server-side (and therefore more robust) solution is to accept only one form submission from each user/session. An additional strategy to make your system more robust is to use three pages for your form submission: 1) the form itself, which submits to: 2) the script that processes input, which redirects to: 3) the page that displays the results (or is the next form in a sequence). Even if the user reloads the results page (3) they won't be resubmitting the form (1) or repeating the input processing (2). Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to disable PHP's POST caching?
PHP seems to cache POST data, and waits for the entire POST to finish sending before it makes it available to php://input. I'd like to be able to read the post data from php://input while the client is still uploading it. How can I cause PHP to make the POST data available right away instead of after the client finishes sending? Regards, Adam Zey. PS: As far as I can tell, PHP caches the entire POST in memory as it is being sent, but just doesn't make it available to php://input until after the client is done. Since PHP already has it in memory, why isn't it accessible? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
On Tue, 2006-05-23 at 15:01, Paul Novitski wrote: At 11:08 AM 5/23/2006, Lester Caine wrote: I could not believe that double clicking a link would run the link twice. It just does not make any sense. So I've been round the browsers. IE does NOT process the link twice how ever I try and since all the user sites are IE they should be OK. Moz, Firefox and Sea Monkey *DO* run the link twice, and any code attached to that link. I can't believe that this has not surfaced before. I should not need to prevent duplicate actions, but it looks as that is required by the Mozilla browsers :( Just to clarify, there's a difference between double-clicking and clicking more than once before the form completely submits. Double-clicking is a GUI event, the two mouse clicks bound together as a single event as defined by your mouse properties in your computer's operating system. It is certainly possible to single-click once to submit a form, then single-click again to submit the same form a second time before the first request has completed. This sends two submissions to the server and is a common problem on pages that have left this door wide open. Before I wandered off into the dense jungle of possible browser bugs, I'd make absolutely sure my users can't submit the form more than once. There is no way you can prevent your users from clicking more than once unless you visit them and physically restrain them, a strategy which would quickly exhaust your resources and soon curtail your personal freedom. Instead, you have to assume that some of your users WILL multiply click (whether deliberately or accidentally) and plan for that contingency. Multiple submissions can happen for a variety of reasons: - maliciousness; - accidentally clicking twice (happens to me when I've been working too long: my mouse button finger sometimes just clicks of its own accord); - getting impatient with a form submission that takes more than a few seconds and either clicking again or reloading the form to try again. A client-side solution is for Javascript to disable the submit button onsubmit(), however this wouldn't prevent the user from reloading the page and submitting a second time and wouldn't work at all if scripting were disabled. A server-side (and therefore more robust) solution is to accept only one form submission from each user/session. An additional strategy to make your system more robust is to use three pages for your form submission: 1) the form itself, which submits to: 2) the script that processes input, which redirects to: 3) the page that displays the results (or is the next form in a sequence). Even if the user reloads the results page (3) they won't be resubmitting the form (1) or repeating the input processing (2). I think a 2 page scenario is simpler and more elegant: 1) the form itself, which submits to itself for validation and re-presenation in case of validation errors (including multiple submission of same form - such as going back in browser). This also means if errors occur then the form can be presented with previously submitted data. 2) the final destination page(s) after the form has been submitted with successful validation to which the user is redirected (preventing reload submissions). Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Can php convert doc to HTML?
Thanks for the example, Tedd. That script would work if I already had the files in HTML format. Try searching the site using html, I found 85 examples that did something with html and php. Searching Google, presented this: http://www.needscripts.com/Resource/15472.html That's another source too. I have about two hundred .doc files that I have archived over the years. Now that I'm rid of windows I would still like to use them. I figure that the easiest way to still view the documents, and make them available for others in my faculty, would be to publish them on dotancohen.com . However, I'd need to convert them from .doc format to HTML before I can put them on the web. I know that I can just drag it all over to a winbox at the university and convert them one-by-one in Word, but I'd rather not do that to 200 individual files! Dotan Cohen If you were on a Mac, you could batch change the doc's into html pretty easily using AppleScript. You know that Word can save doc's directly to html. tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting subdirectory
how do I get the subdirectory that a page is being pulled from. say I have three sites running the same script and I need to determine which site is which. http://www.domain.com/subdir1 http://www.domain.com/subdir2 http://www.domain.com/subdir3 and subdir1, subdir2 and subdir3 all need different header and different db and so on. how would i get that I am in site subdir3 and not in subdir1? Lot's of ways to do this. Try: $u = basename($_SERVER['PHP_SELF']); hth's tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
You have users who double-click on their submit button. Deal with it. :-) Add a token to the form and mark it used in the database on first submit. On Tue, May 23, 2006 6:55 am, Lester Caine wrote: I'm having very occasional problems with my PHP5 applications which only seem to be explained if the script is run twice. Example - page has 'Add Ticket' button, which adds a record and marks it as being processed by the location that created it. 99.99% of the time no problems, but just now and again there are two records, with different primary keys - so the database bit worked - but with very close now times and identified as being at the same counter. The next page does not have the 'Add Ticket' button, so it would seem the first script was trigger twice? Am I simply going mad ( which is the logical choice ;) ), or is this something that can happen and needs to be handled? -- Lester Caine - G8HFL - L.S.Caine Electronic Services - http://home.lsces.co.uk Model Engineers Digital Workshop - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/ Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Windows/Apache Shopping Cart Software
On 5/23/06, P. Guethlein [EMAIL PROTECTED] wrote: Anyone have any recommendations/Links to Shopping Cart Software that will run on Windows/Apache/PHP ? Thanks, -Pete Have you tried OSCommerce? -Mike -- Michael E. Crute http://mike.crute.org It is a mistake to think you can solve any major problems just with potatoes. --Douglas Adams -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
On Tue, 2006-05-23 at 15:01, Paul Novitski wrote: An additional strategy to make your system more robust is to use three pages for your form submission: 1) the form itself, which submits to: 2) the script that processes input, which redirects to: 3) the page that displays the results (or is the next form in a sequence). Even if the user reloads the results page (3) they won't be resubmitting the form (1) or repeating the input processing (2). At 01:02 PM 5/23/2006, Robert Cummings wrote: I think a 2 page scenario is simpler and more elegant: 1) the form itself, which submits to itself for validation and re-presenation in case of validation errors (including multiple submission of same form - such as going back in browser). This also means if errors occur then the form can be presented with previously submitted data. 2) the final destination page(s) after the form has been submitted with successful validation to which the user is redirected (preventing reload submissions). Robert, you're absolutely right: there's no reason why my pages 1) 2) can't be the same script posting to itself, and in fact the two-page model you describe is what I most often use in practice. Perhaps I should have written step instead of page... To take your point further, the process would be even simpler more elegant if we stuck with a single script-page that displayed the form, processed input, and displayed the results. If the server-side script is doing its homework, even separating out the results page isn't necessary since the form-processor has to be on guard against multiple executions regardless of the cause. Reloading the script when it's in results mode isn't a big deal because it's smart enough not to process the same input twice. There are occasionally some practical reasons for making the separation. A few years back I wrote an action center engine that drove letter-writing campaigns run from many different environmental websites. We let each client site host the introduction and the final thanks page, but the intervening 'action engine' that processed input and generated email faxes was resident on our domain. I'm sure many users were never aware that they'd left the client site for the duration of the processing. Regards, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting subdirectory
On 5/23/06, Dallas Cahker [EMAIL PROTECTED] wrote: how do I get the subdirectory that a page is being pulled from. say I have three sites running the same script and I need to determine which site is which. http://www.domain.com/subdir1 http://www.domain.com/subdir2 http://www.domain.com/subdir3 and subdir1, subdir2 and subdir3 all need different header and different db and so on. how would i get that I am in site subdir3 and not in subdir1? I like to use dirname(__FILE__) when working with paths. Maybe this will be of use to you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
On Tuesday 23 May 2006 13:40, Richard Lynch wrote: You have users who double-click on their submit button. Deal with it. :-) Add a token to the form and mark it used in the database on first submit. You could even go so far as to disable the form element with the onClick event. Should work for anchor tags as well. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
At 4:02 PM -0400 5/23/06, Robert Cummings wrote: On Tue, 2006-05-23 at 15:01, Paul Novitski wrote: At 11:08 AM 5/23/2006, Lester Caine wrote: I could not believe that double clicking a link would run the link twice. It just does not make any sense. So I've been round the browsers. IE does NOT process the link twice how ever I try and since all the user sites are IE they should be OK. Moz, Firefox and Sea Monkey *DO* run the link twice, and any code attached to that link. I can't believe that this has not surfaced before. I should not need to prevent duplicate actions, but it looks as that is required by the Mozilla browsers :( Just to clarify, there's a difference between double-clicking and clicking more than once before the form completely submits. Double-clicking is a GUI event, the two mouse clicks bound together as a single event as defined by your mouse properties in your computer's operating system. It is certainly possible to single-click once to submit a form, then single-click again to submit the same form a second time before the first request has completed. This sends two submissions to the server and is a common problem on pages that have left this door wide open. Before I wandered off into the dense jungle of possible browser bugs, I'd make absolutely sure my users can't submit the form more than once. There is no way you can prevent your users from clicking more than once unless you visit them and physically restrain them, a strategy which would quickly exhaust your resources and soon curtail your personal freedom. Instead, you have to assume that some of your users WILL multiply click (whether deliberately or accidentally) and plan for that contingency. Multiple submissions can happen for a variety of reasons: - maliciousness; - accidentally clicking twice (happens to me when I've been working too long: my mouse button finger sometimes just clicks of its own accord); - getting impatient with a form submission that takes more than a few seconds and either clicking again or reloading the form to try again. A client-side solution is for Javascript to disable the submit button onsubmit(), however this wouldn't prevent the user from reloading the page and submitting a second time and wouldn't work at all if scripting were disabled. A server-side (and therefore more robust) solution is to accept only one form submission from each user/session. An additional strategy to make your system more robust is to use three pages for your form submission: 1) the form itself, which submits to: 2) the script that processes input, which redirects to: 3) the page that displays the results (or is the next form in a sequence). Even if the user reloads the results page (3) they won't be resubmitting the form (1) or repeating the input processing (2). I think a 2 page scenario is simpler and more elegant: 1) the form itself, which submits to itself for validation and re-presenation in case of validation errors (including multiple submission of same form - such as going back in browser). This also means if errors occur then the form can be presented with previously submitted data. 2) the final destination page(s) after the form has been submitted with successful validation to which the user is redirected (preventing reload submissions). Cheers, Rob. - Considering that everyone is putting in their $0.02, here's my suggestion. 1. Keep the form and processing on one page. The number of pages is not the problem -- double clicking is. 2. Start a session. 3. Initialize a variable that is incremented each time the page is refreshed per session. 4. If the variable's value is larger than one, then do something other than create and insert a duplicate record. Allow the user one insert per session or whatever. If you want a very simple example that deals with clicks, see this: http://xn--ovg.com/session No matter how many times you double click that link, it will not increment more than once (at least that's been my experience). In other words, you can't get it to jump more than one. If you want code, then see this: http://www.weberdev.com/get_example-4349.html tedd PS: For several reasons, don't rely on javascript to control what the user is doing. -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
Paul Novitski wrote: An additional strategy to make your system more robust is to use three pages for your form submission: 1) the form itself, which submits to: So I need separate forms for each function on the main page rather than just a link to ... 2) the script that processes input, which redirects to: Yep that is the one, and it does check if the user already has an existing ticket, but it does not see the ticket created by the first click of double click in Moz :( *THAT* should prevent the second record ! 3) the page that displays the results (or is the next form in a sequence). This just sees the second record and not the first :( Even if the user reloads the results page (3) they won't be resubmitting the form (1) or repeating the input processing (2). Exactly what should be happening. The bit I have to work out is why the second page is not seeing the already loaded ticket! Which I think is exactly where I started, the scripts seem to be processed in parallel and so do not see the data committed by each the other instance. However now that I know what is going on I can deal with it, but the problem is much less in IE anyway :) -- Lester Caine - G8HFL - L.S.Caine Electronic Services - http://home.lsces.co.uk Model Engineers Digital Workshop - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/ Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Can php convert doc to HTML?
On 5/23/06, Martin Alterisio [EMAIL PROTECTED] wrote: If that's the case, why don't you just use the export as web page or save as web page tools of MS Word (if you don't have it anymore you can as someone who still has it, or I think OpenOffice also has a similar tool). Because there are 200 of them. Dotan Cohen http://what-is-what.com 323
Re: [PHP] Can a script run twice?
Richard Lynch wrote: You have users who double-click on their submit button. Deal with it. :-) Add a token to the form and mark it used in the database on first submit. As I have indicated - the code SHOULD have delt with it - that is part of the problem :( I just had not anticipated a browser splitting double click into two single clicks :) But I'm now looking at other ways of flagging the 'second page' so that it knows that it is already being handled. That way I will not need to do so much work everywhere else in the code base. ;) -- Lester Caine - G8HFL - L.S.Caine Electronic Services - http://home.lsces.co.uk Model Engineers Digital Workshop - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/ Treasurer - Firebird Foundation Inc. - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
On Tue, 2006-05-23 at 16:47, tedd wrote: Considering that everyone is putting in their $0.02, here's my suggestion. 1. Keep the form and processing on one page. The number of pages is not the problem -- double clicking is. 2. Start a session. 3. Initialize a variable that is incremented each time the page is refreshed per session. 4. If the variable's value is larger than one, then do something other than create and insert a duplicate record. Allow the user one insert per session or whatever. I'd stay away form relying on the session unless your whole site relies on the session. Your form should contain a hidden submission UID and THAT should be used to determine if the form was submitted already. In this way your form will still detect double submissions even when sessions are disabled. Then the user needs to work quite hard to do a double submission -- if you're using the POST method anyways :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
On Tue, May 23, 2006 1:08 pm, Lester Caine wrote: IE does NOT process the link twice how ever I try and since all the user sites are IE they should be OK. Moz, Firefox and Sea Monkey *DO* run the link twice, and any code attached to that link. I can't believe that this has not surfaced before. I should not need to prevent duplicate actions, but it looks as that is required by the Mozilla browsers :( I can't believe IE has so little faith in its users' that it blocks double-click on a form button... Oh, wait. It's MS. Look, just dump out a uniqid() when you send the form and log that ID. Only accept *ONE* INSERT per ID. Done. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to disable PHP's POST caching?
Adam Zey wrote: PHP seems to cache POST data, and waits for the entire POST to finish sending before it makes it available to php://input. I'd like to be able to read the post data from php://input while the client is still uploading it. How can I cause PHP to make the POST data available right away instead of after the client finishes sending? Regards, Adam Zey. PS: As far as I can tell, PHP caches the entire POST in memory as it is being sent, but just doesn't make it available to php://input until after the client is done. Since PHP already has it in memory, why isn't it accessible? are you sure it's php that is holding it in memory? $_POST is fully filled on the first line of the script which gives me the impression that the webserver is caching the response until it all been uploaded before even starting up php. or am I missing something here? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: SV: [PHP] One works, but the other doesn't
On Tue, May 23, 2006 7:19 am, Jonas Rosling wrote: Well, I'm kind of a newbie at this. So you think this will solve my problem? Yes, as we told you a week ago. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
At 01:50 PM 5/23/2006, Lester Caine wrote: 2) the script that processes input, which redirects to: Yep that is the one, and it does check if the user already has an existing ticket, but it does not see the ticket created by the first click of double click in Moz :( *THAT* should prevent the second record ! 3) the page that displays the results (or is the next form in a sequence). This just sees the second record and not the first :( Even if the user reloads the results page (3) they won't be resubmitting the form (1) or repeating the input processing (2). Exactly what should be happening. The bit I have to work out is why the second page is not seeing the already loaded ticket! Which I think is exactly where I started, the scripts seem to be processed in parallel and so do not see the data committed by each the other instance. I really don't see how this could be browser-dependent. (Unless you have cookies or session cookies disabled in your Mozilla browser?) I can see that, in theory, it might be possible to submit a form twice in succession so quickly that the first query is still being processed by PHP when the second query is initiated. It's hard to imagine such a slow database or script, but perhaps all it would take would be a slow internet connection. However, if you flag form submission in the session cookie I don't think it's practically possible to slip a duplicate by. Because both form submissions would exist in the same session context, the server would know that a tenth or hundredth of a second previously the same session had submitted the same form, and could squelch it. Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date iteration
mktime() args are hour/minute/second/month/day/year or somesuch. You are passing in a string, which PHP tries to convert to int, which results in who knows what, on the line that starts $added = On Tue, May 23, 2006 6:11 am, Dave Goodchild wrote: Hi all, I am writing an app that runs a prize draw, wherein the admin chooses the duration by adding a start date and number of days for the draw to run. These values are passed into a small function that generates an array holding the start date, end date and all dates in between as follows: function generateDates($first, $duration) { $dates = array(); $date = getdate(mktime($first)); $month = $date['mon'];$day = $date['mday'];$year = $date['year']; for ($i = 1;$i = $duration; $i++) { $added = getdate(mktime($day++ . - . $month . - . $year)); $dates[] = $added['mday'] . - . $added['mon'] . - . $added['year']; } return $dates; } $series = generateDates('23-05-2006', 20); var_dump($series); ...when I var_dump the array the iteration stops at May 24 - I am looking into it but does anyone have any ideas why this is sticking ie is my date arithmetic wrong? Cheers. -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon! -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Security Concerns with Uploaded Images:
On Tue, May 23, 2006 3:45 am, Rory Browne wrote: Use the unix command file to determiner what file you have. I have had the same problem... Don't depend on it. http://php.net/getimagesize would be slightly better, as it tries to dig out width/height and number of colors for any given format, plus other fun stuff for some formats. So they'd have to hack MORE of a file and make it look kosher enough to fool that... You STILL ought to put the images OUTSIDE the webtree and use PHP to readfile them so they can never get executed by remote visitor, imho. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Security Concerns with Uploaded Images:
On Tue, May 23, 2006 9:52 am, tedd wrote: At 9:45 AM +0100 5/23/06, Rory Browne wrote: I'm not disagreeing with you, but how would that work? The file would still have a suffix of .gif and as such wouldn't be recognized as code to execute. Unless you have ANOTHER bug somewhere in those million lines of PHP code... Which might maybe let you eval() that, or manage to include it or... Why risk it? Defense in depth. It's not like a call to http://getimagesize is gonna kill you. Even moving the image out of web tree and using readfile is fine for all but the busiest servers. [shrug] I don't understand why people are so resistant to something so simple that adds a layer of defense. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to disable PHP's POST caching?
Jochem Maas wrote: Adam Zey wrote: PHP seems to cache POST data, and waits for the entire POST to finish sending before it makes it available to php://input. I'd like to be able to read the post data from php://input while the client is still uploading it. How can I cause PHP to make the POST data available right away instead of after the client finishes sending? Regards, Adam Zey. PS: As far as I can tell, PHP caches the entire POST in memory as it is being sent, but just doesn't make it available to php://input until after the client is done. Since PHP already has it in memory, why isn't it accessible? are you sure it's php that is holding it in memory? $_POST is fully filled on the first line of the script which gives me the impression that the webserver is caching the response until it all been uploaded before even starting up php. or am I missing something here? You're correct, of course. I was a bit confused, it seems. PUT behaves as I described above. If you do a PUT request for the PHP script directly, the PHP script is called right away, and any attempt to fread from php://input blocks until either the client is done sending, or some sort of buffer is filled (the fread occasionally returns with lots of data if you keep sending). So, might I amend my question to, is it possible to disable PHP buffering PUTs, or Apache buffering POST? (Or is it PHP that just buffers the POST before actually executing the script, but post Apache?) Essentially what I want is a persistant HTTP connection over which I can stream data and have the server-side PHP script process the data as it arrives, rather than when all the data is sent. The only other approach I can figure out is to send periodic POST requests with the latest data, the downside of which is a huge increase in latency between data production and consumption. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Generating thumbnails from tiff images
On Mon, May 22, 2006 5:10 pm, mbneto wrote: I am looking for sample code/class that can generate a thumbnail (can be a png/jpeg) image from a tiff image. So far I've only found examples using png/jpg/gif as input. In those examples, change the line that reads: imagecreatefromjpeg(...) to imagecreatefromtiff(...) That's pretty much it... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to disable PHP's POST caching?
On Tue, May 23, 2006 4:39 pm, Adam Zey wrote: The only other approach I can figure out is to send periodic POST requests with the latest data, the downside of which is a huge increase in latency between data production and consumption. Sounds like you maybe want to run your own server... http://php.net/sockets -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Can php convert doc to HTML?
2006/5/23, Dotan Cohen [EMAIL PROTECTED]: On 5/23/06, Martin Alterisio [EMAIL PROTECTED] wrote: If that's the case, why don't you just use the export as web page or save as web page tools of MS Word (if you don't have it anymore you can as someone who still has it, or I think OpenOffice also has a similar tool). Because there are 200 of them. Dotan Cohen http://what-is-what.com 323 Open file, choose file, save as web page, close file ~ 2 minutes 200 files * 2 minutes = 400 minutes ~ 7 hours How much hours have you wasted looking for a php script? Anyway, I understand... it's a pain in the ass. Whay you're doing wrong is: you have turned your solution into a problem and forgot what the real problem was. Why don't look for another solution: http://www.google.com/search?q=batch+convert+word+to+html But they'll probably ask money for it, so why don't just: http://www.google.com/search?q=batch+convert+word+to+html+free
Re: [PHP] How to disable PHP's POST caching?
Richard Lynch wrote: On Tue, May 23, 2006 4:39 pm, Adam Zey wrote: The only other approach I can figure out is to send periodic POST requests with the latest data, the downside of which is a huge increase in latency between data production and consumption. Sounds like you maybe want to run your own server... http://php.net/sockets Unfortunately, the requirement is that the script be able to accept data on port 80, and co-exist with an existing webserver at the same time. As far as I can tell, this requirement can only be fulfilled by running the script through a webserver. Also, sockets are not compiled into PHP by default, and stream sockets aren't included in versions below PHP 5.0.0, as far as I can tell. That sort of puts a hamper on socket usage. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to disable PHP's POST caching?
Adam Zey wrote: Jochem Maas wrote: ... Essentially what I want is a persistant HTTP connection over which I can stream data and have the server-side PHP script process the data as it arrives, rather than when all the data is sent. The only other approach I can figure out is to send periodic POST requests with the latest data, the downside of which is a huge increase in latency between data production and consumption. Richard's suggestion is most likely the best option (assuming you want to use php) otherwise you'll probably end up hacking webserver and/or php sources (painful, time consuming and a probable maintainance nightmare) ... which also comes with the risk of breaking lots http protocols 'rules' while your at it. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to disable PHP's POST caching?
Jochem Maas wrote:. ... Richard's suggestion is most likely the best option (assuming you want to use php) otherwise you'll probably end up hacking webserver and/or php sources (painful, time consuming and a probable maintainance nightmare) ... which also comes with the risk of breaking lots http protocols 'rules' while your at it. Regards, Adam Zey. As I mentioned in my more recent mail, this unfortunately isn't an option since I need to run on port 80 without disturbing the existing webserver, which requirse that the script be running through the webserver :( I've considered the possibility of looking into Perl or C (via CGI) to try to get the desired functionality, but they have their own issues (namely more complicated installation than just sticking a script anywhere in the web tree as you can with a default PHP installation). Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Can php convert doc to HTML?
my 2cents Martin Alterisio wrote: 2006/5/23, Dotan Cohen [EMAIL PROTECTED]: On 5/23/06, Martin Alterisio [EMAIL PROTECTED] wrote: If that's the case, why don't you just use the export as web page or save as web page tools of MS Word (if you don't have it anymore you can as someone who still has it, or I think OpenOffice also has a similar tool). Because there are 200 of them. Dotan Cohen http://what-is-what.com 323 Open file, choose file, save as web page, close file ~ 2 minutes 200 files * 2 minutes = 400 minutes ~ 7 hours How much hours have you wasted looking for a php script? even if it takes him 14 hours to find a script and get it working he will have: a, learnt quite abit about php'ing/html/etc b, have the basis for a tool that can convert any future .doc files that he finds/get thrown at him. Martin the suggestion you give sucks because it doesn't empower, it leaves Dotan with a sore wrist and no gain in knowledge... maybe it's good advice for 'noobs' on an Office mailing but this is a lsit about programming (sure it's php and plenty of IT related people consider us phpers to be the pretty much the lowest form of programmer - well not as low as VBscripters ;-) - anyone reading, posting here, I would hope, aspires to a little more than PHB's secretary with regards to their IT skills. Anyway, I understand... it's a pain in the ass. Whay you're doing wrong is: you have turned your solution into a problem and forgot what the real problem was. this assumes there is a 'problem' - maybe Dotan is driven more or less by a desire to see if he can do it rather than being up against some deadline or having his boss breathing down his neck waiting for a result? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to disable PHP's POST caching?
Adam Zey wrote: Jochem Maas wrote:. ... Richard's suggestion is most likely the best option (assuming you want to use php) otherwise you'll probably end up hacking webserver and/or php sources (painful, time consuming and a probable maintainance nightmare) ... which also comes with the risk of breaking lots http protocols 'rules' while your at it. Regards, Adam Zey. As I mentioned in my more recent mail, this unfortunately isn't an option since I need to run on port 80 without disturbing the existing why is port 80 a requirement - HTTP can technically over any port. webserver, which requirse that the script be running through the webserver :( I've considered the possibility of looking into Perl or C (via CGI) to try to get the desired functionality, but they have their own issues (namely more complicated installation than just sticking a script anywhere in the web tree as you can with a default PHP installation). sounds to me your requirement rules out the use of bog standard setups, that said I doubt using CGI (with any language you choose) will fix the problem because your still at thew mercy of the webserver that is running the CGI. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to disable PHP's POST caching?
Jochem Maas wrote: why is port 80 a requirement - HTTP can technically over any port. It must be accessible to any client, no matter what sort of firewall or proxy they go through. The only way to absolutely assure that is, as far as I know, to use port 80. It is the only port that you can count on with a fair degree of certainty, if the user is proxied or firewalled. I'd just as soon write my own simple webserver, but then it'd run into conflicts with existing webservers on port 80. My current solution is to buffer data on the client-side, and send a fresh POST request every so many milliseconds (Say, 250) over a keepalive connection with the latest buffered data. The downside of this is that it introduces up to 250ms of latency on top of the existing network latency, and it produces a lot of POST requests. I would really like to eliminate that by streaming the data rather than splitting it up like that. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to disable PHP's POST caching?
[snip] As I mentioned in my more recent mail, this unfortunately isn't an option since I need to run on port 80 without disturbing the existing webserver, which requirse that the script be running through the webserver :( [/snip] I have been reading this thread with much interest and think that perhaps a different approach may be needed. What, exactly, are you trying to accomplish? Skip past the persistency, etc. and describe the problem for which you are seeking a solution. I have the feeling that there may be a way to do what you want with PHP if you will describe the process. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Going through 2 arrays at once
Greetings, PHP Rookie here with a quick question - how do I go through 2 arrays at once with different keys? I'd like to combine these 2 arrays into one: for ( $i = 0; $i sizeof($logicalDrive); $i++) { echo $arrLogDrive[$i]br /\n; } for (reset($logicalDrive); $i = key($logicalDrive); next($logicalDrive)) { echo $i: $logicalDrive[$i]br /\n; } The first array returns things that the OID in the second array represent. I.E. $array = array( 1= 'Controller Index:', 'Drive Index:', Fault Tolerant Mode:', etc, etc); While the second has the MIB name as the key, then the return value of the snmpget: CPQIDA-MIB::cpqDaLogDrvCntlrIndex.0.1: 0 CPQIDA-MIB::cpqDaLogDrvIndex.0.1: 1 CPQIDA-MIB::cpqDaLogDrvFaultTol.0.1: mirroring What I'd like to do it replace CPQIDA-MIB::cpqDaLogDrvCntlrIndex.0.1 that gets displayed into the Controller Index: in the other array. I hope this makes sense. Sorry if it's super simple to solve, but I tried a few things, and googled a few things, but I must have not found the right thing I was looking for, as I still can't figure it out. Thank you very much! JDP Jeremy Pavleck Network Engineer - Systems Management IT Networks and Infrastructure Direct Line: 612-977-5881 Toll Free: 1-888-CAPELLA ext. 5881 Fax: 612-977-5053 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Capella University 225 South 6th Street, 9th Floor Minneapolis, MN 55402 www.capella.edu http://www.capella.edu/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to disable PHP's POST caching?
Jay Blanchard wrote: [snip] As I mentioned in my more recent mail, this unfortunately isn't an option since I need to run on port 80 without disturbing the existing webserver, which requirse that the script be running through the webserver :( [/snip] I have been reading this thread with much interest and think that perhaps a different approach may be needed. What, exactly, are you trying to accomplish? Skip past the persistency, etc. and describe the problem for which you are seeking a solution. I have the feeling that there may be a way to do what you want with PHP if you will describe the process. Essentially, I'm looking to write something in the same vein as GNU httptunnel, but in PHP, and running on port 80 serverside. The server-client part is easy, since a never-ending GET request can stream the data and be consumed by the client instantly. The thing I'm having trouble with is the other direction. Getting data from the client to the server. The data going from client-server needs to be sent over an HTTP connection, which seems to limit me to PUT and POST requests, since they're the only ones that allow significant quantities of data to be sent by the client. Ideally, there should be no delay between the client wanting to send data and the data being sent over the connection; it should be as simple as wrapping the data and sending. So, I need some way to send data to a PHP script that lives on a webserver without any buffering going on. My backup approach, as I described in another mail, involves client-side buffering and multiple POST requests. But that induces quite a bit of latency, which is quite undesirable. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Security Concerns with Uploaded Images:
At 4:34 PM -0500 5/23/06, Richard Lynch wrote: On Tue, May 23, 2006 9:52 am, tedd wrote: At 9:45 AM +0100 5/23/06, Rory Browne wrote: I'm not disagreeing with you, but how would that work? The file would still have a suffix of .gif and as such wouldn't be recognized as code to execute. Unless you have ANOTHER bug somewhere in those million lines of PHP code... Which might maybe let you eval() that, or manage to include it or... Why risk it? Defense in depth. It's not like a call to http://getimagesize is gonna kill you. Even moving the image out of web tree and using readfile is fine for all but the busiest servers. [shrug] I don't understand why people are so resistant to something so simple that adds a layer of defense. Again, I'm not disagreeing with anyone! Instead I'm simply trying to understand how this might work. Understanding a risk is one step closer to providing a proper defense. Just placing an additional step is not necessary adding another layer of defense and in fact goes against the Simple is Beautiful security level that Chris Shifett addresses in his Essential PHP security book. As for using eval(), that function ranks number one on his list to pay the most attention to with regard to security. I hope that no programmer would use an evalu() on an uploaded image -- but, that might be a way to make an image with embedded code do bad things. However, the programmer would have to be an accomplice in the attack by using eval() incorrectly. In the past, I have used headers of jpg files to store information -- there's a lots of unused space there -- however, at some point, the program that deals with the image has to switch from this is an image to this is an executable piece of code for this to work. I'm trying to understand how that would happen. If this is something that is real, then I am also suggesting that doing something with the image should screw-up any embedded code. But, before providing a defense, one should understand the threat. My $0.02. tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Going through 2 arrays at once
Pavleck, Jeremy D. wrote: Greetings, PHP Rookie that explains why you may not have bumped into 'foreach' yet :-) ... here with a quick question - how do I go through 2 arrays at once with different keys? I'd like to combine these 2 arrays into one: for ( $i = 0; $i sizeof($logicalDrive); $i++) { echo $arrLogDrive[$i]br /\n; } for (reset($logicalDrive); $i = key($logicalDrive); next($logicalDrive)) { echo $i: $logicalDrive[$i]br /\n; } something like: foreach ($arrLogDrive as $key = $val) { echo isset($logicalDrive[$key]) ? $logicalDrive[$key]: $value; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Going through 2 arrays at once
Pavleck, Jeremy D. wrote: Greetings, PHP Rookie here with a quick question - how do I go through 2 arrays at once with different keys? I'd like to combine these 2 arrays into one: for ( $i = 0; $i sizeof($logicalDrive); $i++) { echo $arrLogDrive[$i]br /\n; } for (reset($logicalDrive); $i = key($logicalDrive); next($logicalDrive)) { echo $i: $logicalDrive[$i]br /\n; } The first array returns things that the OID in the second array represent. I.E. $array = array( 1= 'Controller Index:', 'Drive Index:', Fault Tolerant Mode:', etc, etc); While the second has the MIB name as the key, then the return value of the snmpget: CPQIDA-MIB::cpqDaLogDrvCntlrIndex.0.1: 0 CPQIDA-MIB::cpqDaLogDrvIndex.0.1: 1 CPQIDA-MIB::cpqDaLogDrvFaultTol.0.1: mirroring What I'd like to do it replace CPQIDA-MIB::cpqDaLogDrvCntlrIndex.0.1 that gets displayed into the Controller Index: in the other array. I hope this makes sense. Sorry if it's super simple to solve, but I tried a few things, and googled a few things, but I must have not found the right thing I was looking for, as I still can't figure it out. Thank you very much! JDP Jeremy Pavleck Network Engineer - Systems Management IT Networks and Infrastructure Direct Line: 612-977-5881 Toll Free: 1-888-CAPELLA ext. 5881 Fax: 612-977-5053 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Capella University 225 South 6th Street, 9th Floor Minneapolis, MN 55402 www.capella.edu http://www.capella.edu/ It sounds like you want to use a while loop and then iterate manually through both arrays, iterating both arrays once per loop iteration. Sorry if I've misunderstood the problem. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to disable PHP's POST caching?
[snip] Essentially, I'm looking to write something in the same vein as GNU httptunnel, but in PHP, and running on port 80 serverside. [/snip] All of that was nice, but still does not explain what you are trying to accomplish other than maintaining a connection state between client and server. What kind of process are you running that would require this? That is what I am looking for. What is the real issue? What would you do that would require a stated connection? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Going through 2 arrays at once
At 5:33 PM -0500 5/23/06, Pavleck, Jeremy D. wrote: Greetings, PHP Rookie here with a quick question - how do I go through 2 arrays at once with different keys? I'd like to combine these 2 arrays into one: Jeremy: array_merge Review this: http://www.weberdev.com/array_merge hth's tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Can php convert doc to HTML?
2006/5/23, Jochem Maas [EMAIL PROTECTED]: my 2cents Martin Alterisio wrote: 2006/5/23, Dotan Cohen [EMAIL PROTECTED]: On 5/23/06, Martin Alterisio [EMAIL PROTECTED] wrote: If that's the case, why don't you just use the export as web page or save as web page tools of MS Word (if you don't have it anymore you can as someone who still has it, or I think OpenOffice also has a similar tool). Because there are 200 of them. Dotan Cohen http://what-is-what.com 323 Open file, choose file, save as web page, close file ~ 2 minutes 200 files * 2 minutes = 400 minutes ~ 7 hours How much hours have you wasted looking for a php script? even if it takes him 14 hours to find a script and get it working he will have: a, learnt quite abit about php'ing/html/etc b, have the basis for a tool that can convert any future .doc files that he finds/get thrown at him. Martin the suggestion you give sucks because it doesn't empower, it leaves Dotan with a sore wrist and no gain in knowledge... maybe it's good advice for 'noobs' on an Office mailing but this is a lsit about programming (sure it's php and plenty of IT related people consider us phpers to be the pretty much the lowest form of programmer - well not as low as VBscripters ;-) - anyone reading, posting here, I would hope, aspires to a little more than PHB's secretary with regards to their IT skills. You're completely right about that. Maybe living too much at the edge of the deadline has turned me into boring freak (most probably). I have to take this way of thinking out my mind. Anyway, I understand... it's a pain in the ass. Whay you're doing wrong is: you have turned your solution into a problem and forgot what the real problem was. this assumes there is a 'problem' - maybe Dotan is driven more or less by a desire to see if he can do it rather than being up against some deadline or having his boss breathing down his neck waiting for a result? I disagree. There is always a problem, the kind of problem you're referring to is I'm lacking this knowledge, or I want to know how to do X, in his case X would be converting word docs to html with a php script. My first impression was that this was his problem, but deducing from what he explained after, I'm certain this isn't the problem he wants to solve, but rather a solution he came up but is unable to put into practice. I think this time PHP is not the solution. A shell script interacting with a third party tool, or a C program interacting with a third party library will be a much more appropiate solution.
Re: [PHP] How to disable PHP's POST caching?
Jay Blanchard wrote: [snip] Essentially, I'm looking to write something in the same vein as GNU httptunnel, but in PHP, and running on port 80 serverside. [/snip] All of that was nice, but still does not explain what you are trying to accomplish other than maintaining a connection state between client and server. What kind of process are you running that would require this? That is what I am looking for. What is the real issue? What would you do that would require a stated connection? Tunelling arbitrary TCP packets. Similar idea to SSH port forwarding, except tunneling over HTTP instead of SSH. A good example might be encapsulating an IRC (or telnet, or pop3, or ssh, etc) connection inside of an HTTP connection such that incomming IRC traffic goes over a GET to the client, and outgoing IRC traffic goes over a POST request. So, the traffic is bounced: [mIRC] --- [client.php] -internet- [apache --- server.php] -internet- [irc server] And the same in reverse. The connection between client.php and server.php is taking the IRC traffic and encapsulating it inside an HTTP connection, where it is unpacked by server.php before being sent on to the final destination. The idea is to get TCP tunneling working, once you do that you can rely on other programs to use that TCP tunnel for more complex things, like SOCKS. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Formatting of a.m. and p.m.
date(a); output = AM Is there any easy way to change the formatting of the output of above from am to a.m. in order to conform to AP style? Something like this below would work, but I'm wondering if there is something I could do differently in the date() fuction to make it work: $date = date(a); if ($date == am) { echo a.m. } elseif ($date == pm) { echo p.m. } -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Formatting of a.m. and p.m.
Kevin Murphy wrote: date(a); output = AM Is there any easy way to change the formatting of the output of above from am to a.m. in order to conform to AP style? Something like this below would work, but I'm wondering if there is something I could do differently in the date() fuction to make it work: $date = date(a); if ($date == am) { echo a.m.} elseif ($date == pm) { echo p.m.} The date function itself doesn't support it, but you don't need IFs. To replace your example: echo str_replace(array(am, pm), array(a.m., p.m.), date(a)); And to do the replacement on a full data/time: echo str_replace(array(am, pm), array(a.m., p.m.), date(g:i a)); which would output something like 12:52 p.m. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how include works?
Hi can anybody explain how require works, and what's the difference between _once and regular? What's going on when php file is processed? In manual is written just, that it's readed once if include_once. What does to mean readed? Thank You -- Mindaugas
Re: [PHP] How to disable PHP's POST caching?
Mindaugas L wrote: I'm still new in php:) what about using cookies? nobody mentioned anything? store info in client cookie, and read it from server the same time? :)) On 5/24/06, *Adam Zey* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: *snip* Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Mindaugas Cookie data is sent to the server as an HTTP header. That sort of puts the kibosh on that. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how include works?
Mindaugas L wrote: Hi can anybody explain how require works, and what's the difference between _once and regular? What's going on when php file is processed? In manual is written just, that it's readed once if include_once. What does to mean readed? Thank You The difference between include and require is that if include() can't find a file, it produces a warning, and the script continues. If require() can't find a file, the script dies with a fatal error. The difference between include()/require() and include_once()/require_once() is that if you do, say, require_once() twice, it ignores the second one. This is useful if your script might include the same file in different places (perhaps your main script includes two other scripts which both themselves include functions.php) Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can a script run twice?
On Tue, 2006-05-23 at 17:26, Paul Novitski wrote: At 01:50 PM 5/23/2006, Lester Caine wrote: 2) the script that processes input, which redirects to: Yep that is the one, and it does check if the user already has an existing ticket, but it does not see the ticket created by the first click of double click in Moz :( *THAT* should prevent the second record ! 3) the page that displays the results (or is the next form in a sequence). This just sees the second record and not the first :( Even if the user reloads the results page (3) they won't be resubmitting the form (1) or repeating the input processing (2). Exactly what should be happening. The bit I have to work out is why the second page is not seeing the already loaded ticket! Which I think is exactly where I started, the scripts seem to be processed in parallel and so do not see the data committed by each the other instance. I really don't see how this could be browser-dependent. (Unless you have cookies or session cookies disabled in your Mozilla browser?) I can see that, in theory, it might be possible to submit a form twice in succession so quickly that the first query is still being processed by PHP when the second query is initiated. It's hard to imagine such a slow database or script, but perhaps all it would take would be a slow internet connection. However, if you flag form submission in the session cookie I don't think it's practically possible to slip a duplicate by. Because both form submissions would exist in the same session context, the server would know that a tenth or hundredth of a second previously the same session had submitted the same form, and could squelch it. These are called race conditions for a reason. They are racing against all kinds of things. Network latency, filesystem, processor, etc etc. Any one of these thigns can slow down one thread just long enough for a newer thread to grab the session data before the older thread saves it. Then the newer thread happily uses the stale session and voila duplicate input. If you absolutely, definitely, for sure want to prevent this... use some kind of locking mechanism. I'd suggest locking the table that manages the form submission unique IDs until you've checked and, if necessary, updated it. There's a reason pages load sequentially in multiple frames when using PHP sessions... it's because PHP uses locking. Are you using PHP native sessions or your own home cooked system? Are sessions even activated? Did the user disabled sessions? Why am I teaching you second year comp sci? :) http://en.wikipedia.org/wiki/Race_condition Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New PostgreSQL
Martin Marques wrote: A new version on PostgreSQL came out with a security SQL-injection hole fixed. Reading the docs, I find that clients have to be rebuilt, and with changes in regard to the use of the libpq library. Is there going to be a new version of PHP4 and 5 to ajust to this? Here is the data: http://www.postgresql.org/docs/techdocs.49 Interesting. Might be better off asking on the internals list if one is needed. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to disable PHP's POST caching?
jekillen wrote: On May 23, 2006, at 3:37 PM, Adam Zey wrote: Essentially, I'm looking to write something in the same vein as GNU httptunnel, but in PHP, and running on port 80 serverside. The server-client part is easy, since a never-ending GET request can stream the data and be consumed by the client instantly. The thing I'm having trouble with is the other direction. Getting data from the client to the server. Allow me to interject a suggestion/question. As far as I understand it AJAX or asyincronous connections sound like what youmr afterno(?) JK AJAX implies javascript, which means a browser. My situation doesn't involve a browser. Unless I'm mistaken, AJAX makes many GET requests to send data, which would have the same problem as sending many POST requests, except you can send less data. Regards, Adam ey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Going through 2 arrays at once
Pavleck, Jeremy D. wrote: how do I go through 2 arrays at once with different keys? for ( $i = 0; $i sizeof($logicalDrive); $i++) { echo $arrLogDrive[$i]br /\n; } for (reset($logicalDrive); $i = key($logicalDrive); next($logicalDrive)) { echo $i: $logicalDrive[$i]br /\n; } The slight complication here is that you are iterating through an indexed and an associative array. There are two easy solutions, building on each of the above loops. As you don't care about the key of the second array you can convert it to an indexed array using array_values(). $logicalDrive_indexed = array_values($logicalDrive); for($i=0; $imin(sizeof($arrLogDrive), sizeof($logicalDrive)); $i++) { echo $arrLogDrive[$i].: .$logicalDrive[$i].br /\n; } Alternatively the next() function works for indexed arrays. for(reset($arrLogDrive), reset($logicalDrive); current($arrLogDrive)!==false current($logicalDrive)!==false; next($arrLogDrive), next($logicalDrive)) { echo current($arrLogDrive).: .current($logicalDrive).br /\n; } The second approach will have problems if either of the arrays contain the value false. Personally I would use the first loop. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP SNMP
Pavleck, Jeremy D. wrote: Greetings, Seem to have a bit of a problem I can't figure out. I'm trying to query servers via SNMP with PHP's snmpget function. Everything seems to work fine, no problems at all - except I'd like the web page to print the string value instead of the numeric value (I.E. OK for the Compaq Drive Array vs 1). Now I've configured everything as best I can tell, and I have the page loading the appropriate MIB file ( snmp_read_mib(/usr/local/share/snmp/mibs/CPQIDA.MIB)). Running it from the terminal via 'php mypage.php' returns all the correct values, I see Ok, instead of 1. But accessing it via the web produces nothing - no output. It doesn't matter how I set the get, I've tried varying it with CPQIDA-MIB::cpqDaCntlrBoardStatus.0, cpqDaCntlrBoardStatus.0, .iso.org.dod.internet.private.enterprises.compaq.cpqDriveArray.cpqDaCom ponent.cpqDaCntlr.cpqDaCntlrTable.cpqDaCntlrEntry.cpqDaCntlrBoardStatus. 0 - all work fine running it via the terminal, but not via the web page. Does the webpage show anything at all? Sounds like you have a fatal error.. Does the web php version have snmp support? Check with a phpinfo page. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php