/** * Converts a SQL timestamp to a text string representing how long ago this timestamp occured * * @param $sql_time SQL timestamp * @return text string representing how long ago this timestamp occured */ function ago($sql_time, $past = 'ago', $future = 'in', $just_now = 'just now') { $old_time = ts(sql_datetime($sql_time)); $curr_time = time(); if ($curr_time == $old_time) { return $just_now; } if ($curr_time >= $old_time) { return elapsed_seconds($curr_time - $old_time, 0) . ' ' . $past; } return $future . ' ' . elapsed_seconds($old_time - $curr_time, 0); }
<?php namespace cd; if (!$temp instanceof TempStoreRedis) { return; } $config = $temp->getServerConfig(); //d($config); $info = $temp->getServerInfo(); //d($info); echo 'Redis ' . $info['redis_version'] . ', ' . $info['redis_mode'] . ' mode<br/>'; echo 'at <b>' . $config['bind'] . ':' . $config['port'] . '</b><br/>'; echo 'Uptime <b>' . elapsed_seconds($info['uptime_in_seconds']) . '</b><br/>'; echo 'Connected clients: <b>' . $info['connected_clients'] . '</b><br/>'; echo 'Used memory: <b>' . byte_count($info['used_memory']) . '</b><br/>';
$limit = ConvertDatasize::ToBytes($memory_limit); $pct = round($used_mem / $limit * 100, 1); $limit_s = round(ConvertDatasize::convert('byte', 'MiB', $limit), 1); echo ' (<b>' . $pct . '%</b>' . ' of <b>' . $limit_s . ' MiB</b>)<br/>'; } else { echo ' (no limit)<br/>'; } echo '<br/>'; if (extension_loaded('apc')) { $info = apc_cache_info('', true); //d($info); echo 'APC: using <b>' . round(ConvertDatasize::convert('byte', 'MiB', $info['mem_size']), 2) . ' MiB</b><br/>'; echo 'APC: <b>' . $info['num_hits'] . '</b> hits, <b>' . $info['num_misses'] . '</b> misses<br/>'; echo 'APC: <b>' . $info['num_entries'] . '</b> entries (max <b>' . $info['num_slots'] . '</b>)<br/>'; echo '<br/>'; } $client = HttpUserAgent::getBrowser(); echo 'Client: <b>' . $_SERVER['REMOTE_ADDR'] . '</b>' . ' using ' . ' <span title="' . $_SERVER['HTTP_USER_AGENT'] . '" style="font-weight:bold">' . $client->name . ' ' . $client->version . ' (' . $client->os . ', ' . $client->arch . ')</span><br/>'; echo '<br/>'; echo 'Webserver: <b>' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '</b><br/>'; echo 'Software: <b>' . $_SERVER['SERVER_SOFTWARE'] . '</b> with <b><span title="PHP_VERSION_ID = ' . PHP_VERSION_ID . '">PHP ' . phpversion() . '</span></b><br/>'; echo 'Webserver time: <b>' . date('Y-m-d H:i:s T') . '</b><br/>'; echo 'System uptime: <b>' . elapsed_seconds(uptime()) . '</b><br/>'; echo '</div>'; // closing $prof_id echo ' | <span id="span_rendertime">9.99</span>s render'; echo ahref_js('', "return hide_el('" . $wrapper_id . "');", 'closebtn'); echo '</div>'; // closing inner $container_id echo '</div>'; // closing outer wrapper
// ex: GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*xxx' WITH GRANT OPTION /// XXXXX FIXME: censor password from string instead of cut it!!!! //d($priv); echo '<h2>Privileges</h2>'; foreach ($priv as $p) { $key = key($p); $val = current($p); echo $key . ': <b>' . substr($val, 0, 60) . '</b>...<br/>'; } echo '<br/>'; echo '<h2>Time</h2>'; $db_time = Sql::pSelectItem('SELECT NOW()'); echo 'Database time: ' . $db_time . '<br/>'; echo 'Webserver time: ' . now() . '<br/>'; $uptime = Sql::pSelectRow('SHOW STATUS WHERE Variable_name = ?', 's', 'Uptime'); echo 'Database uptime: <b>' . elapsed_seconds($uptime['Value']) . '</b><br/>'; echo '<br/>'; echo '<h2>Character sets</h2>'; $charsets = Sql::pSelectMapped('SHOW VARIABLES LIKE "%character_set%"'); foreach ($charsets as $ch_name => $val) { echo $ch_name . ' = '; if (!in_array($val, array('utf8'))) { echo '<font color="red">' . $val . '</font>'; } else { echo $val; } echo '<br/>'; } $collations = Sql::pSelectMapped('SHOW VARIABLES LIKE "%collation%"'); foreach ($collations as $ch_name => $val) { echo $ch_name . ' = ' . $val . '<br/>';
return; } $pool = $temp->getServerStats(); if (!$pool) { echo 'No server configured'; return; } foreach ($pool as $host => $stat) { $pct = 0; if ($stat['limit_maxbytes']) { $pct = $stat['bytes'] / $stat['limit_maxbytes']; } echo 'Read: <b>' . byte_count($stat['bytes_read']) . '</b><br/>'; echo 'Written: <b>' . byte_count($stat['bytes_written']) . '</b><br/>'; echo 'Used memory: <b>' . byte_count($stat['bytes']) . '</b>' . ' (<b>' . round($pct * 100, 1) . '%</b>' . ' of <b>' . byte_count($stat['limit_maxbytes']) . '</b>)' . '<br/>'; echo '<br/>'; echo 'Get: <b>' . $stat['get_hits'] . '</b> hits, <b>' . $stat['get_misses'] . '</b> misses<br/>'; echo 'Cmd: <b>' . $stat['cmd_get'] . '</b> get, <b>' . $stat['cmd_set'] . '</b> set<br/>'; echo '<br/>'; echo 'Currently <b>' . $stat['curr_items'] . '</b> items, <b>' . $stat['curr_connections'] . '</b> connections<br/>'; echo 'Total <b>' . $stat['total_items'] . '</b> items, <b>' . $stat['total_connections'] . '</b> connections<br/>'; echo '<br/>'; // ??? echo 'Evictions: <b>' . $stat['evictions'] . '</b><br/>'; echo 'Threads: <b>' . $stat['threads'] . '</b><br/>'; echo '<br/>'; echo 'Server: <b>' . $host . '</b><br/>'; echo 'Software: <b>memcached ' . $stat['version'] . '</b><br/>'; echo 'Local time: <b>' . sql_datetime($stat['time']) . '</b><br/>'; echo 'Uptime: <b>' . elapsed_seconds($stat['uptime']) . '</b><br/>'; }
if (elapsed_seconds(60 * 60 * 24 * 2) != '2 days') { echo "FAIL 4\n"; } if (elapsed_seconds(60 * 60 * 24 * 12) != '12 days') { echo "FAIL 5\n"; } if (elapsed_seconds(60 * 60 * 24 * 14) != '2 weeks') { echo "FAIL 6\n"; } if (elapsed_seconds(60 * 60 * 24 * 30 * 3) != '3 months') { echo "FAIL 7\n"; } if (elapsed_seconds(60 * 60 * 24 * 365 * 2) != '2 years') { echo "FAIL 8\n"; } if (elapsed_seconds(60 * 60 * 24 * 1) != '1 day') { echo "FAIL 9\n"; } if (in_seconds('00:00:00') != 0) { echo "FAIL 10\n"; } if (in_seconds('18:13:45') != 65625) { echo "FAIL 11\n"; } if (in_seconds('23:59:59') != 86399) { echo "FAIL 12\n"; } if (in_seconds('0:49:47.53') != 2987.53) { echo "FAIL 13\n"; } if (in_seconds('00:26:36,595') != 1596.595) {