Ejemplo n.º 1
0
 /**
  * Megnézzük, hogy volt e module hívás az url-ben, ha volt ellenőrízzük hogy szükséges e authentikáció
  * a module futtatásához, majd elindítjuk. Ha nem volt moule hívás, betöltjük a main module-t.
  *
  * @access public
  * @version 1.0
  */
 public function Initialize()
 {
     $this->_initClasses();
     (string) ($loc_URL = Httprequest::getGETElement('url'));
     (array) ($loc_Array = array());
     if (!is_null($loc_URL)) {
         $loc_Array = explode('/', $loc_URL);
     } else {
         $loc_Array = array();
     }
     if (!empty($loc_Array)) {
         $this->_method = $loc_Array[0];
     } else {
         $this->_method = 'startModule';
         $loc_Array[1] = $this->_mainModule;
     }
     if (method_exists($this, $this->_method)) {
         try {
             call_user_func_array(array($this, $this->_method), array($loc_Array));
         } catch (\Exception $e) {
             Debug::setDebugMessage(array(__METHOD__, self::moduleExceptionErr, "{MSG.ERROR.MODULE_EXCEPTION_ERR}", "err", $e->getMessage()));
             $this->ShowErrorPage(500);
         }
     } else {
         Debug::setDebugMessage(array(__METHOD__, self::moduleNotExists, "{MSG.ERROR.MODULE_NOT_EXISTS}", "err", $this->_method));
         $this->ShowErrorPage(404);
     }
 }
Ejemplo n.º 2
0
		/**
		 * Request to google service
		 *
		 * @param string $url
		 * @param string $data
		 * @param array $headers
		 * @param string $method (POST or GET)
		 * @param int $followlocation (Handle redirect)
		 * @return string
		 */
		protected function Request($url, $data, $headers = array(), $method = "POST", $isretry = false)
		{
		    $this->HttpRequest->setUrl($url);
		    $this->HttpRequest->setMethod(constant("HTTP_METH_{$method}"));
		   	 
		    // Add auth token
			if ($this->AuthToken)
                $headers = array_merge($headers, array("Authorization" => "GoogleLogin auth={$this->AuthToken}"));
			    
            $this->HttpRequest->addHeaders($headers);
            
            if ($method == "POST" || $method == "GET")
                $this->HttpRequest->setQueryData($data);
            elseif ($method == "PUT")
                $this->HttpRequest->setPutData($data);
            
            try 
            {
                $this->HttpRequest->send();
                
                if (($this->HttpRequest->getResponseCode() == 500 && stristr($this->HttpRequest->getResponseBody(), "Token expired")) && !$isretry)
                {
                    if($this->Authenticate(false, false, $this->Service))
                    {
                        return $this->Request($url, $data, $headers, $method, true);
                    }
                    else
                    {
                        Core::RaiseWarning("Session expired");
                        return false;
                    }
                }
                else
                    return $this->HttpRequest->getResponseCode();
            }
            catch (HttpException $e)
            {
                Core::RaiseWarning($e->__toString());
		        return false;
            }
		}