Exemple #1
0
     if (APPLICATION_IS_WINDOWS) {
         $needCliPath = true;
         $cliPath = isset($_POST["cliPath"]) ? $_POST["cliPath"] : PATH_PHP_CLI_WINDOWS;
     } elseif (substr(CMS_patch::executeCommand('which php 2>&1', $error), 0, 1) !== '/') {
         $return = CMS_patch::executeCommand('php -v', $error);
         if (strpos(strtolower($return), '(cli)') === false) {
             $needCliPath = true;
             $cliPath = isset($_POST["cliPath"]) ? $_POST["cliPath"] : PATH_PHP_CLI_UNIX;
         }
     }
 }
 //CHMOD scripts with good values
 $scriptsFiles = CMS_file::getFileList(PATH_PACKAGES_FS . '/scripts/*.php');
 foreach ($scriptsFiles as $aScriptFile) {
     //then set it executable
     CMS_file::makeExecutable($aScriptFile["name"]);
 }
 //test temporary directory and create it if none found
 $tmpPath = '';
 if (@is_dir(ini_get("session.save_path")) && is_writable(PATH_TMP_FS)) {
     $tmpPath = ini_get("session.save_path");
 } elseif (@is_dir(PATH_PHP_TMP) && is_writable(PATH_PHP_TMP)) {
     $tmpPath = PATH_PHP_TMP;
 } else {
     if (@is_dir(PATH_TMP_FS) && is_writable(PATH_TMP_FS)) {
         $tmpPath = realpath(PATH_TMP_FS);
         //add tmp path to config.php file
         $configFile = new CMS_file(dirname(__FILE__) . "/config.php");
         $configFileContent = $configFile->readContent("array", "rtrim");
         $skip = false;
         foreach ($configFileContent as $lineNb => $aLineOfConfigFile) {
Exemple #2
0
 /**
  * Apply chmod on file(s)
  *
  * @param $right, string : rights to apply to file(s)
  *  format : 
  *  r	read (and execute if it's a folder)
  *  w	read and write (and execute if it's a folder)
  *  x	read+write+execute
  *  XXX	unix chmod octal value (ex : 664, 775, etc.)
  * @param $files, string : the files to apply new rights (relative to CMS_file::FILE_SYSTEM)
  * @return string, the files who can't apply the chmod, else nothing if all is done.
  * @access public
  */
 function applyChmod($right, $files)
 {
     $filesList = CMS_file::getFileList($files);
     if (is_array($filesList) && $filesList) {
         $nok = '';
         foreach ($filesList as $aFile) {
             switch ($right) {
                 case 'r':
                     $nok .= CMS_file::makeReadable($aFile['name']) ? '' : $aFile['name'] . '<br />';
                     break;
                 case 'w':
                     $nok .= CMS_file::makeWritable($aFile['name']) ? '' : $aFile['name'] . '<br />';
                     break;
                 case 'x':
                     $nok .= CMS_file::makeExecutable($aFile['name']) ? '' : $aFile['name'] . '<br />';
                     break;
                 default:
                     $nok .= CMS_file::chmodFile($right, $aFile['name']) ? '' : $aFile['name'] . '<br />';
                     break;
             }
         }
         return $nok;
     } else {
         return '';
     }
 }
 /**
  * function chmodFile
  * Try to chmod a file (a dir is redirected to makeExecutable method).
  * @param string $right, the 3 or 4 octal numbers to set (775, 664, 0664, etc.)
  * @param string $file, the full filename of the file or dir
  * @return boolean true on success, false on failure
  * @static
  */
 static function chmodFile($right, $file)
 {
     $file = realpath($file);
     if (!file_exists($file)) {
         return false;
     }
     if (@is_dir($file)) {
         return CMS_file::makeExecutable($file);
     } elseif (@is_file($file)) {
         if (APPLICATION_IS_WINDOWS) {
             //chmod does not mean anything on windows
             return true;
         }
         $right = io::strlen($right) == 3 ? '0' . $right : $right;
         return @chmod($file, octdec($right));
     } else {
         CMS_grandFather::raiseError("Can't chmod file who does not exist : " . $file);
         return false;
     }
 }