1
0
Fork 0

Merge pull request #3423 from Hypolite/improvement/move-app-to-src-2

Move App to `src` redux
This commit is contained in:
Michael Vogel 2017-05-07 19:37:50 +02:00 committed by GitHub
commit fa3fa42d96
319 changed files with 2509 additions and 2156 deletions

1220
boot.php
View file

@ -1,4 +1,5 @@
<?php
/** @file boot.php
*
* This file defines some global constants and includes the central App class.
@ -17,22 +18,23 @@
* easily as email does today.
*/
require_once(__DIR__ . DIRECTORY_SEPARATOR. 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('include/config.php');
require_once('include/network.php');
require_once('include/plugin.php');
require_once('include/text.php');
require_once('include/datetime.php');
require_once('include/pgettext.php');
require_once('include/nav.php');
require_once('include/cache.php');
require_once('include/features.php');
require_once('include/identity.php');
require_once('update.php');
require_once('include/dbstructure.php');
require_once 'include/config.php';
require_once 'include/network.php';
require_once 'include/plugin.php';
require_once 'include/text.php';
require_once 'include/datetime.php';
require_once 'include/pgettext.php';
require_once 'include/nav.php';
require_once 'include/cache.php';
require_once 'include/features.php';
require_once 'include/identity.php';
require_once 'update.php';
require_once 'include/dbstructure.php';
define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_CODENAME', 'Asparagus');
@ -50,7 +52,6 @@ define ( 'DB_UPDATE_VERSION', 1224 );
define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
/**
* @brief Image storage quality.
*
@ -61,8 +62,8 @@ define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
* below about 50
*
*/
define ( 'JPEG_QUALITY', 100 );
/**
* $a->config['system']['png_quality'] from 0 (uncompressed) to 9
*/
@ -86,12 +87,10 @@ define ( 'PNG_QUALITY', 8 );
*/
define ( 'MAX_IMAGE_LENGTH', -1 );
/**
* Not yet used
*/
define ( 'DEFAULT_DB_ENGINE', 'MyISAM' );
define ( 'DEFAULT_DB_ENGINE', 'InnoDB' );
/**
* @name SSL Policy
@ -165,7 +164,6 @@ define ( 'UPDATE_SUCCESS', 0);
define ( 'UPDATE_FAILED', 1);
/** @}*/
/**
* @name page/profile types
*
@ -291,20 +289,16 @@ $netgroup_ids = array(
NETWORK_PHANTOM => (-127),
);
/**
* Maximum number of "people who like (or don't like) this" that we will list by name
*/
define ( 'MAX_LIKERS', 75);
/**
* Communication timeout
*/
define ( 'ZCURL_TIMEOUT' , (-1));
/**
* @name Notify
*
@ -345,8 +339,6 @@ define ( 'TERM_CONVERSATION', 7 );
define ( 'TERM_OBJ_POST', 1 );
define ( 'TERM_OBJ_PHOTO', 2 );
/**
* @name Namespaces
*
@ -458,14 +450,13 @@ define('SR_SCOPE_TAGS', 'tags');
/**
* Lowest possible date time value
*/
define ('NULL_DATE', '0001-01-01 00:00:00');
// Normally this constant is defined - but not if "pcntl" isn't installed
if (!defined("SIGTERM")) {
define("SIGTERM", 15);
}
/**
*
* Reverse the effect of magic_quotes_gpc if it is enabled.
@ -473,9 +464,7 @@ if (!defined("SIGTERM")) {
* See http://php.net/manual/en/security.magicquotes.disabling.php
*
*/
function startup() {
error_reporting(E_ERROR | E_WARNING | E_PARSE);
set_time_limit(0);
@ -483,7 +472,6 @@ function startup() {
// This has to be quite large to deal with embedded private photos
ini_set('pcre.backtrack_limit', 500000);
if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
@ -499,989 +487,6 @@ function startup() {
}
unset($process);
}
}
/**
*
* class: App
*
* @brief Our main application structure for the life of this page.
*
* Primarily deals with the URL that got us here
* and tries to make some sense of it, and
* stores our page contents and config storage
* and anything else that might need to be passed around
* before we spit the page out.
*
*/
class App {
/// @TODO decide indending as a colorful mixure is ahead ...
public $module_loaded = false;
public $query_string;
public $config;
public $page;
public $profile;
public $profile_uid;
public $user;
public $cid;
public $contact;
public $contacts;
public $page_contact;
public $content;
public $data = array();
public $error = false;
public $cmd;
public $argv;
public $argc;
public $module;
public $pager;
public $strings;
public $path;
public $hooks;
public $timezone;
public $interactive = true;
public $plugins;
public $apps = array();
public $identities;
public $is_mobile = false;
public $is_tablet = false;
public $is_friendica_app;
public $performance = array();
public $callstack = array();
public $theme_info = array();
public $backend = true;
public $nav_sel;
public $category;
// Allow themes to control internal parameters
// by changing App values in theme.php
public $sourcename = '';
public $videowidth = 425;
public $videoheight = 350;
public $force_max_items = 0;
public $theme_thread_allow = true;
public $theme_events_in_profile = true;
/**
* @brief An array for all theme-controllable parameters
*
* Mostly unimplemented yet. Only options 'template_engine' and
* beyond are used.
*/
public $theme = array(
'sourcename' => '',
'videowidth' => 425,
'videoheight' => 350,
'force_max_items' => 0,
'thread_allow' => true,
'stylesheet' => '',
'template_engine' => 'smarty3',
);
/**
* @brief An array of registered template engines ('name'=>'class name')
*/
public $template_engines = array();
/**
* @brief An array of instanced template engines ('name'=>'instance')
*/
public $template_engine_instance = array();
public $process_id;
private $ldelim = array(
'internal' => '',
'smarty3' => '{{'
);
private $rdelim = array(
'internal' => '',
'smarty3' => '}}'
);
private $scheme;
private $hostname;
private $db;
private $curl_code;
private $curl_content_type;
private $curl_headers;
private $cached_profile_image;
private $cached_profile_picdate;
private static $a;
/**
* @brief App constructor.
*/
function __construct() {
global $default_timezone;
$hostname = "";
if (file_exists(".htpreconfig.php")) {
include ".htpreconfig.php";
}
$this->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');
date_default_timezone_set($this->timezone);
$this->performance["start"] = microtime(true);
$this->performance["database"] = 0;
$this->performance["database_write"] = 0;
$this->performance["network"] = 0;
$this->performance["file"] = 0;
$this->performance["rendering"] = 0;
$this->performance["parser"] = 0;
$this->performance["marktime"] = 0;
$this->performance["markstart"] = microtime(true);
$this->callstack["database"] = array();
$this->callstack["database_write"] = array();
$this->callstack["network"] = array();
$this->callstack["file"] = array();
$this->callstack["rendering"] = array();
$this->callstack["parser"] = array();
$this->config = array();
$this->page = array();
$this->pager= array();
$this->query_string = '';
$this->process_id = uniqid("log", true);
startup();
set_include_path(
get_include_path() . PATH_SEPARATOR
. 'include' . PATH_SEPARATOR
. 'library' . PATH_SEPARATOR
. 'library/langdet' . PATH_SEPARATOR
. '.' );
$this->scheme = 'http';
if ((x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) ||
(x($_SERVER, 'HTTP_FORWARDED') && preg_match("/proto=https/", $_SERVER['HTTP_FORWARDED'])) ||
(x($_SERVER, 'HTTP_X_FORWARDED_PROTO') && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||
(x($_SERVER, 'HTTP_X_FORWARDED_SSL') && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') ||
(x($_SERVER, 'FRONT_END_HTTPS') && $_SERVER['FRONT_END_HTTPS'] == 'on') ||
(x($_SERVER, 'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) // XXX: reasonable assumption, but isn't this hardcoding too much?
) {
$this->scheme = 'https';
}
if (x($_SERVER, 'SERVER_NAME')) {
$this->hostname = $_SERVER['SERVER_NAME'];
if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
$this->hostname .= ':' . $_SERVER['SERVER_PORT'];
}
/*
* Figure out if we are running at the top of a domain
* or in a sub-directory and adjust accordingly
*/
/// @TODO This kind of escaping breaks syntax-highlightning on CoolEdit (Midnight Commander)
$path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
if (isset($path) && strlen($path) && ($path != $this->path)) {
$this->path = $path;
}
}
if ($hostname != "") {
$this->hostname = $hostname;
}
if (is_array($_SERVER["argv"]) && $_SERVER["argc"] > 1 && substr(end($_SERVER["argv"]), 0, 4) == "http" ) {
$this->set_baseurl(array_pop($_SERVER["argv"]));
$_SERVER["argc"] --;
}
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
$this->query_string = ltrim($this->query_string, '/');
} 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
$this->query_string = ltrim($this->query_string, '/');
}
if (x($_GET, 'pagename')) {
$this->cmd = trim($_GET['pagename'], '/\\');
} elseif (x($_GET, 'q')) {
$this->cmd = trim($_GET['q'], '/\\');
}
// fix query_string
$this->query_string = str_replace($this->cmd . "&", $this->cmd . "?", $this->query_string);
// unix style "homedir"
if (substr($this->cmd, 0, 1) === '~') {
$this->cmd = 'profile/' . substr($this->cmd, 1);
}
// Diaspora style profile url
if (substr($this->cmd, 0, 2) === 'u/') {
$this->cmd = 'profile/' . substr($this->cmd, 2);
}
/*
* Break the URL path into C style argc/argv style arguments for our
* modules. Given "http://example.com/module/arg1/arg2", $this->argc
* will be 3 (integer) and $this->argv will contain:
* [0] => 'module'
* [1] => 'arg1'
* [2] => 'arg2'
*
*
* There will always be one argument. If provided a naked domain
* URL, $this->argv[0] is set to "home".
*/
$this->argv = explode('/', $this->cmd);
$this->argc = count($this->argv);
if ((array_key_exists('0', $this->argv)) && strlen($this->argv[0])) {
$this->module = str_replace(".", "_", $this->argv[0]);
$this->module = str_replace("-", "_", $this->module);
} else {
$this->argc = 1;
$this->argv = array('home');
$this->module = 'home';
}
/*
* See if there is any page number information, and initialise
* pagination
*/
$this->pager['page'] = ((x($_GET, 'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1);
$this->pager['itemspage'] = 50;
$this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
if ($this->pager['start'] < 0) {
$this->pager['start'] = 0;
}
$this->pager['total'] = 0;
/*
* Detect mobile devices
*/
$mobile_detect = new Mobile_Detect();
$this->is_mobile = $mobile_detect->isMobile();
$this->is_tablet = $mobile_detect->isTablet();
// Friendica-Client
$this->is_friendica_app = ($_SERVER['HTTP_USER_AGENT'] == "Apache-HttpClient/UNAVAILABLE (java 1.4)");
/*
* register template engines
*/
$dc = get_declared_classes();
foreach ($dc as $k) {
if (in_array("ITemplateEngine", class_implements($k))){
$this->register_template_engine($k);
}
}
self::$a = $this;
}
public static function get_basepath() {
$basepath = get_config("system", "basepath");
if ($basepath == "") {
$basepath = dirname(__FILE__);
}
if ($basepath == "") {
$basepath = $_SERVER["DOCUMENT_ROOT"];
}
if ($basepath == "") {
$basepath = $_SERVER["PWD"];
}
return $basepath;
}
function get_scheme() {
return $this->scheme;
}
/**
* @brief Retrieves the Friendica instance base URL
*
* This function assembles the base URL from multiple parts:
* - Protocol is determined either by the request or a combination of
* system.ssl_policy and the $ssl parameter.
* - Host name is determined either by system.hostname or inferred from request
* - Path is inferred from SCRIPT_NAME
*
* 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
* @return string Friendica server base URL
*/
function get_baseurl($ssl = false) {
// Is the function called statically?
if (!(isset($this) && get_class($this) == __CLASS__)) {
return self::$a->get_baseurl($ssl);
}
$scheme = $this->scheme;
if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) {
$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 (Config::get('system', 'ssl_policy') == SSL_POLICY_SELFSIGN) {
if ($ssl) {
$scheme = 'https';
} else {
$scheme = 'http';
}
}
if (Config::get('config', 'hostname') != '') {
$this->hostname = Config::get('config', 'hostname');
}
return $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' );
}
/**
* @brief Initializes the baseurl components
*
* Clears the baseurl cache to prevent inconstistencies
*
* @param string $url
*/
function set_baseurl($url) {
$parsed = @parse_url($url);
if ($parsed) {
$this->scheme = $parsed['scheme'];
$hostname = $parsed['host'];
if (x($parsed, 'port')) {
$hostname .= ':' . $parsed['port'];
}
if (x($parsed, 'path')) {
$this->path = trim($parsed['path'], '\\/');
}
if (file_exists(".htpreconfig.php")) {
include ".htpreconfig.php";
}
if (get_config('config', 'hostname') != '') {
$this->hostname = get_config('config', 'hostname');
}
if (!isset($this->hostname) OR ($this->hostname == '')) {
$this->hostname = $hostname;
}
}
}
function get_hostname() {
if (get_config('config', 'hostname') != "") {
$this->hostname = get_config('config', 'hostname');
}
return $this->hostname;
}
function set_hostname($h) {
$this->hostname = $h;
}
function set_path($p) {
$this->path = trim(trim($p), '/');
}
function get_path() {
return $this->path;
}
function set_pager_total($n) {
$this->pager['total'] = intval($n);
}
function set_pager_itemspage($n) {
$this->pager['itemspage'] = ((intval($n) > 0) ? intval($n) : 0);
$this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
}
function set_pager_page($n) {
$this->pager['page'] = $n;
$this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
}
function init_pagehead() {
$interval = ((local_user()) ? get_pconfig(local_user(),'system','update_interval') : 40000);
// If the update is "deactivated" set it to the highest integer number (~24 days)
if ($interval < 0) {
$interval = 2147483647;
}
if ($interval < 10000) {
$interval = 40000;
}
// compose the page title from the sitename and the
// current module called
if (!$this->module == '') {
$this->page['title'] = $this->config['sitename'] . ' (' . $this->module . ')';
} else {
$this->page['title'] = $this->config['sitename'];
}
/* put the head template at the beginning of page['htmlhead']
* since the code added by the modules frequently depends on it
* being first
*/
if (!isset($this->page['htmlhead'])) {
$this->page['htmlhead'] = '';
}
// If we're using Smarty, then doing replace_macros() will replace
// any unrecognized variables with a blank string. Since we delay
// replacing $stylesheet until later, we need to replace it now
// with another variable name
if ($this->theme['template_engine'] === 'smarty3') {
$stylesheet = $this->get_template_ldelim('smarty3') . '$stylesheet' . $this->get_template_rdelim('smarty3');
} else {
$stylesheet = '$stylesheet';
}
$shortcut_icon = get_config("system", "shortcut_icon");
if ($shortcut_icon == "") {
$shortcut_icon = "images/friendica-32.png";
}
$touch_icon = get_config("system", "touch_icon");
if ($touch_icon == "") {
$touch_icon = "images/friendica-128.png";
}
// get data wich is needed for infinite scroll on the network page
$invinite_scroll = infinite_scroll_data($this->module);
$tpl = get_markup_template('head.tpl');
$this->page['htmlhead'] = replace_macros($tpl,array(
'$baseurl' => $this->get_baseurl(), // FIXME for z_path!!!!
'$local_user' => local_user(),
'$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION,
'$delitem' => t('Delete this item?'),
'$showmore' => t('show more'),
'$showfewer' => t('show fewer'),
'$update_interval' => $interval,
'$shortcut_icon' => $shortcut_icon,
'$touch_icon' => $touch_icon,
'$stylesheet' => $stylesheet,
'$infinite_scroll' => $invinite_scroll,
)) . $this->page['htmlhead'];
}
function init_page_end() {
if (!isset($this->page['end'])) {
$this->page['end'] = '';
}
$tpl = get_markup_template('end.tpl');
$this->page['end'] = replace_macros($tpl,array(
'$baseurl' => $this->get_baseurl() // FIXME for z_path!!!!
)) . $this->page['end'];
}
function set_curl_code($code) {
$this->curl_code = $code;
}
function get_curl_code() {
return $this->curl_code;
}
function set_curl_content_type($content_type) {
$this->curl_content_type = $content_type;
}
function get_curl_content_type() {
return $this->curl_content_type;
}
function set_curl_headers($headers) {
$this->curl_headers = $headers;
}
function get_curl_headers() {
return $this->curl_headers;
}
function get_cached_avatar_image($avatar_image){
return $avatar_image;
}
/**
* @brief Removes the baseurl from an url. This avoids some mixed content problems.
*
* @param string $orig_url
*
* @return string The cleaned url
*/
function remove_baseurl($orig_url){
// Is the function called statically?
if (!(isset($this) && get_class($this) == __CLASS__)) {
return self::$a->remove_baseurl($orig_url);
}
// Remove the hostname from the url if it is an internal link
$nurl = normalise_link($orig_url);
$base = normalise_link($this->get_baseurl());
$url = str_replace($base."/", "", $nurl);
// if it is an external link return the orignal value
if ($url == normalise_link($orig_url)) {
return $orig_url;
} else {
return $url;
}
}
/**
* @brief Register template engine class
*
* If $name is "", is used class static property $class::$name
*
* @param string $class
* @param string $name
*/
function register_template_engine($class, $name = '') {
/// @TODO Really === and not just == ?
if ($name === "") {
$v = get_class_vars( $class );
if (x($v,"name")) $name = $v['name'];
}
if ($name === "") {
echo "template engine <tt>$class</tt> cannot be registered without a name.\n";
killme();
}
$this->template_engines[$name] = $class;
}
/**
* @brief Return template engine instance.
*
* If $name is not defined, return engine defined by theme,
* or default
*
* @param strin $name Template engine name
* @return object Template Engine instance
*/
function template_engine($name = '') {
/// @TODO really type-check included?
if ($name !== "") {
$template_engine = $name;
} else {
$template_engine = 'smarty3';
if (x($this->theme, 'template_engine')) {
$template_engine = $this->theme['template_engine'];
}
}
if (isset($this->template_engines[$template_engine])){
if (isset($this->template_engine_instance[$template_engine])){
return $this->template_engine_instance[$template_engine];
} else {
$class = $this->template_engines[$template_engine];
$obj = new $class;
$this->template_engine_instance[$template_engine] = $obj;
return $obj;
}
}
echo "template engine <tt>$template_engine</tt> is not registered!\n"; killme();
}
/**
* @brief Returns the active template engine.
*
* @return string
*/
function get_template_engine() {
return $this->theme['template_engine'];
}
function set_template_engine($engine = 'smarty3') {
$this->theme['template_engine'] = $engine;
}
function get_template_ldelim($engine = 'smarty3') {
return $this->ldelim[$engine];
}
function get_template_rdelim($engine = 'smarty3') {
return $this->rdelim[$engine];
}
function save_timestamp($stamp, $value) {
if (!isset($this->config['system']['profiler']) || !$this->config['system']['profiler']) {
return;
}
$duration = (float)(microtime(true)-$stamp);
if (!isset($this->performance[$value])) {
// Prevent ugly E_NOTICE
$this->performance[$value] = 0;
}
$this->performance[$value] += (float)$duration;
$this->performance["marktime"] += (float)$duration;
$callstack = $this->callstack();
if (!isset($this->callstack[$value][$callstack])) {
// Prevent ugly E_NOTICE
$this->callstack[$value][$callstack] = 0;
}
$this->callstack[$value][$callstack] += (float)$duration;
}
/**
* @brief Log active processes into the "process" table
*/
function start_process() {
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
$command = basename($trace[0]["file"]);
$this->remove_inactive_processes();
q("START TRANSACTION");
$r = q("SELECT `pid` FROM `process` WHERE `pid` = %d", intval(getmypid()));
if (!dbm::is_result($r)) {
q("INSERT INTO `process` (`pid`,`command`,`created`) VALUES (%d, '%s', '%s')",
intval(getmypid()),
dbesc($command),
dbesc(datetime_convert()));
}
q("COMMIT");
}
/**
* @brief Remove inactive processes
*/
function remove_inactive_processes() {
q("START TRANSACTION");
$r = q("SELECT `pid` FROM `process`");
if (dbm::is_result($r)) {
foreach ($r AS $process) {
if (!posix_kill($process["pid"], 0)) {
q("DELETE FROM `process` WHERE `pid` = %d", intval($process["pid"]));
}
}
}
q("COMMIT");
}
/**
* @brief Remove the active process from the "process" table
*/
function end_process() {
q("DELETE FROM `process` WHERE `pid` = %d", intval(getmypid()));
}
/**
* @brief Returns a string with a callstack. Can be used for logging.
*
* @return string
*/
function callstack() {
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 6);
// We remove the first two items from the list since they contain data that we don't need.
array_shift($trace);
array_shift($trace);
$callstack = array();
foreach ($trace AS $func) {
$callstack[] = $func["function"];
}
return implode(", ", $callstack);
}
function get_useragent() {
return
FRIENDICA_PLATFORM . " '" .
FRIENDICA_CODENAME . "' " .
FRIENDICA_VERSION . "-" .
DB_UPDATE_VERSION . "; " .
$this->get_baseurl();
}
function is_friendica_app() {
return $this->is_friendica_app;
}
/**
* @brief Checks if the site is called via a backend process
*
* This isn't a perfect solution. But we need this check very early.
* So we cannot wait until the modules are loaded.
*
* @return bool Is it a known backend?
*/
function is_backend() {
static $backends = array();
$backends[] = "_well_known";
$backends[] = "api";
$backends[] = "dfrn_notify";
$backends[] = "fetch";
$backends[] = "hcard";
$backends[] = "hostxrd";
$backends[] = "nodeinfo";
$backends[] = "noscrape";
$backends[] = "p";
$backends[] = "poco";
$backends[] = "post";
$backends[] = "proxy";
$backends[] = "pubsub";
$backends[] = "pubsubhubbub";
$backends[] = "receive";
$backends[] = "rsd_xml";
$backends[] = "salmon";
$backends[] = "statistics_json";
$backends[] = "xrd";
// Check if current module is in backend or backend flag is set
return (in_array($this->module, $backends) || $this->backend);
}
/**
* @brief Checks if the maximum number of database processes is reached
*
* @return bool Is the limit reached?
*/
function max_processes_reached() {
if ($this->is_backend()) {
$process = "backend";
$max_processes = get_config('system', 'max_processes_backend');
if (intval($max_processes) == 0) {
$max_processes = 5;
}
} else {
$process = "frontend";
$max_processes = get_config('system', 'max_processes_frontend');
if (intval($max_processes) == 0) {
$max_processes = 20;
}
}
$processlist = dbm::processlist();
if ($processlist["list"] != "") {
logger("Processcheck: Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
if ($processlist["amount"] > $max_processes) {
logger("Processcheck: Maximum number of processes for ".$process." tasks (".$max_processes.") reached.", LOGGER_DEBUG);
return true;
}
}
return false;
}
/**
* @brief Checks if the minimal memory is reached
*
* @return bool Is the memory limit reached?
*/
public function min_memory_reached() {
$min_memory = Config::get('system', 'min_memory', 0);
if ($min_memory == 0) {
return false;
}
if (!is_readable("/proc/meminfo")) {
return false;
}
$memdata = explode("\n", file_get_contents('/proc/meminfo'));
$meminfo = array();
foreach ($memdata as $line) {
list($key, $val) = explode(":", $line);
$meminfo[$key] = (int)trim(str_replace("kB", "", $val));
$meminfo[$key] = (int)($meminfo[$key] / 1024);
}
if (!isset($meminfo['MemAvailable']) OR !isset($meminfo['MemFree'])) {
return false;
}
$free = $meminfo['MemAvailable'] + $meminfo['MemFree'];
$reached = ($free < $min_memory);
if ($reached) {
logger('Minimal memory reached: '.$free.'/'.$meminfo['MemTotal'].' - limit '.$min_memory, LOGGER_DEBUG);
}
return $reached;
}
/**
* @brief Checks if the maximum load is reached
*
* @return bool Is the load reached?
*/
function maxload_reached() {
if ($this->is_backend()) {
$process = "backend";
$maxsysload = intval(get_config('system', 'maxloadavg'));
if ($maxsysload < 1) {
$maxsysload = 50;
}
} else {
$process = "frontend";
$maxsysload = intval(get_config('system','maxloadavg_frontend'));
if ($maxsysload < 1) {
$maxsysload = 50;
}
}
$load = current_load();
if ($load) {
if (intval($load) > $maxsysload) {
logger('system: load '.$load.' for '.$process.' tasks ('.$maxsysload.') too high.');
return true;
}
}
return false;
}
function proc_run($args) {
if (!function_exists("proc_open")) {
return;
}
// 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.
$cachekey = "app:proc_run:started";
$result = Cache::get($cachekey);
if (!is_null($result) AND (time() - $result) < 10) {
return;
}
// Set the timestamp of the last proc_run
Cache::set($cachekey, time(), CACHE_MINUTE);
array_unshift($args, ((x($this->config,'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php'));
// add baseurl to args. cli scripts can't construct it
$args[] = $this->get_baseurl();
for ($x = 0; $x < count($args); $x ++) {
$args[$x] = escapeshellarg($args[$x]);
}
$cmdline = implode($args, " ");
if ($this->min_memory_reached()) {
return;
}
if (get_config('system', 'proc_windows')) {
$resource = proc_open('cmd /c start /b ' . $cmdline, array(), $foo, dirname(__FILE__));
} else {
$resource = proc_open($cmdline . " &", array(), $foo, dirname(__FILE__));
}
if (!is_resource($resource)) {
logger('We got no resource for command '.$cmdline, LOGGER_DEBUG);
return;
}
proc_close($resource);
}
/**
* @brief Returns the system user that is executing the script
*
* This mostly returns something like "www-data".
*
* @return string system username
*/
static function systemuser() {
if (!function_exists('posix_getpwuid') OR !function_exists('posix_geteuid')) {
return '';
}
$processUser = posix_getpwuid(posix_geteuid());
return $processUser['name'];
}
/**
* @brief Checks if a given directory is usable for the system
*
* @return boolean the directory is usable
*/
static function directory_usable($directory) {
if ($directory == '') {
logger("Directory is empty. This shouldn't happen.", LOGGER_DEBUG);
return false;
}
if (!file_exists($directory)) {
logger('Path "'.$directory.'" does not exist for user '.self::systemuser(), LOGGER_DEBUG);
return false;
}
if (is_file($directory)) {
logger('Path "'.$directory.'" is a file for user '.self::systemuser(), LOGGER_DEBUG);
return false;
}
if (!is_dir($directory)) {
logger('Path "'.$directory.'" is not a directory for user '.self::systemuser(), LOGGER_DEBUG);
return false;
}
if (!is_writable($directory)) {
logger('Path "'.$directory.'" is not writable for user '.self::systemuser(), LOGGER_DEBUG);
return false;
}
return true;
}
}
/**
@ -1494,7 +499,6 @@ function get_app() {
return $a;
}
/**
* @brief Multi-purpose function to check variable state.
*
@ -1509,7 +513,7 @@ function get_app() {
*
* @return bool|int
*/
function x($s,$k = NULL) {
function x($s, $k = NULL) {
if ($k != NULL) {
if ((is_array($s)) && (array_key_exists($k, $s))) {
if ($s[$k]) {
@ -1529,7 +533,6 @@ function x($s,$k = NULL) {
}
}
/**
* @brief Called from db initialisation if db is dead.
*/
@ -1539,7 +542,6 @@ function system_unavailable() {
killme();
}
function clean_urls() {
$a = get_app();
return true;
@ -1548,7 +550,7 @@ function clean_urls() {
function z_path() {
$base = App::get_baseurl();
if (! clean_urls()) {
if (!clean_urls()) {
$base .= '/?q=';
}
@ -1575,7 +577,7 @@ function z_root() {
* @return string
*/
function absurl($path) {
if (strpos($path,'/') === 0) {
if (strpos($path, '/') === 0) {
return z_path() . $path;
}
return $path;
@ -1592,25 +594,23 @@ function is_ajax() {
function check_db() {
$build = get_config('system','build');
if (! x($build)) {
set_config('system','build',DB_UPDATE_VERSION);
$build = get_config('system', 'build');
if (!x($build)) {
set_config('system', 'build', DB_UPDATE_VERSION);
$build = DB_UPDATE_VERSION;
}
if ($build != DB_UPDATE_VERSION) {
proc_run(PRIORITY_CRITICAL, 'include/dbupdate.php');
}
}
/**
* Sets the base url for use in cmdline programs which don't have
* $_SERVER variables
*/
function check_url(App $a) {
$url = get_config('system','url');
$url = get_config('system', 'url');
// if the url isn't set or the stored url is radically different
// than the currently visited url, store the current value accordingly.
@ -1618,24 +618,23 @@ function check_url(App $a) {
// and www.example.com vs example.com.
// We will only change the url to an ip address if there is no existing setting
if (! x($url)) {
$url = set_config('system','url',App::get_baseurl());
if (!x($url)) {
$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());
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(App $a) {
$build = get_config('system','build');
if (! x($build)) {
$build = set_config('system','build',DB_UPDATE_VERSION);
$build = get_config('system', 'build');
if (!x($build)) {
$build = set_config('system', 'build', DB_UPDATE_VERSION);
}
if ($build != DB_UPDATE_VERSION) {
@ -1646,7 +645,6 @@ function update_db(App $a) {
// We're reporting a different version than what is currently installed.
// Run any existing update scripts to bring the database up to current.
// make sure that boot.php and update.php are the same release, we might be
// updating right this very second and the correct version of the update.php
// file may not be here yet. This can happen on a very busy site.
@ -1654,12 +652,12 @@ function update_db(App $a) {
if (DB_UPDATE_VERSION == UPDATE_VERSION) {
// Compare the current structure with the defined structure
$t = get_config('database','dbupdate_'.DB_UPDATE_VERSION);
$t = get_config('database', 'dbupdate_' . DB_UPDATE_VERSION);
if ($t !== false) {
return;
}
set_config('database','dbupdate_'.DB_UPDATE_VERSION, time());
set_config('database', 'dbupdate_' . DB_UPDATE_VERSION, time());
// run old update routine (wich could modify the schema and
// conflits with new routine)
@ -1683,7 +681,7 @@ function update_db(App $a) {
);
return;
} else {
set_config('database','dbupdate_'.DB_UPDATE_VERSION, 'success');
set_config('database', 'dbupdate_' . DB_UPDATE_VERSION, 'success');
}
// run any left update_nnnn functions in update.php
@ -1707,15 +705,14 @@ function run_update_function($x) {
// We want exactly one process to run the update command.
// So store the fact that we're taking responsibility
// after first checking to see if somebody else already has.
// If the update fails or times-out completely you may need to
// delete the config entry to try again.
$t = get_config('database','update_' . $x);
$t = get_config('database', 'update_' . $x);
if ($t !== false) {
return false;
}
set_config('database','update_' . $x, time());
set_config('database', 'update_' . $x, time());
// call the specific update
@ -1730,13 +727,13 @@ function run_update_function($x) {
);
return false;
} else {
set_config('database','update_' . $x, 'success');
set_config('system','build', $x + 1);
set_config('database', 'update_' . $x, 'success');
set_config('system', 'build', $x + 1);
return true;
}
} else {
set_config('database','update_' . $x, 'success');
set_config('system','build', $x + 1);
set_config('database', 'update_' . $x, 'success');
set_config('system', 'build', $x + 1);
return true;
}
return true;
@ -1765,11 +762,11 @@ function check_plugins(App $a) {
$installed = array();
}
$plugins = get_config('system','addon');
$plugins = get_config('system', 'addon');
$plugins_arr = array();
if ($plugins) {
$plugins_arr = explode(',',str_replace(' ', '',$plugins));
$plugins_arr = explode(',', str_replace(' ', '', $plugins));
}
$a->plugins = $plugins_arr;
@ -1778,7 +775,7 @@ function check_plugins(App $a) {
if (count($installed)) {
foreach ($installed as $i) {
if (! in_array($i['name'],$plugins_arr)) {
if (!in_array($i['name'], $plugins_arr)) {
uninstall_plugin($i['name']);
} else {
$installed_arr[] = $i['name'];
@ -1788,20 +785,18 @@ function check_plugins(App $a) {
if (count($plugins_arr)) {
foreach ($plugins_arr as $p) {
if (! in_array($p,$installed_arr)) {
if (!in_array($p, $installed_arr)) {
install_plugin($p);
}
}
}
load_hooks();
return;
}
function get_guid($size=16, $prefix = "") {
function get_guid($size = 16, $prefix = "") {
if ($prefix == "") {
$a = get_app();
$prefix = hash("crc32", $a->get_hostname());
@ -1834,7 +829,7 @@ function get_guid($size=16, $prefix = "") {
* @hooks 'login_hook'
* string $o
*/
function login($register = false, $hiddens=false) {
function login($register = false, $hiddens = false) {
$a = get_app();
$o = "";
$reg = false;
@ -1845,14 +840,14 @@ function login($register = false, $hiddens=false) {
);
}
$noid = get_config('system','no_openid');
$noid = get_config('system', 'no_openid');
$dest_url = $a->query_string;
if (local_user()) {
$tpl = get_markup_template("logout.tpl");
} else {
$a->page['htmlhead'] .= replace_macros(get_markup_template("login_head.tpl"),array(
$a->page['htmlhead'] .= replace_macros(get_markup_template("login_head.tpl"), array(
'$baseurl' => $a->get_baseurl(true)
));
@ -1886,10 +881,9 @@ function login($register = false, $hiddens=false) {
'$privacytitle' => t('Website Privacy Policy'),
'$privacylink' => t('privacy policy'),
));
call_hooks('login_hook',$o);
call_hooks('login_hook', $o);
return $o;
}
@ -1898,7 +892,6 @@ function login($register = false, $hiddens=false) {
* @brief Used to end the current process, after saving session state.
*/
function killme() {
if (!get_app()->is_backend()) {
session_write_close();
}
@ -1911,14 +904,13 @@ function killme() {
*/
function goaway($s) {
if (!strstr(normalise_link($s), "http://")) {
$s = App::get_baseurl()."/".$s;
$s = App::get_baseurl() . "/" . $s;
}
header("Location: $s");
killme();
}
/**
* @brief Returns the user id of locally logged in user or false.
*
@ -1960,7 +952,7 @@ function public_contact() {
* @return int|bool visitor_id or false
*/
function remote_user() {
if ((x($_SESSION,'authenticated')) && (x($_SESSION,'visitor_id'))) {
if ((x($_SESSION, 'authenticated')) && (x($_SESSION, 'visitor_id'))) {
return intval($_SESSION['visitor_id']);
}
return false;
@ -1975,7 +967,7 @@ function remote_user() {
*/
function notice($s) {
$a = get_app();
if (! x($_SESSION,'sysmsg')) {
if (!x($_SESSION, 'sysmsg')) {
$_SESSION['sysmsg'] = array();
}
if ($a->interactive) {
@ -1993,11 +985,11 @@ function notice($s) {
function info($s) {
$a = get_app();
if (local_user() AND get_pconfig(local_user(),'system','ignore_info')) {
if (local_user() AND get_pconfig(local_user(), 'system', 'ignore_info')) {
return;
}
if (! x($_SESSION,'sysmsg_info')) {
if (!x($_SESSION, 'sysmsg_info')) {
$_SESSION['sysmsg_info'] = array();
}
if ($a->interactive) {
@ -2005,7 +997,6 @@ function info($s) {
}
}
/**
* @brief Wrapper around config to limit the text length of an incoming message
*
@ -2013,12 +1004,12 @@ function info($s) {
*/
function get_max_import_size() {
$a = get_app();
return ((x($a->config,'max_import_size')) ? $a->config['max_import_size'] : 0 );
return ((x($a->config, 'max_import_size')) ? $a->config['max_import_size'] : 0 );
}
/**
* @brief Wrap calls to proc_close(proc_open()) and call hook
* so plugins can take part in process :)
* so plugins can take part in process :)
*
* @param (integer|array) priority or parameter array, $cmd atrings are deprecated and are ignored
*
@ -2029,9 +1020,9 @@ function get_max_import_size() {
* @note $cmd and string args are surrounded with ""
*
* @hooks 'proc_run'
* array $arr
* array $arr
*/
function proc_run($cmd){
function proc_run($cmd) {
$a = get_app();
@ -2064,7 +1055,7 @@ function proc_run($cmd){
$arr = array('args' => $args, 'run_cmd' => true);
call_hooks("proc_run", $arr);
if (!$arr['run_cmd'] OR !count($args)) {
if (!$arr['run_cmd'] OR ! count($args)) {
return;
}
@ -2086,8 +1077,7 @@ function proc_run($cmd){
array_shift($argv);
$parameters = json_encode($argv);
$found = q("SELECT `id` FROM `workerqueue` WHERE `parameter` = '%s'",
dbesc($parameters));
$found = q("SELECT `id` FROM `workerqueue` WHERE `parameter` = '%s'", dbesc($parameters));
if (!dbm::is_result($found)) {
q("INSERT INTO `workerqueue` (`parameter`, `created`, `priority`)
@ -2123,7 +1113,7 @@ function proc_run($cmd){
$a->proc_run($args);
}
function current_theme(){
function current_theme() {
$app_base_themes = array('duepuntozero', 'dispy', 'quattro');
$a = get_app();
@ -2145,7 +1135,7 @@ function current_theme(){
// This works only if the user is on the same server
if ($page_theme && local_user() && (local_user() != $a->profile_uid)) {
if (get_pconfig(local_user(),'system','always_my_theme')) {
if (get_pconfig(local_user(), 'system', 'always_my_theme')) {
$page_theme = null;
}
}
@ -2155,7 +1145,7 @@ function current_theme(){
$is_mobile = $a->is_mobile || $a->is_tablet;
$standard_system_theme = Config::get('system', 'theme', '');
$standard_theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $standard_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']) {
@ -2166,7 +1156,7 @@ function current_theme(){
if ($system_theme == '') {
$system_theme = $standard_system_theme;
}
$theme_name = ((isset($_SESSION) && x($_SESSION,'mobile-theme')) ? $_SESSION['mobile-theme'] : $system_theme);
$theme_name = ((isset($_SESSION) && x($_SESSION, 'mobile-theme')) ? $_SESSION['mobile-theme'] : $system_theme);
if ($theme_name === '---') {
// user has selected to have the mobile theme be the same as the normal one
@ -2188,21 +1178,21 @@ function current_theme(){
}
if ($theme_name &&
(file_exists('view/theme/' . $theme_name . '/style.css') ||
file_exists('view/theme/' . $theme_name . '/style.php'))) {
(file_exists('view/theme/' . $theme_name . '/style.css') ||
file_exists('view/theme/' . $theme_name . '/style.php'))) {
return($theme_name);
}
foreach ($app_base_themes as $t) {
if (file_exists('view/theme/' . $t . '/style.css') ||
file_exists('view/theme/' . $t . '/style.php')) {
file_exists('view/theme/' . $t . '/style.php')) {
return($t);
}
}
$fallback = array_merge(glob('view/theme/*/style.css'),glob('view/theme/*/style.php'));
$fallback = array_merge(glob('view/theme/*/style.css'), glob('view/theme/*/style.php'));
if (count($fallback)) {
return (str_replace('view/theme/','', substr($fallback[0],0,-10)));
return (str_replace('view/theme/', '', substr($fallback[0], 0, -10)));
}
/// @TODO No final return statement?
@ -2222,13 +1212,13 @@ function current_theme_url() {
$opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : '');
if (file_exists('view/theme/' . $t . '/style.php')) {
return('view/theme/'.$t.'/style.pcss'.$opts);
return('view/theme/' . $t . '/style.pcss' . $opts);
}
return('view/theme/'.$t.'/style.css');
return('view/theme/' . $t . '/style.css');
}
function feed_birthday($uid,$tz) {
function feed_birthday($uid, $tz) {
/**
*
@ -2248,11 +1238,9 @@ function feed_birthday($uid,$tz) {
* 6:00PM the day before, but that will correspond to midnight to the birthday person.
*
*/
$birthday = '';
if (! strlen($tz)) {
if (!strlen($tz)) {
$tz = 'UTC';
}
@ -2261,16 +1249,16 @@ function feed_birthday($uid,$tz) {
);
if (dbm::is_result($p)) {
$tmp_dob = substr($p[0]['dob'],5);
$tmp_dob = substr($p[0]['dob'], 5);
if (intval($tmp_dob)) {
$y = datetime_convert($tz,$tz,'now','Y');
$y = datetime_convert($tz, $tz, 'now', 'Y');
$bd = $y . '-' . $tmp_dob . ' 00:00';
$t_dob = strtotime($bd);
$now = strtotime(datetime_convert($tz,$tz,'now'));
$now = strtotime(datetime_convert($tz, $tz, 'now'));
if ($t_dob < $now) {
$bd = $y + 1 . '-' . $tmp_dob . ' 00:00';
}
$birthday = datetime_convert($tz,'UTC',$bd,ATOM_TIME);
$birthday = datetime_convert($tz, 'UTC', $bd, ATOM_TIME);
}
}
@ -2288,7 +1276,7 @@ function is_site_admin() {
$adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
//if(local_user() && x($a->user,'email') && x($a->config,'admin_email') && ($a->user['email'] === $a->config['admin_email']))
if (local_user() && x($a->user,'email') && x($a->config,'admin_email') && in_array($a->user['email'], $adminlist)) {
if (local_user() && x($a->user, 'email') && x($a->config, 'admin_email') && in_array($a->user['email'], $adminlist)) {
return true;
}
return false;
@ -2310,7 +1298,7 @@ function build_querystring($params, $name = null) {
if ($name == null) {
$ret .= build_querystring($val, $key);
} else {
$ret .= build_querystring($val, $name."[$key]");
$ret .= build_querystring($val, $name . "[$key]");
}
} else {
$val = urlencode($val);
@ -2358,10 +1346,10 @@ function explode_querystring($query) {
}
/**
* Returns the complete URL of the current page, e.g.: http(s)://something.com/network
*
* Taken from http://webcheatsheet.com/php/get_current_page_url.php
*/
* Returns the complete URL of the current page, e.g.: http(s)://something.com/network
*
* Taken from http://webcheatsheet.com/php/get_current_page_url.php
*/
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {
@ -2371,9 +1359,9 @@ function curPageURL() {
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
$pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
}
return $pageURL;
}
@ -2382,7 +1370,7 @@ function random_digits($digits) {
$rn = '';
for ($i = 0; $i < $digits; $i++) {
/// @TODO rand() is different to mt_rand() and maybe lesser "random"
$rn .= rand(0,9);
$rn .= rand(0, 9);
}
return $rn;
}
@ -2400,7 +1388,7 @@ function get_server() {
function get_cachefile($file, $writemode = true) {
$cache = get_itemcachepath();
if ((! $cache) || (! is_dir($cache))) {
if ((!$cache) || (!is_dir($cache))) {
return("");
}
@ -2433,15 +1421,15 @@ function clear_cache($basepath = "", $path = "") {
return;
}
$cachetime = (int)get_config('system','itemcache_duration');
$cachetime = (int) get_config('system', 'itemcache_duration');
if ($cachetime == 0) {
$cachetime = 86400;
}
if (is_writable($path)){
if (is_writable($path)) {
if ($dh = opendir($path)) {
while (($file = readdir($dh)) !== false) {
$fullpath = $path."/".$file;
$fullpath = $path . "/" . $file;
if ((filetype($fullpath) == "dir") and ($file != ".") and ($file != "..")) {
clear_cache($basepath, $fullpath);
}
@ -2456,12 +1444,12 @@ function clear_cache($basepath = "", $path = "") {
function get_itemcachepath() {
// Checking, if the cache is deactivated
$cachetime = (int)get_config('system','itemcache_duration');
$cachetime = (int) get_config('system', 'itemcache_duration');
if ($cachetime < 0) {
return "";
}
$itemcache = get_config('system','itemcache');
$itemcache = get_config('system', 'itemcache');
if (($itemcache != "") AND App::directory_usable($itemcache)) {
return $itemcache;
}
@ -2469,7 +1457,7 @@ function get_itemcachepath() {
$temppath = get_temppath();
if ($temppath != "") {
$itemcache = $temppath."/itemcache";
$itemcache = $temppath . "/itemcache";
if (!file_exists($itemcache) && !is_dir($itemcache)) {
mkdir($itemcache);
}
@ -2488,7 +1476,7 @@ function get_itemcachepath() {
* @return string Spool path
*/
function get_spoolpath() {
$spoolpath = get_config('system','spoolpath');
$spoolpath = get_config('system', 'spoolpath');
if (($spoolpath != "") AND App::directory_usable($spoolpath)) {
// We have a spool path and it is usable
return $spoolpath;
@ -2499,7 +1487,7 @@ function get_spoolpath() {
if ($temppath != "") {
// To avoid any interferences with other systems we create our own directory
$spoolpath = $temppath."/spool";
$spoolpath = $temppath . "/spool";
if (!is_dir($spoolpath)) {
mkdir($spoolpath);
}
@ -2535,7 +1523,7 @@ function get_temppath() {
// Check if it is usable
if (($temppath != "") AND App::directory_usable($temppath)) {
// To avoid any interferences with other systems we create our own directory
$new_temppath = $temppath."/".$a->get_hostname();
$new_temppath = $temppath . "/" . $a->get_hostname();
if (!is_dir($new_temppath)) {
/// @TODO There is a mkdir()+chmod() upwards, maybe generalize this (+ configurable) into a function/method?
mkdir($new_temppath);
@ -2581,7 +1569,7 @@ function validate_include(&$file) {
return false;
}
$file = str_replace(getcwd()."/", "", $file, $count);
$file = str_replace(getcwd() . "/", "", $file, $count);
if ($count != 1) {
return false;
}
@ -2633,7 +1621,7 @@ function argc() {
* @return string Value of the argv key
*/
function argv($x) {
if (array_key_exists($x,get_app()->argv)) {
if (array_key_exists($x, get_app()->argv)) {
return get_app()->argv[$x];
}
@ -2650,12 +1638,12 @@ function argv($x) {
*
* @param string $module The name of the module (e.g. "network")
* @return array Of infinite scroll data
* 'pageno' => $pageno The number of the actual page
* 'reload_uri' => $reload_uri The URI of the content we have to load
* 'pageno' => $pageno The number of the actual page
* 'reload_uri' => $reload_uri The URI of the content we have to load
*/
function infinite_scroll_data($module) {
if (get_pconfig(local_user(),'system','infinite_scroll')
if (get_pconfig(local_user(), 'system', 'infinite_scroll')
AND ($module == "network") AND ($_GET["mode"] != "minimal")) {
// get the page number
@ -2674,7 +1662,7 @@ function infinite_scroll_data($module) {
}
}
if (($a->page_offset != "") AND !strstr($reload_uri, "&offset=")) {
if (($a->page_offset != "") AND ! strstr($reload_uri, "&offset=")) {
$reload_uri .= "&offset=" . urlencode($a->page_offset);
}

6
composer.lock generated
View file

@ -226,10 +226,10 @@
},
{
"name": "pear-pear.php.net/PEAR",
"version": "1.10.3",
"version": "1.10.4",
"dist": {
"type": "file",
"url": "https://pear.php.net/get/PEAR-1.10.3.tgz",
"url": "https://pear.php.net/get/PEAR-1.10.4.tgz",
"reference": null,
"shasum": null
},
@ -247,7 +247,7 @@
"pear-pear.php.net/pear_frontend_web": "<=0.4.0.0"
},
"replace": {
"pear-pear/pear": "== 1.10.3.0"
"pear-pear/pear": "== 1.10.4.0"
},
"type": "pear-library",
"autoload": {

View file

@ -113,3 +113,8 @@ For Composer, this would be:
````
$> COMPOSER_HOME=/var/tmp/composer sudo -u [web user] util/composer.phar [mode]
````
## Related
* [Class autoloading](help/autoloader)
* [How To Move Classes to `src`](help/Developer-How-To-Move-Classes-to-src)

View file

@ -0,0 +1,108 @@
How To Move Classes to `src`
==============
* [Home](help)
* [Developer Intro](help/Developers-Intro)
Friendica uses [Composer](help/Composer) to manage autoloading.
This means that all the PHP class files moved to the `src` folder will be [automatically included](help/autoloader) when the class it defines is first used in the flow.
This is an improvement over the current `require` usage since files will be included on an actual usage basis instead of the presence of a `require` call.
However, there are a significant number of items to check when moving a class file from the `include` folder to the `src` folder, and this page is there to list them.
## Decide the namespace
This isn't the most technical decision of them all, but it has long lasting consequences as it will be the name that will be used to refer to this class from now on.
There is [a shared Ethercalc sheet](https://ethercalc.org/friendica_classes) to suggest namespace/class names that lists all the already moved class files for inspiration.
A few pointers though:
* `Friendica` is the base namespace for all classes in the `src` folder
* Namespaces match the directory structure, with `Friendica` namespace being the base `src` directory. The `Config` class set in the `Friendica\Core` namespace is expected to be found at `src/Core/Config.php`.
* Namespaces can help group classes with a similar purpose or relevant to a particular feature
When you're done deciding the namespace, it's time to use it.
Let's say we choose `Friendica\Core` for the `Config` class.
## Use the namespace
To declare the namespace, the file `src/Core/Config.php` must start with the following statement:
````php
namespace Friendica\Core;
````
From now on, the `Config` class can be referred to as `Friendica\Core\Config`, however it isn't very practical, especially when the class was previously used as `Config`.
Thankfully, PHP provides namespace shortcuts through `use`.
This language construct just provides a different naming scheme for a namespace or a class, but doesn't trigger the autoload mechanism on its own.
Here are the different ways you can use `use`:
````php
// No use
$config = new Friendica\Core\Config();
````
````php
// Namespace shortcut
use Friendica\Core;
$config = new Core\Config();
````
````php
// Class name shortcut
use Friendica\Core\Config;
$config = new Config();
````
````php
// Aliasing
use Friendica\Core\Config as Cfg;
$config = new Cfg();
````
Whatever the style chosen, a repository-wide search has to be done to find all the class name usage and either use the fully-qualified class name (including the namespace) or add a `use` statement at the start of each relevant file.
## Escape non-namespace classes
The class file you just moved is now in the `Friendica` namespace, but it probably isn't the case for all the classes referenced in this file.
Since we added a `namespace Friendica\Core;` to the file, all the class names still declared in `include` will be implicitly understood as `Friendica\Core\ClassName`, which is rarely what we expect.
To avoid `Class Friendica\Core\ClassName not found` errors, all the `include`-declared class names have to be prepended with a `\`, it tells the autoloader not to look for the class in the namespace but in the global space where non-namespaced classes are set.
If there are only a handful of references to a single non-namespaced class, just prepending `\` is enough. However, if there are many instance, we can use `use` again.
````php
namespace Friendica\Core;
...
if (\dbm::is_result($r)) {
...
}
````
````php
namespace Friendica\Core;
use \dbm;
if (dbm::is_result($r)) {
...
}
````
## Remove any useless `require`
Now that you successfully moved your class to the autoloaded `src` folder, there's no need to include this file anywhere in the app ever again.
Please remove all the `require_once` mentions of the former file, as they will provoke a Fatal Error even if the class isn't used.
## Miscellaneous tips
When you are done with moving the class, please run `php util/typo.php` from the Friendica base directory to check for obvious mistakes.
Howevever, this tool isn't bullet-proof, and a staging install of Friendica is recommended to test your class move without impairing your production server if you host one.
Most of Friendica processes are run in the background, so make sure to turn on your debug log to check for errors that wouldn't show up while simply browsing Friendica.
Check the class file for any magic constant `__FILE__` or `__DIR__`, as their value changed since you moved the class in the file tree.
Most of the time it's used for debugging purposes but there can be instances where it's used to create cache folders for example.
## Related
* [Class autoloading](help/autoloader)
* [Using Composer](help/Composer)

View file

@ -52,7 +52,9 @@ Friendica uses [Composer](https://getcomposer.org) to manage dependencies librar
It's a command-line tool that downloads required libraries into the `vendor` folder and makes any namespaced class in `src` available through the whole application through `boot.php`.
* [Class autoloading](help/autoloader)
* [Using Composer](help/Composer)
* [How To Move Classes to `src`](help/Developer-How-To-Move-Classes-to-src)
###Coding standards

View file

@ -36,21 +36,25 @@ Friendica Documentation and Resources
**Developer Manual**
* [Where to get started?](help/Developers-Intro)
* [Help on Github](help/Github)
* [Help on Vagrant](help/Vagrant)
* [How to translate Friendica](help/translations)
* [Bugs and Issues](help/Bugs-and-Issues)
* [Plugin Development](help/Plugins)
* [Theme Development](help/themes)
* [Smarty 3 Templates](help/smarty3-templates)
* [Protocol Documentation](help/Protocol)
* [Database schema documantation](help/database)
* [Class Autoloading](help/autoloader)
* [Using Composer](help/Composer)
* [Code - Reference(Doxygen generated - sets cookies)](doc/html/)
* [Twitter/GNU Social API Functions](help/api)
* [Get started](help/Developers-Intro)
* Set up development environment
* [Help on Github](help/Github)
* [Help on Vagrant](help/Vagrant)
* [Bugs and Issues](help/Bugs-and-Issues)
* Code structure
* [Plugin Development](help/Plugins)
* [Theme Development](help/themes)
* [Smarty 3 Templates](help/smarty3-templates)
* How To
* [Translate Friendica](help/translations)
* [Use Composer](help/Composer)
* [Move classes to `src`](help/Developer-How-To-Move-Classes-to-src)
* Reference
* [Twitter/GNU Social API Functions](help/api)
* [Code (Doxygen generated - sets cookies)](doc/html/)
* [Protocol Documentation](help/Protocol)
* [Database schema documantation](help/database)
* [Class Autoloading](help/autoloader)
**External Resources**

View file

@ -24,14 +24,14 @@ For more info about PHP autoloading, please refer to the [official PHP documenta
Let's say you have a PHP file in `src/` that define a very useful class:
```php
// src/ItemsManager.php
<?php
namespace \Friendica;
// src/ItemsManager.php
<?php
namespace Friendica;
class ItemsManager {
public function getAll() { ... }
public function getByID($id) { ... }
}
class ItemsManager {
public function getAll() { ... }
public function getByID($id) { ... }
}
```
The class `ItemsManager` has been declared in the `Friendica` namespace.
@ -43,16 +43,16 @@ In order for the Composer autoloader to work, it must first be included. In Frie
The code will be something like:
```php
// mod/network.php
<?php
// mod/network.php
<?php
function network_content(App $a) {
$itemsmanager = new \Friendica\ItemsManager();
$items = $itemsmanager->getAll();
function network_content(App $a) {
$itemsmanager = new Friendica\ItemsManager();
$items = $itemsmanager->getAll();
// pass $items to template
// return result
}
// pass $items to template
// return result
}
```
That's a quite simple example, but look: no `require()`!
@ -61,132 +61,137 @@ If you need to use a class, you can simply use it and you don't need to do anyth
Going further: now we have a bunch of `*Manager` classes that cause some code duplication, let's define a `BaseManager` class, where we move all common code between all managers:
```php
// src/BaseManager.php
<?php
namespace \Friendica;
// src/BaseManager.php
<?php
namespace Friendica;
class BaseManager {
public function thatFunctionEveryManagerUses() { ... }
}
class BaseManager {
public function thatFunctionEveryManagerUses() { ... }
}
```
and then let's change the ItemsManager class to use this code
```php
// src/ItemsManager.php
<?php
namespace \Friendica;
// src/ItemsManager.php
<?php
namespace Friendica;
class ItemsManager extends BaseManager {
public function getAll() { ... }
public function getByID($id) { ... }
}
class ItemsManager extends BaseManager {
public function getAll() { ... }
public function getByID($id) { ... }
}
```
Even though we didn't explicitly include the `src/BaseManager.php` file, the autoloader will when this class is first defined, because it is referenced as a parent class.
It works with the "BaseManager" example here and it works when we need to call static methods:
```php
// src/Dfrn.php
<?php
namespace \Friendica;
// src/Dfrn.php
<?php
namespace Friendica;
class Dfrn {
public static function mail($item, $owner) { ... }
}
class Dfrn {
public static function mail($item, $owner) { ... }
}
```
```php
// mod/mail.php
<?php
// mod/mail.php
<?php
mail_post($a){
...
\Friendica\dfrn::mail($item, $owner);
...
}
mail_post($a){
...
Friendica\dfrn::mail($item, $owner);
...
}
```
If your code is in same namespace as the class you need, you don't need to prepend it:
```php
// include/delivery.php
<?php
// include/delivery.php
<?php
namespace \Friendica;
namespace Friendica;
// this is the same content of current include/delivery.php,
// but has been declared to be in "Friendica" namespace
// this is the same content of current include/delivery.php,
// but has been declared to be in "Friendica" namespace
[...]
switch($contact['network']) {
case NETWORK_DFRN:
if ($mail) {
$item['body'] = ...
$atom = Dfrn::mail($item, $owner);
} elseif ($fsuggest) {
$atom = Dfrn::fsuggest($item, $owner);
q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));
} elseif ($relocate)
$atom = Dfrn::relocate($owner, $uid);
[...]
[...]
switch($contact['network']) {
case NETWORK_DFRN:
if ($mail) {
$item['body'] = ...
$atom = Dfrn::mail($item, $owner);
} elseif ($fsuggest) {
$atom = Dfrn::fsuggest($item, $owner);
q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));
} elseif ($relocate)
$atom = Dfrn::relocate($owner, $uid);
[...]
```
This is the current code of `include/delivery.php`, and since the code is declared to be in the "Friendica" namespace, you don't need to write it when you need to use the "Dfrn" class.
But if you want to use classes from another library, you need to use the full namespace, e.g.
```php
// src/Diaspora.php
<?php
// src/Diaspora.php
<?php
namespace \Friendica;
namespace Friendica;
class Diaspora {
public function md2bbcode() {
$html = \Michelf\MarkdownExtra::defaultTransform($text);
}
class Diaspora {
public function md2bbcode() {
$html = \Michelf\MarkdownExtra::defaultTransform($text);
}
}
```
if you use that class in many places of the code and you don't want to write the full path to the class every time, you can use the "use" PHP keyword
```php
// src/Diaspora.php
<?php
namespace \Friendica;
// src/Diaspora.php
<?php
namespace Friendica;
use \Michelf\MarkdownExtra;
use \Michelf\MarkdownExtra;
class Diaspora {
public function md2bbcode() {
$html = MarkdownExtra::defaultTransform($text);
}
class Diaspora {
public function md2bbcode() {
$html = MarkdownExtra::defaultTransform($text);
}
}
```
Note that namespaces are like paths in filesystem, separated by "\", with the first "\" being the global scope.
You can go deeper if you want to, like:
```
// src/Network/Dfrn.php
<?php
namespace \Friendica\Network;
// src/Network/Dfrn.php
<?php
namespace Friendica\Network;
class Dfrn {
}
class Dfrn {
}
```
Please note that the location of the file defining the class must be placed in the appropriate sub-folders of `src` if the namespace isn't plain `\Friendica`.
Please note that the location of the file defining the class must be placed in the appropriate sub-folders of `src` if the namespace isn't plain `Friendica`.
or
```
// src/Dba/Mysql
<?php
namespace \Friendica\Dba;
// src/Dba/Mysql
<?php
namespace Friendica\Dba;
class Mysql {
}
class Mysql {
}
```
So you can think of namespaces as folders in a Unix file system, with global scope as the root ("\").
## Related
* [Using Composer](help/Composer)
* [How To Move Classes to `src`](help/Developer-How-To-Move-Classes-to-src)

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
// Included here for completeness, but this is a very dangerous operation.
// It is the caller's responsibility to confirm the requestor's intent and
// authorisation to do this.
@ -852,4 +854,3 @@ function account_type($contact) {
return $account_type;
}
?>

View file

@ -81,4 +81,3 @@ class Emailer {
return $res;
}
}
?>

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
/**
* @file include/ForumManager.php
* @brief ForumManager class with its methods related to forum functionality *

View file

@ -24,7 +24,7 @@ class NotificationsManager {
*
* @param array $notes array of note arrays from db
* @return array Copy of input array with added properties
*
*
* Set some extra properties to note array from db:
* - timestamp as int in default TZ
* - date_rel : relative date string
@ -143,8 +143,7 @@ class NotificationsManager {
/**
* @brief List of pages for the Notifications TabBar
*
* @param app $a The
*
* @return array with with notifications TabBar data
*/
public function getTabs() {
@ -191,7 +190,7 @@ class NotificationsManager {
/**
* @brief Format the notification query in an usable array
*
*
* @param array $notifs The array from the db query
* @param string $ident The notifications identifier (e.g. network)
* @return array
@ -360,7 +359,7 @@ class NotificationsManager {
}
/**
* @brief Total number of network notifications
* @brief Total number of network notifications
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
@ -388,13 +387,13 @@ class NotificationsManager {
/**
* @brief Get network notifications
*
*
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
* @param int $start Start the query at this point
* @param int $limit Maximum number of query results
*
*
* @return array with
* string 'ident' => Notification identifier
* int 'total' => Total number of available network notifications
@ -436,7 +435,7 @@ class NotificationsManager {
}
/**
* @brief Total number of system notifications
* @brief Total number of system notifications
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
@ -460,13 +459,13 @@ class NotificationsManager {
/**
* @brief Get system notifications
*
*
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
* @param int $start Start the query at this point
* @param int $limit Maximum number of query results
*
*
* @return array with
* string 'ident' => Notification identifier
* int 'total' => Total number of available system notifications
@ -502,7 +501,7 @@ class NotificationsManager {
/**
* @brief Addional SQL query string for the personal notifications
*
*
* @return string The additional sql query
*/
private function _personal_sql_extra() {
@ -520,7 +519,7 @@ class NotificationsManager {
}
/**
* @brief Total number of personal notifications
* @brief Total number of personal notifications
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
@ -550,13 +549,13 @@ class NotificationsManager {
/**
* @brief Get personal notifications
*
*
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
* @param int $start Start the query at this point
* @param int $limit Maximum number of query results
*
*
* @return array with
* string 'ident' => Notification identifier
* int 'total' => Total number of available personal notifications
@ -573,13 +572,13 @@ class NotificationsManager {
$sql_seen = " AND `item`.`unseen` = 1 ";
$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, `item`.`unseen`,
`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` AS `object`,
`pitem`.`author-name` AS `pname`, `pitem`.`author-link` AS `plink`, `pitem`.`guid` AS `pguid`
`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` AS `object`,
`pitem`.`author-name` AS `pname`, `pitem`.`author-link` AS `plink`, `pitem`.`guid` AS `pguid`
FROM `item` INNER JOIN `item` AS `pitem` ON `pitem`.`id`=`item`.`parent`
WHERE `item`.`visible` = 1
$sql_extra
$sql_seen
AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0
AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0
ORDER BY `item`.`created` DESC LIMIT %d, %d " ,
intval(local_user()),
intval($start),
@ -588,7 +587,7 @@ class NotificationsManager {
if (dbm::is_result($r))
$notifs = $this->formatNotifs($r, $ident);
$arr = array (
'notifications' => $notifs,
'ident' => $ident,
@ -599,7 +598,7 @@ class NotificationsManager {
}
/**
* @brief Total number of home notifications
* @brief Total number of home notifications
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
@ -626,13 +625,13 @@ class NotificationsManager {
/**
* @brief Get home notifications
*
*
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
* @param int $start Start the query at this point
* @param int $limit Maximum number of query results
*
*
* @return array with
* string 'ident' => Notification identifier
* int 'total' => Total number of available home notifications
@ -673,7 +672,7 @@ class NotificationsManager {
}
/**
* @brief Total number of introductions
* @brief Total number of introductions
* @param bool $all
* If false only include introductions into the query
* which aren't marked as ignored
@ -698,13 +697,13 @@ class NotificationsManager {
/**
* @brief Get introductions
*
*
* @param bool $all
* If false only include introductions into the query
* which aren't marked as ignored
* @param int $start Start the query at this point
* @param int $limit Maximum number of query results
*
*
* @return array with
* string 'ident' => Notification identifier
* int 'total' => Total number of available introductions
@ -749,7 +748,7 @@ class NotificationsManager {
/**
* @brief Format the notification query in an usable array
*
*
* @param array $intros The array from the db query
* @return array with the introductions
*/

View file

@ -4,6 +4,8 @@
* @brief This file contains the Photo class for image processing
*/
use Friendica\App;
require_once("include/photos.php");
class Photo {

View file

@ -5,8 +5,9 @@
*
*/
use \Friendica\Core\Config;
use \Friendica\Core\PConfig;
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
require_once("include/feed.php");
require_once('include/email.php');
@ -1261,4 +1262,3 @@ class Probe {
}
}
?>

View file

@ -5,6 +5,8 @@
* @brief This file contains the Smilies class which contains functions to handle smiles
*/
use Friendica\App;
/**
* This class contains functions to handle smiles
*/
@ -13,13 +15,13 @@ class Smilies {
/**
* @brief Function to list all smilies
*
*
* Get an array of all smilies, both internal and from addons.
*
*
* @return array
* 'texts' => smilie shortcut
* 'icons' => icon in html
*
*
* @hook smilie ('texts' => smilies texts array, 'icons' => smilies html array)
*/
public static function get_list() {
@ -64,41 +66,41 @@ class Smilies {
);
$icons = array(
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-heart.gif" alt="&lt;3" title="&lt;3" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-brokenheart.gif" alt="&lt;/3" title="&lt;/3" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-brokenheart.gif" alt="&lt;\\3" title="&lt;\\3" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-smile.gif" alt=":-)" title=":-)" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-wink.gif" alt=";-)" title=";-)" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-frown.gif" alt=":-(" title=":-(" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-P" title=":-P" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-p" title=":-P" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-kiss.gif" alt=":-\" title=":-\" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-kiss.gif" alt=":-\" title=":-\" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-kiss.gif" alt=":-x" title=":-x" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-kiss.gif" alt=":-X" title=":-X" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-laughing.gif" alt=":-D" title=":-D" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-surprised.gif" alt="8-|" title="8-|" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-surprised.gif" alt="8-O" title="8-O" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-surprised.gif" alt=":-O" title="8-O" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-thumbsup.gif" alt="\\o/" title="\\o/" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-Oo.gif" alt="o.O" title="o.O" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-Oo.gif" alt="O.o" title="O.o" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-Oo.gif" alt="o_O" title="o_O" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-Oo.gif" alt="O_o" title="O_o" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-cry.gif" alt=":\'(" title=":\'("/>',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-foot-in-mouth.gif" alt=":-!" title=":-!" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-undecided.gif" alt=":-/" title=":-/" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-embarassed.gif" alt=":-[" title=":-[" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-cool.gif" alt="8-)" title="8-)" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/beer_mug.gif" alt=":beer" title=":beer" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/beer_mug.gif" alt=":homebrew" title=":homebrew" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/coffee.gif" alt=":coffee" title=":coffee" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-facepalm.gif" alt=":facepalm" title=":facepalm" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/like.gif" alt=":like" title=":like" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/dislike.gif" alt=":dislike" title=":dislike" />',
'<a href="http://friendica.com">~friendica <img class="smiley" src="' . app::get_baseurl() . '/images/friendica-16.png" alt="~friendica" title="~friendica" /></a>',
'<a href="http://redmatrix.me/">red<img class="smiley" src="' . app::get_baseurl() . '/images/rm-16.png" alt="red#" title="red#" />matrix</a>',
'<a href="http://redmatrix.me/">red<img class="smiley" src="' . app::get_baseurl() . '/images/rm-16.png" alt="red#matrix" title="red#matrix" />matrix</a>'
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-heart.gif" alt="&lt;3" title="&lt;3" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-brokenheart.gif" alt="&lt;/3" title="&lt;/3" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-brokenheart.gif" alt="&lt;\\3" title="&lt;\\3" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-smile.gif" alt=":-)" title=":-)" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-wink.gif" alt=";-)" title=";-)" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-frown.gif" alt=":-(" title=":-(" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-P" title=":-P" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-p" title=":-P" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-kiss.gif" alt=":-\" title=":-\" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-kiss.gif" alt=":-\" title=":-\" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-kiss.gif" alt=":-x" title=":-x" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-kiss.gif" alt=":-X" title=":-X" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-laughing.gif" alt=":-D" title=":-D" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-surprised.gif" alt="8-|" title="8-|" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-surprised.gif" alt="8-O" title="8-O" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-surprised.gif" alt=":-O" title="8-O" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-thumbsup.gif" alt="\\o/" title="\\o/" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-Oo.gif" alt="o.O" title="o.O" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-Oo.gif" alt="O.o" title="O.o" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-Oo.gif" alt="o_O" title="o_O" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-Oo.gif" alt="O_o" title="O_o" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-cry.gif" alt=":\'(" title=":\'("/>',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-foot-in-mouth.gif" alt=":-!" title=":-!" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-undecided.gif" alt=":-/" title=":-/" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-embarassed.gif" alt=":-[" title=":-[" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-cool.gif" alt="8-)" title="8-)" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/beer_mug.gif" alt=":beer" title=":beer" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/beer_mug.gif" alt=":homebrew" title=":homebrew" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/coffee.gif" alt=":coffee" title=":coffee" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-facepalm.gif" alt=":facepalm" title=":facepalm" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/like.gif" alt=":like" title=":like" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/dislike.gif" alt=":dislike" title=":dislike" />',
'<a href="http://friendica.com">~friendica <img class="smiley" src="' . App::get_baseurl() . '/images/friendica-16.png" alt="~friendica" title="~friendica" /></a>',
'<a href="http://redmatrix.me/">red<img class="smiley" src="' . App::get_baseurl() . '/images/rm-16.png" alt="red#" title="red#" />matrix</a>',
'<a href="http://redmatrix.me/">red<img class="smiley" src="' . App::get_baseurl() . '/images/rm-16.png" alt="red#matrix" title="red#matrix" />matrix</a>'
);
$params = array('texts' => $texts, 'icons' => $icons);
@ -121,7 +123,7 @@ class Smilies {
*
* @param string $s
* @param boolean $sample
*
*
* @return string HML Output of the Smilie
*/
public static function replace($s, $sample = false) {
@ -166,7 +168,7 @@ class Smilies {
*
* @param string $x
* @return string HTML Output
*
*
* @todo: Rework because it doesn't work correctly
*/
private function preg_heart($x) {
@ -174,7 +176,7 @@ class Smilies {
return $x[0];
$t = '';
for($cnt = 0; $cnt < strlen($x[1]); $cnt ++)
$t .= '<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-heart.gif" alt="&lt;3" />';
$t .= '<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-heart.gif" alt="&lt;3" />';
$r = str_replace($x[0],$t,$x[0]);
return $r;
}

View file

@ -4,6 +4,8 @@
* @file include/acl_selectors.php
*/
use Friendica\App;
require_once "include/contact_selectors.php";
require_once "include/contact_widgets.php";
require_once "include/DirSearch.php";

View file

@ -6,7 +6,8 @@
* @todo Automatically detect if incoming data is HTML or BBCode
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once 'include/HTTPExceptions.php';
require_once 'include/bbcode.php';

View file

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('include/security.php');
require_once('include/datetime.php');

View file

@ -32,6 +32,8 @@
*
*/
use Friendica\App;
if (sizeof($_SERVER["argv"]) == 0)
die();
@ -47,8 +49,9 @@ require_once("boot.php");
global $a, $db;
if (is_null($a))
$a = new App;
if (is_null($a)) {
$a = new App(dirname(__DIR__));
}
if (is_null($db)) {
@include(".htconfig.php");
@ -332,4 +335,3 @@ class exAuth {
fclose($this->rLogFile);
}
}
?>

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
use League\HTMLToMarkdown\HtmlConverter;
require_once "include/oembed.php";

View file

@ -1,5 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once 'include/oembed.php';
require_once 'include/event.php';

View file

@ -5,8 +5,8 @@
* @brief Class for storing data for a short time
*/
use \Friendica\Core\Config;
use \Friendica\Core\PConfig;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
class Cache {
/**
@ -121,9 +121,9 @@ class Cache {
/**
* @brief Put data in the cache according to the key
*
*
* The input $value can have multiple formats.
*
*
* @param string $key The key to the cached data
* @param mixed $valie The value that is about to be stored
* @param integer $duration The cache lifespan

View file

@ -1,6 +1,7 @@
<?php /** @file */
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('boot.php');
@ -11,7 +12,7 @@ function cli_startup() {
global $a, $db;
if (is_null($a)) {
$a = new App;
$a = new App(dirname(__DIR__));
}
if (is_null($db)) {

View file

@ -1,7 +1,7 @@
<?php
/**
* @file include/config.php
*
*
* @brief (Deprecated) Arbitrary configuration storage
* Note:
* Please do not store booleans - convert to 0/1 integer values
@ -12,8 +12,8 @@
* configurations need to be fixed as of 10/08/2011.
*/
use \Friendica\Core\Config;
use \Friendica\Core\PConfig;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
/**
* @brief (Deprecated) Loads all configuration values of family into a cached storage.

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function follow_widget($value = "") {
return replace_macros(get_markup_template('follow.tpl'), array(

View file

@ -1,9 +1,10 @@
<?php
use Friendica\App;
require_once "include/bbcode.php";
require_once "include/acl_selectors.php";
/*
* Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
* is identical to the code in mod/message.php for 'item_extract_images' and

View file

@ -17,4 +17,3 @@ function create_shadowentry_run($argv, $argc) {
add_shadow_entry($message_id);
}
?>

View file

@ -1,5 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
function cron_run(&$argv, &$argc){
global $a;

View file

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
function cronhooks_run(&$argv, &$argc) {
global $a;

View file

@ -1,5 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
function cronjobs_run(&$argv, &$argc){
global $a;

View file

@ -4,7 +4,7 @@
* @brief Some functions for date and time related tasks.
*/
use \Friendica\Core\Config;
use Friendica\Core\Config;
/**
* @brief Two-level sort for timezones.
@ -34,7 +34,7 @@ function timezone_cmp($a, $b) {
/**
* @brief Emit a timezone selector grouped (primarily) by continent
*
*
* @param string $current Timezone
* @return string Parsed HTML output
*/
@ -81,17 +81,17 @@ function select_timezone($current = 'America/Los_Angeles') {
/**
* @brief Generating a Timezone selector
*
*
* Return a select using 'field_select_raw' template, with timezones
* groupped (primarily) by continent
* arguments follow convetion as other field_* template array:
* 'name', 'label', $value, 'help'
*
*
* @param string $name Name of the selector
* @param string $label Label for the selector
* @param string $current Timezone
* @param string $help Help text
*
*
* @return string Parsed HTML
*/
function field_timezone($name='timezone', $label='', $current = 'America/Los_Angeles', $help){
@ -114,7 +114,7 @@ function field_timezone($name='timezone', $label='', $current = 'America/Los_Ang
* @param string $s Some parseable date/time string
* @param string $fmt Output format recognised from php's DateTime class
* http://www.php.net/manual/en/datetime.format.php
*
*
* @return string Formatted date according to given format
*/
function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d H:i:s") {
@ -212,7 +212,7 @@ function dob($dob) {
/**
* @brief Returns a date selector
*
*
* @param string $format
* Format string, e.g. 'ymd' or 'mdy'. Not currently supported
* @param string $min
@ -223,7 +223,7 @@ function dob($dob) {
* Unix timestamp of default date
* @param string $id
* ID and name of datetimepicker (defaults to "datetimepicker")
*
*
* @return string Parsed HTML output.
*/
function datesel($format, $min, $max, $default, $id = 'datepicker') {
@ -232,7 +232,7 @@ function datesel($format, $min, $max, $default, $id = 'datepicker') {
/**
* @brief Returns a time selector
*
*
* @param string $format
* Format string, e.g. 'ymd' or 'mdy'. Not currently supported
* @param $h
@ -241,7 +241,7 @@ function datesel($format, $min, $max, $default, $id = 'datepicker') {
* Already selected minute
* @param string $id
* ID and name of datetimepicker (defaults to "timepicker")
*
*
* @return string Parsed HTML output.
*/
function timesel($format, $h, $m, $id = 'timepicker') {
@ -270,7 +270,7 @@ function timesel($format, $h, $m, $id = 'timepicker') {
* @param $maxfrom
* set maximum date from picker with id $maxfrom (none by default)
* @param bool $required default false
*
*
* @return string Parsed HTML output.
*
* @todo Once browser support is better this could probably be replaced with
@ -417,7 +417,7 @@ function relative_date($posted_date, $format = null) {
* @param string $dob Date of Birth
* @param string $owner_tz (optional) Timezone of the person of interest
* @param string $viewer_tz (optional) Timezone of the person viewing
*
*
* @return int Age in years
*/
function age($dob, $owner_tz = '', $viewer_tz = '') {
@ -452,7 +452,7 @@ function age($dob, $owner_tz = '', $viewer_tz = '') {
*
* @param int $y Year
* @param int $m Month (1=January, 12=December)
*
*
* @return int Number of days in the given month
*/
function get_dim($y, $m) {
@ -477,7 +477,7 @@ function get_dim($y, $m) {
*
* @param int $y Year
* @param int $m Month (1=January, 12=December)
*
*
* @return string day 0 = Sunday through 6 = Saturday
*/
function get_first_dim($y,$m) {
@ -498,7 +498,7 @@ function get_first_dim($y,$m) {
* @param int $m Month
* @param bool $links (default false)
* @param string $class
*
*
* @return string
*
* @todo Provide (prev,next) links, define class variations for different size calendars

View file

@ -4,7 +4,7 @@
* @brief The script is called from time to time to clean the database entries and remove orphaned data.
*/
use \Friendica\Core\Config;
use Friendica\Core\Config;
function dbclean_run(&$argv, &$argc) {
if (!Config::get('system', 'dbclean', false)) {
@ -149,4 +149,3 @@ function remove_orphans($stage = 0) {
}
}
?>

View file

@ -110,4 +110,3 @@ class dbm {
return date('Y-m-d H:i:s', $timestamp);
}
}
?>

View file

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once("boot.php");
require_once("include/text.php");
@ -1745,7 +1746,7 @@ function dbstructure_run(&$argv, &$argc) {
global $a, $db;
if (is_null($a)) {
$a = new App;
$a = new App(dirname(__DIR__));
}
if (is_null($db)) {

View file

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
function dbupdate_run(&$argv, &$argc) {
global $a;

View file

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('include/queue_fn.php');
require_once('include/html2plain.php');

View file

@ -7,6 +7,8 @@
* https://github.com/friendica/friendica/blob/master/spec/dfrn2.pdf
*/
use Friendica\App;
require_once("include/Contact.php");
require_once("include/ostatus.php");
require_once("include/enotify.php");
@ -370,7 +372,7 @@ class dfrn {
$ext = Photo::supportedTypes();
foreach ($rp as $p) {
$photos[$p['scale']] = app::get_baseurl().'/photo/'.$p['resource-id'].'-'.$p['scale'].'.'.$ext[$p['type']];
$photos[$p['scale']] = App::get_baseurl().'/photo/'.$p['resource-id'].'-'.$p['scale'].'.'.$ext[$p['type']];
}
unset($rp, $ext);
@ -431,7 +433,7 @@ class dfrn {
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
xml::add_element($doc, $root, "id", app::get_baseurl()."/profile/".$owner["nick"]);
xml::add_element($doc, $root, "id", App::get_baseurl()."/profile/".$owner["nick"]);
xml::add_element($doc, $root, "title", $owner["name"]);
$attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION);
@ -448,13 +450,13 @@ class dfrn {
// DFRN itself doesn't uses this. But maybe someone else wants to subscribe to the public feed.
ostatus::hublinks($doc, $root);
$attributes = array("rel" => "salmon", "href" => app::get_baseurl()."/salmon/".$owner["nick"]);
$attributes = array("rel" => "salmon", "href" => App::get_baseurl()."/salmon/".$owner["nick"]);
xml::add_element($doc, $root, "link", "", $attributes);
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-replies", "href" => app::get_baseurl()."/salmon/".$owner["nick"]);
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-replies", "href" => App::get_baseurl()."/salmon/".$owner["nick"]);
xml::add_element($doc, $root, "link", "", $attributes);
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-mention", "href" => app::get_baseurl()."/salmon/".$owner["nick"]);
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-mention", "href" => App::get_baseurl()."/salmon/".$owner["nick"]);
xml::add_element($doc, $root, "link", "", $attributes);
}
@ -511,7 +513,7 @@ class dfrn {
}
xml::add_element($doc, $author, "name", $owner["name"], $attributes);
xml::add_element($doc, $author, "uri", app::get_baseurl().'/profile/'.$owner["nickname"], $attributes);
xml::add_element($doc, $author, "uri", App::get_baseurl().'/profile/'.$owner["nickname"], $attributes);
xml::add_element($doc, $author, "dfrn:handle", $owner["addr"], $attributes);
$attributes = array("rel" => "photo", "type" => "image/jpeg",
@ -812,7 +814,7 @@ class dfrn {
$parent = q("SELECT `guid` FROM `item` WHERE `id` = %d", intval($item["parent"]));
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
$attributes = array("ref" => $parent_item, "type" => "text/html",
"href" => app::get_baseurl().'/display/'.$parent[0]['guid'],
"href" => App::get_baseurl().'/display/'.$parent[0]['guid'],
"dfrn:diaspora_guid" => $parent[0]['guid']);
xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes);
}
@ -854,7 +856,7 @@ class dfrn {
// We save this value in "plink". Maybe we should read it from there as well?
xml::add_element($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html",
"href" => app::get_baseurl()."/display/".$item["guid"]));
"href" => App::get_baseurl()."/display/".$item["guid"]));
// "comment-allow" is some old fashioned stuff for old Friendica versions.
// It is included in the rewritten code for completeness

View file

@ -8,7 +8,8 @@
* This will change in the future.
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once 'include/items.php';
require_once 'include/bb2diaspora.php';
@ -3819,4 +3820,3 @@ class Diaspora {
return true;
}
}
?>

View file

@ -1,9 +1,9 @@
<?php
/// @TODO no longer used?
use \Friendica\Core\Config;
use Friendica\Core\Config;
function directory_run(&$argv, &$argc){
$dir = get_config('system', 'directory');
$dir = Config::get('system', 'directory');
if (!strlen($dir)) {
return;

View file

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
require_once('include/socgraph.php');
require_once('include/datetime.php');

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
require_once('include/Emailer.php');
require_once('include/email.php');
require_once('include/bbcode.php');

View file

@ -4,6 +4,8 @@
* @brief functions specific to event handling
*/
use Friendica\App;
require_once 'include/bbcode.php';
require_once 'include/map.php';
require_once 'include/datetime.php';
@ -535,7 +537,7 @@ function get_event_strings() {
*
* @param array $dates Array of possibly duplicated events
* @return array Cleaned events
*
*
* @todo We should replace this with a separate update function if there is some time left
*/
function event_remove_duplicates($dates) {

View file

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
function expire_run(&$argv, &$argc){
global $a;

View file

@ -366,4 +366,3 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
return array("header" => $author, "items" => $items);
}
}
?>

View file

@ -47,4 +47,3 @@ function update_files_for_items() {
create_files_from_item($message["id"]);
}
}
?>

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
require_once("include/Scrape.php");
require_once("include/socgraph.php");
require_once('include/group.php');

View file

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
require_once('include/Scrape.php');
require_once('include/socgraph.php');

View file

@ -325,4 +325,3 @@ function html2bbcode($message)
return $message;
}
?>

View file

@ -233,4 +233,3 @@ function html2plain($html, $wraplength = 75, $compact = false)
return(trim($message));
}
?>

View file

@ -3,6 +3,8 @@
* @file include/identity.php
*/
use Friendica\App;
require_once('include/ForumManager.php');
require_once('include/bbcode.php');
require_once("mod/proxy.php");

View file

@ -4,7 +4,8 @@
* @file include/items.php
*/
use \Friendica\ParseUrl;
use Friendica\App;
use Friendica\ParseUrl;
require_once 'include/bbcode.php';
require_once 'include/oembed.php';
@ -339,7 +340,7 @@ function add_page_info_to_body($body, $texturl = false, $no_photos = false) {
* Adds a "lang" specification in a "postopts" element of given $arr,
* if possible and not already present.
* Expects "body" element to exist in $arr.
*
*
* @todo Add a parameter to request forcing override
*/
function item_add_language_opt(&$arr) {

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
require_once("include/diaspora.php");
/**

View file

@ -1,9 +1,8 @@
<?php
// send a private message
// send a private message
use Friendica\App;
function send_message($recipient=0, $body='', $subject='', $replyto=''){

View file

@ -187,7 +187,7 @@ function removelinebreak($message)
(substr(trim($nextline), 0, 7) == 'http://') or
(substr(trim($nextline), 0, 8) == 'https://'));
if (!$specialchars)
if (!$specialchars)
$specialchars = ((substr(rtrim($line), -1) == '-') or
(substr(rtrim($line), -1) == '=') or
(substr(rtrim($line), -1) == '*') or
@ -222,4 +222,3 @@ function removelinebreak($message)
return(implode("\n", $lines));
}
?>

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function nav(App $a) {
/*

View file

@ -4,7 +4,8 @@
* @file include/network.php
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once("include/xml.php");
require_once('include/Probe.php');

View file

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('include/queue_fn.php');
require_once('include/html2plain.php');

View file

@ -5,6 +5,8 @@
*
*/
use Friendica\App;
define('REQUEST_TOKEN_DURATION', 300);
define('ACCESS_TOKEN_DURATION', 31536000);
@ -61,13 +63,13 @@ class FKOAuthDataStore extends OAuthDataStore {
logger(__function__.":".$consumer.", ". $callback);
$key = $this->gen_token();
$sec = $this->gen_token();
if ($consumer->key){
$k = $consumer->key;
} else {
$k = $consumer;
}
$r = q("INSERT INTO tokens (id, secret, client_id, scope, expires) VALUES ('%s','%s','%s','%s', UNIX_TIMESTAMP()+%d)",
dbesc($key),
dbesc($sec),
@ -80,19 +82,19 @@ class FKOAuthDataStore extends OAuthDataStore {
function new_access_token($token, $consumer, $verifier = null) {
logger(__function__.":".$token.", ". $consumer.", ". $verifier);
// return a new access token attached to this consumer
// for the user associated with this token if the request token
// is authorized
// should also invalidate the request token
$ret=Null;
// get user for this verifier
$uverifier = get_config("oauth", $verifier);
logger(__function__.":".$verifier.",".$uverifier);
if (is_null($verifier) || ($uverifier!==false)){
$key = $this->gen_token();
$sec = $this->gen_token();
$r = q("INSERT INTO tokens (id, secret, client_id, scope, expires, uid) VALUES ('%s','%s','%s','%s', UNIX_TIMESTAMP()+%d, %d)",
@ -103,13 +105,13 @@ class FKOAuthDataStore extends OAuthDataStore {
intval(ACCESS_TOKEN_DURATION),
intval($uverifier));
if ($r)
$ret = new OAuthToken($key,$sec);
$ret = new OAuthToken($key,$sec);
}
q("DELETE FROM tokens WHERE id='%s'", $token->key);
if (!is_null($ret) && $uverifier!==false){
del_config("oauth", $verifier);
/* $apps = get_pconfig($uverifier, "oauth", "apps");
@ -117,9 +119,9 @@ class FKOAuthDataStore extends OAuthDataStore {
$apps[] = $consumer->key;
set_pconfig($uverifier, "oauth", "apps", $apps);*/
}
return $ret;
}
}
@ -172,9 +174,9 @@ class FKOAuth1 extends OAuthServer {
intval($_SESSION['uid'])
);
call_hooks('logged_in', $a->user);
call_hooks('logged_in', $a->user);
}
}
/*
class FKOAuth2 extends OAuth2 {
@ -190,13 +192,13 @@ class FKOAuth2 extends OAuth2 {
dbesc($client_secret),
dbesc($redirect_uri)
);
return $r;
}
protected function checkClientCredentials($client_id, $client_secret = NULL) {
$client_secret = $this->db_secret($client_secret);
$r = q("SELECT pw FROM clients WHERE client_id = '%s'",
dbesc($client_id));
@ -218,21 +220,21 @@ class FKOAuth2 extends OAuth2 {
protected function getAccessToken($oauth_token) {
$r = q("SELECT client_id, expires, scope FROM tokens WHERE id = '%s'",
dbesc($oauth_token));
if (dbm::is_result($r))
return $r[0];
return null;
}
protected function setAccessToken($oauth_token, $client_id, $expires, $scope = NULL) {
$r = q("INSERT INTO tokens (id, client_id, expires, scope) VALUES ('%s', '%s', %d, '%s')",
dbesc($oauth_token),
dbesc($client_id),
intval($expires),
dbesc($scope));
return $r;
}
@ -246,23 +248,23 @@ class FKOAuth2 extends OAuth2 {
protected function getAuthCode($code) {
$r = q("SELECT id, client_id, redirect_uri, expires, scope FROM auth_codes WHERE id = '%s'",
dbesc($code));
if (dbm::is_result($r))
return $r[0];
return null;
}
protected function setAuthCode($code, $client_id, $redirect_uri, $expires, $scope = NULL) {
$r = q("INSERT INTO auth_codes
(id, client_id, redirect_uri, expires, scope) VALUES
$r = q("INSERT INTO auth_codes
(id, client_id, redirect_uri, expires, scope) VALUES
('%s', '%s', '%s', %d, '%s')",
dbesc($code),
dbesc($client_id),
dbesc($redirect_uri),
intval($expires),
dbesc($scope));
return $r;
}
return $r;
}
}
*/

View file

@ -4,8 +4,9 @@
* @file include/oembed.php
*/
use \Friendica\ParseUrl;
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\ParseUrl;
use Friendica\Core\Config;
function oembed_replacecb($matches){
$embedurl=$matches[1];

View file

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
require_once('include/follow.php');

View file

@ -3,7 +3,8 @@
* @file include/ostatus.php
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once("include/Contact.php");
require_once("include/threads.php");
@ -2192,7 +2193,7 @@ class ostatus {
/**
* @brief Creates the XML feed for a given nickname
*
* @param app $a The application class
* @param App $a The application class
* @param string $owner_nick Nickname of the feed owner
* @param string $last_update Date of the last update
*
@ -2288,4 +2289,3 @@ class ostatus {
return(trim($doc->saveXML()));
}
}
?>

View file

@ -10,7 +10,7 @@
*
*/
use \Friendica\Core\Config;
use Friendica\Core\Config;
require_once("include/dba.php");

View file

@ -4,8 +4,8 @@
* @brief Functions related to photo handling.
*/
use \Friendica\Core\Config;
use \Friendica\Core\PConfig;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
function getGps($exifCoord, $hemi) {
$degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;

View file

@ -38,4 +38,3 @@ class pidfile {
return(posix_kill(file_get_contents($this->_file), SIGTERM));
}
}
?>

View file

@ -4,7 +4,8 @@
* @file include/plaintext.php
*/
use \Friendica\ParseUrl;
use Friendica\App;
use Friendica\ParseUrl;
require_once("include/Photo.php");
require_once("include/bbcode.php");
@ -431,4 +432,3 @@ function plaintext(App $a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2
return($post);
}
?>

View file

@ -1,10 +1,11 @@
<?php
/**
* @file include/plugin.php
*
*
* @brief Some functions to handle addons and themes.
*/
use Friendica\App;
/**
* @brief uninstalls an addon.
@ -164,7 +165,7 @@ function register_hook($hook,$file,$function,$priority=0) {
/**
* @brief unregisters a hook.
*
*
* @param string $hook the name of the hook
* @param string $file the name of the file that hooks into
* @param string $function the name of the function that the hook called
@ -325,7 +326,7 @@ function get_plugin_info($plugin){
/**
* @brief Parse theme comment in search of theme infos.
*
*
* like
* \code
* ..* Name: My Theme
@ -545,11 +546,11 @@ function upgrade_bool_message($bbcode = false) {
/**
* @brief Get the full path to relevant theme files by filename
*
*
* This function search in the theme directory (and if not present in global theme directory)
* if there is a directory with the file extension and for a file with the given
* filename.
*
* filename.
*
* @param string $file Filename
* @param string $root Full root path
* @return string Path to the file or empty string if the file isn't found

View file

@ -1,4 +1,8 @@
<?php
use Friendica\App;
use Friendica\Core\Config;
if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
$directory = dirname($_SERVER["argv"][0]);
@ -10,15 +14,13 @@ if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
chdir($directory);
}
use \Friendica\Core\Config;
require_once("boot.php");
function poller_run($argv, $argc){
global $a, $db;
if(is_null($a)) {
$a = new App;
if (is_null($a)) {
$a = new App(dirname(__DIR__));
}
if(is_null($db)) {
@ -89,7 +91,6 @@ function poller_run($argv, $argc){
if (time() > ($starttime + 3600))
return;
}
}
/**
@ -687,4 +688,3 @@ if (array_search(__file__,get_included_files())===0){
killme();
}
?>

View file

@ -258,5 +258,3 @@ function post_update_1206() {
logger("Done", LOGGER_DEBUG);
return true;
}
?>

View file

@ -1,5 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('include/items.php');
require_once('include/ostatus.php');

View file

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
require_once('include/queue_fn.php');
require_once('include/dfrn.php');

View file

@ -129,4 +129,3 @@ function removetofu($message)
return($message);
}
?>

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function auto_redir(App $a, $contact_nick) {
// prevent looping

View file

@ -4,7 +4,7 @@
* @brief Removes orphaned data from deleted contacts
*/
use \Friendica\Core\Config;
use Friendica\Core\Config;
function remove_contact_run($argv, $argc) {
if ($argc != 2) {
@ -22,4 +22,3 @@ function remove_contact_run($argv, $argc) {
// Now we delete all the depending table entries
dba::delete('contact', array('id' => $id));
}
?>

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
/**
* @brief Calculate the hash that is needed for the "Friendica" cookie
*

View file

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once("boot.php");
require_once("include/threads.php");
@ -9,7 +10,7 @@ function shadowupdate_run(&$argv, &$argc){
global $a, $db;
if (is_null($a)) {
$a = new App;
$a = new App(dirname(__DIR__));
}
if (is_null($db)) {

View file

@ -1,13 +1,14 @@
<?php
/**
* @file include/socgraph.php
*
*
* @todo Move GNU Social URL schemata (http://server.tld/user/number) to http://server.tld/username
* @todo Fetch profile data from profile page for Redmatrix users
* @todo Detect if it is a forum
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('include/datetime.php');
require_once("include/Scrape.php");
@ -1425,7 +1426,7 @@ function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = fal
$r = q("SELECT `gcontact`.*
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`zcid` = %d
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 )
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 )
$sql_extra limit %d, %d",
intval($zcid),
intval($uid),
@ -2340,4 +2341,3 @@ function poco_serverlist() {
}
return $r;
}
?>

View file

@ -4,7 +4,7 @@
* @brief Posts items that wer spooled because they couldn't be posted.
*/
use \Friendica\Core\Config;
use Friendica\Core\Config;
require_once("include/items.php");
@ -55,4 +55,3 @@ function spool_post_run($argv, $argc) {
}
}
}
?>

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
function create_tags_from_item($itemid) {
$profile_base = App::get_baseurl();
$profile_data = parse_url($profile_base);
@ -145,4 +148,3 @@ function update_items() {
dba::close($messages);
}
?>

View file

@ -1,12 +1,13 @@
<?php
use Friendica\App;
require_once("include/template_processor.php");
require_once("include/friendica_smarty.php");
require_once("include/Smilies.php");
require_once("include/map.php");
require_once("mod/proxy.php");
if(! function_exists('replace_macros')) {
/**
* This is our template processor

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
function add_thread($itemid, $onlyshadow = false) {
$items = q("SELECT `uid`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`,
`moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, `gcontact-id`,
@ -293,4 +296,3 @@ function update_shadow_copy() {
dba::close($messages);
}
?>

View file

@ -1,11 +1,7 @@
<?php
/**
* import account file exported from mod/uexport
* args:
* $a App Friendica App Class
* $file Array array from $_FILES
*/
use Friendica\App;
require_once("include/Photo.php");
define("IMPORT_DEBUG", False);
@ -75,6 +71,12 @@ function import_cleanup($newuid) {
q("DELETE FROM `pconfig` WHERE uid = %d", $newuid);
}
/**
* @brief Import account file exported from mod/uexport
*
* @param App $a Friendica App Class
* @param array $file array from $_FILES
*/
function import_account(App $a, $file) {
logger("Start user import from " . $file['tmp_name']);
/*
@ -255,10 +257,6 @@ function import_account(App $a, $file) {
}
}
foreach ($account['photo'] as &$photo) {
$photo['uid'] = $newuid;
$photo['data'] = hex2bin($photo['data']);

View file

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
function update_gcontact_run(&$argv, &$argc) {
global $a;

View file

@ -13,12 +13,13 @@
*
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('boot.php');
require_once('object/BaseObject.php');
require_once 'boot.php';
require_once 'object/BaseObject.php';
$a = new App;
$a = new App(__DIR__);
BaseObject::set_app($a);
// We assume that the index.php is called by a frontend process
@ -73,7 +74,7 @@ if (!$install) {
exit();
}
require_once("include/session.php");
require_once 'include/session.php';
load_hooks();
call_hooks('init_1');
@ -486,7 +487,7 @@ header("X-Friendica-Version: " . FRIENDICA_VERSION);
header("Content-type: text/html; charset=utf-8");
/*
* We use $_GET["mode"] for special page templates. So we will check if we have
* We use $_GET["mode"] for special page templates. So we will check if we have
* to load another page template than the default one.
* The page templates are located in /view/php/ or in the theme directory.
*/

View file

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once("mod/hostxrd.php");
require_once("mod/nodeinfo.php");

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/Scrape.php');
function acctlink_init(App $a) {

View file

@ -1,6 +1,8 @@
<?php
/* ACL selector json backend */
use Friendica\App;
require_once 'include/acl_selectors.php';
function acl_init(App $a) {

View file

@ -6,7 +6,8 @@
* @brief Friendica admin
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once("include/enotify.php");
require_once("include/text.php");

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/socgraph.php');
require_once('include/Contact.php');
require_once('include/contact_selectors.php');

View file

@ -1,8 +1,9 @@
<?php
use Friendica\App;
function amcd_content(App $a) {
//header("Content-type: text/json");
echo <<< EOT
echo <<< JSON
{
"version":1,
"sessionstatus":{
@ -44,6 +45,6 @@ echo <<< EOT
}
}
}
EOT;
killme();
JSON;
killme();
}

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/api.php');
function oauth_get_client($request){
@ -106,8 +108,6 @@ function api_content(App $a) {
'$no' => t('No'),
));
//echo "<pre>"; var_dump($app); killme();
return $o;
}

View file

@ -1,25 +1,25 @@
<?php
use Friendica\App;
function apps_content(App $a) {
$privateaddons = get_config('config','private_addons');
if ($privateaddons === "1") {
if((! (local_user()))) {
info( t("You must be logged in to use addons. "));
return;};
}
$privateaddons = get_config('config', 'private_addons');
if ($privateaddons === "1") {
if (! local_user()) {
info(t('You must be logged in to use addons. '));
return;
};
}
$title = t('Applications');
$title = t('Applications');
if(count($a->apps)==0)
notice( t('No installed applications.') . EOL);
if (count($a->apps) == 0) {
notice(t('No installed applications.') . EOL);
}
$tpl = get_markup_template("apps.tpl");
$tpl = get_markup_template('apps.tpl');
return replace_macros($tpl, array(
'$title' => $title,
'$apps' => $a->apps,
));
}

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/security.php');
function attach_init(App $a) {

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once 'include/bbcode.php';
require_once 'library/markdown.php';
require_once 'include/bb2diaspora.php';

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/conversation.php');
require_once('include/items.php');

View file

@ -6,6 +6,8 @@
* of the profile owner
*/
use Friendica\App;
require_once('include/event.php');
require_once('include/redir.php');

View file

@ -4,6 +4,7 @@
* General purpose landing page for plugins/addons
*/
use Friendica\App;
function cb_init(App $a) {
call_hooks('cb_init');

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/socgraph.php');
require_once('include/Contact.php');
require_once('include/contact_selectors.php');

View file

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
function community_init(App $a) {
if (! local_user()) {
@ -9,7 +10,6 @@ function community_init(App $a) {
}
}
function community_content(App $a, $update = 0) {
$o = '';

View file

@ -1,10 +1,10 @@
<?php
use Friendica\App;
require_once('include/group.php');
function contactgroup_content(App $a) {
if (! local_user()) {
killme();
}

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/Contact.php');
require_once('include/socgraph.php');
require_once('include/contact_selectors.php');
@ -828,7 +830,7 @@ function contacts_content(App $a) {
*
* Available Pages are 'Status', 'Profile', 'Contacts' and 'Common Friends'
*
* @param app $a
* @param App $a
* @param int $contact_id The ID of the contact
* @param int $active_tab 1 if tab should be marked as active
*

View file

@ -15,6 +15,7 @@
// fast - e.g. one or two milliseconds to fetch parent items for the current content,
// and 10-20 milliseconds to fetch all the child items.
use Friendica\App;
function content_content(App $a, $update = 0) {

View file

@ -1,20 +1,23 @@
<?php
/**
* Show a credits page for all the developers who helped with the project
* (only contributors to the git repositories for friendica core and the
* addons repository will be listed though ATM)
*/
function credits_content (App $a) {
/* fill the page with credits */
$f = fopen('util/credits.txt','r');
$names = fread($f, filesize('util/credits.txt'));
$arr = explode("\n", htmlspecialchars($names));
fclose($f);
$tpl = get_markup_template('credits.tpl');
return replace_macros( $tpl, array(
'$title' => t('Credits'),
'$thanks' => t('Friendica is a community project, that would not be possible without the help of many people. Here is a list of those who have contributed to the code or the translation of Friendica. Thank you all!'),
'$names' => $arr,
));
use Friendica\App;
function credits_content(App $a) {
/* fill the page with credits */
$f = fopen('util/credits.txt', 'r');
$names = fread($f, filesize('util/credits.txt'));
$arr = explode("\n", htmlspecialchars($names));
fclose($f);
$tpl = get_markup_template('credits.tpl');
return replace_macros($tpl, array(
'$title' => t('Credits'),
'$thanks' => t('Friendica is a community project, that would not be possible without the help of many people. Here is a list of those who have contributed to the code or the translation of Friendica. Thank you all!'),
'$names' => $arr,
));
}

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
require_once("include/contact_selectors.php");
require_once("mod/contacts.php");

View file

@ -1,11 +1,13 @@
<?php
use Friendica\App;
require_once('mod/settings.php');
function delegate_init(App $a) {
return settings_init($a);
}
function delegate_content(App $a) {
if (! local_user()) {

View file

@ -18,6 +18,8 @@
* https://github.com/friendica/friendica/blob/master/spec/dfrn2_contact_confirmation.png
*/
use Friendica\App;
require_once('include/enotify.php');
require_once('include/group.php');
require_once('include/Probe.php');

View file

@ -5,6 +5,9 @@
* @brief The dfrn notify endpoint
* @see PDF with dfrn specs: https://github.com/friendica/friendica/blob/master/spec/dfrn2.pdf
*/
use Friendica\App;
require_once('include/items.php');
require_once('include/dfrn.php');
require_once('include/event.php');

View file

@ -1,12 +1,12 @@
<?php
use Friendica\App;
require_once('include/items.php');
require_once('include/auth.php');
require_once('include/dfrn.php');
function dfrn_poll_init(App $a) {
$dfrn_id = ((x($_GET,'dfrn_id')) ? $_GET['dfrn_id'] : '');
$type = ((x($_GET,'type')) ? $_GET['type'] : 'data');
$last_update = ((x($_GET,'last_update')) ? $_GET['last_update'] : '');

View file

@ -12,6 +12,8 @@
* https://github.com/friendica/friendica/blob/master/spec/dfrn2_contact_request.png
*/
use Friendica\App;
require_once('include/enotify.php');
require_once('include/Scrape.php');
require_once('include/Probe.php');

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function directory_init(App $a) {
$a->set_pager_itemspage(60);
@ -9,24 +11,18 @@ function directory_init(App $a) {
$a->page['aside'] .= findpeople_widget();
$a->page['aside'] .= follow_widget();
}
else {
unset($_SESSION['theme']);
unset($_SESSION['mobile-theme']);
}
}
function directory_post(App $a) {
if(x($_POST,'search'))
$a->data['search'] = $_POST['search'];
}
function directory_content(App $a) {
global $db;

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
require_once('include/contact_widgets.php');
require_once('include/socgraph.php');
require_once('include/Contact.php');
@ -21,8 +24,6 @@ function dirfind_init(App $a) {
$a->page['aside'] .= follow_widget();
}
function dirfind_content(App $a, $prefix = "") {
$community = false;

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function display_init(App $a) {
if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
@ -106,7 +108,6 @@ function display_init(App $a) {
}
profile_load($a, $nick, 0, $profiledata);
}
function display_fetchauthor($a, $item) {

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/acl_selectors.php');
function editpost_content(App $a) {

View file

@ -3,6 +3,9 @@
* @file mod/events.php
* @brief The events module
*/
use Friendica\App;
require_once 'include/bbcode.php';
require_once 'include/datetime.php';
require_once 'include/event.php';

View file

@ -5,6 +5,8 @@
* @author Fabio Comuni <fabrixxm@kirgroup.com>
*/
use Friendica\App;
require_once('include/Photo.php');
/**

View file

@ -2,6 +2,9 @@
/*
This file is part of the Diaspora protocol. It is used for fetching single public posts.
*/
use Friendica\App;
require_once("include/crypto.php");
require_once("include/diaspora.php");
require_once("include/xml.php");

View file

@ -1,10 +1,11 @@
<?php
use Friendica\App;
require_once('include/security.php');
require_once('include/bbcode.php');
require_once('include/items.php');
function filer_content(App $a) {
if (! local_user()) {

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function filerm_content(App $a) {
if (! local_user()) {

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/Scrape.php');
require_once('include/follow.php');
require_once('include/Contact.php');

View file

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
function friendica_init(App $a) {
if ($a->argv[1] == "json"){

View file

@ -1,5 +1,6 @@
<?php
use Friendica\App;
function fsuggest_post(App $a) {

View file

@ -5,6 +5,7 @@
* remove contacts to the contact groups
*/
use Friendica\App;
function group_init(App $a) {
if (local_user()) {

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function hcard_init(App $a) {
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
require_once('library/markdown.php');
if (!function_exists('load_doc_file')) {
@ -87,7 +90,7 @@ function help_content(App $a) {
for($k=0;$k<$lastlevel; $k++) $toc.="</ul>";
$html = implode("\n",$lines);
$a->page['aside'] = $toc.$a->page['aside'];
$a->page['aside'] = '<section class="help-aside-wrapper">' . $toc . $a->page['aside'] . '</section>';
}
$html = "

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
if(! function_exists('home_init')) {
function home_init(App $a) {

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/crypto.php');
function hostxrd_init(App $a) {

View file

@ -8,6 +8,8 @@
* License: GNU AFFERO GENERAL PUBLIC LICENSE (Version 3)
*/
use Friendica\App;
require_once("include/socgraph.php");
require_once("include/Contact.php");
@ -15,6 +17,7 @@ function hovercard_init(App $a) {
// Just for testing purposes
$_GET["mode"] = "minimal";
}
function hovercard_content() {
$profileurl = (x($_REQUEST,'profileurl') ? $_REQUEST['profileurl'] : "");
$datatype = (x($_REQUEST,'datatype') ?$_REQUEST['datatype'] : "json");

View file

@ -1,5 +1,6 @@
<?php
use Friendica\App;
function ignored_init(App $a) {

View file

@ -1,8 +1,10 @@
<?php
use Friendica\App;
require_once "include/Photo.php";
$install_wizard_pass=1;
$install_wizard_pass = 1;
function install_init(App $a) {

View file

@ -7,6 +7,8 @@
*
*/
use Friendica\App;
require_once('include/email.php');
function invite_post(App $a) {

View file

@ -15,6 +15,8 @@
* posting categories go through item_store() instead of this function.
*/
use Friendica\App;
require_once 'include/crypto.php';
require_once 'include/enotify.php';
require_once 'include/email.php';

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/security.php');
require_once('include/bbcode.php');
require_once('include/items.php');

View file

@ -1,7 +1,8 @@
<?php
require_once('include/datetime.php');
use Friendica\App;
require_once('include/datetime.php');
function localtime_post(App $a) {

View file

@ -1,5 +1,6 @@
<?php
use Friendica\App;
function lockview_content(App $a) {

View file

@ -1,13 +1,18 @@
<?php
use Friendica\App;
function login_content(App $a) {
if(x($_SESSION,'theme'))
if (x($_SESSION, 'theme')) {
unset($_SESSION['theme']);
if(x($_SESSION,'mobile-theme'))
}
if (x($_SESSION, 'mobile-theme')) {
unset($_SESSION['mobile-theme']);
}
if(local_user())
if (local_user()) {
goaway(z_root());
}
return login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true);
}

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/email.php');
require_once('include/enotify.php');
require_once('include/text.php');

View file

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
function maintenance_content(App $a) {

View file

@ -1,7 +1,8 @@
<?php
require_once("include/text.php");
use Friendica\App;
require_once("include/text.php");
function manage_post(App $a) {

View file

@ -1,26 +1,26 @@
<?php
use Friendica\Core\Config;
function manifest_content(App $a) {
use Friendica\App;
use Friendica\Core\Config;
$tpl = get_markup_template('manifest.tpl');
function manifest_content(App $a) {
header('Content-type: application/manifest+json');
$tpl = get_markup_template('manifest.tpl');
$touch_icon = Config::get('system', 'touch_icon', 'images/friendica-128.png');
if ($touch_icon == '') {
$touch_icon = 'images/friendica-128.png';
}
$o = replace_macros($tpl, array(
'$baseurl' => App::get_baseurl(),
'$touch_icon' => $touch_icon,
'$title' => Config::get('config', 'sitename', 'Friendica'),
));
echo $o;
killme();
header('Content-type: application/manifest+json');
$touch_icon = Config::get('system', 'touch_icon', 'images/friendica-128.png');
if ($touch_icon == '') {
$touch_icon = 'images/friendica-128.png';
}
?>
$o = replace_macros($tpl, array(
'$baseurl' => App::get_baseurl(),
'$touch_icon' => $touch_icon,
'$title' => Config::get('config', 'sitename', 'Friendica'),
));
echo $o;
killme();
}

View file

@ -1,5 +1,8 @@
<?php
include_once('include/text.php');
use Friendica\App;
require_once('include/text.php');
require_once('include/socgraph.php');
require_once('include/contact_widgets.php');
require_once('mod/proxy.php');

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/acl_selectors.php');
require_once('include/message.php');
require_once('include/Smilies.php');

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('library/asn1.php');
function modexp_init(App $a) {

View file

@ -1,10 +1,11 @@
<?php
use Friendica\App;
require_once('include/security.php');
require_once('include/bbcode.php');
require_once('include/items.php');
function mood_init(App $a) {
if (! local_user()) {

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function msearch_post(App $a) {
$perpage = (($_POST['n']) ? $_POST['n'] : 80);

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once("include/nav.php");
function navigation_content(App $a) {

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
function network_init(App $a) {
if (! local_user()) {
notice( t('Permission denied.') . EOL);
@ -792,7 +795,7 @@ function network_content(App $a, $update = 0) {
/**
* @brief Get the network tabs menu
*
* @param app $a The global App
* @param App $a The global App
* @return string Html of the networktab
*/
function network_tabs(App $a) {

View file

@ -1,83 +1,54 @@
<?php
use Friendica\App;
function newmember_content(App $a) {
$o = '<h1>' . t('Welcome to Friendica') . '</h1>';
$o .= '<h3>' . t('New Member Checklist') . '</h3>';
$o .= '<div style="font-size: 120%;">';
$o .= t('We would like to offer some tips and links to help make your experience enjoyable. Click any item to visit the relevant page. A link to this page will be visible from your home page for two weeks after your initial registration and then will quietly disappear.');
$o .= '<h4>' . t('Getting Started') . '</h4>';
$o .= '<ul>';
$o .= '<li> ' . '<a target="newmember" href="help/guide">' . t('Friendica Walk-Through') . '</a><br />' . t('On your <em>Quick Start</em> page - find a brief introduction to your profile and network tabs, make some new connections, and find some groups to join.') . '</li>' . EOL;
$o .= '</ul>';
$o .= '<h4>' . t('Settings') . '</h4>';
$o .= '<ul>';
$o .= '<li>' . '<a target="newmember" href="settings">' . t('Go to Your Settings') . '</a><br />' . t('On your <em>Settings</em> page - change your initial password. Also make a note of your Identity Address. This looks just like an email address - and will be useful in making friends on the free social web.') . '</li>' . EOL;
$o .= '<li>' . t('Review the other settings, particularly the privacy settings. An unpublished directory listing is like having an unlisted phone number. In general, you should probably publish your listing - unless all of your friends and potential friends know exactly how to find you.') . '</li>' . EOL;
$o .= '</ul>';
$o .= '<h4>' . t('Profile') . '</h4>';
$o .= '<ul>';
$o .= '<li>' . '<a target="newmember" href="profile_photo">' . t('Upload Profile Photo') . '</a><br />' . t('Upload a profile photo if you have not done so already. Studies have shown that people with real photos of themselves are ten times more likely to make friends than people who do not.') . '</li>' . EOL;
$o .= '<li>' . '<a target="newmember" href="profiles">' . t('Edit Your Profile') . '</a><br />' . t('Edit your <strong>default</strong> profile to your liking. Review the settings for hiding your list of friends and hiding the profile from unknown visitors.') . '</li>' . EOL;
$o .= '<li>' . '<a target="newmember" href="profiles">' . t('Profile Keywords') . '</a><br />' . t('Set some public keywords for your default profile which describe your interests. We may be able to find other people with similar interests and suggest friendships.') . '</li>' . EOL;
$o .= '</ul>';
$o .= '<h4>' . t('Connecting') . '</h4>';
$o .= '<ul>';
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
$mail_disabled = ((function_exists('imap_open') && (!get_config('system', 'imap_disabled'))) ? 0 : 1);
if(! $mail_disabled)
if (!$mail_disabled) {
$o .= '<li>' . '<a target="newmember" href="settings/connectors">' . t('Importing Emails') . '</a><br />' . t('Enter your email access information on your Connector Settings page if you wish to import and interact with friends or mailing lists from your email INBOX') . '</li>' . EOL;
}
$o .= '<li>' . '<a target="newmember" href="contacts">' . t('Go to Your Contacts Page') . '</a><br />' . t('Your Contacts page is your gateway to managing friendships and connecting with friends on other networks. Typically you enter their address or site URL in the <em>Add New Contact</em> dialog.') . '</li>' . EOL;
$o .= '<li>' . '<a target="newmember" href="directory">' . t("Go to Your Site's Directory") . '</a><br />' . t('The Directory page lets you find other people in this network or other federated sites. Look for a <em>Connect</em> or <em>Follow</em> link on their profile page. Provide your own Identity Address if requested.') . '</li>' . EOL;
$o .= '<li>' . '<a target="newmember" href="contacts">' . t('Finding New People') . '</a><br />' . t("On the side panel of the Contacts page are several tools to find new friends. We can match people by interest, look up people by name or interest, and provide suggestions based on network relationships. On a brand new site, friend suggestions will usually begin to be populated within 24 hours.") . '</li>' . EOL;
$o .= '</ul>';
$o .= '<h4>' . t('Groups') . '</h4>';
$o .= '<ul>';
$o .= '<li>' . '<a target="newmember" href="contacts">' . t('Group Your Contacts') . '</a><br />' . t('Once you have made some friends, organize them into private conversation groups from the sidebar of your Contacts page and then you can interact with each group privately on your Network page.') . '</li>' . EOL;
if(get_config('system', 'newuser_private')) {
if (get_config('system', 'newuser_private')) {
$o .= '<li>' . '<a target="newmember" href="help/Groups-and-Privacy">' . t("Why Aren't My Posts Public?") . '</a><br />' . t("Friendica respects your privacy. By default, your posts will only show up to people you've added as friends. For more information, see the help section from the link above.") . '</li>' . EOL;
}
$o .= '</ul>';
$o .= '<h4>' . t('Getting Help') . '</h4>';
$o .= '<ul>';
$o .= '<li>' . '<a target="newmember" href="help">' . t('Go to the Help Section') . '</a><br />' . t('Our <strong>help</strong> pages may be consulted for detail on other program features and resources.') . '</li>' . EOL;
$o .= '</ul>';
$o .= '</div>';
return $o;

View file

@ -5,7 +5,8 @@
* Documentation: http://nodeinfo.diaspora.software/schema.html
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once 'include/plugin.php';
@ -251,5 +252,3 @@ function nodeinfo_cron() {
logger('cron_end');
Config::set('nodeinfo', 'last_calucation', time());
}
?>

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/Contact.php');
require_once('include/socgraph.php');
require_once('include/contact_selectors.php');

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function noscrape_init(App $a) {
if($a->argc > 1)

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function notes_init(App $a) {
if (! local_user()) {

View file

@ -1,20 +1,21 @@
<?php
/* identi.ca -> friendica items permanent-url compatibility */
function notice_init(App $a) {
$id = $a->argv[1];
$r = q("SELECT user.nickname FROM user LEFT JOIN item ON item.uid=user.uid WHERE item.id=%d",
intval($id)
);
if (dbm::is_result($r)){
$nick = $r[0]['nickname'];
$url = App::get_baseurl()."/display/$nick/$id";
goaway($url);
} else {
$a->error = 404;
notice( t('Item not found.') . EOL);
/* identi.ca -> friendica items permanent-url compatibility */
}
return;
use Friendica\App;
function notice_init(App $a) {
$id = $a->argv[1];
$r = q("SELECT `user`.`nickname` FROM `user` LEFT JOIN `item` ON `item`.`uid` = `user`.`uid` WHERE `item`.`id` = %d", intval($id));
if (dbm::is_result($r)) {
$nick = $r[0]['nickname'];
$url = App::get_baseurl() . "/display/$nick/$id";
goaway($url);
} else {
$a->error = 404;
notice(t('Item not found.') . EOL);
}
return;
}

View file

@ -5,6 +5,8 @@
* @brief The notifications module
*/
use Friendica\App;
require_once("include/NotificationsManager.php");
require_once("include/contact_selectors.php");
require_once("include/network.php");

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
require_once('include/NotificationsManager.php');
function notify_init(App $a) {

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
require_once("include/oembed.php");
function oembed_content(App $a) {

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
function oexchange_init(App $a) {
if (($a->argc > 1) && ($a->argv[1] === 'xrd')) {

View file

@ -1,9 +1,9 @@
<?php
use Friendica\App;
require_once('library/openid.php');
function openid_content(App $a) {
$noid = get_config('system','no_openid');

View file

@ -1,18 +1,19 @@
<?php
function opensearch_content(App $a) {
$tpl = get_markup_template('opensearch.tpl');
use Friendica\App;
header("Content-type: application/opensearchdescription+xml");
function opensearch_content(App $a) {
$o = replace_macros($tpl, array(
'$baseurl' => App::get_baseurl(),
'$nodename' => $a->get_hostname(),
));
$tpl = get_markup_template('opensearch.tpl');
echo $o;
header("Content-type: application/opensearchdescription+xml");
killme();
$o = replace_macros($tpl, array(
'$baseurl' => App::get_baseurl(),
'$nodename' => $a->get_hostname(),
));
}
?>
echo $o;
killme();
}

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/Scrape.php');
require_once('include/follow.php');

View file

@ -2,6 +2,9 @@
/*
This file is part of the Diaspora protocol. It is used for fetching single public posts.
*/
use Friendica\App;
require_once("include/diaspora.php");
function p_init($a){

View file

@ -10,7 +10,8 @@
* @see ParseUrl::getSiteinfo() for more information about scraping embeddable content
*/
use \Friendica\ParseUrl;
use Friendica\App;
use Friendica\ParseUrl;
require_once("include/items.php");

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/security.php');
require_once('include/Photo.php');

View file

@ -1,4 +1,8 @@
<?php
use Friendica\App;
use Friendica\Core\Config;
require_once 'include/Photo.php';
require_once 'include/photos.php';
require_once 'include/items.php';
@ -10,8 +14,6 @@ require_once 'include/tags.php';
require_once 'include/threads.php';
require_once 'include/Probe.php';
use \Friendica\Core\Config;
function photos_init(App $a) {
if ($a->argc > 1) {

View file

@ -1,5 +1,8 @@
<?php
require_once("include/datetime.php");
use Friendica\App;
require_once('include/datetime.php');
require_once('include/bbcode.php');
require_once('include/ForumManager.php');
require_once('include/group.php');

View file

@ -2,6 +2,8 @@
// See here for a documentation for portable contacts:
// https://web.archive.org/web/20160405005550/http://portablecontacts.net/draft-spec.html
use Friendica\App;
function poco_init(App $a) {
require_once("include/bbcode.php");

View file

@ -1,7 +1,6 @@
<?php /** @file */
<?php
/**
*
* Poke, prod, finger, or otherwise do unspeakable things to somebody - who must be a connection in your address book
* This function can be invoked with the required arguments (verb and cid and private and possibly parent) silently via ajax or
* other web request. You must be logged in and connected to a profile.
@ -12,13 +11,15 @@
*
* private creates a private conversation with the recipient. Otherwise your profile's default post privacy is used.
*
* @file mod/poke.php
*/
use Friendica\App;
require_once('include/security.php');
require_once('include/bbcode.php');
require_once('include/items.php');
function poke_init(App $a) {
if (! local_user()) {

View file

@ -4,6 +4,7 @@
* Zot endpoint
*/
use Friendica\App;
require_once('include/salmon.php');
require_once('include/crypto.php');

View file

@ -1,22 +1,24 @@
<?php
use Friendica\App;
function pretheme_init(App $a) {
if($_REQUEST['theme']) {
if ($_REQUEST['theme']) {
$theme = $_REQUEST['theme'];
$info = get_theme_info($theme);
if($info) {
if ($info) {
// unfortunately there will be no translation for this string
$desc = $info['description'];
$version = $info['version'];
$credits = $info['credits'];
}
else {
} else {
$desc = '';
$version = '';
$credits = '';
}
echo json_encode(array('img' => get_theme_screenshot($theme), 'desc' => $desc, 'version' => $version, 'credits' => $credits));
}
killme();
}

View file

@ -1,31 +1,32 @@
<?php
use Friendica\App;
require_once('include/Scrape.php');
function probe_content(App $a) {
if (!local_user()) {
http_status_exit(403,
array("title" => t("Public access denied."),
"description" => t("Only logged in users are permitted to perform a probing.")));
http_status_exit(403, array("title" => t("Public access denied."),
"description" => t("Only logged in users are permitted to perform a probing.")));
killme();
}
$o .= '<h3>Probe Diagnostic</h3>';
$o .= '<form action="probe" method="get">';
$o .= 'Lookup address: <input type="text" style="width: 250px;" name="addr" value="' . $_GET['addr'] .'" />';
$o .= 'Lookup address: <input type="text" style="width: 250px;" name="addr" value="' . $_GET['addr'] . '" />';
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
$o .= '<br /><br />';
if(x($_GET,'addr')) {
if (x($_GET, 'addr')) {
$addr = trim($_GET['addr']);
$res = probe_url($addr);
$o .= '<pre>';
$o .= str_replace("\n",'<br />',print_r($res,true));
$o .= str_replace("\n", '<br />', print_r($res, true));
$o .= '</pre>';
}
return $o;
}

View file

@ -1,9 +1,10 @@
<?php
use Friendica\App;
require_once('include/contact_widgets.php');
require_once('include/redir.php');
function profile_init(App $a) {
if(! x($a->page,'aside'))

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once("include/Photo.php");
function profile_photo_init(App $a) {
@ -9,10 +11,8 @@ function profile_photo_init(App $a) {
}
profile_load($a,$a->user['nickname']);
}
function profile_photo_post(App $a) {
if (! local_user()) {

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
require_once("include/Contact.php");
require_once('include/Probe.php');

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function profperm_init(App $a) {
if (! local_user()) {

View file

@ -1,6 +1,8 @@
<?php
// Based upon "Privacy Image Cache" by Tobias Hößl <https://github.com/CatoTH/>
use Friendica\App;
define('PROXY_DEFAULT_TIME', 86400); // 1 Day
define('PROXY_SIZE_MICRO', 'micro');

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function hub_return($valid,$body) {
if($valid) {

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function post_var($name) {
return (x($_POST, $name)) ? notags(trim($_POST[$name])) : '';
}
@ -158,5 +160,3 @@ function pubsubhubbub_init(App $a) {
killme();
}
?>

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function qsearch_init(App $a) {
if (! local_user()) {
@ -48,4 +50,3 @@ function qsearch_init(App $a) {
echo json_encode((object) $results);
killme();
}

View file

@ -1,5 +1,6 @@
<?php
use Friendica\App;
function randprof_init(App $a) {
require_once('include/Contact.php');

View file

@ -4,12 +4,12 @@
* Diaspora endpoint
*/
use Friendica\App;
require_once('include/salmon.php');
require_once('include/crypto.php');
require_once('include/diaspora.php');
function receive_post(App $a) {
$enabled = intval(get_config('system', 'diaspora_enabled'));
if (!$enabled) {

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function redir_init(App $a) {
$url = ((x($_GET,'url')) ? $_GET['url'] : '');

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/enotify.php');
require_once('include/bbcode.php');
require_once('include/user.php');

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/enotify.php');
require_once('include/user.php');

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function removeme_post(App $a) {
if (! local_user()) {

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/Scrape.php');
require_once('include/follow.php');

View file

@ -1,10 +1,12 @@
<?php
/**
* @file mod/robots_text.php
* @brief Module which returns the default robots.txt
* @version 0.1.2
*/
use Friendica\App;
/**
* @brief Return default robots.txt when init
@ -13,7 +15,6 @@
*/
function robots_txt_init(App $a)
{
$allDisalloweds = array(
'/settings/',
'/admin/',
@ -21,9 +22,9 @@ function robots_txt_init(App $a)
);
header('Content-Type: text/plain');
echo 'User-agent: *'.PHP_EOL;
echo 'User-agent: *' . PHP_EOL;
foreach ($allDisalloweds as $disallowed) {
echo 'Disallow: '.$disallowed.PHP_EOL;
echo 'Disallow: ' . $disallowed . PHP_EOL;
}
killme();
}

View file

@ -1,24 +1,25 @@
<?php
use Friendica\App;
function rsd_xml_content(App $a) {
function rsd_xml_content(App $a)
{
header ("Content-Type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>
<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">
<service>
<engineName>Friendica</engineName>
<engineLink>http://friendica.com/</engineLink>
<apis>
<api name="Twitter" preferred="true" apiLink="'.App::get_baseurl().'/api/" blogID="">
<settings>
<docs>http://status.net/wiki/TwitterCompatibleAPI</docs>
<setting name="OAuth">false</setting>
</settings>
</api>
</apis>
</service>
</rsd>
';
die();
<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">
<service>
<engineName>Friendica</engineName>
<engineLink>http://friendica.com/</engineLink>
<apis>
<api name="Twitter" preferred="true" apiLink="'.App::get_baseurl().'/api/" blogID="">
<settings>
<docs>http://status.net/wiki/TwitterCompatibleAPI</docs>
<setting name="OAuth">false</setting>
</settings>
</api>
</apis>
</service>
</rsd>';
killme();
}

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/salmon.php');
require_once('include/ostatus.php');
require_once('include/crypto.php');

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
require_once("include/bbcode.php");
require_once('include/security.php');
require_once('include/conversation.php');

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function session_content(App $a) {
}

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/group.php');
require_once('include/socgraph.php');

View file

@ -1,4 +1,7 @@
<?php
use Friendica\App;
function share_init(App $a) {
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);

View file

@ -3,19 +3,19 @@
/**
* @file mod/smilies.php
*/
use Friendica\App;
require_once("include/Smilies.php");
function smilies_content(App $a) {
if ($a->argv[1]==="json"){
if ($a->argv[1] === "json") {
$tmp = Smilies::get_list();
$results = array();
for($i = 0; $i < count($tmp['texts']); $i++) {
for ($i = 0; $i < count($tmp['texts']); $i++) {
$results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]);
}
json_return_and_die($results);
}
else {
return Smilies::replace('',true);
} else {
return Smilies::replace('', true);
}
}

View file

@ -1,5 +1,6 @@
<?php
use Friendica\App;
function starred_init(App $a) {

View file

@ -1,27 +1,30 @@
<?php
/**
* @file mod/statistics_json.php
*/
use Friendica\App;
require_once("include/plugin.php");
function statistics_json_init(App $a) {
if (!get_config("system", "nodeinfo")) {
http_status_exit(404);
killme();
}
if (!get_config("system", "nodeinfo")) {
http_status_exit(404);
killme();
}
$statistics = array(
"name" => $a->config["sitename"],
"network" => FRIENDICA_PLATFORM,
"version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION,
"registrations_open" => ($a->config['register_policy'] != 0),
"total_users" => get_config('nodeinfo','total_users'),
"active_users_halfyear" => get_config('nodeinfo','active_users_halfyear'),
"active_users_monthly" => get_config('nodeinfo','active_users_monthly'),
"local_posts" => get_config('nodeinfo','local_posts')
);
"name" => $a->config["sitename"],
"network" => FRIENDICA_PLATFORM,
"version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION,
"registrations_open" => ($a->config['register_policy'] != 0),
"total_users" => get_config('nodeinfo', 'total_users'),
"active_users_halfyear" => get_config('nodeinfo', 'active_users_halfyear'),
"active_users_monthly" => get_config('nodeinfo', 'active_users_monthly'),
"local_posts" => get_config('nodeinfo', 'local_posts')
);
$statistics["services"] = array();
$statistics["services"]["appnet"] = plugin_enabled("appnet");
@ -53,7 +56,7 @@ function statistics_json_init(App $a) {
$statistics["wordpress"] = $statistics["services"]["wordpress"];
header("Content-Type: application/json");
echo json_encode($statistics, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
logger("statistics_init: printed ".print_r($statistics, true), LOGGER_DATA);
echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
logger("statistics_init: printed " . print_r($statistics, true), LOGGER_DATA);
killme();
}

View file

@ -1,10 +1,11 @@
<?php
use Friendica\App;
require_once('include/security.php');
require_once('include/bbcode.php');
require_once('include/items.php');
function subthread_content(App $a) {
if(! local_user() && ! remote_user()) {

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/socgraph.php');
require_once('include/contact_widgets.php');

View file

@ -1,10 +1,11 @@
<?php
use Friendica\App;
require_once('include/security.php');
require_once('include/bbcode.php');
require_once('include/items.php');
function tagger_content(App $a) {
if(! local_user() && ! remote_user()) {

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/bbcode.php');
function tagrm_post(App $a) {

View file

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function toggle_mobile_init(App $a) {
if (isset($_GET['off'])) {
@ -16,4 +18,3 @@ function toggle_mobile_init(App $a) {
goaway($address);
}

View file

@ -1,7 +1,9 @@
<?php
use Friendica\App;
function uexport_init(App $a) {
if (! local_user()) {
if (!local_user()) {
killme();
}
@ -9,13 +11,12 @@ function uexport_init(App $a) {
settings_init($a);
}
/// @TODO Change space -> tab where wanted
function uexport_content(App $a) {
if ($a->argc > 1) {
header("Content-type: application/json");
header('Content-Disposition: attachment; filename="'.$a->user['nickname'].'.'.$a->argv[1].'"');
switch($a->argv[1]) {
header('Content-Disposition: attachment; filename="' . $a->user['nickname'] . '.' . $a->argv[1] . '"');
switch ($a->argv[1]) {
case "backup":
uexport_all($a);
killme();
@ -51,9 +52,9 @@ function _uexport_multirow($query) {
$result = array();
$r = q($query);
if (dbm::is_result($r)) {
foreach($r as $rr){
foreach ($r as $rr) {
$p = array();
foreach($rr as $k => $v) {
foreach ($rr as $k => $v) {
$p[$k] = $v;
}
$result[] = $p;
@ -66,8 +67,8 @@ function _uexport_row($query) {
$result = array();
$r = q($query);
if (dbm::is_result($r)) {
foreach($r as $rr) {
foreach($rr as $k => $v) {
foreach ($r as $rr) {
foreach ($rr as $k => $v) {
$result[$k] = $v;
}
}
@ -75,39 +76,38 @@ function _uexport_row($query) {
return $result;
}
function uexport_account($a){
function uexport_account($a) {
$user = _uexport_row(
sprintf( "SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval(local_user()) )
sprintf("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval(local_user()))
);
$contact = _uexport_multirow(
sprintf( "SELECT * FROM `contact` WHERE `uid` = %d ",intval(local_user()) )
sprintf("SELECT * FROM `contact` WHERE `uid` = %d ", intval(local_user()))
);
$profile =_uexport_multirow(
sprintf( "SELECT * FROM `profile` WHERE `uid` = %d ", intval(local_user()) )
$profile = _uexport_multirow(
sprintf("SELECT * FROM `profile` WHERE `uid` = %d ", intval(local_user()))
);
$photo = _uexport_multirow(
sprintf( "SELECT * FROM `photo` WHERE uid = %d AND profile = 1", intval(local_user()) )
sprintf("SELECT * FROM `photo` WHERE uid = %d AND profile = 1", intval(local_user()))
);
foreach ($photo as &$p) {
$p['data'] = bin2hex($p['data']);
}
$pconfig = _uexport_multirow(
sprintf( "SELECT * FROM `pconfig` WHERE uid = %d",intval(local_user()) )
sprintf("SELECT * FROM `pconfig` WHERE uid = %d", intval(local_user()))
);
$group = _uexport_multirow(
sprintf( "SELECT * FROM `group` WHERE uid = %d",intval(local_user()) )
sprintf("SELECT * FROM `group` WHERE uid = %d", intval(local_user()))
);
$group_member = _uexport_multirow(
sprintf( "SELECT * FROM `group_member` WHERE uid = %d",intval(local_user()) )
sprintf("SELECT * FROM `group_member` WHERE uid = %d", intval(local_user()))
);
$output = array(
@ -150,13 +150,8 @@ function uexport_all(App $a) {
intval($x),
intval(500)
);
/*if (dbm::is_result($r)) {
foreach($r as $rr)
foreach($rr as $k => $v)
$item[][$k] = $v;
}*/
$output = array('item' => $r);
echo json_encode($output)."\n";
echo json_encode($output) . "\n";
}
}

View file

@ -1,35 +1,37 @@
<?php
/**
* View for user import
* @TODO This file has DOS line endings!
*/
use Friendica\App;
require_once("include/uimport.php");
function uimport_post(App $a) {
switch($a->config['register_policy']) {
case REGISTER_OPEN:
$blocked = 0;
$verified = 1;
break;
switch ($a->config['register_policy']) {
case REGISTER_OPEN:
$blocked = 0;
$verified = 1;
break;
case REGISTER_APPROVE:
$blocked = 1;
$verified = 0;
break;
case REGISTER_APPROVE:
$blocked = 1;
$verified = 0;
break;
default:
case REGISTER_CLOSED:
if ((! x($_SESSION,'authenticated') && (! x($_SESSION,'administrator')))) {
notice( t('Permission denied.') . EOL );
return;
}
$blocked = 1;
$verified = 0;
break;
default:
case REGISTER_CLOSED:
if ((!x($_SESSION, 'authenticated') && (!x($_SESSION, 'administrator')))) {
notice(t('Permission denied.') . EOL);
return;
}
$blocked = 1;
$verified = 0;
break;
}
if (x($_FILES,'accountfile')){
if (x($_FILES, 'accountfile')) {
/// @TODO Pass $blocked / $verified, send email to admin on REGISTER_APPROVE
import_account($a, $_FILES['accountfile']);
return;
@ -38,26 +40,26 @@ function uimport_post(App $a) {
function uimport_content(App $a) {
if ((! local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) {
if ((!local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) {
notice("Permission denied." . EOL);
return;
}
$max_dailies = intval(get_config('system','max_daily_registrations'));
$max_dailies = intval(get_config('system', 'max_daily_registrations'));
if ($max_dailies) {
$r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day");
if ($r && $r[0]['total'] >= $max_dailies) {
logger('max daily registrations exceeded.');
notice( t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL);
notice(t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL);
return;
}
}
if (x($_SESSION,'theme')) {
if (x($_SESSION, 'theme')) {
unset($_SESSION['theme']);
}
if (x($_SESSION,'mobile-theme')) {
if (x($_SESSION, 'mobile-theme')) {
unset($_SESSION['mobile-theme']);
}
@ -65,11 +67,11 @@ function uimport_content(App $a) {
return replace_macros($tpl, array(
'$regbutt' => t('Import'),
'$import' => array(
'title' => t("Move account"),
'intro' => t("You can import an account from another Friendica server."),
'instruct' => t("You need to export your account from the old server and upload it here. We will recreate your old account here with all your contacts. We will try also to inform your friends that you moved here."),
'warn' => t("This feature is experimental. We can't import contacts from the OStatus network (GNU Social/Statusnet) or from Diaspora"),
'field' => array('accountfile', t('Account file'),'<input id="id_accountfile" name="accountfile" type="file">', t('To export your account, go to "Settings->Export your personal data" and select "Export account"')),
'title' => t("Move account"),
'intro' => t("You can import an account from another Friendica server."),
'instruct' => t("You need to export your account from the old server and upload it here. We will recreate your old account here with all your contacts. We will try also to inform your friends that you moved here."),
'warn' => t("This feature is experimental. We can't import contacts from the OStatus network (GNU Social/Statusnet) or from Diaspora"),
'field' => array('accountfile', t('Account file'), '<input id="id_accountfile" name="accountfile" type="file">', t('To export your account, go to "Settings->Export your personal data" and select "Export account"')),
),
));
}

View file

@ -2,6 +2,8 @@
// See update_profile.php for documentation
use Friendica\App;
require_once("mod/community.php");
function update_community_content(App $a) {

Some files were not shown because too many files have changed in this diff Show more