includes/common_cli.php
author Dan Fuhry <dan@enanocms.org>
Wed, 21 Aug 2013 22:50:34 -0400
changeset 1378 e58294b867c1
parent 1365 a52cac1b190d
permissions -rw-r--r--
Add transparent support for PDO into installer; further integration of PDO
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
     1
<?php
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
     2
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
     3
/*
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
     4
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
1081
745200a9cc2a Fixed some upgrade bugs; added support for choosing one's own date/time formats; rebrand as 1.1.7
Dan
parents: 945
diff changeset
     5
 * Copyright (C) 2006-2009 Dan Fuhry
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
     6
 *
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
     7
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
     8
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
     9
 *
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    11
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    12
 */
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    13
 
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    14
/**
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    15
 * The main loader script that initializes everything about Enano in the proper order. This is only loaded
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    16
 * if PHP is running via CLI.
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    17
 * @package Enano
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    18
 * @subpackage Core
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    19
 * @copyright See header block
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    20
 */
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    21
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    22
//
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    23
// MAIN API INITIALIZATION
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    24
//
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    25
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    26
// Note to important functions and the template class that we're running via CLI
812
68060328e9c6 Added CLI installer. Supports interactive, command-line, and internal-call installation. Fixed a few bugs related to anti-SQL injection parser and plugin installation.
Dan
parents: 801
diff changeset
    27
@define('ENANO_CLI', 1);
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    28
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    29
// The first thing we need to do is start the database connection. At this point, for all we know, Enano might not
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    30
// even be installed. If this connection attempt fails and it's because of a missing or corrupt config file, the
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    31
// user will be redirected (intelligently) to install.php.
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    32
1143
e271ae801c62 common_cli and dbal: Fixed lack of ENANO_INSTALLED check in determining config path
Dan
parents: 1099
diff changeset
    33
$config_file = ( defined('IN_ENANO_INSTALL') && !defined('ENANO_INSTALLED') ) ? '/config.new.php' : '/config.php';
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    34
@include(ENANO_ROOT . $config_file);
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    35
unset($dbuser, $dbpasswd);
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    36
if ( !isset($dbdriver) )
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
    37
	$dbdriver = 'mysql';
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    38
1378
e58294b867c1 Add transparent support for PDO into installer; further integration of PDO
Dan Fuhry <dan@enanocms.org>
parents: 1365
diff changeset
    39
$dbdriver_cls = have_pdo($dbdriver) ? "{$dbdriver}_pdo" : $dbdriver;
e58294b867c1 Add transparent support for PDO into installer; further integration of PDO
Dan Fuhry <dan@enanocms.org>
parents: 1365
diff changeset
    40
e58294b867c1 Add transparent support for PDO into installer; further integration of PDO
Dan Fuhry <dan@enanocms.org>
parents: 1365
diff changeset
    41
$db = new $dbdriver_cls();
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    42
$db->connect();
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    43
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    44
profiler_log('Database connected');
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    45
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    46
// The URL separator is the character appended to contentPath + url_title type strings.
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    47
// If the contentPath has a ? in it, this should be an ampersand; else, it should be a
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    48
// question mark.
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    49
$sep = ( strstr(contentPath, '?') ) ? '&' : '?';
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    50
define('urlSeparator', $sep);
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    51
unset($sep); // save 10 bytes of memory...
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    52
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    53
// Select and fetch the site configuration
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    54
$e = $db->sql_query('SELECT config_name, config_value FROM '.table_prefix.'config;');
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    55
if ( !$e )
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    56
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
    57
	$db->_die('Some critical configuration information could not be selected.');
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    58
}
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    59
// Used in die_semicritical to figure out whether to call getConfig() or not
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    60
define('ENANO_CONFIG_FETCHED', '');
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    61
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    62
// Initialize and fetch the site configuration array, which is used to cache the config
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    63
$enano_config = Array();
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    64
while($r = $db->fetchrow())
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    65
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
    66
	$enano_config[$r['config_name']] = $r['config_value'];
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    67
}
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    68
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    69
$db->free_result();
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    70
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    71
profiler_log('Config fetched');
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    72
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    73
// Now that we have the config, check the Enano version.
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    74
if ( enano_version(false, true) != $version && !defined('IN_ENANO_UPGRADE') )
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    75
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
    76
	grinding_halt('Version mismatch', 'Trying to run Enano version '.$version.' on database version '.enano_version().', you might need to upgrade.');
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    77
}
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    78
650
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 612
diff changeset
    79
