public static function createConfig(PostmanTransport $transport)
 {
     // create Logger
     $logger = new PostmanLogger("PostmanBasicAuthConfigurationFactory");
     // retrieve the hostname and port form the transport
     $hostname = $transport->getHostname();
     $port = $transport->getPort();
     $securityType = $transport->getSecurityType();
     $authType = $transport->getAuthenticationType();
     $username = $transport->getCredentialsId();
     $password = $transport->getCredentialsSecret();
     // create the Configuration structure for Zend_Mail
     $config = array('port' => $port);
     $logger->debug(sprintf('Using %s:%s ', $hostname, $port));
     if ($securityType != PostmanOptions::SECURITY_TYPE_NONE) {
         $config['ssl'] = $securityType;
         $logger->debug('Using encryption ' . $securityType);
     } else {
         $logger->debug('Using no encryption');
     }
     if ($authType != PostmanOptions::AUTHENTICATION_TYPE_NONE) {
         $config['auth'] = $authType;
         $config['username'] = $username;
         $config['password'] = $password;
         $logger->debug(sprintf('Using auth %s with username %s and password %s', $authType, $username, PostmanUtils::obfuscatePassword($password)));
     } else {
         $logger->debug('Using no authentication');
     }
     // return the Configuration structure
     return $config;
 }
コード例 #2
0
 /**
  * PHP version less than 5.3 don't have str_getcsv natively.
  *
  * @param unknown $string
  * @return multitype:
  */
 function str_getcsv($string)
 {
     $logger = new PostmanLogger('postman-common-functions');
     $logger->debug('Using custom str_getcsv');
     return PostmanUtils::postman_strgetcsv_impl($string);
 }
コード例 #3
0
 public function log(PostmanLogger $log, $desc)
 {
     $message = $desc . ' email=' . $this->getEmail();
     if (!empty($this->name)) {
         $message .= ' name=' . $this->getName();
     }
     $log->debug($message);
 }
コード例 #4
0
ファイル: PostmanOptions.php プロジェクト: DanMaiman/Awfulkid
 /**
  *
  * @param unknown $data        	
  */
 public function import($data)
 {
     if (PostmanPreRequisitesCheck::checkZlibEncode()) {
         $logger = new PostmanLogger(get_class($this));
         $logger->debug('Importing Settings');
         $base64 = $data;
         $logger->trace($base64);
         $gz = base64_decode($base64);
         $logger->trace($gz);
         $json = @gzuncompress($gz);
         $logger->trace($json);
         if (!empty($json)) {
             $data = json_decode($json, true);
             $logger->trace($data);
             // overwrite the current version with the version from the imported options
             // this way database upgrading can occur
             $postmanState = get_option('postman_state');
             $postmanState['version'] = $data['version'];
             $logger->trace(sprintf('Setting Postman version to %s', $postmanState['version']));
             assert($postmanState['version'] == $data['version']);
             update_option('postman_state', $postmanState);
             $this->options = $data;
             $logger->info('Imported data');
             $this->save();
             return true;
         } else {
             $logger->error('Could not import data - data error');
             return false;
         }
     }
 }
コード例 #5
0
 /**
  * If the host port is a possible configuration option, recommend it
  *
  * $hostData includes ['host'] and ['port']
  *
  * response should include ['success'], ['message'], ['priority']
  *
  * @param unknown $hostData        	
  */
 public function getRecommendation($hostData, $userAuthOverride, $originalSmtpServer)
 {
     //
     $priority = -1;
     $winningRecommendation = null;
     $logger = new PostmanLogger(get_class($this));
     $scrubbedUserAuthOverride = $this->scrubUserOverride($hostData, $userAuthOverride);
     foreach ($this->getTransports() as $transport) {
         $recommendation = $transport->getConfigurationBid($hostData, $scrubbedUserAuthOverride, $originalSmtpServer);
         $logger->debug(sprintf('Transport %s bid %s', $transport->getName(), $recommendation['priority']));
         if ($recommendation['priority'] > $priority) {
             $priority = $recommendation['priority'];
             $winningRecommendation = $recommendation;
         }
     }
     return $winningRecommendation;
 }