PageRenderTime 49ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

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

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