wizardsandwars Posted March 18, 2003 Share Posted March 18, 2003 I notice that several scripts and contributions that worked fine in php4.2 no longer work with php4.3. My auto feedback request is one example. It works GREAT in php4.2, however, when my host upgradedto 4.3, this script crashed the server? Can anyone point out what in this script isn't compatible with php4.3? <?php /////////////////////////////////////////////////////////////////// // $Id: Feedback Request (feedback_request.php),v 1.0 2003/01/02 // Programed By: Christopher Bradley www.wizardsandwars.com // // Developed for osCommerce, Open Source E-Commerce Solutions // http://www.oscommerce.com // Copyright (c) 2002 osCommerce // // Released under the GNU General Public License // /////////////////////////////////////////////////////////////////// /////////////////// REQUIRES ////////////////////////////////// require("includes/application_top.php"); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CREATE_ACCOUNT_PROCESS); /////////////////// VARIABLES ////////////////////////////////// $test=0; $test=$HTTP_GET_VARS['test']; $datafile= DIR_FS_DOCUMENT_ROOT ."feedback_data.txt"; $historyfile= DIR_FS_DOCUMENT_ROOT . "request_history.txt"; /////////////////// BODY /////////////////////////////////////// // Get the static customer ID where we left off the last time this script ran $fd = fopen ("$datafile", "r"); while (!feof ($fd)) { $buffer = fgets($fd, 4096); if($buffer){$num=$buffer;} } fclose ($fd); // If this is the first time running, we want to set the static variable to the highest customer_id if(!$num){ $max_id_query_raw = "SELECT max(customers_id) as customers_id FROM customers"; $max_id_query = tep_db_query($max_id_query_raw); while ($max_id_array = tep_db_fetch_array($max_id_query)) {$max_id = $max_id_array['customers_id'];} } else { print "Looking for NEW customers that are not currently online, and have not purchased....n<br>"; // Get NEW customers info that are not currently online, [OPTIONAL: We could add "and that have left items in cart" by adding to the where clause here] $customers_query_raw = "SELECT customers.customers_id, customers.customers_firstname, customers.customers_email_address FROM customers LEFT JOIN whos_online ON customers.customers_id = whos_online.customer_id WHERE whos_online.customer_id IS NULL and customers_id > $num ORDER BY customers.customers_id"; $customers_query = tep_db_query($customers_query_raw); while ($customers = tep_db_fetch_array($customers_query)) { print "Found new customers not online ->" . $customers['customers_email_address'] . "n"; // Make sure that thse customers have not placed an order. //NOTE: This query takes into consideration the default default PayPal IPN Order Status of 99999. $max_id=$customers['customers_id']; $customers_that_purchased_query_raw = "SELECT 1 as ordered_or_not FROM customers LEFT JOIN orders ON customers.customers_id = orders.customers_id WHERE customers.customers_id = $max_id AND (orders.customers_id IS NULL OR orders.orders_status = 99999)"; $customers_that_purchased_query = tep_db_query($customers_that_purchased_query_raw); while ($have_not_ordered = tep_db_fetch_array($customers_that_purchased_query)) { if ($have_not_ordered){ $fd = fopen ("$historyfile", "a+"); $log_msg="Emailing " . $customers['customers_email_address'] . "nn"; fwrite($fd, $log_msg); fclose ($fd); if ($test){ $email_address=STORE_OWNER_EMAIL_ADDRESS; } else { $email = $customers['customers_email_address']; } tep_mail('', $email, FEEDBACK_EMAIL_SUBJECT, "Hello ".$customers['customers_firstname'] ."," . FEEDBACK_EMAIL_TEXT, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, ''); } } } } // If we found customers to email, or this is the first time running this script, we need to update our static file if ($max_id){ if (is_writable("$datafile")) { if (!$fp = fopen($datafile, 'w')) { print "Cannot open file ($datafile)"; exit; } // Write $static to our opened file. if (!fputs($fp, "$max_id")) { print "Cannot write to file ($datafile)"; exit; } fclose($fp); } else { print "The file $datafile is not writable"; } } else { print "No new customers found."; } ?> ------------------------------------------------------------------------------------------------------------------------- NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit. If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help. Link to comment Share on other sites More sharing options...
Druide Posted March 18, 2003 Share Posted March 18, 2003 try this http://bugs.php.net/ Robert We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;) Link to comment Share on other sites More sharing options...
wizardsandwars Posted March 18, 2003 Author Share Posted March 18, 2003 Well, I guess that's a start, but withour being able to narrow it sdown to what it is, I have no idea if this is a bug or not. In fact, it probably is not. It's probably got something to do with the way it passes variables. Anyone know if $HTTP_GET_VARS is still valid in php4.3? ------------------------------------------------------------------------------------------------------------------------- NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit. If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help. Link to comment Share on other sites More sharing options...
Harald Ponce de Leon Posted March 18, 2003 Share Posted March 18, 2003 Anyone know if $HTTP_GET_VARS is still valid in php4.3? Yes, otherwise osCommerce would not be working :D , osCommerce Link to comment Share on other sites More sharing options...
wizardsandwars Posted March 18, 2003 Author Share Posted March 18, 2003 Well, for some reason, this script will crash a server running php4.3, and I don't see anything that could possible cause the problem. Anyone else? ------------------------------------------------------------------------------------------------------------------------- NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit. If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help. Link to comment Share on other sites More sharing options...
Harald Ponce de Leon Posted March 18, 2003 Share Posted March 18, 2003 Try some old fashioned debugging! ;) Step down the script and add the following after a certain piece of logic: die("it died here"); You will then find out what the problem area is. , osCommerce Link to comment Share on other sites More sharing options...
wizardsandwars Posted March 18, 2003 Author Share Posted March 18, 2003 Well, I'd love to, however, I think my host would be pretty upset if I set a brekpoint too late, and brought the server down. C'mon, Harold, I'm cautious, not stuipd. ------------------------------------------------------------------------------------------------------------------------- NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit. If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help. Link to comment Share on other sites More sharing options...
Guest Posted March 18, 2003 Share Posted March 18, 2003 i'm sure its a moot point question but did you check the php variables to make certain the ones you need are in fact active and not turned off? don't beat me please.... 8) Link to comment Share on other sites More sharing options...
dreamscape Posted March 18, 2003 Share Posted March 18, 2003 here is the change log of the updates to PHP http://www.php.net/ChangeLog-4.php I didn't read them all but there are quite a number of changes to fopen()... maybe that could be a place to start? The only thing necessary for evil to flourish is for good men to do nothing - Edmund Burke Link to comment Share on other sites More sharing options...
Harald Ponce de Leon Posted March 18, 2003 Share Posted March 18, 2003 Well, I'd love to, however, I think my host would be pretty upset if I set a brekpoint too late, and brought the server down. C'mon, Harold, I'm cautious, not stuipd. :shock: Maybe my intentions were misinterpreted. I use die() or exit() for debugging all the time - you can even use error_log() to write some string to a file without using die() or exit() to quit the script (and use the nifty unix tail command to watch the file in realtime). die() does not bring down the server - it only stops PHP continuing on parsing the rest of the script. The entire point though of die() or exit() is to kill the script at certain points of the parsing. "this script crashed the server?" does not tell me if PHP is reporting errors or not - I presume not otherwise you would have posted them. I will suggest again to walk through the script with die(), exit(), or error_log() debugging calls to see how far PHP parses the script before it "crashes the server". A PHP script should not be able to "crash the server" though, so again I presume absolutely nothing is being shown on the browser. , osCommerce Link to comment Share on other sites More sharing options...
wizardsandwars Posted March 18, 2003 Author Share Posted March 18, 2003 die() does not bring down the server - it only stops PHP continuing on parsing the rest of the script. I actually use die quite a bit myself, usually after every opening or closing of a file. In this case, however, I wasn't aware of the die function in php. But, my reservation is that I don't really have the luxury of setting breakpoints until I find the source of the problem, because this would mean having to run the source of the problem, obtaining the undesired results at least once before finding and identifying the problem. Would it not? "this script crashed the server?" does not tell me if PHP is reporting errors or not - I presume not otherwise you would have posted them. Unfortunaly, I don't have my own server, and so far, the only indication that I have that the script doesn't work properly anymore is that 1.) it takes several minutes to complete, when this script should take less than a second. And 2.) My webhost said that this scipt used up so much of the servers resources, that it had to be bounced. Sounds sorta like a segmentation fault to me, but again, I don't have the logs redily available. I only asked here because I know that Dreamscape has worked with php4.3, and that several other programmers here have had problems with certain contributions and scripts (AD Tracker, Gift Voucher) that also have problems when running under php4.3. I had hoped that someone could identify what in this script could be causing the problem, therefore I wouldn't have to 'debugg' and subsequently bring the server down by using too much of the systmes resources. ------------------------------------------------------------------------------------------------------------------------- NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit. If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help. Link to comment Share on other sites More sharing options...
Guest Posted March 18, 2003 Share Posted March 18, 2003 what version of OSC are you using? I thought that resource load issue had been taken care of long ago :? Link to comment Share on other sites More sharing options...
wizardsandwars Posted March 18, 2003 Author Share Posted March 18, 2003 Loaded 5 ------------------------------------------------------------------------------------------------------------------------- NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit. If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.