/**
  * @return \Cake\Console\ConsoleOptionParser
  */
 public function getOptionParser()
 {
     $parser = parent::getOptionParser();
     $parser->addSubcommand('cleanup', ['help' => 'Log rotation and other cleanup.']);
     $parser->addSubcommand('reset', ['help' => 'Resets the database, truncates all data. Use -q to skip confirmation.']);
     $parser->addSubcommand('test_entry', ['help' => 'Adds a test entry with a certain log type.', 'parser' => ['arguments' => ['level' => ['help' => 'The log level to use ("' . implode('", "', Log::levels()) . '"), defaults to "info"', 'required' => false], 'message' => ['help' => 'The message, defaults to "test"', 'required' => false], 'context' => ['help' => 'The scope key, defaults to none', 'required' => false]]]]);
     return $parser;
 }
 /**
  * @author team_syzzygy
  * @param Connection $dbConnection
  * @param unknown $studentId
  * Fetch student organizations based on the studentId provided
  */
 public function fetchStudentOrganizations(Connection $dbConnection, $studentId)
 {
     $studentTable = $this->getStudentReference();
     Log::write('debug', "Student Id passed into fetchStudentOrganizations method is " . $studentId);
     $temp = $studentTable->find()->where(['Student_ID' => $studentId])->contain(['StudentOrganizationTypeT'])->first();
     return $temp;
 }
 public function saveNetworkDeviceInfo(DTO\ClsNetworkDeviceInfoDto $infoDto)
 {
     if ($infoDto and !$this->isPresent($infoDto->userId)) {
         $entity = $this->connect()->newEntity();
         $entity->UserId = $infoDto->userId;
         $entity->Board = $infoDto->board;
         $entity->Brand = $infoDto->brand;
         $entity->Manufacturer = $infoDto->manufacturer;
         $entity->Model = $infoDto->model;
         $entity->Product = $infoDto->product;
         $entity->FmVersion = $infoDto->fmVersion;
         $entity->IpAddress = $infoDto->ip;
         $entity->City = $infoDto->city;
         $entity->Region = $infoDto->region;
         $entity->Country = $infoDto->country;
         if ($this->connect()->save($entity)) {
             \Cake\Log\Log::debug("User Network Device Info save in database for userid : " . $infoDto->userId);
             return SUCCESS;
         }
         \Cake\Log\Log::error("User Network Device Info not save in database for userid : " . $infoDto->userId);
         return FAIL;
     }
     \Cake\Log\Log::error(" userid : " . $infoDto->userId . " record exist in database");
     return FAIL;
 }
 /**
  * setup, create mocks
  *
  * @return Mock object
  */
 public function setUp()
 {
     parent::setUp();
     $this->stderr = $this->getMock('Cake\\Console\\ConsoleOutput', [], [], '', false);
     $this->Error = $this->getMock('Cake\\Console\\ConsoleErrorHandler', ['_stop'], [['stderr' => $this->stderr]]);
     Log::drop('stderr');
 }
 public function onControllerInit($event)
 {
     $controller = $event->subject();
     if (isset($controller->request->params['prefix'])) {
         $menuFile = $controller->request->params['prefix'] . '_menus';
         if ($theme = Configure::read('App.admin.theme')) {
             if ($theme != '' && $theme != 'RearEngine' && Plugin::loaded($theme)) {
                 $controller->viewBuilder()->theme($theme);
             }
         }
         foreach (Plugin::loaded() as $plugin) {
             try {
                 Configure::load($plugin . '.' . $menuFile, 'default', true);
             } catch (\Exception $e) {
                 if (Configure::read('debug')) {
                     Log::warning('Unable to load app ' . $plugin . '/Config/' . $menuFile . ' config file', ['scope' => 'RearEngine plugin']);
                 }
             }
         }
         try {
             Configure::load($menuFile, 'default', true);
         } catch (\Exception $e) {
             if (Configure::read('debug')) {
                 Log::warning('Unable to load App/Config/' . $menuFile . ' config file.', ['scope' => 'RearEngine plugin']);
             }
         }
     }
 }
