Annotation of /mambo/branches/4.6/index.php
Parent Directory
|
Revision Log
Revision 656 - (view) (download)
| 1 : | csouza | 129 | <?php |
| 2 : | /** | ||
| 3 : | csouza | 297 | * @package Mambo Open Source |
| 4 : | * @copyright (C) 2005 - 2006 Mambo Foundation Inc. | ||
| 5 : | csouza | 129 | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
| 6 : | csouza | 297 | * |
| 7 : | * Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure | ||
| 8 : | * that Mambo remained free Open Source software owned and managed by the community. | ||
| 9 : | csouza | 129 | * Mambo is Free Software |
| 10 : | neilt | 453 | */ |
| 11 : | csouza | 129 | |
| 12 : | /** Set flag that this is a parent file */ | ||
| 13 : | if (!defined('_VALID_MOS')) define( '_VALID_MOS', 1 ); | ||
| 14 : | |||
| 15 : | $protects = array('_REQUEST', '_GET', '_POST', '_COOKIE', '_FILES', '_SERVER', '_ENV', 'GLOBALS', '_SESSION'); | ||
| 16 : | |||
| 17 : | foreach ($protects as $protect) { | ||
| 18 : | csouza | 154 | if ( in_array($protect , array_keys($_REQUEST)) || |
| 19 : | in_array($protect , array_keys($_GET)) || | ||
| 20 : | in_array($protect , array_keys($_POST)) || | ||
| 21 : | in_array($protect , array_keys($_COOKIE)) || | ||
| 22 : | in_array($protect , array_keys($_FILES))) { | ||
| 23 : | die("Invalid Request."); | ||
| 24 : | } | ||
| 25 : | csouza | 129 | } |
| 26 : | |||
| 27 : | /** | ||
| 28 : | * Utility function to return a value from a named array or a specified default | ||
| 29 : | */ | ||
| 30 : | define( "_MOS_NOTRIM", 0x0001 ); | ||
| 31 : | define( "_MOS_ALLOWHTML", 0x0002 ); | ||
| 32 : | define( "_MOS_ALLOWRAW", 0x0004 ); | ||
| 33 : | define( "_MOS_NOMAGIC", 0x0008 ); | ||
| 34 : | function mosGetParam( &$arr, $name, $def=null, $mask=0 ) { | ||
| 35 : | csouza | 154 | if (isset( $arr[$name] )) { |
| 36 : | if (is_array($arr[$name])) foreach ($arr[$name] as $key=>$element) $result[$key] = mosGetParam ($arr[$name], $key, $def, $mask); | ||
| 37 : | else { | ||
| 38 : | $result = $arr[$name]; | ||
| 39 : | if (!($mask&_MOS_NOTRIM)) $result = trim($result); | ||
| 40 : | if (!is_numeric( $result)) { | ||
| 41 : | if (!($mask&_MOS_ALLOWHTML)) $result = strip_tags($result); | ||
| 42 : | if (!($mask&_MOS_ALLOWRAW)) { | ||
| 43 : | if (is_numeric($def)) $result = intval($result); | ||
| 44 : | } | ||
| 45 : | } | ||
| 46 : | } | ||
| 47 : | return $result; | ||
| 48 : | } else { | ||
| 49 : | return $def; | ||
| 50 : | } | ||
| 51 : | csouza | 129 | } |
| 52 : | |||
| 53 : | function sefRelToAbs ($string) { | ||
| 54 : | counterpoi | 238 | t $sef =& mosSEF::getInstance(); |
| 55 : | csouza | 154 | return $sef->sefRelToAbs($string); |
| 56 : | csouza | 129 | } |
| 57 : | |||
| 58 : | neilt | 656 | if (!isset($adminside)) $adminside = 0; |
| 59 : | if (!isset($indextype)) $indextype = 1; | ||
| 60 : | csouza | 129 | |
| 61 : | csouza | 529 | require_once (dirname(__FILE__).'/includes/database.php'); |
| 62 : | require_once(dirname(__FILE__).'/includes/core.classes.php'); | ||
| 63 : | mambo | 157 | $configuration =& mamboCore::getMamboCore(); |
| 64 : | $configuration->handleGlobals(); | ||
| 65 : | |||
| 66 : | |||
| 67 : | csouza | 129 | require($configuration->rootPath().'/includes/version.php'); |
| 68 : | $_VERSION =& new version(); | ||
| 69 : | |||
| 70 : | csouza | 530 | |
| 71 : | csouza | 129 | $version = $_VERSION->PRODUCT .' '. $_VERSION->RELEASE .'.'. $_VERSION->DEV_LEVEL .' ' |
| 72 : | . $_VERSION->DEV_STATUS | ||
| 73 : | .' [ '.$_VERSION->CODENAME .' ] '. $_VERSION->RELDATE .' ' | ||
| 74 : | . $_VERSION->RELTIME .' '. $_VERSION->RELTZ; | ||
| 75 : | |||
| 76 : | if (phpversion() < '4.2.0') require_once( $configuration->rootPath() . '/includes/compat.php41x.php' ); | ||
| 77 : | if (phpversion() < '4.3.0') require_once( $configuration->rootPath() . '/includes/compat.php42x.php' ); | ||
| 78 : | |||
| 79 : | $local_backup_path = $configuration->rootPath().'/administrator/backups'; | ||
| 80 : | $media_path = $configuration->rootPath().'/media/'; | ||
| 81 : | $image_path = $configuration->rootPath().'/images/stories'; | ||
| 82 : | csouza | 252 | $lang_path = $configuration->rootPath().'/language'; |
| 83 : | csouza | 129 | $image_size = 100; |
| 84 : | |||
| 85 : | counterpoi | 238 | t $database =& mamboDatabase::getInstance(); |
| 86 : | csouza | 129 | $database->debug(mamboCore::get('mosConfig_debug')); |
| 87 : | |||
| 88 : | csouza | 252 | |
| 89 : | csouza | 129 | if (!$adminside) { |
| 90 : | csouza | 154 | $sefcode = $configuration->rootPath().'/components/com_sef/sef.php'; |
| 91 : | if (file_exists($sefcode)) require_once($sefcode); | ||
| 92 : | else require_once($configuration->rootPath().'/includes/sef.php'); | ||
| 93 : | $urlerror = 0; | ||
| 94 : | if (mamboCore::get('mosConfig_sef') AND $indextype == 3) { | ||
| 95 : | counterpoi | 238 | t $sef =& mosSEF::getInstance(); |
| 96 : | csouza | 154 | $urlerror = $sef->sefRetrieval(mamboCore::get('mosConfig_register_globals')); |
| 97 : | $indextype = 1; | ||
| 98 : | } | ||
| 99 : | csouza | 129 | } |
| 100 : | |||
| 101 : | /** retrieve some possible request string (or form) arguments */ | ||
| 102 : | $type = mosGetParam($_REQUEST, 'type', 1); | ||
| 103 : | $act = mosGetParam( $_REQUEST, 'act', '' ); | ||
| 104 : | $do_pdf = mosGetParam( $_REQUEST, 'do_pdf', 0 ); | ||
| 105 : | $id = mosGetParam( $_REQUEST, 'id', 0 ); | ||
| 106 : | $task = mosGetParam($_REQUEST, 'task', ''); | ||
| 107 : | $act = strtolower(mosGetParam($_REQUEST, 'act', '')); | ||
| 108 : | $section = mosGetParam($_REQUEST, 'section', ''); | ||
| 109 : | $no_html = strtolower(mosGetParam($_REQUEST, 'no_html', '')); | ||
| 110 : | neilt | 488 | $cid = (array) mosGetParam( $_POST, 'cid', array() ); |
| 111 : | csouza | 129 | |
| 112 : | counterpoi | 422 | t ini_set('session.use_trans_sid', 0); |
| 113 : | t ini_set('session.use_cookies', 1); | ||
| 114 : | t ini_set('session.use_only_cookies', 1); | ||
| 115 : | t | ||
| 116 : | counterpoi | 449 | t |
| 117 : | csouza | 556 | /* initialize i18n */ |
| 118 : | $lang = $configuration->current_language->name; | ||
| 119 : | $charset = $configuration->current_language->charset; | ||
| 120 : | $gettext =& phpgettext(); | ||
| 121 : | $gettext->debug = $configuration->mosConfig_locale_debug; | ||
| 122 : | $gettext->has_gettext = $configuration->mosConfig_locale_use_gettext; | ||
| 123 : | $gettext->setlocale($lang); | ||
| 124 : | $gettext->bindtextdomain($lang, $configuration->rootPath().'/language'); | ||
| 125 : | $gettext->textdomain($lang); | ||
| 126 : | #$gettext =& phpgettext(); dump($gettext); | ||
| 127 : | |||
| 128 : | csouza | 129 | if ($adminside) { |
| 129 : | csouza | 154 | // Start ACL |
| 130 : | require_once($configuration->rootPath().'/includes/gacl.class.php' ); | ||
| 131 : | require_once($configuration->rootPath().'/includes/gacl_api.class.php' ); | ||
| 132 : | $acl = new gacl_api(); | ||
| 133 : | // Handle special admin side options | ||
| 134 : | $option = strtolower(mosGetParam($_REQUEST,'option','com_admin')); | ||
| 135 : | csouza | 252 | |
| 136 : | $domain = substr($option, 4); | ||
| 137 : | counterpoi | 422 | t session_name(md5(mamboCore::get('mosConfig_live_site'))); |
| 138 : | t session_start(); | ||
| 139 : | csouza | 556 | // restore some session variables |
| 140 : | $my = new mosUser(); | ||
| 141 : | $my->getSession(); | ||
| 142 : | if (mosSession::validate($my)) { | ||
| 143 : | mosSession::purge(); | ||
| 144 : | } else { | ||
| 145 : | mosSession::purge(); | ||
| 146 : | $my = null; | ||
| 147 : | } | ||
| 148 : | counterpoi | 422 | t if (!$my AND $option == 'login') { |
| 149 : | csouza | 154 | require_once($configuration->rootPath().'/includes/authenticator.php'); |
| 150 : | counterpoi | 238 | t $authenticator =& mamboAuthenticator::getInstance(); |
| 151 : | csouza | 154 | $my = $authenticator->loginAdmin($acl); |
| 152 : | } | ||
| 153 : | counterpoi | 422 | t // Handle the remaining special options |
| 154 : | t elseif ($option == 'logout') { | ||
| 155 : | t require($configuration->rootPath().'/administrator/logout.php'); | ||
| 156 : | t exit(); | ||
| 157 : | csouza | 154 | } |
| 158 : | // We can now create the mainframe object | ||
| 159 : | $mainframe =& new mosMainFrame($database, $option, '..', true); | ||
| 160 : | // Provided $my is set, we have a valid admin side session and can include remaining code | ||
| 161 : | if ($my) { | ||
| 162 : | mamboCore::set('currentUser', $my); | ||
| 163 : | counterpoi | 422 | t if ($option == 'simple_mode') $admin_mode = 'on'; |
| 164 : | t elseif ($option == 'advanced_mode') $admin_mode = 'off'; | ||
| 165 : | t else $admin_mode = mosGetParam($_SESSION, 'simple_editing', ''); | ||
| 166 : | t $_SESSION['simple_editing'] = mosGetParam($_POST, 'simple_editing', $admin_mode); | ||
| 167 : | t require_once($configuration->rootPath().'/administrator/includes/admin.php'); | ||
| 168 : | csouza | 154 | require_once( $configuration->rootPath().'/includes/mambo.php' ); |
| 169 : | require_once ($configuration->rootPath().'/includes/mambofunc.php'); | ||
| 170 : | require_once ($configuration->rootPath().'/includes/mamboHTML.php'); | ||
| 171 : | require_once( $configuration->rootPath().'/administrator/includes/mosAdminMenus.php'); | ||
| 172 : | require_once($configuration->rootPath().'/administrator/includes/admin.php'); | ||
| 173 : | require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); | ||
| 174 : | csouza | 403 | require_once( $configuration->rootPath() . '/components/com_content/content.class.php' ); |
| 175 : | counterpoi | 238 | t $_MAMBOTS =& mosMambotHandler::getInstance(); |
| 176 : | csouza | 252 | |
| 177 : | csouza | 403 | |
| 178 : | csouza | 154 | // If no_html is set, we avoid starting the template, and go straight to the component |
| 179 : | if ($no_html) { | ||
| 180 : | if ($path = $mainframe->getPath( "admin" )) require $path; | ||
| 181 : | exit(); | ||
| 182 : | } | ||
| 183 : | $configuration->initGzip(); | ||
| 184 : | // When adminside = 3 we assume that HTML is being explicitly written and do nothing more | ||
| 185 : | if ($adminside != 3) { | ||
| 186 : | $path = $configuration->rootPath().'/administrator/templates/'.$mainframe->getTemplate().'/index.php'; | ||
| 187 : | require_once($path); | ||
| 188 : | $configuration->doGzip(); | ||
| 189 : | } | ||
| 190 : | else { | ||
| 191 : | csouza | 302 | if (!isset($popup)) { |
| 192 : | csouza | 252 | $pop = mosGetParam($_REQUEST, 'pop', ''); |
| 193 : | counterpoi | 419 | t if ($pop) require($configuration->rootPath()."/administrator/popups/$pop"); |
| 194 : | t else require($configuration->rootPath()."/administrator/popups/index3pop.php"); | ||
| 195 : | csouza | 252 | $configuration->doGzip(); |
| 196 : | } | ||
| 197 : | csouza | 154 | } |
| 198 : | } | ||
| 199 : | counterpoi | 422 | t // If $my was not set, the only possibility is to offer a login screen |
| 200 : | csouza | 154 | else { |
| 201 : | $configuration->initGzip(); | ||
| 202 : | $path = $configuration->rootPath().'/administrator/templates/'.$mainframe->getTemplate().'/login.php'; | ||
| 203 : | require_once( $path ); | ||
| 204 : | $configuration->doGzip(); | ||
| 205 : | } | ||
| 206 : | csouza | 129 | } |
| 207 : | // Finished admin side; the rest is user side code: | ||
| 208 : | else { | ||
| 209 : | csouza | 154 | $option = $configuration->determineOptionAndItemid(); |
| 210 : | $configuration->handleGlobals(); | ||
| 211 : | $Itemid = $configuration->get('Itemid'); | ||
| 212 : | csouza | 129 | |
| 213 : | csouza | 154 | $mainframe =& new mosMainFrame($database, $option, '.'); |
| 214 : | counterpoi | 223 | t if ($option == 'login') $configuration->handleLogin(); |
| 215 : | t elseif ($option == 'logout') $configuration->handleLogout(); | ||
| 216 : | t | ||
| 217 : | counterpoi | 238 | t $session =& mosSession::getCurrent(); |
| 218 : | counterpoi | 419 | t $my =& new mosUser(); |
| 219 : | csouza | 154 | $my->getSessionData(); |
| 220 : | mamboCore::set('currentUser',$my); | ||
| 221 : | $configuration->offlineCheck($my, $database); | ||
| 222 : | $gid = intval( $my->gid ); | ||
| 223 : | // gets template for page | ||
| 224 : | $cur_template = $mainframe->getTemplate(); | ||
| 225 : | csouza | 129 | |
| 226 : | csouza | 154 | require_once( $configuration->rootPath().'/includes/frontend.php' ); |
| 227 : | require_once( $configuration->rootPath().'/includes/mambo.php' ); | ||
| 228 : | require_once ($configuration->rootPath().'/includes/mambofunc.php'); | ||
| 229 : | require_once ($configuration->rootPath().'/includes/mamboHTML.php'); | ||
| 230 : | csouza | 129 | |
| 231 : | csouza | 154 | if ($indextype == 2 AND $do_pdf == 1 ) { |
| 232 : | include_once('includes/pdf.php'); | ||
| 233 : | exit(); | ||
| 234 : | } | ||
| 235 : | csouza | 129 | |
| 236 : | csouza | 154 | /** detect first visit */ |
| 237 : | $mainframe->detect(); | ||
| 238 : | csouza | 129 | |
| 239 : | csouza | 154 | /** @global mosPlugin $_MAMBOTS */ |
| 240 : | counterpoi | 238 | t $_MAMBOTS =& mosMambotHandler::getInstance(); |
| 241 : | csouza | 154 | require_once( $configuration->rootPath().'/editor/editor.php' ); |
| 242 : | require_once( $configuration->rootPath() . '/includes/gacl.class.php' ); | ||
| 243 : | require_once( $configuration->rootPath() . '/includes/gacl_api.class.php' ); | ||
| 244 : | counterpoi | 270 | t require_once( $configuration->rootPath() . '/components/com_content/content.class.php' ); |
| 245 : | csouza | 154 | $acl = new gacl_api(); |
| 246 : | csouza | 403 | |
| 247 : | csouza | 154 | /** Get the component handler */ |
| 248 : | require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); | ||
| 249 : | csouza | 236 | $c_handler =& mosComponentHandler::getInstance(); |
| 250 : | csouza | 154 | $c_handler->startBuffer(); |
| 251 : | csouza | 129 | |
| 252 : | csouza | 154 | if (!$urlerror AND $path = $mainframe->getPath( 'front' )) { |
| 253 : | counterpoi | 238 | t $menuhandler =& mosMenuHandler::getInstance(); |
| 254 : | csouza | 154 | $ret = $menuhandler->menuCheck($Itemid, $option, $task, $gid); |
| 255 : | $menuhandler->setPathway($Itemid); | ||
| 256 : | csouza | 252 | if ($ret) { |
| 257 : | counterpoi | 390 | t require ($path); |
| 258 : | csouza | 252 | } |
| 259 : | csouza | 154 | else mosNotAuth(); |
| 260 : | } | ||
| 261 : | else { | ||
| 262 : | header ('HTTP/1.1 404 Not Found'); | ||
| 263 : | csouza | 183 | $mainframe->setPageTitle(T_('404 Error - page not found')); |
| 264 : | csouza | 154 | include ($configuration->rootPath().'/page404.php'); |
| 265 : | } | ||
| 266 : | csouza | 129 | |
| 267 : | csouza | 154 | $c_handler->endBuffer(); |
| 268 : | csouza | 129 | |
| 269 : | csouza | 154 | $configuration->initGzip(); |
| 270 : | csouza | 129 | |
| 271 : | csouza | 154 | $configuration->standardHeaders(); |
| 272 : | counterpoi | 270 | t if (mosGetParam($_GET, 'syndstyle', '') == 'yes') mosMainBody(); |
| 273 : | t elseif ($indextype == 1) { | ||
| 274 : | csouza | 154 | // loads template file |
| 275 : | if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) { | ||
| 276 : | csouza | 183 | echo '<font color=\"red\"><b>'.T_('Template File Not Found! Looking for template').'</b></font>'.$cur_template; |
| 277 : | csouza | 154 | } else { |
| 278 : | require_once( 'templates/'. $cur_template .'/index.php' ); | ||
| 279 : | counterpoi | 238 | t $mambothandler =& mosMambotHandler::getInstance(); |
| 280 : | csouza | 154 | $mambothandler->loadBotGroup('system'); |
| 281 : | $mambothandler->trigger('afterTemplate', array($configuration)); | ||
| 282 : | echo "<!-- ".time()." -->"; | ||
| 283 : | } | ||
| 284 : | } | ||
| 285 : | elseif ($indextype == 2) { | ||
| 286 : | if ( $no_html == 0 ) { | ||
| 287 : | // needed to seperate the ISO number from the language file constant _ISO | ||
| 288 : | $iso = split( '=', _ISO ); | ||
| 289 : | // xml prolog | ||
| 290 : | echo '<?xml version="1.0" encoding="'. $iso[1] .'"?' .'>'; | ||
| 291 : | csouza | 129 | ?> |
| 292 : | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
| 293 : | <html xmlns="http://www.w3.org/1999/xhtml"> | ||
| 294 : | <head> | ||
| 295 : | <link rel="stylesheet" href="templates/<?php echo $cur_template;?>/css/template_css.css" type="text/css" /> | ||
| 296 : | <meta http-equiv="Content-Type" content="text/html; <?php echo _ISO; ?>" /> | ||
| 297 : | <meta name="robots" content="noindex, nofollow"> | ||
| 298 : | </head> | ||
| 299 : | <body class="contentpane"> | ||
| 300 : | <?php mosMainBody(); ?> | ||
| 301 : | </body> | ||
| 302 : | </html> | ||
| 303 : | <?php | ||
| 304 : | csouza | 154 | } else { |
| 305 : | mosMainBody(); | ||
| 306 : | } | ||
| 307 : | } | ||
| 308 : | csouza | 129 | |
| 309 : | csouza | 154 | $configuration->doGzip(); |
| 310 : | csouza | 129 | } |
| 311 : | // displays queries performed for page | ||
| 312 : | counterpoi | 419 | t if ($configuration->get('mosConfig_debug') AND $adminside != 3) $database->displayLogged(); |
| 313 : | csouza | 129 | |
| 314 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