// Set our CDN path
666
402adf8ea719 Made cdnPath define conditionally; fixed common_cli not properly loading plugins
Dan
parents: 650
diff changeset
    80
if ( !defined('cdnPath') )
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
    81
	define('cdnPath', getConfig('cdn_path', scriptPath));
650
e45183014778 Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
parents: 612
diff changeset
    82
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    83
//
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    84
// Low level maintenance
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    85
//
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    86
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    87
// If the AES key size has been changed, bail out and fast
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    88
if ( !getConfig('aes_key_size') )
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    89
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
    90
	setConfig('aes_key_size', AES_BITS);
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    91
}
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    92
else if ( $ks = getConfig('aes_key_size') )
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    93
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
    94
	if ( intval($ks) != AES_BITS )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
    95
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
    96
		grinding_halt('AES key size changed', '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.' . "\n\n" . 'Please change the key size back to ' . $ks . ' bits and rerun this script.');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
    97
	}
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    98
}
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
    99
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   100
// Same for AES block size
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   101
if ( !getConfig('aes_block_size') )
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   102
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   103
	setConfig('aes_block_size', AES_BLOCKSIZE);
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   104
}
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   105
else if ( $ks = getConfig('aes_block_size') )
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   106
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   107
	if ( intval($ks) != AES_BLOCKSIZE )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   108
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   109
		grinding_halt('AES block size changed', "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.\n\nPlease change the block size back to $ks bits and rerun this script.");
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   110
	}
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   111
}
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   112
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   113
// Is there no default language?
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   114
if ( getConfig('default_language') === false && !defined('IN_ENANO_MIGRATION') )
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   115
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   116
	$q = $db->sql_query('SELECT lang_id FROM '.table_prefix.'language LIMIT 1;');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   117
	if ( !$q )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   118
		$db->_die('common.php - setting default language');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   119
	if ( $db->numrows() < 1 && !defined('ENANO_ALLOW_LOAD_NOLANG') )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   120
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   121
		grinding_halt('No languages', 'No languages are installed on the site, load from web interface for instructions on how to fix this.');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   122
	}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   123
	$row = $db->fetchrow();
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   124
	setConfig('default_language', $row['lang_id']);
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   125
}
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   126
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   127
profiler_log('Ran checks');
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   128
612
3e73e4996d64 Made CLI version of common load cache manager properly
Dan
parents: 541
diff changeset
   129
// Init cache
1365
a52cac1b190d Cacher: Add XCache support (partial)
Dan Fuhry <dan@enanocms.org>
parents: 1227
diff changeset
   130
$cache = CacheManager::factory();
612
3e73e4996d64 Made CLI version of common load cache manager properly
Dan
parents: 541
diff changeset
   131
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   132
// Load plugin manager
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   133
$plugins = new pluginLoader();
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   134
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   135
//
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   136
// Mainstream API boot-up
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   137
//
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   138
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   139
// Obtain list of plugins
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   140
$plugins->loadAll();
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   141
666
402adf8ea719 Made cdnPath define conditionally; fixed common_cli not properly loading plugins
Dan
parents: 650
diff changeset
   142
profiler_log('Fetched plugin list');
402adf8ea719 Made cdnPath define conditionally; fixed common_cli not properly loading plugins
Dan
parents: 650
diff changeset
   143
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   144
global $plugins;
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   145
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   146
// Load plugins from common because we can't give plugins full abilities in object context
695
6bd7215c718b Added ENANO_NO_PLUGINS optional switch to common_cli.
Dan
parents: 685
diff changeset
   147
