[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @ Version: $Id: index.php 1878 2008-01-25 21:26:29Z datahell $ 4 * @ Copyright: Copyright (C) 2006-2008 Elxis.org. All rights reserved. 5 * @ Package: Elxis 6 * @ Subpackage: Elxis 7 * @ Author: Elxis Team 8 * @ E-mail: info@elxis.org 9 * @ URL: http://www.elxis.org 10 * @ License: http://www.gnu.org/copyleft/gpl.html GNU/GPL 11 * Elxis CMS is a Free Software 12 */ 13 14 require_once ( 'includes/Core/security.php' ); 15 16 define( '_VALID_MOS', 1 ); 17 session_start(); 18 19 //checks for configuration file, if none found loads installation page 20 if ( !file_exists( 'configuration.php' ) || filesize( 'configuration.php' ) < 10 ) { 21 header( 'Location: installation/index.php' ); 22 exit(); 23 } 24 25 include_once ( 'globals.php' ); 26 require_once( 'configuration.php' ); 27 28 if (file_exists($mosConfig_absolute_path.'/installation/index.php')) { 29 include ( $mosConfig_absolute_path.'/offline.php' ); 30 exit(); 31 } 32 33 require_once ( $mosConfig_absolute_path.'/includes/Core/loader.php' ); 34 35 $database = new database( $mosConfig_host, $mosConfig_user, $mosConfig_password, $mosConfig_db, $mosConfig_dbprefix, $mosConfig_dbtype ); 36 $database->debug( $mosConfig_debug ); 37 $acl = new gacl_api(); 38 39 if ($mosConfig_offline == 2) { 40 $mosConfig_offline = 1; 41 $GLOBALS['mosConfig_offline'] = 1; 42 $scook = md5( 'site'.$mosConfig_live_site); 43 if (isset($_COOKIE[$scook])) { 44 $sesid = md5($_COOKIE[$scook].$_SERVER['REMOTE_ADDR']); 45 $database->setQuery("SELECT COUNT(*) FROM #__session WHERE session_id='$sesid' AND gid='25'"); 46 if (intval($database->loadResult()) > 0) { 47 $mosConfig_offline = 0; 48 $GLOBALS['mosConfig_offline'] = 0; 49 } 50 } 51 } 52 53 if ($mosConfig_offline == 1) { 54 include ( $mosConfig_absolute_path.'/offline.php' ); 55 exit(); 56 } 57 58 require_once ( $mosConfig_absolute_path.'/includes/sef.php' ); 59 require_once ( $mosConfig_absolute_path.'/includes/frontend.php' ); 60 61 /** retrieve some expected url (or form) arguments */ 62 $option = strval( strtolower( mosGetParam( $_REQUEST, 'option' ) ) ); 63 $Itemid = intval( mosGetParam( $_REQUEST, 'Itemid', 0 ) ); 64 65 if ($option == '') { 66 if ($Itemid) { 67 $query = "SELECT id, link FROM #__menu WHERE menutype='mainmenu'" 68 . "\n AND id = '$Itemid' AND published = '1'" 69 . "\n AND ((language IS NULL) OR (language LIKE '%$lang%'))"; 70 $database->setQuery( $query, '#__', 1, 0 ); 71 } else { 72 $query = "SELECT id, link FROM #__menu" 73 . "\n WHERE menutype='mainmenu' AND published='1'" 74 . "\n AND ((language IS NULL) OR (language LIKE '%$lang%'))" 75 . "\n ORDER BY parent, ordering "; 76 $database->setQuery( $query, '#__', 1, 0 ); 77 } 78 $menu = new mosMenu( $database ); 79 if ($database->loadObject( $menu )) { 80 $Itemid = $menu->id; 81 } 82 $link = $menu->link; 83 if (($pos = strpos( $link, '?' )) !== false) { 84 $link = substr( $link, $pos+1 ). '&Itemid='.$Itemid; 85 } 86 parse_str( $link, $temp ); 87 /** this is a patch, need to rework when globals are handled better */ 88 foreach ($temp as $k=>$v) { 89 $GLOBALS[$k] = $v; 90 $_REQUEST[$k] = $v; 91 if ($k == 'option') { 92 $option = $v; 93 } 94 } 95 } 96 97 /** mainframe is an API workhorse, lots of 'core' interaction routines */ 98 $mainframe = new mosMainFrame( $database, $option, '.' ); 99 $mainframe->initSession(); 100 101 // checking if we can find the Itemid thru the content 102 if ( $option == 'com_content' && $Itemid === 0 ) { 103 $id = intval( mosGetParam( $_REQUEST, 'id', 0 ) ); 104 $Itemid = intval($mainframe->getItemid( $id )); 105 } 106 107 /** do we have a valid Itemid yet?? */ 108 if ( $Itemid === 0 ) { 109 /** Nope, just use the homepage then. */ 110 $query = "SELECT id FROM #__menu" 111 . "\n WHERE menutype='mainmenu' AND published='1'" 112 . "\n AND ((language IS NULL) OR (language LIKE '%$lang%'))" 113 . "\n ORDER BY parent, ordering"; 114 $database->setQuery( $query, '#__', 1, 0 ); 115 $Itemid = intval($database->loadResult()); 116 } 117 118 /** patch to lessen the impact on templates */ 119 if ($option == 'search') { 120 $option = 'com_search'; 121 } 122 123 //frontend login & logout controls 124 $return = strval( mosGetParam( $_REQUEST, 'return', NULL ) ); 125 if ($option == 'login') { 126 $mainframe->login(); 127 128 if ( mosGetParam( $_POST, 'message', 0 ) ) { 129 ?> 130 <script language="javascript" type="text/javascript"> 131 <!-- 132 alert( "<?php echo _LOGIN_SUCCESS; ?>" ); 133 //--> 134 </script> 135 <?php 136 } 137 if ($return) { 138 mosRedirect( $return ); 139 } else { 140 mosRedirect( 'index.php' ); 141 } 142 143 } else if ($option == 'logout') { 144 $mainframe->logout(); 145 146 if ( mosGetParam( $_POST, 'message', 0 ) ) { 147 ?> 148 <script language="javascript" type="text/javascript"> 149 <!-- 150 alert( "<?php echo _LOGOUT_SUCCESS; ?>" ); 151 //--> 152 </script> 153 <?php 154 } 155 if ($return) { 156 mosRedirect( $return ); 157 } else { 158 mosRedirect( 'index.php' ); 159 } 160 } 161 162 /** get the information about the current user from the sessions table */ 163 $my = $mainframe->getUser(); 164 165 //Elxis Access Control System 166 @require_once ( $mosConfig_absolute_path.'/includes/Core/access.control.php' ); 167 168 /** detect first visit */ 169 $mainframe->detect(); 170 171 $gid = intval( $my->gid ); 172 173 // gets template for page 174 $cur_template = $mainframe->getTemplate(); 175 /** temp fix - this feature is currently disabled */ 176 177 /** @global A places to store information from processing of the component */ 178 $_MOS_OPTION = array(); 179 180 // precapture the output of the component 181 require_once ( $mosConfig_absolute_path.'/editor/editor.php' ); 182 183 ob_start(); 184 if ($path = $mainframe->getPath( 'front' )) { 185 $task = strval(mosGetParam( $_REQUEST, 'task', '' )); 186 $ret = mosMenuCheck( $Itemid, $option, $task, $gid ); 187 if ($ret) { 188 require_once( $path ); 189 } else { 190 mosNotAuth(); 191 } 192 } else { 193 @header( 'HTTP/1.0 404 Not Found' ); 194 echo _NOT_EXIST; 195 } 196 197 $_MOS_OPTION['buffer'] = ob_get_contents(); 198 ob_end_clean(); 199 200 initGzip(); 201 202 if(!headers_sent()) { 203 header( 'Content-type: text/html; charset=utf-8' ); 204 header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); 205 header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); 206 header( 'Cache-Control: no-store, no-cache, must-revalidate' ); 207 header( 'Cache-Control: post-check=0, pre-check=0', false ); 208 header( 'Pragma: no-cache' ); 209 } 210 211 // loads template file 212 if ( !file_exists( $mosConfig_absolute_path.'/templates/'.$cur_template.'/index.php' ) ) { 213 echo _TEMPLATE_WARN . $cur_template; 214 } else { 215 require_once( $mosConfig_absolute_path.'/templates/'.$cur_template.'/index.php' ); 216 echo '<!-- '.time().' -->'._LEND; 217 } 218 219 // displays queries performed for page 220 if ($mosConfig_debug) { 221 echo $database->_ticker . ' queries executed'; 222 echo '<pre>'._LEND; 223 foreach ($database->_log as $k=>$sql) { 224 echo $k+1 . _LEND . $sql . '<hr />'._LEND; 225 } 226 echo '</pre>'._LEND; 227 } 228 229 doGzip(); 230 //close FTP connection if we used it 231 $fmanager->closeFTP(); 232 233 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body