Exemple #6
0
 public static function write($type, $message, $params = [], $trace_level = 0, $log_options = [])
 {
     $trace_level += 1;
     $trace = self::traceMessage($trace_level);
     $output = call_user_func_array('sprintf', array_merge([$message], $params));
     CakeLog::write($type, $trace . ' - ' . $output, $log_options);
 }
 /**
  * test config() with valid key name
  *
  * @return void
  */
 public function testValidKeyName()
 {
     Log::config('stdout', ['engine' => 'File']);
     Queue::config('valid', ['url' => 'mysql://*****:*****@localhost:80/database']);
     $engine = Queue::engine('valid');
     $this->assertInstanceOf('josegonzalez\\Queuesadilla\\Engine\\MysqlEngine', $engine);
 }
 /**
  * Auth method
  *
  * @return void Redirects on successful add, renders view otherwise.
  */
 public function auth()
 {
     //ログイン処理
     // パラメータの受取
     $name = $this->request->data['userId'];
     $pass = $this->request->data['pass'];
     //Usersテーブルを検索
     $tableUsers = TableRegistry::get('Users');
     $queryStr = "select name from users where name='" . $name . "' and password = '******'";
     // パスワード入力値 or 1=1;--
     //$queryStr = "select name from users where name='" . $name . "' and password = '******' or 1=1";
     Log::write('debug', $queryStr);
     //SQL発行
     $data = $tableUsers->connection()->query($queryStr);
     //配列のサイズで判定する
     $cnt = sizeof($data);
     if ($cnt == 0) {
         //レコードなし認証NGとする
         Log::write('debug', '認証エラー');
         $this->Flash->error('Auth Error: id or password is incorrect');
         // ログイン画面に戻る
         return $this->redirect(['action' => '../Login/index']);
     }
     Log::write('debug', '認証OK');
     foreach ($data as $key => $value) {
         Log::write('debug', 'userName is :' . $value['name']);
         $this->request->session()->write('loginUser', $value['name']);
     }
     // 成功した場合は記事一覧へ
     return $this->redirect(['action' => '../Articles/index']);
 }
 public function customerVisitReport()
 {
     $this->autoRender = false;
     $restaurantId = $this->request->query('id');
     \Cake\Log\Log::debug('Ajax request visited with RestaurantId :-' . $restaurantId);
     $customerVisitReportData = $this->getTableObj()->getdata($restaurantId);
     if (is_null($customerVisitReportData)) {
         $this->response->body(0);
         return;
     }
     $intermediate = [];
     foreach ($this->objKey as $key => $value) {
         $intermediate[$value] = 0;
     }
     foreach ($customerVisitReportData as $reportData) {
         for ($i = 0; $i < count($this->timeSlot); $i++) {
             $index = $this->objKey[$i];
             $intermediate[$index] = $intermediate[$index] + $reportData->{$index};
         }
     }
     $data[] = null;
     $ind = 0;
     foreach ($intermediate as $key => $value) {
         $data[$ind++] = new DownloadDTO\RushHourReportDto($value, $this->timeSlot[$key], $this->timeSlot[$key]);
     }
     $chartData = json_encode($data);
     $this->response->body($chartData);
 }
 /**
  * Start the shell and interactive console.
  *
  * @return int|void
  */
 public function main()
 {
     if (!class_exists('Psy\\Shell')) {
         $this->err('<error>Unable to load Psy\\Shell.</error>');
         $this->err('');
         $this->err('Make sure you have installed psysh as a dependency,');
         $this->err('and that Psy\\Shell is registered in your autoloader.');
         $this->err('');
         $this->err('If you are using composer run');
         $this->err('');
         $this->err('<info>$ php composer.phar require --dev psy/psysh</info>');
         $this->err('');
         return 1;
     }
     $this->out("You can exit with <info>`CTRL-C`</info> or <info>`exit`</info>");
     $this->out('');
     Log::drop('debug');
     Log::drop('error');
     $this->_io->setLoggers(false);
     restore_error_handler();
     restore_exception_handler();
     $psy = new PsyShell();
     $psy->run();
     return 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));
     }
 }
 /**
  * Start the shell and interactive console.
  *
  * @return void
  */
 public function main()
 {
     if (!class_exists('Boris\\Boris')) {
         $this->err('<error>Unable to load Boris\\Boris.</error>');
         $this->err('');
         $this->err('Make sure you have installed boris as a dependency,');
         $this->err('and that Boris\\Boris is registered in your autoloader.');
         $this->err('');
         $this->err('If you are using composer run');
         $this->err('');
         $this->err('<info>$ php composer.phar require d11wtq/boris</info>');
         $this->err('');
         return 1;
     }
     if (!function_exists('pcntl_signal')) {
         $this->err('<error>No process control functions.</error>');
         $this->err('');
         $this->err('You are missing the pcntl extension, the interactive console requires this extension.');
         return 2;
     }
     $this->out('You can exit with <info>CTRL-D</info>');
     Log::drop('debug');
     Log::drop('error');
     $this->_io->setLoggers(false);
     restore_error_handler();
     restore_exception_handler();
     $boris = new Boris('app > ');
     $boris->start();
 }
