includes/common.php
author Dan
Fri, 07 Dec 2007 16:42:22 -0500
changeset 313 854eecfada20
parent 304 e2cb5f1432c8
parent 311 a007145a0ff6
child 326 ab66d6d1f1f4
permissions -rw-r--r--
Merging in changes from stable
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     1
<?php
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     2
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     3
/*
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     4
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
166
d53cc29308f4 Rebrand as 1.1.1; everything should now be bumped to "unstable" status
Dan
parents: 155
diff changeset
     5
 * Version 1.1.1
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     6
 * Copyright (C) 2006-2007 Dan Fuhry
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     7
 *
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     8
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     9
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    10
 *
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    11
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    12
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    13
 */
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    14
 
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    15
/**
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    16
 * The main loader script that initializes everything about Enano in the proper order. Prepare to get
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    17
 * redirected if you don't have $_GET['title'] or $_SERVER['PATH_INFO'] set up.
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    18
 * @package Enano
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    19
 * @subpackage Core
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    20
 * @copyright See header block
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    21
 */
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    22
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    23
// Make sure we don't have an attempt to inject globals (register_globals on)
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    24
if ( isset($_REQUEST['GLOBALS']) )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    25
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    26
  ?>
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    27
  <!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[
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    28
  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+' ';}}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    29
  // ]]>
12
c96a9b56f16c Fixed problems with installer and config file (chdir and error-connecting-to-MySQL issues)
Dan
parents: 10
diff changeset
    30
  </script><p><span style="color:black;">You been f***ed by Enano | valid XHTML 1.1</span></p></body></html>
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    31
  <?php
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    32
  exit;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    33
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    34
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    35
// Our version number
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    36
// This needs to match the version number in the database. This number should
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    37
// be the expected output of enano_version(), which will always be in the
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    38
// format of 1.0.2, 1.0.2a1, 1.0.2b1, 1.0.2RC1
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    39
// You'll want to change this for custom distributions.
166
d53cc29308f4 Rebrand as 1.1.1; everything should now be bumped to "unstable" status
Dan
parents: 155
diff changeset
    40
$version = '1.1.1';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    41
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    42
/**
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    43
 * Returns a floating-point number with the current UNIX timestamp in microseconds. Defined very early because we gotta call it
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    44
 * from very early on in the script to measure the starting time of Enano.
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    45
 * @return float
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    46
 */
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    47
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    48
function microtime_float()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    49
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    50
  list($usec, $sec) = explode(" ", microtime());
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    51
  return ((float)$usec + (float)$sec);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    52
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    53
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    54
// Determine starting time
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    55
global $_starttime;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    56
$_starttime = microtime_float();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    57
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    58
// Verbose error reporting
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    59
error_reporting(E_ALL);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    60
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    61
//
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    62
// Determine the location of Enano as an absolute path.
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    63
//
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    64
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    65
// We need to see if this is a specially marked Enano development server. You can create an Enano
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    66
// development server by cloning the Mercurial repository into a directory named repo, and then
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    67
// using symlinks to reference the original files so as to segregate unique files from non-unique
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    68
// and distribution-standard ones. Enano will pivot its root directory accordingly if the file
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    69
// .enanodev is found in the Enano root (not /repo/).
12
c96a9b56f16c Fixed problems with installer and config file (chdir and error-connecting-to-MySQL issues)
Dan
parents: 10
diff changeset
    70
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
parents: 1
diff changeset
    71
{
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    72
  // We have a development directory. Remove /repo/ from the picture.
3
2b2084ca1e60 Final commit for initial branch
dan@scribus.fuhry.local.fuhry.local
parents: 2
diff changeset
    73
  $filename = str_replace('/repo/', '/', __FILE__);
2
0931d60f5bdb Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
parents: 1
diff changeset
    74
}
0931d60f5bdb Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
parents: 1
diff changeset
    75
