Exemple #1
0
 function tools_check_comics($repair = FALSE)
 {
     // basically CSRF protection from repairing
     if (!$this->input->is_cli_request()) {
         $repair = FALSE;
     }
     if ($this->input->post('repair') == 'repair') {
         $repair = TRUE;
     }
     $recursive = FALSE;
     if ($this->input->is_cli_request()) {
         $recursive = TRUE;
     }
     $comics = new Comic();
     $comics->check_external($repair, $recursive);
     $warnings = array();
     foreach ($this->notices as $notice) {
         if ($notice['type'] == 'error') {
             if (!$this->input->is_cli_request()) {
                 $this->output->set_output(json_encode(array('status' => 'error', 'message' => $notice['message'])));
             }
             if ($this->input->is_cli_request()) {
                 echo PHP_EOL . _('You have to correct the errors above to continue.') . PHP_EOL;
             }
             return FALSE;
         }
         if ($notice['type'] == 'warning') {
             $warnings[] = $notice['message'];
         }
     }
     if (!$recursive) {
         // if we are here we at most have warning notices
         // add count to request so we can process chapters one by one
         $chapters = new Chapter();
         $count = $chapters->count();
     }
     if (!$this->input->is_cli_request()) {
         $this->output->set_output(json_encode(array('status' => count($warnings) > 0 ? 'warning' : 'success', 'messages' => $warnings, 'count' => $count)));
     } else {
         echo '#----------DONE----------#' . PHP_EOL;
         if (!$repair) {
             echo sprintf(_('To repair automatically by removing the unidentified data and rebuilding the missing thumbnails, enter: %s'), 'php ' . FCPATH . 'index.php admin system tools_check_comics repair') . PHP_EOL;
         } else {
             echo _('Successfully repaired your library.') . PHP_EOL;
         }
     }
 }