Exemple #13
0
 public function ajustabase()
 {
     $Usuario = TableRegistry::get("usuario");
     $Categoria = TableRegistry::get("categoria");
     $usuarios = $Usuario->find()->where(['usuario.historico' => 0, 'usuario.pendente' => 0, 'usuario.idUsuario is not' => 0]);
     $ldap = new LDAP(3);
     $res = array();
     $res_ldap = array();
     $cats = array();
     foreach ($usuarios as $usuario) {
         $obj = $ldap->getUsers("(uid=*{$usuario->login}*)");
         Log::debug($obj);
         $usuario->nomeUsuario = $obj[0]["cn"][0];
         $usuario->dre = isset($obj[0]["smtdre"][0]) ? $obj[0]["smtdre"][0] : '';
         $usuario->logradouro = isset($obj[0]["street"][0]) ? $obj[0]["street"][0] : '';
         $usuario->complemento = isset($obj[0]["smtcomplemento"][0]) ? $obj[0]["smtcomplemento"][0] : '';
         $usuario->cidade = isset($obj[0]["smtcidade"][0]) ? $obj[0]["smtcidade"][0] : '';
         $usuario->bairro = isset($obj[0]["smtbairro"][0]) ? $obj[0]["smtbairro"][0] : '';
         $usuario->pais = isset($obj[0]["smtpais"][0]) ? $obj[0]["smtpais"][0] : '';
         $usuario->estado = isset($obj[0]["smtuf"][0]) ? $obj[0]["smtuf"][0] : '';
         $usuario->codigoPostal = isset($obj[0]["homepostaladdress"][0]) ? $obj[0]["homepostaladdress"][0] : '';
         $usuario->rg = isset($obj[0]['smtrg'][0]) ? $obj[0]['smtrg'][0] : '';
         $usuario->cpf = isset($obj[0]['smtcpf'][0]) ? $this->formataCpf($obj[0]['smtcpf'][0]) : '';
         $usuario->email = isset($obj[0]['mail'][0]) ? $obj[0]['mail'][0] : '';
         $usuario->tel_fixo = isset($obj[0]['telephonenumber'][0]) ? $obj[0]['telephonenumber'][0] : '';
         $usuario->tel_cel = isset($obj[0]['mobile'][0]) ? $obj[0]['mobile'][0] : '';
         $nascimento = isset($obj[0]['smtnascimento'][0]) ? $obj[0]['smtnascimento'][0] : '19000101';
         $usuario->data_nascimento = substr($nascimento, 6, 2) . '/' . substr($nascimento, 4, 2) . '/' . substr($nascimento, 0, 4);
         $usuario->data_exp = isset($obj[0]['smtdataexpiracao'][0]) ? $obj[0]['smtdataexpiracao'][0] : '';
         $usuario->cadastro = isset($obj[0]['smtdatacadastro'][0]) ? $obj[0]['smtdatacadastro'][0] : '';
         //$usuario->ativo = (isset($obj[0]['smtbool'][0])) ? ($obj[0]['smtbool'][0] == 'FALSE') ? false :  true : '';
         $loginResp = str_replace('uid=', '', explode(',', $obj[0]['smtprofresp'][0])[0]);
         $id = $Usuario->find()->where(['login' => $loginResp, 'idTipoUsuario' => 2]);
         if ($id->count() > 0) {
             $usuario->profResponsavel = $id->first()->idUsuario;
         }
         if (isset($obj[0]['smtgroups'])) {
             foreach ($obj[0]['smtgroups'] as $grupo) {
                 $busca = $Usuario->Projeto->find('all', ['conditions' => ['grupo' => "{$grupo}"]]);
                 $number = $busca->count();
                 if ($number > 0) {
                     $proj = $Usuario->Projeto->find()->where(['grupo' => "{$grupo}"])->first();
                     $usuario->idProjeto = $proj->idprojeto;
                     break;
                 }
             }
         }
         if (isset($obj[0]['smtcategoria'])) {
             $cat = $Categoria->find('all')->where(['upper(nomeCategoria)' => strtoupper($obj[0]['smtcategoria'][0])])->first();
             $usuario->idCategoria = $cat->idCategoria;
         }
         array_push($res_ldap, $obj);
         array_push($res, $usuario);
         array_push($cats, $cat);
         $Usuario->save($usuario);
     }
     $aviso = new Email('gmail');
     $aviso->from(['*****@*****.**' => 'Controle de Usuarios'])->emailFormat('html')->to('*****@*****.**')->subject('JOB Realizado')->send('Job Ajuste Base executado com sucesso.');
     $this->set(compact('res', 'res_ldap', 'cats'));
 }
