function main() { global $log; //this script can take a long time to run //we don't want it ending early set_time_limit(0); $timer = new timer(); $log->writeLine("============================================"); $log->writeLine("Begin upload processing."); $timer->start(); //process all files in the upload directory do_process(); $timer->stop(); $log->writeLine("--------------------------------------------"); $log->writeLine("End upload processing. Took " . $timer->taken() . " seconds."); $log->writeLine("============================================"); $log->saveLog("blah.txt"); }
} // Be sure that the user is not already defined by PHP on hosts that still have the php.ini config "register_globals = On" unset($user); require_once 'lib/setup/third_party.php'; // Enable Versioning include_once 'lib/setup/twversion.class.php'; $TWV = new TWVersion(); $num_queries = 0; $elapsed_in_db = 0.0; $server_load = ''; $area = 'tiki'; $crumbs = array(); require_once 'lib/setup/tikisetup.class.php'; require_once 'lib/setup/timer.class.php'; $tiki_timer = new timer(); $tiki_timer->start(); require_once 'tiki-setup_base.php'; // Attempt setting locales. This code is just a start, locales should be set per-user. // Also, different operating systems use different locale strings. en_US.utf8 is valid on POSIX systems, maybe not on Windows, feel free to add alternative locale strings. setlocale(LC_ALL, ''); // Attempt changing the locale to the system default. // Since the system default may not be UTF-8 but we may be dealing with multilingual content, attempt ensuring the collations are intelligent by forcing a general UTF-8 collation. // This will have no effect if the locale string is not valid or if the designated locale is not generated. foreach (array('en_US.utf8') as $UnicodeLocale) { if (setlocale(LC_COLLATE, $UnicodeLocale)) { break; } } if ($prefs['feature_tikitests'] == 'y') { require_once 'tiki_tests/tikitestslib.php'; }
/** * @param $mod_reference * @return bool|mixed|string */ function execute_module($mod_reference) { global $user, $prefs, $tiki_p_admin; $smarty = TikiLib::lib('smarty'); $tikilib = TikiLib::lib('tiki'); try { $defaults = array('style' => '', 'nonums' => 'n'); $module_params = isset($mod_reference['params']) ? (array) $mod_reference['params'] : array(); $module_params = array_merge($defaults, $module_params); // not sure why style doesn't get set sometime but is used in the tpl $mod_reference = array_merge(array('moduleId' => null, 'ord' => 0, 'position' => 0, 'rows' => 10), $mod_reference); $module_rows = $mod_reference["rows"]; $info = $this->get_module_info($mod_reference); $cachefile = $this->get_cache_file($mod_reference, $info); foreach ((array) $info['prefs'] as $preference) { if ($prefs[$preference] != 'y') { $smarty->loadPlugin('smarty_block_remarksbox'); return smarty_block_remarksbox(array('type' => 'warning', 'title' => tr('Failed to execute "%0" module', $mod_reference['name'])), tr('Missing dependencies'), $smarty, $repeat); } } if (!$cachefile || $this->require_cache_build($mod_reference, $cachefile) || $this->is_admin_mode()) { if ($this->is_admin_mode()) { require_once 'lib/setup/timer.class.php'; $timer = new timer('module'); $timer->start('module'); } if ($info['type'] == "function") { // Use the module name as default module title. This can be overriden later. A module can opt-out of this in favor of a dynamic default title set in the TPL using clear_assign in the main module function. It can also be overwritten in the main module function. $smarty->assign('tpl_module_title', tra($info['name'])); } $smarty->assign('nonums', $module_params['nonums']); if ($info['type'] == 'include') { $phpfile = 'modules/mod-' . $mod_reference['name'] . '.php'; if (file_exists($phpfile)) { include $phpfile; } } elseif ($info['type'] == 'function') { $function = 'module_' . $mod_reference['name']; $phpfuncfile = 'modules/mod-func-' . $mod_reference['name'] . '.php'; if (file_exists($phpfuncfile)) { include_once $phpfuncfile; } if (function_exists($function)) { $function($mod_reference, $module_params); } } $ck = getCookie('mod-' . $mod_reference['name'] . $mod_reference['position'] . $mod_reference['ord'], 'menu', 'o'); $smarty->assign('module_display', $prefs['javascript_enabled'] == 'n' || $ck == 'o'); $smarty->assign_by_ref('module_rows', $mod_reference['rows']); $smarty->assign_by_ref('module_params', $module_params); // module code can unassign this if it wants to hide params $smarty->assign('module_ord', $mod_reference['ord']); $smarty->assign('module_position', $mod_reference['position']); $smarty->assign('moduleId', $mod_reference['moduleId']); if (isset($module_params['title'])) { $smarty->assign('tpl_module_title', tra($module_params['title'])); } $smarty->assign('tpl_module_name', $mod_reference['name']); $tpl_module_style = empty($mod_reference['module_style']) ? '' : $mod_reference['module_style']; if ($tiki_p_admin == 'y' && $this->is_admin_mode() && (!$this->filter_active_module($mod_reference) || $prefs['modhideanonadmin'] == 'y' && (empty($mod_reference['groups']) || $mod_reference['groups'] == serialize(array('Anonymous'))))) { $tpl_module_style .= 'opacity: 0.5;'; } if (isset($module_params['overflow']) && $module_params['overflow'] === 'y') { $tpl_module_style .= 'overflow:visible !important;'; } $smarty->assign('tpl_module_style', $tpl_module_style); $template = 'modules/mod-' . $mod_reference['name'] . '.tpl'; if (file_exists('templates/' . $template)) { $data = $smarty->fetch($template); } else { $data = $this->get_user_module_content($mod_reference['name'], $module_params); } $smarty->clear_assign('module_params'); // ensure params not available outside current module $smarty->clear_assign('tpl_module_title'); $smarty->clear_assign('tpl_module_name'); $smarty->clear_assign('tpl_module_style'); if ($this->is_admin_mode() && $timer) { $elapsed = round($timer->stop('module'), 3); $data = preg_replace('/<div /', '<div title="Module Execution Time ' . $elapsed . 's" ', $data, 1); } if (!empty($cachefile) && !$this->is_admin_mode()) { file_put_contents($cachefile, $data); } } else { $data = file_get_contents($cachefile); } return $data; } catch (Exception $e) { $smarty->loadPlugin('smarty_block_remarksbox'); if ($tiki_p_admin == 'y') { $message = $e->getMessage(); } else { $message = tr('Contact the system administrator'); } $repeat = false; return smarty_block_remarksbox(array('type' => 'warning', 'title' => tr('Failed to execute "%0" module', $mod_reference['name'])), html_entity_decode($message), $smarty, $repeat); } }
* * Note: baseDir and fileName parameters are available in command line mode only * * * If you want to know the translation progression for your language, just visit : http://i18n.tiki.org/status * which is made with http://tikiwiki.svn.sourceforge.net/viewvc/tikiwiki/trunk/doc/devtools/get_translation_percentage.php?view=markup * */ if (php_sapi_name() != 'cli') { require_once 'tiki-setup.php'; $access->check_permission('tiki_p_admin'); } require_once 'lib/init/initlib.php'; require_once 'lib/setup/timer.class.php'; $timer = new timer(); $timer->start(); $options = array(); $request = new Tiki_Request(); if ($request->hasProperty('lang')) { $options['lang'] = $request->getProperty('lang'); } if ($request->hasProperty('outputFiles')) { $options['outputFiles'] = $request->getProperty('outputFiles'); } $excludeDirs = array('dump', 'img', 'lang', 'vendor', 'vendor_extra', 'lib/test', 'temp', 'temp/cache', 'templates_c'); $includeFiles = array('./lang/langmapping.php', './img/flags/flagnames.php'); // command-line only options if (php_sapi_name() == 'cli') { if ($request->hasProperty('baseDir')) { $options['baseDir'] = $request->getProperty('baseDir'); // when a custom base dir is set, default $includeFiles and $excludeDirs are not used
function doMonitor($id) { $time = new timer(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->args['url']); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //post if ($this->args['type'] == 'POST' && $this->args['data'] != NULL) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->args['data']); } //cookie if (isset($this->args['cookie']) && $this->args['cookie'] != NULL) { curl_setopt($ch, CURLOPT_COOKIE, $this->args['cookie']); } $time->start(); $res_content = curl_exec($ch); $time->stop(); //$curl_close($ch); global $db; $max_time = $time->spent(); $sql = "select * from history_record where data_id = {$id} order by time desc limit 1"; $result = mysql_query($sql, $db); if ($result) { $row = mysql_fetch_array($result); if ($row != NULL && $max_time < $row['max_time']) { $max_time = $row['max_time']; } else { $update_sql = "update history_record set max_time='" . $max_time . "' where id=" . $row['id']; mysql_query($update_sql, $db); } } echo "最大响应时间:" . $max_time . "秒<br>"; echo "当前响应时间:" . $time->spent() . "秒"; echo "<br>返回内容<br>"; #echo "<xmp>".$res_content."</xmp>"; echo "<br>" . $res_content . "<br>"; }
function list_raw_items($calIds, $user, $tstart, $tstop, $offset, $maxRecords, $sort_mode = 'start_asc', $find = '') { global $user, $tikilib; $dc = $tikilib->get_date_converter($user); if (sizeOf($calIds) == 0) { return array(); } $tstart = $dc->getServerDateFromDisplayDate($tstart); /* user time -> server time */ $tstop = $dc->getServerDateFromDisplayDate($tstop); $where = array(); $bindvars = array(); $time = new timer(); $time->start(); foreach ($calIds as $calendarId) { $where[] = "i.`calendarId`=?"; $bindvars[] = (int) $calendarId; } $cond = "(" . implode(" or ", $where) . ") and "; $cond .= " ((i.`start` > ? and i.`end` < ?) or (i.`start` < ? and i.`end` > ?))"; $bindvars[] = (int) $tstart; $bindvars[] = (int) $tstop; $bindvars[] = (int) $tstop; $bindvars[] = (int) $tstart; $cond .= " and ((c.`personal`='y' and i.`user`=?) or c.`personal` != 'y')"; $bindvars[] = $user; $query = "select i.`calitemId` as `calitemId`, i.`name` as `name`, i.`description` as `description`, i.`start` as `start`, i.`end` as `end`, "; $query .= "i.`url` as `url`, i.`status` as `status`, i.`priority` as `priority`, c.`name` as `calname`, i.`calendarId` as `calendarId`, "; $query .= "i.`locationID` as `locationID`, i.`categoryID` as `categoryID`, i.`nlId` as `nlId` "; $query .= "from `tiki_calendar_items` as i left join `tiki_calendars` as c on i.`calendarId`=c.`calendarId` where ({$cond}) order by " . $this->convert_sortmode("{$sort_mode}"); $result = $this->query($query, $bindvars, $maxRecords, $offset); $ret = array(); while ($res = $result->fetchRow()) { $ret[] = $this->get_item($res["calitemId"]); } return $ret; }
} ?> name="irmod"/>高级搜索 <input type="checkbox" name="light" value="1">开启高亮<br> <input id="word" type="text" name="word" value="<?php echo $keyword; ?> "> <!--input class="a" type="submit" value="名单搜素" name="button1"--> <input class="a" type="submit" value="Search" name="button2" onclick="validation();"> </form> <div id="content" class="content"> <?php $Timer1 = new timer(); //计时器 $Timer1->start(); $sphinx = new SphinxClient(); $sphinx->SetServer("localhost", 9312); if ($irmod == '1') { $sphinx->SetMatchMode(SPH_MATCH_EXTENDED2); } // else if($irmod == '2') // $sphinx->SetMatchMode(SPH_MATCH_PHRASE); #$sphinx->SetSortMode(SPH_SORT_RELEVANCE); // $sphinx->SetSortMode(SPH_SORT_EXTENDED,"@weight DESC");########### $sphinx->SetSortMode(SPH_SORT_EXPR, "hits*0.1+@weight*5"); $sphinx->setLimits(0, 1000, 1000); $sphinx->SetIndexWeights(array("title" => 50, "keywords" => 10, "description" => 5)); $result = $sphinx->query($keyword, "mysql"); echo "<pre>"; // print_r($result);
public function testStart() { timer::start(); // not much to test here $this->assertTrue(is_float(timer::stop())); }