public function index()
 {
     $this->autoRender = false;
     $data = $this->request->data;
     if (empty($data)) {
         $this->response->body(DTO\ClsErrorDto::prepareError(106));
         \Cake\Log\Log::debug("Image data empty");
         return;
     }
     if (!array_key_exists('userId', $data) or !array_key_exists('emailId', $data) or !array_key_exists('userName', $data)) {
         $this->response->body(DTO\ClsErrorDto::prepareError(107));
         \Cake\Log\Log::debug("Image data empty");
         return;
     }
     $userTable = new Table\UserTable();
     if (!$userTable->userCkeck($data['userId'], $data['emailId'], $data['userName'])) {
         $this->response->body(DTO\ClsErrorDto::prepareError(112));
         return;
     }
     if (array_key_exists('destId', $data)) {
         $imagesController = new ImagesController();
         $result = $imagesController->uploadDestinationImage($data);
         if ($result) {
             \Cake\Log\Log::debug("Destination image uploaded successfully");
         } else {
             \Cake\Log\Log::error("Invalid image extension");
         }
     } else {
         $imagesController = new ImagesController();
         $result = $imagesController->uploadProfileImage($data);
         if ($result) {
             \Cake\Log\Log::debug("profile image uploaded successfully");
         } else {
             \Cake\Log\Log::error("Invalid image extension");
         }
     }
 }
Example #2
0
<?php

// Ensure we have session
if (session_id() === "") {
    session_start();
}
use App\Controller\ImagesController;
require_once "app/Controller/ImagesController.php";
$action = null;
if (isset($_GET['a'])) {
    $action = $_GET['a'];
}
$imagesController = new ImagesController($action);
$fragment = $imagesController->dispatch();
require_once "app/View/fragments/header.html";
echo $fragment;
require_once "app/View/fragments/footer.html";
 public function getDB($userId)
 {
     $this->autoRender = false;
     $tableObject = new Table\SqliteTable();
     if ($tableObject->Create($userId)) {
         //Destination Table
         $destinationController = new DestinationController();
         $destinationPreparedStatement = $destinationController->prepareInsertStatement();
         if ($tableObject->excutePreparedStatement($destinationPreparedStatement)) {
             \Cake\Log\Log::info('Record is inserted into Destination SQLite table for id ' . $userId);
         } else {
             \Cake\Log\Log::error('Record is not inserted into Destination SQLite table');
         }
         //User Table
         $userController = new UserController();
         $userPreparedStatement = $userController->prepareInsertStatement();
         if ($tableObject->excutePreparedStatement($userPreparedStatement)) {
             \Cake\Log\Log::info('Record is inserted into User SQLite table for id ' . $userId);
         } else {
             \Cake\Log\Log::error('Record is not inserted into User  SQLite table');
         }
         //Question Table
         $questionController = new QuestionController();
         $questionPreparedStatement = $questionController->prepareInsertStatement();
         if ($tableObject->excutePreparedStatement($questionPreparedStatement)) {
             \Cake\Log\Log::debug('Record is inserted into Question sQLite table for id' . $userId);
         } else {
             \Cake\Log\Log::debug('Record is not inserted into Question sQLite table for id');
         }
         //Options Table
         $optionController = new OptionsController();
         $optionPreparedStatement = $optionController->prepareInsertStatement();
         if ($tableObject->excutePreparedStatement($optionPreparedStatement)) {
             \Cake\Log\Log::debug('Record is inserted into Options sQLite table for id' . $userId);
         } else {
             \Cake\Log\Log::debug('Record is not inserted into Options sQLite table for id');
         }
         //Answer Table
         $answerController = new AnswerController();
         $answerPreparedStatement = $answerController->prepareInsertStatement();
         if ($tableObject->excutePreparedStatement($answerPreparedStatement)) {
             \Cake\Log\Log::debug('Record is inserted into Answer sQLite table for id' . $userId);
         } else {
             \Cake\Log\Log::debug('Record is not inserted into Answer sQLite table for id');
         }
         //Comment And Like  Table
         $commentAndLikeController = new CommentAndLikeController();
         $commentAndLikePreparedStatement = $commentAndLikeController->prepareInsertStatement();
         if ($tableObject->excutePreparedStatement($commentAndLikePreparedStatement)) {
             \Cake\Log\Log::debug('Record is inserted into commentAndLike sQLite table for id' . $userId);
         } else {
             \Cake\Log\Log::debug('Record is not inserted into commentAndLike sQLite table for id');
         }
         //Images Table
         $imagesController = new ImagesController();
         $imagesPreparedStatement = $imagesController->prepareInsertStatement();
         if ($tableObject->excutePreparedStatement($imagesPreparedStatement)) {
             \Cake\Log\Log::debug('Record is inserted into Images sQLite table for id' . $userId);
         } else {
             \Cake\Log\Log::debug('Record is not inserted into Images sQLite table for id');
         }
         //Stat_Config Table
         $statconfController = new StatConfController();
         $statconfPreparedStatement = $statconfController->prepareInsertStatement();
         if ($tableObject->excutePreparedStatement($statconfPreparedStatement)) {
             \Cake\Log\Log::debug('Record is inserted into stat_conf sQLite table for id' . $userId);
         } else {
             \Cake\Log\Log::debug('Record is not inserted into stat_conf SQLite table for id');
         }
         $this->response->type('class');
         $this->response->file(SQLITE_DB_DIR . 'TravelDb' . $userId . '.sqlite', ['download' => true]);
         $this->response->send();
         $retult = unlink(SQLITE_DB_DIR . 'TravelDb' . $userId . '.sqlite');
         \Cake\Log\Log::info('TravelDb.' . $userId . '.sqlite  File deleted successfully');
         $userTable = new Table\UserTable();
         //$userTable->update($userId);
     }
 }