load_class: error loading file "'.$filename.'"';
die();
}
// The mu_sort function is used to sort a multi-dimensional array.
// It looks like the code example is taken from the PHP manual http://ca2.php.net/manual/en/function.sort.php
function mu_sort($array, $key_sort) {
$n = 0;
if (!is_array($array) || count($array)==0)
return array();
$key_sorta = explode(",", $key_sort);
$keys = array_keys($array[0]);
for($m=0; $m < count($key_sorta); $m++) {
$nkeys[$m] = trim($key_sorta[$m]);
}
$n += count($key_sorta);
for($i=0; $i < count($keys); $i++) {
if(!in_array($keys[$i], $key_sorta)) {
$nkeys[$n] = $keys[$i];
$n += "1";
}
}
for($u=0;$u 0)) {
$value = str_replace(",",".",$value);
return floatval($value);
}
return null;
}
function stripslashes_deep($value) {
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
function &getConnection() {
if (!isset($GLOBALS["_MDB2_CONNECTION"])) {
require_once('MDB2.php');
$mdb2 = MDB2::connect(DSN);
if (is_a($mdb2, 'PEAR_Error')) {
die($mdb2->getMessage());
}
$mdb2->setFetchMode(MDB2_FETCHMODE_ASSOC);
$GLOBALS["_MDB2_CONNECTION"] = $mdb2;
}
return $GLOBALS["_MDB2_CONNECTION"];
}
// time_to_decimal converts a time string such as 1:15 to its decimal representation such as 1.25 or 1,25.
function time_to_decimal($val) {
global $user;
$parts = explode(':', $val); // parts[0] is hours, parts[1] is minutes.
$minutePercent = round($parts[1]*100/60); // Integer value (0-98) of percent of minutes portion in the hour.
if($minutePercent < 10) $minutePercent = '0'.$minutePercent; // Pad small values with a 0 to always have 2 digits.
$decimalTime = $parts[0].$user->decimal_mark.$minutePercent; // Construct decimal representation of time value.
return $decimalTime;
}
function sec_to_time_fmt_hm($sec)
{
return sprintf("%d:%02d", $sec / 3600, $sec % 3600 / 60);
}
function magic_quotes_off()
{
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
// check_extension checks whether a required PHP extension is loaded and dies if not so.
function check_extension($ext)
{
if (!extension_loaded($ext))
die("PHP extension '{$ext}' is required but is not loaded. Read Time Tracker Install Guide for help.");
}
// isTrue is a helper function to return correct false for older config.php values defined as a string 'false'.
function isTrue($val)
{
return (defined($val) && constant($val) === true);
}
// ttValidString is used to check user input to validate a string.
function ttValidString($val, $emptyValid = false)
{
$val = trim($val);
if (strlen($val) == 0 && !$emptyValid)
return false;
// String must not be XSS evil (to insert JavaScript).
if (stristr($val, '