예제 #1
0
 public function testGetLogFilesNames()
 {
     $username = '******' . rand();
     try {
         HelperService::getLogFilesNames($username);
     } catch (\Exception $error) {
         $encoding = $this->getKernel()->getContainer()->getParameter('string_functions_encoding');
         $this->assertTrue(mb_strstr($error->getMessage(), $username, false, $encoding) !== false);
         $this->assertEquals(0, $error->getCode());
     }
 }
예제 #2
0
 /**
  * @Route("/ajax/log_files_names/get")
  */
 public function ajaxLogFilesNamesGetAction()
 {
     $request = new Request($_GET, $_POST);
     $username = (string) $request->request->get('username');
     $nameLogFiles = [];
     if ($username) {
         try {
             $nameLogFiles = HelperService::getLogFilesNames($username);
         } catch (\Exception $e) {
             $nameLogFiles = [];
         }
     }
     $response = new JsonResponse();
     return $response->setData(['name_log_files' => $nameLogFiles]);
 }
 /**
  * @Route("/")
  * @Template()
  */
 public function indexAction()
 {
     $user = $this->getUser();
     $isAdmin = $user->getRole()->getName() == 'ROLE_ADMIN';
     if ($isAdmin === true) {
         $listUsername = HelperService::getActiveUserNames($this->getDoctrine());
     } else {
         $listUsername = array();
     }
     try {
         $nameLogFiles = HelperService::getLogFilesNames($user->getUsername());
     } catch (\Exception $e) {
         $nameLogFiles = [];
     }
     return array('log_files_names' => $nameLogFiles, 'log_rows_on_page' => $this->container->getParameter('log_rows_on_page'), 'is_admin' => $isAdmin, 'list_username' => $listUsername);
 }
예제 #4
0
 protected function cronDumpLogFiles(OutputInterface $output)
 {
     $doctrine = $this->getContainer()->get('doctrine');
     $this->setDoctrine($doctrine);
     $this->setOutput($output);
     $listUsername = HelperService::getActiveUserNames($doctrine);
     foreach ($listUsername as $username) {
         try {
             $nameLogFiles = HelperService::getLogFilesNames($username);
         } catch (\Exception $e) {
             $nameLogFiles = [];
         }
         foreach ($nameLogFiles as $filename) {
             $this->dumpLogFile($username, $filename);
         }
     }
 }