/**
  * Configure after successfull mount.
  *
  * @return void
  * @author Dmitry (dio) Levashov
  **/
 protected function configure()
 {
     $this->aroot = realpath($this->root);
     $root = $this->stat($this->root);
     if ($this->options['quarantine']) {
         $this->attributes[] = array('pattern' => '~^' . preg_quote($this->separator . $this->options['quarantine']) . '$~', 'read' => false, 'write' => false, 'locked' => true, 'hidden' => true);
     }
     // check thumbnails path
     if ($this->options['tmbPath'] && ($test_path = $this->_separator($this->options['tmbPath'])) && strpos($test_path, $this->separator) === false) {
         $this->options['tmbPath'] = $this->_joinPath($this->root, $this->options['tmbPath']);
         $this->options['tmbPath'] = $this->_normpath($this->options['tmbPath']);
     }
     parent::configure();
     // if no thumbnails url - try detect it
     if ($root['read'] && !$this->tmbURL && $this->URL) {
         if ($this->inRoot($this->tmbPath)) {
             $temp = substr($this->tmbPath, strlen($this->root) + 1);
             $this->tmbURL = $this->URL . str_replace($this->separator, '/', $temp);
             if (preg_match("|[^/?&=]\$|", $this->tmbURL)) {
                 $this->tmbURL .= '/';
             }
         }
     }
     // check quarantine dir
     if (!empty($this->options['quarantine'])) {
         $this->quarantine = $this->_joinPath($this->root, $this->options['quarantine']);
         if (!is_dir($this->quarantine) && !$this->_mkdir($this->root, $this->options['quarantine']) || !is_writable($this->quarantine)) {
             $this->archivers['extract'] = array();
             $this->disabled[] = 'extract';
         }
     } else {
         $this->archivers['extract'] = array();
         $this->disabled[] = 'extract';
     }
 }
Пример #2
0
 /**
  * Connect to ftp server
  *
  * @return bool
  * @author Dmitry (dio) Levashov
  */
 public function connect()
 {
     static $connected = false;
     if ($connected) {
         return true;
     }
     if (!($this->connect = ftp_connect($this->options['host'], $this->options['port'], $this->options['timeout']))) {
         return $this->setError('Unable to connect to FTP server ' . $this->options['host']);
     }
     if (!ftp_login($this->connect, $this->options['user'], $this->options['pass'])) {
         $this->umount();
         return $this->setError('Unable to login into ' . $this->options['host']);
     }
     // switch off extended passive mode - may be usefull for some servers
     @ftp_exec($this->connect, 'epsv4 off');
     // enter passive mode if required
     ftp_pasv($this->connect, $this->options['mode'] == 'passive');
     // enter root folder
     if (!ftp_chdir($this->connect, $this->root) || $this->root != ftp_pwd($this->connect)) {
         $this->umount();
         return $this->setError('Unable to open root folder.');
     }
     $connected = parent::connect();
     return $connected;
 }
Пример #3
0
 /**
  * Return temporary file path for required file
  *
  * @param  string  $path   file path
  * @return string
  * @author Dmitry (dio) Levashov
  **/
 protected function tmpname($path)
 {
     return parent::_joinPath($this->tmpPath, md5($path));
 }