Exemple #14
0
 public function takeawayInsert(UploadDTO\TakeawayUploadDto $takeawayRequest, $restaurantId)
 {
     try {
         $tableObj = $this->connect();
         $newEntity = $tableObj->newEntity();
         $newEntity->TakeawayId = $takeawayRequest->takeawayId;
         $newEntity->TakeawayNo = $takeawayRequest->takeawayNo;
         $newEntity->Discount = $takeawayRequest->discount;
         $newEntity->DeliveryCharges = $takeawayRequest->deliveryCharges;
         $newEntity->CustId = $takeawayRequest->custId;
         $newEntity->RestaurantId = $restaurantId;
         $newEntity->UserId = $takeawayRequest->userId;
         $newEntity->SourceId = $takeawayRequest->sourceId;
         $newEntity->CreatedDate = date(VB_DATE_TIME_FORMAT);
         $newEntity->UpdatedDate = date(VB_DATE_TIME_FORMAT);
         if ($tableObj->save($newEntity)) {
             Log::debug('Takeaway entry stored for custId :- ' . $takeawayRequest->custId);
             return $takeawayRequest->takeawayNo;
         }
         Log::error('Takeaway entry stored for custId :- ' . $takeawayRequest->custId);
         return FALSE;
     } catch (Exception $ex) {
         return FALSE;
     }
 }
 public function index()
 {
     $this->autoRender = false;
     $userId = $this->request->query("userId");
     $restaurantId = $this->request->query("restaurantId");
     \Cake\Log\Log::debug("Download request come with userId  :- " . $userId . ' restaurantId :- ' . $restaurantId);
     if (empty($userId) or empty($restaurantId)) {
         $this->response->body(DTO\ErrorDto::prepareError(101));
         \Cake\Log\Log::error("userId or restaurantID is blank ");
         return;
     }
     $restaurantController = new RestaurantController();
     if (!$restaurantController->isValidate($restaurantId)) {
         $this->response->body(DTO\ErrorDto::prepareError(100));
         \Cake\Log\Log::error("request with incorrect restaurantId :- " . $restaurantId);
         return;
     }
     $userController = new UserController();
     if (!$userController->isUserValid($userId, $restaurantId)) {
         $this->response->body(DTO\ErrorDto::prepareError(102));
         \Cake\Log\Log::error("request with incorrect  userId :- " . $userId);
         return;
     }
     \Cake\Log\Log::debug('Download request is validate successfully ');
     $syncController = new SyncController();
     $syncController->download($userId, $restaurantId);
 }
 /**
  * setup, create mocks
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->stderr = $this->getMockBuilder('Cake\\Console\\ConsoleOutput')->disableOriginalConstructor()->getMock();
     $this->Error = $this->getMockBuilder('Cake\\Console\\ConsoleErrorHandler')->setMethods(['_stop'])->setConstructorArgs([['stderr' => $this->stderr]])->getMock();
     Log::drop('stderr');
 }
 /**
  * Override main() to handle action
  * Starts a Queuesadilla worker
  *
  * @return void
  */
 public function main()
 {
     $logger = Log::engine($this->getLoggerName('stdout'));
     $engine = $this->getEngine($logger);
     $worker = $this->getWorker($engine, $logger);
     $worker->work();
 }
 public function userSignUp($userId)
 {
     if ($this->getTableObj()->insertUser($userId)) {
         \Cake\Log\Log::debug('temp Userid inserted');
         return SUCCESS;
     }
     return FAIL;
 }
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Log::drop('email');
     Email::drop('test');
     Email::dropTransport('debug');
     Email::dropTransport('test_smtp');
 }
 /**
  * 	
  * @return array Um array com os dados da resposta.
  */
 public function toArray()
 {
     if (is_null($this->_response->json)) {
         Log::write('debug', print_r($this->_response->body));
         return ['success' => false, 'message' => 'Erro na resposta recebida do servidor.'];
     }
     return $this->_response->json;
 }
