Exemplo n.º 1
0
 public function index()
 {
     $this->autoRender = false;
     $restaurantId = $this->request->query('restaurantId');
     $imei = $this->request->query('imei');
     $macAddress = $this->isNull($this->request->query('macId'));
     $info = base64_decode($this->request->query('info'));
     $ipAddress = $this->request->clientIp();
     $restaurantIMEIController = new RestaurantImeiController();
     if (!$restaurantIMEIController->isPresent($restaurantId, $imei, $macAddress)) {
         $this->response->body(DTO\ErrorDto::prepareError(116));
         \Cake\Log\Log::error("request with incorrect restaurantId :- " . $restaurantId);
         return;
     }
     $restaurantController = new RestaurantController();
     \Cake\Log\Log::info('Request is in Download Controller');
     if ($restaurantController->isValidate($restaurantId) and !empty($info)) {
         $networkDeviceDto = UploadDTO\NetworkDeviceInfoDto::Deserialize($info);
         $ipInfo = new Component\Ipinfo();
         $ipDetails = $ipInfo->getFullIpDetails($imei, $networkDeviceDto, $ipAddress);
         $networkDeviceController = new NetworkDeviceController();
         $addNetworkDeviceInfo = $networkDeviceController->addNetworkDeviceInfo($ipDetails, $restaurantId, $macAddress);
         $sqliteController = new SqliteController();
         $sqliteController->getDB($restaurantId);
     } else {
         $this->response->body(DTO\ErrorDto::prepareError(100));
     }
 }
 public function index()
 {
     $this->autoRender = false;
     //$tempUserId = null;
     $tempUserId = $this->request->query("userid");
     $info = base64_decode($this->request->query('info'));
     $ip = "113.193.128.35";
     //$this->request->clientIp();
     \Cake\Log\Log::debug('DownloadDb request input querystring info : ' . $info);
     if (empty($tempUserId) or empty($info)) {
         $this->response->body(DTO\ClsErrorDto::prepareError(101));
         \Cake\Log\Log::error("User requested with blank user id :" . $tempUserId);
         return;
     }
     $networkDeviceInfoDto = DTO\ClsNetworkDeviceInfoDto::Deserialize($info);
     $ipInfo = new Component\Ipinfo();
     $fullDetails = $ipInfo->getFullIpDetails($tempUserId, $networkDeviceInfoDto, $ip);
     $networkDeviceInfoTable = new Table\NetworkDeviceInfoTable();
     $networkDeviceInfoTable->saveNetworkDeviceInfo($fullDetails);
     $userDto = new DTO\ClsUserDto($tempUserId);
     \Cake\Log\Log::debug('TempUserId is send to Validate' . $tempUserId . " userIP : " . $ip);
     if ($this->isValid($userDto->userId)) {
         \Cake\Log\Log::debug("User validate");
         $sqliteController = new SqliteController();
         $sqliteController->getDB($userDto->userId);
         \Cake\Log\Log::debug("Sqlite database sended to user");
     } else {
         $userController = new UserController();
         \Cake\Log\Log::debug('UserId send to save in database');
         if ($userController->userSignUp($userDto->userId)) {
             $sqliteController = new SqliteController();
             $sqliteController->getDB($userDto->userId);
             \Cake\Log\Log::debug("sqlite file sended  to user after userid saving");
         }
     }
 }