if ( !defined('ENANO_NO_PLUGINS') )
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   148
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   149
	foreach ( $plugins->load_list as $f )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   150
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   151
		if ( file_exists(ENANO_ROOT . '/plugins/' . $f) )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   152
			include_once ENANO_ROOT . '/plugins/' . $f;
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   153
	}
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   154
}
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   155
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   156
profiler_log('Loaded plugins');
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   157
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   158
// Three fifths of the Enano API gets the breath of life right here.
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   159
$session = new sessionManager();
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   160
$paths = new pathManager();
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   161
$template = new template();
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   162
$email = new EmailEncryptor();
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   163
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   164
profiler_log('Instanciated important singletons');
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   165
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   166
// We've got the five main objects - flick on the switch so if a problem occurs, we can have a "friendly" UI
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   167
define('ENANO_BASE_CLASSES_INITIALIZED', '');
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   168
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   169
// From here on out, none of this functionality is needed during the installer stage.
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   170
// Once $paths->init() is called, we could be redirected to the main page, so we don't want
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   171
// that if the installer's running. Don't just go and define IN_ENANO_INSTALL from your
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   172
// script though, because that will make the DBAL look in the wrong place for the config file.
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   173
if ( !defined('IN_ENANO_INSTALL') )
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   174
{
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   175
	// And here you have it, the de facto way to place a hook. Plugins can place hooks and hook
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   176
	// into other plugins. You just never know.
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   177
	$code = $plugins->setHook('base_classes_initted');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   178
	foreach ( $code as $cmd )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   179
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   180
		eval($cmd);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   181
	}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   182
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   183
	profiler_log('Finished base_classes_initted hook');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   184
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   185
	// One quick security check...
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   186
	if ( isset($_SERVER['REMOTE_ADDR']) )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   187
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   188
		grinding_halt('REMOTE_ADDR detected', 'Detected a REMOTE_ADDR, this should not happen in CLI mode.');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   189
	}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   190
	$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   191
1227
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   192
	// All checks passed! Start the main components up.  
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   193
	$session->start();
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   194
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   195
	// This is where plugins will want to add pages from 1.1.x on out. You can still add
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   196
	// pages at base_classes_initted but the titles won't be localized. This is because
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   197
	// the session manager has to be started before localization will work in the user's
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   198
	// preferred language.
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   199
	$code = $plugins->setHook('session_started');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   200
	foreach ( $code as $cmd )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   201
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   202
		eval($cmd);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   203
	}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   204
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   205
	profiler_log('Ran session_started hook');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   206
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   207
	$paths->init($paths->nslist['System'] . 'API');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   208
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   209
	// We're ready for whatever life throws us now.
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   210
	define('ENANO_MAINSTREAM', '');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   211
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   212
	// If the site is disabled, bail out, unless we're trying to log in or administer the site
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   213
	if(getConfig('site_disabled') == '1' && $session->user_level < USER_LEVEL_ADMIN)
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   214
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   215
		if ( $paths->namespace == 'Admin' || ( $paths->namespace == 'Special' && ( $paths->page_id == 'CSS' || $paths->page_id == 'Administration' || $paths->page_id == 'Login' ) ) )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   216
		{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   217
			// do nothing; allow execution to continue
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   218
		}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   219
		else
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   220
		{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   221
			if(!$n = getConfig('site_disabled_notice')) 
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   222
			{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   223
				$n = 'The administrator has disabled the site. Please check back later.';
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   224
			}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   225
			
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   226
			$text = RenderMan::render($n) . '
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   227
			<div class="info-box">
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   228
				If you have an administrative account, you may <a href="'.makeUrlNS('Special', 'Login').'">log in</a> to the site.
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   229
			</div>';
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   230
			$paths->wiki_mode = 0;
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   231
			die_semicritical('Site disabled', $text);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   232
		}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   233
	}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   234
	else if ( getConfig('site_disabled') == '1' && $session->user_level >= USER_LEVEL_ADMIN )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   235
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   236
		// If the site is disabled but the user has admin rights, allow browsing
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   237
		// and stuff, but display the orange box notifying the admin.
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   238
		$template->site_disabled = true;
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   239
	}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   240
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   241
	// At this point all of Enano is fully initialized and running and you're ready to do whatever you want.
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   242
	$code = $plugins->setHook('common_post');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   243
	foreach ( $code as $cmd )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   244
	{
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   245
		eval($cmd);
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   246
	}
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   247
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   248
	profiler_log('Ran disabled-site checks and common_post');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   249
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   250
	load_rank_data();
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   251
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   252
	profiler_log('Loaded user rank data');
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   253
	
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   254
	if ( isset($_GET['noheaders']) )
bdac73ed481e Going ahead with the switch to tabs. This is a major coding standards change! If any unusual parser bugs show up, check this changeset. Converted all .php, .js, .tpl, .css, and .json files and did basic testing.
Dan
parents: 1202
diff changeset
   255
		$template->no_headers = true;
500
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   256
}
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   257
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   258
profiler_log('common finished');
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   259
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   260
// That's the end. Enano should be loaded now :-)
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   261
455277559782 Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
diff changeset
   262
?>