Example #1
0
 public static function create($start = false, $ms = true)
 {
     $sw = new StopWatch($ms);
     if ($start) {
         $sw->start();
     }
     return $sw;
 }
Example #2
0
 public function GetAttributes($category, $entityIds = array())
 {
     if (!is_array($entityIds) && !empty($entityIds)) {
         $entityIds = array($entityIds);
     }
     $attributeList = new AttributeList();
     $attributes = $this->attributeRepository->GetByCategory($category);
     $stopwatch = new StopWatch();
     $stopwatch->Start();
     $values = $this->attributeRepository->GetEntityValues($category, $entityIds);
     foreach ($attributes as $attribute) {
         $attributeList->AddDefinition($attribute);
     }
     foreach ($values as $value) {
         $attributeList->AddValue($value);
     }
     $stopwatch->Stop();
     Log::Debug('Took %d seconds to load custom attributes for category %s', $stopwatch->GetTotalSeconds(), $category);
     return $attributeList;
 }
 protected function execute($arguments = array(), $options = array())
 {
     $stop_watch = new StopWatch();
     $stop_watch->start();
     logline('Started processing.');
     $databaseManager = new sfDatabaseManager($this->configuration);
     $queries = QueryPeer::doSelect(new Criteria());
     logline(sprintf("There are %s queries to process.", sizeof($queries)));
     foreach ($queries as $query) {
         $connection = Propel::getConnection();
         $sql = "SELECT STD(%s) as standard_deviation FROM %s where %s=%s";
         $sql = sprintf($sql, QueryResultPeer::RESULT_SIZE, QueryResultPeer::TABLE_NAME, QueryResultPeer::QUERY_ID, $query->getId());
         $statement = $connection->prepareStatement($sql);
         $resultset = $statement->executeQuery();
         $resultset->next();
         $std = $resultset->getString('standard_deviation');
         $sql = "SELECT AVG(%s) as mean_of_all FROM %s where %s=%s";
         $sql = sprintf($sql, QueryResultPeer::RESULT_SIZE, QueryResultPeer::TABLE_NAME, QueryResultPeer::QUERY_ID, $query->getId());
         $statement = $connection->prepareStatement($sql);
         $resultset = $statement->executeQuery();
         $resultset->next();
         $mean = $resultset->getString('mean_of_all');
         $query->setStandardDeviation($std / $mean);
         logline(sprintf('Average stdev for query %s is %s.', $query->getQuery(), $query->getStandardDeviation()));
         $query->save();
         //logLine(sprintf("Standart deviation for %s is %s.", $query->getQuery(), $deviation));
     }
     logline(sprintf("Finished processing."));
     $stop_watch->end();
     logline(sprintf('Execution time: %s seconds.', $stop_watch->getTime()));
     logline(sprintf('!!!!!CAN RUN %s TIMES A DAY!!!!!', 24 * 60 * 60 / ($stop_watch->getTime() == 0 ? 1 : $stop_watch->getTime())));
 }
 protected function execute($arguments = array(), $options = array())
 {
     $stop_watch = new StopWatch();
     $stop_watch->start();
     logline('Started processing.');
     $searchEngine = new GoogleHitFetcher();
     $databaseManager = new sfDatabaseManager($this->configuration);
     $queries = QueryPeer::doSelect(new Criteria());
     logline(sprintf("There are %s queries to process.", sizeof($queries)));
     foreach ($queries as $query) {
         $qr = new QueryResultBulk();
         $qr->setQuery($query);
         $result_size = $searchEngine->fetch($query->getQuery());
         $qr->setResultSize($result_size);
         logline(sprintf("Found %s results for %s.", $result_size, $query->getQuery()));
         $qr->save();
     }
     logline(sprintf("Finished processing."));
     $stop_watch->end();
     logline(sprintf('Execution time: %s seconds.', $stop_watch->getTime()));
     logline(sprintf('!!!!!CAN RUN %s TIMES A DAY!!!!!', 24 * 60 * 60 / $stop_watch->getTime()));
 }
Example #5
0
 public function GetLayout(Date $date, $resourceId)
 {
     try {
         $hideBlocked = Configuration::Instance()->GetSectionKey(ConfigSection::SCHEDULE, ConfigKeys::SCHEDULE_HIDE_BLOCKED_PERIODS, new BooleanConverter());
         $sw = new StopWatch();
         $sw->Start();
         $items = $this->_reservationListing->OnDateForResource($date, $resourceId);
         $sw->Record('listing');
         $list = new ScheduleReservationList($items, $this->_scheduleLayout, $date, $hideBlocked);
         $slots = $list->BuildSlots();
         $sw->Record('slots');
         $sw->Stop();
         Log::Debug('DailyLayout::GetLayout - For resourceId %s on date %s, took %s seconds to get reservation listing, %s to build the slots, %s total seconds for %s reservations. Memory consumed=%sMB', $resourceId, $date->ToString(), $sw->GetRecordSeconds('listing'), $sw->TimeBetween('slots', 'listing'), $sw->GetTotalSeconds(), count($items), round(memory_get_usage() / 1048576, 2));
         return $slots;
     } catch (Exception $ex) {
         Log::Error('Error getting layout on date %s for resourceId %s. Exception=%s', $date->ToString(), $resourceId, $ex);
         throw $ex;
     }
 }
