send() abstract public method

Attempts to send a command to the server.
abstract public send ( string $commandText, boolean $includeTag = true, boolean $sendCRLF = true, boolean $continuation = false )
$commandText string Text to send to the server.
$includeTag boolean Determines if command tag is prepended.
$sendCRLF boolean Determines if CRLF is appended.
$continuation boolean Expect a command continuation response.
示例#1
0
文件: Book.php 项目: raz0rsdge/horde
 /**
  * Returns an ACL string containing the rights for the current user
  *
  * @param string $abook Name of address book to retrieve acl.
  *
  * @return mixed acl of current user.
  */
 public function myRights($abook)
 {
     $data = '';
     $this->_imsp->send('MYRIGHTS ADDRESSBOOK ', true, false);
     if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $abook)) {
         $biBook = sprintf("{%d}", strlen($abook));
         $this->_imsp->send($biBook, false, true, true);
     }
     $this->_imsp->send($abook, false, true);
     $server_response = $this->_imsp->receive();
     switch ($server_response) {
         case 'NO':
             // Could not create abook.
             $this->_imsp->_logger->err('IMSP server is unable to perform your request.');
             throw new Horde_Imsp_Exception('IMSP server is unable to perform your request.');
         case 'BAD':
             $this->_imsp->_logger->err('The IMSP server did not understand your request.');
             throw new Horde_Imsp_Exception('The IMSP server did not understand your request.');
     }
     if (!preg_match("/^\\* MYRIGHTS ADDRESSBOOK/", $server_response)) {
         throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
     }
     // {} for the abook name?
     if (preg_match(Horde_Imsp_Client_Base::OCTET_COUNT, $server_response, $tempArray)) {
         $data = $this->_imsp->receiveStringLiteral($tempArray[2]);
         $server_response = $this->_imsp->receive();
     }
     $parts = explode(' ', $server_response);
     // Push the array if we had a {}
     if ($data) {
         array_unshift($parts, ' ', ' ', ' ', ' ');
     }
     // Quoted address book name?
     $numParts = count($parts);
     $name = $parts[3];
     $firstACLIdx = 4;
     $firstChar = substr($name, 0, 1);
     if ($firstChar == "\"") {
         for ($i = 4; $i < $numParts; $i++) {
             $lastChar = substr($parts[$i], strlen($parts[$i]) - 1, 1);
             $firstACLIdx++;
             if ($lastChar == "\"") {
                 break;
             }
         }
     }
     $acl = $parts[$firstACLIdx];
     $server_response = $this->_imsp->receive();
     if ($server_response != 'OK') {
         throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
     } else {
         $this->_imsp->_logger->debug("MYRIGHTS on {$abook} completed.");
         return $acl;
     }
 }
示例#2
0
文件: Options.php 项目: horde/horde
 /**
  * Function sets an option value on the IMSP server.
  *
  * @param string $name  Name of option to set.
  * @param string $value Value to assign.
  *
  * @throws Horde_Imsp_Exception
  */
 public function set($option, $value)
 {
     /* Send the beginning of the command. */
     $this->_imsp->send("SET {$option} ", true, false);
     /* Send $optionValue as a literal {}? */
     if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $value)) {
         $biValue = sprintf("{%d}", strlen($value));
         $result = $this->_imsp->send($biValue, false, true, true);
     }
     /* Now send the rest of the command. */
     $result = $this->_imsp->send($value, false, true);
     $server_response = $this->_imsp->receive();
     if ($server_response != 'OK') {
         throw new Horde_Imsp_Exception('The option could not be set on the IMSP server.');
     }
     $this->_imsp->_logger->debug('SET command OK.');
 }