Ejemplo n.º 1
0
 /**
  * Decodes the given $encodedValue string which is
  * encoded in the JSON format
  *
  * Uses ext/json's json_decode if available.
  *
  * @param string $encodedValue Encoded in JSON format
  * @param int $objectDecodeType Optional; flag indicating how to decode
  * objects. See {@link Zend_Json_Decoder::decode()} for details.
  * @return mixed
  */
 public static function decode($encodedValue, $objectDecodeType = Zend_Json::TYPE_ARRAY)
 {
     $encodedValue = (string) $encodedValue;
     if (function_exists('json_decode') && self::$useBuiltinEncoderDecoder !== true) {
         $decode = json_decode($encodedValue, $objectDecodeType);
         // php < 5.3
         if (!function_exists('json_last_error')) {
             if ($decode === $encodedValue) {
                 throw new Zend_Json_Exception('Decoding failed');
             }
             // php >= 5.3
         } elseif (($jsonLastErr = json_last_error()) != JSON_ERROR_NONE) {
             switch ($jsonLastErr) {
                 case JSON_ERROR_DEPTH:
                     throw new Zend_Json_Exception('Decoding failed: Maximum stack depth exceeded');
                 case JSON_ERROR_CTRL_CHAR:
                     throw new Zend_Json_Exception('Decoding failed: Unexpected control character found');
                 case JSON_ERROR_SYNTAX:
                     throw new Zend_Json_Exception('Decoding failed: Syntax error');
                 default:
                     throw new Zend_Json_Exception('Decoding failed');
             }
         }
         return $decode;
     }
     return Zend_Json_Decoder::decode($encodedValue, $objectDecodeType);
 }
Ejemplo n.º 2
0
 public function _fetchPersonalInfo()
 {
     $faculty_id = $this->getFacultyId();
     $cache = self::getCache('remote');
     $facultyPersonal = $cache->load('facultyPersonal');
     // see if a cache already exists:
     if ($facultyPersonal === false or !isset($facultyPersonal[$faculty_id])) {
         $PROTOCOL = 'http://';
         $URL_STAFF_INFO = $PROTOCOL . CORE_SERVER . '/staff/getinfo' . "?staff_id={$faculty_id}";
         $client = new Zend_Http_Client($URL_STAFF_INFO);
         $client->setCookie('PHPSESSID', $_COOKIE['PHPSESSID']);
         $response = $client->request();
         if ($response->isError()) {
             $remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getMessage();
             Zend_Registry::get('logger')->err($remoteErr);
             throw new Zend_Exception($remoteErr, Zend_Log::ERR);
         } else {
             $jsonContent = $response->getBody();
             $facultyInfo = Zend_Json_Decoder::decode($jsonContent);
             $facultyPersonal[$faculty_id] = $facultyInfo;
             $cache->save($facultyPersonal, 'facultyPersonal');
         }
     }
     return $facultyPersonal[$faculty_id];
 }
