Exemplo n.º 1
0
 /**
  * Deletes paths from the current path
  *
  * @param string $listFolder The image directory to delete a file from
  * @since 1.5
  */
 function delete()
 {
     global $mainframe;
     JRequest::checkToken('request') or jexit('Invalid Token');
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     // Get some data from the request
     $tmpl = JRequest::getCmd('tmpl');
     $paths = JRequest::getVar('rm', array(), '', 'array');
     $folder = JRequest::getVar('folder', '', '', 'path');
     // Initialize variables
     $msg = array();
     $ret = true;
     if (count($paths)) {
         foreach ($paths as $path) {
             if ($path !== JFile::makeSafe($path)) {
                 JError::raiseWarning(100, JText::_('Unable to delete:') . htmlspecialchars($path, ENT_COMPAT, 'UTF-8') . ' ' . JText::_('WARNDIRNAME'));
                 continue;
             }
             $fullPath = JPath::clean(JA_WORKING_DATA_FOLDER . DS . $folder . DS . $path);
             if (is_file($fullPath)) {
                 $ret |= !JFile::delete($fullPath);
             } else {
                 if (is_dir($fullPath)) {
                     $files = JFolder::files($fullPath, '.', true);
                     $canDelete = true;
                     foreach ($files as $file) {
                         if ($file != 'index.html') {
                             $canDelete = false;
                         }
                     }
                     if ($canDelete) {
                         $ret |= !JFolder::delete($fullPath);
                     } else {
                         //allow remove folder not empty on local repository
                         $ret2 = FileSystemHelper::rm($fullPath, true);
                         $ret |= $ret2;
                         if ($ret2 == false) {
                             JError::raiseWarning(100, JText::_('Unable to delete:') . $fullPath);
                         }
                     }
                 }
             }
         }
     }
     if ($tmpl == 'component') {
         // We are inside the iframe
         $mainframe->redirect('index.php?option=' . JACOMPONENT . '&view=repolist&folder=' . $folder . '&tmpl=component');
     } else {
         $mainframe->redirect('index.php?option=' . JACOMPONENT . '&view=repolist&folder=' . $folder);
     }
 }
Exemplo n.º 2
0
 function doBackupConflictedFiles($upgradeVersion, $folder)
 {
     global $jauc;
     $backupDir = $jauc->getLocalConflictPath($this->getInfo(), $folder);
     $upgradeInfo = $jauc->buildDiff($this->getFullInfo(), $upgradeVersion);
     if ($backupDir !== false && $upgradeInfo !== false) {
         $conflicted = $this->_doBackupConflictedFiles($backupDir, "", $upgradeInfo);
         if (!$conflicted) {
             //dont have any conflicted files
             FileSystemHelper::rm($backupDir, true);
             return false;
         } else {
             return $folder;
         }
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  *  Advanced move file and directories with support recursively mode
  *
  * @param $src  string source file or directory
  * @param $dest  string destination file or directory
  * @param $recursive  boolean recursive mode
  * @param $mod  int unix permission formated number
  *
  * @return  boolean true if success, otherwise return false
  */
 function mv($src, $dest, $recursive = false, $mod = 0700)
 {
     if (FileSystemHelper::cp($src, $dest, $recursive, $mod) === false) {
         return false;
     }
     if (JFolder::exists($src) && preg_match("/\\/\$/", $src) > 0) {
         $rv = true;
         $dh = opendir($src);
         while (($entry = readdir($dh)) !== false) {
             if (FileSystemHelper::rm($src . $entry, true) === false) {
                 $rv = false;
             }
         }
         return $rv;
     } else {
         return FileSystemHelper::rm($src, $dest, $recursive);
     }
 }