Ejemplo n.º 1
1
 public function testInstantiable()
 {
     $adapter = new Ftp($this->options);
     $this->assertEquals('example.org', $adapter->getHost());
     $this->assertEquals(40, $adapter->getPort());
     $this->assertEquals(true, $adapter->getSsl());
     $this->assertEquals(35, $adapter->getTimeout());
     $this->assertEquals('/somewhere/', $adapter->getRoot());
     $this->assertEquals(0777, $adapter->getPermPublic());
     $this->assertEquals(00, $adapter->getPermPrivate());
     $this->assertEquals(false, $adapter->getPassive());
     $this->assertEquals('user', $adapter->getUsername());
     $this->assertEquals('password', $adapter->getPassword());
     $listing = $adapter->listContents('', true);
     $this->assertInternalType('array', $listing);
     $this->assertFalse($adapter->has('not.found'));
     $this->assertFalse($adapter->getVisibility('not.found'));
     $this->assertFalse($adapter->getSize('not.found'));
     $this->assertFalse($adapter->getMimetype('not.found'));
     $this->assertFalse($adapter->getTimestamp('not.found'));
     $this->assertFalse($adapter->write('write.fail', 'contents'));
     $this->assertFalse($adapter->writeStream('write.fail', tmpfile()));
     $this->assertFalse($adapter->update('write.fail', 'contents'));
     $this->assertFalse($adapter->setVisibility('chmod.fail', 'private'));
     $this->assertTrue($adapter->rename('a', 'b'));
     $this->assertTrue($adapter->delete('a'));
     $result = $adapter->read('something.txt');
     $this->assertEquals('contents', $result['contents']);
     $result = $adapter->getMimetype('something.txt');
     $this->assertEquals('text/plain', $result['mimetype']);
     $this->assertFalse($adapter->createDir('some.nested/mkdir.fail'));
     $this->assertInternalType('array', $adapter->write('unknowndir/file.txt', 'contents', 'public'));
     $this->assertInternalType('array', $adapter->writeStream('unknowndir/file.txt', tmpfile(), 'public'));
     $adapter->deleteDir('');
     $this->assertInternalType('array', $adapter->getTimestamp('some/file.ext'));
 }
Ejemplo n.º 2
0
 /**
  * Deletes files.
  * @return void
  */
 private function deleteFiles(array $files)
 {
     rsort($files);
     $root = $this->ftp->pwd();
     foreach ($files as $num => $file) {
         $remoteFile = $root . $file;
         $this->writeProgress($num + 1, count($files), "Deleting {$file}");
         if (substr($file, -1) === '/') {
             // is directory?
             $this->ftp->rmdir($remoteFile);
         } else {
             $this->ftp->delete($remoteFile);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Borra físicamente el archivo del disco del servidor vía FTP
  *
  * @return boolean TRUE si se ha borrado con éxito
  */
 private function borraArchivo()
 {
     $pathInfo = pathinfo($this->PathName);
     $carpetaDestino = $this->_prePath . $pathInfo['dirname'];
     $ftp = new Ftp($_SESSION['project']['ftp']);
     $ok = $ftp->delete($carpetaDestino, $this->Name);
     $this->_errores = $ftp->getErrores();
     $ftp->close();
     unset($ftp);
     return $ok;
 }