Annotation of /mambo/branches/4.6/index.php
Parent Directory
|
Revision Log
Revision 112 - (view) (download)
| 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 : | csouza | 39 | |
| 35 : | // loads english language file by default | ||
| 36 : | if ( $mosConfig_lang == '' ) { | ||
| 37 : | $mosConfig_lang = 'english'; | ||
| 38 : | } | ||
| 39 : | #include_once ( 'language/'.$mosConfig_lang.'.php' ); | ||
| 40 : | DEFINE('_ISO','charset=iso-8859-1'); | ||
| 41 : | DEFINE('_DATE_FORMAT_LC',"%A, %d %B %Y"); //Uses PHP's strftime Command Format | ||
| 42 : | DEFINE('_DATE_FORMAT_LC2',"%A, %d %B %Y %H:%M"); | ||
| 43 : | |||
| 44 : | // include phpgettext library | ||
| 45 : | require_once( 'includes/phpgettext/phpgettext.class.php' ); | ||
| 46 : | $domain = 'frontend'; | ||
| 47 : | $textdomain = $mosConfig_absolute_path.'language'; | ||
| 48 : | $charset = 'utf-8'; | ||
| 49 : | $phpgettext =& phpgettext(); | ||
| 50 : | $phpgettext->setlocale($mosConfig_lang); | ||
| 51 : | $phpgettext->bindtextdomain($domain, $textdomain); | ||
| 52 : | $phpgettext->bind_textdomain_codeset($domain, $charset); | ||
| 53 : | $phpgettext->textdomain($domain); | ||
| 54 : | |||
| 55 : | |||
| 56 : | root | 1 | // displays offline page |
| 57 : | if ( $mosConfig_offline == 1 ){ | ||
| 58 : | include( 'offline.php' ); | ||
| 59 : | exit(); | ||
| 60 : | } | ||
| 61 : | |||
| 62 : | require_once( 'includes/mambo.php' ); | ||
| 63 : | if (file_exists( 'components/com_sef/sef.php' )) { | ||
| 64 : | require_once( 'components/com_sef/sef.php' ); | ||
| 65 : | } else { | ||
| 66 : | require_once( 'includes/sef.php' ); | ||
| 67 : | } | ||
| 68 : | require_once( 'includes/frontend.php' ); | ||
| 69 : | |||
| 70 : | /* | ||
| 71 : | csouza | 39 | Installation sub folder check, removed for work with CVS* / |
| 72 : | root | 1 | if (file_exists( 'installation/index.php' )) { |
| 73 : | include ('offline.php'); | ||
| 74 : | exit(); | ||
| 75 : | } | ||
| 76 : | /**/ | ||
| 77 : | /** retrieve some expected url (or form) arguments */ | ||
| 78 : | $option = trim( strtolower( mosGetParam( $_REQUEST, 'option' ) ) ); | ||
| 79 : | $Itemid = intval( mosGetParam( $_REQUEST, 'Itemid', null ) ); | ||
| 80 : | $database = new database( $mosConfig_host, $mosConfig_user, $mosConfig_password, $mosConfig_db, $mosConfig_dbprefix ); | ||
| 81 : | $database->debug( $mosConfig_debug ); | ||
| 82 : | $acl = new gacl_api(); | ||
| 83 : | |||
| 84 : | if ($option == '') { | ||
| 85 : | if ($Itemid) { | ||
| 86 : | $query = "SELECT id, link" | ||
| 87 : | . "\n FROM #__menu" | ||
| 88 : | . "\n WHERE menutype='mainmenu'" | ||
| 89 : | . "\n AND id = '$Itemid'" | ||
| 90 : | . "\n AND published = '1'" | ||
| 91 : | ; | ||
| 92 : | $database->setQuery( $query ); | ||
| 93 : | } else { | ||
| 94 : | $query = "SELECT id, link" | ||
| 95 : | . "\n FROM #__menu" | ||
| 96 : | . "\n WHERE menutype='mainmenu' AND published='1'" | ||
| 97 : | . "\n ORDER BY parent, ordering LIMIT 1" | ||
| 98 : | ; | ||
| 99 : | $database->setQuery( $query ); | ||
| 100 : | } | ||
| 101 : | $menu = new mosMenu( $database ); | ||
| 102 : | if ($database->loadObject( $menu )) { | ||
| 103 : | $Itemid = $menu->id; | ||
| 104 : | } | ||
| 105 : | $link = $menu->link; | ||
| 106 : | if (($pos = strpos( $link, '?' )) !== false) { | ||
| 107 : | $link = substr( $link, $pos+1 ). '&Itemid='.$Itemid; | ||
| 108 : | } | ||
| 109 : | parse_str( $link, $temp ); | ||
| 110 : | /** this is a patch, need to rework when globals are handled better */ | ||
| 111 : | foreach ($temp as $k=>$v) { | ||
| 112 : | $GLOBALS[$k] = $v; | ||
| 113 : | $_REQUEST[$k] = $v; | ||
| 114 : | if ($k == 'option') { | ||
| 115 : | $option = $v; | ||
| 116 : | } | ||
| 117 : | } | ||
| 118 : | } | ||
| 119 : | |||
| 120 : | /** mainframe is an API workhorse, lots of 'core' interaction routines */ | ||
| 121 : | $mainframe = new mosMainFrame( $database, $option, '.' ); | ||
| 122 : | $mainframe->initSession(); | ||
| 123 : | |||
| 124 : | // checking if we can find the Itemid thru the content | ||
| 125 : | if ( $option == 'com_content' && $Itemid === 0 ) { | ||
| 126 : | $id = intval( mosGetParam( $_REQUEST, 'id', 0 ) ); | ||
| 127 : | $Itemid = $mainframe->getItemid( $id ); | ||
| 128 : | } | ||
| 129 : | |||
| 130 : | /** do we have a valid Itemid yet?? */ | ||
| 131 : | if ( $Itemid === 0 ) { | ||
| 132 : | /** Nope, just use the homepage then. */ | ||
| 133 : | $query = "SELECT id" | ||
| 134 : | . "\n FROM #__menu" | ||
| 135 : | . "\n WHERE menutype='mainmenu'" | ||
| 136 : | . "\n AND published='1'" | ||
| 137 : | . "\n ORDER BY parent, ordering" | ||
| 138 : | . "\n LIMIT 1" | ||
| 139 : | ; | ||
| 140 : | $database->setQuery( $query ); | ||
| 141 : | $Itemid = $database->loadResult(); | ||
| 142 : | } | ||
| 143 : | |||
| 144 : | /** patch to lessen the impact on templates */ | ||
| 145 : | if ($option == 'search') { | ||
| 146 : | $option = 'com_search'; | ||
| 147 : | } | ||
| 148 : | |||
| 149 : | |||
| 150 : | csouza | 39 | |
| 151 : | |||
| 152 : | root | 1 | // frontend login & logout controls |
| 153 : | $return = mosGetParam( $_REQUEST, 'return', NULL ); | ||
| 154 : | if ($option == "login") { | ||
| 155 : | $mainframe->login(); | ||
| 156 : | |||
| 157 : | // JS Popup message | ||
| 158 : | mambo | 112 | if ( mosGetParam( $_POST, 'message', 0 ) ) { |
| 159 : | root | 1 | ?> |
| 160 : | <script> | ||
| 161 : | <!--// | ||
| 162 : | csouza | 39 | alert( "<?php echo T_('You have Logged In succesfully'); ?>" ); |
| 163 : | root | 1 | //--> |
| 164 : | </script> | ||
| 165 : | <?php | ||
| 166 : | } | ||
| 167 : | |||
| 168 : | if ($return) { | ||
| 169 : | mosRedirect( $return ); | ||
| 170 : | } else { | ||
| 171 : | mosRedirect( 'index.php' ); | ||
| 172 : | } | ||
| 173 : | |||
| 174 : | } else if ($option == "logout") { | ||
| 175 : | $mainframe->logout(); | ||
| 176 : | |||
| 177 : | // JS Popup message | ||
| 178 : | mambo | 112 | if ( mosGetParam( $_POST, 'message', 0 ) ) { |
| 179 : | root | 1 | ?> |
| 180 : | <script> | ||
| 181 : | <!--// | ||
| 182 : | csouza | 39 | alert( "<?php echo T_('You have Logged Out successfully'); ?>" ); |
| 183 : | root | 1 | //--> |
| 184 : | </script> | ||
| 185 : | <?php | ||
| 186 : | } | ||
| 187 : | |||
| 188 : | if ($return) { | ||
| 189 : | mosRedirect( $return ); | ||
| 190 : | } else { | ||
| 191 : | mosRedirect( 'index.php' ); | ||
| 192 : | } | ||
| 193 : | } | ||
| 194 : | |||
| 195 : | /** get the information about the current user from the sessions table */ | ||
| 196 : | $my = $mainframe->getUser(); | ||
| 197 : | |||
| 198 : | /** detect first visit */ | ||
| 199 : | $mainframe->detect(); | ||
| 200 : | |||
| 201 : | $gid = intval( $my->gid ); | ||
| 202 : | |||
| 203 : | // gets template for page | ||
| 204 : | $cur_template = $mainframe->getTemplate(); | ||
| 205 : | /** temp fix - this feature is currently disabled */ | ||
| 206 : | |||
| 207 : | /** @global A places to store information from processing of the component */ | ||
| 208 : | $_MOS_OPTION = array(); | ||
| 209 : | |||
| 210 : | // precapture the output of the component | ||
| 211 : | require_once( $mosConfig_absolute_path . '/editor/editor.php' ); | ||
| 212 : | |||
| 213 : | ob_start(); | ||
| 214 : | if ($path = $mainframe->getPath( 'front' )) { | ||
| 215 : | $task = mosGetParam( $_REQUEST, 'task', '' ); | ||
| 216 : | $ret = mosMenuCheck( $Itemid, $option, $task, $gid ); | ||
| 217 : | if ($ret) { | ||
| 218 : | csouza | 39 | $phpgettext->textdomain($option); |
| 219 : | root | 1 | require_once( $path ); |
| 220 : | } else { | ||
| 221 : | mosNotAuth(); | ||
| 222 : | } | ||
| 223 : | } else { | ||
| 224 : | csouza | 39 | echo T_('The page you are trying to access does not exist. Please select a page from the main menu.'); |
| 225 : | root | 1 | } |
| 226 : | $_MOS_OPTION['buffer'] = ob_get_contents(); | ||
| 227 : | ob_end_clean(); | ||
| 228 : | |||
| 229 : | initGzip(); | ||
| 230 : | |||
| 231 : | header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); | ||
| 232 : | header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); | ||
| 233 : | header( 'Cache-Control: no-store, no-cache, must-revalidate' ); | ||
| 234 : | header( 'Cache-Control: post-check=0, pre-check=0', false ); | ||
| 235 : | header( 'Pragma: no-cache' ); | ||
| 236 : | |||
| 237 : | // loads template file | ||
| 238 : | if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) { | ||
| 239 : | csouza | 39 | |
| 240 : | echo "<font color=\"red\"><b>" . sprintf(T_('Template File Not Found! Looking for template: %s'), $cur_template) ."</b></font>"; | ||
| 241 : | root | 1 | } else { |
| 242 : | require_once( 'templates/'. $cur_template .'/index.php' ); | ||
| 243 : | echo "<!-- ".time()." -->"; | ||
| 244 : | } | ||
| 245 : | |||
| 246 : | // displays queries performed for page | ||
| 247 : | if ($mosConfig_debug) { | ||
| 248 : | csouza | 39 | printf(Tn_('%d query executed', '%d queries executed', $database->_ticker), $database->_ticker); |
| 249 : | root | 1 | echo '<pre>'; |
| 250 : | foreach ($database->_log as $k=>$sql) { | ||
| 251 : | echo $k+1 . "\n" . $sql . '<hr />'; | ||
| 252 : | } | ||
| 253 : | csouza | 39 | echo '</pre>'; |
| 254 : | root | 1 | } |
| 255 : | |||
| 256 : | doGzip(); | ||
| 257 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

