if ($_SESSION['UserDST'] == "on") { $MyDST = $checktimea['hour'] + 1; } if ($_SESSION['UserDST'] == "off") { $MyDST = $checktimea['hour']; } if ($MyDST >= 0) { $TimeSign = "+"; } if ($MyDST < 0) { $TimeSign = "-"; $MyDST = abs($MyDST); } $MyDST = $MyDST . ":" . $checktimea['minute']; $MyTimeNow = GMTimeGet($_SESSION['iDBTimeFormat'], $_SESSION['UserTimeZone'], 0, $_SESSION['UserDST']); $MyFullTimeNow = GMTimeGet($_SESSION['iDBDateFormat'] . ", " . $_SESSION['iDBTimeFormat'], $_SESSION['UserTimeZone'], 0, $_SESSION['UserDST']); $endpagevar = $endpagevar . "<br />The time now is <span class=\"ctimenow\" title=\"" . $MyFullTimeNow . "\">" . $MyTimeNow . "</span> " . $ThemeSet['LineDivider'] . " All times are UTC " . $TimeSign . " " . $MyDST; } function execution_time($starttime) { list($uetime, $etime) = explode(" ", microtime()); $endtime = $uetime + $etime; return bcsub($endtime, $starttime, 4); } if ($_GET['debug'] == "true" || $_GET['debug'] == "on") { $endpagevar = $endpagevar . "<br />\nNumber of Queries: " . $NumQueries . " " . $ThemeSet['LineDivider'] . " Execution Time: " . execution_time($starttime) . $ThemeSet['LineDivider'] . "<a href=\"http://validator.w3.org/check/referer?verbose=1\" title=\"Validate HTML\" onclick=\"window.open(this.href);return false;\">HTML</a>" . $ThemeSet['LineDivider'] . "<a href=\"http://jigsaw.w3.org/css-validator/check/referer?profile=css3\" title=\"Validate CSS\" onclick=\"window.open(this.href);return false;\">CSS</a>"; } $endpagevar = $endpagevar . "</div>\n"; echo $endpagevar; session_write_close(); //session_write_close();
?> </a> | <a href="http://wiki.wolfcms.org/" target="_blank"><?php echo __('Documentation'); ?> </a> </p> --> <?php if (DEBUG) { ?> <p class="stats"> <?php echo __('Page rendered in'); ?> <?php echo execution_time(); ?> <?php echo __('seconds'); ?> | <?php echo __('Memory usage:'); ?> <?php echo memory_usage(); ?> </p> <?php } ?>
function start_next_program() { global $dbc, $si; $p = new sys_program(); $p_toStart = $p->findBy_status('Initiated'); if (!empty($p_toStart)) { foreach ($p->field_a as $key => $value) { $p->{$value} = $p_toStart->{$value}; } //update the status to inprogress $p->status = 'inprogress'; $p->save(); $dbc->confirm(); $class = $p->class; ${$class} = new $class(); if ($p_toStart->request_type == 'REPORT') { $search_class_obj_all = ${$class}->findBySql(base64_decode($p_toStart->report_query)); $search_class_array_all = json_decode(json_encode($search_class_obj_all), true); if (!empty($p_toStart->op_email_address)) { //send email $im = new inomail(); $im->FromName = $si->site_name; $email_a = explode(',', $p_toStart->op_email_address); foreach ($email_a as $em_k => $email_v) { $im->addAddress($email_v); } $im->addReplyTo($si->email, 'Search Output'); $im->Subject = 'Search Result'; $im->Body = 'Please find attached the search result'; switch ($p_toStart->op_email_format) { case 'text_format': $report_op = array2text($search_class_array_all); $file_name = date("Y-m-d") . '_' . $class . '_report_output.txt'; break; case 'pdf_format': $report_op = array2pdf($search_class_array_all); $file_name = date("Y-m-d") . '_' . $class . '_report_output.pdf'; break; case 'xml_format': $report_op = array2xml($search_class_array_all); $file_name = date("Y-m-d") . '_' . $class . '_report_output.txt'; break; case 'worddoc_format': $report_op = array2worddoc($search_class_array_all); $file_name = date("Y-m-d") . '_' . $class . '_report_output.doc'; break; default: $report_op = array2csv($search_class_array_all); $file_name = date("Y-m-d") . '_' . $class . '_report_output.csv'; break; } $im->addStringAttachment($report_op, $file_name); try { $im->ino_sendMail(); $p->message = "Program {$p->program_name} is sucessfully completed <br>" . execution_time(); $p->status = 'Completed'; } catch (Exception $e) { $p->status = 'Error'; } $p->save(); } } else { try { $result = call_user_func(array(${$class}, $p->program_name), $p->parameters); $result_message = is_array($result) ? $result[0] : $result; $result_output = is_array($result) ? $result[1] : null; $p->message = "Program {$p->program_name} is sucessfully completed <br>" . $result_message . '<br>' . execution_time(); $p->status = 'Completed'; try { if (!empty($result_output)) { $op_file_name = $p->program_name . '_' . time() . '.xls'; $module_name = $class::$module; $file_path = HOME_DIR . "/files/outputs/modules/{$module_name}/{$p->program_name}/{$op_file_name}"; $file = fopen($file_path, 'w'); $headerData = []; foreach ($result_output[0] as $key => $value) { array_push($headerData, $key); } fputcsv($file, $headerData); foreach ($result_output as $obj) { $rowData = []; foreach ($obj as $key => $value) { array_push($rowData, $value); } fputcsv($file, $rowData); } fclose($file); $p->output_path = "/files/outputs/modules/{$module_name}/{$p->program_name}/{$op_file_name}"; } } catch (Exception $e) { $p->output_path = null; } $p->save(); } catch (Exception $e) { $p->status = 'Failed'; $p->message = "<br> Program failed @ start_program " . __LINE__ . '<br>' . $e->getMessage(); $p->save(); } } $dbc->confirm(); } else { sleep(5); } execution_time(); unset($p_toStart); unset($p); }
function db_profile() { // total query time $total = 0; $html = ''; $html .= '<table id="debug_table" class="debug">'; $html .= '<thead><tr><th>SQL</th><th>Bindings</th><th>Rows</th><th>Time</th></th></thead>'; $html .= '<tbody>'; foreach (Db::profile() as $row) { $html .= '<tr><td>' . $row['sql'] . '</td><td>' . implode(', ', $row['binds']) . '</td><td>' . $row['rows'] . '</td><td>' . $row['time'] . '</td></tr>'; $total += $row['time']; } $html .= '</tbody>'; $html .= '<tfoot>'; $html .= '<tr><td colspan="3"><strong>Query Time</strong></td><td>' . round($total, 4) . '</td></tr>'; $html .= '<tr><td colspan="3"><strong>Execution Time</strong></td><td>' . execution_time() . '</td></tr>'; $html .= '<tr><td colspan="3"><strong>Memory Usage</strong></td><td>' . memory_usage() . 'Kb</td></tr>'; $html .= '</tfoot>'; $html .= '</table>'; return $html; }
public function executionTime() { return execution_time(); }
?> </Image> <Url type="text/html" method="POST" template="<?php echo $BoardURL . url_maker("search", $Settings['file_ext'], null, "search", "search"); ?> "> <Param name="act" value="topics"/> <Param name="search" value="{searchTerms}"/> <Param name="type" value="wildcard"/> <Param name="page" value="1"/> </Url> <?php echo $endtag; ?> <moz:SearchForm><?php echo $BoardURL . url_maker("search", $Settings['file_ext'], null, "search", "search"); ?> </moz:SearchForm> </OpenSearchDescription> <?php } if ($_GET['debug'] == "true" || $_GET['debug'] == "on") { function execution_time($starttime) { list($uetime, $etime) = explode(" ", microtime()); $endtime = $uetime + $etime; return bcsub($endtime, $starttime, 4); } echo "<!-- execution_time=\"" . execution_time($starttime) . "\" -->"; } gzip_page($Settings['use_gzip'], $GZipEncode['Type']);
function db_profile() { // total query time $total = 0; $html = '<style>'; $html .= '.debug {display: none;font-size: 13px; margin-bottom: 1em;}'; $html .= '.debug td, .debug th {padding: 4px 6px; border-bottom: 1px solid #ddd;}'; $html .= '.debug th {font-weight: bold; text-align: center;}'; $html .= '.debug tfoot td:first-child {text-align: right;}'; $html .= '</style>'; $html .= '<table id="debug_table" class="debug">'; $html .= '<thead><tr><th>SQL</th><th>Bindings</th><th>Rows</th><th>Time</th></th></thead>'; $html .= '<tbody>'; foreach (Db::profile() as $row) { $html .= '<tr><td>' . $row['sql'] . '</td><td>' . implode(', ', $row['binds']) . '</td><td>' . $row['rows'] . '</td><td>' . $row['time'] . '</td></tr>'; $total += $row['time']; } $html .= '</tbody>'; $html .= '<tfoot>'; $html .= '<tr><td colspan="3"><strong>Query Time</strong></td><td>' . round($total, 4) . '</td></tr>'; $html .= '<tr><td colspan="3"><strong>Execution Time</strong></td><td>' . execution_time() . '</td></tr>'; $html .= '<tr><td colspan="3"><strong>Memory Usage</strong></td><td>' . memory_usage() . 'Kb</td></tr>'; $html .= '</tfoot>'; $html .= '</table>'; return $html; }
error_reporting(E_ALL); if (phpversion() < 4.3) { die('You must have php 4.3 or higher to use this program'); } // temps d'exécution function execution_time($content = false) { global $execution_time, $db; list($usec, $sec) = explode(' ', microtime()); if (!$content) { $execution_time = doubleval($usec) + doubleval($sec); } else { return str_replace('<span id="execution_time"></span>', '<span id="execution_time">' . round(doubleval($usec) + doubleval($sec) - $execution_time, 3) . ' s - ' . $db->num_queries . ' queries</span>', $content); } } execution_time(); // définition de la constante certifiant que PHPore a démarré define('IN_PHPORE', true); // création de l'objet $config settype($config, 'object'); // récupération de l'extension des fichiers php et définition de la racine du répertoire $config->phpex = preg_replace('`^(.*?)\\.([a-z0-9\\-_]*)$`s', '$2', $_SERVER['PHP_SELF']); $config->path = './'; // on charge les fichiers indispensables au bon fonctionnement du script require $config->path . 'includes/config.' . $config->phpex; require $config->path . 'includes/common.' . $config->phpex; // on finit l'initialisation de l'objet $config $config = new config($config); // connexion é la base de données $db = new sql_db($config->db_host, $config->db_user, $config->db_password, $config->db_name, false); unset($config->db_host, $config->db_user, $config->db_password, $config->db_name);
function start_next_program() { global $dbc; $prg_schedule = new sys_program_schedule(); $all_prg_schedule = $prg_schedule->findAll(); /* * Foreach schedule check the schedule frequency * Check if any program is submitted with in the schduled ferquency, If yes, continue. Else create a new program */ $curr_time = new DateTime(); foreach ($all_prg_schedule as $prg_schedule) { $intvl = 'P365D'; switch ($prg_schedule->frequency_uom) { case 'MINUTELY': $intvl_i = $prg_schedule->frequency_value; $intvl = 'PT' . $intvl_i . 'M'; break; case 'HOURLY': $intvl_i = $prg_schedule->frequency_value; $intvl = 'PT' . $intvl_i . 'H'; break; case 'DAILY': $intvl_i = $prg_schedule->frequency_value; $intvl = 'P' . $intvl_i . 'D'; break; case 'WEEKLY': $intvl_i = $prg_schedule->frequency_value * 7; $intvl = 'P' . $intvl_i . 'D'; break; case 'MONTHLY': $intvl_i = $prg_schedule->frequency_value; $intvl = 'P' . $intvl_i . 'M'; break; } $date_time_int = new DateInterval($intvl); $curr_time->sub($date_time_int); $sys_prg = new sys_program(); $sys_prg->class = $prg_schedule->program_class_name; $sys_prg->program_name = $prg_schedule->program_name; $sys_prg->program_source = 'SCHEDULER'; $sys_prg->request_type = $prg_schedule->request_type; $sys_prg->report_query = $prg_schedule->report_query; $sys_prg->op_email_address = $prg_schedule->op_email_address; $sys_prg->op_email_format = $prg_schedule->op_email_format; $sys_prg->creation_date = $curr_time->format('Y-m-d'); $existing_schl = $sys_prg->findBy_schdule_details(); if ($existing_schl) { continue; } else { //submit a request $all_parameters = unserialize($prg_schedule->parameter); if ($prg_schedule->increase_date_parameter_cb) { $format_param = 'Y-m-d'; foreach ($all_parameters as $param_k => &$param_v) { $d = DateTime::createFromFormat($format_param, $param_v[0]); if ($d && $d->format($format_param) == $param_v[0]) { $scheduled_date_time = new DateTime($prg_schedule->creation_date); $param_date_time = new DateTime($param_v[0]); $param_date_time->diff($scheduled_date_time, true); $diff = $param_date_time->diff($scheduled_date_time); $param_d = new DateTime(); if ($diff->invert) { //negative - use add $param_d->add(new DateInterval('P' . $diff->days . 'D')); } else { //positive - use sub $param_d->sub(new DateInterval('P' . $diff->days . 'D')); } $param_v[0] = $param_d->format($format_param); } } } $sys_prg->parameters = serialize($all_parameters); $sys_prg->description = 'Auto schdule program @' . $curr_time->format('Y-m-d'); $sys_prg->status = 'Initiated'; $sys_prg->save(); } } $dbc->confirm(); sleep(15); execution_time(); }