auAlan Posted November 9, 2013 Share Posted November 9, 2013 Hi, I had this message recently from my website hosting provider. “We would like to inform you that your account has exceeded the allowed monthly program and script executions per account and your web service has been limited”. I then asked for more information and got this reply; “I checked the files and found that the issue was caused by this script: 147455 /home/supersym/public_html/testcounter.php.It seems that this script generates too many script executions - probably it is not optimized properly or includes a lot of files. Please optimize it or delete it and the problem should be resolved.”I am unable to delete this file as it’s a critical part of my website and I have no idea how to “optimize” it. Can anyone suggest a way to “optimize” it?My website is not very old and has a very low hit rate at the moment so if it ever takes off it will “exceeded the allowed monthly program and script executions” all of the time! I don't think that changing hosting providers is the answer (it has been suggested), because the problem with the code will still be there. I would like to get this sorted asap. Thanks in advance for any help. The code is attached. php Code.doc Quote Link to comment https://forums.phpfreaks.com/topic/283758-script-executions-exceeded/ Share on other sites More sharing options...
QuickOldCar Posted November 9, 2013 Share Posted November 9, 2013 Get a better host is most likely your best solution. Quote Link to comment https://forums.phpfreaks.com/topic/283758-script-executions-exceeded/#findComment-1457693 Share on other sites More sharing options...
auAlan Posted November 9, 2013 Author Share Posted November 9, 2013 But the problem will still be there. I use siteground which I understand is a good a host; isn't it? Quote Link to comment https://forums.phpfreaks.com/topic/283758-script-executions-exceeded/#findComment-1457699 Share on other sites More sharing options...
QuickOldCar Posted November 10, 2013 Share Posted November 10, 2013 Lots of hosts when are shared don't want you doing much, they expect simple little sites that are barely used. Maybe your next step is getting a dedicated server so you can run what you need to. Quote Link to comment https://forums.phpfreaks.com/topic/283758-script-executions-exceeded/#findComment-1457703 Share on other sites More sharing options...
QuickOldCar Posted November 10, 2013 Share Posted November 10, 2013 Is the file you uploaded even testcounter.php, to me it looks like a huge shopping cart script that includes all sorts of stuff including a framework. And can post the code here using the sites code tags, some don't like clicking to read them. Quote Link to comment https://forums.phpfreaks.com/topic/283758-script-executions-exceeded/#findComment-1457704 Share on other sites More sharing options...
auAlan Posted November 10, 2013 Author Share Posted November 10, 2013 I tried earlier to upload the code but a message said that the file was too large so here it is; I hope! <?php define('_JEXEC', 1); define('DS', DIRECTORY_SEPARATOR); if (file_exists(dirname(__FILE__) . '/defines.php')) { include_once dirname(__FILE__) . '/defines.php'; } if (!defined('_JDEFINES')) { define('JPATH_BASE', dirname(__FILE__)); require_once JPATH_BASE . '/includes/defines.php'; } require_once JPATH_BASE . '/includes/framework.php'; // Mark afterLoad in the profiler. JDEBUG ? $_PROFILER->mark('afterLoad') : null; // Instantiate the application. $app = JFactory::getApplication('site'); // Initialise the application. $app->initialise(); // Mark afterIntialise in the profiler. JDEBUG ? $_PROFILER->mark('afterInitialise') : null; // Route the application. $app->route(); // Mark afterRoute in the profiler. JDEBUG ? $_PROFILER->mark('afterRoute') : null; // Dispatch the application. $app->dispatch(); // Mark afterDispatch in the profiler. JDEBUG ? $_PROFILER->mark('afterDispatch') : null; // Render the application. $app->render(); // Mark afterRender in the profiler. JDEBUG ? $_PROFILER->mark('afterRender') : null; $db = JFactory::getDBO(); if (isset($_REQUEST['purchase']) && intval($_REQUEST['purchase']) > 0) { //die(); //echo "Purchased<br>"; //exit; if (isset($_REQUEST['aid']) && $_REQUEST['aid'] != "") { $aid = $_REQUEST['aid']; } else { $aid = "0"; } if (isset($_REQUEST['data']) && $_REQUEST['data'] != "") { $pprice = $_REQUEST['data']; } else { $pprice = "0"; } if (isset($_REQUEST['startprice']) && $_REQUEST['startprice'] != "") { $stprice = $_REQUEST['startprice']; } else { $stprice = "0"; } //echo "<span style='color:black;'>Purchased Price: </span>$" . $pprice; if (isset($_REQUEST['adsuseremail']) && $_REQUEST['adsuseremail'] != "") { $adsowner = $_REQUEST['adsuseremail']; } if (isset($_REQUEST['adsusername']) && $_REQUEST['adsusername'] != "") { $adsuser = $_REQUEST['adsusername']; } if (isset($_REQUEST['to']) && $_REQUEST['to'] != "") { $buyer = $_REQUEST['to']; } if (isset($_REQUEST['toname']) && $_REQUEST['toname'] != "") { $toname = $_REQUEST['toname']; } $db->setQuery("SELECT * FROM `b04qa_users` WHERE `email` = '" . $buyer . "'"); $usddrar = $db->loadObjectList(); $uddddddd = $usddrar[0]->id; $app = JFactory::getApplication(); $query = "UPDATE `b04qa_adsmanager_ads` SET `purchased` = '1' , `purchaseprice` = '" . $pprice . "', `purchaseby` = '" . $uddddddd . "' WHERE `id` = " . $aid . " "; // echo $query; $db->setQuery($query); $db->query(); $db->setQuery("SELECT * FROM `b04qa_adsmanager_ads` WHERE `id` = " . $aid . " "); $resd = $db->loadObjectList(); if (!empty($resd)) { $startprs = $resd[0]->ad_startingprice; $adownid = $resd[0]->adsownerid; $adsownersname = $resd[0]->name; $zip = $resd[0]->ad_zip; $city = $resd[0]->ad_city; $contact = $resd[0]->ad_phone; $purchaedprice = $resd[0]->purchaseprice; $purchaedprice1 = $resd[0]->purchaseprice; $title = $resd[0]->ad_headline; $adowneremail = $resd[0]->email; /* * ************ ads owner / seller detail ******************************** */ $emailBody = "Confirmation of purchased item. " . "\n"; $emailBody .= "Your contact details have been sent to the seller. " . "\n" . "\n"; $emailBody .= "Sellers Details: " . "\n"; $emailBody .= "Name: " . $adsownersname . "" . "\n"; $emailBody .= "Email Address: " . $adowneremail . "" . "\n"; $emailBody .= "Advert Title: " . $title . "" . "\n"; $emailBody .= "Purchased Price: $" . $purchaedprice . "" . "\n"; /* * ************ purchased by / buyer detail ******************************** */ $emailBody1 = "Your item has been purchased by: " . $toname . "\n"; // buyer detail $emailBody1 .= "Your contact details have been sent to the buyer." . "\n" . "\n"; $emailBody1 .= "Buyers Details:" . "\n"; $emailBody1 .= "Name: " . $toname . "" . "\n"; $emailBody1 .= "Email Address: " . $buyer . "" . "\n"; $emailBody1 .= "Advert Title: " . $title . "" . "\n"; $emailBody1 .= "Purchased Price: $" . $purchaedprice1 . "" . "\n"; $emailSubject = "You Purchased An Item"; $emailSubject1 = "Your Item Has Been Purchased"; $sitemail = "alsads@alsads.com.au"; $site = "Al's Ads"; $uri = JURI::getInstance(); $sent = JFactory::getMailer()->sendMail($sitemail, $site, $buyer, $emailSubject, $emailBody); $sent1 = JFactory::getMailer()->sendMail($sitemail, $site, $adsowner, $emailSubject1, $emailBody1); /* if(isset($_REQUEST['startprs']) && $_REQUEST['startprs'] != ""){ $startprs = $_REQUEST['startprs']; } else { $startprs = "0";} if(isset($_REQUEST['mnprs']) && $_REQUEST['mnprs'] != ""){ $mnprs = $_REQUEST['mnprs']; } else { $mnprs = "0";} if(isset($_REQUEST['hour']) && $_REQUEST['hour'] != ""){ $hour = $_REQUEST['hour']; } else { $hour = "0";} if(isset($_REQUEST['minval']) && $_REQUEST['minval'] != ""){ $minval = $_REQUEST['minval']; } else { $minval = "0";} if(isset($_REQUEST['dayd']) && $_REQUEST['dayd'] != ""){ $dayd = $_REQUEST['dayd']; } else { $dayd = "0";} if(isset($_REQUEST['mnth']) && $_REQUEST['mnth'] != ""){ $mnth = $_REQUEST['mnth']; } else { $mnth = "0";} if(isset($_REQUEST['yer']) && $_REQUEST['yer'] != ""){ $yer = $_REQUEST['yer']; } else { $yer = "0";} if(isset($_REQUEST['dayd']) && $_REQUEST['dayd'] != ""){ $dayd = $_REQUEST['dayd']; } else { $dayd = "0";} */ } exit(); } if (isset($_REQUEST['ended']) && intval($_REQUEST['ended']) > 0) { $aids = intval($_REQUEST['ended']); //$app = JFactory::getApplication(); $query = "UPDATE `b04qa_adsmanager_ads` SET `ended` = '1' WHERE `id` = $aids"; $db->setQuery($query); $db->query(); echo "Ended"; exit(); } if (isset($_REQUEST['refresh']) && $_REQUEST['refresh'] != '') { $ad_id = intval($_REQUEST['refresh']); //echo $ad_id; $db->setQuery("SELECT * FROM `b04qa_adsmanager_ads` WHERE id='$ad_id'"); $resd = $db->loadObjectList(); $owner_timezone_utc_offset = (int) $resd[0]->owner_timezone_utc_offset; $ad_startingprice = (float) $resd[0]->ad_startingprice; $ad_minimumprice = (float) $resd[0]->ad_minimumprice; //$datecreated = $resd[0]->starttime; $date_modified = $resd[0]->date_modified; $ad_year = $resd[0]->ad_year; $ad_month = $resd[0]->ad_month; $ad_day = $resd[0]->ad_day; $ad_hour = $resd[0]->ad_hour; $ad_minutes = $resd[0]->ad_minutes; $owner_timezone_utc_offset_seconds = (int) $resd[0]->owner_timezone_utc_offset * 60; //$starttime_server = gmstrftime("%Y-%m-%d %H:%M:%S", $starttime/1000 + $owner_timezone_utc_offset_seconds); //$starttime = $starttime_server; $server_tz_name = date_default_timezone_get(); $server_tz = new DateTimeZone($server_tz_name); $server_dt = new DateTime("now", $server_tz); $server_timezone_utc_offset = $server_tz->getOffset($server_dt); $starttime = strtotime($resd[0]->starttime); // In server timezone $starttime_utc = $starttime - $server_timezone_utc_offset; $endtime = mktime($ad_hour, $ad_minutes, 0, $ad_month, $ad_day, $ad_year); // In owner timezone $endtime_utc = $endtime - $owner_timezone_utc_offset_seconds; // In UTC $endtime_server = $endtime_utc + $server_timezone_utc_offset; //$ad_expired_time = "$ad_year-$ad_month-$ad_day $ad_hour:$ad_minutes"; //$ad_expired_time = gmstrftime("%Y-%m-%d %H:%M:%S", $endtime); $ad_expired_time = strftime("%Y-%m-%d %H:%M:%S", $endtime_server); $diff_seconds = $endtime_utc - $starttime_utc; if ($diff_seconds > 0) { $timer_price_step = ($ad_startingprice - $ad_minimumprice) / $diff_seconds; } else { $timer_price_step = 0; $diff_seconds = 0; } /* $currenttime_utc = time() - $server_timezone_utc_offset; // UTC time $current_diff_seconds = $currenttime_utc - $starttime_utc ; if ( $current_diff_seconds > 0 ) { $current_price = $ad_startingprice - $current_diff_seconds*$timer_price_step; } else { $current_price = $ad_minimumprice; } */ $res = array( 'date_modified' => $date_modified, 'ad_expired_time' => $ad_expired_time, 'starttime' => $starttime, 'starttime_utc' => $starttime_utc, 'endtime' => $endtime, 'endtime_utc' => $endtime_utc, 'starttime_utc_formatted' => strftime("%Y%m%d%H%M%S", $starttime_utc), 'endtime_utc_formatted' => strftime("%Y%m%d%H%M%S", $endtime_utc), 'starttime' => $resd[0]->starttime, 'ad_startingprice' => $ad_startingprice, 'ad_minimumprice' => $ad_minimumprice, //'current_price'=>$current_price, 'timer_price_step' => $timer_price_step, 'diff_seconds' => $diff_seconds, //'currenttime'=>$currenttime, //'currenttime_utc'=>strftime("%Y-%m-%d %H:%M:%S",$currenttime_utc), //'current_diff_seconds'=>$current_diff_seconds, 'ended' => $resd[0]->ended, 'purchased' => $resd[0]->purchased, 'purchaseprice' => $resd[0]->purchaseprice, 'owner_timezone_utc_offset' => $owner_timezone_utc_offset, 'server_timezone_name' => $server_tz_name . "<br> Life in seconds: " . strftime("%Y-%m-%d %H:%M:%S", $starttime_utc) . " - " . strftime("%Y-%m-%d %H:%M:%S", $endtime_utc) . " = $diff_seconds" . "<br>", 'server_timezone_utc_offset' => $server_timezone_utc_offset, ); echo json_encode($res); exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/283758-script-executions-exceeded/#findComment-1457717 Share on other sites More sharing options...
auAlan Posted November 11, 2013 Author Share Posted November 11, 2013 If my code cannot be optimized then please let me know; although I don't know what I can do about it. Quote Link to comment https://forums.phpfreaks.com/topic/283758-script-executions-exceeded/#findComment-1457839 Share on other sites More sharing options...
Solution kicken Posted November 11, 2013 Solution Share Posted November 11, 2013 I'd try and get some clarification about the problem from your host. If they just have an arbitrary "You can only run X PHP scripts per month" rule which is what you post makes it sound like, then your host just sucks and you need to move somewhere else. If your script is indeed causing performance issues by running too long or using too many resources, perhaps they can provide a bit more insight into what kinds of issues it is causing. Quote Link to comment https://forums.phpfreaks.com/topic/283758-script-executions-exceeded/#findComment-1457916 Share on other sites More sharing options...
auAlan Posted November 12, 2013 Author Share Posted November 12, 2013 Thanks kicken. I have been corresponding with my host Siteground and they have been exceptional to say the least. They went out of their way to try and resolve the problem and their final reply was too long to post here. The php script (above) that is causing the problem is an integral part of my website and runs continually. This one sentence sums it up pretty well. "Nevertheless, it is my believe that the script is executed so often, just so that frequent updates on the current status of ads on the site are passed to the Joomla application, so that all managed ads and their details are up-to-date." I agree. Changing host will not solve the issue; it appears that I will need a dedicated server . Quote Link to comment https://forums.phpfreaks.com/topic/283758-script-executions-exceeded/#findComment-1457997 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.