Exemplo n.º 1
0
 /**
  * (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['s3_access_key']) || empty($params['s3_secret_key']) || empty($params['s3_bucket'])) {
             return false;
         }
         $local = new Remote(new Local(dirname($this->getTestFilePath())));
         $client = m62S3::getRemoteClient($params['s3_access_key'], $params['s3_secret_key']);
         if ($client->doesBucketExist($params['s3_bucket'])) {
             $contents = $local->read($this->test_file);
             $filesystem = new Remote(new m62S3($client, $params['s3_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;
     }
 }
Exemplo n.º 2
0
 /**
  * (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;
     }
 }
Exemplo n.º 3
0
 /**
  * (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;
     }
 }
Exemplo n.º 4
0
 /**
  * (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['s3_access_key']) || empty($params['s3_secret_key']) || empty($params['s3_bucket'])) {
             return false;
         }
         $client = m62S3::getRemoteClient($params['s3_access_key'], $params['s3_secret_key']);
         if ($client->doesBucketExist($params['s3_bucket'])) {
             $filesystem = new Remote(new m62S3($client, $params['s3_bucket']));
             $filesystem->getAdapter()->listContents();
             return true;
         }
     } catch (\Exception $e) {
         return false;
     }
 }
Exemplo n.º 5
0
 /**
  * (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;
     }
 }
Exemplo n.º 6
0
 /**
  * (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;
     }
 }
Exemplo n.º 7
0
 /**
  * (non-PHPdoc)
  * @see \League\Flysystem\Filesystem::copy()
  */
 public function copy($path, $newpath)
 {
     $this->checkBackupDirs();
     return parent::copy($path, $newpath);
 }