Annotation of /mambo/branches/4.5.3h/index.php
Parent Directory
|
Revision Log
Revision 1542 - (view) (download)
| 1 : | alwarren | 1542 | <?php |
| 2 : | /** | ||
| 3 : | * @package Mambo | ||
| 4 : | * @author Mambo Foundation Inc see README.php | ||
| 5 : | * @copyright Mambo Foundation Inc. | ||
| 6 : | * See COPYRIGHT.php for copyright notices and details. | ||
| 7 : | * @license GNU/GPL Version 2, see LICENSE.php | ||
| 8 : | * Mambo is free software; you can redistribute it and/or | ||
| 9 : | * modify it under the terms of the GNU General Public License | ||
| 10 : | * as published by the Free Software Foundation; version 2 of the License. | ||
| 11 : | */ | ||
| 12 : | |||
| 13 : | // fix to address the globals overwrite problem in php versions < 4.4.1 | ||
| 14 : | $protect_globals = array('_REQUEST', '_GET', '_POST', '_COOKIE', '_FILES', '_SERVER', '_ENV', 'GLOBALS', '_SESSION'); | ||
| 15 : | foreach ($protect_globals as $global) { | ||
| 16 : | if ( in_array($global , array_keys($_REQUEST)) || | ||
| 17 : | in_array($global , array_keys($_GET)) || | ||
| 18 : | in_array($global , array_keys($_POST)) || | ||
| 19 : | in_array($global , array_keys($_COOKIE)) || | ||
| 20 : | in_array($global , array_keys($_FILES))) { | ||
| 21 : | die("Invalid Request."); | ||
| 22 : | } | ||
| 23 : | } | ||
| 24 : | |||
| 25 : | /** Set flag that this is a parent file */ | ||
| 26 : | define( '_VALID_MOS', 1 ); | ||
| 27 : | session_start(); | ||
| 28 : | if (!isset($_SESSION['initiated'])) { | ||
| 29 : | session_regenerate_id(); | ||
| 30 : | $_SESSION['initiated'] = true; | ||
| 31 : | } | ||
| 32 : | // checks for configuration file, if none found loads installation page | ||
| 33 : | if ( !file_exists( 'configuration.php' ) || filesize( 'configuration.php' ) < 10 ) { | ||
| 34 : | header( 'Location: installation/index.php' ); | ||
| 35 : | exit(); | ||
| 36 : | } | ||
| 37 : | |||
| 38 : | include_once( 'globals.php' ); | ||
| 39 : | require_once( 'configuration.php' ); | ||
| 40 : | |||
| 41 : | // displays offline page | ||
| 42 : | if ( $mosConfig_offline == 1 ){ | ||
| 43 : | include( 'offline.php' ); | ||
| 44 : | exit(); | ||
| 45 : | } | ||
| 46 : | |||
| 47 : | require_once( 'includes/mambo.php' ); | ||
| 48 : | if (file_exists( 'components/com_sef/sef.php' )) { | ||
| 49 : | require_once( 'components/com_sef/sef.php' ); | ||
| 50 : | } else { | ||
| 51 : | require_once( 'includes/sef.php' ); | ||
| 52 : | } | ||
| 53 : | require_once( 'includes/frontend.php' ); | ||
| 54 : | |||
| 55 : | /* | ||
| 56 : | Installation sub folder check, removed for work with CVS*/ | ||
| 57 : | if (file_exists( 'installation/index.php' )) { | ||
| 58 : | include ('offline.php'); | ||
| 59 : | exit(); | ||
| 60 : | } | ||
| 61 : | /**/ | ||
| 62 : | /** retrieve some expected url (or form) arguments */ | ||
| 63 : | $option = trim( strtolower( mosGetParam( $_REQUEST, 'option' ) ) ); | ||
| 64 : | $Itemid = intval( mosGetParam( $_REQUEST, 'Itemid', null ) ); | ||
| 65 : | $database = new database( $mosConfig_host, $mosConfig_user, $mosConfig_password, $mosConfig_db, $mosConfig_dbprefix ); | ||
| 66 : | $database->debug( $mosConfig_debug ); | ||
| 67 : | $acl = new gacl_api(); | ||
| 68 : | |||
| 69 : | //--- Start Nok Kaew Patch | ||
| 70 : | $mosConfig_nok_content='0'; | ||
| 71 : | if (file_exists( 'components/com_nokkaew/nokkaew.php' )) { | ||
| 72 : | $mosConfig_nok_content='1'; // can also go into the configuration - but this might be overwritten! | ||
| 73 : | require_once( "administrator/components/com_nokkaew/nokkaew.class.php"); | ||
| 74 : | require_once( "components/com_nokkaew/classes/nokkaew.class.php"); | ||
| 75 : | } | ||
| 76 : | |||
| 77 : | if( $mosConfig_nok_content ) { | ||
| 78 : | $database = new mlDatabase( $mosConfig_host, $mosConfig_user, $mosConfig_password, $mosConfig_db, $mosConfig_dbprefix ); | ||
| 79 : | } else { | ||
| 80 : | $database = new database( $mosConfig_host, $mosConfig_user, $mosConfig_password, $mosConfig_db, $mosConfig_dbprefix ); | ||
| 81 : | } | ||
| 82 : | if ($mosConfig_nok_content) { | ||
| 83 : | $mosConfig_defaultLang = $mosConfig_lang; // Save the default language of the site | ||
| 84 : | $iso_client_lang = NokKaew::discoverLanguage( $database ); | ||
| 85 : | $_NOKKAEW_MANAGER = new NokKaewManager(); | ||
| 86 : | } | ||
| 87 : | |||
| 88 : | //--- End Nok Kaew Patch | ||
| 89 : | if ($option == '') { | ||
| 90 : | if ($Itemid) { | ||
| 91 : | $query = "SELECT id, link" | ||
| 92 : | . "\n FROM #__menu" | ||
| 93 : | . "\n WHERE menutype='mainmenu'" | ||
| 94 : | . "\n AND id = '$Itemid'" | ||
| 95 : | . "\n AND published = '1'" | ||
| 96 : | ; | ||
| 97 : | $database->setQuery( $query ); | ||
| 98 : | } else { | ||
| 99 : | $query = "SELECT id, link" | ||
| 100 : | . "\n FROM #__menu" | ||
| 101 : | . "\n WHERE menutype='mainmenu' AND published='1'" | ||
| 102 : | . "\n ORDER BY parent, ordering LIMIT 1" | ||
| 103 : | ; | ||
| 104 : | $database->setQuery( $query ); | ||
| 105 : | } | ||
| 106 : | $menu = new mosMenu( $database ); | ||
| 107 : | if ($database->loadObject( $menu )) { | ||
| 108 : | $Itemid = $menu->id; | ||
| 109 : | } | ||
| 110 : | $link = $menu->link; | ||
| 111 : | if (($pos = strpos( $link, '?' )) !== false) { | ||
| 112 : | $link = substr( $link, $pos+1 ). '&Itemid='.$Itemid; | ||
| 113 : | } | ||
| 114 : | parse_str( $link, $temp ); | ||
| 115 : | /** this is a patch, need to rework when globals are handled better */ | ||
| 116 : | foreach ($temp as $k=>$v) { | ||
| 117 : | $GLOBALS[$k] = $v; | ||
| 118 : | $_REQUEST[$k] = $v; | ||
| 119 : | if ($k == 'option') { | ||
| 120 : | $option = $v; | ||
| 121 : | } | ||
| 122 : | } | ||
| 123 : | } | ||
| 124 : | |||
| 125 : | /** mainframe is an API workhorse, lots of 'core' interaction routines */ | ||
| 126 : | $mainframe = new mosMainFrame( $database, $option, '.' ); | ||
| 127 : | $mainframe->initSession(); | ||
| 128 : | |||
| 129 : | // checking if we can find the Itemid thru the content | ||
| 130 : | if ( $option == 'com_content' && $Itemid === 0 ) { | ||
| 131 : | $id = intval( mosGetParam( $_REQUEST, 'id', 0 ) ); | ||
| 132 : | $Itemid = $mainframe->getItemid( $id ); | ||
| 133 : | } | ||
| 134 : | |||
| 135 : | /** do we have a valid Itemid yet?? */ | ||
| 136 : | if ( $Itemid === null ) { | ||
| 137 : | /** Nope, just use the homepage then. */ | ||
| 138 : | $query = "SELECT id" | ||
| 139 : | . "\n FROM #__menu" | ||
| 140 : | . "\n WHERE menutype='mainmenu'" | ||
| 141 : | . "\n AND published='1'" | ||
| 142 : | . "\n ORDER BY parent, ordering" | ||
| 143 : | . "\n LIMIT 1" | ||
| 144 : | ; | ||
| 145 : | $database->setQuery( $query ); | ||
| 146 : | $Itemid = $database->loadResult(); | ||
| 147 : | } | ||
| 148 : | |||
| 149 : | /** patch to lessen the impact on templates */ | ||
| 150 : | if ($option == 'search') { | ||
| 151 : | $option = 'com_search'; | ||
| 152 : | } | ||
| 153 : | |||
| 154 : | // loads english language file by default | ||
| 155 : | if ( $mosConfig_lang == '' ) { | ||
| 156 : | $mosConfig_lang = 'english'; | ||
| 157 : | } | ||
| 158 : | include_once ( 'language/'.$mosConfig_lang.'.php' ); | ||
| 159 : | |||
| 160 : | // frontend login & logout controls | ||
| 161 : | $return = mosGetParam( $_REQUEST, 'return', NULL ); | ||
| 162 : | if ($option == "login") { | ||
| 163 : | $mainframe->login(); | ||
| 164 : | |||
| 165 : | // JS Popup message | ||
| 166 : | if ( mosGetParam( $_POST, 'message', 0 ) ) { | ||
| 167 : | ?> | ||
| 168 : | <script> | ||
| 169 : | <!--// | ||
| 170 : | alert( "<?php echo _LOGIN_SUCCESS; ?>" ); | ||
| 171 : | //--> | ||
| 172 : | </script> | ||
| 173 : | <?php | ||
| 174 : | } | ||
| 175 : | |||
| 176 : | if ($return) { | ||
| 177 : | mosRedirect( $return ); | ||
| 178 : | } else { | ||
| 179 : | mosRedirect( 'index.php' ); | ||
| 180 : | } | ||
| 181 : | |||
| 182 : | } else if ($option == "logout") { | ||
| 183 : | $mainframe->logout(); | ||
| 184 : | |||
| 185 : | // JS Popup message | ||
| 186 : | if ( mosGetParam( $_POST, 'message', 0 ) ) { | ||
| 187 : | ?> | ||
| 188 : | <script> | ||
| 189 : | <!--// | ||
| 190 : | alert( "<?php echo _LOGOUT_SUCCESS; ?>" ); | ||
| 191 : | //--> | ||
| 192 : | </script> | ||
| 193 : | <?php | ||
| 194 : | } | ||
| 195 : | |||
| 196 : | if ($return) { | ||
| 197 : | mosRedirect( $return ); | ||
| 198 : | } else { | ||
| 199 : | mosRedirect( 'index.php' ); | ||
| 200 : | } | ||
| 201 : | } | ||
| 202 : | |||
| 203 : | /** get the information about the current user from the sessions table */ | ||
| 204 : | $my = $mainframe->getUser(); | ||
| 205 : | |||
| 206 : | /** detect first visit */ | ||
| 207 : | $mainframe->detect(); | ||
| 208 : | |||
| 209 : | $gid = intval( $my->gid ); | ||
| 210 : | |||
| 211 : | // gets template for page | ||
| 212 : | $cur_template = $mainframe->getTemplate(); | ||
| 213 : | /** temp fix - this feature is currently disabled */ | ||
| 214 : | |||
| 215 : | /** @global A places to store information from processing of the component */ | ||
| 216 : | $_MOS_OPTION = array(); | ||
| 217 : | |||
| 218 : | // precapture the output of the component | ||
| 219 : | require_once( $mosConfig_absolute_path . '/editor/editor.php' ); | ||
| 220 : | |||
| 221 : | ob_start(); | ||
| 222 : | if ($path = $mainframe->getPath( 'front' )) { | ||
| 223 : | $task = mosGetParam( $_REQUEST, 'task', '' ); | ||
| 224 : | $ret = mosMenuCheck( $Itemid, $option, $task, $gid ); | ||
| 225 : | if ($ret) { | ||
| 226 : | require_once( $path ); | ||
| 227 : | } else { | ||
| 228 : | mosNotAuth(); | ||
| 229 : | } | ||
| 230 : | } else { | ||
| 231 : | echo _NOT_EXIST; | ||
| 232 : | } | ||
| 233 : | $_MOS_OPTION['buffer'] = ob_get_contents(); | ||
| 234 : | ob_end_clean(); | ||
| 235 : | |||
| 236 : | initGzip(); | ||
| 237 : | |||
| 238 : | header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); | ||
| 239 : | header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); | ||
| 240 : | header( 'Cache-Control: no-store, no-cache, must-revalidate' ); | ||
| 241 : | header( 'Cache-Control: post-check=0, pre-check=0', false ); | ||
| 242 : | header( 'Pragma: no-cache' ); | ||
| 243 : | |||
| 244 : | // loads template file | ||
| 245 : | if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) { | ||
| 246 : | echo _TEMPLATE_WARN . $cur_template; | ||
| 247 : | } else { | ||
| 248 : | require_once( 'templates/'. $cur_template .'/index.php' ); | ||
| 249 : | echo "<!-- ".time()." -->"; | ||
| 250 : | } | ||
| 251 : | |||
| 252 : | // displays queries performed for page | ||
| 253 : | if ($mosConfig_debug) { | ||
| 254 : | echo $database->_ticker . ' queries executed'; | ||
| 255 : | echo '<pre>'; | ||
| 256 : | foreach ($database->_log as $k=>$sql) { | ||
| 257 : | echo $k+1 . "\n" . $sql . '<hr />'; | ||
| 258 : | } | ||
| 259 : | } | ||
| 260 : | |||
| 261 : | doGzip(); | ||
| 262 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

