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 initialize() { parent::initialize(); session_start(); \Cake\Log\Log::info("Cookie varible is set in configuration form controller : " . $_SESSION['login']); if (!isset($_SESSION['login']) or !isset($_COOKIE['Id'])) { $this->redirect(['controller' => 'LoginForm', 'action' => 'index']); } session_write_close(); }
/** * Always output info message to screen (even when using --quiet). * * @param string|array $message Message to be logged. * @return void */ public function logInfo($message) { if (is_string($message)) { Log::info($message); $this->out($message, 1, Shell::QUIET); return; } foreach ($message as $entry) { $this->out($entry, 1, Shell::QUIET); } }
/** * test convenience methods */ public function testConvenienceMethods() { $this->_deleteLogs(); Log::config('debug', ['engine' => 'File', 'path' => LOGS, 'types' => ['notice', 'info', 'debug'], 'file' => 'debug']); Log::config('error', ['engine' => 'File', 'path' => LOGS, 'types' => ['emergency', 'alert', 'critical', 'error', 'warning'], 'file' => 'error']); $testMessage = 'emergency message'; Log::emergency($testMessage); $contents = file_get_contents(LOGS . 'error.log'); $this->assertRegExp('/(Emergency|Critical): ' . $testMessage . '/', $contents); $this->assertFileNotExists(LOGS . 'debug.log'); $this->_deleteLogs(); $testMessage = 'alert message'; Log::alert($testMessage); $contents = file_get_contents(LOGS . 'error.log'); $this->assertRegExp('/(Alert|Critical): ' . $testMessage . '/', $contents); $this->assertFileNotExists(LOGS . 'debug.log'); $this->_deleteLogs(); $testMessage = 'critical message'; Log::critical($testMessage); $contents = file_get_contents(LOGS . 'error.log'); $this->assertContains('Critical: ' . $testMessage, $contents); $this->assertFileNotExists(LOGS . 'debug.log'); $this->_deleteLogs(); $testMessage = 'error message'; Log::error($testMessage); $contents = file_get_contents(LOGS . 'error.log'); $this->assertContains('Error: ' . $testMessage, $contents); $this->assertFileNotExists(LOGS . 'debug.log'); $this->_deleteLogs(); $testMessage = 'warning message'; Log::warning($testMessage); $contents = file_get_contents(LOGS . 'error.log'); $this->assertContains('Warning: ' . $testMessage, $contents); $this->assertFileNotExists(LOGS . 'debug.log'); $this->_deleteLogs(); $testMessage = 'notice message'; Log::notice($testMessage); $contents = file_get_contents(LOGS . 'debug.log'); $this->assertRegExp('/(Notice|Debug): ' . $testMessage . '/', $contents); $this->assertFileNotExists(LOGS . 'error.log'); $this->_deleteLogs(); $testMessage = 'info message'; Log::info($testMessage); $contents = file_get_contents(LOGS . 'debug.log'); $this->assertRegExp('/(Info|Debug): ' . $testMessage . '/', $contents); $this->assertFileNotExists(LOGS . 'error.log'); $this->_deleteLogs(); $testMessage = 'debug message'; Log::debug($testMessage); $contents = file_get_contents(LOGS . 'debug.log'); $this->assertContains('Debug: ' . $testMessage, $contents); $this->assertFileNotExists(LOGS . 'error.log'); $this->_deleteLogs(); }
public function download($userId, $restaurantId) { $this->autoRender = false; \Cake\Log\Log::info("in Sync controller download method"); $Update = $this->getTableObj()->getUpdate($userId, $restaurantId); if ($Update) { $this->response->body(json_encode($Update)); $this->response->send(); \Cake\Log\Log::debug("Update send to User : "******" Update json for this user" . json_encode($Update)); $this->getTableObj()->deleteUpdate($userId); } else { $this->response->body(DTO\ErrorDto::prepareError(103)); $this->response->send(); } }
private function uploadAnswer($senderUserId, $answerDto) { $answercontroller = new AnswerController(); \Cake\Log\Log::info('Answer DTO object send to submit'); if ($answercontroller->submit($senderUserId, $answerDto)) { \Cake\Log\Log::debug("Answer stored in database"); } }
public function ispresent($userid, $destid) { $checks = $this->connect()->find()->where(['UserId =' => $userid, 'DestId =' => $destid]); $check = null; foreach ($checks as $check) { return $check; } \Cake\Log\Log::info("user count for like insert : " . $check); return FAIL; }
/** * main() method. * * @return void */ public function main() { if ($this->params['stagger']) { sleep(rand(0, $this->params['stagger'])); } Configure::write('App.baseUrl', '/'); $emailQueue = TableRegistry::get('EmailQueue', ['className' => EmailQueueTable::class]); $emails = $emailQueue->getBatch($this->params['limit']); $count = count($emails); foreach ($emails as $e) { $configName = $e->config === 'default' ? $this->params['config'] : $e->config; $template = $e->template === 'default' ? $this->params['template'] : $e->template; $layout = $e->layout === 'default' ? $this->params['layout'] : $e->layout; $headers = empty($e->headers) ? [] : (array) $e->headers; $theme = empty($e->theme) ? '' : (string) $e->theme; $helpers = ['Html', 'Text', 'Number', 'Url']; $fromEmail = null; $fromName = null; try { $email = $this->_newEmail($configName); if (!empty($e->from_email) && !empty($e->from_name)) { $email->from($e->from_email, $e->from_name); } $transport = $email->transport(); if ($transport && $transport->config('additionalParameters')) { $from = key($email->from()); $transport->config(['additionalParameters' => "-f {$from}"]); } $sent = $email->to($e->email_to)->subject($e->subject)->template($template, $layout)->emailFormat($e->format)->addHeaders($headers)->theme($theme)->helpers($helpers)->viewVars($e->template_vars)->messageId(false)->returnPath($email->from()); if ($e->email_cc) { $sent->addCc(explode(',', $e->email_cc)); } if ($e->email_bcc) { $sent->addBcc(explode(',', $e->email_bcc)); } if (get_class($transport) === 'Cake\\Mailer\\Transport\\SmtpTransport') { $fromEmail = $fromName = $transport->config()['username']; } else { foreach ($sent->from() as $k => $v) { $fromEmail = $k; $fromName = $v; } } if ($e->email_reply_to) { $sent->replyTo(explode(',', $e->email_reply_to)); } else { $sent->replyTo($fromEmail, $fromName); } $sent = $sent->send(); } catch (SocketException $exception) { $this->err($exception->getMessage()); $sent = false; } if ($sent) { $emailQueue->success($e->id, $fromEmail, $fromEmail); Log::info("Email {$e->id} was sent"); } else { $emailQueue->fail($e->id, $fromEmail, $fromEmail); Log::info("Email {$e->id} was NOT sent"); } } if ($count > 0) { $emailQueue->releaseLocks(collection($emails)->extract('id')->toList()); } }
/** * Set globally writable permissions on the "tmp" and "logs" directory. * * This is not the most secure default, but it gets people up and running quickly. * * @param string $dir The application's root directory. * @return boolean True if permissions are updated successfully */ public static function setFolderPermissions($dir) { Log::info("Setting permissions on {$dir} to world writable"); // Change the permissions on a path and output the results. $changePerms = function ($path, $perms) { // Get current permissions in decimal format so we can bitmask it. $currentPerms = octdec(substr(sprintf('%o', fileperms($path)), -4)); if (($currentPerms & $perms) == $perms) { Log::debug('* Skipping: desired permissions already set for ' . $path); return true; } $res = chmod($path, $currentPerms | $perms); if (!$res) { Log::error('Failed to set permissions on ' . $path); return false; } Log::debug('* Successfully updated permissions for ' . $path); }; $walker = function ($dir, $perms) use(&$walker, $changePerms) { $files = array_diff(scandir($dir), ['.', '..']); foreach ($files as $file) { $path = $dir . '/' . $file; if (!is_dir($path)) { continue; } $changePerms($path, $perms); $walker($path, $perms); } }; $worldWritable = bindec('0000000111'); $changePerms($dir, $worldWritable); $walker($dir, $worldWritable); return true; }
private function createS3Client() { $this->autoRender = false; $s3FactoryArgs = \appconfig::getAwsDefaults(LOCAL_ENV); $s3Client = S3Client::factory($s3FactoryArgs); \Cake\Log\Log::info("S3Client instantiation completed"); return $s3Client; }
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); } }