Example #6
0
require_once ROOT_DIR . 'tests/data/namespace.php';
require_once ROOT_DIR . 'tests/fakes/namespace.php';
require_once ROOT_DIR . 'tests/TestBase.php';
$tests = array('Domain/Reservation/ReservationViewRepositoryTests.php', 'Domain/Reservation/AdminEmailNotificationTests.php', 'Domain/Reservation/OwnerEmailNotificationTests.php', 'Domain/Reservation/ReservationDateTimeRuleTests.php', 'Domain/PermissionValidationRuleTests.php', 'Domain/ResourceAvailabilityRuleTests.php', 'Domain/AddReservationValidationServiceTests.php', 'PresenterTests/EditReservationPresenterTests.php', 'PresenterTests/ReservationSavePresenterTests.php', 'Domain/RepeatOptionsTests.php', 'Domain/ReservationTests.php', 'Domain/UserRepositoryTests.php', 'Domain/ReservationRepositoryTests.php', 'PresenterTests/NewReservationPresenterTests.php', 'PresenterTests/ReservationInitializationTests.php', 'PresenterTests/NewReservationPreconditionServiceTests.php', 'ScheduleUserRepositoryTests.php', 'ResourcePermissionStoreTests.php', 'PermissionServiceTests.php', 'DateTests.php', 'ReservationListingTests.php', 'ScheduleLayoutTests.php', 'DailyLayoutTests.php', 'SchedulePresenterTests.php', 'ReservationServiceTests.php', 'ScheduleReservationListTests.php', 'ResourceRepositoryTestsitoryTests.php', 'SchedulesTests.php', 'AnnouncementRepositoryTeststoryTests.php', 'AnnouncementPresenterTests.php', 'PluginManagerTests.php', 'ConfigTests.php', 'ActiveDirectoryTests.php', 'RegisterPresenterTests.php', 'ValidatorTests.php', 'PasswordMigrationTests.php', 'ResourcesTests.php', 'LoginPresenterTests.php', 'DatabaseTests.php', 'DatabaseCommandTests.php', 'AuthorizationTests.php', 'PasswordEncryptionTests.php', 'RegistrationTests.php', 'SmartyControlTests.php');
/*
$tests = array(
'SchedulePresenterTests.php',
'ResourceRepositoryTests.phpyTests.php',
'DateTests.php',
'ScheduleReservationListTests.php');
*/
$passed = true;
$totalRun = 0;
$totalPassed = 0;
$totalFailed = 0;
$totalTimer = new StopWatch();
$totalTimer->Start();
$suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework');
for ($i = 0; $i < count($tests); $i++) {
    require_once $tests[$i];
    $fileWithDir = explode('/', $tests[$i]);
    $fileName = $tests[$i];
    if (count($fileWithDir) > 1) {
        $fileName = $fileWithDir[count($fileWithDir) - 1];
    }
    $name_parts = explode('.', $fileName);
    $name = $name_parts[0];
    //$suite->addTestFile($tests[$i]);
    $suite->addTestSuite($name);
}
PHPUnit_TextUI_TestRunner::run($suite);
Example #7
0
 public static function delete($command)
 {
     array_shift($command);
     array_shift($command);
     $cmd_string = implode(':', $command);
     if (preg_match_all("/^(project|app)[:]([a-zA-z][a-zA-z0-9]+)\$/", $cmd_string, $regex_output)) {
         $type = $regex_output[1][0];
         $name = $regex_output[2][0];
         switch ($type) {
             case 'project':
                 $dir = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'dist' . DIRECTORY_SEPARATOR . $name;
                 if (file_exists($dir)) {
                     $chk = true;
                     $confirm = "Are you sure you want to " . Color::RED . "delete" . Color::RESET . " `{$name}` [no/yes]?" . Color::RESET . ': ';
                     fwrite(STDOUT, "");
                     fwrite(STDOUT, $confirm);
                     while ($chk) {
                         $handle = fopen("php://stdin", "r");
                         $line = fgets($handle);
                         if (trim($line) != 'yes' and trim($line) != 'no') {
                             fwrite(STDOUT, "");
                             fwrite(STDOUT, "Just type '" . Color::BOLD_GREEN . "yes'" . Color::RESET . " or '" . Color::BOLD_GREEN . "no'" . Color::RESET . PHP_EOL);
                             fwrite(STDOUT, $confirm);
                         } else {
                             $chk = false;
                         }
                     }
                     if (trim($line) == 'no') {
                         fwrite(STDOUT, "");
                         fwrite(STDOUT, '[ABORTED]: ' . Color::BOLD_UNDERLINE . "Nothing is deleted." . Color::RESET . PHP_EOL . PHP_EOL);
                     } else {
                         self::$i = 0;
                         self::$allfiles = self::count_files($dir . '/');
                         StopWatch::start();
                         self::rrmdir($dir);
                         $seconds = round(StopWatch::elapsed(), 4);
                         fwrite(STDERR, "");
                         fwrite(STDERR, PHP_EOL);
                         fwrite(STDOUT, "");
                         fwrite(STDOUT, Color::BOLD_GREEN . '[SUCCESS]: Project deleted.' . Color::RESET . PHP_EOL);
                         fwrite(STDOUT, Drawing::SUCCESS_BOX('Stirlingframe->Delelte:', "# Project `{$name}` has been delete.", "# " . self::$allfiles . " files have been removed in " . $seconds . "s."));
                         fwrite(STDOUT, PHP_EOL);
                     }
                 } else {
                     fwrite(STDOUT, "");
                     $header = 'Stirlingframe delete error:';
                     $desc = '# Project `' . $name . '` not exist';
                     fwrite(STDOUT, Color::BOLD_RED . '[ERROR]: Can\'t delete project.' . Color::RESET . PHP_EOL);
                     fwrite(STDOUT, Drawing::ERROR_BOX($header, $desc));
                     fwrite(STDOUT, PHP_EOL);
                 }
                 break;
             case 'app':
                 fwrite(STDOUT, '$create ' . $type . ' ' . $name . PHP_EOL);
                 break;
         }
     } else {
         $msg = Color::CYAN . '$' . Color::RESET . ' delete [project|app] [name]               ';
         fwrite(STDOUT, "");
         fwrite(STDOUT, Color::BOLD_RED . '[ERROR]: Invalid command.' . Color::RESET . PHP_EOL);
         fwrite(STDOUT, Drawing::ERROR_BOX('Stirlingframe create error:', '# Invalid parameters: command should be', $msg));
         fwrite(STDOUT, PHP_EOL);
     }
 }
 private function IndexLayout()
 {
     $sw = StopWatch::StartNew();
     if (!LayoutIndexCache::Contains($this->_layoutDateStart)) {
         LayoutIndexCache::Add($this->_layoutDateStart, $this->_layoutItems, $this->_layoutDateStart, $this->_layoutDateEnd);
     }
     $cachedIndex = LayoutIndexCache::Get($this->_layoutDateStart);
     $this->_firstLayoutTime = $cachedIndex->GetFirstLayoutTime();
     $this->_lastLayoutTime = $cachedIndex->GetLastLayoutTime();
     $this->_layoutByStartTime = $cachedIndex->LayoutByStartTime();
     $this->_layoutIndexByEndTime = $cachedIndex->LayoutIndexByEndTime();
     $sw->Stop();
     //		Log::Debug('IndexLayout() took %s seconds', $sw->GetTotalSeconds());
 }
