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

