") { $this->beg = $beg; $this->end = $end; //File has to exist if (file_exists($file)) { $content = fread(fopen($file, "rb"), filesize($file)); } else { $content = "Template was not found!"; } $this->p = 0; $this->s[0][$this->p] = ""; $this->s[1][$this->p] = $content; $this->s[2][$this->p] = $content; } /* * Create new block on the stack, if $copy is true then original area is copied into changed * area else changed area is empty */ public function pushBlock($name, $copy = true) { $begStr = $this->beg."+".$name.$this->end; $endStr = $this->beg."-".$name.$this->end; //Only content (without block name) $begPos = strpos($this->s[1][$this->p], $begStr) + strlen($begStr); $endPos = strpos($this->s[1][$this->p], $endStr); //Block doesn't exist if ($endPos == false) { echo "Block ".$name." doesn't exist!"; return; } //Cut new content from old content $content = substr($this->s[1][$this->p], $begPos, $endPos - $begPos); //Paste new content on top of stack (create copy if it is necessary) $this->p++; $this->s[0][$this->p] = $name; $this->s[1][$this->p] = $content; $this->s[2][$this->p] = $copy == true ? $content : ""; } /* * Create new condition on the stack, if $truth is true then content is area from + to : else * content is area from : to - */ public function pushCond($name, $truth) { if ($truth) { $begStr = $this->beg."+".$name.$this->end; $endStr = $this->beg.":".$name.$this->end; } else { $begStr = $this->beg.":".$name.$this->end; $endStr = $this->beg."-".$name.$this->end; } //Only content (without block name) $begPos = strpos($this->s[1][$this->p], $begStr) + strlen($begStr); $endPos = strpos($this->s[1][$this->p], $endStr); //Condition doesn't exist if ($endPos == false) { echo "Condition ".$name." doesn't exist!"; return; } //Cut new content from old content $content = substr($this->s[1][$this->p], $begPos, $endPos - $begPos); //Paste new content on top of stack and create copy $this->p++; $this->s[0][$this->p] = $name; $this->s[1][$this->p] = $content; $this->s[2][$this->p] = $content; } /* * Pop highest content to lower content */ public function pop() { if ($this->p == 0) { return; } $begStr = $this->beg."+".$this->s[0][$this->p].$this->end; $endStr = $this->beg."-".$this->s[0][$this->p].$this->end; //Decrease pointer $this->p--; //Content with block name $begPos = strpos($this->s[2][$this->p], $begStr); $endPos = strpos($this->s[2][$this->p], $endStr) + strlen($endStr); //Remove unused variables, blocks and conditions //TODO //Remove spaces //TODO //Cut old content $content = substr($this->s[2][$this->p], $begPos, $endPos - $begPos); //Replace old content $this->s[2][$this->p] = str_replace( $content, $this->s[2][$this->p + 1], $this->s[2][$this->p]); } /* * Copy original content to changed content */ public function copy() { $this->s[2][$this->p] .= $this->s[1][$this->p]; } /* * Replace variable */ public function replaceVar($src, $dst) { $this->s[2][$this->p] = str_replace( $this->beg.$src.$this->end, $dst, $this->s[2][$this->p]); } /* * Return top of stack */ public function content() { return $this->s[2][$this->p]; } /* * Show top of stack */ public function show() { echo $this->content(); } } ?> timeout = $timeout; $this->now = time(); $this->id = 0; $this->rights = 0; $this->connected = $connected; } /* * Connect to server and select database */ public function database($server, $user, $pass, $database) { if (mysql_connect($server, $user, $pass) == null) { echo "MySQL error!"; return; } if (mysql_select_db($database) == null) { echo "Database error!"; return; } $this->connected = true; } /* * Load logged user and return rows */ public function load($key, $rows = "") { //Check connection if ($this->connected == false) { return; } //Check lenght if (strlen($key) < 1) { return; } //Select logged users $result = mysql_query(" SELECT uzivatel_id, prava, odchod".(empty($rows) ? "" : ", ".$rows)." FROM uzivatele WHERE relace='".$key."' "); if ($result == null) { return; } //Logged user must be just one if (mysql_num_rows($result) != 1) { return; } //Load data $data = mysql_fetch_object($result); //Security if ($data->odchod + $this->timeout < $this->now) { return; } //Copy data $this->id = $data->uzivatel_id; $this->rights = $data->prava; //Update user mysql_query(" UPDATE uzivatele SET odchod='".$this->now."' WHERE uzivatel_id='".$this->id."' "); return $data; } /* * Return user's ID */ public function id() { return $this->id; } /* * Return user's rights */ public function rights() { return $this->rights; } } ?> 0; $i--) { if ($path[$i] == '/') { $ret .= $space; } } return $ret; } function noDiacritic($str) { $str = strtolower($str); $str = str_replace("á", "a", $str); $str = str_replace("é", "e", $str); $str = str_replace("í", "i", $str); $str = str_replace("ó", "o", $str); $str = str_replace("ú", "u", $str); $str = str_replace("ý", "y", $str); $str = str_replace("ž", "z", $str); $str = str_replace("š", "s", $str); $str = str_replace("č", "c", $str); $str = str_replace("ř", "r", $str); $str = str_replace("ď", "d", $str); $str = str_replace("ť", "t", $str); $str = str_replace("ň", "n", $str); $str = str_replace("ě", "e", $str); $str = str_replace("ů", "u", $str); $str = str_replace(" ", "-", $str); $str = str_replace("Á", "a", $str); $str = str_replace("É", "e", $str); $str = str_replace("Í", "i", $str); $str = str_replace("Ó", "o", $str); $str = str_replace("Ú", "u", $str); $str = str_replace("Ý", "y", $str); $str = str_replace("Ě", "e", $str); $str = str_replace("Ů", "u", $str); $str = str_replace("Ž", "z", $str); $str = str_replace("Š", "s", $str); $str = str_replace("Č", "c", $str); $str = str_replace("Ř", "r", $str); $str = str_replace("Ď", "d", $str); $str = str_replace("Ť", "t", $str); $str = str_replace("Ň", "n", $str); $str = eregi_replace("[^a-z0-9\/]", "-", $str); return $str; } function price($price, $splitter = ".") { settype($price, "string"); $ret = ""; $len = strlen($price); $j = -2; for ($i = $len; $i >= 0; $i -= 1) { $j++; if ($j == 3) { $j = 0; $ret = $price[$i].$splitter.$ret; } else { $ret = $price[$i].$ret; } } return $ret; } ?>