コード例 #1
0
ファイル: Writable.php プロジェクト: jaeger-app/validate-rcf
 /**
  * (non-PHPdoc)
  * 
  * @ignore
  *
  * @see \mithra62\Validate\RuleInterface::validate()
  */
 public function validate($field, $input, array $params = array())
 {
     try {
         if ($input == '' || empty($params['0'])) {
             return false;
         }
         $params = $params['0'];
         if (empty($params['rcf_username']) || empty($params['rcf_api']) || empty($params['rcf_container'])) {
             return false;
         }
         $local = new Remote(new Local(dirname($this->getTestFilePath())));
         $client = Rcf::getRemoteClient($params, true);
         if ($client instanceof \OpenCloud\ObjectStore\Resource\Container) {
             $contents = $local->read($this->test_file);
             $filesystem = new Remote(new Rcf($client, $params['rcf_container']));
             if ($filesystem->has($this->test_file)) {
                 $filesystem->delete($this->test_file);
             } else {
                 if ($filesystem->write($this->test_file, $contents)) {
                     $filesystem->delete($this->test_file);
                 }
             }
             return true;
         }
     } catch (\Exception $e) {
         return false;
     }
 }
コード例 #2
0
ファイル: Writable.php プロジェクト: jaeger-app/validate-gcs
 /**
  * (non-PHPdoc)
  * 
  * @ignore
  *
  * @see \mithra62\Validate\RuleInterface::validate()
  */
 public function validate($field, $input, array $params = array())
 {
     try {
         if ($input == '' || empty($params['0'])) {
             return false;
         }
         $params = $params['0'];
         if (empty($params['gcs_access_key']) || empty($params['gcs_secret_key']) || empty($params['gcs_bucket'])) {
             return false;
         }
         $local = new Remote(new Local(dirname($this->getTestFilePath())));
         $client = m62Gcs::getRemoteClient($params['gcs_access_key'], $params['gcs_secret_key']);
         if ($client->doesBucketExist($params['gcs_bucket'])) {
             $contents = $local->read($this->test_file);
             $filesystem = new Remote(new m62Gcs($client, $params['gcs_bucket']));
             if ($filesystem->has($this->test_file)) {
                 $filesystem->delete($this->test_file);
             } else {
                 if ($filesystem->write($this->test_file, $contents)) {
                     $filesystem->delete($this->test_file);
                 }
             }
             return true;
         }
     } catch (\Exception $e) {
         return false;
     }
 }
コード例 #3
0
ファイル: Connect.php プロジェクト: jaeger-app/validate-sftp
 /**
  * (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['sftp_host']) || empty($params['sftp_port']) || empty($params['sftp_root'])) {
             return false;
         }
         // we require either a private key file OR a username and password
         if (empty($params['sftp_password']) && empty($params['sftp_username']) && empty($params['sftp_private_key'])) {
             return false;
         }
         $filesystem = new Remote(Sftp::getRemoteClient($params));
         $return = true;
         $filesystem->getAdapter()->listContents();
         if (!$filesystem->getAdapter()->isConnected()) {
             $return = false;
         }
         $filesystem->getAdapter()->disconnect();
         return $return;
     } catch (\Exception $e) {
         return false;
     }
 }
コード例 #4
0
ファイル: Writable.php プロジェクト: jaeger-app/validate-sftp
 /**
  * (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['sftp_host']) || empty($params['sftp_password']) || empty($params['sftp_username']) || empty($params['sftp_port']) || empty($params['sftp_root'])) {
             return false;
         }
         $local = new Remote(new Local(dirname($this->getTestFilePath())));
         $filesystem = new Remote(Sftp::getRemoteClient($params));
         if ($local->has($this->test_file)) {
             $contents = $local->read($this->test_file);
             $filesystem->getAdapter()->setRoot($params['sftp_root']);
             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;
     }
 }
コード例 #5
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;
     }
 }
コード例 #6
0
ファイル: Readable.php プロジェクト: jaeger-app/validate-gcs
 /**
  * (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['gcs_access_key']) || empty($params['gcs_secret_key']) || empty($params['gcs_bucket'])) {
             return false;
         }
         $client = m62Gcs::getRemoteClient($params['gcs_access_key'], $params['gcs_secret_key']);
         if ($client->doesBucketExist($params['gcs_bucket'])) {
             $filesystem = new Remote(new m62Gcs($client, $params['gcs_bucket']));
             $filesystem->getAdapter()->listContents();
             return true;
         }
     } catch (\Exception $e) {
         return false;
     }
 }
コード例 #7
0
ファイル: Readable.php プロジェクト: jaeger-app/validate-rcf
 /**
  * (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['rcf_username']) || empty($params['rcf_api']) || empty($params['rcf_container'])) {
             return false;
         }
         $client = Rcf::getRemoteClient($params, true);
         if ($client instanceof \OpenCloud\ObjectStore\Resource\Container) {
             $filesystem = new Remote(new Rcf($client, $params['rcf_container']));
             $filesystem->getAdapter()->listContents();
             return true;
         }
     } catch (\Exception $e) {
         return false;
     }
 }
コード例 #8
0
 /**
  * (non-PHPdoc)
  * 
  * @todo implement if (preg_match('@[\x00-\x1f\x7f]@', $s) === 1) matching on token
  * @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['dropbox_access_token']) || empty($params['dropbox_app_secret'])) {
             return false;
         }
         $client = m62Dropbox::getRemoteClient($params['dropbox_access_token'], $params['dropbox_app_secret']);
         $adapter = new m62Dropbox($client);
         $filesystem = new Remote($adapter);
         if (!$filesystem->getAdapter()->listContents()) {
             return false;
         }
         return true;
     } catch (\Exception $e) {
         $this->setErrorMessage($e->getMessage());
         return false;
     }
 }