本文整理汇总了PHP中Tinebase_Helper::jsonDecode方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Helper::jsonDecode方法的具体用法?PHP Tinebase_Helper::jsonDecode怎么用?PHP Tinebase_Helper::jsonDecode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Helper
的用法示例。
在下文中一共展示了Tinebase_Helper::jsonDecode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate($username, $password)
{
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Options: ' . print_r($this->_options, true));
}
$url = isset($this->_options['url']) ? $this->_options['url'] : 'https://localhost/validate/check';
$adapter = new Zend_Http_Client_Adapter_Socket();
$adapter->setStreamContext($this->_options = array('ssl' => array('verify_peer' => isset($this->_options['ignorePeerName']) ? false : true, 'allow_self_signed' => isset($this->_options['allowSelfSigned']) ? true : false)));
$client = new Zend_Http_Client($url, array('maxredirects' => 0, 'timeout' => 30));
$client->setAdapter($adapter);
$params = array('user' => $username, 'pass' => $password);
$client->setParameterPost($params);
try {
$response = $client->request(Zend_Http_Client::POST);
} catch (Zend_Http_Client_Adapter_Exception $zhcae) {
Tinebase_Exception::log($zhcae);
return Tinebase_Auth::FAILURE;
}
$body = $response->getBody();
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Request: ' . $client->getLastRequest());
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Response: ' . $body);
}
if ($response->getStatus() !== 200) {
return Tinebase_Auth::FAILURE;
}
$result = Tinebase_Helper::jsonDecode($body);
if (isset($result['result']) && $result['result']['status'] === true && $result['result']['value'] === true) {
return Tinebase_Auth::SUCCESS;
} else {
return Tinebase_Auth::FAILURE;
}
}
示例2: _prepareParameter
/**
* returns function parameter as object, decode Json if needed
*
* Prepare function input to be an array. Input maybe already an array or (empty) text.
* Starting PHP 7 Zend_Json::decode can't handle empty strings.
*
* @param mixed $_dataAsArrayOrJson
* @return array
*/
protected function _prepareParameter($_dataAsArrayOrJson)
{
return Tinebase_Helper::jsonDecode($_dataAsArrayOrJson);
}
示例3: _decrypt
/**
* decrypts username and password
*
* @param Tinebase_Model_CredentialCache $_cache
* @throws Tinebase_Exception_NotFound
* @throws Tinebase_Exception_SystemGeneric
*/
protected function _decrypt($_cache)
{
if (!extension_loaded('mcrypt')) {
throw new Tinebase_Exception_SystemGeneric('mcrypt extension required');
}
$encryptedData = base64_decode($_cache->cache);
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', '');
mcrypt_generic_init($td, $_cache->key, substr($_cache->getId(), 0, 16));
$jsonEncodedData = trim(mdecrypt_generic($td, $encryptedData));
$cacheData = Tinebase_Helper::jsonDecode($jsonEncodedData);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
if (!isset($cacheData['username']) && !isset($cacheData['password'])) {
throw new Tinebase_Exception_NotFound('could not find valid credential cache');
}
$_cache->username = $cacheData['username'];
$_cache->password = $cacheData['password'];
}