PageRenderTime 41ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/administrator/components/com_jevents/jevents.php

https://bitbucket.org/kraymitchell/saiu
PHP | 144 lines | 77 code | 24 blank | 43 comment | 18 complexity | 0a374c4e06ac85aceb74429702ef34bb MD5 | raw file
Possible License(s): GPL-2.0, LGPL-3.0, BSD-3-Clause, LGPL-2.1, GPL-3.0
  1. <?php
  2. /**
  3. * JEvents Component for Joomla 1.5.x
  4. *
  5. * @version $Id: jevents.php 3552 2012-04-20 09:41:53Z geraintedwards $
  6. * @package JEvents
  7. * @copyright Copyright (C) 2008-2012 GWE Systems Ltd
  8. * @license GNU/GPLv2, see http://www.gnu.org/licenses/gpl-2.0.html
  9. * @link http://www.jevents.net
  10. */
  11. defined( 'JPATH_BASE' ) or die( 'Direct Access to this location is not allowed.' );
  12. if (version_compare(phpversion(), '5.0.0', '<')===true) {
  13. echo '<div style="font:12px/1.35em arial, helvetica, sans-serif;"><div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;"><h3 style="margin:0; font-size:1.7em; font-weight:normal; text-transform:none; text-align:left; color:#2f2f2f;">'.JText::_("JEV_INVALID_PHP1").'</h3></div>'.JText::_("JEV_INVALID_PHP2").'</div>';
  14. return;
  15. }
  16. // remove metadata.xml if its there.
  17. jimport('joomla.filesystem.file');
  18. if (JFile::exists(JPATH_COMPONENT_SITE.DS."metadata.xml")){
  19. JFile::delete(JPATH_COMPONENT_SITE.DS."metadata.xml");
  20. }
  21. //error_reporting(E_ALL);
  22. jimport('joomla.filesystem.path');
  23. // Get Joomla version.
  24. $version = new JVersion();
  25. $jver = explode( '.', $version->getShortVersion() );
  26. //version_compare(JVERSION,'1.5.0',">=")
  27. if (!isset($option)) $option = JRequest::getCmd("option"); // 1.6 mod
  28. define("JEV_COM_COMPONENT",$option);
  29. define("JEV_COMPONENT",str_replace("com_","",$option));
  30. include_once(JPATH_COMPONENT_ADMINISTRATOR.DS.JEV_COMPONENT.".defines.php");
  31. $registry =& JRegistry::getInstance("jevents");
  32. /*
  33. * frontend only!
  34. // In Joomla 1.6 JComponentHelper::getParams(JEV_COM_COMPONENT) is a clone so the menu params do not propagate so we force this here!
  35. if (JVersion::isCompatible("1.6.0")){
  36. $newparams = JFactory::getApplication()->getParams();
  37. $component =& JComponentHelper::getComponent(JEV_COM_COMPONENT);
  38. $component->params =& $newparams;
  39. }
  40. */
  41. // See http://www.php.net/manual/en/timezones.php
  42. $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
  43. if ($params->get("icaltimezonelive","")!="" && is_callable("date_default_timezone_set") && $params->get("icaltimezonelive","")!=""){
  44. $timezone= date_default_timezone_get();
  45. date_default_timezone_set($params->get("icaltimezonelive",""));
  46. $registry->setValue("jevents.timezone",$timezone);
  47. }
  48. if (!JVersion::isCompatible("1.6.0")){
  49. // Multi-category events only supported in Joomla 2.5 + so disable elsewhere
  50. $params->set('multicategory',0);
  51. }
  52. // Thanks to ssobada
  53. if (JVersion::isCompatible("1.6.0")){
  54. $authorisedonly = $params->get("authorisedonly", 0);
  55. $user = JFactory::getUser();
  56. //Stop if user is not authorised to access JEevents CPanel
  57. if (!$authorisedonly && !$user->authorise('core.manage', 'com_jevents')) {
  58. return;
  59. }
  60. }
  61. // Must also load frontend language files
  62. $lang =& JFactory::getLanguage();
  63. $lang->load(JEV_COM_COMPONENT, JPATH_SITE);
  64. if (!version_compare(JVERSION,'1.6.0',">=")){
  65. // Load Site specific language overrides - can't use getTemplate since wer'e in the admin interface
  66. $db =& JFactory::getDBO();
  67. $query = 'SELECT template'
  68. . ' FROM #__templates_menu'
  69. . ' WHERE client_id = 0 AND menuid=0'
  70. . ' ORDER BY menuid DESC'
  71. . ' LIMIT 1'
  72. ;
  73. $db->setQuery($query);
  74. $template = $db->loadResult();
  75. $lang->load(JEV_COM_COMPONENT, JPATH_SITE.DS."templates".DS.$template);
  76. }
  77. // disable Zend php4 compatability mode
  78. @ini_set("zend.ze1_compatibility_mode","Off");
  79. // Split tasl into command and task
  80. $cmd = JRequest::getCmd('task', 'cpanel.show');
  81. if (strpos($cmd, '.') != false) {
  82. // We have a defined controller/task pair -- lets split them out
  83. list($controllerName, $task) = explode('.', $cmd);
  84. // Define the controller name and path
  85. $controllerName = strtolower($controllerName);
  86. $controllerPath = JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php';
  87. $controllerName = "Admin".$controllerName;
  88. // If the controller file path exists, include it ... else lets die with a 500 error
  89. if (file_exists($controllerPath)) {
  90. require_once($controllerPath);
  91. } else {
  92. JError::raiseError(500, 'Invalid Controller');
  93. }
  94. } else {
  95. // Base controller, just set the task
  96. $controllerName = null;
  97. $task = $cmd;
  98. }
  99. // Make the task available later
  100. JRequest::setVar("jevtask",$cmd);
  101. JRequest::setVar("jevcmd",$cmd);
  102. JPluginHelper::importPlugin("jevents");
  103. // Make this a config option - should not normally be needed
  104. //$db = JFactory::getDBO();
  105. //$db->setQuery( "SET SQL_BIG_SELECTS=1");
  106. //$db->query();
  107. // Set the name for the controller and instantiate it
  108. $controllerClass = ucfirst($controllerName).'Controller';
  109. if (class_exists($controllerClass)) {
  110. $controller = new $controllerClass();
  111. } else {
  112. JError::raiseError(500, 'Invalid Controller Class - '.$controllerClass );
  113. }
  114. // record what is running - used by the filters
  115. $registry =& JRegistry::getInstance("jevents");
  116. $registry->setValue("jevents.activeprocess","administrator");
  117. // Perform the Request task
  118. $controller->execute($task);
  119. // Redirect if set by the controller
  120. $controller->redirect();