Exemplo n.º 1
0
 /**
  * Handle the curl response
  * @param $curl
  * @param $response
  * @return $this
  */
 public function resolve($curl, $response)
 {
     $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     if (curl_errno($curl)) {
         $this->fill(false, $http_status, curl_error($curl), []);
     } else {
         if ($http_status == 200) {
             $res = json_decode(EncryptAes::dencrypt($response));
             $this->fill($res->success, $http_status, curl_error($curl), $res);
         } else {
             $this->fill(false, $http_status, curl_error($curl), []);
         }
     }
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Make a POST HTTP request
  * @param $url
  * @param $data
  * @return \Alfredoem\Ragnarok\Soul\RagnarokCurlResponse
  */
 public function httpPosRequest($url, $data)
 {
     $enc = EncryptAes::encrypt($data);
     $dataEncrypt = 'data=' . $enc;
     $dataEncrypt = str_replace('+', '%2B', $dataEncrypt);
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_HEADER, 0);
     curl_setopt($curl, CURLOPT_POST, count($dataEncrypt));
     curl_setopt($curl, CURLOPT_POSTFIELDS, $dataEncrypt);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_FAILONERROR, true);
     curl_setopt($curl, CURLOPT_FRESH_CONNECT, true);
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($curl, CURLOPT_URL, $url);
     $response = curl_exec($curl);
     $resolve = $this->curlResponse->resolve($curl, $response);
     curl_close($curl);
     return $resolve;
 }
Exemplo n.º 3
0
 /**
  * Check if the user have a active session
  * @param Request $request
  * @param $userId
  * @param $sessionCode
  * @return string
  */
 public function getValidUserSession(Request $request, $userId, $sessionCode)
 {
     $session = SecUserSessions::whereuserid($userId)->wheresessioncode($sessionCode)->wheredateins(date('Y-m-d'))->wherestatus(1)->first();
     $ipAddress = $request->ip();
     if ($session) {
         if ($session->datetimeUpd < date('Y-m-d H:m:s')) {
             $session->update(['ipAddress' => $ipAddress, 'datetimeUpd' => date('Y-m-d H:m:s')]);
         }
         if ($session->datetimeUpd < date('Y-m-d H:m:s') || $session->ipAddress == $ipAddress) {
             $data = $session->user;
             $data->ipAddress = $ipAddress;
             $data->sessionCode = $session->sessionCode;
             $data->userSessionId = $session->userSessionId;
             $data->environment = $this->environment;
             $data->remember_token = $session->user->remember_token;
             $this->responseData = $data;
             $this->responseSuccess = true;
         }
     }
     return EncryptAes::encrypt(json_encode($this->responseRagnarok->make($this->responseSuccess, $this->responseData)));
 }