Permalink
Browse files

microtime in php 5 style and better Page created

Signed-off-by: albertlast albertlast@hotmail.de
  • Loading branch information...
albertlast committed Sep 23, 2017
1 parent 3ecb1d9 commit 00d552713e803dc689f7d84f6e4c0acffd2b975a
View
@@ -25,7 +25,7 @@
global $smcFunc, $ssi_db_user, $scripturl, $ssi_db_passwd, $db_passwd, $cachedir;
// Remember the current configuration so it can be set back.
$time_start = microtime();
$time_start = microtime(true);
// Just being safe...
foreach (array('db_character_set', 'cachedir') as $variable)
@@ -1696,7 +1696,7 @@ function pauseAttachmentMaintenance($to_fix, $max_substep = 0)
@apache_reset_timeout();
// Have we already used our maximum time?
if (time() - array_sum(explode(' ', $time_start)) < 3 || $context['starting_substep'] == $_GET['substep'])
if ((time() - $time_start) < 3 || $context['starting_substep'] == $_GET['substep'])
return;
$context['continue_get_data'] = '?action=admin;area=manageattachments;sa=repair' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id'];
View
@@ -428,7 +428,7 @@ function pauseMailQueueClear()
@apache_reset_timeout();
// Have we already used our maximum time?
if (time() - array_sum(explode(' ', $time_start)) < 5)
if ((time() - $time_start) < 5)
return;
$context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id'];
@@ -433,7 +433,7 @@ function ConvertMsgBody()
$_REQUEST['start'] += $increment;
if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3)
if (microtime(true) - $time_start > 3)
{
createToken('admin-convertMsg');
$context['continue_post_data'] = '
@@ -740,7 +740,7 @@ function OptimizeTables()
break;
// Continue?
if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 10)
if (microtime(true) - $time_start > 10)
{
$_REQUEST['start'] = $key;
$context['continue_get_data'] = '?action=admin;area=maintain;sa=database;activity=optimize;start=' . $_REQUEST['start'] . ';' . $context['session_var'] . '=' . $context['session_id'];
@@ -893,7 +893,7 @@ function AdminBoardRecount()
$_REQUEST['start'] += $increment;
if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3)
if (microtime(true) - $time_start > 3)
{
createToken('admin-boardrecount');
$context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-boardrecount_token_var'] . '" value="' . $context['admin-boardrecount_token'] . '">';
@@ -951,7 +951,7 @@ function AdminBoardRecount()
$_REQUEST['start'] += $increment;
if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3)
if (microtime(true) - $time_start > 3)
{
createToken('admin-boardrecount');
$context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-boardrecount_token_var'] . '" value="' . $context['admin-boardrecount_token'] . '">';
@@ -1007,7 +1007,7 @@ function AdminBoardRecount()
$_REQUEST['start'] += $increment;
if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3)
if (microtime(true) - $time_start > 3)
{
createToken('admin-boardrecount');
$context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-boardrecount_token_var'] . '" value="' . $context['admin-boardrecount_token'] . '">';
@@ -1063,7 +1063,7 @@ function AdminBoardRecount()
$_REQUEST['start'] += $increment;
if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3)
if (microtime(true) - $time_start > 3)
{
createToken('admin-boardrecount');
$context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-boardrecount_token_var'] . '" value="' . $context['admin-boardrecount_token'] . '">';
@@ -1119,7 +1119,7 @@ function AdminBoardRecount()
$_REQUEST['start'] += $increment;
if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3)
if (microtime(true) - $time_start > 3)
{
createToken('admin-boardrecount');
$context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-boardrecount_token_var'] . '" value="' . $context['admin-boardrecount_token'] . '">';
@@ -1168,7 +1168,7 @@ function AdminBoardRecount()
updateMemberData($row['id_member'], array('unread_messages' => $row['real_num']));
$smcFunc['db_free_result']($request);
if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3)
if (microtime(true) - $time_start > 3)
{
createToken('admin-boardrecount');
$context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-boardrecount_token_var'] . '" value="' . $context['admin-boardrecount_token'] . '">';
@@ -1214,7 +1214,7 @@ function AdminBoardRecount()
$_REQUEST['start'] += $increment;
if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3)
if (microtime(true) - $time_start > 3)
{
createToken('admin-boardrecount');
$context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-boardrecount_token_var'] . '" value="' . $context['admin-boardrecount_token'] . '">';
View
@@ -2526,7 +2526,7 @@ function PackagePermissionsAction()
unset($context['to_process'][$path]);
// See if we're out of time?
if (time() - array_sum(explode(' ', $time_start)) > $timeout_limit)
if ((time() - $time_start) > $timeout_limit)
{
// Prepare template usage for to_process.
$context['to_process_encode'] = base64_encode($smcFunc['json_encode']($context['to_process']));
@@ -2639,7 +2639,7 @@ function build_special_files__recursive($path, &$data)
}
// See if we're out of time?
if (!$dont_chmod && time() - array_sum(explode(' ', $time_start)) > $timeout_limit)
if (!$dont_chmod && (time() - $time_start) > $timeout_limit)
{
$dont_chmod = true;
// Don't do this again.
@@ -2664,7 +2664,7 @@ function build_special_files__recursive($path, &$data)
unset($context['directory_list'][$path]);
// See if we're out of time?
if (time() - array_sum(explode(' ', $time_start)) > $timeout_limit)
if ((time() - $time_start) > $timeout_limit)
{
// Prepare this for usage on templates.
$context['directory_list_encode'] = base64_encode($smcFunc['json_encode']($context['directory_list']));
View
@@ -124,7 +124,7 @@ function pauseRepairProcess($to_fix, $current_step_description, $max_substep = 0
@apache_reset_timeout();
// Errr, wait. How much time has this taken already?
if (!$force && time() - array_sum(explode(' ', $time_start)) < 3)
if (!$force && (time() - $time_start) < 3)
return;
// Restore the query cache if interested.
@@ -110,7 +110,7 @@ function AutoTask()
// Log that we did it ;)
if ($completed)
{
$total_time = round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 3);
$total_time = round(microtime(true) - $time_start, 3);
$smcFunc['db_insert']('',
'{db_prefix}log_scheduled_tasks',
array(
@@ -444,11 +444,11 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
}
// Don't overload it.
$st = microtime();
$st = microtime(true);
$db_cache[$db_count]['q'] = $db_count < 50 ? $db_string : '...';
$db_cache[$db_count]['f'] = $file;
$db_cache[$db_count]['l'] = $line;
$db_cache[$db_count]['s'] = array_sum(explode(' ', $st)) - array_sum(explode(' ', $time_start));
$db_cache[$db_count]['s'] = $st - $time_start;
}
// First, we clean strings out of the query, reduce whitespace, lowercase, and trim - so we can check it over.
@@ -410,12 +410,12 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
$_SESSION['debug_redirect'] = array();
}
$st = microtime();
$st = microtime(true);
// Don't overload it.
$db_cache[$db_count]['q'] = $db_count < 50 ? $db_string : '...';
$db_cache[$db_count]['f'] = $file;
$db_cache[$db_count]['l'] = $line;
$db_cache[$db_count]['s'] = array_sum(explode(' ', $st)) - array_sum(explode(' ', $time_start));
$db_cache[$db_count]['s'] = $st - $time_start;
}
// First, we clean strings out of the query, reduce whitespace, lowercase, and trim - so we can check it over.
View
@@ -3467,7 +3467,7 @@ function template_footer()
// Show the load time? (only makes sense for the footer.)
$context['show_load_time'] = !empty($modSettings['timeLoadPageEnable']);
$context['load_time'] = comma_format(round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 3));
$context['load_time'] = round(microtime(true) - $time_start, 3);
$context['load_queries'] = $db_count;
foreach (array_reverse($context['template_layers']) as $layer)
View
@@ -26,7 +26,7 @@
// Get everything started up...
define('SMF', 1);
error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL);
$time_start = microtime();
$time_start = microtime(true);
// This makes it so headers can be sent!
ob_start();

0 comments on commit 00d5527

Please sign in to comment.