Ejemplo n.º 3
0
 /**
  * @return AM_Mapper_Sqlite_Element
  */
 protected function _unmapCustom()
 {
     $sContentText = null;
     $oElementDataSet = $this->getModel()->getResources();
     /* @var $oElementDataSet AM_Model_Db_Element_Data_Abstract */
     foreach ($oElementDataSet->getData() as $oElementData) {
         /* @var $oElementData AM_Model_Db_Element_Data_Abstract */
         if (AM_Model_Db_Element_Data_Resource::PDF_INFO == $oElementData->key_name) {
             if (!empty($oElementData->value)) {
                 $aPdfInfo = Zend_Json_Decoder::decode($oElementData->value, true);
                 $sContentText = $aPdfInfo['text'];
             }
         }
         $sElementDataMapperClassName = self::ELEMENT_DATA_MAPPER_CLASS_PREFIX . Zend_Filter::filterStatic($oElementData->key_name, 'Word_UnderscoreToCamelCase');
         if (class_exists($sElementDataMapperClassName, true)) {
             $oElementDataMapper = new $sElementDataMapperClassName($oElementData, array('adapter' => $this->_getAdapter()));
             $oElementDataMapper->unmap();
             continue;
         }
         $aData = array('element_id' => $this->getModel()->id, 'type' => $oElementData->key_name, 'value' => $oElementDataSet->getDataValueForExport($oElementData->key_name), 'position_id' => 0);
         $this->_getSqliteGateway('element_data')->insert($aData);
     }
     $aData = array('id' => $this->getModel()->id, 'page_id' => $this->getModel()->page, 'element_type_name' => $this->getModel()->getFieldTypeTitle(), 'weight' => intval($this->getModel()->weight), 'content_text' => $sContentText);
     $this->_getSqliteGateway()->insert($aData);
     return $this;
 }
 public function testPoolsNoMonetaryUserAction()
 {
     $this->loginByUserId(App_Test_PHPUnit_Framework_TestCase::PROVIDER_NO_MONETARY_USER_ID);
     $this->get(self::NS . '/pools', array('id' => 234));
     $body = $this->getResponse()->getBody();
     $pool = Zend_Json_Decoder::decode($body);
     $this->assertNotEmpty($pool);
     $this->assertNotEmpty($pool['data']);
     $this->assertEmpty(@$pool['totalExpense']);
     $this->assertEmpty(@$pool['dataExpense']);
     $this->assertEmpty(@$pool['smsExpense']);
     $this->assertEmpty(@$pool['voiceExpense']);
     $this->assertEmpty(@$pool['expenseTimestamp']);
     $pool = $pool['data'];
     $pools = array('dataPools', 'smsPools', 'voiceOriginatedPools', 'voiceTerminatedPools');
     foreach ($pools as $poolInformation) {
         $this->assertNotEmpty($pool[$poolInformation]);
         $poolInformation = current($pool[$poolInformation]);
         $this->assertNotEmpty($poolInformation['zoneGroupId']);
         $this->assertNotEmpty($poolInformation['zoneGroupName']);
         $this->assertNotEmpty($poolInformation['consumption']);
         $this->assertEmpty(@$poolInformation['expense']);
         $this->assertEmpty(@$poolInformation['q1Absolute']);
     }
     $this->assertNotEmpty($pool['lastPoolTimestamp']);
     $this->assertResponseCode("200");
 }
Ejemplo n.º 5
0
 public function viewemailidsAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout()->disableLayout();
     $member_ids = array(1, 2, 3, 4, 5);
     $httpClient = new Zend_Http_Client('http://' . CORE_SERVER . '/student/fetchemailids');
     //$httpClient->setCookie('PHPSESSID', $_COOKIE['PHPSESSID']);
     $httpClient->setMethod('POST');
     $call_back = 'viewbatchinfo';
     $httpClient->setParameterPost(array('member_ids' => $member_ids, 'format' => 'json', 'call_back' => $call_back));
     $response = $httpClient->request();
     if ($response->isError()) {
         $remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getHeader('Message') . $response->getBody();
         throw new Zend_Exception($remoteErr, Zend_Log::ERR);
     } else {
         $jsonContent = $response->getBody($response);
         Zend_Registry::get('logger')->debug($jsonContent);
         Zend_Registry::get('logger')->debug(Zend_Json_Decoder::decode($jsonContent));
         Zend_Registry::get('logger')->debug(json_decode($jsonContent));
         /*Zend_Registry::get('logger')->debug(
           Zend_Json_Decoder::decode($jsonContent));*/
         /*$r = Zend_Json_Decoder::decode($jsonContent);
           $batch_info = $r['batch_info'];
           Zend_Registry::get('logger')->debug($batch_info);*/
     }
 }
