Beispiel #1
0
 /**
  * Constructor
  * @param string     gallery id
  * @param sgGallery  reference to the parent gallery
  */
 function sgGallery($id, &$parent)
 {
     $this->id = $id;
     $this->parent = $parent;
     $this->config = sgConfig::getInstance();
     $this->translator = Translator::getInstance();
 }
 function sgThumbnail(&$img, $type)
 {
     $this->config = sgConfig::getInstance();
     $this->image = $img;
     $widthVar = "thumb_width_" . $type;
     $heightVar = "thumb_height_" . $type;
     $cropVar = "thumb_crop_" . $type;
     $this->maxWidth = $this->config->{$widthVar};
     $this->maxHeight = $this->config->{$heightVar};
     if (isset($this->config->{$cropVar})) {
         $this->forceSize = $this->config->{$cropVar};
     }
     if ($this->image == null) {
         return;
     }
     $this->imagePath = $this->image->realPath();
     $this->thumbPath = $this->config->base_path . Singapore::thumbnailPath($this->image->parent->id, $this->image->id, $this->maxWidth, $this->maxHeight, $this->forceSize);
     $this->thumbURL = $this->config->base_url . Singapore::thumbnailPath($this->image->parent->id, $this->image->id, $this->maxWidth, $this->maxHeight, $this->forceSize);
     //security check: make sure requested file is in galleries directory
     if (!Singapore::isSubPath($this->config->base_path . $this->config->pathto_galleries, $this->imagePath) && !$this->image->isRemote()) {
         return;
     }
     //security check: make sure $image has a valid extension
     if (!$this->image->isRemote() && !preg_match("/.+\\.(" . $this->config->recognised_extensions . ")\$/i", $this->image->id)) {
         return;
     }
     $this->calculateDimensions();
     //link straight to image if it smaller than required size
     if ($this->image->width <= $this->thumbWidth && $this->image->height <= $this->thumbHeight) {
         $this->thumbURL = $this->image->realURL();
         return;
     }
     $imageModified = @filemtime($this->imagePath);
     $thumbModified = @filemtime($this->thumbPath);
     if ($imageModified > $thumbModified || !$thumbModified) {
         $this->buildThumbnail();
     }
 }
Beispiel #3
0
     $config->pathto_cache = $config->pathto_data_dir . "cache/";
     $config->base_path = $basePath;
     if (createDirectories($config)) {
         setupHeader("OK");
         setupMessage("This step completed successfully");
     } else {
         setupHeader("Oops!");
         setupError('There was a problem. Please fix it and <a href="install.php?step=directories">retry this step</a>');
     }
     echo '<br /><a href="install.php?step=test">&lt;&lt; Previous: test server</a>';
     echo ' | <a href="install.php?step=database">Next: setup database &gt;&gt;</a>';
     break;
 case "database":
     setupHeader("Step 2 of 2: Setup Database");
     //create config object
     $config = sgConfig::getInstance();
     $config->loadConfig($basePath . "singapore.ini");
     $config->base_path = $basePath;
     switch ($config->io_handler) {
         case "csv":
             setupMessage("The default CSV file database does not require any further setting up");
             setupHeader("OK");
             setupMessage("This step completed successfully");
             break;
         case "mysql":
             include_once $basePath . "includes/io_mysql.class.php";
             $config->loadConfig($basePath . "secret.ini.php");
             setupMessage("Setup will now create the tables necessary to run singapore on a MySQL database");
             setupHeader("Connecting to database");
             $io = new sgIO_mysql();
             if (!$io) {
Beispiel #4
0
 /**
  * Admin constructor. Doesn't call {@link Singapore} constructor.
  * @param string the path to the base singapore directory
  */
 function sgAdmin($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);
         //as if magic_quotes_gpc wasn't insane enough, php doesn't add slashes
         //to the tmp_name variable so I have to add them manually. Grrrr.
         foreach ($_FILES as $key => $nothing) {
             $_FILES[$key]["tmp_name"] = addslashes($_FILES[$key]["tmp_name"]);
         }
         $_FILES = array_map(array("Singapore", "arraystripslashes"), $_FILES);
     }
     $galleryId = isset($_REQUEST["gallery"]) ? $_REQUEST["gallery"] : ".";
     //load config from singapore root directory
     $this->config = sgConfig::getInstance();
     $this->config->loadConfig($basePath . "singapore.ini");
     $this->config->loadConfig($basePath . "secret.ini.php");
     //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_current_template = $this->config->pathto_templates . $this->config->default_template . "/";
     $this->config->pathto_admin_template = $this->config->pathto_templates . $this->config->admin_template_name . "/";
     //load config from admin template ini file (admin.ini) if present
     $this->config->loadConfig($basePath . $this->config->pathto_admin_template . "admin.ini");
     $this->template = $this->config->default_template;
     //do not load gallery-specific ini files
     //set current language from request vars or config
     $this->language = isset($_REQUEST["lang"]) ? $_REQUEST["lang"] : $this->config->default_language;
     //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");
     $this->translator->readLanguageFile($this->config->base_path . $this->config->pathto_locale . "singapore.admin." . $this->language . ".pmo");
     //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);
     //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;
     }
     //set action to perform
     if (empty($_REQUEST["action"])) {
         $this->action = "menu";
     } else {
         $this->action = $_REQUEST["action"];
     }
     //set page title
     $this->pageTitle = $this->config->gallery_name;
     //set root node of crumb line
     $holder = new sgGallery("", new stdClass());
     $holder->name = $this->config->gallery_name;
     $this->ancestors = array($holder);
 }
 /**
  * @param sgConfig pointer to a {@link sgConfig} object representing 
  *   the current script configuration
  */
 function sgIO_sqlite()
 {
     $this->config = sgConfig::getInstance();
     $this->db = sqlite_open($this->config->base_path . $this->config->pathto_data_dir . "sqlite.dat");
 }
 /**
  * Wrapper for mkdir() implementing the safe-mode hack
  */
 function mkdir($path)
 {
     $config = sgConfig::getInstance();
     if ($config->safe_mode_hack) {
         $connection = ftp_connect($config->ftp_server);
         // login to ftp server
         $result = ftp_login($connection, $config->ftp_user, $config->ftp_pass);
         // check if connection was made
         if (!$connection || !$result) {
             return false;
         }
         ftp_chdir($connection, $config->ftp_base_path);
         // go to destination dir
         if (!ftp_mkdir($connection, $path)) {
             // create directory
             return false;
         }
         ftp_site($connection, "CHMOD " . $config->directory_mode . " " . $path);
         ftp_close($connection);
         // close connection
         return true;
     } else {
         return mkdir($path, octdec($config->directory_mode));
     }
 }
 /**
  * @param sgConfig pointer to a {@link sgConfig} object representing 
  *   the current script configuration
  */
 function sgIO_mysql()
 {
     $this->config = sgConfig::getInstance();
     mysql_connect($this->config->sql_host, $this->config->sql_user, $this->config->sql_pass);
     mysql_select_db($this->config->sql_database);
 }