case "defaults": setupHeader("Step 2 of 3: Select default permissions"); setupMessage("Nothing is deleted at this time"); makeWritable($basePath); setupHeader("OK"); setupMessage("This step completed successfully"); setupHeader("WARNING!"); setupMessage("The following step will delete all gallery, image and user information from the currently selected database. Gallery directories and image files will not be deleted but all extended information (e.g. name, artist, copyright etc.) will be irretrievably lost"); echo '<br /><a href="index.html">Finish</a>'; echo ' | <a href="uninstall.php?step=database">Next: I AM SURE I WANT TO delete database information >></a>'; break; case "convert": setupHeader("Step 2 of 2: Delete database information"); //create config object $config = new sgConfig($basePath . "singapore.ini"); $config->loadConfig($basePath . "secret.ini.php"); $config->base_path = $basePath; //include base classes require_once $basePath . "includes/io.class.php"; require_once $basePath . "includes/io_sql.class.php"; switch ($config->io_handler) { case "csv": setupMessage("The default CSV file database does not require uninstalling"); setupHeader("OK"); setupMessage("This step completed successfully"); break; case "mysql": require_once $basePath . "includes/io_mysql.class.php"; setupMessage("Setup will now delete all gallery, image and user information"); setupHeader("Connecting to MySQL database"); $io = new sgIO_mysql($config);
/** * 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"]; } }