Ejemplo n.º 6
0
 /**
  * Constructeur de la classe
  *
  * @access public
  * @author Mathieu Desvé, <*****@*****.**>
  * @param  array|object|Zend_Db_Table_Row_Abstract|string vo Object permettant de remplire l'instance
  * @return mixed
  */
 public function __construct($vo = array())
 {
     if ($vo instanceof Zend_Db_Table_Row_Abstract) {
         $vo = $vo->toArray();
     }
     if (is_string($vo) && preg_match('/^\\{("(\\.|[^"\\\\n\\r])*?"|[,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t])+?\\}$/', $vo)) {
         $vo = Zend_Json_Decoder::decode($vo, Zend_Json::TYPE_ARRAY);
     }
     if (is_array($vo)) {
         foreach ($vo as $key => $value) {
             $key = $this->_getKey($key);
             if ($key) {
                 $this->{$key} = $value;
             }
         }
     } elseif (is_object($vo)) {
         foreach ($vo as $key => $value) {
             $key = $this->_getKey($key);
             if ($key) {
                 $this->{$key} = $value;
             }
         }
     } else {
         throw new Vo_Exception('Invalide type of comment parameter in contructor.', 3);
     }
 }
Ejemplo n.º 7
0
 /**
  * Call path (with optional parameters) on base url using the given method.
  *
  * @throws Zend_Http_Client_Exception
  * @param $path URL path
  * @param string $method POST|GET|PUT|DELETE
  * @param bool|array $args Optional parameters for PUT/POST requests
  * @return mixed
  */
 public function call($path, $method = 'GET', $args = false, $verbose = false)
 {
     $client = $this->getClient();
     $client->setUri($this->_getClientUrl() . $path);
     if ($verbose) {
         echo "### URL: " . $this->_getClientUrl() . $path . "\n";
     }
     if ($args && ($method == 'POST' || $method == 'PUT')) {
         foreach ($args as $k => $v) {
             $client->setParameterPost($k, $v);
         }
     } else {
         if ($args && $method == 'GET') {
             foreach ($args as $k => $v) {
                 $client->setParameterGet($k, $v);
             }
         }
     }
     try {
         $result = $client->request($method);
         if ($verbose) {
             echo "###Result:\n";
             var_dump($result->getBody());
             echo "###\n\n";
         }
         if (!$result->isSuccessful()) {
             throw new Exception('API request failed miserably', $result->getStatus());
         }
         return Zend_Json_Decoder::decode($result->getBody());
     } catch (Zend_Http_Client_Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 8
0
 /**
  * Decodes the given $encodedValue string which is
  * encoded in the JSON format
  *
  * Uses ext/json's json_decode if available.
  *
  * @param string $encodedValue Encoded in JSON format
  * @param int $objectDecodeType Optional; flag indicating how to decode
  * objects. See {@link ZJsonDecoder::decode()} for details.
  * @return mixed
  */
 public static function decode($encodedValue, $objectDecodeType = Zend_Json::TYPE_ARRAY)
 {
     if (function_exists('json_decode') && self::$useBuiltinEncoderDecoder !== true) {
         return json_decode($encodedValue, $objectDecodeType);
     }
     import('lib.Json.Decoder');
     return Zend_Json_Decoder::decode($encodedValue, $objectDecodeType);
 }
Ejemplo n.º 9
0
 /**
  * Decodes the given $encodedValue string which is
  * encoded in the JSON format
  *
  * Uses ext/json's json_decode if available.
  *
  * @param string $encodedValue Encoded in JSON format
  * @param int $objectDecodeType Optional; flag indicating how to decode
  * objects. See {@link ZJsonDecoder::decode()} for details.
  * @return mixed
  */
 public static function decode($encodedValue, $objectDecodeType = Zend_Json::TYPE_ARRAY)
 {
     if (function_exists('json_decode')) {
         return json_decode($encodedValue, $objectDecodeType);
     }
     include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Json' . DIRECTORY_SEPARATOR . 'Decoder.php';
     return Zend_Json_Decoder::decode($encodedValue, $objectDecodeType);
 }
Ejemplo n.º 10
0
 /**
  * Decodes the given $encodedValue string which is
  * encoded in the JSON format
  *
  * Uses ext/json's json_decode if available.
  *
  * @param string $encodedValue Encoded in JSON format
  * @param int $objectDecodeType Optional; flag indicating how to decode
  * objects. See {@link ZJsonDecoder::decode()} for details.
  * @return mixed
  */
 public static function decode($encodedValue, $objectDecodeType = Zend_Json::TYPE_ARRAY)
 {
     if (function_exists('json_decode')) {
         return json_decode($encodedValue, $objectDecodeType);
     }
     include_once 'Zend/Json/Decoder.php';
     return Zend_Json_Decoder::decode($encodedValue, $objectDecodeType);
 }
Ejemplo n.º 11
0
 /**
  * Decodes the given $encodedValue string which is
  * encoded in the JSON format
  *
  * Uses ext/json's json_decode if available.
  *
  * @param string $encodedValue Encoded in JSON format
  * @param int $objectDecodeType Optional; flag indicating how to decode
  * objects. See {@link Zend_Json_Decoder::decode()} for details.
  * @return mixed
  */
 public static function decode($encodedValue, $objectDecodeType = Zend_Json::TYPE_ARRAY)
 {
     if (function_exists('json_decode') && self::$useBuiltinEncoderDecoder !== true) {
         return json_decode($encodedValue, $objectDecodeType);
     }
     require_once 'Zend/Json/Decoder.php';
     return Zend_Json_Decoder::decode($encodedValue, $objectDecodeType);
 }
 public function testGetVpns()
 {
     $this->loginByUserId(\App_Test_PHPUnit_Framework_TestCase::CUSTOMER_API_ID, $this->_authType);
     $this->get($this->_controllerUrl . '/' . $this->_customerId . '/' . 'vpns', $this->_queryParams);
     $response = $this->getResponse()->getBody();
     $vpns = Zend_Json_Decoder::decode($response);
     $this->assertEquals(array($this->vpns), $vpns['data']);
 }
Ejemplo n.º 13
0
 /** Get the coordinates from an address string
  * @access public
  * @param float $lat
  * @param float $lon
  * @access public
  */
 public function _getElevationApiCall($lat, $lon)
 {
     $client = new Zend_Http_Client();
     $client->setUri(self::ELEVATIONURI);
     $client->setParameterGet('locations', (string) $lon . ',' . (string) $lat)->setParameterGet('sensor', 'false');
     $result = $client->request('GET');
     $response = Zend_Json_Decoder::decode($result->getBody(), Zend_Json::TYPE_OBJECT);
     return $response;
 }
Ejemplo n.º 14
0
 public function save($data)
 {
     $this->_tableMailing->insert($data);
     $idMailing = $this->_tableMailing->getAdapter()->lastInsertId();
     if ($data['template'] == 'contactBusinessman') {
         $data = Zend_Json_Decoder::decode($data['data']);
         $this->_tableMailing->getAdapter()->insert($this->_nameTableBusinessman, array('idmailing' => $idMailing, 'codempr' => $data['codempr']));
     }
 }
Ejemplo n.º 15
0
 function update_method()
 {
     $json = trim($_REQUEST['json']);
     require_once MongoAdmin::$root_path . '/deps/zend_json_decoder.php';
     $vars = Zend_Json_Decoder::decode($json, Zend_Json_Decoder::TYPE_ARRAY);
     $coll = MongoAdmin::db()->selectCollection($_REQUEST['coll']);
     $coll->update(array('_id' => $_REQUEST['doc']), $vars);
     redirect(url('doc.edit', array('coll' => $coll->getName(), 'doc' => $_REQUEST['doc'])));
 }
Ejemplo n.º 16
0
 public function removeAction()
 {
     $data = Zend_Json_Decoder::decode($this->_getParam('data'));
     if (!sizeof($data)) {
         return;
     }
     Axis::single('location/geozone_zone')->delete($this->db->quoteInto('id IN(?)', $data));
     return $this->_helper->json->sendSuccess();
 }
Ejemplo n.º 17
0
 /** Get the coordinates from an address string
  * @access public
  * @param string $address
  */
 public function _getGeocodedLatitudeAndLongitude($address)
 {
     $client = new Zend_Http_Client();
     $client->setUri(self::GEOCODEURI);
     $client->setParameterGet('address', $address)->setParameterGet('sensor', 'false');
     $result = $client->request('GET');
     $response = Zend_Json_Decoder::decode($result->getBody(), Zend_Json::TYPE_OBJECT);
     return $response;
 }
Ejemplo n.º 18
0
 public function removeAction()
 {
     $data = Zend_Json_Decoder::decode($this->_getParam('data'));
     if (!$data) {
         return $this->_helper->json->sendFailure();
     }
     Axis::single('sitemap/sitemap')->delete($this->db->quoteInto('id IN(?)', $data));
     return $this->_helper->json->sendSuccess();
 }
Ejemplo n.º 19
0
 /** Get the coordinates from an address string
  * @param string $address
  */
 public function _getGeocodedLatitudeAndLongitude($address)
 {
     $client = new Zend_Http_Client();
     $client->setUri(self::GEOCODEURI);
     $client->setParameterGet('q', urlencode($address))->setParameterGet('output', 'json')->setParameterGet('sensor', 'false')->setParameterGet('key', (string) $this->_key);
     $result = $client->request('GET');
     $response = Zend_Json_Decoder::decode($result->getBody(), Zend_Json::TYPE_OBJECT);
     return $response;
 }
Ejemplo n.º 20
0
 /**
  * @return AM_Mapper_Sqlite_ElementData_PdfInfo
  */
 protected function _unmapCustom()
 {
     if (!empty($this->getModel()->value)) {
         $aPdfInfo = Zend_Json_Decoder::decode($this->getModel()->value, true);
         $sContentText = $aPdfInfo['text'];
         $this->_unmapPdfInfo($aPdfInfo);
     }
     return $this;
 }
Ejemplo n.º 21
0
 /**
  * Decodes the given $encodedValue string which is
  * encoded in the JSON format
  *
  * Uses ext/json's json_decode if available.
  *
  * @param string $encodedValue Encoded in JSON format
  * @param int $objectDecodeType Optional; flag indicating how to decode
  * objects. See {@link Zend_Json_Decoder::decode()} for details.
  * @return mixed
  */
 public static function decode($encodedValue, $objectDecodeType = Zend_Json::TYPE_ARRAY)
 {
     if (function_exists('json_decode') && self::$useBuiltinEncoderDecoder !== true) {
         $decoded = json_decode($encodedValue, $objectDecodeType);
         return $decoded;
     }
     require_once JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_contentbuilder' . DS . 'classes' . DS . 'Zend' . DS . 'Json' . DS . 'Decoder.php';
     $decoded = Zend_Json_Decoder::decode($encodedValue, $objectDecodeType);
     return $decoded;
 }
 public function getEcodeCdSerials()
 {
     $customer = Mage::getSingleton('customer/session')->getCustomer();
     $json_encoded_ecode_cds = $customer->getEcodesCdSerials();
     if (empty($json_encoded_ecode_cds)) {
         $ecodes_cds = array();
     } else {
         $ecodes_cds = Zend_Json_Decoder::decode($json_encoded_ecode_cds);
     }
     return $ecodes_cds;
 }
Ejemplo n.º 23
0
 public function getGeocodedLatitudeAndLongitude($address)
 {
     $client = new Zend_Http_Client();
     $client->setUri($this->getGeocodeUri());
     $client->setParameterGet('q', urlencode($address))->setParameterGet('output', 'json')->setParameterGet('sensor', 'false')->setParameterGet('key', $this->apiKey);
     $result = $client->request('GET');
     $response = Zend_Json_Decoder::decode($result->getBody(), Zend_Json::TYPE_OBJECT);
     if ($response instanceof stdClass) {
         return $response->Placemark[0]->Point->coordinates;
     }
 }
Ejemplo n.º 24
0
 public function call($method, $args)
 {
     $this->client->setUri(self::URI . '/' . $method);
     // setup all the arguments
     $this->client->setParameterPost('appName', $this->appName);
     foreach ($args as $k => $v) {
         $this->client->setParameterPost($k, $v);
     }
     $this->client->setParameterPost('auth', $this->signArgs($args));
     $result = $this->client->request(self::HTTP_METHOD);
     return Zend_Json_Decoder::decode($result->getBody());
 }
Ejemplo n.º 25
0
 public static function getMemberInfo($memberId)
 {
     $PROTOCOL = 'http://';
     $membership = self::getMembership($memberId);
     $memberType = strtoupper($membership['member_type_id']);
     Zend_Registry::get('logger')->debug($membership);
     $memberInfo = $membership;
     switch ($memberType) {
         case 'STUDENT':
             $URL_STU_INFO = $PROTOCOL . CORE_SERVER . '/student/getinfo' . "?rollno={$memberId}";
             $client = new Zend_Http_Client($URL_STU_INFO);
             $client->setCookie('PHPSESSID', $_COOKIE['PHPSESSID']);
             $response = $client->request();
             if ($response->isError()) {
                 $remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getMessage();
                 Zend_Registry::get('logger')->err($remoteErr);
                 /**
                  * @todo Surpress Remote Error.
                  */
                 //throw new Zend_Exception ( $remoteErr, Zend_Log::ERR );
                 $memberInfo['info'] = array();
                 return $memberInfo;
             }
             $jsonContent = $response->getBody($response);
             $memberInfo['info'] = Zend_Json_Decoder::decode($jsonContent);
             return $memberInfo;
         case 'STAFF':
             $URL_STAFF_INFO = $PROTOCOL . CORE_SERVER . '/staff/getinfo' . "?staff_id={$memberId}";
             $client = new Zend_Http_Client($URL_STAFF_INFO);
             $client->setCookie('PHPSESSID', $_COOKIE['PHPSESSID']);
             $response = $client->request();
             if ($response->isError()) {
                 $remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getMessage();
                 Zend_Registry::get('logger')->err($remoteErr);
                 /**
                  * @todo Surpress Remote Error.
                  */
                 //throw new Zend_Exception ( $remoteErr, Zend_Log::ERR );
                 $memberInfo['info'] = array();
                 return $memberInfo;
             }
             $jsonContent = $response->getBody($response);
             $memberInfo['info'] = Zend_Json_Decoder::decode($jsonContent);
             return $memberInfo;
         case 'BOOKBANK':
             $memberInfo['info'] = array('first_name' => strtoupper($memberId));
             return $memberInfo;
         default:
             throw new Zend_Exception('Unknown member type : "' . $memberType . '"', Zend_Log::WARN);
     }
     // TODO Name, Department etc
 }
Ejemplo n.º 26
0
 public function indexAction()
 {
     $authData = Zend_Auth::getInstance()->getStorage()->read();
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     //!isset($authData ['identity']) and $authData ['identity'] != 'anon'
     if (false) {
         $this->_helper->redirector('index', 'index');
     } else {
         $client = new Zend_Http_Client('http://' . AUTH_SERVER . self::AUTH_PATH . '/check', array('timeout' => 30));
         if (isset($_COOKIE[self::AUTH_SID])) {
             $moduleName = $this->getRequest()->getModuleName();
             $client->setCookie('PHPSESSID', $_COOKIE[self::AUTH_SID]);
             //$client->setCookie('moduleName', $moduleName);
             $response = $client->request();
             if ($response->isError()) {
                 $remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getBody();
                 throw new Zend_Exception($remoteErr, Zend_Log::ERR);
             } else {
                 $jsonContent = $response->getBody();
                 $userInfo = Zend_Json_Decoder::decode($jsonContent);
                 if (!count($userInfo)) {
                     throw new Zend_Exception('No privileges found.', Zend_Log::ERR);
                 }
                 $remoteAcl = new Zend_Session_Namespace('remoteAcl');
                 $remoteAcl->userInfo = $userInfo;
                 if (isset($remoteAcl->redirectedFrom)) {
                     $rdirctdFrom = $remoteAcl->redirectedFrom;
                     $module = $moduleName == $rdirctdFrom['module'] ? '' : $rdirctdFrom['module'] . '/';
                     $controller = $rdirctdFrom['controller'] == 'index' ? '' : $rdirctdFrom['controller'];
                     $action = $rdirctdFrom['action'] == 'index' ? '' : '/' . $rdirctdFrom['action'];
                     $url = '/' . $module . $controller . $action;
                     $this->getResponse()->setRedirect($url);
                 } else {
                     $this->getResponse()->setRedirect('/');
                 }
             }
         } else {
             echo 'You need to login first.';
             /*
             					$userInfo['identity'] = 'anon';
             					$userInfo['roles'][] = 'guest';
             						$remoteAcl->userInfo = $userInfo;
             						if (isset ( $_SERVER ['HTTP_REFERER'] )) {
             							$this->getResponse ()->setRedirect ( $_SERVER ['HTTP_REFERER'] );
             						} else {
             							$this->getResponse ()->setRedirect ( '/' );
             						}
             						//*/
         }
     }
 }
 /**
  * Function addeditAction for add and edit the user's information.
  */
 public function addeditAction()
 {
     $asUser = Zend_Json_Decoder::decode($this->getRequest()->getParam('ssUserDetail'), Zend_Json::TYPE_ARRAY);
     if ($asUser['id_user'] == 0) {
         $oUser = new Model_Users();
         $oUser->saveUser($asUser);
     } else {
         $oUser = Model_UsersTable::updateUser($asUser);
     }
     $asResponse = array('status' => 'success', 'massage' => 'Record added or edited successfully');
     echo Zend_Json_Encoder::encode($asResponse);
     exit;
 }
Ejemplo n.º 28
0
 public function shortenURL($url)
 {
     if (!$this->_config['bitly']['enabled']) {
         return false;
     }
     $client = new Zend_Http_Client('http://api.bit.ly/v3/shorten');
     $client->setParameterGet(array('apiKey' => $this->_config['bitly']['api_key'], 'login' => $this->_config['bitly']['login'], 'uri' => $url, 'format' => 'json'));
     $response = Zend_Json_Decoder::decode($client->request()->getBody());
     if ($response['status_txt'] == 'OK') {
         return $response['data']['url'];
     }
     return false;
 }
Ejemplo n.º 29
0
 public function getParams($params)
 {
     $defaultArray = array('resource_type = ?' => $params['resource_type']);
     if (isset($params['moduleName'])) {
         $defaultArray = array_merge($defaultArray, array('module = ?' => $params['moduleName']));
     }
     $customCheck = Engine_Api::_()->getDbTable('modules', 'yncomment')->fetchRow($defaultArray);
     if (!$customCheck->params) {
         return '';
     } else {
         return Zend_Json_Decoder::decode($customCheck->params);
     }
 }
Ejemplo n.º 30
0
 public function call($method, $args)
 {
     //http://localhost/stubstats/services/test/
     //echo self::URI ."/". $method;exit;
     $this->client->setUri(self::URI . "/" . $method);
     $this->client->setParameterPost('appName', $this->appName);
     foreach ($args as $key => $val) {
         $this->client->setParameterPost($key, $val);
     }
     $this->client->setParameterPost('auth', $this->signArguments($args));
     $result = $this->client->request(self::HTTP_METHOD);
     //echo "<pre>";print_r($result);exit;
     return Zend_Json_Decoder::decode($result);
 }