mode = $val; } function setKrihvel($kr) { $this->krihvel = $kr; } function setDB($val) { $this->kdb = $val; } function setUser($val) { $this->user = $val; } public function formatTime($time) { date_default_timezone_set(TIME_ZONE); $d = strtotime($time); return strftime("%e. %B %H:%M", $d); } public function getTimeToStart($startline) { date_default_timezone_set(TIME_ZONE); $time = strtotime("now"); $sl = strtotime($startline); $timeToStart = $sl - $time; if($timeToStart > 0) { return $timeToStart; } return false; } public function getTimeToEnd($deadline) { date_default_timezone_set(TIME_ZONE); $time = strtotime("now"); $dl = strtotime($deadline); $timeLeft = $dl - $time; $theTime = array(); if($timeLeft > 0) { return $timeLeft; } return false; } public function getTimeLeft($timeLeft) { $theTime = array(); if($timeLeft > 0) { $days = floor($timeLeft/60/60/24); $hours = $timeLeft/60/60%24; $mins = $timeLeft/60%60; $secs = $timeLeft%60; if($days) { $theTime['days'] = $days; if($hours) { $theTime['hours'] = $hours; } } elseif($hours) { $theTime['hours'] = $hours; if($mins) { $theTime['minutes'] = $mins; } } elseif($mins) { $theTime['minutes'] = $mins; if($secs) { $theTime['seconds'] = $secs; } } elseif($secs) { $theTime['seconds'] = $secs; } return $theTime; } else { return false; } } public function getClassName($sl, $dl) { if ($sl) { return 'fresh'; } else { if ($dl) { return 'active'; } else { return 'expired'; } } } } /** * Handles multidimentional array sorting by a key (not recursive) * * @author Oliwier Ptak */ class array_sorter { var $skey = false; var $sarray = false; var $sasc = true; /** * Constructor * * @access public * @param mixed $array array to sort * @param string $key array key to sort by * @param boolean $asc sort order (ascending or descending) */ function array_sorter(&$array, $key, $asc=true) { $this->sarray = $array; $this->skey = $key; $this->sasc = $asc; } /** * Sort method * * @access public * @param boolean $remap if true reindex the array to rewrite indexes */ function sortit($remap=true) { $array = &$this->sarray; uksort($array, array($this, "_as_cmp")); if ($remap) { $tmp = array(); while (list($id, $data) = each($array)) $tmp[] = $data; return $tmp; } return $array; } /** * Custom sort function * * @access private * @param mixed $a an array entry * @param mixed $b an array entry */ function _as_cmp($a, $b) { //since uksort will pass here only indexes get real values from our array if (!is_array($a) && !is_array($b)) { $a = $this->sarray[$a][$this->skey]; $b = $this->sarray[$b][$this->skey]; } //if string - use string comparision if (!ctype_digit($a) && !ctype_digit($b)) { if ($this->sasc) return strcasecmp($a, $b); else return strcasecmp($b, $a); } else { if (intval($a) == intval($b)) return 0; if ($this->sasc) return (intval($a) > intval($b)) ? -1 : 1; else return (intval($a) > intval($b)) ? 1 : -1; } } }//end of class ?>