2015-05-23 23:34:08 +00:00
|
|
|
<?php
|
2010-12-09 07:08:59 +00:00
|
|
|
/**
|
2015-05-23 23:34:08 +00:00
|
|
|
* @file index.php
|
2010-12-09 07:08:59 +00:00
|
|
|
*
|
2015-05-23 23:34:08 +00:00
|
|
|
* @brief The main entry point to the application.
|
2010-12-09 07:08:59 +00:00
|
|
|
*
|
2015-05-23 23:34:08 +00:00
|
|
|
* Bootstrap the application, load configuration, load modules, load theme, etc.
|
2010-12-09 07:08:59 +00:00
|
|
|
*/
|
2010-07-01 23:48:07 +00:00
|
|
|
|
2015-05-23 23:34:08 +00:00
|
|
|
/*
|
2010-12-09 07:08:59 +00:00
|
|
|
* bootstrap the application
|
|
|
|
*/
|
|
|
|
require_once('boot.php');
|
2016-01-18 00:29:32 +00:00
|
|
|
|
|
|
|
if(file_exists('.htsite.php'))
|
|
|
|
include('.htsite.php');
|
|
|
|
|
2015-05-23 23:34:08 +00:00
|
|
|
// our global App object
|
2016-04-01 03:15:47 +00:00
|
|
|
|
|
|
|
$a = new miniApp;
|
|
|
|
|
2016-04-01 03:24:30 +00:00
|
|
|
App::init();
|
2010-07-01 23:48:07 +00:00
|
|
|
|
2015-05-23 23:34:08 +00:00
|
|
|
/*
|
2010-12-09 07:08:59 +00:00
|
|
|
* Load the configuration file which contains our DB credentials.
|
2015-05-23 23:34:08 +00:00
|
|
|
* Ignore errors. If the file doesn't exist or is empty, we are running in
|
|
|
|
* installation mode.
|
2010-12-09 07:08:59 +00:00
|
|
|
*/
|
2010-07-01 23:48:07 +00:00
|
|
|
|
2016-03-31 23:06:03 +00:00
|
|
|
App::$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true);
|
2010-07-01 23:48:07 +00:00
|
|
|
|
2015-05-23 23:34:08 +00:00
|
|
|
@include('.htconfig.php');
|
2010-10-07 00:40:58 +00:00
|
|
|
|
2016-02-05 08:06:35 +00:00
|
|
|
if(! defined('UNO'))
|
|
|
|
define('UNO', 0);
|
|
|
|
|
2016-04-01 03:15:47 +00:00
|
|
|
$a->convert();
|
|
|
|
|
2016-03-31 23:06:03 +00:00
|
|
|
App::$timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');
|
|
|
|
date_default_timezone_set(App::$timezone);
|
2014-09-30 06:36:41 +00:00
|
|
|
|
|
|
|
|
2015-05-23 23:34:08 +00:00
|
|
|
/*
|
2010-12-09 07:08:59 +00:00
|
|
|
* Try to open the database;
|
|
|
|
*/
|
|
|
|
|
2015-05-23 23:34:08 +00:00
|
|
|
require_once('include/dba/dba_driver.php');
|
2010-12-09 07:08:59 +00:00
|
|
|
|
2016-03-31 23:06:03 +00:00
|
|
|
if(! App::$install) {
|
2016-04-26 03:12:36 +00:00
|
|
|
$db = dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, App::$install);
|
2015-11-20 20:49:38 +00:00
|
|
|
if(! $db->connected) {
|
|
|
|
system_unavailable();
|
2015-11-20 04:58:13 +00:00
|
|
|
}
|
|
|
|
|
2015-05-23 23:34:08 +00:00
|
|
|
unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type);
|
2011-06-28 00:18:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load configs from db. Overwrite configs from .htconfig.php
|
|
|
|
*/
|
|
|
|
|
2011-06-30 08:15:18 +00:00
|
|
|
load_config('config');
|
|
|
|
load_config('system');
|
2013-06-14 23:54:58 +00:00
|
|
|
load_config('feature');
|
2011-06-28 00:18:13 +00:00
|
|
|
|
2016-04-08 11:44:10 +00:00
|
|
|
\Zotlabs\Web\Session::init();
|
2011-06-28 00:18:13 +00:00
|
|
|
load_hooks();
|
|
|
|
call_hooks('init_1');
|
2015-05-23 23:34:08 +00:00
|
|
|
|
2013-03-11 23:13:09 +00:00
|
|
|
}
|
2016-02-24 19:20:46 +00:00
|
|
|
|
|
|
|
|
2016-03-31 23:06:03 +00:00
|
|
|
App::$language = get_best_language();
|
|
|
|
load_translation_table(App::$language,App::$install);
|
2011-06-13 10:51:36 +00:00
|
|
|
|
|
|
|
|
2010-12-09 07:08:59 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Important stuff we always need to do.
|
2012-06-12 02:52:46 +00:00
|
|
|
*
|
2010-12-09 07:08:59 +00:00
|
|
|
* The order of these may be important so use caution if you think they're all
|
|
|
|
* intertwingled with no logical order and decide to sort it out. Some of the
|
2015-05-23 23:34:08 +00:00
|
|
|
* dependencies have changed, but at least at one time in the recent past - the
|
2010-12-09 07:08:59 +00:00
|
|
|
* order was critical to everything working properly
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-04-08 11:44:10 +00:00
|
|
|
\Zotlabs\Web\Session::start();
|
2010-07-01 23:48:07 +00:00
|
|
|
|
2011-03-31 11:57:31 +00:00
|
|
|
/**
|
|
|
|
* Language was set earlier, but we can over-ride it in the session.
|
|
|
|
* We have to do it here because the session was just now opened.
|
|
|
|
*/
|
|
|
|
|
2011-09-21 23:00:17 +00:00
|
|
|
if(array_key_exists('system_language',$_POST)) {
|
|
|
|
if(strlen($_POST['system_language']))
|
|
|
|
$_SESSION['language'] = $_POST['system_language'];
|
|
|
|
else
|
|
|
|
unset($_SESSION['language']);
|
|
|
|
}
|
2015-05-23 23:34:08 +00:00
|
|
|
if((x($_SESSION, 'language')) && ($_SESSION['language'] !== $lang)) {
|
2016-03-31 23:06:03 +00:00
|
|
|
App::$language = $_SESSION['language'];
|
|
|
|
load_translation_table(App::$language);
|
2011-03-31 11:57:31 +00:00
|
|
|
}
|
|
|
|
|
2016-03-31 23:06:03 +00:00
|
|
|
if((x($_GET,'zid')) && (! App::$install)) {
|
|
|
|
App::$query_string = strip_zids(App::$query_string);
|
2015-01-29 04:56:04 +00:00
|
|
|
if(! local_channel()) {
|
2012-11-09 03:07:19 +00:00
|
|
|
$_SESSION['my_address'] = $_GET['zid'];
|
|
|
|
zid_init($a);
|
|
|
|
}
|
2012-03-30 03:58:32 +00:00
|
|
|
}
|
2011-03-31 11:57:31 +00:00
|
|
|
|
2016-03-31 23:06:03 +00:00
|
|
|
if((x($_SESSION, 'authenticated')) || (x($_POST, 'auth-params')) || (App::$module === 'login'))
|
2015-05-23 23:34:08 +00:00
|
|
|
require('include/auth.php');
|
2010-07-01 23:48:07 +00:00
|
|
|
|
2015-05-23 23:34:08 +00:00
|
|
|
if(! x($_SESSION, 'sysmsg'))
|
2011-09-05 12:01:21 +00:00
|
|
|
$_SESSION['sysmsg'] = array();
|
2010-10-31 23:38:22 +00:00
|
|
|
|
2015-05-23 23:34:08 +00:00
|
|
|
if(! x($_SESSION, 'sysmsg_info'))
|
2011-09-05 12:01:21 +00:00
|
|
|
$_SESSION['sysmsg_info'] = array();
|
2011-05-23 09:39:57 +00:00
|
|
|
|
2010-12-09 07:08:59 +00:00
|
|
|
/*
|
2015-05-23 23:34:08 +00:00
|
|
|
* check_config() is responsible for running update scripts. These automatically
|
2011-03-10 10:45:37 +00:00
|
|
|
* update the DB schema whenever we push a new one out. It also checks to see if
|
2015-05-23 23:34:08 +00:00
|
|
|
* any plugins have been added or removed and reacts accordingly.
|
2010-12-09 07:08:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-03-31 23:06:03 +00:00
|
|
|
if(App::$install) {
|
2013-07-04 03:37:39 +00:00
|
|
|
/* Allow an exception for the view module so that pcss will be interpreted during installation */
|
2016-03-31 23:06:03 +00:00
|
|
|
if(App::$module != 'view')
|
|
|
|
App::$module = 'setup';
|
2013-07-04 03:37:39 +00:00
|
|
|
}
|
2010-08-15 01:11:36 +00:00
|
|
|
else
|
|
|
|
check_config($a);
|
2010-07-01 23:48:07 +00:00
|
|
|
|
2011-11-12 20:28:21 +00:00
|
|
|
nav_set_selected('nothing');
|
2010-12-09 07:08:59 +00:00
|
|
|
|
2016-03-31 23:06:03 +00:00
|
|
|
$arr = array('app_menu' => App::get_apps());
|
2011-02-19 08:56:15 +00:00
|
|
|
|
|
|
|
call_hooks('app_menu', $arr);
|
|
|
|
|
2016-03-31 23:06:03 +00:00
|
|
|
App::set_apps($arr['app_menu']);
|
2011-02-19 08:56:15 +00:00
|
|
|
|
2016-02-20 00:19:15 +00:00
|
|
|
$Router = new Zotlabs\Web\Router($a);
|
2011-02-19 08:56:15 +00:00
|
|
|
|
2011-01-10 21:45:42 +00:00
|
|
|
/* initialise content region */
|
|
|
|
|
2016-03-31 23:06:03 +00:00
|
|
|
if(! x(App::$page, 'content'))
|
|
|
|
App::$page['content'] = '';
|
2011-01-10 21:45:42 +00:00
|
|
|
|
2016-04-13 05:55:26 +00:00
|
|
|
call_hooks('page_content_top', App::$page['content']);
|
2014-02-02 22:06:36 +00:00
|
|
|
|
2013-12-09 12:30:00 +00:00
|
|
|
|
2016-02-20 00:19:15 +00:00
|
|
|
$Router->Dispatch($a);
|
2014-02-02 22:06:36 +00:00
|
|
|
|
2011-01-10 21:45:42 +00:00
|
|
|
|
2011-03-10 10:45:37 +00:00
|
|
|
// If you're just visiting, let javascript take you home
|
2011-01-04 22:35:12 +00:00
|
|
|
|
2015-05-23 23:34:08 +00:00
|
|
|
if(x($_SESSION, 'visitor_home')) {
|
2011-01-04 22:35:12 +00:00
|
|
|
$homebase = $_SESSION['visitor_home'];
|
2015-05-23 23:34:08 +00:00
|
|
|
} elseif(local_channel()) {
|
2016-03-31 23:06:03 +00:00
|
|
|
$homebase = z_root() . '/channel/' . App::$channel['channel_address'];
|
2015-05-23 23:34:08 +00:00
|
|
|
}
|
2011-01-04 22:35:12 +00:00
|
|
|
|
2015-05-23 23:34:08 +00:00
|
|
|
if(isset($homebase)) {
|
2016-03-31 23:06:03 +00:00
|
|
|
App::$page['content'] .= '<script>var homebase = "' . $homebase . '";</script>';
|
2015-05-23 23:34:08 +00:00
|
|
|
}
|
2011-01-04 13:06:10 +00:00
|
|
|
|
2011-01-05 09:53:34 +00:00
|
|
|
// now that we've been through the module content, see if the page reported
|
|
|
|
// a permission problem and if so, a 403 response would seem to be in order.
|
|
|
|
|
2015-05-23 23:34:08 +00:00
|
|
|
if(stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) {
|
|
|
|
header($_SERVER['SERVER_PROTOCOL'] . ' 403 ' . t('Permission denied.'));
|
2010-09-09 03:14:17 +00:00
|
|
|
}
|
|
|
|
|
2011-01-10 21:45:42 +00:00
|
|
|
|
2016-03-31 23:06:03 +00:00
|
|
|
call_hooks('page_end', App::$page['content']);
|
2011-01-10 21:45:42 +00:00
|
|
|
|
2013-01-05 04:27:41 +00:00
|
|
|
construct_page($a);
|
2010-07-01 23:48:07 +00:00
|
|
|
|
|
|
|
exit;
|