当前位置: 首页>>代码示例>>PHP>>正文


PHP Swift::command方法代码示例

本文整理汇总了PHP中Swift::command方法的典型用法代码示例。如果您正苦于以下问题:PHP Swift::command方法的具体用法?PHP Swift::command怎么用?PHP Swift::command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Swift的用法示例。


在下文中一共展示了Swift::command方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isAuthenticated

 /**
  * Try to authenticate using the username and password
  * Returns false on failure
  * @param string The username
  * @param string The password
  * @param Swift The instance of Swift this authenticator is used in
  * @return boolean
  */
 public function isAuthenticated($user, $pass, Swift $swift)
 {
     try {
         $swift->command("AUTH LOGIN", 334);
         $swift->command(base64_encode($user), 334);
         $swift->command(base64_encode($pass), 235);
     } catch (Swift_ConnectionException $e) {
         $swift->reset();
         return false;
     }
     return true;
 }
开发者ID:IngenioContenidoDigital,项目名称:americana,代码行数:20,代码来源:LOGIN.php

示例2: isAuthenticated

 /**
  * Try to authenticate using the username and password
  * Returns false on failure
  * @param string The username
  * @param string The password
  * @param Swift The instance of Swift this authenticator is used in
  * @return boolean
  */
 public function isAuthenticated($user, $pass, Swift $swift)
 {
     try {
         $encoded_challenge = substr($swift->command("AUTH CRAM-MD5", 334)->getString(), 4);
         $challenge = base64_decode($encoded_challenge);
         $response = base64_encode($user . " " . self::generateCRAMMD5Hash($pass, $challenge));
         $swift->command($response, 235);
     } catch (Swift_ConnectionException $e) {
         $swift->reset();
         return false;
     }
     return true;
 }
开发者ID:IngenioContenidoDigital,项目名称:americana,代码行数:21,代码来源:CRAMMD5.php

示例3: isAuthenticated

 /**
  * Try to authenticate using the username and password
  * Returns false on failure
  * @param string The username
  * @param string The password
  * @param Swift The instance of Swift this authenticator is used in
  * @return boolean
  */
 public function isAuthenticated($user, $pass, Swift $swift)
 {
     try {
         //The authorization string uses ascii null as a separator (See RFC 2554)
         $credentials = base64_encode($user . chr(0) . $user . chr(0) . $pass);
         $swift->command("AUTH PLAIN " . $credentials, 235);
     } catch (Swift_ConnectionException $e) {
         $swift->reset();
         return false;
     }
     return true;
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:20,代码来源:PLAIN.php

示例4: command

 /**
  * Send a command to Swift and get a response
  * @param string The command to send (leave of CRLF)
  * @return string
  */
 public function command($command)
 {
     if (substr($command, -2) == "\r\n") {
         $command = substr($command, 0, -2);
     }
     try {
         $rs = $this->swift->command($command);
         return $rs->getString();
     } catch (Swift_ConnectionException $e) {
         $this->setError("Command failed:<br />" . $e->getMessage());
         return false;
     }
 }
开发者ID:darkcolonist,项目名称:kohana234-doctrine115,代码行数:18,代码来源:EasySwift.php

示例5: command

 /**
  * Send a command to Swift and get a response
  * @param string The command to send (leave of CRLF)
  * @return string
  */
 function command($command)
 {
     if (substr($command, -2) == "\r\n") {
         $command = substr($command, 0, -2);
     }
     Swift_Errors::expect($e, "Swift_ConnectionException");
     $rs =& $this->swift->command($command);
     if ($e) {
         $this->setError("Command failed:<br />" . $e->getMessage());
         return false;
     }
     Swift_Errors::clear("Swift_ConnectionException");
     return $rs->getString();
 }
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:19,代码来源:EasySwift.php

示例6: testBytesPerMinuteThrottling

 public function testBytesPerMinuteThrottling()
 {
     $conn = new FullMockConnection();
     for ($i = 0; $i < 10; $i++) {
         $conn->setReturnValueAt($i, "read", "250 xx");
     }
     $swift = new Swift($conn, null, Swift::NO_START);
     set_time_limit(90);
     //60 secs expected + standard 30 secs
     $plugin = new Swift_Plugin_Throttler();
     //Outgoing bytes
     $plugin->setBytesPerMinute(60);
     $swift->attachPlugin($plugin, "throttler");
     $start = time();
     for ($i = 0; $i < 10; $i++) {
         //4 + 2 = 6 bytes each (and 6 x 10 = 60)
         $swift->command("1234");
     }
     $end = time();
     $duration = $end - $start;
     $this->assertTrue($duration >= 60);
     $this->dump("Sending 60 bytes at 60 bytes per minute took " . $duration . " secs");
     //
     $conn = new FullMockConnection();
     for ($i = 0; $i < 10; $i++) {
         $conn->setReturnValueAt($i, "read", "250 xx");
     }
     $swift = new Swift($conn, null, Swift::NO_START);
     set_time_limit(50);
     //20 secs expected + standard 30 secs
     $plugin = new Swift_Plugin_Throttler();
     //Outgoing bytes
     $plugin->setBytesPerMinute(180);
     $swift->attachPlugin($plugin, "throttler");
     $start = time();
     for ($i = 0; $i < 10; $i++) {
         //4 + 2 = 6 bytes each (and 6 x 10 = 60)
         $swift->command("ab c");
     }
     $end = time();
     $duration = $end - $start;
     $this->assertTrue($duration >= 20);
     $this->dump("Sending 60 bytes at 180 bytes per minute took " . $duration . " secs");
 }
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:44,代码来源:Test_OfThrottlerPlugin.php

示例7: testBytesCanBeReset

 /**
  * The counters should be settable through setBytesIn() and setBytesOut().
  */
 public function testBytesCanBeReset()
 {
     $conn = new FullMockConnection();
     //7 chars + 2 for EOL
     $conn->setReturnValueAt(0, "read", "250 foo");
     //15 chars + 2 for EOL
     $conn->setReturnValueAt(1, "read", "221 bye for now");
     $swift = new Swift($conn, null, Swift::NO_START);
     $plugin = new Swift_Plugin_BandwidthMonitor();
     $swift->attachPlugin($plugin, "bwmon");
     //20 chars + 2 for EOL
     $swift->command("abcdefghijklm 123456");
     $this->assertEqual(22, $plugin->getBytesOut());
     $this->assertEqual(9, $plugin->getBytesIn());
     $plugin->setBytesOut(0);
     $this->assertEqual(0, $plugin->getBytesOut());
     //3 chars + 2 for EOL
     $swift->command("bar");
     $this->assertEqual(5, $plugin->getBytesOut());
     $this->assertEqual(26, $plugin->getBytesIn());
     $plugin->setBytesIn(0);
     $this->assertEqual(0, $plugin->getBytesIn());
 }
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:26,代码来源:TestOfBandwidthMonitorPlugin.php


注:本文中的Swift::command方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。