Merge remote-tracking branch 'upstream/dev' into wiki

This commit is contained in:
Andrew Manning
2016-05-27 06:35:15 -04:00
152 changed files with 4445 additions and 5346 deletions

120
boot.php
View File

@@ -39,14 +39,14 @@ require_once('include/permissions.php');
require_once('library/Mobile_Detect/Mobile_Detect.php');
require_once('include/features.php');
require_once('include/taxonomy.php');
require_once('include/identity.php');
require_once('include/Contact.php');
require_once('include/channel.php');
require_once('include/connections.php');
require_once('include/account.php');
define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'STD_VERSION', '1.7.1' );
define ( 'ZOT_REVISION', 1 );
define ( 'ZOT_REVISION', 1.1 );
define ( 'DB_UPDATE_VERSION', 1168 );
@@ -580,6 +580,72 @@ define ( 'ITEM_IS_STICKY', 1000 );
define ( 'DBTYPE_MYSQL', 0 );
define ( 'DBTYPE_POSTGRES', 1 );
function sys_boot() {
// our central App object
App::init();
/*
* Load the configuration file which contains our DB credentials.
* Ignore errors. If the file doesn't exist or is empty, we are running in
* installation mode.
*/
// miniApp is a conversion object from old style .htconfig.php files
$a = new miniApp;
App::$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true);
@include('.htconfig.php');
if(! defined('UNO'))
define('UNO', 0);
if(array_key_exists('default_timezone',get_defined_vars())) {
App::$config['system']['timezone'] = $default_timezone;
}
$a->convert();
App::$timezone = ((App::$config['system']['timezone']) ? App::$config['system']['timezone'] : 'UTC');
date_default_timezone_set(App::$timezone);
/*
* Try to open the database;
*/
require_once('include/dba/dba_driver.php');
if(! App::$install) {
DBA::dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, App::$install);
if(! DBA::$dba->connected) {
system_unavailable();
}
unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type);
/**
* Load configs from db. Overwrite configs from .htconfig.php
*/
load_config('config');
load_config('system');
load_config('feature');
App::$session = new Zotlabs\Web\Session();
App::$session->init();
load_hooks();
call_hooks('init_1');
}
}
/**
*
* Reverse the effect of magic_quotes_gpc if it is enabled.
@@ -1198,7 +1264,6 @@ class App {
* @return App
*/
function get_app() {
global $a;
return $a;
}
@@ -1248,7 +1313,6 @@ function system_unavailable() {
function clean_urls() {
global $a;
// if(App::$config['system']['clean_urls'])
return true;
@@ -1256,8 +1320,6 @@ function clean_urls() {
}
function z_path() {
global $a;
$base = z_root();
if(! clean_urls())
$base .= '/?q=';
@@ -1273,7 +1335,6 @@ function z_path() {
* @return string
*/
function z_root() {
global $a;
return App::get_baseurl();
}
@@ -1605,7 +1666,6 @@ function fix_system_urls($oldurl, $newurl) {
// returns the complete html for inserting into the page
function login($register = false, $form_id = 'main-login', $hiddens=false) {
$a = get_app();
$o = '';
$reg = false;
$reglink = get_config('system', 'register_link');
@@ -1675,9 +1735,7 @@ function goaway($s) {
}
function shutdown() {
global $db;
if(is_object($db) && $db->connected)
$db->close();
}
/**
@@ -1767,7 +1825,6 @@ function remote_user() {
* @param string $s Text to display
*/
function notice($s) {
$a = get_app();
if(! x($_SESSION, 'sysmsg')) $_SESSION['sysmsg'] = array();
// ignore duplicated error messages which haven't yet been displayed
@@ -1791,7 +1848,6 @@ function notice($s) {
* @param string $s Text to display
*/
function info($s) {
$a = get_app();
if(! x($_SESSION, 'sysmsg_info')) $_SESSION['sysmsg_info'] = array();
if(App::$interactive)
$_SESSION['sysmsg_info'][] = $s;
@@ -1892,7 +1948,6 @@ function is_windows() {
*/
function is_site_admin() {
$a = get_app();
if($_SESSION['delegate'])
return false;
@@ -1913,7 +1968,7 @@ function is_site_admin() {
* @return bool true if user is a developer
*/
function is_developer() {
$a = get_app();
if((intval($_SESSION['authenticated']))
&& (is_array(App::$account))
&& (App::$account['account_roles'] & ACCOUNT_ROLE_DEVELOPER))
@@ -1924,7 +1979,6 @@ function is_developer() {
function load_contact_links($uid) {
$a = get_app();
$ret = array();
@@ -2242,7 +2296,6 @@ function appdirpath() {
* @param string $icon
*/
function head_set_icon($icon) {
global $a;
App::$data['pageicon'] = $icon;
// logger('head_set_icon: ' . $icon);
@@ -2254,7 +2307,6 @@ function head_set_icon($icon) {
* @return string absolut path to pageicon
*/
function head_get_icon() {
global $a;
$icon = App::$data['pageicon'];
if(! strpos($icon, '://'))
@@ -2320,7 +2372,7 @@ function z_get_temp_dir() {
}
function z_check_cert() {
$a = get_app();
if(strpos(z_root(),'https://') !== false) {
$x = z_fetch_url(z_root() . '/siteinfo/json');
if(! $x['success']) {
@@ -2341,8 +2393,6 @@ function z_check_cert() {
*/
function cert_bad_email() {
$a = get_app();
$email_tpl = get_intltext_template("cert_bad_eml.tpl");
$email_msg = replace_macros($email_tpl, array(
'$sitename' => App::$config['system']['sitename'],
@@ -2363,26 +2413,30 @@ function cert_bad_email() {
*/
function check_cron_broken() {
$t = get_config('system','lastpollcheck');
$d = get_config('system','lastcron');
if((! $d) || ($d < datetime_convert('UTC','UTC','now - 4 hours'))) {
Zotlabs\Daemon\Master::Summon(array('Cron'));
}
$t = get_config('system','lastcroncheck');
if(! $t) {
// never checked before. Start the timer.
set_config('system','lastpollcheck',datetime_convert());
set_config('system','lastcroncheck',datetime_convert());
return;
}
if($t > datetime_convert('UTC','UTC','now - 3 days')) {
// Wait for 3 days before we do anything so as not to swamp the admin with messages
return;
}
$d = get_config('system','lastpoll');
if(($d) && ($d > datetime_convert('UTC','UTC','now - 3 days'))) {
// Scheduled tasks have run successfully in the last 3 days.
set_config('system','lastpollcheck',datetime_convert());
set_config('system','lastcroncheck',datetime_convert());
return;
}
$a = get_app();
$email_tpl = get_intltext_template("cron_bad_eml.tpl");
$email_msg = replace_macros($email_tpl, array(
'$sitename' => App::$config['system']['sitename'],
@@ -2396,8 +2450,16 @@ function check_cron_broken() {
'From: Administrator' . '@' . App::get_hostname() . "\n"
. 'Content-type: text/plain; charset=UTF-8' . "\n"
. 'Content-transfer-encoding: 8bit' );
set_config('system','lastpollcheck',datetime_convert());
return;
}
function observer_prohibited($allow_account = false) {
if($allow_account)
return (((get_config('system','block_public')) && (! get_account_id()) && (! remote_channel())) ? true : false );
return (((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) ? true : false );
}