$errorcode, 'message' => $message ];
require (__DIR__ . '/../pages/errorview.php');
die();
}
function destructiveUrlEncode($str) {
$str = str_replace(' ', '_', $str);
$str = str_replace('+', '_', $str);
$str = str_replace('.', '', $str);
return urlencode($str);
}
function formatMilliseconds($millis)
{
if ($millis < 1000)
{
return $millis . 'ms';
}
else if ($millis < 10 * 1000)
{
return number_format($millis / (1000), 2) . 's';
}
else if ($millis < 60 * 1000)
{
return floor($millis / (1000)) . 's';
}
else if ($millis < 10 * 60 * 1000)
{
return floor($millis / (60 * 1000)) . 'min ' . floor(($millis % (60 * 1000)) / 1000) . 's';
}
else if ($millis < 60 * 60 * 1000)
{
return floor($millis / (60 * 1000)) . 'min';
}
else if ($millis < 10 * 60 * 60 * 1000)
{
return number_format($millis / (60 * 60 * 1000), 2) . ' hours';
}
else
{
return floor($millis / (60 * 60 * 1000)) . ' hours';
}
}
function includeScriptOnce($script, $echo = true)
{
global $REGISTERED_SCRIPTS;
if ($echo)
{
if (in_array($script, $REGISTERED_SCRIPTS)) return false;
$REGISTERED_SCRIPTS []= $script;
echo "";
return true;
}
else
{
if (in_array($script, $REGISTERED_SCRIPTS)) return '';
$REGISTERED_SCRIPTS []= $script;
return "";
}
}
function printCSS() {
global $CSS_BASE;
echo '';
}
function isProd() {
global $CONFIG;
return $CONFIG['prod'];
}