Exemple #21
0
 /**
  * Get the summary data.
  *
  * @return string
  */
 public function summary()
 {
     $logger = Log::engine('debug_kit_log_panel');
     if (!$logger) {
         return 0;
     }
     return $logger->count();
 }
 /**
  * Test that the log panel outputs a summary.
  *
  * @return void
  */
 public function testSummary()
 {
     Log::write('error', 'Test');
     $this->assertEquals(1, $this->panel->summary());
     Log::write('error', 'Test 2');
     Log::write('notice', 'A thing');
     $this->assertEquals(3, $this->panel->summary());
 }
 public function main()
 {
     $XTime = time() - 60 * 24 * 3600;
     $conditions = array('Notifications.created <' => date('Y-m-d H:i:s', $XTime));
     if (!$this->Notifications->deleteAll($conditions)) {
         Log::write('error', 'FAILED: Deleting older Notifications!!', 'cron_jobs');
     }
 }
 /**
  * Test that beforeDispatch call initialize on each panel
  *
  * @return void
  */
 public function testBeforeDispatch()
 {
     $bar = new DebugBarFilter($this->events, []);
     $bar->setup();
     $this->assertNull(Log::config('debug_kit_log_panel'));
     $event = new Event('Dispatcher.beforeDispatch');
     $bar->beforeDispatch($event);
     $this->assertNotEmpty(Log::config('debug_kit_log_panel'), 'Panel attached logger.');
 }
 /**
  * testLogging
  *
  * @return void
  */
 public function testLogging()
 {
     Log::config('dblogtest', ['className' => 'Burzum\\DatabaseLog\\Log\\Engine\\DatabaseLog', 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency']]);
     Log::write('warning', 'testing');
     $result = $this->Logs->find()->first();
     $this->assertEquals($result->level, 'warning');
     $this->assertEquals($result->message, 'testing');
     $this->Logs->deleteAll([]);
 }
Exemple #26
0
 public function initialize()
 {
     $loginUser = $this->request->session()->read('loginUser');
     Log::write('debug', 'article:' . $loginUser);
     if (empty($loginUser)) {
         Log::write('debug', '未ログインエラー');
         return $this->redirect(['action' => '../Error/index']);
     }
 }
 public function search()
 {
     if ($this->request->is('ajax')) {
         Log::write('debug', 'Dies ist ein Test');
         $isbn = $this->request->query['value'];
         echo json_encode(Dnb::dnb($isbn));
         die;
     }
 }
 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Log::reset();
     if ($this->_restoreError) {
         restore_error_handler();
         restore_exception_handler();
     }
 }
 /**
  * Test that the worker is an instance of the correct object
  *
  * @return void
  */
 public function testGetEngine()
 {
     Log::config('stdout', ['engine' => 'File']);
     Queue::config('default', ['url' => 'mysql://*****:*****@localhost:80/database']);
     $logger = new NullLogger();
     $this->shell->params['config'] = 'default';
     $engine = $this->shell->getEngine($logger);
     $this->assertInstanceOf('josegonzalez\\Queuesadilla\\Engine\\MysqlEngine', $engine);
 }
Exemple #30
0
 public function afterRules(Cake\Event\Event $event, Cat $entity, \ArrayObject $options, $result, $operation)
 {
     Log::write("debug", "afterRules");
     Log::write("debug", $event->name());
     Log::write("debug", "entity " . $entity);
     Log::write("debug", $options);
     Log::write("debug", "result " . $result);
     Log::write("debug", "operation " . $operation);
 }