PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/upload/admin/controller/tool/error_log.php

https://github.com/opencartlite/opencart
PHP | 63 lines | 45 code | 18 blank | 0 comment | 4 complexity | da2a24775096f2cc746593598376a260 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, GPL-3.0
  1. <?php
  2. class ControllerToolErrorLog extends Controller {
  3. private $error = array();
  4. public function index() {
  5. $this->data += $this->language->load('tool/error_log');
  6. $this->document->setTitle($this->language->get('heading_title'));
  7. if (isset($this->session->data['success'])) {
  8. $this->data['success'] = $this->session->data['success'];
  9. unset($this->session->data['success']);
  10. } else {
  11. $this->data['success'] = '';
  12. }
  13. $this->data['breadcrumbs'] = array();
  14. $this->data['breadcrumbs'][] = array(
  15. 'text' => $this->language->get('text_home'),
  16. 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL')
  17. );
  18. $this->data['breadcrumbs'][] = array(
  19. 'text' => $this->language->get('heading_title'),
  20. 'href' => $this->url->link('tool/error_log', 'token=' . $this->session->data['token'], 'SSL')
  21. );
  22. $this->data['clear'] = $this->url->link('tool/error_log/clear', 'token=' . $this->session->data['token'], 'SSL');
  23. $file = DIR_LOGS . $this->config->get('config_error_filename');
  24. if (file_exists($file)) {
  25. $this->data['log'] = file_get_contents($file, FILE_USE_INCLUDE_PATH, null);
  26. } else {
  27. $this->data['log'] = '';
  28. }
  29. $this->template = 'tool/error_log.tpl';
  30. $this->children = array(
  31. 'common/header',
  32. 'common/footer'
  33. );
  34. $this->response->setOutput($this->render());
  35. }
  36. public function clear() {
  37. $this->data += $this->language->load('tool/error_log');
  38. $file = DIR_LOGS . $this->config->get('config_error_filename');
  39. $handle = fopen($file, 'w+');
  40. fclose($handle);
  41. $this->session->data['success'] = $this->language->get('text_success');
  42. $this->redirect($this->url->link('tool/error_log', 'token=' . $this->session->data['token'], 'SSL'));
  43. }
  44. }
  45. ?>