Example #9
0
 *   page (unless full license is purchase) and in the header of each script source file.
 *
 *   You should have received a full copy of the LICENSE AGREEMENT along with
 *   Codefuture Image Hosting Script. If not, see http://codefuture.co.uk/projects/imagehost/license/.
 *
 *
 *   ABOUT THIS PAGE -----
 *   Used For:     Check images
 *   Last edited:  19/12/2012
 *
 *************************************************************************************************************/

	ini_set("max_execution_time", "600");
	ini_set("max_input_time", "600");

	$stopwatch = new StopWatch();
	$autouse = 0;

	if(!checklogin()){
		header('Location: ../index.php');
		exit();
	}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title>Image Folder Check</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="description" content="" />
	<meta name="keywords" content="" />
Example #10
0
 /**
  * @return StopWatch
  */
 public static function StartNew()
 {
     $sw = new StopWatch();
     $sw->Start();
     return $sw;
 }
 function Start()
 {
     self::$start_time = microtime(true);
 }
            // Set default page
            case 'page_default':
                Editor::SetDefaultPage($_POST['page_id']);
                exit;
            default:
                exit;
        }
    } else {
        print Editor::GetPage($pageid);
    }
} else {
    $pagename = isset($_GET['page']) ? $_GET['page'] : 'index';
    print Content::GetPage($pageid);
}
StopWatch::Stop();
print "<br/><br/><h1>Execution took " . StopWatch::GetTotal() . "ms with " . Database::$queries . " queries</h1>";
//print "<br/><br/>";
/*
    if ($_GET['action'] == "login") {
        if (!$core->Account->m_loggedin) {
            if ($core->Account->Login($_GET['username'], $_GET['password'], false))
                print "Login successful!<br/>";
            else
                print "Login failed<br/>";
        } else {
            print "Your'e already logged in!<br/>";
        }
    }
    
    if ($_GET['action'] == "logout") {
        if ($core->Account->m_loggedin) {
 function get_html($p_coo_product, $p_current_category_id = 0)
 {
     $t_html_output = '';
     $xtPrice = new xtcPrice($_SESSION['currency'], $_SESSION['customers_status']['customers_status_id']);
     $main = new main();
     $group_check = '';
     // xs:booster start (v1.041)
     $xsb_tx = array();
     if (@is_array($_SESSION['xtb0']['tx'])) {
         foreach ($_SESSION['xtb0']['tx'] as $tx) {
             if ($tx['products_id'] == $p_coo_product->data['products_id']) {
                 $xsb_tx = $tx;
                 break;
             }
         }
     }
     // xs:booster end
     if (!is_object($p_coo_product) || !$p_coo_product->isProduct()) {
         // product not found in database
         $error = TEXT_PRODUCT_NOT_FOUND;
         include DIR_WS_MODULES . FILENAME_ERROR_HANDLER;
         $t_html_output = $main_content;
     } else {
         if (ACTIVATE_NAVIGATOR == 'true') {
             $coo_product_navigator = MainFactory::create_object('ProductNavigatorContentView');
             $t_view_html = $coo_product_navigator->get_html($p_coo_product, $p_current_category_id);
             $this->set_content_data('PRODUCT_NAVIGATOR', $t_view_html);
         }
         xtc_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . $p_coo_product->data['products_id'] . "' and language_id = '" . $_SESSION['languages_id'] . "'");
         $products_price = $xtPrice->xtcGetPrice($p_coo_product->data['products_id'], $format = true, 1, $p_coo_product->data['products_tax_class_id'], $p_coo_product->data['products_price'], 1);
         // check if customer is allowed to add to cart
         // BOF GM_MOD:
         if ($_SESSION['customers_status']['customers_status_show_price'] != '0' && $xtPrice->gm_check_price_status($p_coo_product->data['products_id']) == 0) {
             // fsk18
             if ($_SESSION['customers_status']['customers_fsk18'] == '1') {
                 if ($p_coo_product->data['products_fsk18'] == '0') {
                     // BOF GM_MOD:
                     $this->set_content_data('ADD_QTY', xtc_draw_input_field('products_qty', gm_convert_qty($p_coo_product->data['gm_min_order'], false), 'id="gm_attr_calc_qty"') . ' ' . xtc_draw_hidden_field('products_id', $p_coo_product->data['products_id'], 'id="gm_products_id"'));
                     $t_quantity = gm_convert_qty($p_coo_product->data['gm_min_order'], false);
                     $t_disabled_quantity = 0;
                     if (@$xsb_tx['XTB_ALLOW_USER_CHQTY'] == 'true' || $xsb_tx['products_id'] != $p_coo_product->data['products_id']) {
                         $this->set_content_data('ADD_QTY', xtc_draw_input_field('products_qty', str_replace('.', ',', (double) $p_coo_product->data['gm_min_order']), 'id="gm_attr_calc_qty"') . ' ' . xtc_draw_hidden_field('products_id', $p_coo_product->data['products_id'], 'id="gm_products_id"'));
                     } else {
                         $this->set_content_data('ADD_QTY', xtc_draw_input_field('products_qty', '1', 'disabled="disabled" style="background-color:gray;"') . ' ' . xtc_draw_hidden_field('products_id', $p_coo_product->data['products_id'], 'id="gm_attr_calc_qty"'));
                         $t_quantity = 1;
                         $t_disabled_quantity = 1;
                     }
                     $this->set_content_data('QUANTITY', $t_quantity);
                     $this->set_content_data('DISABLED_QUANTITY', $t_disabled_quantity);
                     $this->set_content_data('ADD_CART_BUTTON', xtc_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, 'id="cart_button"'));
                     if (gm_get_conf('GM_SHOW_WISHLIST') == 'true') {
                         $this->set_content_data('ADD_WISHLIST_BUTTON', '<a href="javascript:submit_to_wishlist()" id="gm_wishlist_link">' . xtc_image_button('button_in_wishlist.gif', NC_WISHLIST) . '</a>');
                     }
                 } else {
                     $this->set_content_data('GM_PID', xtc_draw_hidden_field('products_id', $p_coo_product->data['products_id'], 'id="gm_products_id"'));
                 }
             } else {
                 // BOF GM_MOD:
                 $this->set_content_data('ADD_QTY', xtc_draw_input_field('products_qty', gm_convert_qty($p_coo_product->data['gm_min_order'], false), 'id="gm_attr_calc_qty"') . ' ' . xtc_draw_hidden_field('products_id', $p_coo_product->data['products_id'], 'id="gm_products_id"'));
                 $t_quantity = gm_convert_qty($p_coo_product->data['gm_min_order'], false);
                 $t_disabled_quantity = 0;
                 if (@$xsb_tx['XTB_ALLOW_USER_CHQTY'] == 'true' || $xsb_tx['products_id'] != $p_coo_product->data['products_id']) {
                     $this->set_content_data('ADD_QTY', xtc_draw_input_field('products_qty', str_replace('.', ',', (double) $p_coo_product->data['gm_min_order']), 'id="gm_attr_calc_qty"') . ' ' . xtc_draw_hidden_field('products_id', $p_coo_product->data['products_id'], 'id="gm_products_id"'));
                 } else {
                     $this->set_content_data('ADD_QTY', xtc_draw_input_field('products_qty', '1', 'disabled="disabled" style="background-color:gray;"') . ' ' . xtc_draw_hidden_field('products_id', $p_coo_product->data['products_id'], 'id="gm_attr_calc_qty"'));
                     $t_quantity = 1;
                     $t_disabled_quantity = 1;
                 }
                 $this->set_content_data('QUANTITY', $t_quantity);
                 $this->set_content_data('DISABLED_QUANTITY', $t_disabled_quantity);
                 $this->set_content_data('ADD_CART_BUTTON', xtc_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, 'id="cart_button"'));
                 if (gm_get_conf('GM_SHOW_WISH_LIST') == 'true') {
                     $this->set_content_data('ADD_WISHLIST_BUTTON', '<a href="javascript:submit_to_wishlist()">' . xtc_image_button('button_in_wishlist.gif', NC_WISHLIST) . '</a>');
                 }
             }
         } elseif ($xtPrice->gm_check_price_status($p_coo_product->data['products_id']) > 0 || $_SESSION['customers_status']['customers_status_show_price'] == '0') {
             $this->set_content_data('GM_PID', xtc_draw_hidden_field('products_id', $p_coo_product->data['products_id'], 'id="gm_products_id"'));
         }
         if ($p_coo_product->data['products_fsk18'] == '1') {
             $this->set_content_data('PRODUCTS_FSK18', 'true');
         }
         // BOF GM_MOD:
         if (ACTIVATE_SHIPPING_STATUS == 'true' && $xtPrice->gm_check_price_status($p_coo_product->data['products_id']) == 0) {
             $this->set_content_data('SHIPPING_NAME', $main->getShippingStatusName($p_coo_product->data['products_shippingtime']));
             $this->set_content_data('SHIPPING_IMAGE', $main->getShippingStatusImage($p_coo_product->data['products_shippingtime']));
         }
         // BOF_GM_MOD:
         $this->set_content_data('FORM_ACTION', xtc_draw_form('cart_quantity', xtc_href_link(FILENAME_PRODUCT_INFO, xtc_get_all_get_params(array('action')) . 'action=add_product'), 'post', 'name="cart_quantity" onsubmit="gm_qty_check = new GMOrderQuantityChecker(); return gm_qty_check.check();"'));
         $this->set_content_data('FORM_ACTION_URL', xtc_href_link(FILENAME_PRODUCT_INFO, xtc_get_all_get_params(array('action')) . 'action=add_product'));
         $this->set_content_data('FORM_ID', 'cart_quantity');
         $this->set_content_data('FORM_NAME', 'cart_quantity');
         $this->set_content_data('FORM_METHOD', 'post');
         // BOF GM_MOD GX-Customizer
         $coo_gm_gprint_product_manager = new GMGPrintProductManager();
         if ($coo_gm_gprint_product_manager->get_surfaces_groups_id($p_coo_product->data['products_id']) !== false) {
             $coo_gm_gprint_configuration = new GMGPrintConfiguration($_SESSION['languages_id']);
             $this->set_content_data('GM_GPRINT_SHOW_PRODUCTS_DESCRIPTION', $coo_gm_gprint_configuration->get_configuration('SHOW_PRODUCTS_DESCRIPTION'));
             $this->set_content_data('GM_GPRINT', 1);
         }
         // EOF GM_MOD GX-Customizer
         $this->set_content_data('FORM_END', '</form>');
         $this->set_content_data('PRODUCTS_PRICE', $products_price['formated']);
         if ($p_coo_product->data['products_vpe_status'] == 1 && $p_coo_product->data['products_vpe_value'] != 0.0 && $products_price['plain'] > 0) {
             $this->set_content_data('PRODUCTS_VPE', $xtPrice->xtcFormat($products_price['plain'] * (1 / $p_coo_product->data['products_vpe_value']), true) . TXT_PER . xtc_get_vpe_name($p_coo_product->data['products_vpe']));
         }
         $this->set_content_data('PRODUCTS_ID', $p_coo_product->data['products_id']);
         $this->set_content_data('PRODUCTS_NAME', $p_coo_product->data['products_name']);
         // BOF GM_MOD:
         if ($_SESSION['customers_status']['customers_status_show_price'] != 0 && ($xtPrice->gm_check_price_status($p_coo_product->data['products_id']) == 0 || $xtPrice->gm_check_price_status($p_coo_product->data['products_id']) == 2 && $p_coo_product->data['products_price'] > 0)) {
             // price incl tax
             $tax_rate = $xtPrice->TAX[$p_coo_product->data['products_tax_class_id']];
             $tax_info = $main->getTaxInfo($tax_rate);
             $this->set_content_data('PRODUCTS_TAX_INFO', $tax_info);
             // BOF GM_MOD:
             if ($xtPrice->gm_check_price_status($p_coo_product->data['products_id']) == 0) {
                 $this->set_content_data('PRODUCTS_SHIPPING_LINK', $main->getShippingLink(true));
             }
         }
         // BOF GM_MOD
         if (gm_get_conf('GM_TELL_A_FRIEND') == 'true') {
             $this->set_content_data('GM_TELL_A_FRIEND', 1);
         }
         if ($p_coo_product->data['gm_show_price_offer'] == 1 && $_SESSION['customers_status']['customers_status_show_price'] != '0' && $xtPrice->gm_check_price_status($p_coo_product->data['products_id']) == 0) {
             $this->set_content_data('GM_PRICE_OFFER', 1);
         }
         if ((double) $p_coo_product->data['gm_min_order'] != 1) {
             $this->set_content_data('GM_MIN_ORDER', gm_convert_qty($p_coo_product->data['gm_min_order'], false));
         }
         if ((double) $p_coo_product->data['gm_graduated_qty'] != 1) {
             $this->set_content_data('GM_GRADUATED_QTY', gm_convert_qty($p_coo_product->data['gm_graduated_qty'], false));
         }
         // EOF GM_MOD
         $this->set_content_data('PRODUCTS_MODEL', $p_coo_product->data['products_model']);
         $this->set_content_data('PRODUCTS_EAN', $p_coo_product->data['products_ean']);
         if ($p_coo_product->data['gm_show_qty_info'] == 1) {
             $this->set_content_data('PRODUCTS_QUANTITY', gm_convert_qty(xtc_get_products_stock($p_coo_product->data['products_id']), false));
             if ($p_coo_product->data['quantity_unit_id'] > 0) {
                 $this->set_content_data('PRODUCTS_QUANTITY_UNIT', $p_coo_product->data['unit_name']);
             }
         }
         // BOF GM_MOD
         if ($p_coo_product->data['gm_show_weight'] == '1') {
             $this->set_content_data('SHOW_PRODUCTS_WEIGHT', 1);
             $this->set_content_data('PRODUCTS_WEIGHT', gm_prepare_number($p_coo_product->data['products_weight'], $xtPrice->currencies[$xtPrice->actualCurr]['decimal_point']));
         }
         // EOF GM_MOD
         $this->set_content_data('PRODUCTS_STATUS', $p_coo_product->data['products_status']);
         $this->set_content_data('PRODUCTS_ORDERED', $p_coo_product->data['products_ordered']);
         $this->set_content_data('PRODUCTS_PRINT', '<img src="templates/' . CURRENT_TEMPLATE . '/buttons/' . $_SESSION['language'] . '/print.gif"  style="cursor:hand;" onclick="javascript:window.open(\'' . xtc_href_link(FILENAME_PRINT_PRODUCT_INFO, 'products_id=' . $p_coo_product->data['products_id']) . '\', \'popup\', \'toolbar=0, width=640, height=600\')" alt="" />');
         //GM_MOD:
         $gmTabTokenizer = MainFactory::create_object('GMTabTokenizer', array(stripslashes($p_coo_product->data['products_description'])));
         $gm_products_descrition = $gmTabTokenizer->get_prepared_output();
         $this->set_content_data('PRODUCTS_DESCRIPTION', $gm_products_descrition);
         $t_gm_images_data = array();
         $t_thumbnails_array = array();
         $t_main_max_width = 369;
         $t_main_max_height = 279;
         $t_thumbnail_max_width = 86;
         $t_thumbnail_max_height = 86;
         // BOF GM_MOD
         require_once DIR_FS_CATALOG . 'gm/classes/GMGMotion.php';
         $coo_gm_gmotion = new GMGMotion();
         $this->set_content_data('GMOTION', $coo_gm_gmotion->check_status($p_coo_product->data['products_id']));
         // EOF GM_MOD
         if (isset($xsb_tx['XTB_REDIRECT_USER_TO']) && $xsb_tx['products_id'] == $p_coo_product->data['products_id']) {
             $this->set_content_data('XTB_REDIRECT_USER_TO', $xsb_tx['XTB_REDIRECT_USER_TO']);
         }
         // BOF GM_MOD
         if ($p_coo_product->data['products_image'] != '' && $p_coo_product->data['gm_show_image'] == '1') {
             $t_info_image_size_array = @getimagesize(DIR_WS_INFO_IMAGES . $p_coo_product->data['products_image']);
             $t_thumbnail_image_size_array = @getimagesize(DIR_WS_IMAGES . 'product_images/gallery_images/' . $p_coo_product->data['products_image']);
             $t_main_padding_left = 0;
             $t_main_padding_top = 0;
             if (isset($t_info_image_size_array[0]) && $t_info_image_size_array[0] < $t_main_max_width) {
                 $t_main_padding_left = round(($t_main_max_width - $t_info_image_size_array[0]) / 2);
             }
             if (isset($t_info_image_size_array[1]) && $t_info_image_size_array[1] < $t_main_max_height) {
                 $t_main_padding_top = round(($t_main_max_height - $t_info_image_size_array[1]) / 2);
             }
             $t_zoom_image = DIR_WS_POPUP_IMAGES . $p_coo_product->data['products_image'];
             if (file_exists(DIR_WS_ORIGINAL_IMAGES . $p_coo_product->data['products_image'])) {
                 $t_zoom_image = DIR_WS_ORIGINAL_IMAGES . $p_coo_product->data['products_image'];
             }
             $t_gm_images_data[] = array('IMAGE' => DIR_WS_INFO_IMAGES . $p_coo_product->data['products_image'], 'IMAGE_ALT' => $p_coo_product->data['gm_alt_text'], 'IMAGE_NR' => 0, 'ZOOM_IMAGE' => $t_zoom_image, 'PRODUCTS_NAME' => $p_coo_product->data['products_name'], 'PADDING_LEFT' => $t_main_padding_left, 'PADDING_TOP' => $t_main_padding_top, 'WIDTH' => $t_info_image_size_array[0], 'HEIGHT' => $t_info_image_size_array[1]);
             $t_thumbnail_padding_left = 0;
             $t_thumbnail_padding_top = 0;
             if (isset($t_thumbnail_image_size_array[0]) && $t_thumbnail_image_size_array[0] < $t_thumbnail_max_width) {
                 $t_thumbnail_padding_left = round(($t_thumbnail_max_width - $t_thumbnail_image_size_array[0]) / 2);
             }
             if (isset($t_thumbnail_image_size_array[1]) && $t_thumbnail_image_size_array[1] < $t_thumbnail_max_height) {
                 $t_thumbnail_padding_top = round(($t_thumbnail_max_height - $t_thumbnail_image_size_array[1]) / 2);
             }
             $t_thumbnails_array[] = array('IMAGE' => DIR_WS_IMAGES . 'product_images/gallery_images/' . $p_coo_product->data['products_image'], 'IMAGE_ALT' => $p_coo_product->data['gm_alt_text'], 'IMAGE_NR' => 0, 'ZOOM_IMAGE' => $t_zoom_image, 'INFO_IMAGE' => DIR_WS_INFO_IMAGES . $p_coo_product->data['products_image'], 'PRODUCTS_NAME' => $p_coo_product->data['products_name'], 'PADDING_LEFT' => $t_thumbnail_padding_left, 'PADDING_TOP' => $t_thumbnail_padding_top);
         }
         $t_gm_images = xtc_get_products_mo_images($p_coo_product->data['products_id']);
         if ($t_gm_images != false) {
             $coo_gm_alt_form = MainFactory::create_object('GMAltText');
             foreach ($t_gm_images as $t_gm_image) {
                 $t_info_image_size_array = @getimagesize(DIR_WS_INFO_IMAGES . $t_gm_image['image_name']);
                 $t_thumbnail_image_size_array = @getimagesize(DIR_WS_IMAGES . 'product_images/gallery_images/' . $t_gm_image['image_name']);
                 $t_main_padding_left = 0;
                 $t_main_padding_top = 0;
                 if (isset($t_info_image_size_array[0]) && $t_info_image_size_array[0] < $t_main_max_width) {
                     $t_main_padding_left = round(($t_main_max_width - $t_info_image_size_array[0]) / 2);
                 }
                 if (isset($t_info_image_size_array[1]) && $t_info_image_size_array[1] < $t_main_max_height) {
                     $t_main_padding_top = round(($t_main_max_height - $t_info_image_size_array[1]) / 2);
                 }
                 $t_zoom_image = DIR_WS_POPUP_IMAGES . $t_gm_image['image_name'];
                 if (file_exists(DIR_WS_ORIGINAL_IMAGES . $t_gm_image['image_name'])) {
                     $t_zoom_image = DIR_WS_ORIGINAL_IMAGES . $t_gm_image['image_name'];
                 }
                 $t_gm_images_data[] = array('IMAGE' => DIR_WS_INFO_IMAGES . $t_gm_image['image_name'], 'IMAGE_ALT' => $coo_gm_alt_form->get_alt($t_gm_image["image_id"], $t_gm_image['image_nr'], $p_coo_product->data['products_id']), 'IMAGE_NR' => $t_gm_image['image_nr'], 'ZOOM_IMAGE' => $t_zoom_image, 'PRODUCTS_NAME' => $p_coo_product->data['products_name'], 'PADDING_LEFT' => $t_main_padding_left, 'PADDING_TOP' => $t_main_padding_top, 'IMAGE_POPUP_URL' => DIR_WS_POPUP_IMAGES . $t_gm_image['image_name']);
                 $t_thumbnail_padding_left = 0;
                 $t_thumbnail_padding_top = 0;
                 if (isset($t_thumbnail_image_size_array[0]) && $t_thumbnail_image_size_array[0] < $t_thumbnail_max_width) {
                     $t_thumbnail_padding_left = round(($t_thumbnail_max_width - $t_thumbnail_image_size_array[0]) / 2);
                 }
                 if (isset($t_thumbnail_image_size_array[1]) && $t_thumbnail_image_size_array[1] < $t_thumbnail_max_height) {
                     $t_thumbnail_padding_top = round(($t_thumbnail_max_height - $t_thumbnail_image_size_array[1]) / 2);
                 }
                 $t_thumbnails_array[] = array('IMAGE' => DIR_WS_IMAGES . 'product_images/gallery_images/' . $t_gm_image['image_name'], 'IMAGE_ALT' => $coo_gm_alt_form->get_alt($t_gm_image["image_id"], $t_gm_image['image_nr'], $p_coo_product->data['products_id']), 'IMAGE_NR' => $t_gm_image['image_nr'], 'ZOOM_IMAGE' => $t_zoom_image, 'INFO_IMAGE' => DIR_WS_INFO_IMAGES . $t_gm_image['image_name'], 'PRODUCTS_NAME' => $p_coo_product->data['products_name'], 'PADDING_LEFT' => $t_thumbnail_padding_left, 'PADDING_TOP' => $t_thumbnail_padding_top);
             }
         }
         $this->set_content_data('images', $t_gm_images_data);
         $this->set_content_data('thumbnails', $t_thumbnails_array);
         // EOF GM_MOD
         $discount = 0.0;
         if ($_SESSION['customers_status']['customers_status_discount'] != '0.00') {
             // BOF GM_MOD:
             $discount = $_SESSION['customers_status']['customers_status_discount'];
             if ($p_coo_product->data['products_discount_allowed'] < $_SESSION['customers_status']['customers_status_discount']) {
                 $discount = $p_coo_product->data['products_discount_allowed'];
             }
             if ($discount != '0.00') {
                 $this->set_content_data('PRODUCTS_DISCOUNT', $discount . '%');
             }
         }
         // BOF GM_MOD
         if (PRODUCT_IMAGE_INFO_WIDTH < 190 - 16) {
             $this->set_content_data('MIN_IMAGE_WIDTH', 188);
             $this->set_content_data('MIN_INFO_BOX_WIDTH', 156 - 10);
             $this->set_content_data('MARGIN_LEFT', 188 + 10);
         } else {
             $this->set_content_data('MIN_IMAGE_WIDTH', PRODUCT_IMAGE_INFO_WIDTH + 16);
             $this->set_content_data('MIN_INFO_BOX_WIDTH', PRODUCT_IMAGE_INFO_WIDTH + 16 - 32 - 10);
             $this->set_content_data('MARGIN_LEFT', PRODUCT_IMAGE_INFO_WIDTH + 16 + 10);
         }
         // EOF GM_MOD
         $coo_product_attributes = MainFactory::create_object('ProductAttributesContentView', array($p_coo_product->data['options_template']));
         $t_view_html = $coo_product_attributes->get_html($p_coo_product);
         $this->set_content_data('MODULE_product_options', $t_view_html);
         $coo_product_reviews = MainFactory::create_object('ProductReviewsContentView');
         $t_view_html = $coo_product_reviews->get_html($p_coo_product);
         $this->set_content_data('MODULE_products_reviews', $t_view_html);
         if (xtc_not_null($p_coo_product->data['products_url'])) {
             $this->set_content_data('PRODUCTS_URL', sprintf(TEXT_MORE_INFORMATION, xtc_href_link(FILENAME_REDIRECT, 'action=product&id=' . $p_coo_product->data['products_id'], 'NONSSL', true)));
         }
         if ($p_coo_product->data['products_date_available'] > date('Y-m-d H:i:s')) {
             $this->set_content_data('PRODUCTS_DATE_AVIABLE', sprintf(TEXT_DATE_AVAILABLE, xtc_date_long($p_coo_product->data['products_date_available'])));
         } else {
             // BOF GM_MOD:
             if ($p_coo_product->data['products_date_added'] != '0000-00-00 00:00:00' && $p_coo_product->data['gm_show_date_added'] == 1) {
                 $this->set_content_data('PRODUCTS_ADDED', sprintf(TEXT_DATE_ADDED, xtc_date_long($p_coo_product->data['products_date_added'])));
             }
         }
         $coo_product_media = MainFactory::create_object('ProductMediaContentView');
         $t_view_html = $coo_product_media->get_html($p_coo_product->data['products_id'], $_SESSION['languages_id']);
         $this->set_content_data('MODULE_products_media', $t_view_html);
         $coo_graduated_prices = MainFactory::create_object('GraduatedPricesContentView');
         $t_view_html = $coo_graduated_prices->get_html($p_coo_product);
         $this->set_content_data('MODULE_graduated_price', $t_view_html);
         $coo_also_purchased = MainFactory::create_object('AlsoPurchasedContentView');
         $t_view_html = $coo_also_purchased->get_html($p_coo_product);
         $this->set_content_data('MODULE_also_purchased', $t_view_html);
         $coo_cross_selling = MainFactory::create_object('CrossSellingContentView', array('cross_selling'));
         $t_view_html = $coo_cross_selling->get_html($p_coo_product);
         $this->set_content_data('MODULE_cross_selling', $t_view_html);
         $coo_reverse_cross_selling = MainFactory::create_object('CrossSellingContentView', array('reverse_cross_selling'));
         $t_view_html = $coo_reverse_cross_selling->get_html($p_coo_product);
         $this->set_content_data('MODULE_reverse_cross_selling', $t_view_html);
         $i = count($_SESSION['tracking']['products_history']);
         if ($i > 6) {
             array_shift($_SESSION['tracking']['products_history']);
             $_SESSION['tracking']['products_history'][6] = $p_coo_product->data['products_id'];
             $_SESSION['tracking']['products_history'] = array_unique($_SESSION['tracking']['products_history']);
         } else {
             $_SESSION['tracking']['products_history'][$i] = $p_coo_product->data['products_id'];
             $_SESSION['tracking']['products_history'] = array_unique($_SESSION['tracking']['products_history']);
         }
         $coo_stop_watch = new StopWatch();
         $coo_stop_watch->start();
         $coo_properties_view = MainFactory::create_object('PropertiesView', array($_GET, $_POST));
         $t_properties_selection_form = $coo_properties_view->get_selection_form($p_coo_product->data['products_id'], $_SESSION['languages_id']);
         if (trim($t_properties_selection_form) != "") {
             if ($p_coo_product->data['gm_show_qty_info'] == 1) {
                 if ($p_coo_product->data['use_properties_combis_quantity'] == 0 && STOCK_CHECK == 'true' && ATTRIBUTES_STOCK_CHECK == 'true' || $p_coo_product->data['use_properties_combis_quantity'] == 2) {
                     $this->set_content_data('PRODUCTS_QUANTITY', '-');
                     $this->set_content_data('SHOW_PRODUCTS_QUANTITY', true);
                 } else {
                     if ($p_coo_product->data['use_properties_combis_quantity'] == 1) {
                         $this->set_content_data('SHOW_PRODUCTS_QUANTITY', true);
                     }
                 }
             }
             $this->set_content_data('SHOW_PRODUCTS_MODEL', true);
             if (APPEND_PROPERTIES_MODEL == "false" || trim($p_coo_product->data['products_model']) == '') {
                 $this->set_content_data('PRODUCTS_MODEL', '-');
             }
             if (ACTIVATE_SHIPPING_STATUS == 'true' && $xtPrice->gm_check_price_status($p_coo_product->data['products_id']) == 0 && $p_coo_product->data['use_properties_combis_shipping_time'] == 1) {
                 $this->set_content_data('SHOW_SHIPPING_TIME', true);
                 $this->set_content_data('SHIPPING_NAME', '');
                 $this->set_content_data('SHIPPING_IMAGE', 'admin/images/icons/gray.png');
             }
         }
         $this->set_content_data('properties_selection_form', $t_properties_selection_form);
         $coo_stop_watch->stop();
         //$coo_stop_watch->log_total_time('PropertiesView get_selection_form');
         // BOF GM_MOD
         $t_gm_show_wishlist = gm_get_conf('GM_SHOW_WISHLIST');
         if ($t_gm_show_wishlist == 'true') {
             $this->set_content_data('GM_SHOW_WISHLIST', 1);
         }
         $t_show_facebook = gm_get_conf('SHOW_FACEBOOK');
         if ($t_show_facebook == 'true') {
             $this->set_content_data('SHOW_FACEBOOK', 1);
         }
         $t_show_twitter = gm_get_conf('SHOW_TWITTER');
         if ($t_show_twitter == 'true') {
             $this->set_content_data('SHOW_TWITTER', 1);
         }
         $t_show_googleplus = gm_get_conf('SHOW_GOOGLEPLUS');
         if ($t_show_googleplus == 'true') {
             $this->set_content_data('SHOW_GOOGLEPLUS', 1);
         }
         $t_show_pinterest = gm_get_conf('SHOW_PINTEREST');
         if ($t_show_pinterest == 'true') {
             $this->set_content_data('SHOW_PINTEREST', 1);
         }
         $t_show_print = gm_get_conf('SHOW_PRINT');
         if ($t_show_print == 'true') {
             $this->set_content_data('SHOW_PRINT', 1);
         }
         $t_show_bookmarking = gm_get_conf('SHOW_BOOKMARKING');
         if ($t_show_bookmarking == 'true') {
             $this->set_content_data('SHOW_BOOKMARKING', 1);
         }
         // EOF GM_MOD
         // Bitcoin Payment - Commerce Coding - BEGIN
         $multiplier = 1;
         $digits = 8;
         switch (MODULE_PAYMENT_BITCOIN_UNITS) {
             case 'uBTC':
                 $multiplier *= 1000;
                 $digits -= 3;
             case 'mBTC':
                 $multiplier *= 1000;
                 $digits -= 3;
             case 'BTC':
                 $btcPrice = number_format($products_price['plain'] / MODULE_PAYMENT_BITCOIN_BTCEUR * $multiplier, $digits, '.', '');
                 $this->set_content_data('BITCOIN_PRICE', $btcPrice . ' ' . MODULE_PAYMENT_BITCOIN_UNITS);
         }
         // Bitcoin Payment - Commerce Coding - END
         include_once DIR_FS_DOCUMENT_ROOT . '/shopgate/plugins/gambiogx/system/views/product_info/ProductInfoContentView.inc.php';
         $t_html_output = $this->build_html();
     }
     return $t_html_output;
 }
Example #14
0
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Booked Scheduler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Booked Scheduler.  If not, see <http://www.gnu.org/licenses/>.
*/
define('ROOT_DIR', dirname(__FILE__) . '/../');
require_once ROOT_DIR . 'lib/Application/Reservation/namespace.php';
require_once ROOT_DIR . 'lib/Common/Helpers/namespace.php';
echo "<h1>Booked Scheduler Data Load</h1>";
$stopWatch = new StopWatch();
$stopWatch->Start();
$numberOfResources = 10;
$numberOfUsers = 1000;
$numberOfReservations = 5000;
$numberOfAccessories = 20;
$users = array();
$resources = array();
$db = ServiceLocator::GetDatabase();
// USERS
$db->Execute(new AdHocCommand("delete from users where fname ='load' and lname = 'test'"));
$userRepo = new UserRepository();
for ($i = 0; $i < $numberOfUsers; $i++) {
    $user = User::Create("load{$i}", "test{$i}", "email {$i}", "username {$i}", "en_us", "America/Chicago", "7b6aec38ff9b7650d64d0374194307bdde711425", "3b3dbb9b");
    $userId = $userRepo->Add($user);
    $users[] = $user;
 public static function startNew()
 {
     $watch = new StopWatch();
     $watch->start();
     return $watch;
 }
 protected function execute($arguments = array(), $options = array())
 {
     $frequencies = array('D' => 'Daily', 'W' => 'Weekly', 'M' => 'Monthly');
     $frequency = $arguments['frequency'];
     if (!array_key_exists($frequency, $frequencies)) {
         logline(sprintf('Invalid frequency %s use [D|W|M]', $frequency));
         exit;
     }
     sfLoader::loadHelpers('Partial', 'My');
     $context = sfContext::createInstance($this->configuration);
     $stop_watch = new StopWatch();
     $stop_watch->start();
     logline(sprintf('Started processing %s mails.', $frequencies[$frequency]));
     $databaseManager = new sfDatabaseManager($this->configuration);
     $c1 = new Criteria();
     $c1->addJoin(sfGuardUserPeer::ID, ReportPeer::USER_ID);
     $c1->add(ReportPeer::MAIL_FREQUENCY, $frequency);
     $c1->setDistinct();
     $users = sfGuardUserPeer::doSelect($c1);
     foreach ($users as $user) {
         $c = new Criteria();
         $c->add(ReportPeer::USER_ID, $user->getId());
         $c->add(ReportPeer::MAIL_FREQUENCY, $frequency);
         $reports = ReportPeer::doSelect($c);
         logline(sprintf("There are %s reports to process.", sizeof($reports)));
         $sfGuardUserProfile = $user->getsfGuardUserProfiles();
         $sfGuardUserProfile = $sfGuardUserProfile[0];
         $connection = new Swift_Connection_SMTP('mail.sis-nav.com', 25);
         $connection->setUsername('*****@*****.**');
         $connection->setPassword('gahve123');
         $mailer = new Swift($connection);
         $message = new Swift_Message(sprintf("Goole Volume - %s notifications.", $frequencies[$frequency]));
         $images = array();
         foreach ($reports as $report) {
             //                $rtn = ReportPeer::_getReportChart(
             //                $report, date('Y-m-d', strtotime(date('Ymd') . ' -1 months')),
             //                date('Y-m-d', strtotime(date('Y-m-d') . ' +1 days')),
             //                QueryResultPeer::FREQUENCY_DAY, new MailChartDecorator());
             $rtn = ReportPeer::_getReportChartt($report, new MailChartDecorator());
             $data = $rtn['values'];
             $line_chart = $rtn['chart'];
             $image_path = $local_url = sfConfig::get('app_web_images') . '/' . $line_chart->__toString();
             $images[$report->getTitle()] = new Swift_Message_Image(new Swift_File($image_path));
             $imageReferences = array();
             foreach ($images as $name => $image) {
                 $imageReferences[$name] = $message->attach($image);
             }
             $mailContext = array('data' => $data, 'full_name' => $sfGuardUserProfile->getFullName(), 'report' => $report, 'images' => $imageReferences);
         }
         try {
             $message->attach(new Swift_Message_Part(get_partial('mail/mailReportHtmlBody', $mailContext), 'text/html'));
             $message->attach(new Swift_Message_Part(get_partial('mail/mailReportTextBody', $mailContext), 'text/plain'));
             $mailer->send($message, $sfGuardUserProfile->getEmail(), '*****@*****.**');
             $mailer->disconnect();
         } catch (Exception $e) {
             logline(sprintf('Exception while sending email to %s about %s. %s', $sfGuardUserProfile->getEmail(), $report->getTitle(), $e));
             $mailer->disconnect();
         }
         logline(sprintf('Sent mail to %s.', $sfGuardUserProfile->getEmail()));
     }
     logline(sprintf("Finished processing."));
     $stop_watch->end();
     logline(sprintf('Execution time: %s seconds.', $stop_watch->getTime()));
     logline(sprintf('!!!!!CAN RUN %s TIMES A DAY!!!!!', 24 * 60 * 60 / ($stop_watch->getTime() == 0 ? 1 : $stop_watch->getTime())));
 }
Example #17
-1
 function do_post_testbasicphp_thing_v1($job, $resp)
 {
     $resp->status()->progress(10);
     $resp->status()->add_message("processing");
     # test SWIG wapper for scoreboarding
     Scoreboard::initialize($resp->status()->component());
     $sb = Scoreboard::get_scoreboard();
     $sb->increment_counter("status", "testbasicphp");
     $sw = new StopWatch();
     $sw->start();
     $sw->stop();
     $sb->update_duration_hours("status", "testbasicphp", "duration_success", $sw);
     if ($job->operation() == "create") {
         // post-create where the resource id is created for user
         // (instead of a PUT where the user specifies the name)
         // get the generated id
         $in = json_decode($job->content(), true);
         $in["id"] = $job->resource_name();
         file_put_contents(DBDIR . $job->resource_name(), json_encode($in));
     } else {
         $args = $job->arguments();
         // post update
         if (file_exists(DBDIR . $args[0])) {
             $in = json_decode($job->content(), true);
             $out = json_decode(file_get_contents(DBDIR . $args[0]), true);
             $out["stuff"] = $in["stuff"];
             file_put_contents(DBDIR . $args[0], json_encode($out));
         } else {
             throw new ERR_NOT_FOUND("thing \"" . $args[0] . "\" not found");
         }
     }
     $resp->status()->add_message("done");
     return Worker::WORKER_SUCCESS;
 }