PageRenderTime 2080ms CodeModel.GetById 18ms RepoModel.GetById 59ms app.codeStats 0ms

/administrator/components/com_akeeba/controllers/log.php

https://bitbucket.org/organicdevelopment/joomla-2.5
PHP | 90 lines | 58 code | 12 blank | 20 comment | 4 complexity | 56242d01e49bd7705b24782137a8459b MD5 | raw file
Possible License(s): LGPL-3.0, GPL-2.0, MIT, BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * @package AkeebaBackup
  4. * @copyright Copyright (c)2009-2012 Nicholas K. Dionysopoulos
  5. * @license GNU General Public License version 3, or later
  6. * @version $Id$
  7. * @since 1.3
  8. */
  9. // Protect from unauthorized access
  10. defined('_JEXEC') or die('Restricted Access');
  11. // Load framework base classes
  12. jimport('joomla.application.component.controller');
  13. /**
  14. * Log view controller class
  15. *
  16. */
  17. class AkeebaControllerLog extends JController
  18. {
  19. public function __construct($config = array()) {
  20. parent::__construct($config);
  21. if(AKEEBA_JVERSION=='16')
  22. {
  23. // Access check, Joomla! 1.6 style.
  24. $user = JFactory::getUser();
  25. if (!$user->authorise('akeeba.download', 'com_akeeba')) {
  26. $this->setRedirect('index.php?option=com_akeeba');
  27. return JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
  28. $this->redirect();
  29. }
  30. } else {
  31. // Custom ACL for Joomla! 1.5
  32. $aclModel = JModel::getInstance('Acl','AkeebaModel');
  33. if(!$aclModel->authorizeUser('download')) {
  34. $this->setRedirect('index.php?option=com_akeeba');
  35. return JError::raiseWarning(403, JText::_('Access Forbidden'));
  36. $this->redirect();
  37. }
  38. }
  39. }
  40. /**
  41. * Display the log page
  42. *
  43. */
  44. public function display()
  45. {
  46. AEPlatform::getInstance()->load_configuration(AEPlatform::getInstance()->get_active_profile());
  47. parent::display();
  48. }
  49. // Renders the contents of the log's iframe
  50. public function iframe()
  51. {
  52. AEPlatform::getInstance()->load_configuration(AEPlatform::getInstance()->get_active_profile());
  53. parent::display();
  54. flush();
  55. JFactory::getApplication()->close();
  56. }
  57. public function download()
  58. {
  59. AEPlatform::getInstance()->load_configuration(AEPlatform::getInstance()->get_active_profile());
  60. $tag = JRequest::getCmd('tag',null);
  61. $filename = AEUtilLogger::logName($tag);
  62. @ob_end_clean(); // In case some braindead plugin spits its own HTML
  63. header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  64. header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  65. header("Content-Description: File Transfer");
  66. header('Content-Type: text/plain');
  67. header('Content-Disposition: attachment; filename="Akeeba Backup Debug Log.txt"');
  68. echo "WARNING: Do not copy and paste lines from this file!\r\n";
  69. echo "You are supposed to ZIP and attach it in your support forum post.\r\n";
  70. echo "If you fail to do so, your support request will receive minimal priority.\r\n";
  71. echo "\r\n";
  72. echo "--- START OF RAW LOG --\r\n";
  73. @readfile($filename); // The at sign is necessary to skip showing PHP errors if the file doesn't exist or isn't readable for some reason
  74. echo "--- END OF RAW LOG ---\r\n";
  75. flush();
  76. JFactory::getApplication()->close();
  77. }
  78. }