1
+ − 1
<?php
+ − 2
+ − 3
/*
+ − 4
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
+ − 5
* Version 1.0 (Banshee)
+ − 6
* Copyright (C) 2006-2007 Dan Fuhry
+ − 7
*
+ − 8
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
+ − 9
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+ − 10
*
+ − 11
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ − 12
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ − 13
*/
+ − 14
+ − 15
if(isset($_REQUEST['GLOBALS']))
+ − 16
{
+ − 17
?>
+ − 18
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title>Hacking Attempt</title><meta http-equiv="Content-type" content="text/html; charset=utf-8" /></head><style type="text/css">body{background-color:#000;color:#CCC;font-family:trebuchet ms,sans-serif;font-size:9pt;}a{color:#FFF;}</style><body><p>Hacking attempt using <a href="http://www.hardened-php.net/index.76.html">PHP $GLOBALS overwrite vulnerability</a> detected, reported to admin</p><p>You're worse than this guy! Unless you are this guy...</p><p id="billp"><img alt=" " src="about:blank" id="billi" /></p><script type="text/javascript">// <![CDATA[
+ − 19
window.onload=function(){counter();setInterval('counter();', 1000);};var text=false;var cnt=10;function counter(){if(!text){text=document.createElement('span');text.id='billc';text.innerHTML=cnt;text.style.fontSize='96pt';text.style.color='#FF0000';p=document.getElementById('billp');p.appendChild(text);}else{if(cnt==1){document.getElementById('billi').src='http://upload.wikimedia.org/wikipedia/commons/7/7f/Bill_Gates_2004_cr.jpg';document.getElementById('billc').innerHTML='';return;}cnt--;document.getElementById('billc').innerHTML=cnt+' ';}}
+ − 20
// ]]>
12
+ − 21
</script><p><span style="color:black;">You been f***ed by Enano | valid XHTML 1.1</span></p></body></html>
1
+ − 22
<?php
+ − 23
exit;
+ − 24
}
+ − 25
+ − 26
$version = '1.0';
+ − 27
+ − 28
function microtime_float()
+ − 29
{
+ − 30
list($usec, $sec) = explode(" ", microtime());
+ − 31
return ((float)$usec + (float)$sec);
+ − 32
}
+ − 33
+ − 34
global $_starttime;
+ − 35
$_starttime = microtime_float();
+ − 36
+ − 37
error_reporting(E_ALL);
+ − 38
2
0931d60f5bdb
Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
diff
changeset
+ − 39
// Determine directory (special case for development servers)
12
+ − 40
if ( strpos(__FILE__, '/repo/') && ( file_exists('.enanodev') || file_exists('../.enanodev') ) )
2
0931d60f5bdb
Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
diff
changeset
+ − 41
{
3
+ − 42
$filename = str_replace('/repo/', '/', __FILE__);
2
0931d60f5bdb
Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
diff
changeset
+ − 43
}
0931d60f5bdb
Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
diff
changeset
+ − 44
else
0931d60f5bdb
Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
diff
changeset
+ − 45
{
0931d60f5bdb
Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
diff
changeset
+ − 46
$filename = __FILE__;
0931d60f5bdb
Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
diff
changeset
+ − 47
}
0931d60f5bdb
Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
diff
changeset
+ − 48
1
+ − 49
if(!defined('ENANO_ROOT')) // ENANO_ROOT is sometimes defined by plugins like AjIM that need the constant before the Enano API is initialized
2
0931d60f5bdb
Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
diff
changeset
+ − 50
define('ENANO_ROOT', dirname(dirname($filename)));
1
+ − 51
+ − 52
if(defined('ENANO_DEBUG') && version_compare(PHP_VERSION, '5.0.0') < 0)
+ − 53
{
+ − 54
die(__FILE__.':'.__LINE__.': The debugConsole requires PHP 5.x.x or greater. Please comment out the ENANO_DEBUG constant in your index.php.');
+ − 55
}
+ − 56
+ − 57
if(defined('ENANO_DEBUG'))
+ − 58
{
+ − 59
require_once(ENANO_ROOT.'/includes/debugger/debugConsole.php');
+ − 60
} else {
+ − 61
function dc_here($m) { return false; }
+ − 62
function dc_dump($a, $g) { return false; }
+ − 63
function dc_watch($n) { return false; }
+ − 64
function dc_start_timer($u) { return false; }
+ − 65
function dc_stop_timer($m) { return false; }
+ − 66
}
+ − 67
+ − 68
if ( file_exists( ENANO_ROOT . '/_nightly.php') )
+ − 69
require(ENANO_ROOT.'/_nightly.php');
+ − 70
+ − 71
// Start including files. LOTS of files. Yeah!
+ − 72
require_once(ENANO_ROOT.'/includes/constants.php');
+ − 73
dc_here('Enano CMS '.$version.' (dev) - debug window<br />Powered by debugConsole');
+ − 74
dc_here('common: including files');
+ − 75
require_once(ENANO_ROOT.'/includes/functions.php');
+ − 76
require_once(ENANO_ROOT.'/includes/dbal.php');
+ − 77
require_once(ENANO_ROOT.'/includes/paths.php');
+ − 78
require_once(ENANO_ROOT.'/includes/sessions.php');
+ − 79
require_once(ENANO_ROOT.'/includes/template.php');
+ − 80
require_once(ENANO_ROOT.'/includes/plugins.php');
+ − 81
require_once(ENANO_ROOT.'/includes/comment.php');
+ − 82
require_once(ENANO_ROOT.'/includes/wikiformat.php');
+ − 83
require_once(ENANO_ROOT.'/includes/diff.php');
+ − 84
require_once(ENANO_ROOT.'/includes/render.php');
+ − 85
require_once(ENANO_ROOT.'/includes/stats.php');
+ − 86
require_once(ENANO_ROOT.'/includes/pageutils.php');
+ − 87
require_once(ENANO_ROOT.'/includes/js-compressor.php');
+ − 88
require_once(ENANO_ROOT.'/includes/rijndael.php');
+ − 89
require_once(ENANO_ROOT.'/includes/email.php');
+ − 90
require_once(ENANO_ROOT.'/includes/search.php');
+ − 91
require_once(ENANO_ROOT.'/includes/json.php');
+ − 92
require_once(ENANO_ROOT.'/includes/wikiengine/Tables.php');
+ − 93
require_once(ENANO_ROOT.'/includes/pageprocess.php');
+ − 94
+ − 95
strip_magic_quotes_gpc();
+ − 96
+ − 97
// Enano has five parts: the database abstraction layer (DBAL), the session manager, the path/URL manager, the template engine, and the plugin manager.
+ − 98
// Each part has its own class and a global var; nearly all Enano functions are handled by one of these five components.
+ − 99
+ − 100
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 101
global $enano_config; // A global used to cache config information without making loads of queries ;-)
+ − 102
// In addition, $enano_config is used to fetch config information if die_semicritical() is called.
+ − 103
+ − 104
global $email;
+ − 105
+ − 106
if(!isset($_SERVER['HTTP_HOST'])) grinding_halt('Cannot get hostname', '<p>Your web browser did not provide the HTTP Host: field. This site requires a modern browser that supports the HTTP 1.1 standard.</p>');
+ − 107
+ − 108
$db = new mysql();
+ − 109
dc_here('common: calling $db->connect();');
+ − 110
$db->connect(); // Redirects to install.php if an installation is not detected
+ − 111
+ − 112
if(strstr(contentPath, '?')) $sep = '&';
+ − 113
else $sep = '?';
+ − 114
define('urlSeparator', $sep);
+ − 115
unset($sep); // save 10 bytes of memory...
+ − 116
+ − 117
// See if any diagnostic actions have been requested
+ − 118
if ( isset($_GET['do']) && $_GET['do'] == 'diag' && isset($_GET['sub']) )
+ − 119
{
+ − 120
switch($_GET['sub'])
+ − 121
{
+ − 122
case 'cookie_destroy':
+ − 123
unset($_COOKIE['sid']);
+ − 124
setcookie('sid', '', time()-3600*24, scriptPath);
+ − 125
setcookie('sid', '', time()-3600*24, scriptPath.'/');
+ − 126
die('Session cookie cleared. <a href="'.$_SERVER['PHP_SELF'].'">Continue</a>');
+ − 127
break;
+ − 128
}
+ − 129
}
+ − 130
+ − 131
// Select and fetch the site configuration
+ − 132
dc_here('common: selecting global config data');
+ − 133
$e = $db->sql_query('SELECT config_name, config_value FROM '.table_prefix.'config;');
+ − 134
if(!$e) $db->_die('Some critical configuration information could not be selected.');
+ − 135
else define('ENANO_CONFIG_FETCHED', ''); // Used in die_semicritical to figure out whether to call getConfig() or not
+ − 136
+ − 137
dc_here('common: fetching $enano_config');
+ − 138
$enano_config = Array();
+ − 139
while($r = $db->fetchrow())
+ − 140
{
+ − 141
$enano_config[$r['config_name']] = $r['config_value'];
+ − 142
}
+ − 143
+ − 144
$db->free_result();
+ − 145
+ − 146
if(enano_version(false, true) != $version)
+ − 147
{
+ − 148
grinding_halt('Version mismatch', '<p>It seems that the Enano release we\'re trying to run ('.$version.') is different from the version specified in your database ('.enano_version().'). Perhaps you need to <a href="'.scriptPath.'/upgrade.php">upgrade</a>?</p>');
+ − 149
}
+ − 150
+ − 151
// Our list of tables included in Enano
+ − 152
$system_table_list = Array(
+ − 153
table_prefix.'categories',
+ − 154
table_prefix.'comments',
+ − 155
table_prefix.'config',
+ − 156
table_prefix.'logs',
+ − 157
table_prefix.'page_text',
+ − 158
table_prefix.'session_keys',
+ − 159
table_prefix.'pages',
+ − 160
table_prefix.'users',
10
+ − 161
table_prefix.'users_extra',
1
+ − 162
table_prefix.'themes',
+ − 163
table_prefix.'buddies',
+ − 164
table_prefix.'banlist',
+ − 165
table_prefix.'files',
+ − 166
table_prefix.'privmsgs',
+ − 167
table_prefix.'sidebar',
+ − 168
table_prefix.'hits',
+ − 169
table_prefix.'search_index',
+ − 170
table_prefix.'groups',
+ − 171
table_prefix.'group_members',
+ − 172
table_prefix.'acl',
+ − 173
table_prefix.'search_cache'
+ − 174
);
+ − 175
+ − 176
dc_here('common: initializing base classes');
+ − 177
$plugins = new pluginLoader();
+ − 178
+ − 179
// So where does the majority of Enano get executed? How about the next nine lines of code :)
+ − 180
dc_here('common: ok, we\'re set up, starting mainstream execution');
+ − 181
+ − 182
$plugins->loadAll();
+ − 183
dc_here('common: loading plugins');
+ − 184
global $plugins;
+ − 185
foreach($plugins->load_list as $f) { include_once $f; } // Can't be in object context when this is done
+ − 186
+ − 187
$session = new sessionManager();
+ − 188
$paths = new pathManager();
+ − 189
$template = new template();
+ − 190
$email = new EmailEncryptor();
+ − 191
+ − 192
define('ENANO_BASE_CLASSES_INITIALIZED', '');
+ − 193
+ − 194
$code = $plugins->setHook('base_classes_initted');
+ − 195
foreach ( $code as $cmd )
+ − 196
{
+ − 197
eval($cmd);
+ − 198
}
+ − 199
+ − 200
$p = RenderMan::strToPageId($paths->get_pageid_from_url());
+ − 201
if( ( $p[1] == 'Admin' || $p[1] == 'Special' ) && function_exists('page_'.$p[1].'_'.$p[0].'_preloader'))
+ − 202
{
+ − 203
@call_user_func('page_'.$p[1].'_'.$p[0].'_preloader');
+ − 204
}
+ − 205
+ − 206
$session->start();
+ − 207
$paths->init();
+ − 208
+ − 209
define('ENANO_MAINSTREAM', '');
+ − 210
+ − 211
// If the site is disabled, bail out, unless we're trying to log in or administer the site
+ − 212
if(getConfig('site_disabled') == '1')
+ − 213
{
+ − 214
if ( $paths->namespace == 'Admin' || ( $paths->namespace == 'Special' && ( $paths->cpage['urlname_nons'] == 'CSS' || $paths->cpage['urlname_nons'] == 'Administration' || $paths->cpage['urlname_nons'] == 'Login' ) ) )
+ − 215
{
+ − 216
// do nothing; allow execution to continue
+ − 217
}
+ − 218
else
+ − 219
{
10
+ − 220
if(!$n = getConfig('site_disabled_notice'))
+ − 221
{
+ − 222
$n = 'The administrator has disabled the site. Please check back later.';
+ − 223
}
1
+ − 224
+ − 225
$text = RenderMan::render($n) . '
+ − 226
<div class="info-box">
+ − 227
If you have an administrative account, you may <a href="'.makeUrlNS('Special', 'Login').'">log in</a> to the site or <a href="'.makeUrlNS('Special', 'Administration').'">use the administration panel</a>.
+ − 228
</div>';
+ − 229
$paths->wiki_mode = 0;
+ − 230
die_semicritical('Site disabled', $text);
+ − 231
}
+ − 232
}
+ − 233
+ − 234
$code = $plugins->setHook('session_started');
+ − 235
foreach ( $code as $cmd )
+ − 236
{
+ − 237
eval($cmd);
+ − 238
}
+ − 239
+ − 240
if(isset($_GET['noheaders'])) $template->no_headers = true;
+ − 241
+ − 242
?>