PageRenderTime 23ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/exchange/code/trunk/administrator/components/com_exchange/exchange.php

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 72 lines | 39 code | 13 blank | 20 comment | 8 complexity | d3e40fa6fe21728c0ba0ff630ecabd63 MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: exchange.php 280 2010-09-18 02:14:15Z eddieajau $
  4. * @package NewLifeInIT
  5. * @subpackage com_exchange
  6. * @copyright Copyright 2005 - 2010 New Life in IT Pty Ltd. All rights reserved.
  7. * @license GNU General Public License version 2 or later.
  8. * @link http://www.theartofjoomla.com
  9. */
  10. // no direct access
  11. defined('_JEXEC') or die;
  12. require_once(JPATH_COMPONENT.'/version.php');
  13. require_once(JPATH_COMPONENT.'/helper.php');
  14. // Determine the request protocol
  15. $protocol = JRequest::getWord('protocol');
  16. // Get task command from the request
  17. $cmd = JRequest::getVar('task', null);
  18. // If it was a multiple option post get the selected option
  19. if (is_array($cmd)) {
  20. $cmd = array_pop(array_keys($cmd));
  21. }
  22. // Filter the command and instantiate the appropriate controller
  23. $cmd = JFilterInput::clean($cmd,'cmd');
  24. if (strpos($cmd, '.') != false) {
  25. // We have a defined controller/task pair -- lets split them out
  26. list($controllerName, $task) = explode('.', $cmd);
  27. // Define the controller name and path
  28. $controllerName = strtolower($controllerName);
  29. $controllerFile = ($protocol) ? $controllerName.'.'.$protocol : $controllerName;
  30. $controllerPath = JPATH_COMPONENT.DS.'controllers'.DS.$controllerFile.'.php';
  31. // If the controller file path exists, include it ... else lets die with a 500 error
  32. if (file_exists($controllerPath)) {
  33. require_once($controllerPath);
  34. }
  35. else {
  36. JError::raiseError(500, 'Invalid Controller');
  37. }
  38. }
  39. else {
  40. require_once(JPATH_COMPONENT.DS.'controller.php');
  41. // Base controller, just set the task :)
  42. $controllerName = null;
  43. $task = $cmd;
  44. }
  45. // Set the name for the controller and instantiate it
  46. $controllerClass = 'ExchangeController'.ucfirst($controllerName);
  47. if (class_exists($controllerClass)) {
  48. $controller = new $controllerClass();
  49. } else {
  50. JError::raiseError(500, 'Invalid Controller Class');
  51. }
  52. // Perform the Request task
  53. $controller->execute($task);
  54. // Redirect if set by the controller
  55. $controller->redirect();
  56. $version = new ExchangeVersion;
  57. echo '<div id="nlitcopy">Exchange Version '.$version->version.'.'.$version->subversion.':'.$version->getBuild().' '.$version->status;
  58. echo ' &bull; Please support us by <a href="http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,4759/Itemid,35/" target="_blank" style="font-weight:bold">rating or writing a review</a> about this extension';
  59. echo '</div>';