コード例 #1
0
ファイル: Writable.php プロジェクト: jaeger-app/validate-ftp
 /**
  * (non-PHPdoc)
  * 
  * @see \mithra62\Validate\RuleInterface::validate()
  * @ignore
  *
  */
 public function validate($field, $input, array $params = array())
 {
     try {
         if ($input == '' || empty($params['0'])) {
             return false;
         }
         $params = $params['0'];
         if (empty($params['ftp_hostname']) || empty($params['ftp_password']) || empty($params['ftp_username']) || empty($params['ftp_port']) || empty($params['ftp_store_location'])) {
             return false;
         }
         $local = new Remote(new Local(dirname($this->getTestFilePath())));
         $filesystem = new Remote(Ftp::getRemoteClient($params));
         if ($local->has($this->test_file)) {
             $contents = $local->read($this->test_file);
             $filesystem->getAdapter()->setRoot($params['ftp_store_location']);
             if ($filesystem->has($this->test_file)) {
                 $filesystem->delete($this->test_file);
             } else {
                 if ($filesystem->write($this->test_file, $contents)) {
                     $filesystem->delete($this->test_file);
                 }
             }
         }
         $filesystem->getAdapter()->disconnect();
         return true;
     } catch (\Exception $e) {
         return false;
     }
 }
コード例 #2
0
ファイル: Connect.php プロジェクト: jaeger-app/validate-ftp
 /**
  * (non-PHPdoc)
  * 
  * @see \mithra62\Validate\RuleInterface::validate()
  * @ignore
  *
  */
 public function validate($field, $input, array $params = array())
 {
     try {
         if ($input == '' || empty($params['0'])) {
             return false;
         }
         $params = $params['0'];
         if (empty($params['ftp_hostname']) || empty($params['ftp_password']) || empty($params['ftp_username']) || empty($params['ftp_port'])) {
             return false;
         }
         $filesystem = new Remote(Ftp::getRemoteClient($params));
         if (!$filesystem->getAdapter()->listContents()) {
             return false;
         }
         $filesystem->getAdapter()->disconnect();
         return true;
     } catch (\Exception $e) {
         return false;
     }
 }
コード例 #3
0
ファイル: FtpTest.php プロジェクト: jaeger-app/remote-ftp
 public function testGetRemoteClient()
 {
     $settings = $this->getFtpCreds();
     $this->assertInstanceOf('\\League\\Flysystem\\AdapterInterface', Ftp::getRemoteClient($settings));
 }