當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。