www.webdeveloper.com
Results 1 to 7 of 7

Thread: Script Executions Exceeded

  1. #1
    Join Date
    Dec 2012
    Location
    Central Coast, NSW, Australia
    Posts
    21

    Script Executions Exceeded

    Hi, I had this message recently from my website host; “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 php wizard that may be able to help me with my problem?

    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!

    Thanks in Advance.

  2. #2
    Join Date
    Oct 2013
    Posts
    6
    Post the code here and I will have a look at it.

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,614
    Or upgrade to a better hosting provider/plan.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Oct 2013
    Posts
    6
    Another good option above :P

  5. #5
    Join Date
    Dec 2012
    Location
    Central Coast, NSW, Australia
    Posts
    21
    Thanks mrnash, here is the code.

    PHP Code:
    <?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_minutes0$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();
    }
    ?>
    Last edited by NogDog; 11-09-2013 at 04:23 PM. Reason: added [php] tags around code

  6. #6
    Join Date
    Dec 2012
    Location
    Central Coast, NSW, Australia
    Posts
    21
    Hi mrnash, have you had a chance to have a look at my code yet? Are you able to optimize it?

  7. #7
    Join Date
    Dec 2012
    Location
    Central Coast, NSW, Australia
    Posts
    21
    Does anyone know who or where I can get my php code as shown above optimized. I don't think that changing hosting providers is the answer because the problem with the code will still be there. I would like to get this sorted asap. Thanks again for any help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles