/** * Constructor, does all init type stuff. This code is a total mess. * @param string the path to the base singapore directory */ function Singapore($basePath = "") { //import class definitions //io handler class included once config is loaded require_once $basePath . "includes/translator.class.php"; require_once $basePath . "includes/thumbnail.class.php"; require_once $basePath . "includes/gallery.class.php"; require_once $basePath . "includes/config.class.php"; require_once $basePath . "includes/image.class.php"; require_once $basePath . "includes/user.class.php"; //start execution timer $this->scriptStartTime = microtime(); //remove slashes if (get_magic_quotes_gpc()) { $_REQUEST = array_map(array("Singapore", "arraystripslashes"), $_REQUEST); } //desanitize request $_REQUEST = array_map("htmlentities", $_REQUEST); //load config from singapore root directory $this->config = sgConfig::getInstance(); $this->config->loadConfig($basePath . "singapore.ini"); $this->config->loadConfig($basePath . "secret.ini.php"); //if instantiated remotely... if (!empty($basePath)) { //...try to guess base path and relative url if (empty($this->config->base_path)) { $this->config->base_path = $basePath; } if (empty($this->config->base_url)) { $this->config->base_url = $basePath; } //...load local config if present //may over-ride guessed values above $this->config->loadConfig("singapore.local.ini"); } //set current gallery to root if not specified in url $galleryId = isset($_GET[$this->config->url_gallery]) ? $_GET[$this->config->url_gallery] : "."; //load config from gallery ini file (gallery.ini) if present $this->config->loadConfig($basePath . $this->config->pathto_galleries . $galleryId . "/gallery.ini"); //set current template from request vars or config //first, preset template to default one $this->template = $this->config->default_template; //then check if requested template exists if (!empty($_REQUEST[$this->config->url_template])) { $templates = Singapore::getListing($this->config->base_path . $this->config->pathto_templates); foreach ($templates->dirs as $single) { if ($single == $_REQUEST[$this->config->url_template]) { $this->template = $single; break; } } } $this->config->pathto_current_template = $this->config->pathto_templates . $this->template . '/'; //load config from template ini file (template.ini) if present $this->config->loadConfig($basePath . $this->config->pathto_current_template . "template.ini"); //set runtime values $this->config->pathto_logs = $this->config->pathto_data_dir . "logs/"; $this->config->pathto_cache = $this->config->pathto_data_dir . "cache/"; $this->config->pathto_admin_template = $this->config->pathto_templates . $this->config->admin_template_name . "/"; //set current language from request vars or config if (!empty($_REQUEST[$this->config->url_lang])) { $this->language = $_REQUEST[$this->config->url_lang]; } else { $this->language = $this->config->default_language; if ($this->config->detect_language) { foreach ($this->getBrowserLanguages() as $lang) { if ($lang == "en" || file_exists($basePath . $this->config->pathto_locale . "singapore." . $lang . ".pmo")) { $this->language = $lang; break; } } } } //read the language file $this->translator = Translator::getInstance($this->language); $this->translator->readLanguageFile($this->config->base_path . $this->config->pathto_locale . "singapore." . $this->language . ".pmo"); //clear the UMASK umask(0); //include IO handler class and create instance require_once $basePath . "includes/io_" . $this->config->io_handler . ".class.php"; $ioClassName = "sgIO_" . $this->config->io_handler; $this->io = new $ioClassName($this->config); //load gallery and image info $this->selectGallery($galleryId); //set character set if (!empty($this->translator->languageStrings[0]["charset"])) { $this->character_set = $this->translator->languageStrings[0]["charset"]; } else { $this->character_set = $this->config->default_charset; } if (ini_get("mbstring.func_overload") == "7") { $this->character_set = "UTF-8"; } //set action to perform if (empty($_REQUEST["action"])) { $this->action = "view"; } else { $this->action = $_REQUEST["action"]; } }