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

/administrator/components/com_akeeba/akeeba.php

https://bitbucket.org/organicdevelopment/joomla-2.5
PHP | 173 lines | 121 code | 20 blank | 32 comment | 24 complexity | bc467517391bf218a9cf9755e806bf8d 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. JDEBUG ? define('AKEEBADEBUG', 1) : null;
  12. // Check for PHP4
  13. if(defined('PHP_VERSION')) {
  14. $version = PHP_VERSION;
  15. } elseif(function_exists('phpversion')) {
  16. $version = phpversion();
  17. } else {
  18. // No version info. I'll lie and hope for the best.
  19. $version = '5.0.0';
  20. }
  21. // Old PHP version detected. EJECT! EJECT! EJECT!
  22. if(!version_compare($version, '5.2.0', '>='))
  23. {
  24. return JError::raise(E_ERROR, 500, 'PHP 4.x, 5.0 and 5.1 is no longer supported by Akeeba Backup.','The version of PHP used on your site is obsolete and contains known security vulenrabilities. Moreover, it is missing features required by Akeeba Backup to work properly or at all. Please ask your host to upgrade your server to the latest PHP 5.2 or 5.3 release. Thank you!');
  25. }
  26. // Timezone fix; avoids errors printed out by PHP 5.3.3+ (thanks Yannick!)
  27. if(function_exists('date_default_timezone_get') && function_exists('date_default_timezone_set') && !version_compare(JVERSION,'1.6','ge')) {
  28. if(function_exists('error_reporting')) {
  29. $oldLevel = error_reporting(0);
  30. }
  31. $serverTimezone = @date_default_timezone_get();
  32. if(empty($serverTimezone) || !is_string($serverTimezone)) $serverTimezone = 'UTC';
  33. if(function_exists('error_reporting')) {
  34. error_reporting($oldLevel);
  35. }
  36. @date_default_timezone_set( $serverTimezone);
  37. }
  38. // Joomla! 1.6 detection
  39. jimport('joomla.filesystem.file');
  40. if(!version_compare( JVERSION, '1.6.0', 'ge' )) {
  41. define('AKEEBA_JVERSION','15');
  42. } else {
  43. define('AKEEBA_JVERSION','16');
  44. }
  45. if(!defined('AKEEBAENGINE')) {
  46. define('AKEEBAENGINE', 1); // Required for accessing Akeeba Engine's factory class
  47. define('AKEEBAROOT', dirname(__FILE__).'/akeeba');
  48. define('AKEEBAPLATFORM', 'joomla15'); // So that platform-specific stuff can get done!
  49. }
  50. // Setup Akeeba's ACLs, honoring laxed permissions in component's parameters, if set
  51. if(AKEEBA_JVERSION == '15')
  52. {
  53. $component = JComponentHelper::getComponent( 'com_akeeba' );
  54. $params = new JParameter($component->params);
  55. $acl = JFactory::getACL();
  56. if(method_exists($acl, 'addACL'))
  57. {
  58. $min_acl = $params->get('minimum_acl_group','super administrator');
  59. $acl->addACL('com_akeeba', 'manage', 'users', 'super administrator' );
  60. switch($min_acl)
  61. {
  62. case 'administrator':
  63. $acl->addACL('com_akeeba', 'manage', 'users', 'administrator' );
  64. break;
  65. case 'manager':
  66. $acl->addACL('com_akeeba', 'manage', 'users', 'administrator' );
  67. $acl->addACL('com_akeeba', 'manage', 'users', 'manager' );
  68. break;
  69. }
  70. }
  71. }
  72. else
  73. {
  74. // Access check, Joomla! 1.6 style.
  75. $user = JFactory::getUser();
  76. if (!$user->authorise('core.manage', 'com_akeeba')) {
  77. return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
  78. }
  79. }
  80. // Make sure we have a profile set throughout the component's lifetime
  81. $session = JFactory::getSession();
  82. $profile_id = $session->get('profile', null, 'akeeba');
  83. if(is_null($profile_id))
  84. {
  85. // No profile is set in the session; use default profile
  86. $session->set('profile', 1, 'akeeba');
  87. }
  88. // Get the view and controller from the request, or set to default if they weren't set
  89. JRequest::setVar('view', JRequest::getCmd('view','cpanel'));
  90. JRequest::setVar('c', JRequest::getCmd('view','cpanel')); // Black magic: Get controller based on the selected view
  91. // Load the factory
  92. require_once JPATH_COMPONENT_ADMINISTRATOR.'/akeeba/factory.php';
  93. // Load the Akeeba Backup configuration and check user access permission
  94. $aeconfig = AEFactory::getConfiguration();
  95. AEPlatform::getInstance()->load_configuration();
  96. unset($aeconfig);
  97. require_once JPATH_COMPONENT_ADMINISTRATOR.'/helpers/includes.php';
  98. require_once JPATH_COMPONENT_ADMINISTRATOR.'/helpers/escape.php';
  99. // Merge the default translation with the current translation
  100. $jlang = JFactory::getLanguage();
  101. // Front-end translation
  102. $jlang->load('com_akeeba', JPATH_SITE, 'en-GB', true);
  103. $jlang->load('com_akeeba', JPATH_SITE, $jlang->getDefault(), true);
  104. $jlang->load('com_akeeba', JPATH_SITE, null, true);
  105. // Back-end translation
  106. $jlang->load('com_akeeba', JPATH_ADMINISTRATOR, 'en-GB', true);
  107. $jlang->load('com_akeeba', JPATH_ADMINISTRATOR, $jlang->getDefault(), true);
  108. $jlang->load('com_akeeba', JPATH_ADMINISTRATOR, null, true);
  109. // Load the utils helper library
  110. AEPlatform::getInstance()->load_version_defines();
  111. // Create a versioning tag for our static files
  112. $staticFilesVersioningTag = md5(AKEEBA_VERSION.AKEEBA_DATE.AKEEBA_JVERSION);
  113. define('AKEEBAMEDIATAG', $staticFilesVersioningTag);
  114. // If JSON functions don't exist, load our compatibility layer
  115. if( (!function_exists('json_encode')) || (!function_exists('json_decode')) )
  116. {
  117. require_once JPATH_COMPONENT_ADMINISTRATOR.'/helpers/jsonlib.php';
  118. }
  119. // Handle Live Update requests
  120. require_once JPATH_COMPONENT_ADMINISTRATOR.'/liveupdate/liveupdate.php';
  121. if(JRequest::getCmd('view','') == 'liveupdate') {
  122. LiveUpdate::handleRequest();
  123. return;
  124. }
  125. // Load the appropriate controller
  126. $c = JRequest::getCmd('c','cpanel');
  127. $path = JPATH_COMPONENT_ADMINISTRATOR.'/controllers/'.$c.'.php';
  128. $alt_path = JPATH_COMPONENT_ADMINISTRATOR.'/plugins/controllers/'.$c.'.php';
  129. if(JFile::exists($alt_path))
  130. {
  131. // The requested controller exists and there you load it...
  132. require_once($alt_path);
  133. }
  134. elseif(JFile::exists($path))
  135. {
  136. require_once($path);
  137. }
  138. else
  139. {
  140. // Hmm... an invalid controller was passed
  141. JError::raiseError('500',JText::_('Unknown controller').' '.$c);
  142. }
  143. // Instanciate and execute the controller
  144. jimport('joomla.utilities.string');
  145. $c = 'AkeebaController'.ucfirst($c);
  146. $controller = new $c();
  147. if(AKEEBA_JVERSION=='15')
  148. {
  149. $controller->setAccessControl('com_akeeba','manage'); // Enforce Joomla!'s ACL
  150. }
  151. $controller->execute(JRequest::getCmd('task','display'));
  152. // Redirect
  153. $controller->redirect();