public function validate()
 {
     $this->autoRender = false;
     if ($this->request->is('post')) {
         $data = $this->request->data;
         $credential = \appconfig::getAdminCredential();
         //\Cake\Log\Log::debug("Admin credential from config table : ".$credential['username']);
         if ($data['username'] == $credential['username'] and $data['password'] == $credential['password']) {
             session_start();
             $_SESSION['login'] = '******';
             setcookie('Id', $credential['username'], time() + 60 * 60, "/");
             $pass = md5($credential['password']);
             setcookie('pass', $pass, time() + 60 * 60, "/");
             // \Cake\Log\Log::info("Cookie varible after created: ".$_SESSION['login']);
             // \Cake\Log\Log::debug("redirect to destiationform controller");
             $this->redirect(['controller' => 'HomeForm', 'action' => 'adminPanel']);
         } else {
             session_start();
             $_SESSION['message'] = 'Username and Password wrong !!';
             $this->redirect(['controller' => 'LoginForm', 'action' => 'index']);
         }
     } else {
         die('Request error occured');
     }
 }
 function query($sql, $accion)
 {
     require_once 'appconfig.php';
     $appconfig = new appconfig();
     $datos = $appconfig->conexion();
     $hostname = $datos['hostname'];
     $database = $datos['database'];
     $username = $datos['username'];
     $password = $datos['password'];
     /*		$hostname = "localhost";
     		$database = "lacalder_diablo";
     		$username = "******";
     		$password = "******";*/
     $conex = mysql_connect($hostname, $username, $password) or die("no se puede conectar" . mysql_error());
     mysql_select_db($database);
     /*
     $result = mysql_query($sql,$conex);
     if ($accion && $result) {
     	$result = mysql_insert_id();
     }
     mysql_close($conex);
     return $result;
     */
     $error = 0;
     mysql_query("BEGIN");
     $result = mysql_query($sql, $conex);
     if ($accion && $result) {
         $result = mysql_insert_id();
     }
     if (!$result) {
         $error = 1;
     }
     if ($error == 1) {
         mysql_query("ROLLBACK");
         return false;
     } else {
         mysql_query("COMMIT");
         return $result;
     }
 }
 private function questionPagination($page = 1)
 {
     $questionTable = new Table\QuestionTable();
     if (!$questionTable->connect()->find()->count()) {
         return NOT_FOUND;
     }
     $allquestions = array();
     $i = 0;
     $limit = \appconfig::getPageSize();
     $questions = $this->Paginator->paginate($questionTable->connect()->find(), ['limit' => $limit, 'page' => $page]);
     foreach ($questions as $question) {
         $questionDto = new DTO\ClsQuestionDto($question->QuestionId, $question->QuestionText, $question->Active);
         $allquestions[$i] = $questionDto;
         $i++;
     }
     return $allquestions;
 }
 private function configurationPagination($page = 1)
 {
     $statconfTable = new Table\StatConfTable();
     if (!$statconfTable->connect()->find()->count()) {
         return NOT_FOUND;
     }
     $allConfig = array();
     $i = 0;
     $limit = \appconfig::getPageSize();
     $configurations = $this->Paginator->paginate($statconfTable->connect()->find(), ['limit' => $limit, 'page' => $page]);
     foreach ($configurations as $configuration) {
         $statConfDto = new DTO\ClsStatConfigDto($configuration->ConfigKey, $configuration->ConfigValue);
         $allConfig[$i] = $statConfDto;
         $i++;
     }
     return $allConfig;
 }
 private function createS3Client()
 {
     $this->autoRender = false;
     $s3FactoryArgs = \appconfig::getAwsDefaults(LOCAL_ENV);
     $s3Client = S3Client::factory($s3FactoryArgs);
     \Cake\Log\Log::info("S3Client instantiation completed");
     return $s3Client;
 }
 private function destinationPagination($page = 1)
 {
     $destinationTable = new Table\DestinationTable();
     if (!$destinationTable->connect()->find()->count()) {
         return NOT_FOUND;
     }
     $allDest = array();
     $i = 0;
     $limit = \appconfig::getPageSize();
     $destination = $this->Paginator->paginate($destinationTable->connect()->find(), ['limit' => $limit, 'page' => $page]);
     foreach ($destination as $row) {
         $destDto = new DTO\ClsDestinationDto($row->DestId, $row->DestName, $row->Latitude, $row->Longitude, $row->Active);
         $allDest[$i] = $destDto;
         $i++;
     }
     return $allDest;
 }