public
Description: Git mirror of the CMS Made Simple 2.0 rewrite
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsmadesimple-2-0.git
tedkulp (author)
Thu Jan 12 17:30:35 -0800 2006
commit  b2a79cc3bf5b9945144ddcdebcdafaa893950249
tree    fd5954eab55ecb76b8a408882be84c7b211320e2
parent  e6ec90832804e0c443b8aa2e57027c9c5cadf12e
cmsmadesimple-2-0 / include.php
100644 202 lines (171 sloc) 6.026 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#$Id$
 
require_once(dirname(__FILE__).'/fileloc.php');
 
/**
* This file is included in every page. It does all seutp functions including
* importing additional functions/classes, setting up sessions and nls, and
* construction of various important variables like $gCms.
*
* @package CMS
*/
#magic_quotes_runtime is a nuisance... turn it off before it messes something up
set_magic_quotes_runtime(false);
 
#Setup session with different id and start it
@session_name("CMSSESSID");
@ini_set('url_rewriter.tags', '');
@ini_set('session.use_trans_sid', 0);
#if(!@session_id()) {
if(!@session_id() && (isset($_REQUEST[session_name()]) || isset($CMS_ADMIN_PAGE))) {
  #Trans SID sucks also...
  @ini_set('url_rewriter.tags', '');
  @ini_set('session.use_trans_sid', 0);
  @session_start();
}
 
require_once(dirname(__FILE__)."/lib/misc.functions.php");
 
#Make a new CMS object
require_once(dirname(__FILE__)."/lib/classes/class.global.inc.php");
$gCms = new CmsObject();
 
#Setup hash for storing all modules
$gCms->cmsmodules = array();
$gCms->userplugins = array();
$gCms->cmsplugins = array();
$gCms->siteprefs = array();
 
#Load the config file (or defaults if it doesn't exist)
require_once(dirname(__FILE__)."/version.php");
require_once(dirname(__FILE__)."/lib/config.functions.php");
 
#make a local reference
#if (cms_config_check_old_config()) {
#  cms_config_upgrade();
#}
#$config = cms_config_load(true);
$config =& $gCms->GetConfig();
 
#Hack for changed directory and no way to upgrade config.php
$config['previews_path'] = str_replace('smarty/cms', 'tmp', $config['previews_path']);
 
#Set the locale if it's set
if (isset($config['locale']) && $config['locale'] != '')
{
  @setlocale(LC_ALL, $config['locale']);
}
 
#Add users if they exist in the session
$gCms->variables["user_id"] = "";
if (isset($_SESSION["cms_admin_user_id"]))
{
  $gCms->variables["user_id"] = $_SESSION["cms_admin_user_id"];
}
 
$gCms->variables["username"] = "";
if (isset($_SESSION["cms_admin_username"]))
{
  $gCms->variables["username"] = $_SESSION["cms_admin_username"];
}
 
$sql_execs = 0;
$sql_queries = "";
 
function count_sql_execs($db, $sql, $inputarray)
{
  global $gCms;
  global $sql_execs;
  global $sql_queries;
  if (!is_array($inputarray)) $sql_execs++;
  else if (is_array(reset($inputarray))) $sql_execs += sizeof($inputarray);
  else $sql_execs++;
}
 
require_once(dirname(__FILE__).'/lib/smarty/Smarty.class.php');
require_once(dirname(__FILE__)."/lib/adodb/adodb.inc.php");
require_once(dirname(__FILE__)."/lib/page.functions.php");
require_once(dirname(__FILE__)."/lib/content.functions.php");
require_once(dirname(__FILE__)."/lib/classes/class.pageinfo.inc.php");
require_once(dirname(__FILE__)."/lib/classes/class.content.inc.php");
require_once(dirname(__FILE__)."/lib/classes/class.module.inc.php");
require_once(dirname(__FILE__)."/lib/classes/class.user.inc.php");
require_once(dirname(__FILE__).'/lib/classes/class.htmlblob.inc.php');
require_once(dirname(__FILE__).'/lib/classes/class.template.inc.php');
require_once(dirname(__FILE__).'/lib/classes/class.stylesheet.inc.php');
require_once(dirname(__FILE__).'/lib/classes/class.contentnode.inc.php');
require_once(dirname(__FILE__).'/lib/classes/class.contenthierarchymanager.inc.php');
require_once(dirname(__FILE__)."/lib/translation.functions.php");
require_once(dirname(__FILE__)."/lib/classes/class.bookmark.inc.php");
require_once(dirname(__FILE__)."/lib/classes/class.group.inc.php");
 
#Load them into the usual variables. This'll go away a little later on.
if (!isset($DONT_LOAD_DB))
{
  $db =& $gCms->GetDB();
 
  #TODO: Move this into debug... I think
  $db->fnExecute = 'count_sql_execs';
}
 
$smarty =& $gCms->GetSmarty();
 
#Load content types
$dir = dirname(__FILE__)."/lib/contenttypes";
$ls = dir($dir);
while (($file = $ls->read()) != "")
{
  if (!is_dir("$dir/$file") && (strpos($file, ".") === false || strpos($file, ".") != 0))
  {
    if (substr($file,strlen($file)-4,4) == ".php")
    {
      include_once("$dir/$file");
    }
  }
}
 
if (!defined('SMARTY_DIR')) {
  define('SMARTY_DIR', dirname(__FILE__).'/lib/smarty/');
}
 
#Setup global smarty object
#$smarty = new Smarty_CMS($config);
#$gCms->smarty = &$smarty;
 
#Stupid magic quotes...
if(get_magic_quotes_gpc())
{
  strip_slashes($_GET);
  strip_slashes($_POST);
  strip_slashes($_REQUEST);
  strip_slashes($_COOKIE);
  strip_slashes($_SESSIONS);
}
 
#Fix for IIS (and others) to make sure REQUEST_URI is filled in
if (!isset($_SERVER['REQUEST_URI']))
{
  $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
  if(isset($_SERVER['QUERY_STRING']))
    $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
}
 
#Setup the object sent to modules
$gCms->variables["pluginnum"] = 1;
if (isset($page))
{
  $gCms->variables["page"] = $page;
}
 
#Load all site preferences
load_site_preferences();
 
if (isset($CMS_ADMIN_PAGE))
{
  include_once(dirname(__FILE__)."/".$config['admin_dir']."/lang.php");
 
  require_once(dirname(__FILE__).'/lib/convert/ConvertCharset.class.php');
  $gCms->variables['convertclass'] = new ConvertCharset();
 
}
 
#Load all installed module code
if (isset($LOAD_ALL_MODULES))
{
  ModuleOperations::LoadModules(true);
}
else
{
  ModuleOperations::LoadModules(false);
}
 
# vim:ts=4 sw=4 noet
?>