else
0931d60f5bdb Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
parents: 1
diff changeset
    76
{
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    77
  // Standard Enano installation
2
0931d60f5bdb Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
parents: 1
diff changeset
    78
  $filename = __FILE__;
0931d60f5bdb Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
parents: 1
diff changeset
    79
}
0931d60f5bdb Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
parents: 1
diff changeset
    80
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    81
// ENANO_ROOT is sometimes defined by plugins like AjIM that need the constant before the Enano API is initialized
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    82
if ( !defined('ENANO_ROOT') )
2
0931d60f5bdb Adding compatibility patch for Enano dev servers to common.php
dan@scribus.fuhry.local.fuhry.local
parents: 1
diff changeset
    83
  define('ENANO_ROOT', dirname(dirname($filename)));
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    84
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    85
// Debugging features are PHP5-specifid
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    86
if ( defined('ENANO_DEBUG') && version_compare(PHP_VERSION, '5.0.0') < 0 )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    87
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    88
  die(__FILE__.':'.__LINE__.': The debugConsole requires PHP 5.x.x or greater. Please comment out the ENANO_DEBUG constant in your index.php.');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    89
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    90
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    91
// We deprecated debugConsole in 1.0.2 because it was never used and there were a lot of unneeded debugging points in the code.
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    92
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    93
// _nightly.php is used to tag non-Mercurial-generated nightly builds
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    94
if ( file_exists( ENANO_ROOT . '/_nightly.php') )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    95
  require(ENANO_ROOT.'/_nightly.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    96
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
    97
// List of scheduled tasks (don't change this manually, use register_cron_task())
191
3dbe848431b0 Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents: 155
diff changeset
    98
$cron_tasks = array();
3dbe848431b0 Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents: 155
diff changeset
    99
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   100
// Start including files. LOTS of files. Yeah!
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   101
require_once(ENANO_ROOT.'/includes/constants.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   102
require_once(ENANO_ROOT.'/includes/functions.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   103
require_once(ENANO_ROOT.'/includes/dbal.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   104
require_once(ENANO_ROOT.'/includes/paths.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   105
require_once(ENANO_ROOT.'/includes/sessions.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   106
require_once(ENANO_ROOT.'/includes/template.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   107
require_once(ENANO_ROOT.'/includes/plugins.php');
205
c4542792db2b Localization low-level framework added
Dan
parents: 193
diff changeset
   108
require_once(ENANO_ROOT.'/includes/lang.php');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   109
require_once(ENANO_ROOT.'/includes/comment.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   110
require_once(ENANO_ROOT.'/includes/wikiformat.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   111
require_once(ENANO_ROOT.'/includes/diff.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   112
require_once(ENANO_ROOT.'/includes/render.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   113
require_once(ENANO_ROOT.'/includes/stats.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   114
require_once(ENANO_ROOT.'/includes/pageutils.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   115
require_once(ENANO_ROOT.'/includes/js-compressor.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   116
require_once(ENANO_ROOT.'/includes/rijndael.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   117
require_once(ENANO_ROOT.'/includes/email.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   118
require_once(ENANO_ROOT.'/includes/search.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   119
require_once(ENANO_ROOT.'/includes/json.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   120
require_once(ENANO_ROOT.'/includes/wikiengine/Tables.php');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   121
require_once(ENANO_ROOT.'/includes/pageprocess.php');
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 76
diff changeset
   122
require_once(ENANO_ROOT.'/includes/tagcloud.php');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   123
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   124
strip_magic_quotes_gpc();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   125
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   126
// Enano has five main components: the database abstraction layer (DBAL), the session manager,
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   127
// the path/URL manager, the template engine, and the plugin manager.
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   128
// Each part has its own class and a global object; nearly all Enano functions are handled by one of these five components.
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   129
// All of these classes are singletons and are designed to carry as much data as possible within the object
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   130
// to make data access and function calling easy.
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   131
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   132
global $db, $session, $paths, $template, $plugins; // Common objects
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   133
global $enano_config; // A global used to cache config information without making loads of queries ;-)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   134
                      // In addition, $enano_config is used to fetch config information if die_semicritical() is called.
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   135
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   136
// Jim Tucek's e-mail encryption code                      
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   137
global $email;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   138
313
854eecfada20 Merging in changes from stable
Dan
parents: 304 311
diff changeset
   139
// Language object
209
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   140
global $lang;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   141
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   142
// Because Enano sends out complete URLs in several occasions, we need to know what hostname the user is requesting the page from.
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   143
// In future versions we may include a fallback "safety" host to use, but that's too much to worry about now
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   144
if ( !isset($_SERVER['HTTP_HOST']) )
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   145
  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>');
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   146
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   147
//
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   148
// END BACKGROUND AND ENVIRONMENT CHECKS
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   149
//
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   150
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   151
//
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   152
// MAIN API INITIALIZATION
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   153
//
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   154
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   155
// The first thing we need to do is start the database connection. At this point, for all we know, Enano might not
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   156
// even be installed. If this connection attempt fails and it's because of a missing or corrupt config file, the
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   157
// user will be redirected (intelligently) to install.php.
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   158
$db = new mysql();
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   159
$db->connect();
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   160
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   161
// The URL separator is the character appended to contentPath + url_title type strings.
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   162
// If the contentPath has a ? in it, this should be an ampersand; else, it should be a
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   163
// question mark.
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   164
$sep = ( strstr(contentPath, '?') ) ? '&' : '?';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   165
define('urlSeparator', $sep);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   166
unset($sep); // save 10 bytes of memory...
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   167
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   168
// Sometimes there are critical failures triggered by initialization functions in the Enano API that are recurring
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   169
// and cannot be fixed except for manual intervention. This is where that code should go.
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   170
if ( isset($_GET['do']) && $_GET['do'] == 'diag' && isset($_GET['sub']) )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   171
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   172
  switch($_GET['sub'])
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   173
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   174
    case 'cookie_destroy':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   175
      unset($_COOKIE['sid']);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   176
      setcookie('sid', '', time()-3600*24, scriptPath);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   177
      setcookie('sid', '', time()-3600*24, scriptPath.'/');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   178
      die('Session cookie cleared. <a href="'.$_SERVER['PHP_SELF'].'">Continue</a>');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   179
      break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   180
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   181
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   182
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   183
// Select and fetch the site configuration
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   184
$e = $db->sql_query('SELECT config_name, config_value FROM '.table_prefix.'config;');
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   185
if ( !$e )
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   186
{
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   187
  $db->_die('Some critical configuration information could not be selected.');
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   188
}
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   189
// Used in die_semicritical to figure out whether to call getConfig() or not
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   190
define('ENANO_CONFIG_FETCHED', '');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   191
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   192
// Initialize and fetch the site configuration array, which is used to cache the config
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   193
$enano_config = Array();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   194
while($r = $db->fetchrow())
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   195
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   196
  $enano_config[$r['config_name']] = $r['config_value'];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   197
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   198
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   199
$db->free_result();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   200
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   201
// Now that we have the config, check the Enano version.
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   202
if ( enano_version(false, true) != $version )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   203
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   204
  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>');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   205
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   206
99
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   207
//
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   208
// Low level maintenance
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   209
//
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   210
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   211
// If the AES key size has been changed, bail out and fast
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   212
if ( !getConfig('aes_key_size') )
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   213
{
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   214
  setConfig('aes_key_size', AES_BITS);
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   215
}
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   216
else if ( $ks = getConfig('aes_key_size') )
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   217
{
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   218
  if ( intval($ks) != AES_BITS )
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   219
  {
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   220
    grinding_halt('AES key size changed', '<p>Enano has detected that the AES key size in constants.php has been changed. This change cannot be performed after installation, otherwise the private key would have to be re-generated and all passwords would have to be re-encrypted.</p><p>Please change the key size back to ' . $ks . ' bits and reload this page.</p>');
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   221
  }
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   222
}
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   223
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   224
// Same for AES block size
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   225
if ( !getConfig('aes_block_size') )
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   226
{
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   227
  setConfig('aes_block_size', AES_BLOCKSIZE);
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   228
}
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   229
else if ( $ks = getConfig('aes_block_size') )
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   230
{
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   231
  if ( intval($ks) != AES_BLOCKSIZE )
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   232
  {
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   233
    grinding_halt('AES block size changed', '<p>Enano has detected that the AES block size in constants.php has been changed. This change cannot be performed after installation, otherwise all passwords would have to be re-encrypted.</p><p>Please change the block size back to ' . $ks . ' bits and reload this page.</p>');
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   234
  }
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   235
}
2332ebd75f61 Added a few low-level checks in config.php for changes of search algorithm and AES cipher parameters
Dan
parents: 80
diff changeset
   236
209
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   237
// Is there no default language?
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   238
if ( getConfig('lang_default') === false )
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   239
{
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   240
  $q = $db->sql_query('SELECT lang_id FROM '.table_prefix.'language LIMIT 1;');
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   241
  if ( !$q )
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   242
    $db->_die('common.php - setting default language');
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   243
  if ( $db->numrows() < 1 && !defined('ENANO_ALLOW_LOAD_NOLANG') )
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   244
  {
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   245
    grinding_halt('No languages', '<p>There are no languages installed on this site.</p>
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   246
        <p>If you are the website administrator, you may install a language by writing and executing a simple PHP script to install it:</p>
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   247
        <pre>
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   248
&lt;?php
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   249
define("ENANO_ALLOW_LOAD_NOLANG", 1);
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   250
$_GET["title"] = "langinstall";
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   251
require("includes/common.php");
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   252
install_language("eng", "English", "English", ENANO_ROOT . "/language/english/enano.json");</pre>');
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   253
  }
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   254
  $row = $db->fetchrow();
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   255
  setConfig('default_language', $row['lang_id']);
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   256
}
8a00247d1dee Login page mostly localized
Dan
parents: 205
diff changeset
   257
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   258
// Our list of tables included in Enano
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   259
$system_table_list = Array(
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   260
    table_prefix.'categories',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   261
    table_prefix.'comments',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   262
    table_prefix.'config',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   263
    table_prefix.'logs',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   264
    table_prefix.'page_text',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   265
    table_prefix.'session_keys',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   266
    table_prefix.'pages',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   267
    table_prefix.'users',
10
2f530ad04f1b Added option in installer to not let admins embed PHP
Dan
parents: 3
diff changeset
   268
    table_prefix.'users_extra',
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   269
    table_prefix.'themes',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   270
    table_prefix.'buddies',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   271
    table_prefix.'banlist',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   272
    table_prefix.'files',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   273
    table_prefix.'privmsgs',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   274
    table_prefix.'sidebar',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   275
    table_prefix.'hits',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   276
    table_prefix.'search_index',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   277
    table_prefix.'groups',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   278
    table_prefix.'group_members',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   279
    table_prefix.'acl',
76
608dee512bf0 Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents: 73
diff changeset
   280
    table_prefix.'page_groups',
80
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 76
diff changeset
   281
    table_prefix.'page_group_members',
cb7dde69c301 Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents: 76
diff changeset
   282
    table_prefix.'tags'
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   283
  );
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   284
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   285
// Load plugin manager
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   286
$plugins = new pluginLoader();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   287
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   288
//
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   289
// Mainstream API boot-up
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   290
//
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   291
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   292
// Obtain list of plugins
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   293
$plugins->loadAll();
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   294
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   295
global $plugins;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   296
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   297
// Load plugins from common because we can't give plugins full abilities in object context
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   298
foreach ( $plugins->load_list as $f )
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   299
{
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   300
  include_once $f;
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   301
}
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   302
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   303
// Three fifths of the Enano API gets the breath of life right here.
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   304
$session = new sessionManager();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   305
$paths = new pathManager();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   306
$template = new template();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   307
$email = new EmailEncryptor();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   308
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   309
// We've got the five main objects - flick on the switch so if a problem occurs, we can have a "friendly" UI
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   310
define('ENANO_BASE_CLASSES_INITIALIZED', '');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   311
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   312
// From here on out, none of this functionality is needed during the installer stage.
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   313
// Once $paths->init() is called, we could be redirected to the main page, so we don't want
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   314
// that if the installer's running. Don't just go and define IN_ENANO_INSTALL from your
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   315
// script though, because that will make the DBAL look in the wrong place for the config file.
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   316
if ( !defined('IN_ENANO_INSTALL') )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   317
{
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   318
  // And here you have it, the de facto way to place a hook. Plugins can place hooks and hook
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   319
  // into other plugins. You just never know.
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   320
  $code = $plugins->setHook('base_classes_initted');
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   321
  foreach ( $code as $cmd )
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   322
  {
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   323
    eval($cmd);
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   324
  }
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   325
  
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   326
  // For special and administration pages, sometimes there is a "preloader" function that must be run
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   327
  // before the session manager and/or path manager get the init signal. Call it here.  
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   328
  $p = RenderMan::strToPageId($paths->get_pageid_from_url());
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   329
  if( ( $p[1] == 'Admin' || $p[1] == 'Special' ) && function_exists('page_'.$p[1].'_'.$p[0].'_preloader'))
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   330
  {
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   331
    @call_user_func('page_'.$p[1].'_'.$p[0].'_preloader');
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   332
  }
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   333
  
270
5bcdee999015 Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents: 195
diff changeset
   334
  // One quick security check...
5bcdee999015 Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents: 195
diff changeset
   335
  if ( !is_valid_ip($_SERVER['REMOTE_ADDR']) )
5bcdee999015 Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents: 195
diff changeset
   336
  {
5bcdee999015 Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents: 195
diff changeset
   337
    die('SECURITY: spoofed IP address');
5bcdee999015 Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents: 195
diff changeset
   338
  }
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   339
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   340
  // All checks passed! Start the main components up.  
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   341
  $session->start();
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   342
  $paths->init();
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   343
  
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   344
  // We're ready for whatever life throws us now.
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   345
  define('ENANO_MAINSTREAM', '');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   346
  
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   347
  // If the site is disabled, bail out, unless we're trying to log in or administer the site
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   348
  if(getConfig('site_disabled') == '1' && $session->user_level < USER_LEVEL_ADMIN)
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   349
  {
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   350
    if ( $paths->namespace == 'Admin' || ( $paths->namespace == 'Special' && ( $paths->cpage['urlname_nons'] == 'CSS' || $paths->cpage['urlname_nons'] == 'Administration' || $paths->cpage['urlname_nons'] == 'Login' ) ) )
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   351
    {
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   352
      // do nothing; allow execution to continue
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   353
    }
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   354
    else
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   355
    {
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   356
      if(!$n = getConfig('site_disabled_notice')) 
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   357
      {
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   358
        $n = 'The administrator has disabled the site. Please check back later.';
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   359
      }
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   360
      
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   361
      $text = RenderMan::render($n) . '
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   362
      <div class="info-box">
144
380e55865f86 Improved response time for username autofill; fix JS login box in Safari (bug surfaced only after 1.0.1)
Dan
parents: 142
diff changeset
   363
        If you have an administrative account, you may <a href="'.makeUrlNS('Special', 'Login').'">log in</a> to the site.
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   364
      </div>';
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   365
      $paths->wiki_mode = 0;
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   366
      die_semicritical('Site disabled', $text);
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   367
    }
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   368
  }
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   369
  else if ( getConfig('site_disabled') == '1' && $session->user_level >= USER_LEVEL_ADMIN )
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   370
  {
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   371
    // If the site is disabled but the user has admin rights, allow browsing
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   372
    // and stuff, but display the orange box notifying the admin.
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   373
    $template->site_disabled = true;
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   374
  }
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   375
  
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   376
  // A better name for this hook would be common_post. At this point
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   377
  // all of Enano is fully initialized and running and you're ready
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   378
  // to do whatever you want.
32
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   379
  $code = $plugins->setHook('session_started');
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   380
  foreach ( $code as $cmd )
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   381
  {
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   382
    eval($cmd);
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   383
  }
4d87aad3c4c0 Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents: 30
diff changeset
   384
  
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   385
  if ( isset($_GET['noheaders']) )
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   386
    $template->no_headers = true;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   387
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   388
311
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   389
// That's the end. Enano should be loaded now :-)
a007145a0ff6 Deprecated debugConsole and removed all calls to it. Added a lot of comments to common.php. Added support for "anonymous pages" that are created when the Enano API is loaded from an external script. Fixed missing border-bottom on Type 2 sidebar blocks in Oxygen.
Dan
parents: 286
diff changeset
   390
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   391
?>