Example #1
0
 /**
  * Saves options to the database, inserting if none exists or updating on duplicate key
  * 
  * @param array $options An array of options
  * @param string $group A unique string representing the options group
  * @return boolean
  */
 public function save($group, $folder = null)
 {
     //Save the user config
     $configini = \Library\Config::$ini;
     $fileHandler = \Library\Folder\Files::getInstance();
     $userfolders = $this->config->getParam('site-users-folder', '/users');
     $prefdir = FSPATH . $userfolders . DS . $this->user->get("user_name_id") . DS . 'preferences' . DS;
     if (!$fileHandler->is($prefdir, true)) {
         //if its not a folder
         $folderHandler = \Library\Folder::getInstance();
         if (!$folderHandler->create($prefdir)) {
             $this->setError(_("Could not create the target uploads folder. Please check that you have write permissions"));
             throw new \Platform\Exception($this->getError());
         }
     }
     $paramsfolder = str_replace(array('/', '\\'), DS, $prefdir);
     $paramsconf = array($group);
     $filename = $group . ".ini";
     if ($configini::saveParams($filename, $paramsconf, $paramsfolder) == FALSE) {
         $this->setError($this->config->getError());
         return false;
     }
     return true;
 }
Example #2
0
 public function reset()
 {
     $fileHandler = \Library\Folder\Files::getInstance();
     $database = \Library\Database::getInstance();
     $usersdir = FSPATH . $this->config->getParam('site-users-folder', 'users');
     $databasename = FSPATH . $this->config->getParam('name', '', 'database');
     //Empty the users folder
     if (!$fileHandler->deleteContents($usersdir, array(), array(".htaccess"))) {
         $message = "Could not empty the user directory: {$usersdir}";
         $messageType = "error";
         $this->alert($message, "", $messageType);
         //$this->returnRequest();
     }
     //recreate users folder
     //$fileHandler->create($usersdir);
     //Delete the setup ini file;
     if (!$fileHandler->delete(FSPATH . "config" . DS . "setup.ini")) {
         $message = "Could not delete your setup.ini file";
         $messageType = "error";
         $this->alert($message, "", $messageType);
         $this->returnRequest();
     }
     //Clear all sessions;
     if (!$database->query("TRUNCATE ?session", TRUE)) {
         $message = $database->getError();
         $messageType = "error";
         $this->alert($message, "", $messageType);
         //$this->returnRequest();
     }
     //die;
     $message = "We have deleted your setup.ini. You will have to manually delete your backedup database: {$_databasename}." . "Please Note you cannot re-install to the same database";
     $messageType = "success";
     $this->alert($message, "", $messageType);
     $this->redirect("/setup/install/step1");
     //This will take them to installer
 }
Example #3
0
 /**
  * Resizes an image
  *
  * @param type $file
  * @param type $params
  */
 public static final function resize($file, $params)
 {
     //die;
     $fileHandler = \Library\Folder\Files::getInstance('image');
     $resizable = array("jpg", "gif", "png", "jpeg");
     //If there is no file
     if (empty($file)) {
         return $file;
     }
     $fileExtension = $fileHandler->getExtension($file);
     //If we can't resize this type of file
     if (!in_array(strtolower($fileExtension), $resizable)) {
         return $file;
     }
     //If we can't resize it just return the file
     //We need at least the width or height to resize;
     if (empty($params)) {
         return false;
     }
     $width = isset($params[0]) ? $params[0] : null;
     $height = isset($params[1]) ? $params[1] : null;
     $isSquare = $width == $height ? true : false;
     //NewName = OriginalName-widthxheight.OriginalExtension
     $fileName = $fileHandler->getName($file);
     $filePath = $fileHandler->getPath($file);
     $target = $filePath . DS . $fileName . (isset($width) ? "-" . $width : null) . (isset($height) ? "x" . $height : null) . "." . $fileExtension;
     if (!$fileHandler->resizeImage($file, $target, $width, $height, $isSquare)) {
         return false;
         //There was a problem and we could not resize the file
     }
     return $file = $target;
 }