[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (wishy@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.sf.net 5 # 6 #This program is free software; you can redistribute it and/or modify 7 #it under the terms of the GNU General Public License as published by 8 #the Free Software Foundation; either version 2 of the License, or 9 #(at your option) any later version. 10 # 11 #This program is distributed in the hope that it will be useful, 12 #but WITHOUT ANY WARRANTY; without even the implied warranty of 13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 #GNU General Public License for more details. 15 #You should have received a copy of the GNU General Public License 16 #along with this program; if not, write to the Free Software 17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 # 19 #$Id$ 20 21 $dirname = dirname(__FILE__); 22 require_once ($dirname.DIRECTORY_SEPARATOR.'fileloc.php'); 23 24 $session_key = substr(md5($dirname), 0, 8); 25 26 #Setup session with different id and start it 27 @session_name('CMSSESSID' . $session_key); 28 @ini_set('url_rewriter.tags', ''); 29 @ini_set('session.use_trans_sid', 0); 30 #if(!@session_id()) { 31 if(!@session_id() && (isset($_REQUEST[session_name()]) || isset($CMS_ADMIN_PAGE))) 32 { 33 #Trans SID sucks also... 34 @ini_set('url_rewriter.tags', ''); 35 @ini_set('session.use_trans_sid', 0); 36 @session_start(); 37 } 38 39 /** 40 * This file is included in every page. It does all seutp functions including 41 * importing additional functions/classes, setting up sessions and nls, and 42 * construction of various important variables like $gCms. 43 * 44 * @package CMS 45 */ 46 #magic_quotes_runtime is a nuisance... turn it off before it messes something up 47 set_magic_quotes_runtime(false); 48 49 require_once ($dirname.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'misc.functions.php'); 50 debug_buffer('', 'Start of include'); 51 52 # sanitize $_GET 53 array_walk_recursive($_GET, 'sanitize_get_var'); 54 55 #Make a new CMS object 56 require(cms_join_path($dirname,'lib','classes','class.global.inc.php')); 57 $gCms =& new CmsObject(); 58 if (isset($starttime)) 59 { 60 $gCms->variables['starttime'] = $starttime; 61 } 62 63 #Load the config file (or defaults if it doesn't exist) 64 require(cms_join_path($dirname,'version.php')); 65 require(cms_join_path($dirname,'lib','config.functions.php')); 66 67 #Grab the current configuration 68 $config =& $gCms->GetConfig(); 69 70 #Hack for changed directory and no way to upgrade config.php 71 $config['previews_path'] = str_replace('smarty/cms', 'tmp', $config['previews_path']); 72 73 #Add users if they exist in the session 74 $gCms->variables['user_id'] = ''; 75 if (isset($_SESSION['cms_admin_user_id'])) 76 { 77 $gCms->variables['user_id'] = $_SESSION['cms_admin_user_id']; 78 } 79 80 $gCms->variables['username'] = ''; 81 if (isset($_SESSION['cms_admin_username'])) 82 { 83 $gCms->variables['username'] = $_SESSION['cms_admin_username']; 84 } 85 86 debug_buffer('loading smarty'); 87 require(cms_join_path($dirname,'lib','smarty','Smarty.class.php')); 88 debug_buffer('loading adodb'); 89 require(cms_join_path($dirname,'lib','adodb.functions.php')); 90 load_adodb(); 91 debug_buffer('loading page functions'); 92 require_once(cms_join_path($dirname,'lib','page.functions.php')); 93 debug_buffer('loading content functions'); 94 require_once(cms_join_path($dirname,'lib','content.functions.php')); 95 debug_buffer('loading pageinfo functions'); 96 require_once(cms_join_path($dirname,'lib','classes','class.pageinfo.inc.php')); 97 debug_buffer('loading translation functions'); 98 require_once(cms_join_path($dirname,'lib','translation.functions.php')); 99 debug_buffer('loading events functions'); 100 require_once(cms_join_path($dirname,'lib','classes','class.events.inc.php')); 101 102 if (isset($config['backwards_compatible']) && $config['backwards_compatible'] == true) 103 { 104 load_backwards_compatibility(); 105 } 106 107 debug_buffer('done loading files'); 108 109 #Load them into the usual variables. This'll go away a little later on. 110 global $DONT_LOAD_DB; 111 if (!isset($DONT_LOAD_DB)) 112 { 113 $cmsdb =& $gCms->GetDB(); 114 } 115 116 $smarty =& $gCms->GetSmarty(); 117 $contenttypes =& $gCms->contenttypes; 118 119 #Load content types 120 $dir = cms_join_path($dirname,'lib','classes','contenttypes'); 121 $handle=opendir($dir); 122 while ($file = readdir ($handle)) 123 { 124 $path_parts = pathinfo($file); 125 if (isset($path_parts['extension']) && $path_parts['extension'] == 'php') 126 { 127 $obj =& new CmsContentTypePlaceholder(); 128 $obj->type = strtolower(basename($file, '.inc.php')); 129 $obj->filename = cms_join_path($dir,$file); 130 $obj->loaded = false; 131 $obj->friendlyname = basename($file, '.inc.php'); 132 $contenttypes[strtolower(basename($file, '.inc.php'))] =& $obj; 133 } 134 } 135 closedir($handle); 136 137 if (!defined('SMARTY_DIR')) { 138 define('SMARTY_DIR', cms_join_path($dirname,'lib','smarty') . DIRECTORY_SEPARATOR); 139 } 140 141 #Stupid magic quotes... 142 if(get_magic_quotes_gpc()) 143 { 144 stripslashes_deep($_GET); 145 stripslashes_deep($_POST); 146 stripslashes_deep($_REQUEST); 147 stripslashes_deep($_COOKIE); 148 stripslashes_deep($_SESSION); 149 } 150 151 #Fix for IIS (and others) to make sure REQUEST_URI is filled in 152 if (!isset($_SERVER['REQUEST_URI'])) 153 { 154 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; 155 if(isset($_SERVER['QUERY_STRING'])) 156 { 157 $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; 158 } 159 } 160 161 #Setup the object sent to modules 162 $gCms->variables['pluginnum'] = 1; 163 if (isset($page)) 164 { 165 $gCms->variables['page'] = $page; 166 } 167 168 #Set a umask 169 $global_umask = get_site_preference('global_umask',''); 170 if( $global_umask != '' ) 171 { 172 @umask( $global_umask ); 173 } 174 175 #Set the locale if it's set 176 #either in the config, or as a site preference. 177 $frontendlang = get_site_preference('frontendlang',''); 178 if (isset($config['locale']) && $config['locale'] != '') 179 { 180 $frontendlang = $config['locale']; 181 } 182 if ($frontendlang != '') 183 { 184 @setlocale(LC_ALL, $frontendlang); 185 } 186 187 $smarty->assign('sitename', get_site_preference('sitename', 'CMSMS Site')); 188 $smarty->assign('lang',$frontendlang); 189 $smarty->assign('encoding',get_encoding()); 190 $smarty->assign_by_ref('gCms',$gCms); 191 192 if ($config['debug'] == true) 193 { 194 $smarty->debugging = true; 195 $smarty->error_reporting = 'E_ALL'; 196 } 197 if (isset($CMS_ADMIN_PAGE) || isset($CMS_STYLESHEET)) 198 { 199 include_once(cms_join_path($dirname,$config['admin_dir'],'lang.php')); 200 201 #This will only matter on upgrades now. All new stuff (0.13 on) will be UTF-8. 202 if (is_file(cms_join_path($dirname,'lib','convert','ConvertCharset.class.php'))) 203 { 204 include(cms_join_path($dirname,'lib','convert','ConvertCharset.class.php')); 205 $gCms->variables['convertclass'] =& new ConvertCharset(); 206 } 207 } 208 209 #Load all installed module code 210 $modload =& $gCms->GetModuleLoader(); 211 $modload->LoadModules(isset($LOAD_ALL_MODULES), !isset($CMS_ADMIN_PAGE)); 212 213 debug_buffer('', 'End of include'); 214 215 function sanitize_get_var(&$value, $key) 216 { 217 $value = eregi_replace('\<\/?script[^\>]*\>', '', $value); 218 } 219 220 function load_backwards_compatibility() 221 { 222 $dirname = dirname(__FILE__); 223 debug_buffer('loading template functions'); 224 require_once(cms_join_path($dirname,'lib','classes','class.templateoperations.inc.php')); 225 debug_buffer('loading gcb functions'); 226 require_once(cms_join_path($dirname,'lib','classes','class.globalcontentoperations.inc.php')); 227 debug_buffer('loading module class'); 228 require_once(cms_join_path($dirname,'lib','classes','class.moduleoperations.inc.php')); 229 debug_buffer('loading bookmark functions'); 230 require_once(cms_join_path($dirname,'lib','classes','class.bookmarkoperations.inc.php')); 231 debug_buffer('loading content class'); 232 require_once(cms_join_path($dirname,'lib','classes','class.contentoperations.inc.php')); 233 debug_buffer('loading user functions'); 234 require_once(cms_join_path($dirname,'lib','classes','class.useroperations.inc.php')); 235 debug_buffer('loading group functions'); 236 require_once(cms_join_path($dirname,'lib','classes','class.groupoperations.inc.php')); 237 debug_buffer('loading stylesheet functions'); 238 require_once(cms_join_path($dirname,'lib','classes','class.stylesheetoperations.inc.php')); 239 debug_buffer('loading user tags functions'); 240 require_once(cms_join_path($dirname,'lib','classes','class.usertagoperations.inc.php')); 241 } 242 243 # vim:ts=4 sw=4 noet 244 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |