require_once('include/autoloader.php');
+use \Friendica\Core\Config;
+
require_once('include/config.php');
require_once('include/network.php');
require_once('include/plugin.php');
define ( 'FRIENDICA_CODENAME', 'Asparagus');
define ( 'FRIENDICA_VERSION', '3.5.1-dev' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
-define ( 'DB_UPDATE_VERSION', 1209 );
+define ( 'DB_UPDATE_VERSION', 1214 );
/**
* @brief Constant with a HTML line break.
define ( 'NETWORK_APPNET', 'apdn'); // app.net
define ( 'NETWORK_NEWS', 'nntp'); // Network News Transfer Protocol
define ( 'NETWORK_ICALENDAR', 'ical'); // iCalendar
+define ( 'NETWORK_PNUT', 'pnut'); // pnut.io
define ( 'NETWORK_PHANTOM', 'unkn'); // Place holder
/** @}*/
NETWORK_APPNET => (-17),
NETWORK_NEWS => (-18),
NETWORK_ICALENDAR => (-19),
+ NETWORK_PNUT => (-20),
NETWORK_PHANTOM => (-127),
);
public $videoheight = 350;
public $force_max_items = 0;
public $theme_thread_allow = true;
- public $theme_richtext_editor = true;
public $theme_events_in_profile = true;
/**
private $scheme;
private $hostname;
- private $baseurl;
private $db;
private $curl_code;
#set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path());
- if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,9) === "pagename=") {
+ if ((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,9) === "pagename=") {
$this->query_string = substr($_SERVER['QUERY_STRING'],9);
// removing trailing / - maybe a nginx problem
if (substr($this->query_string, 0, 1) == "/")
$this->query_string = substr($this->query_string, 1);
- } elseif((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
+ } elseif ((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
$this->query_string = substr($_SERVER['QUERY_STRING'],2);
// removing trailing / - maybe a nginx problem
if (substr($this->query_string, 0, 1) == "/")
$this->query_string = substr($this->query_string, 1);
}
- if (x($_GET,'pagename'))
+ if (x($_GET,'pagename')) {
$this->cmd = trim($_GET['pagename'],'/\\');
- elseif (x($_GET,'q'))
+ } elseif (x($_GET,'q')) {
$this->cmd = trim($_GET['q'],'/\\');
+ }
// fix query_string
// unix style "homedir"
- if(substr($this->cmd,0,1) === '~')
+ if (substr($this->cmd,0,1) === '~') {
$this->cmd = 'profile/' . substr($this->cmd,1);
+ }
// Diaspora style profile url
- if(substr($this->cmd,0,2) === 'u/')
+ if (substr($this->cmd,0,2) === 'u/') {
$this->cmd = 'profile/' . substr($this->cmd,2);
+ }
/*
* - Host name is determined either by system.hostname or inferred from request
* - Path is inferred from SCRIPT_NAME
*
- * Caches the result (depending on $ssl value) for performance.
- *
* Note: $ssl parameter value doesn't directly correlate with the resulting protocol
*
* @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN
function get_baseurl($ssl = false) {
// Is the function called statically?
- if (!is_object($this)) {
+ if (!(isset($this) && get_class($this) == __CLASS__)) {
return self::$a->get_baseurl($ssl);
}
- // Arbitrary values, the resulting url protocol can be different
- $cache_index = $ssl ? 'https' : 'http';
+ $scheme = $this->scheme;
- // Cached value found, nothing to process
- if (isset($this->baseurl[$cache_index])) {
- return $this->baseurl[$cache_index];
+ if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) {
+ $scheme = 'https';
}
- $scheme = $this->scheme;
+ // Basically, we have $ssl = true on any links which can only be seen by a logged in user
+ // (and also the login link). Anything seen by an outsider will have it turned off.
- if ((x($this->config, 'system')) && (x($this->config['system'], 'ssl_policy'))) {
- if (intval($this->config['system']['ssl_policy']) === SSL_POLICY_FULL) {
+ if (Config::get('system', 'ssl_policy') == SSL_POLICY_SELFSIGN) {
+ if ($ssl) {
$scheme = 'https';
- }
-
- // Basically, we have $ssl = true on any links which can only be seen by a logged in user
- // (and also the login link). Anything seen by an outsider will have it turned off.
-
- if ($this->config['system']['ssl_policy'] == SSL_POLICY_SELFSIGN) {
- if ($ssl) {
- $scheme = 'https';
- } else {
- $scheme = 'http';
- }
+ } else {
+ $scheme = 'http';
}
}
- if (get_config('config', 'hostname') != '') {
- $this->hostname = get_config('config', 'hostname');
+ if (Config::get('config', 'hostname') != '') {
+ $this->hostname = Config::get('config', 'hostname');
}
- $this->baseurl[$cache_index] = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' );
-
- return $this->baseurl[$cache_index];
+ return $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' );
}
/**
function set_baseurl($url) {
$parsed = @parse_url($url);
- $this->baseurl = [];
-
if($parsed) {
$this->scheme = $parsed['scheme'];
'$local_user' => local_user(),
'$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION,
'$delitem' => t('Delete this item?'),
- '$comment' => t('Comment'),
'$showmore' => t('show more'),
'$showfewer' => t('show fewer'),
'$update_interval' => $interval,
} else {
$r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like '%%/%s'",
$common_filename);
- if(! dbm::is_result($r)){
+ if (! dbm::is_result($r)) {
$this->cached_profile_image[$avatar_image] = $avatar_image;
} else {
$this->cached_profile_picdate[$common_filename] = "?rev=".urlencode($r[0]['picdate']);
function remove_baseurl($orig_url){
// Is the function called statically?
- if (!is_object($this)) {
+ if (!(isset($this) && get_class($this) == __CLASS__)) {
return(self::$a->remove_baseurl($orig_url));
}
// If the last worker fork was less than 10 seconds before then don't fork another one.
// This should prevent the forking of masses of workers.
if (get_config("system", "worker")) {
- if ((time() - get_config("system", "proc_run_started")) < 10)
- return;
-
+ $cachekey = "app:proc_run:started";
+ $result = Cache::get($cachekey);
+ if (!is_null($result)) {
+ if ((time() - $result) < 10) {
+ return;
+ }
+ }
// Set the timestamp of the last proc_run
- set_config("system", "proc_run_started", time());
+ Cache::set($cachekey, time(), CACHE_MINUTE);
}
$args[0] = ((x($this->config,'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php');
function clean_urls() {
$a = get_app();
- // if($a->config['system']['clean_urls'])
return true;
- // return false;
}
function z_path() {
* Sets the base url for use in cmdline programs which don't have
* $_SERVER variables
*/
-function check_url(&$a) {
+function check_url(App $a) {
$url = get_config('system','url');
// We will only change the url to an ip address if there is no existing setting
if(! x($url))
- $url = set_config('system','url',$a->get_baseurl());
- if((! link_compare($url,$a->get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname)))
- $url = set_config('system','url',$a->get_baseurl());
+ $url = set_config('system','url',App::get_baseurl());
+ if((! link_compare($url,App::get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname)))
+ $url = set_config('system','url',App::get_baseurl());
return;
}
/**
* @brief Automatic database updates
*/
-function update_db(&$a) {
+function update_db(App $a) {
$build = get_config('system','build');
if(! x($build))
$build = set_config('system','build',DB_UPDATE_VERSION);
$stored = intval($build);
$current = intval(DB_UPDATE_VERSION);
if($stored < $current) {
- load_config('database');
+ Config::load('database');
// We're reporting a different version than what is currently installed.
// Run any existing update scripts to bring the database up to current.
* @param App $a
*
*/
-function check_plugins(&$a) {
+function check_plugins(App $a) {
$r = q("SELECT * FROM `addon` WHERE `installed` = 1");
if (dbm::is_result($r))
// $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
$is_mobile = $a->is_mobile || $a->is_tablet;
- $standard_system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : '');
+ $standard_system_theme = Config::get('system', 'theme', '');
$standard_theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $standard_system_theme);
- if($is_mobile) {
- if(isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
+ if ($is_mobile) {
+ if (isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
$system_theme = $standard_system_theme;
$theme_name = $standard_theme_name;
- }
- else {
- $system_theme = ((isset($a->config['system']['mobile-theme'])) ? $a->config['system']['mobile-theme'] : $standard_system_theme);
+ } else {
+ $system_theme = Config::get('system', 'mobile-theme', '');
+ if ($system_theme == '') {
+ $system_theme = $standard_system_theme;
+ }
$theme_name = ((isset($_SESSION) && x($_SESSION,'mobile-theme')) ? $_SESSION['mobile-theme'] : $system_theme);
if($theme_name === '---') {
return("");
}
-function set_template_engine(&$a, $engine = 'internal') {
+/// @deprecated
+function set_template_engine(App $a, $engine = 'internal') {
/// @note This function is no longer necessary, but keep it as a wrapper to the class method
/// to avoid breaking themes again unnecessarily