* @package Horde_Imsp
*/
class Horde_Imsp_Auth_Plaintext extends Horde_Imsp_Auth_Base
{
/**
* Private authentication function. Provides actual
* authentication code.
*
* @return boolean
*/
protected function _authenticate()
{
$userId = $this->_params['username'];
$credentials = $this->_params['password'];
/* Start the command. */
$this->_imsp->send('LOGIN ', true, false);
/* Username as a {}? */
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $userId)) {
$biUser = sprintf('{%d}', strlen($userId));
$result = $this->_imsp->send($biUser, false, true, true);
}
$this->_imsp->send($userId . ' ', false, false);
/* Pass as {}? */
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $credentials)) {
$biPass = sprintf('{%d}', strlen($credentials));
$this->_imsp->send($biPass, false, true, true);
}
$this->_imsp->send($credentials, false, true);
$server_response = $this->_imsp->receive();
if ($server_response != 'OK') {
return false;
}
return true;
}
/**
* Force a logout command to the imsp stream.
*
*/
public function logout()
{
$this->_imsp->logout();
}
/**
* Return the driver type
*
* @return string the type of this IMSP_Auth driver
*/
public function getDriverType()
{
return 'plaintext';
}
}
Horde_Imsp-2.0.10/lib/Horde/Imsp/Client/Base.php 0000664 0001750 0001750 00000012154 13160155210 017244 0 ustar jan jan
* @package Horde_Imsp
*/
abstract class Horde_Imsp_Client_Base
{
const OCTET_COUNT = '/({)([0-9]{1,})(\}$)/';
const MUST_USE_LITERAL = '/[\x80-\xFF\\r\\n\"\\\\]/';
const MUST_QUOTE = '/[\W]/i';
/**
* String containing name/IP address of IMSP host.
*
* @var string
*/
public $host = 'localhost';
/**
* String containing port for IMSP server.
*
* @var string
*/
public $port = '406';
/**
* String buffer containing the last raw NO or BAD response from the
* server.
*
* @var string
*/
public $lastRawError;
/**
* Current command prefix
*
* @var string
*/
protected $_commandPrefix = 'A';
/**
* Current command count
*
* @var integer
*/
protected $_commandCount = 1;
/**
* Currently in-use command tag
*
* @var string
*/
protected $_tag;
/**
* Command tag last used.
*
* @var string
*/
protected $_lastCommandTag = 'undefined';
/**
* Logger
*
* @var Horde_Log_Logger
*/
public $_logger;
/**
* The auth object
*
* @var Horde_Imsp_Auth
*/
protected $_authObj;
/**
* Constructor function.
* Required parameters:
*
* authObj The object to handle the authentication
*
*
* Optional parameters:
*
* server The IMSP host
* port The port the IMSP server listens on
* logger The logger.
*
* @param array $params Hash containing server parameters.
*/
public function __construct(array $params)
{
if (empty($params['authObj'])) {
throw new InvalidArgumentException('Missing required AuthObj');
}
$this->_authObj = $params['authObj'];
if (!empty($params['server'])) {
$this->host = $params['server'];
}
if (!empty($params['port'])) {
$this->port = $params['port'];
}
if (!empty($params['logger'])) {
$this->_logger = $params['logger'];
} else {
$this->_logger = new Horde_Support_Stub();
}
}
/**
* Determines if a string needs to be quoted before sending to the server.
*
* @param string $string String to be tested.
*
* @return string Original string, quoted if needed.
*/
public static function quoteSpacedString($string)
{
if (strpos($string, ' ') !== false ||
preg_match(self::MUST_QUOTE, $string)) {
return '"' . $string . '"';
} else {
return $string;
}
}
/**
* Increments the IMSP command tag token.
*
* @return string Next command tag.
*/
protected function _getNextCommandTag()
{
$this->_lastCommandTag = $this->_tag ? $this->_tag : 'undefined';
return $this->_commandPrefix . sprintf('%04d', $this->_commandCount++);
}
/**
* Close connection and logout from IMSP server.
*/
abstract public function logout();
/**
* Returns the raw capability response from the server.
*
* @return string The raw capability response.
* @throws Horde_Imsp_Exception
*/
abstract public function capability();
/**
* Attempts to send a command to the server.
*
* @param string $commandText Text to send to the server.
* @param boolean $includeTag Determines if command tag is prepended.
* @param boolean $sendCRLF Determines if CRLF is appended.
* @param boolean $continuation Expect a command continuation response.
*
* @throws Horde_Imsp_Exception
*/
abstract public function send($commandText, $includeTag = true, $sendCRLF = true, $continuation = false);
/**
* Receives a single CRLF terminated server response string
*
* @return mixed 'NO', 'BAD', 'OK', raw response.
* @throws Horde_Imsp_Exception
*/
abstract public function receive();
/**
* Retrieves CRLF terminated response from server and splits it into
* an array delimited by a .
*
* @return array The exploded string
*/
abstract public function getServerResponseChunks();
/**
* Receives fixed number of bytes from IMSP socket. Used when server returns
* a string literal.
*
* @param integer $length Number of bytes to read from socket.
*
* @return string Text of string literal.
*/
abstract public function receiveStringLiteral($length);
/**
* Attempts to login to IMSP server.
*
* @param boolean $login Should we remain logged in after auth?
*
* @return boolean
*/
abstract public function authenticate($login = true);
} Horde_Imsp-2.0.10/lib/Horde/Imsp/Client/Mock.php 0000664 0001750 0001750 00000000000 13160155210 017246 0 ustar jan jan Horde_Imsp-2.0.10/lib/Horde/Imsp/Client/Socket.php 0000664 0001750 0001750 00000017734 13160155210 017633 0 ustar jan jan
* @package Horde_Imsp
*/
class Horde_Imsp_Client_Socket extends Horde_Imsp_Client_Base
{
/**
* Stream handle
*
* @var resource
*/
protected $_stream;
/**
*
* @var Horde_Imsp_Auth_Base
*/
protected $_authObj;
/**
* Constructor function.
* Required parameters:
*
* authObj The object to handle the authentication
*
*
* Optional parameters:
*
* server The IMSP host
* port The port the IMSP server listens on
* logger The logger.
*
* @param array $params Hash containing server parameters.
*/
public function __construct(array $params)
{
parent::__construct($params);
$this->_imspOpen();
$this->_logger->debug('Initializing Horde_Imsp object.');
}
/**
* Attempts to login to IMSP server.
*
* @param boolean $login Should we remain logged in after auth?
*
* @return boolean
*/
public function authenticate($login = true)
{
if (!$this->_authObj->authenticate($this, $login)) {
return false;
}
return true;
}
/**
* Logs out of the server and closes the IMSP stream
*/
public function logout()
{
$this->_logger->debug('Closing IMSP Connection.');
$command_string = 'LOGOUT';
$this->send($command_string);
fclose($this->_stream);
}
/**
* Returns the raw capability response from the server.
*
* @return string The raw capability response.
* @throws Horde_Imsp_Exception
*/
public function capability()
{
$command_string = 'CAPABILITY';
$this->send($command_string);
$server_response = $this->receive();
if (preg_match("/^\* CAPABILITY/", $server_response)) {
$capability = preg_replace("/^\* CAPABILITY/", '', $server_response);
$server_response = $this->receive(); //OK
if (!$server_response == 'OK') {
$this->_logger->err('Did not receive the expected response from the server.');
throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
} else {
$this->_logger->debug('CAPABILITY completed OK');
return $capability;
}
}
}
/**
* Attempts to send a command to the server.
*
* @param string $commandText Text to send to the server.
* @param boolean $includeTag Determines if command tag is prepended.
* @param boolean $sendCRLF Determines if CRLF is appended.
* @param boolean $continuation Expect a command continuation response.
*
* @throws Horde_Imsp_Exception
*/
public function send($commandText, $includeTag = true, $sendCRLF = true, $continuation = false)
{
$command_text = '';
if (!$this->_stream) {
throw new Horde_Imsp_Exception('No IMSP connection in place');
}
if ($includeTag) {
$this->_tag = $this->_getNextCommandTag();
$command_text = "$this->_tag ";
}
$command_text .= $commandText;
if ($sendCRLF) {
$command_text .= "\r\n";
}
$this->_logger->debug('C: ' . $command_text);
if (!fputs($this->_stream, $command_text)) {
$this->_logger->err('Connection to IMSP host failed.');
fclose($this->_stream);
throw new Horde_Imsp_Exception('Connection to IMSP host failed');
}
if ($continuation && !preg_match("/^\+/", $this->receive())) {
$this->_logger->err('Did not receive expected command continuation response from IMSP server.');
throw new Horde_Imsp_Exception('Did not receive expected command continuation response from IMSP server.');
}
}
/**
* Receives a single CRLF terminated server response string
*
* @return mixed 'NO', 'BAD', 'OK', raw response.
* @throws Horde_Imsp_Exception
*/
public function receive()
{
if (!$this->_stream) {
throw new Horde_Imsp_Exception('No IMSP connection in place.');
}
$result = fgets($this->_stream, 512);
if (!$result) {
$this->_logger->err('Did not receive the expected response from the server.');
throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
}
$meta = stream_get_meta_data($this->_stream);
if ($meta['timed_out']) {
$this->_logger->err('Connection timed out.');
throw new Horde_Imsp_Exception(Horde_Imsp_Translation::t('Connection timed out!'));
}
$server_response = trim($result);
$this->_logger->debug('S: ' . $server_response);
/* Parse out the response:
* First make sure that this is not for a previous command.
* If it is, it means we did not read all the server responses from
* the last command...read them now, but throw an error. */
while (preg_match("/^" . $this->_lastCommandTag . "/", $server_response)) {
$server_response = trim(fgets($this->_stream, 512));
throw new Horde_Imsp_Exception('Did not receive the expected response from the server: ' . $server_response);
}
$currentTag = $this->_tag;
if (preg_match("/^" . $currentTag . " NO/", $server_response)) {
$this->lastRawError = $server_response;
return 'NO';
}
if (preg_match("/^" . $currentTag . " BAD/", $server_response)) {
$this->_logger->err('The IMSP server did not understand your request.');
$this->lastRawError = $server_response;
return 'BAD';
}
if (preg_match("/^" . $currentTag . " OK/", $server_response)) {
return 'OK';
}
/* If it was not a 'NO', 'BAD' or 'OK' response,
* then it's up to the calling function to decide
* what to do with it. */
return $server_response;
}
/**
* Retrieves CRLF terminated response from server and splits it into
* an array delimited by a .
*
* @return array The exploded string
*/
public function getServerResponseChunks()
{
$server_response = trim(fgets($this->_stream, 512));
$chunks = explode(' ', $server_response);
return $chunks;
}
/**
* Receives fixed number of bytes from IMSP socket. Used when server returns
* a string literal.
*
* @param integer $length Number of bytes to read from socket.
*
* @return string Text of string literal.
*/
public function receiveStringLiteral($length)
{
$literal = '';
do {
$temp = fread($this->_stream, $length);
$length -= strlen($temp);
$literal .= $temp;
} while ($length > 0 && strlen($temp));
$this->_logger->debug('From{}: ' . $literal);
return $literal;
}
/**
* Attempts to open an IMSP socket with the server.
*
* @throws Horde_Imsp_Exception
*/
protected function _imspOpen()
{
$fp = @fsockopen($this->host, $this->port);
if (!$fp) {
$this->_logger->err('Connection to IMSP host failed.');
throw new Horde_Imsp_Exception('Connection to IMSP host failed.');
}
$this->_stream = $fp;
$server_response = $this->receive();
if (!preg_match("/^\* OK/", $server_response)) {
fclose($fp);
$this->_logger->err('Did not receive the expected response from the server.');
}
}
} Horde_Imsp-2.0.10/lib/Horde/Imsp/Book.php 0000664 0001750 0001750 00000124375 13160155210 016057 0 ustar jan jan
* @package Horde_Imsp
*/
class Horde_Imsp_Book
{
/**
* Supported ACLs
*
*/
const ACL_RIGHTS = 'lrwcda';
/**
* Sort order.
*
* @var string
*/
public $sort = 'ascend';
/**
* Horde_Imsp_Client object.
*
* @var Horde_Imsp_Client_Base
*/
protected $_imsp;
/**
* Parameter list.
*
* @var array
*/
protected $_params;
/**
* Constructor function.
*
* @param array $params Hash containing IMSP parameters.
*/
public function __construct(Horde_Imsp_Client_Base $client, array $params)
{
$this->_params = $params;
$this->_imsp = $client;
}
/**
* Returns an array containing the names of all the address books
* available to the logged in user.
*
* @return mixed Array of address book names
*/
public function getAddressBookList()
{
$command_string = 'ADDRESSBOOK *';
$this->_imsp->send($command_string);
/* Iterate through the response and populate an array of
* address book names. */
$server_response = $this->_imsp->receive();
$abooks = array();
while (preg_match("/^\* ADDRESSBOOK/", $server_response)) {
/* If this is an ADDRESSBOOK response, then this will explode as so:
* [0] and [1] can be discarded
* [2] = attributes
* [3] = delimiter
* [4] = address book name
*/
/* First, check for a {} */
if (preg_match(Horde_Imsp_Client_Socket::OCTET_COUNT, $server_response, $tempArray)) {
$abooks[] = $this->_imsp->receiveStringLiteral($tempArray[2]);
/* Get the CRLF at end of ADDRESSBOOK response
* that the {} does not include. */
$this->_imsp->receiveStringLiteral(2);
} else {
$parts = explode(' ', $server_response);
$numParts = count($parts);
$name = $parts[4];
$firstChar = substr($name, 0, 1);
if ($firstChar =="\"") {
$name = ltrim($name, "\"");
for ($i = 5; $i < $numParts; $i++) {
$name .= ' ' . $parts[$i];
$lastChar = substr($parts[$i], strlen($parts[$i]) - 1, 1);
if ($lastChar == "\"") {
$name = rtrim($name, "\"");
break;
}
}
}
$abooks[] = $name;
}
$server_response = $this->_imsp->receive();
}
if ($server_response != 'OK') {
$this->_imsp->_logger->err('Did not receive expected response frm server.');
throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
}
$this->_imsp->_logger->debug('ADDRESSBOOK command OK.');
return $abooks;
}
/**
* Returns an array containing the names that match $search
* critera in the address book named $abook.
*
* @param string $abook Address book name to search.
* @param mixed $search Search criteria either a string (name) or an array
* in the form of 'fieldName' => 'searchTerm'.
*
* @return array Array of names of the entries that match.
* @throws Horde_Imsp_Exception
*/
public function search($abook, $search)
{
//If no field => value pairs, assume we are searching name.
$criteria = array();
if (!is_array($search)) {
$criteria['name'] = $search;
} else {
$criteria = $search;
}
$this->_imsp->send('SEARCHADDRESS ', true, false);
// Do we need to send the abook name as {} ?
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $abook)) {
$biBook = sprintf("{%d}", strlen($abook));
$this->_imsp->send($biBook, false, true, true);
}
//Start parsing the search array.
$this->_imsp->send("$abook", false, false);
$count = count($criteria);
$current = 1;
foreach ($criteria as $search_field => $search) {
$this->_imsp->send(" $search_field ", false, false);
// How about the search term as a {}.
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $search)) {
$biSearch = sprintf("{%d}", strlen($search));
$this->_imsp->send($biSearch, false, true, true);
$this->_imsp->send($search, false, $current == $count);
$current++;
} else {
// Only send the CrLf if this is the last field/search atom.
$this->_imsp->send('"' . $search . '"', false, $current == $count);
$current++;
}
}
// Get the response.
$server_response = $this->_imsp->receive();
$abookNames = array();
while (preg_match("/^\* SEARCHADDRESS/", $server_response)) {
$chopped_response = preg_replace("/^\* SEARCHADDRESS/", '', $server_response);
// Remove any lingering white space in front only.
$chopped_response = ltrim($chopped_response);
// Get rid of any lingering quotes.
$temp = preg_replace("/\"/", '', $chopped_response);
if (preg_match("/({)([0-9]{1,})(\}$)/", $temp, $tempArray)) {
$dataSize = $tempArray[2];
$temp = $this->_imsp->receiveStringLiteral($dataSize);
/* Get the CRLF since {} does not include it. */
$this->_imsp->receiveStringLiteral(2);
}
$abookNames[] = $temp;
// Get the next response line from the server.
$server_response = $this->_imsp->receive();
}
// Should check for OK or BAD here just to be certain.
switch ($server_response) {
case 'BAD':
$this->_imsp->_logger->err('The IMSP server did not understand your request:' . $command_text);
throw new Horde_Imsp_Exception('The IMSP server did not understand your request: ' . $command_text);
case 'NO':
$this->_imsp->_logger->err('IMSP server is unable to perform your request: ' . $this->_imsp->lastRawError);
throw new Horde_Imsp_Exception('IMSP server is unable to perform your request: ' . $this->_imsp->lastRawError);
}
/* This allows for no results */
if (count($abookNames) < 1) {
return $abookNames;
}
$this->_imsp->_logger->debug('SEARCHADDRESS command OK');
// Determine the sort direction and perform the sort.
switch ($this->sort) {
case 'ascend':
sort($abookNames);
break;
case 'descend':
rsort($abookNames);
break;
}
return $abookNames;
}
/**
* Returns an associative array of a single address book entry.
* Note that there will always be a 'name' field.
*
* @param string $abook Name of the address book to search.
* @param string $entryName 'name' attribute of the entry to retrieve
*
* @return array Array containing entry.
* @throws Horde_Imsp_Exception
* @throws Horde_Exception_NotFound
*/
public function getEntry($abook, $entryName)
{
$this->_imsp->send('FETCHADDRESS ', 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, false);
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $entryName)) {
$biName = sprintf("{%d}", strlen($entryName));
$this->_imsp->send($biName, false, true, true);
$this->_imsp->send($entryName, false, true);
} else {
$this->_imsp->send("\"$entryName\"", false, true);
}
$server_response = $this->_imsp->receive();
switch ($server_response) {
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');
case 'NO':
throw new Horde_Exception_NotFound('No entry in this address book matches your query.');
}
// Get the data in an associative array.
$entry = $this->_parseFetchAddressResponse($server_response);
//Get the next server response -- this *should* be the OK response.
$server_response = $this->_imsp->receive();
if ($server_response != 'OK') {
// Unexpected response throw error but still continue on.
$this->_imsp->_logger->err('Did not receive the expected response from the server.');
}
$this->_imsp->_logger->debug('FETCHADDRESS completed OK');
return $entry;
}
/**
* Creates a new address book.
*
* @param string $abookName FULLY QUALIFIED name such 'jdoe.clients' etc...
*
* @throws Horde_Imsp_Exception
*/
public function createAddressBook($abookName)
{
$command_text = 'CREATEADDRESSBOOK ';
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $abookName)) {
$biBook = sprintf("{%d}", strlen($abookName));
$this->_imsp->send($command_text . $biBook, true, true, true);
$this->_imsp->send($abookName, false, true);
} else {
$this->_imsp->send($command_text . $abookName, true, true);
}
$server_response = $this->_imsp->receive();
switch ($server_response) {
case 'OK':
$this->_imsp->_logger->debug('CREATEADDRESSBOOK completed OK');
break;
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.');
default:
// Something unexpected.
$this->_imsp->_logger->err('Did not receive the expected response from the server.');
throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
}
}
/**
* Deletes an address book completely!
*
* @param string $abookName Name of address book to delete.
*
* @throws Horde_Imsp_Exception
*/
public function deleteAddressBook($abookName)
{
$command_text = 'DELETEADDRESSBOOK ';
// Check need for {}.
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $abookName)) {
$biBook = sprintf("{%d}", strlen($abookName));
$this->_imsp->send($command_text . $biBook, true, true, true);
$this->_imsp->send($abookName, false, true);
} else {
$this->_imsp->send($command_text . $abookName, true, true);
}
$server_response = $this->_imsp->receive();
switch ($server_response) {
case 'OK':
$this->_imsp->_logger->debug('DELETEADDRESSBOOK completed OK');
break;
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.');
default:
// Something unexpected.
$this->_imsp->_logger->err('Did not receive the expected response from the server.');
throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
}
}
/**
* Renames an address book.
*
* @param string $abookOldName Old name.
* @param string $abookNewName New address book name.
*
* @throws Horde_Imsp_Exception
*/
public function renameAddressBook($abookOldName, $abookNewName)
{
$this->_imsp->send('RENAMEADDRESSBOOK ', true, false);
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $abookOldName)) {
$biOldName = sprintf("{%d}", strlen($abookOldName));
$this->_imsp->send($biOldName, false, true);
$this->_imsp->receive();
}
$this->_imsp->send("$abookOldName ", false, false);
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $abookNewName)) {
$biNewName = sprintf("{%d}", strlen($abookNewName));
$this->_imsp->send($biNewName, false, true);
$this->_imsp->receive();
}
$this->_imsp->send($abookNewName, false, true);
// Get server response.
$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.');
case 'OK':
$this->_imsp->_logger->debug("Address book $abookOldName successfully changed to $abookNewName");
break;
default:
// Something unexpected.
$this->_imsp->_logger->err('Did not receive the expected response from the server.');
throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
}
}
/**
* Adds an address book entry to an address book.
*
* @param string $abook Name of address book to add entry to.
* @param array $entryInfo Address book entry information -
* there MUST be a field 'name' containing the
* entry name.
*
* @throws Horde_Imsp_Exception
*/
public function addEntry($abook, array $entryInfo)
{
$command_text = '';
// Lock the entry if it already exists.
$this->lockEntry($abook, $entryInfo['name']);
$this->_imsp->send('STOREADDRESS ', true, false);
// Take care of the name.
$entryName = $entryInfo['name'];
// {} for book name?
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $abook)) {
$biBook = sprintf("{%d}", strlen($abook));
$this->_imsp->send($biBook, false, true);
$this->_imsp->receive();
}
$this->_imsp->send("$abook ", false, false);
// Do we need {} for entry name as well?
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $entryName)) {
$biname = sprintf("{%d}", strlen($entryName));
$this->_imsp->send($biname, false, true);
$this->_imsp->receive();
$this->_imsp->send($entryName, false, false);
} else {
$this->_imsp->send("\"$entryName\" ", false, false);
}
foreach ($entryInfo as $key => $value) {
// Do not sent the key name 'name'.
if ($key != 'name') {
// Protect from extraneous white space
$value = trim($value);
// For some reason, tabs seem to break this.
$value = preg_replace("/\t/", "\n\r", $value);
// Check to see if we need {}
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $value)) {
$command_text .= $key . sprintf(" {%d}", strlen($value));
$this->_imsp->send($command_text, false, true);
$server_response = $this->_imsp->receive();
$command_text = '';
if (!preg_match("/^\+/", $server_response)) {
$this->_imsp->_logger->err('Did not receive the expected response from the server.');
throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
}
$this->_imsp->send($value, false, false);
} else {
// If we are here, then we do not need to send a literal.
$value = "\"" . $value . "\"";
$command_text .= $key . ' ' . $value . ' ';
}
}
}
// Send anything that is left of the command.
$this->_imsp->send($command_text, 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 ($server_response != 'OK') {
// Cyrus-IMSP server sends a FETCHADDRESS Response here.
// Do others? This was not in the RFC.
$dummy_array = $this->_parseFetchAddressResponse($server_response);
$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.');
case 'OK':
$this->_imsp->_logger->debug('STOREADDRESS Completed successfully.');
//we were successful...so release the lock on the entry
$this->unlockEntry($abook, $entryInfo['name']);
}
}
}
/**
* Deletes an abook entry.
*
* @param string $abook Name of address book containing entry.
* @param string $bookEntry Name of entry to delete.
*
* @throws Horde_Imsp_Exception
*/
public function deleteEntry($abook, $bookEntry)
{
// Start the command.
$this->_imsp->send('DELETEADDRESS ', true, false);
// Need {} for book name?
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, false);
//How bout for the entry name?
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $bookEntry)) {
$biEntry = sprintf("{%d}", strlen($bookEntry));
$this->_imsp->send($biEntry, false, true, true);
} else {
$bookEntry = $this->_imsp->quoteSpacedString($bookEntry);
}
$this->_imsp->send($bookEntry, 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.');
case 'OK':
$this->_imsp->_logger->debug('DELETE Completed successfully.');
}
}
/**
* Attempts to acquire a semaphore on the address book entry.
*
* @param string $abook Address book name
* @param string $bookEntry Name of entry to lock
*
* @return mixed true or array on success (depends on server in use).
*/
public function lockEntry($abook, $bookEntry)
{
$this->_imsp->send('LOCK ADDRESSBOOK ', true, false);
// Do we need a string literal?
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, false);
// What about the entry name?
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $bookEntry)) {
$biEntry = sprintf("{%d}", strlen($bookEntry));
$this->_imsp->send($biEntry, false, true, true);
$this->_imsp->send($bookEntry, false, true);
} else {
$bookEntry = $this->_imsp->quoteSpacedString($bookEntry);
$this->_imsp->send("$bookEntry", false, true);
}
$server_response = $this->_imsp->receive();
do {
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.');
}
//Check to see if this is a FETCHADDRESS resonse
$dummy = $this->_parseFetchAddressResponse($server_response);
if ($dummy) {
$server_response = $this->_imsp->receive();
}
} while ($server_response != 'OK');
$this->_imsp->_logger->debug("LOCK ADDRESSBOOK on $abook $bookEntry OK");
// Return either true or the FETCHADDRESS response if it exists.
if (!$dummy) {
return true;
} else {
return $dummy;
}
}
/**
* Unlocks a previously locked address book.
*
* @param string $abook Name of address book containing locked entry.
* @param string $bookEntry Name of entry to unlock.
*
* @throws Horde_Imsp_Exception
*/
public function unlockEntry($abook, $bookEntry)
{
// Start sending command.
$this->_imsp->send('UNLOCK ADDRESSBOOK ', true, false);
// {} for book name?
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, false);
//How bout for entry name?
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $bookEntry)) {
$biEntry=sprintf("{%d}", strlen($bookEntry));
$this->_imsp->send($biEntry, false, true, true);
$this->_imsp->send($bookEntry, false, true);
} else {
$bookEntry = $this->_imsp->quoteSpacedString($bookEntry);
$this->_imsp->send("$bookEntry", false, true);
}
$response = $this->_imsp->receive();
switch ($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.');
case 'OK':
$this->_imsp->_logger->debug("UNLOCK ADDRESSBOOK on $abook $bookEntry OK");
}
}
/**
* Access Control List (ACL) Methods.
*
* The following characters are recognized ACL characters: lrwcda
* l - "lookup" (see the name and existence of the address book)
* r - "read" (search and retrieve addresses from address book)
* w - "write" (create/edit new address book entries - not delete)
* c - "create" (create new address books under the current address book)
* d - "delete" (delete entries or entire book)
* a - "admin" (set ACL lists for this address book - usually only
* allowed for the owner of the address book)
*
* examples:
* "lr" would be read only for that user
* "lrw" would be read/write
*/
/**
* Sets an Access Control List for an abook.
*
* @param string $abook Name of address book.
* @param string $ident Name of user for this acl.
* @param string $acl acl for this user/book.
*
* @return mixed True on success / PEAR_Error on failure.
*/
public function setACL($abook, $ident, $acl)
{
// Verify that $acl looks good.
if (preg_match("/[^" . self::ACL_RIGHTS . "]/", $acl)) {
$this->_imsp->_logger('Bad Argument');
throw new InvalidArgumentException();
}
// Begin sending command.
$this->_imsp->send('SETACL ADDRESSBOOK ', true, false);
// {} for book name?
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, false);
// {} for ident?
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $ident)) {
$biIdent = sprintf("{%d}", strlen($ident));
$this->_imsp->send($biIdent, false, true, true);
}
$this->_imsp->send("$ident ", false, false);
// Now finish up with the actual ACL.
$this->_imsp->send($acl, false, true);
$response = $this->_imsp->receive();
switch ($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.');
case 'OK':
$this->_imsp->_logger->debug("ACL set for $ident on $abook");
break;
default:
// Do not know why we would make it down here.
$this->_imsp->_logger->err('Did not receive the expected response from the server.');
throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
}
}
/**
* Retrieves an address book's ACL.
*
* @param string $abook Name of address book to retrieve acl for.
*
* @return mixed array containing acl for every user with access to
* address book or PEAR_Error on failure.
*/
public function getACL($abook)
{
$this->_imsp->send('GETACL ADDRESSBOOK ', true, false);
// {} for book name?
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $abook)) {
$biName = sprintf("{%d}", strlen($abook));
$this->_imsp->send($biName, false, true, true);
}
$this->_imsp->send($abook, false, true);
// Get results.
$response = $this->_imsp->receive();
switch ($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 we are here, we need to receive the * ACL Responses.
do {
/* Get an array of responses.
* The [3] element should be the address book name
* [4] and [5] will be user/group name and permissions */
//the book name might be a literal
if (preg_match(Horde_Imsp_Client_Base::OCTET_COUNT, $response, $tempArray)) {
$data = $this->_imsp->receiveStringLiteral($tempArray[2]);
$response = $this->_imsp->receive();
}
$parts = explode(' ', $response);
// Push the array if book was a literal
if ($data) {
array_unshift($parts, ' ', ' ', ' ', ' ');
}
// Address book name quoted?
$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;
}
}
}
for ($i = $firstACLIdx; $i < count($parts); $i += 2) {
$results[$parts[$i]] = $parts[$i+1];
}
$response = $this->_imsp->receive();
} while (preg_match("/^\* ACL ADDRESSBOOK/", $response));
// Hopefully we can receive an OK response here
if ($response != 'OK') {
// Some weird problem
throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
}
$this->_imsp->_logger->debug("GETACL on $abook completed.");
return $results;
}
/**
* Deletes an ACL entry for an address book.
*
* @param string $abook Name of the address book.
* @param string $ident Name of entry to remove acl for.
*
* @throws Horde_Imsp_Exception
*/
function deleteACL($abook, $ident)
{
$this->_imsp->send('DELETEACL ADDRESSBOOK ', true, false);
// Do we need literal for address book name?
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, false);
// Literal for ident name?
if (preg_match(Horde_Imsp_Client_Base::MUST_USE_LITERAL, $ident)) {
$biIdent = sprintf("{%d}", strlen($ident));
$this->_imsp->send($biIdent, false, true, true);
$this->_imsp->send($ident, false, true);
} else {
$this->_imsp->send("\"$ident\"", false, true);
}
// Get results.
$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.');
case 'OK':
$this->_imsp->_logger->debug("DELETED ACL for $ident on $abook");
default:
throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
}
}
/**
* 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;
}
}
/**
* Parses a IMSP fetchaddress response text string into key-value pairs
*
* @param string $server_response The raw fetchaddress response.
*
* @return array Address book entry information as key=>value pairs.
*/
protected function _parseFetchAddressResponse($server_response)
{
$abook = '';
if (!preg_match("/^\* FETCHADDRESS /", $server_response)) {
$this->_imsp->_logger->err('Did not receive a FETCHADDRESS response from server.');
throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
}
/* NOTES
* Parse out the server response string
*
* After choping off the server command response tags and
* explode()'ing the server_response string
* the $parts array contains the chunks of the server returned data.
*
* The predifined 'name' field starts in $parts[1].
* The server should return any single item of data
* that contains spaces within it as a double quoted string.
* So we can interpret the existence of a double quote at the beginning
* of a chunk to mean that the next chunk(s) are part of
* the same value. A double quote at the end of a chunk signifies the
* end of that value and the chunk following that can be interpreted
* as a key name.
*
* We also need to watch for the server returning a {} response for the
* value of the key as well. */
// Was the address book name a {}?
if (preg_match("/(^\* FETCHADDRESS )({)([0-9]{1,})(\}$)/",
$server_response, $tempArray)) {
$abook = $this->_imsp->receiveStringLiteral($tempArray[3]);
$chopped_response = trim($this->_imsp->receive());
} else {
// Take off the stuff from the beginning of the response
$chopped_response = trim(preg_replace("/^\* FETCHADDRESS /", '', $server_response));
}
$parts = explode(' ', $chopped_response);
/* If addres book was sent as a {} then we must 'push' a blank
* value to the start of this array so the rest of the routine
* will work with the correct indexes. */
if (!empty($abook)) {
array_unshift($parts, ' ');
}
// Was the address book name quoted?
$numOfParts = count($parts);
$name = $parts[0];
$firstNameIdx = 1;
$firstChar = substr($name, 0, 1);
if ($firstChar =="\"") {
for ($i = 1; $i < $numOfParts; $i++) {
$lastChar = substr($parts[$i], strlen($parts[$i]) - 1, 1);
$firstNameIdx++;
if ($lastChar == "\"") {
break;
}
}
}
// Now start working on the entry name
$name = $parts[$firstNameIdx];
$firstChar = substr($name,0,1);
// Check to see if the first char of the name string is a double quote
// so we know if we have to extract more of the name.
if ($firstChar == "\"") {
$name = ltrim($name, "\"");
for ($i = $firstNameIdx + 1; $i < $numOfParts; $i++) {
$name .= ' ' . $parts[$i];
$lastChar = substr($parts[$i], strlen($parts[$i]) - 1,1);
if ($lastChar == "\"") {
$name = rtrim($name, "\"");
$nextKey = $i + 1;
break;
}
}
// Check for {}
} elseif (preg_match('/\{(\d+)\}/', $name, $matches)) {
$name = $this->_imsp->receiveStringLiteral($matches[1]);
$response=$this->_imsp->receive();
$parts = explode(' ', $response);
$numOfParts = count($parts);
$nextKey = 0;
} else {
// If only one chunk for 'name' then we just have to point
// to the next chunk in the array...which will hopefully
// be '2'
$nextKey = $firstNameIdx + 1;
}
$lastChar = '';
$entry['name'] = $name;
// Start parsing the rest of the response.
for ($i = $nextKey; $i < $numOfParts; $i += 2) {
$key = $parts[$i];
/* Check for {} */
if (@preg_match(Horde_Imsp_Client_Base::OCTET_COUNT, $parts[$i+1], $tempArray)) {
$server_data = $this->_imsp->receiveStringLiteral($tempArray[2]);
$entry[$key] = $server_data;
/* Read any remaining data from the stream and reset
* the counter variables so the loop will continue
* correctly. Note we set $i to -2 because it will
* be incremented by 2 before the loop will run again */
$parts = $this->_imsp->getServerResponseChunks();
$i = -2;
$numOfParts = count($parts);
} else {
// Not a string literal response
@$entry[$key] = $parts[$i + 1];
// Check to see if the value started with a double
// quote. We also need to check if the last char is a
// quote to make sure we REALLY have to check the next
// elements for a closing quote.
if ((@substr($parts[$i + 1], 0, 1) == '"') &&
(substr($parts[$i + 1],
strlen($parts[$i + 1]) - 1, 1) != '"')) {
do {
$nextElement = $parts[$i+2];
// Was this element the last one?
$lastChar = substr($nextElement, strlen($nextElement) - 1, 1);
$entry[$key] .= ' ' . $nextElement;
// NOW, we can check the lastChar.
if ($lastChar == '"') {
$done = true;
$i++;
} else {
// Check to see if the next element is the
// last one. If so, the do loop will terminate.
$done = false;
$lastChar = substr($parts[$i+3], strlen($parts[$i+3]) - 1,1);
$i++;
}
} while ($lastChar != '"');
// Do we need to add the final element, or were
// there only two total?
if (!$done) {
$nextElement = $parts[$i+2];
$entry[$key] .= ' ' . $nextElement;
$i++;
}
// Remove the quotes sent back to us from the server.
if (substr($entry[$key], 0, 1) == '"') {
$entry[$key] = substr($entry[$key], 1, strlen($entry[$key]) - 2);
}
if (substr($entry[$key], strlen($entry[$key]) - 1, 1) == '"') {
$entry[$key] = substr($entry[$key], 0, strlen($entry[$key]) - 2);
}
} elseif ((@substr($parts[$i + 1], 0, 1) == '"') &&
(substr($parts[$i + 1], -1, 1) == '"')) {
// Remove the quotes sent back to us from the server.
if (substr($entry[$key], 0, 1) == '"') {
$entry[$key] = substr($entry[$key], 1, strlen($entry[$key]) - 2);
}
if (substr($entry[$key], -1, 1) == '"') {
$entry[$key] = substr($entry[$key], 0, strlen($entry[$key]) - 2);
}
}
}
}
return $entry;
}
}
Horde_Imsp-2.0.10/lib/Horde/Imsp/Exception.php 0000664 0001750 0001750 00000000611 13160155210 017105 0 ustar jan jan
* @package Horde_Imsp
*/
class Horde_Imsp_Exception extends Horde_Exception_Wrapped
{
} Horde_Imsp-2.0.10/lib/Horde/Imsp/Options.php 0000664 0001750 0001750 00000010673 13160155210 016613 0 ustar jan jan
* @package Horde_Imsp
*/
class Horde_Imsp_Options
{
/**
* Horde_Imsp object.
*
* @var Horde_Imsp_Client_Base
*/
protected $_imsp;
/**
* Parameter list.
*
* @var array
*/
protected $_params;
/**
* Constructor.
*
* @param Horde_Imsp_Client_base $client The client connection.
* @param array $params Hash containing IMSP parameters.
*/
public function __construct(Horde_Imsp_Client_Base $client, array $params)
{
$this->_params = $params;
$this->_imsp = $client;
$this->_imsp->_logger->debug('Horde_Imsp_Options initialized.');
}
/**
* Function sends a GET command to IMSP server and retrieves values.
*
* @param string $option Name of option to retrieve. Accepts '*' as wild
* card.
*
* @return array Hash containing option=>value pairs.
* @throws Horde_Imsp_Exception
*/
public function get($option)
{
$options = array();
$this->_imsp->send("GET $option", true, true);
$server_response = $this->_imsp->receive();
while (preg_match("/^\* OPTION/", $server_response)) {
/* First, check for a {}. */
if (preg_match(Horde_Imsp_Client_Base::OCTET_COUNT, $server_response, $tempArray)) {
$temp = explode(' ', $server_response);
$options[$temp[2]] = $this->_imsp->receiveStringLiteral($tempArray[2]);
$this->_imsp->receive();
} else {
$temp = explode(' ', $server_response);
$options[$temp[2]] = trim($temp[3]);
$i = 3;
$lastChar = "";
$nextElement = trim($temp[3]);
/* Was the value quoted and spaced? */
if ((substr($nextElement, 0, 1) == '"') &&
(substr($nextElement, strlen($nextElement) - 1, 1) != '"')) {
do {
$nextElement = $temp[$i + 1];
$lastChar = substr($nextElement, strlen($nextElement) - 1, 1);
$options[$temp[2]] .= ' ' . $nextElement;
if ($lastChar == '"') {
$done = true;
} else {
$done = false;
$lastChar = substr($temp[$i + 2], strlen($temp[$i + 2]) - 1, 1);
$i++;
}
} while ($lastChar != '"');
if (!$done) {
$nextElement = $temp[$i + 1];
$options[$temp[2]] .= ' ' . $nextElement;
}
}
}
$server_response = $this->_imsp->receive();
}
if ($server_response != 'OK') {
throw new Horde_Imsp_Exception('Did not receive the expected response from the server.');
}
$this->_imsp->_logger->debug('GET command OK.');
return $options;
}
/**
* 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.');
}
public function logout()
{
$this->_imsp->logout();
}
}
Horde_Imsp-2.0.10/lib/Horde/Imsp/Translation.php 0000664 0001750 0001750 00000001373 13160155210 017453 0 ustar jan jan
* @package Horde_Imsp
*/
class Horde_Imsp_Translation extends Horde_Translation_Autodetect
{
/**
* The translation domain
*
* @var string
*/
protected static $_domain = 'Horde_Imsp';
/**
* The absolute PEAR path to the translations for the default gettext handler.
*
* @var string
*/
protected static $_pearDirectory = '@data_dir@';
}
Horde_Imsp-2.0.10/locale/ar/LC_MESSAGES/Horde_Imsp.mo 0000664 0001750 0001750 00000000577 13160155210 017746 0 ustar jan jan $ , 8 E 9 Project-Id-Version: Horde_Net_IMSP
Report-Msgid-Bugs-To: dev@lists.horde.org
POT-Creation-Date: 2010-10-13 01:27+0200
PO-Revision-Date: 2010-10-13 01:27+0200
Last-Translator: Automatically generated
Language-Team: i18n@lists.horde.org
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Horde_Imsp-2.0.10/locale/ar/LC_MESSAGES/Horde_Imsp.po 0000664 0001750 0001750 00000001511 13160155210 017736 0 ustar jan jan # Arabic translations for Horde_Net_IMSP module.
# Copyright 2010-2017 Horde LLC (http://www.horde.org/)
# This file is distributed under the same license as the Horde_Net_IMSP module.
# Automatically generated, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: Horde_Net_IMSP\n"
"Report-Msgid-Bugs-To: dev@lists.horde.org\n"
"POT-Creation-Date: 2010-10-13 01:27+0200\n"
"PO-Revision-Date: 2010-10-13 01:27+0200\n"
"Last-Translator: Automatically generated\n"
"Language-Team: i18n@lists.horde.org\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: IMSP/Book.php:1308
msgid "The IMSP log could not be initialized."
msgstr ""
#: IMSP.php:458 IMSP/Auth.php:144
#, fuzzy, php-format
msgid "Unable to load the definition of %s."
msgstr "لا إمكانية لقراءة مجلد vfsroot."
Horde_Imsp-2.0.10/locale/bg/LC_MESSAGES/Horde_Imsp.mo 0000664 0001750 0001750 00000000577 13160155210 017734 0 ustar jan jan $ , 8 E 9 Project-Id-Version: Horde_Net_IMSP
Report-Msgid-Bugs-To: dev@lists.horde.org
POT-Creation-Date: 2010-10-13 01:27+0200
PO-Revision-Date: 2010-10-13 01:27+0200
Last-Translator: Automatically generated
Language-Team: i18n@lists.horde.org
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Horde_Imsp-2.0.10/locale/bg/LC_MESSAGES/Horde_Imsp.po 0000664 0001750 0001750 00000001512 13160155210 017725 0 ustar jan jan # Bulgarian translations for Horde_Net_IMSP module.
# Copyright 2010-2017 Horde LLC (http://www.horde.org/)
# This file is distributed under the same license as the Horde_Net_IMSP module.
# Automatically generated, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: Horde_Net_IMSP\n"
"Report-Msgid-Bugs-To: dev@lists.horde.org\n"
"POT-Creation-Date: 2010-10-13 01:27+0200\n"
"PO-Revision-Date: 2010-10-13 01:27+0200\n"
"Last-Translator: Automatically generated\n"
"Language-Team: i18n@lists.horde.org\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: IMSP/Book.php:1308
msgid "The IMSP log could not be initialized."
msgstr ""
#: IMSP.php:458 IMSP/Auth.php:144
#, fuzzy, php-format
msgid "Unable to load the definition of %s."
msgstr "Грешка при изтриване '%s': %s."
Horde_Imsp-2.0.10/locale/bs/LC_MESSAGES/Horde_Imsp.mo 0000664 0001750 0001750 00000000577 13160155210 017750 0 ustar jan jan $ , 8 E 9 Project-Id-Version: Horde_Net_IMSP
Report-Msgid-Bugs-To: dev@lists.horde.org
POT-Creation-Date: 2010-10-13 01:27+0200
PO-Revision-Date: 2010-10-13 01:27+0200
Last-Translator: Automatically generated
Language-Team: i18n@lists.horde.org
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Horde_Imsp-2.0.10/locale/bs/LC_MESSAGES/Horde_Imsp.po 0000664 0001750 0001750 00000001421 13160155210 017740 0 ustar jan jan # Bosnian translations for Horde_Net_IMSP module.
# Copyright 2010-2017 Horde LLC (http://www.horde.org/)
# This file is distributed under the same license as the Horde_Net_IMSP module.
# Automatically generated, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: Horde_Net_IMSP\n"
"Report-Msgid-Bugs-To: dev@lists.horde.org\n"
"POT-Creation-Date: 2010-10-13 01:27+0200\n"
"PO-Revision-Date: 2010-10-13 01:27+0200\n"
"Last-Translator: Automatically generated\n"
"Language-Team: i18n@lists.horde.org\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: IMSP/Book.php:1308
msgid "The IMSP log could not be initialized."
msgstr ""
#: IMSP.php:458 IMSP/Auth.php:144
#, php-format
msgid "Unable to load the definition of %s."
msgstr ""
Horde_Imsp-2.0.10/locale/ca/LC_MESSAGES/Horde_Imsp.mo 0000664 0001750 0001750 00000001106 13160155210 017714 0 ustar jan jan 4 L ` &