Пример #1
0
 /**
  * Check file system full path
  *
  * @param  string $fullPath
  * @param  bool $recursive
  * @param  bool $existence
  * @return bool
  */
 protected function _checkFullPath($fullPath, $recursive, $existence)
 {
     $result = true;
     if ($recursive && $this->_filesystem->isDirectory($fullPath)) {
         $pathsToCheck = $this->_filesystem->getNestedKeys($fullPath);
         array_unshift($pathsToCheck, $fullPath);
     } else {
         $pathsToCheck = array($fullPath);
     }
     $skipFileNames = array('.svn', '.htaccess');
     foreach ($pathsToCheck as $pathToCheck) {
         if (in_array(basename($pathToCheck), $skipFileNames)) {
             continue;
         }
         if ($existence) {
             $setError = !$this->_filesystem->isWritable($fullPath);
         } else {
             $setError = $this->_filesystem->has($fullPath) && !$this->_filesystem->isWritable($fullPath);
         }
         if ($setError) {
             $this->_getInstaller()->getDataModel()->addError(Mage::helper('Mage_Install_Helper_Data')->__('Path "%s" must be writable.', $pathToCheck));
             $result = false;
         }
     }
     return $result;
 }
Пример #2
0
 /**
  * Clear files and directories in storage
  *
  * @param string $dir
  * @return Mage_Core_Model_Resource_File_Storage_File
  */
 public function clear($dir = '')
 {
     if (strpos($dir, $this->getMediaBaseDirectory()) !== 0) {
         $dir = $this->getMediaBaseDirectory() . $dir;
     }
     if ($this->_filesystem->isDirectory($dir)) {
         foreach ($this->_filesystem->getNestedKeys($dir) as $path) {
             $this->_filesystem->delete($path);
         }
     }
     return $this;
 }
Пример #3
0
 /**
  * Delete Expired Captcha Images
  *
  * @return Mage_Captcha_Model_Observer
  */
 public function deleteExpiredImages()
 {
     foreach (Mage::app()->getWebsites(true) as $website) {
         $expire = time() - Mage::helper('Mage_Captcha_Helper_Data')->getConfigNode('timeout', $website->getDefaultStore()) * 60;
         $imageDirectory = Mage::helper('Mage_Captcha_Helper_Data')->getImgDir($website);
         foreach ($this->_filesystem->getNestedKeys($imageDirectory) as $filePath) {
             if ($this->_filesystem->isFile($filePath) && pathinfo($filePath, PATHINFO_EXTENSION) == 'png' && $this->_filesystem->getMTime($filePath) < $expire) {
                 $this->_filesystem->delete($filePath);
             }
         }
     }
     return $this;
 }
Пример #4
0
 protected function _addDir($pfm, $role, $roleDir, $path, $include, $ignore)
 {
     $roleDirLen = strlen($roleDir);
     $entries = $this->_filesystem->getNestedKeys($roleDir . $path . DS);
     if (!empty($entries)) {
         foreach ($entries as $entry) {
             $filePath = substr($entry, $roleDirLen);
             if (!empty($include) && !preg_match($include, $filePath)) {
                 continue;
             }
             if (!empty($ignore) && preg_match($ignore, $filePath)) {
                 continue;
             }
             if ($this->_filesystem->isFile($entry)) {
                 $pfm->addFile('/', $filePath, array('role' => $role, 'md5sum' => $this->_filesystem->getFileMd5($entry)));
             }
         }
     }
 }