page = (isset($_REQUEST['page']) ? (int)$_REQUEST['page'] : 0); if ($this->page < 1) { $this->URL = $this->Format_URL($_SERVER["REQUEST_URI"]); if (('/'.SITE_PREFIX .$this->URL) == $_SERVER['PHP_SELF']) $this->URL = ''; } else $this->PARAMS = $_REQUEST; $this->POST = $_POST; $this->PAGEHREF = $this->BuildUrl($this->URL, $this->PARAMS); $print_params = $this->PARAMS; $print_params['print'] = 1; $this->PRINTHREF = $this->BuildUrl($this->URL, $print_params, false); } function BuildUrl($address, $params, $ignorePrintUrl = true) { $url = ''; While (list($key, $val) = each($params)) { if (!($ignorePrintUrl && ($key == "print")) && $key != 'lang') { if ($url != '') $url .= '&'; $url .= "$key=$val"; } } if ($url != '') $url = '/' . SITE_PREFIX . $address . '?' . $url . '&'; else $url = '/' . SITE_PREFIX . $address . '?'; return $url; } function Extract_params($URL) { $URLs = explode("?", $URL); $paramStr = (isset($URLs[1]) ? $URLs[1] : ''); if ($paramStr != '') { $params = explode('&', $paramStr); While (list($key, $val) = each($params)) { $statment = explode('=', $val); if ($statment[0] != '' && $statment[1] != '') $this->PARAMS[urldecode($statment[0])]=urldecode($statment[1]); } } return $URLs[0]; } function Format_URL($URL) { $URL = $this->Extract_params($URL); $URL = str_replace("\\", "/", $URL); $URL = str_replace("\"", "", $URL); $URL = str_replace("'", "", $URL); $URL = ereg_replace("/+", "/", $URL); $URL = trim($URL, '/'); $URL = strtolower($URL); $URL = substr($URL, strlen(SITE_PREFIX)); return $URL; } function ProcessParent($id) { global $mysql; $query = $mysql->Query("SELECT file_id, file_parent_id FROM arb_file WHERE file_id = '" . (int)$id . "' and file_visible = 'T'"); if ($mysql->NumRows($query) == 1) { $this->activePage[] = $res['file_id']; $res = $mysql->Fetch(); if ($res['file_parent_id'] > 0) { $this->ProcessParent($res['file_parent_id']); } return true; } return true; } function ProcessStartUp() { global $mysql; $query = $mysql->Query("SELECT file_id, file_parent_id FROM arb_file WHERE file_visible = 'T' AND file_type = 'D' AND file_index = 'T'"); if ($mysql->NumRows($query) == 1) { $res = $mysql->Fetch($query); $this->activePage[] = $res['file_id']; if ($this->getIndex($res['file_id']) == true) { if ($res['file_parent_id'] > 0) { $this->ProcessParent($res['file_parent_id']); } } } return true; } function ProcessUrl($URL, $parent = 0) { global $mysql, $gnr; if ($URL == '') exit; $nameLeft = ''; $pos = strpos($URL, '/'); if (!($pos===false)) { $name = substr($URL, 0, $pos); $nameLeft = substr($URL, $pos+1); } else $name = $URL; if ($name == '') exit; $query = $mysql->Query("SELECT file_id, file_type, file_title, file_template_id, file_keywords, file_description, file_lang FROM arb_file WHERE file_name = '" . $name . "' AND file_parent_id = '" . (int)$parent . "' AND file_visible = 'T'"); if ($mysql->NumRows($query) > 0) { $res = $mysql->Fetch($query); if ($res['file_type'] == 'D') { $this->activePage[] = $res['file_id']; $this->path = $this->path . ' » ' . $res['file_title']; $this->title = $res['file_title']; $this->nameLeft = $nameLeft; if ($nameLeft == '') $nameLeft = $this->Index($res['file_id']); if ($nameLeft != '') { if ($this->ProcessUrl($nameLeft, $res['file_id']) == false) { $nameLeft = $this->Index($res['file_id']); return $this->ProcessUrl($nameLeft, $res['file_id']); } return true; } else return true; } else { $this->activePage[] = $res['file_id']; $this->id = $res['file_id']; $this->type = $res['file_type']; $this->template = $res['file_template_id']; $this->keywords = $res['file_keywords']; $this->description = $res['file_description']; $this->lang = $res['file_lang']; $this->title = $res['file_title']; if ($nameLeft != '') $this->nameLeft = $nameLeft; if ($name != 'index') $this->path = $this->path . ' » ' . $res['file_title']; return true; } } else return false; } function Index($parent) { global $mysql; $c_query = $mysql->Query("SELECT count(*) as count FROM arb_file WHERE file_parent_id = '" . (int)$parent . "' AND file_name = 'index' AND file_visible = 'T'"); $c_result = $mysql->Fetch($c_query); if ($c_result['count'] <= 0) { $query = $mysql->Query("SELECT file_name FROM arb_file WHERE file_parent_id = '" . (int)$parent . "' AND file_index = 'T' AND file_visible = 'T' LIMIT 1"); if ($mysql->NumRows() == 1) { $res = $mysql->Fetch($query); return $res['file_name']; } } return 'index'; } function getIndex($parent) { global $mysql, $gnr; $iQuery = $mysql->Query("SELECT file_id, file_type, file_lang, file_title, file_template_id, file_keywords, file_description, file_lang FROM arb_file WHERE (file_name = 'index' OR file_index = 'T') AND file_parent_id = '$parent' AND file_type = 'F' AND file_visible = 'T' ORDER BY file_id LIMIT 1"); if ($mysql->NumRows($iQuery) == 1) { $iRes = $mysql->Fetch($iQuery); $this->activePage[] = $iRes['file_id']; $this->id = $iRes['file_id']; $this->type = $iRes['file_type']; $this->template = $iRes['file_template_id']; $this->keywords = $iRes['file_keywords']; $this->description = $iRes['file_description']; $this->lang = $iRes['file_lang']; $this->title = $iRes['file_title']; $this->path = $this->path . ' » ' . $iRes['file_title']; return true; } else return false; } function GetUrl() { if (!$this->getIndex($this->home_id)) return false; if (!empty($this->URL)) { $result = $this->ProcessUrl($this->URL); } else { $result = $this->ProcessStartUp(); } return $result; } } ?>