<?php
+
/** @file boot.php
*
* This file defines some global constants and includes the central App class.
* 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');
define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
-
/**
* @brief Image storage quality.
*
* below about 50
*
*/
-
define ( 'JPEG_QUALITY', 100 );
+
/**
* $a->config['system']['png_quality'] from 0 (uncompressed) to 9
*/
*/
define ( 'MAX_IMAGE_LENGTH', -1 );
-
/**
* Not yet used
*/
-
-define ( 'DEFAULT_DB_ENGINE', 'MyISAM' );
+define ( 'DEFAULT_DB_ENGINE', 'InnoDB' );
/**
* @name SSL Policy
define ( 'UPDATE_FAILED', 1);
/** @}*/
-
/**
* @name page/profile types
*
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
*
define ( 'TERM_OBJ_POST', 1 );
define ( 'TERM_OBJ_PHOTO', 2 );
-
-
/**
* @name Namespaces
*
/**
* 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.
* See http://php.net/manual/en/security.magicquotes.disabling.php
*
*/
-
function startup() {
-
error_reporting(E_ERROR | E_WARNING | E_PARSE);
set_time_limit(0);
// 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)) {
}
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;
- }
}
/**
return $a;
}
-
/**
* @brief Multi-purpose function to check variable state.
*
*
* @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]) {
}
}
-
/**
* @brief Called from db initialisation if db is dead.
*/
killme();
}
-
function clean_urls() {
$a = get_app();
return true;
function z_path() {
$base = App::get_baseurl();
- if (! clean_urls()) {
+ if (!clean_urls()) {
$base .= '/?q=';
}
* @return string
*/
function absurl($path) {
- if (strpos($path,'/') === 0) {
+ if (strpos($path, '/') === 0) {
return z_path() . $path;
}
return $path;
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.
// 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) {
// 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.
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)
);
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
// 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
);
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;
$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;
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'];
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());
* @hooks 'login_hook'
* string $o
*/
-function login($register = false, $hiddens=false) {
+function login($register = false, $hiddens = false) {
$a = get_app();
$o = "";
$reg = 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)
));
'$privacytitle' => t('Website Privacy Policy'),
'$privacylink' => t('privacy policy'),
-
));
- call_hooks('login_hook',$o);
+ call_hooks('login_hook', $o);
return $o;
}
* @brief Used to end the current process, after saving session state.
*/
function killme() {
-
if (!get_app()->is_backend()) {
session_write_close();
}
*/
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.
*
* @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;
*/
function notice($s) {
$a = get_app();
- if (! x($_SESSION,'sysmsg')) {
+ if (!x($_SESSION, 'sysmsg')) {
$_SESSION['sysmsg'] = array();
}
if ($a->interactive) {
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) {
}
}
-
/**
* @brief Wrapper around config to limit the text length of an incoming message
*
*/
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
*
* @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();
$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;
}
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`)
$a->proc_run($args);
}
-function current_theme(){
+function current_theme() {
$app_base_themes = array('duepuntozero', 'dispy', 'quattro');
$a = get_app();
// 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;
}
}
$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']) {
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
}
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?
$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) {
/**
*
* 6:00PM the day before, but that will correspond to midnight to the birthday person.
*
*/
-
-
$birthday = '';
- if (! strlen($tz)) {
+ if (!strlen($tz)) {
$tz = 'UTC';
}
);
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);
}
}
$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;
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);
}
/**
-* 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") {
$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;
}
$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;
}
function get_cachefile($file, $writemode = true) {
$cache = get_itemcachepath();
- if ((! $cache) || (! is_dir($cache))) {
+ if ((!$cache) || (!is_dir($cache))) {
return("");
}
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);
}
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;
}
$temppath = get_temppath();
if ($temppath != "") {
- $itemcache = $temppath."/itemcache";
+ $itemcache = $temppath . "/itemcache";
if (!file_exists($itemcache) && !is_dir($itemcache)) {
mkdir($itemcache);
}
* @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;
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);
}
// 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);
return false;
}
- $file = str_replace(getcwd()."/", "", $file, $count);
+ $file = str_replace(getcwd() . "/", "", $file, $count);
if ($count != 1) {
return false;
}
* @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];
}
*
* @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
}
}
- 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);
}
},
{
"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
},
"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": {
````
$> 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)
--- /dev/null
+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)
\ No newline at end of file
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
**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**
Let's say you have a PHP file in `src/` that define a very useful class:\r
\r
```php\r
- // src/ItemsManager.php\r
- <?php\r
- namespace \Friendica;\r
-\r
- class ItemsManager {\r
- public function getAll() { ... }\r
- public function getByID($id) { ... }\r
- }\r
+// src/ItemsManager.php\r
+<?php\r
+namespace Friendica;\r
+\r
+class ItemsManager {\r
+ public function getAll() { ... }\r
+ public function getByID($id) { ... }\r
+}\r
```\r
\r
The class `ItemsManager` has been declared in the `Friendica` namespace.\r
The code will be something like:\r
\r
```php\r
- // mod/network.php\r
- <?php\r
+// mod/network.php\r
+<?php\r
\r
- function network_content(App $a) {\r
- $itemsmanager = new \Friendica\ItemsManager();\r
- $items = $itemsmanager->getAll();\r
+function network_content(App $a) {\r
+ $itemsmanager = new Friendica\ItemsManager();\r
+ $items = $itemsmanager->getAll();\r
\r
- // pass $items to template\r
- // return result\r
- }\r
+ // pass $items to template\r
+ // return result\r
+}\r
```\r
\r
That's a quite simple example, but look: no `require()`!\r
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:\r
\r
```php\r
- // src/BaseManager.php\r
- <?php\r
- namespace \Friendica;\r
+// src/BaseManager.php\r
+<?php\r
+namespace Friendica;\r
\r
- class BaseManager {\r
- public function thatFunctionEveryManagerUses() { ... }\r
- }\r
+class BaseManager {\r
+ public function thatFunctionEveryManagerUses() { ... }\r
+}\r
```\r
\r
and then let's change the ItemsManager class to use this code\r
\r
```php\r
- // src/ItemsManager.php\r
- <?php\r
- namespace \Friendica;\r
-\r
- class ItemsManager extends BaseManager {\r
- public function getAll() { ... }\r
- public function getByID($id) { ... }\r
- }\r
+// src/ItemsManager.php\r
+<?php\r
+namespace Friendica;\r
+\r
+class ItemsManager extends BaseManager {\r
+ public function getAll() { ... }\r
+ public function getByID($id) { ... }\r
+}\r
```\r
\r
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.\r
It works with the "BaseManager" example here and it works when we need to call static methods:\r
\r
```php\r
- // src/Dfrn.php\r
- <?php\r
- namespace \Friendica;\r
+// src/Dfrn.php\r
+<?php\r
+namespace Friendica;\r
\r
- class Dfrn {\r
- public static function mail($item, $owner) { ... }\r
- }\r
+class Dfrn {\r
+ public static function mail($item, $owner) { ... }\r
+}\r
```\r
\r
```php\r
- // mod/mail.php\r
- <?php\r
-\r
- mail_post($a){\r
- ...\r
- \Friendica\dfrn::mail($item, $owner);\r
- ...\r
- }\r
+// mod/mail.php\r
+<?php\r
+\r
+mail_post($a){\r
+ ...\r
+ Friendica\dfrn::mail($item, $owner);\r
+ ...\r
+}\r
```\r
\r
If your code is in same namespace as the class you need, you don't need to prepend it:\r
\r
```php\r
- // include/delivery.php\r
- <?php\r
-\r
- namespace \Friendica;\r
-\r
- // this is the same content of current include/delivery.php,\r
- // but has been declared to be in "Friendica" namespace\r
-\r
- [...]\r
- switch($contact['network']) {\r
- case NETWORK_DFRN:\r
- if ($mail) {\r
- $item['body'] = ...\r
- $atom = Dfrn::mail($item, $owner);\r
- } elseif ($fsuggest) {\r
- $atom = Dfrn::fsuggest($item, $owner);\r
- q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));\r
- } elseif ($relocate)\r
- $atom = Dfrn::relocate($owner, $uid);\r
- [...]\r
+// include/delivery.php\r
+<?php\r
+\r
+namespace Friendica;\r
+\r
+// this is the same content of current include/delivery.php,\r
+// but has been declared to be in "Friendica" namespace\r
+\r
+[...]\r
+switch($contact['network']) {\r
+ case NETWORK_DFRN:\r
+ if ($mail) {\r
+ $item['body'] = ...\r
+ $atom = Dfrn::mail($item, $owner);\r
+ } elseif ($fsuggest) {\r
+ $atom = Dfrn::fsuggest($item, $owner);\r
+ q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));\r
+ } elseif ($relocate)\r
+ $atom = Dfrn::relocate($owner, $uid);\r
+[...]\r
```\r
\r
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.\r
But if you want to use classes from another library, you need to use the full namespace, e.g.\r
\r
```php\r
- // src/Diaspora.php\r
- <?php\r
+// src/Diaspora.php\r
+<?php\r
\r
- namespace \Friendica;\r
+namespace Friendica;\r
\r
- class Diaspora {\r
- public function md2bbcode() {\r
- $html = \Michelf\MarkdownExtra::defaultTransform($text);\r
- }\r
+class Diaspora {\r
+ public function md2bbcode() {\r
+ $html = \Michelf\MarkdownExtra::defaultTransform($text);\r
}\r
+}\r
```\r
\r
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\r
\r
```php\r
- // src/Diaspora.php\r
- <?php\r
- namespace \Friendica;\r
+// src/Diaspora.php\r
+<?php\r
+namespace Friendica;\r
\r
- use \Michelf\MarkdownExtra;\r
+use \Michelf\MarkdownExtra;\r
\r
- class Diaspora {\r
- public function md2bbcode() {\r
- $html = MarkdownExtra::defaultTransform($text);\r
- }\r
+class Diaspora {\r
+ public function md2bbcode() {\r
+ $html = MarkdownExtra::defaultTransform($text);\r
}\r
+}\r
```\r
\r
Note that namespaces are like paths in filesystem, separated by "\", with the first "\" being the global scope.\r
You can go deeper if you want to, like:\r
\r
```\r
- // src/Network/Dfrn.php\r
- <?php\r
- namespace \Friendica\Network;\r
+// src/Network/Dfrn.php\r
+<?php\r
+namespace Friendica\Network;\r
\r
- class Dfrn {\r
- }\r
+class Dfrn {\r
+}\r
```\r
\r
-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`.\r
+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`.\r
\r
or\r
\r
```\r
- // src/Dba/Mysql\r
- <?php\r
- namespace \Friendica\Dba;\r
+// src/Dba/Mysql\r
+<?php\r
+namespace Friendica\Dba;\r
\r
- class Mysql {\r
- }\r
+class Mysql {\r
+}\r
```\r
\r
So you can think of namespaces as folders in a Unix file system, with global scope as the root ("\").\r
+\r
+## Related\r
+\r
+* [Using Composer](help/Composer)\r
+* [How To Move Classes to `src`](help/Developer-How-To-Move-Classes-to-src)
\ No newline at end of file
<?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.
return $account_type;
}
-?>
<?php
+use Friendica\App;
+
/**
* @file include/ForumManager.php
* @brief ForumManager class with its methods related to forum functionality *
*
* @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
/**
* @brief List of pages for the Notifications TabBar
- *
- * @param app $a The
+ *
* @return array with with notifications TabBar data
*/
public function getTabs() {
/**
* @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
}
/**
- * @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"
/**
* @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
}
/**
- * @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"
/**
* @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
/**
* @brief Addional SQL query string for the personal notifications
- *
+ *
* @return string The additional sql query
*/
private function _personal_sql_extra() {
}
/**
- * @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"
/**
* @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
$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),
if (dbm::is_result($r))
$notifs = $this->formatNotifs($r, $ident);
-
+
$arr = array (
'notifications' => $notifs,
'ident' => $ident,
}
/**
- * @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"
/**
* @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
}
/**
- * @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
/**
* @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
/**
* @brief Format the notification query in an usable array
- *
+ *
* @param array $intros The array from the db query
* @return array with the introductions
*/
* @brief This file contains the Photo class for image processing
*/
+use Friendica\App;
+
require_once("include/photos.php");
class Photo {
*
*/
-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');
}
}
-?>
* @brief This file contains the Smilies class which contains functions to handle smiles
*/
+use Friendica\App;
+
/**
* This class contains functions to handle smiles
*/
/**
* @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() {
);
$icons = array(
- '<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-heart.gif" alt="<3" title="<3" />',
- '<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-brokenheart.gif" alt="</3" title="</3" />',
- '<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-brokenheart.gif" alt="<\\3" title="<\\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="<3" title="<3" />',
+ '<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-brokenheart.gif" alt="</3" title="</3" />',
+ '<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-brokenheart.gif" alt="<\\3" title="<\\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);
*
* @param string $s
* @param boolean $sample
- *
+ *
* @return string HML Output of the Smilie
*/
public static function replace($s, $sample = false) {
*
* @param string $x
* @return string HTML Output
- *
+ *
* @todo: Rework because it doesn't work correctly
*/
private function preg_heart($x) {
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="<3" />';
+ $t .= '<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-heart.gif" alt="<3" />';
$r = str_replace($x[0],$t,$x[0]);
return $r;
}
* @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";
* @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';
<?php
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
require_once('include/security.php');
require_once('include/datetime.php');
*
*/
+use Friendica\App;
+
if (sizeof($_SERVER["argv"]) == 0)
die();
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");
fclose($this->rLogFile);
}
}
-?>
<?php
+use Friendica\App;
+
use League\HTMLToMarkdown\HtmlConverter;
require_once "include/oembed.php";
<?php
-use \Friendica\Core\Config;
+
+use Friendica\App;
+use Friendica\Core\Config;
require_once 'include/oembed.php';
require_once 'include/event.php';
* @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 {
/**
/**
* @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
<?php /** @file */
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
require_once('boot.php');
global $a, $db;
if (is_null($a)) {
- $a = new App;
+ $a = new App(dirname(__DIR__));
}
if (is_null($db)) {
<?php
/**
* @file include/config.php
- *
+ *
* @brief (Deprecated) Arbitrary configuration storage
* Note:
* Please do not store booleans - convert to 0/1 integer values
* 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.
<?php
+use Friendica\App;
+
function follow_widget($value = "") {
return replace_macros(get_markup_template('follow.tpl'), array(
<?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
add_shadow_entry($message_id);
}
-?>
<?php
-use \Friendica\Core\Config;
+
+use Friendica\Core\Config;
function cron_run(&$argv, &$argc){
global $a;
<?php
-use \Friendica\Core\Config;
+use Friendica\Core\Config;
function cronhooks_run(&$argv, &$argc) {
global $a;
<?php
-use \Friendica\Core\Config;
+
+use Friendica\App;
+use Friendica\Core\Config;
function cronjobs_run(&$argv, &$argc){
global $a;
* @brief Some functions for date and time related tasks.
*/
-use \Friendica\Core\Config;
+use Friendica\Core\Config;
/**
* @brief Two-level sort for timezones.
/**
* @brief Emit a timezone selector grouped (primarily) by continent
- *
+ *
* @param string $current Timezone
* @return string Parsed HTML output
*/
/**
* @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){
* @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") {
/**
* @brief Returns a date selector
- *
+ *
* @param string $format
* Format string, e.g. 'ymd' or 'mdy'. Not currently supported
* @param string $min
* 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') {
/**
* @brief Returns a time selector
- *
+ *
* @param string $format
* Format string, e.g. 'ymd' or 'mdy'. Not currently supported
* @param $h
* 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') {
* @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
* @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 = '') {
*
* @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) {
*
* @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) {
* @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
* @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)) {
}
}
-?>
return date('Y-m-d H:i:s', $timestamp);
}
}
-?>
<?php
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
require_once("boot.php");
require_once("include/text.php");
$sql3 .= ";";
}
+ $field_list = '';
+ if ($is_unique && $ignore == '') {
+ foreach ($structure['fields'] AS $fieldname => $parameters) {
+ $field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
+ }
+ $field_list = rtrim($field_list, ',');
+ }
+
if ($verbose) {
// Ensure index conversion to unique removes duplicates
if ($is_unique) {
if ($ignore != "") {
echo "SET session old_alter_table=0;\n";
} else {
- echo "INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";\n";
+ echo "INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";\n";
echo "DROP TABLE `".$name."`;\n";
echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
}
if ($ignore != "") {
$db->q("SET session old_alter_table=0;");
} else {
- $r = $db->q("INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";");
+ $r = $db->q("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
if (!dbm::is_result($r)) {
$errors .= print_update_error($db, $sql3);
return $errors;
global $a, $db;
if (is_null($a)) {
- $a = new App;
+ $a = new App(dirname(__DIR__));
}
if (is_null($db)) {
<?php
-use \Friendica\Core\Config;
+use Friendica\Core\Config;
function dbupdate_run(&$argv, &$argc) {
global $a;
<?php
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
require_once('include/queue_fn.php');
require_once('include/html2plain.php');
* 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");
$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);
$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);
// 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);
}
}
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",
$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);
}
// 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
* 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';
return true;
}
}
-?>
<?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;
<?php
-use \Friendica\Core\Config;
+use Friendica\Core\Config;
require_once('include/socgraph.php');
require_once('include/datetime.php');
<?php
+
+use Friendica\App;
+
require_once('include/Emailer.php');
require_once('include/email.php');
require_once('include/bbcode.php');
* @brief functions specific to event handling
*/
+use Friendica\App;
+
require_once 'include/bbcode.php';
require_once 'include/map.php';
require_once 'include/datetime.php';
*
* @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) {
<?php
-use \Friendica\Core\Config;
+use Friendica\Core\Config;
function expire_run(&$argv, &$argc){
global $a;
return array("header" => $author, "items" => $items);
}
}
-?>
create_files_from_item($message["id"]);
}
}
-?>
<?php
+
+use Friendica\App;
+
require_once("include/Scrape.php");
require_once("include/socgraph.php");
require_once('include/group.php');
<?php
-use \Friendica\Core\Config;
+use Friendica\Core\Config;
require_once('include/Scrape.php');
require_once('include/socgraph.php');
return(trim($message));
}
-?>
* @file include/identity.php
*/
+use Friendica\App;
+
require_once('include/ForumManager.php');
require_once('include/bbcode.php');
require_once("mod/proxy.php");
* @file include/items.php
*/
-use \Friendica\ParseUrl;
+use Friendica\App;
+use Friendica\ParseUrl;
require_once 'include/bbcode.php';
require_once 'include/oembed.php';
* 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) {
<?php
+
+use Friendica\App;
+
require_once("include/diaspora.php");
/**
<?php
- // send a private message
-
-
+// send a private message
+use Friendica\App;
function send_message($recipient=0, $body='', $subject='', $replyto=''){
(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
return(implode("\n", $lines));
}
-?>
<?php
+use Friendica\App;
+
function nav(App $a) {
/*
* @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');
<?php
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
require_once('include/queue_fn.php');
require_once('include/html2plain.php');
*
*/
+use Friendica\App;
+
define('REQUEST_TOKEN_DURATION', 300);
define('ACCESS_TOKEN_DURATION', 31536000);
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),
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)",
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");
$apps[] = $consumer->key;
set_pconfig($uverifier, "oauth", "apps", $apps);*/
}
-
+
return $ret;
-
+
}
}
intval($_SESSION['uid'])
);
- call_hooks('logged_in', $a->user);
+ call_hooks('logged_in', $a->user);
}
-
+
}
/*
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));
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;
}
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;
+ }
+
}
*/
* @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];
<?php
-use \Friendica\Core\Config;
+use Friendica\Core\Config;
require_once('include/follow.php');
* @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");
/**
* @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
*
return(trim($doc->saveXML()));
}
}
-?>
*
*/
-use \Friendica\Core\Config;
+use Friendica\Core\Config;
require_once("include/dba.php");
* @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;
return(posix_kill(file_get_contents($this->_file), SIGTERM));
}
}
-?>
* @file include/plaintext.php
*/
-use \Friendica\ParseUrl;
+use Friendica\App;
+use Friendica\ParseUrl;
require_once("include/Photo.php");
require_once("include/bbcode.php");
return($post);
}
-?>
<?php
/**
* @file include/plugin.php
- *
+ *
* @brief Some functions to handle addons and themes.
*/
+use Friendica\App;
/**
* @brief uninstalls an addon.
/**
* @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
/**
* @brief Parse theme comment in search of theme infos.
- *
+ *
* like
* \code
* ..* Name: My Theme
/**
* @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
<?php
+
+use Friendica\App;
+use Friendica\Core\Config;
+
if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
$directory = dirname($_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)) {
if (time() > ($starttime + 3600))
return;
}
-
}
/**
killme();
}
-?>
logger("Done", LOGGER_DEBUG);
return true;
}
-
-?>
<?php
-use \Friendica\Core\Config;
+
+use Friendica\App;
+use Friendica\Core\Config;
require_once('include/items.php');
require_once('include/ostatus.php');
<?php
-use \Friendica\Core\Config;
+use Friendica\Core\Config;
require_once('include/queue_fn.php');
require_once('include/dfrn.php');
<?php
+use Friendica\App;
+
function auto_redir(App $a, $contact_nick) {
// prevent looping
* @brief Removes orphaned data from deleted contacts
*/
-use \Friendica\Core\Config;
+use Friendica\Core\Config;
function remove_contact_run($argv, $argc) {
if ($argc != 2) {
// Now we delete all the depending table entries
dba::delete('contact', array('id' => $id));
}
-?>
<?php
+use Friendica\App;
+
/**
* @brief Calculate the hash that is needed for the "Friendica" cookie
*
<?php
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
require_once("boot.php");
require_once("include/threads.php");
global $a, $db;
if (is_null($a)) {
- $a = new App;
+ $a = new App(dirname(__DIR__));
}
if (is_null($db)) {
<?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");
$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),
}
return $r;
}
-?>
* @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");
}
}
}
-?>
<?php
+
+use Friendica\App;
+
function create_tags_from_item($itemid) {
$profile_base = App::get_baseurl();
$profile_data = parse_url($profile_base);
dba::close($messages);
}
-?>
<?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
<?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`,
dba::close($messages);
}
-?>
<?php\r
\r
-/**\r
- * import account file exported from mod/uexport\r
- * args:\r
- * $a App Friendica App Class\r
- * $file Array array from $_FILES\r
- */\r
+use Friendica\App;\r
+\r
require_once("include/Photo.php");\r
define("IMPORT_DEBUG", False);\r
\r
q("DELETE FROM `pconfig` WHERE uid = %d", $newuid);\r
}\r
\r
+/**\r
+ * @brief Import account file exported from mod/uexport\r
+ *\r
+ * @param App $a Friendica App Class\r
+ * @param array $file array from $_FILES\r
+ */\r
function import_account(App $a, $file) {\r
logger("Start user import from " . $file['tmp_name']);\r
/*\r
}\r
}\r
\r
-\r
-\r
-\r
-\r
foreach ($account['photo'] as &$photo) {\r
$photo['uid'] = $newuid;\r
$photo['data'] = hex2bin($photo['data']);\r
<?php
-use \Friendica\Core\Config;
+use Friendica\Core\Config;
function update_gcontact_run(&$argv, &$argc) {
global $a;
*
*/
-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
exit();
}
- require_once("include/session.php");
+ require_once 'include/session.php';
load_hooks();
call_hooks('init_1');
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.
*/
<?php
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
require_once("mod/hostxrd.php");
require_once("mod/nodeinfo.php");
<?php
+use Friendica\App;
+
require_once('include/Scrape.php');
function acctlink_init(App $a) {
<?php
/* ACL selector json backend */
+use Friendica\App;
+
require_once 'include/acl_selectors.php';
function acl_init(App $a) {
* @brief Friendica admin
*/
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
require_once("include/enotify.php");
require_once("include/text.php");
<?php
+use Friendica\App;
+
require_once('include/socgraph.php');
require_once('include/Contact.php');
require_once('include/contact_selectors.php');
<?php
+use Friendica\App;
+
function amcd_content(App $a) {
-//header("Content-type: text/json");
-echo <<< EOT
+ echo <<< JSON
{
"version":1,
"sessionstatus":{
}
}
}
-EOT;
-killme();
+JSON;
+ killme();
}
\ No newline at end of file
<?php
+use Friendica\App;
+
require_once('include/api.php');
function oauth_get_client($request){
'$no' => t('No'),
));
- //echo "<pre>"; var_dump($app); killme();
-
return $o;
}
<?php
-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;};
-}
+use Friendica\App;
- $title = t('Applications');
+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;
+ };
+ }
- if(count($a->apps)==0)
- notice( t('No installed applications.') . EOL);
+ $title = t('Applications');
+ 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,
));
-
-
-
}
<?php
+use Friendica\App;
+
require_once('include/security.php');
function attach_init(App $a) {
<?php
+use Friendica\App;
+
require_once 'include/bbcode.php';
require_once 'library/markdown.php';
require_once 'include/bb2diaspora.php';
<?php
+use Friendica\App;
+
require_once('include/conversation.php');
require_once('include/items.php');
* of the profile owner
*/
+use Friendica\App;
+
require_once('include/event.php');
require_once('include/redir.php');
* General purpose landing page for plugins/addons
*/
+use Friendica\App;
function cb_init(App $a) {
call_hooks('cb_init');
<?php
+use Friendica\App;
+
require_once('include/socgraph.php');
require_once('include/Contact.php');
require_once('include/contact_selectors.php');
<?php
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
function community_init(App $a) {
if (! local_user()) {
}
}
-
function community_content(App $a, $update = 0) {
$o = '';
<?php
+use Friendica\App;
+
require_once('include/group.php');
function contactgroup_content(App $a) {
-
-
if (! local_user()) {
killme();
}
<?php
+use Friendica\App;
+
require_once('include/Contact.php');
require_once('include/socgraph.php');
require_once('include/contact_selectors.php');
*
* 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
*
// 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) {
<?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,
+ ));
}
<?php
+
+use Friendica\App;
+
require_once("include/contact_selectors.php");
require_once("mod/contacts.php");
<?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()) {
* 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');
* @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');
<?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'] : '');
* 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');
<?php
+use Friendica\App;
+
function directory_init(App $a) {
$a->set_pager_itemspage(60);
$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;
<?php
+
+use Friendica\App;
+
require_once('include/contact_widgets.php');
require_once('include/socgraph.php');
require_once('include/Contact.php');
$a->page['aside'] .= follow_widget();
}
-
-
function dirfind_content(App $a, $prefix = "") {
$community = false;
<?php
+use Friendica\App;
+
function display_init(App $a) {
if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
}
profile_load($a, $nick, 0, $profiledata);
-
}
function display_fetchauthor($a, $item) {
<?php
+use Friendica\App;
+
require_once('include/acl_selectors.php');
function editpost_content(App $a) {
* @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';
* @author Fabio Comuni <fabrixxm@kirgroup.com>
*/
+use Friendica\App;
+
require_once('include/Photo.php');
/**
/*
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");
<?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()) {
<?php
+use Friendica\App;
+
function filerm_content(App $a) {
if (! local_user()) {
<?php
+use Friendica\App;
+
require_once('include/Scrape.php');
require_once('include/follow.php');
require_once('include/Contact.php');
<?php
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
function friendica_init(App $a) {
if ($a->argv[1] == "json"){
<?php
+use Friendica\App;
function fsuggest_post(App $a) {
* remove contacts to the contact groups
*/
+use Friendica\App;
function group_init(App $a) {
if (local_user()) {
<?php
+use Friendica\App;
+
function hcard_init(App $a) {
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
<?php
+
+use Friendica\App;
+
require_once('library/markdown.php');
if (!function_exists('load_doc_file')) {
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 = "
<?php
+use Friendica\App;
+
if(! function_exists('home_init')) {
function home_init(App $a) {
<?php
+use Friendica\App;
+
require_once('include/crypto.php');
function hostxrd_init(App $a) {
* License: GNU AFFERO GENERAL PUBLIC LICENSE (Version 3)
*/
+use Friendica\App;
+
require_once("include/socgraph.php");
require_once("include/Contact.php");
// Just for testing purposes
$_GET["mode"] = "minimal";
}
+
function hovercard_content() {
$profileurl = (x($_REQUEST,'profileurl') ? $_REQUEST['profileurl'] : "");
$datatype = (x($_REQUEST,'datatype') ?$_REQUEST['datatype'] : "json");
<?php
+use Friendica\App;
function ignored_init(App $a) {
<?php
-require_once "include/Photo.php";
-$install_wizard_pass=1;
+use Friendica\App;
+
+require_once "include/Photo.php";
+$install_wizard_pass = 1;
function install_init(App $a) {
*
*/
+use Friendica\App;
+
require_once('include/email.php');
function invite_post(App $a) {
* 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';
<?php
+use Friendica\App;
+
require_once('include/security.php');
require_once('include/bbcode.php');
require_once('include/items.php');
<?php
-require_once('include/datetime.php');
+use Friendica\App;
+require_once('include/datetime.php');
function localtime_post(App $a) {
<?php
+use Friendica\App;
function lockview_content(App $a) {
<?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);
-
}
<?php
+use Friendica\App;
+
require_once('include/email.php');
require_once('include/enotify.php');
require_once('include/text.php');
<?php
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
function maintenance_content(App $a) {
<?php
-require_once("include/text.php");
+use Friendica\App;
+require_once("include/text.php");
function manage_post(App $a) {
<?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';
- }
+ header('Content-type: application/manifest+json');
- $o = replace_macros($tpl, array(
- '$baseurl' => App::get_baseurl(),
- '$touch_icon' => $touch_icon,
- '$title' => Config::get('config', 'sitename', 'Friendica'),
- ));
+ $touch_icon = Config::get('system', 'touch_icon', 'images/friendica-128.png');
+ if ($touch_icon == '') {
+ $touch_icon = 'images/friendica-128.png';
+ }
- echo $o;
+ $o = replace_macros($tpl, array(
+ '$baseurl' => App::get_baseurl(),
+ '$touch_icon' => $touch_icon,
+ '$title' => Config::get('config', 'sitename', 'Friendica'),
+ ));
- killme();
+ echo $o;
- }
-?>
+ killme();
+}
<?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');
<?php
+use Friendica\App;
+
require_once('include/acl_selectors.php');
require_once('include/message.php');
require_once('include/Smilies.php');
<?php
+use Friendica\App;
+
require_once('library/asn1.php');
function modexp_init(App $a) {
<?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()) {
<?php
+use Friendica\App;
+
function msearch_post(App $a) {
$perpage = (($_POST['n']) ? $_POST['n'] : 80);
<?php
+use Friendica\App;
+
require_once("include/nav.php");
function navigation_content(App $a) {
<?php
+
+use Friendica\App;
+
function network_init(App $a) {
if (! local_user()) {
notice( t('Permission denied.') . EOL);
/**
* @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) {
<?php
-function newmember_content(App $a) {
+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;
* Documentation: http://nodeinfo.diaspora.software/schema.html
*/
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
require_once 'include/plugin.php';
logger('cron_end');
Config::set('nodeinfo', 'last_calucation', time());
}
-
-?>
<?php
+use Friendica\App;
+
require_once('include/Contact.php');
require_once('include/socgraph.php');
require_once('include/contact_selectors.php');
<?php
+use Friendica\App;
+
function noscrape_init(App $a) {
if($a->argc > 1)
<?php
+use Friendica\App;
+
function notes_init(App $a) {
if (! local_user()) {
<?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;
+}
* @brief The notifications module
*/
+use Friendica\App;
+
require_once("include/NotificationsManager.php");
require_once("include/contact_selectors.php");
require_once("include/network.php");
<?php
+
+use Friendica\App;
+
require_once('include/NotificationsManager.php');
function notify_init(App $a) {
<?php
+
+use Friendica\App;
+
require_once("include/oembed.php");
function oembed_content(App $a) {
<?php
+
+use Friendica\App;
+
function oexchange_init(App $a) {
if (($a->argc > 1) && ($a->argv[1] === 'xrd')) {
<?php
+use Friendica\App;
require_once('library/openid.php');
-
function openid_content(App $a) {
$noid = get_config('system','no_openid');
<?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(),
+ ));
- }
-?>
\ No newline at end of file
+ echo $o;
+
+ killme();
+}
<?php
+use Friendica\App;
+
require_once('include/Scrape.php');
require_once('include/follow.php');
/*
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){
* @see ParseUrl::getSiteinfo() for more information about scraping embeddable content
*/
-use \Friendica\ParseUrl;
+use Friendica\App;
+use Friendica\ParseUrl;
require_once("include/items.php");
<?php
+use Friendica\App;
+
require_once('include/security.php');
require_once('include/Photo.php');
<?php
+
+use Friendica\App;
+use Friendica\Core\Config;
+
require_once 'include/Photo.php';
require_once 'include/photos.php';
require_once 'include/items.php';
require_once 'include/threads.php';
require_once 'include/Probe.php';
-use \Friendica\Core\Config;
-
function photos_init(App $a) {
if ($a->argc > 1) {
<?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');
// 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");
-<?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.
*
* 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()) {
* Zot endpoint
*/
+use Friendica\App;
require_once('include/salmon.php');
require_once('include/crypto.php');
<?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();
}
<?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;
}
<?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'))
<?php
+use Friendica\App;
+
require_once("include/Photo.php");
function profile_photo_init(App $a) {
}
profile_load($a,$a->user['nickname']);
-
}
-
function profile_photo_post(App $a) {
if (! local_user()) {
<?php
+
+use Friendica\App;
+
require_once("include/Contact.php");
require_once('include/Probe.php');
<?php
+use Friendica\App;
+
function profperm_init(App $a) {
if (! local_user()) {
<?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');
<?php
+use Friendica\App;
+
function hub_return($valid,$body) {
if($valid) {
<?php
+use Friendica\App;
+
function post_var($name) {
return (x($_POST, $name)) ? notags(trim($_POST[$name])) : '';
}
killme();
}
-
-?>
<?php
+use Friendica\App;
+
function qsearch_init(App $a) {
if (! local_user()) {
echo json_encode((object) $results);
killme();
}
-
<?php
+use Friendica\App;
function randprof_init(App $a) {
require_once('include/Contact.php');
* 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) {
<?php
+use Friendica\App;
+
function redir_init(App $a) {
$url = ((x($_GET,'url')) ? $_GET['url'] : '');
<?php
+use Friendica\App;
+
require_once('include/enotify.php');
require_once('include/bbcode.php');
require_once('include/user.php');
<?php
+use Friendica\App;
+
require_once('include/enotify.php');
require_once('include/user.php');
<?php
+use Friendica\App;
+
function removeme_post(App $a) {
if (! local_user()) {
<?php
+use Friendica\App;
+
require_once('include/Scrape.php');
require_once('include/follow.php');
<?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
*/
function robots_txt_init(App $a)
{
-
$allDisalloweds = array(
'/settings/',
'/admin/',
);
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();
}
<?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();
}
\ No newline at end of file
<?php
+use Friendica\App;
+
require_once('include/salmon.php');
require_once('include/ostatus.php');
require_once('include/crypto.php');
<?php
+
+use Friendica\App;
+
require_once("include/bbcode.php");
require_once('include/security.php');
require_once('include/conversation.php');
<?php
+use Friendica\App;
+
function session_content(App $a) {
}
<?php
+use Friendica\App;
+
require_once('include/group.php');
require_once('include/socgraph.php');
<?php
+
+use Friendica\App;
+
function share_init(App $a) {
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
/**
* @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);
}
}
<?php
+use Friendica\App;
function starred_init(App $a) {
<?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");
$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();
}
<?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()) {
<?php
+use Friendica\App;
+
require_once('include/socgraph.php');
require_once('include/contact_widgets.php');
<?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()) {
<?php
+use Friendica\App;
+
require_once('include/bbcode.php');
function tagrm_post(App $a) {
<?php
+use Friendica\App;
+
function toggle_mobile_init(App $a) {
if (isset($_GET['off'])) {
goaway($address);
}
-
<?php
+use Friendica\App;
+
function uexport_init(App $a) {
- if (! local_user()) {
+ if (!local_user()) {
killme();
}
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();
$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;
$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;
}
}
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(
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";
}
}
<?php\r
+\r
/**\r
* View for user import\r
- * @TODO This file has DOS line endings!\r
*/\r
\r
+use Friendica\App;\r
+\r
require_once("include/uimport.php");\r
\r
function uimport_post(App $a) {\r
- switch($a->config['register_policy']) {\r
- case REGISTER_OPEN:\r
- $blocked = 0;\r
- $verified = 1;\r
- break;\r
+ switch ($a->config['register_policy']) {\r
+ case REGISTER_OPEN:\r
+ $blocked = 0;\r
+ $verified = 1;\r
+ break;\r
\r
- case REGISTER_APPROVE:\r
- $blocked = 1;\r
- $verified = 0;\r
- break;\r
+ case REGISTER_APPROVE:\r
+ $blocked = 1;\r
+ $verified = 0;\r
+ break;\r
\r
- default:\r
- case REGISTER_CLOSED:\r
- if ((! x($_SESSION,'authenticated') && (! x($_SESSION,'administrator')))) {\r
- notice( t('Permission denied.') . EOL );\r
- return;\r
- }\r
- $blocked = 1;\r
- $verified = 0;\r
- break;\r
+ default:\r
+ case REGISTER_CLOSED:\r
+ if ((!x($_SESSION, 'authenticated') && (!x($_SESSION, 'administrator')))) {\r
+ notice(t('Permission denied.') . EOL);\r
+ return;\r
+ }\r
+ $blocked = 1;\r
+ $verified = 0;\r
+ break;\r
}\r
\r
- if (x($_FILES,'accountfile')){\r
+ if (x($_FILES, 'accountfile')) {\r
/// @TODO Pass $blocked / $verified, send email to admin on REGISTER_APPROVE\r
import_account($a, $_FILES['accountfile']);\r
return;\r
\r
function uimport_content(App $a) {\r
\r
- if ((! local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) {\r
+ if ((!local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) {\r
notice("Permission denied." . EOL);\r
return;\r
}\r
\r
- $max_dailies = intval(get_config('system','max_daily_registrations'));\r
+ $max_dailies = intval(get_config('system', 'max_daily_registrations'));\r
if ($max_dailies) {\r
$r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day");\r
if ($r && $r[0]['total'] >= $max_dailies) {\r
logger('max daily registrations exceeded.');\r
- notice( t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL);\r
+ notice(t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL);\r
return;\r
}\r
}\r
\r
\r
- if (x($_SESSION,'theme')) {\r
+ if (x($_SESSION, 'theme')) {\r
unset($_SESSION['theme']);\r
}\r
- if (x($_SESSION,'mobile-theme')) {\r
+ if (x($_SESSION, 'mobile-theme')) {\r
unset($_SESSION['mobile-theme']);\r
}\r
\r
return replace_macros($tpl, array(\r
'$regbutt' => t('Import'),\r
'$import' => array(\r
- 'title' => t("Move account"),\r
- 'intro' => t("You can import an account from another Friendica server."),\r
- '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."),\r
- 'warn' => t("This feature is experimental. We can't import contacts from the OStatus network (GNU Social/Statusnet) or from Diaspora"),\r
- '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"')),\r
+ 'title' => t("Move account"),\r
+ 'intro' => t("You can import an account from another Friendica server."),\r
+ '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."),\r
+ 'warn' => t("This feature is experimental. We can't import contacts from the OStatus network (GNU Social/Statusnet) or from Diaspora"),\r
+ '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"')),\r
),\r
));\r
}\r
// See update_profile.php for documentation
+use Friendica\App;
+
require_once("mod/community.php");
function update_community_content(App $a) {
// See update_profile.php for documentation
+use Friendica\App;
+
require_once("mod/display.php");
require_once("include/group.php");
// See update_profile.php for documentation
+use Friendica\App;
+
require_once("mod/network.php");
require_once("include/group.php");
* Purpose: AJAX synchronisation of notes page
*/
+use Friendica\App;
+
require_once("mod/notes.php");
function update_notes_content(App $a) {
* Purpose: AJAX synchronisation of profile page
*/
+use Friendica\App;
+
require_once("mod/profile.php");
function update_profile_content(App $a) {
<?php
+
+use Friendica\App;
+
require_once('include/items.php');
require_once('include/acl_selectors.php');
require_once('include/bbcode.php');
require_once('include/security.php');
require_once('include/redir.php');
-
function videos_init(App $a) {
if($a->argc > 1)
<?php
+
+use Friendica\App;
+
require_once('include/Contact.php');
require_once('include/contact_selectors.php');
<?php
+use Friendica\App;
function viewsrc_content(App $a) {
<?php
+use Friendica\App;
+
require_once('include/attach.php');
require_once('include/datetime.php');
/**
* @file mod/wall_upload.php
* @brief Module for uploading a picture to the profile wall
- *
+ *
* By default the picture will be stored in the photo album with the name Wall Photos.
* You can specify a different album by adding an optional query string "album="
* to the url
*/
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
require_once 'include/Photo.php';
-
function wall_upload_post(App $a, $desktopmode = true) {
logger("wall upload: starting new upload", LOGGER_DEBUG);
<?php
+use Friendica\App;
+
require_once('include/message.php');
function wallmessage_post(App $a) {
<?php
+
+use Friendica\App;
+
require_once("include/Probe.php");
function webfinger_content(App $a) {
*/
require_once("include/poller.php");
-use \Friendica\Core\Config;
-use \Friendica\Core\PConfig;
+use Friendica\Core\Config;
+use Friendica\Core\PConfig;
function worker_init($a){
<?php
+use Friendica\App;
+
require_once('include/crypto.php');
function xrd_init(App $a) {
/**
* Get the app
- *
+ *
* Same as get_app from boot.php
*/
public function get_app() {
self::$app = $app;
}
}
-?>
$conv = $this->get_conversation();
- $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
+ $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
? t('Private Message')
: false);
if ((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) {
// The author url doesn't match the owner (typically the contact)
- // and also doesn't match the contact alias.
- // The name match is a hack to catch several weird cases where URLs are
+ // and also doesn't match the contact alias.
+ // The name match is a hack to catch several weird cases where URLs are
// all over the park. It can be tricked, but this prevents you from
// seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn
- // well that it's the same Bob Smith.
+ // well that it's the same Bob Smith.
- // But it could be somebody else with the same name. It just isn't highly likely.
+ // But it could be somebody else with the same name. It just isn't highly likely.
$this->owner_photo = $this->get_data_value('owner-avatar');
$this->owner_name = $this->get_data_value('owner-name');
$this->wall_to_wall = true;
// If it is our contact, use a friendly redirect link
- if ((link_compare($this->get_data_value('owner-link'),$this->get_data_value('url')))
+ if ((link_compare($this->get_data_value('owner-link'),$this->get_data_value('url')))
&& ($this->get_data_value('network') === NETWORK_DFRN)) {
$this->owner_url = $this->get_redirect_url();
} else {
}
}
-/// @TODO These are discouraged and should be removed:
-?>
--- /dev/null
+<?php\r
+\r
+namespace Friendica;\r
+\r
+use Friendica\Core\Config;\r
+use Friendica\Core\PConfig;\r
+\r
+/**\r
+ *\r
+ * class: App\r
+ *\r
+ * @brief Our main application structure for the life of this page.\r
+ *\r
+ * Primarily deals with the URL that got us here\r
+ * and tries to make some sense of it, and\r
+ * stores our page contents and config storage\r
+ * and anything else that might need to be passed around\r
+ * before we spit the page out.\r
+ *\r
+ */\r
+class App {\r
+\r
+ public $module_loaded = false;\r
+ public $query_string;\r
+ public $config;\r
+ public $page;\r
+ public $profile;\r
+ public $profile_uid;\r
+ public $user;\r
+ public $cid;\r
+ public $contact;\r
+ public $contacts;\r
+ public $page_contact;\r
+ public $content;\r
+ public $data = array();\r
+ public $error = false;\r
+ public $cmd;\r
+ public $argv;\r
+ public $argc;\r
+ public $module;\r
+ public $pager;\r
+ public $strings;\r
+ public $basepath;\r
+ public $path;\r
+ public $hooks;\r
+ public $timezone;\r
+ public $interactive = true;\r
+ public $plugins;\r
+ public $apps = array();\r
+ public $identities;\r
+ public $is_mobile = false;\r
+ public $is_tablet = false;\r
+ public $is_friendica_app;\r
+ public $performance = array();\r
+ public $callstack = array();\r
+ public $theme_info = array();\r
+ public $backend = true;\r
+ public $nav_sel;\r
+ public $category;\r
+ // Allow themes to control internal parameters\r
+ // by changing App values in theme.php\r
+\r
+ public $sourcename = '';\r
+ public $videowidth = 425;\r
+ public $videoheight = 350;\r
+ public $force_max_items = 0;\r
+ public $theme_thread_allow = true;\r
+ public $theme_events_in_profile = true;\r
+\r
+ /**\r
+ * @brief An array for all theme-controllable parameters\r
+ *\r
+ * Mostly unimplemented yet. Only options 'template_engine' and\r
+ * beyond are used.\r
+ */\r
+ public $theme = array(\r
+ 'sourcename' => '',\r
+ 'videowidth' => 425,\r
+ 'videoheight' => 350,\r
+ 'force_max_items' => 0,\r
+ 'thread_allow' => true,\r
+ 'stylesheet' => '',\r
+ 'template_engine' => 'smarty3',\r
+ );\r
+\r
+ /**\r
+ * @brief An array of registered template engines ('name'=>'class name')\r
+ */\r
+ public $template_engines = array();\r
+\r
+ /**\r
+ * @brief An array of instanced template engines ('name'=>'instance')\r
+ */\r
+ public $template_engine_instance = array();\r
+ public $process_id;\r
+ private $ldelim = array(\r
+ 'internal' => '',\r
+ 'smarty3' => '{{'\r
+ );\r
+ private $rdelim = array(\r
+ 'internal' => '',\r
+ 'smarty3' => '}}'\r
+ );\r
+ private $scheme;\r
+ private $hostname;\r
+ private $db;\r
+ private $curl_code;\r
+ private $curl_content_type;\r
+ private $curl_headers;\r
+ private $cached_profile_image;\r
+ private $cached_profile_picdate;\r
+ private static $a;\r
+\r
+ /**\r
+ * @brief App constructor.\r
+ *\r
+ * @param string $basepath Path to the app base folder\r
+ */\r
+ function __construct($basepath) {\r
+\r
+ global $default_timezone;\r
+\r
+ $hostname = '';\r
+\r
+ if (file_exists('.htpreconfig.php')) {\r
+ include '.htpreconfig.php';\r
+ }\r
+\r
+ $this->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');\r
+\r
+ date_default_timezone_set($this->timezone);\r
+\r
+ $this->performance['start'] = microtime(true);\r
+ $this->performance['database'] = 0;\r
+ $this->performance['database_write'] = 0;\r
+ $this->performance['network'] = 0;\r
+ $this->performance['file'] = 0;\r
+ $this->performance['rendering'] = 0;\r
+ $this->performance['parser'] = 0;\r
+ $this->performance['marktime'] = 0;\r
+ $this->performance['markstart'] = microtime(true);\r
+\r
+ $this->callstack['database'] = array();\r
+ $this->callstack['database_write'] = array();\r
+ $this->callstack['network'] = array();\r
+ $this->callstack['file'] = array();\r
+ $this->callstack['rendering'] = array();\r
+ $this->callstack['parser'] = array();\r
+\r
+ $this->config = array();\r
+ $this->page = array();\r
+ $this->pager = array();\r
+\r
+ $this->query_string = '';\r
+\r
+ $this->process_id = uniqid('log', true);\r
+\r
+ startup();\r
+\r
+ $this->scheme = 'http';\r
+\r
+ if ((x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) ||\r
+ (x($_SERVER, 'HTTP_FORWARDED') && preg_match('/proto=https/', $_SERVER['HTTP_FORWARDED'])) ||\r
+ (x($_SERVER, 'HTTP_X_FORWARDED_PROTO') && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||\r
+ (x($_SERVER, 'HTTP_X_FORWARDED_SSL') && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') ||\r
+ (x($_SERVER, 'FRONT_END_HTTPS') && $_SERVER['FRONT_END_HTTPS'] == 'on') ||\r
+ (x($_SERVER, 'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) // XXX: reasonable assumption, but isn't this hardcoding too much?\r
+ ) {\r
+ $this->scheme = 'https';\r
+ }\r
+\r
+ if (x($_SERVER, 'SERVER_NAME')) {\r
+ $this->hostname = $_SERVER['SERVER_NAME'];\r
+\r
+ if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {\r
+ $this->hostname .= ':' . $_SERVER['SERVER_PORT'];\r
+ }\r
+ /*\r
+ * Figure out if we are running at the top of a domain\r
+ * or in a sub-directory and adjust accordingly\r
+ */\r
+\r
+ /// @TODO This kind of escaping breaks syntax-highlightning on CoolEdit (Midnight Commander)\r
+ $path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');\r
+ if (isset($path) && strlen($path) && ($path != $this->path)) {\r
+ $this->path = $path;\r
+ }\r
+ }\r
+\r
+ if ($hostname != '') {\r
+ $this->hostname = $hostname;\r
+ }\r
+\r
+ if (! static::directory_usable($basepath)) {\r
+ throw new Exception('Basepath ' . $basepath . ' isn\'t usable.');\r
+ }\r
+\r
+ $this->basepath = rtrim($basepath, DIRECTORY_SEPARATOR);\r
+\r
+ set_include_path(\r
+ get_include_path() . PATH_SEPARATOR\r
+ . $this->basepath . DIRECTORY_SEPARATOR . 'include' . PATH_SEPARATOR\r
+ . $this->basepath . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR\r
+ . $this->basepath . DIRECTORY_SEPARATOR . 'library/langdet' . PATH_SEPARATOR\r
+ . $this->basepath);\r
+\r
+\r
+ if (is_array($_SERVER['argv']) && $_SERVER['argc'] > 1 && substr(end($_SERVER['argv']), 0, 4) == 'http') {\r
+ $this->set_baseurl(array_pop($_SERVER['argv']));\r
+ $_SERVER['argc'] --;\r
+ }\r
+\r
+ if ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 9) === 'pagename=') {\r
+ $this->query_string = substr($_SERVER['QUERY_STRING'], 9);\r
+\r
+ // removing trailing / - maybe a nginx problem\r
+ $this->query_string = ltrim($this->query_string, '/');\r
+ } elseif ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === 'q=') {\r
+ $this->query_string = substr($_SERVER['QUERY_STRING'], 2);\r
+\r
+ // removing trailing / - maybe a nginx problem\r
+ $this->query_string = ltrim($this->query_string, '/');\r
+ }\r
+\r
+ if (x($_GET, 'pagename')) {\r
+ $this->cmd = trim($_GET['pagename'], '/\\');\r
+ } elseif (x($_GET, 'q')) {\r
+ $this->cmd = trim($_GET['q'], '/\\');\r
+ }\r
+\r
+ // fix query_string\r
+ $this->query_string = str_replace($this->cmd . '&', $this->cmd . '?', $this->query_string);\r
+\r
+ // unix style "homedir"\r
+ if (substr($this->cmd, 0, 1) === '~') {\r
+ $this->cmd = 'profile/' . substr($this->cmd, 1);\r
+ }\r
+\r
+ // Diaspora style profile url\r
+ if (substr($this->cmd, 0, 2) === 'u/') {\r
+ $this->cmd = 'profile/' . substr($this->cmd, 2);\r
+ }\r
+\r
+ /*\r
+ * Break the URL path into C style argc/argv style arguments for our\r
+ * modules. Given "http://example.com/module/arg1/arg2", $this->argc\r
+ * will be 3 (integer) and $this->argv will contain:\r
+ * [0] => 'module'\r
+ * [1] => 'arg1'\r
+ * [2] => 'arg2'\r
+ *\r
+ *\r
+ * There will always be one argument. If provided a naked domain\r
+ * URL, $this->argv[0] is set to "home".\r
+ */\r
+\r
+ $this->argv = explode('/', $this->cmd);\r
+ $this->argc = count($this->argv);\r
+ if ((array_key_exists('0', $this->argv)) && strlen($this->argv[0])) {\r
+ $this->module = str_replace('.', '_', $this->argv[0]);\r
+ $this->module = str_replace('-', '_', $this->module);\r
+ } else {\r
+ $this->argc = 1;\r
+ $this->argv = array('home');\r
+ $this->module = 'home';\r
+ }\r
+\r
+ // See if there is any page number information, and initialise pagination\r
+ $this->pager['page'] = ((x($_GET, 'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1);\r
+ $this->pager['itemspage'] = 50;\r
+ $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];\r
+\r
+ if ($this->pager['start'] < 0) {\r
+ $this->pager['start'] = 0;\r
+ }\r
+ $this->pager['total'] = 0;\r
+\r
+ // Detect mobile devices\r
+ $mobile_detect = new \Mobile_Detect();\r
+ $this->is_mobile = $mobile_detect->isMobile();\r
+ $this->is_tablet = $mobile_detect->isTablet();\r
+\r
+ // Friendica-Client\r
+ $this->is_friendica_app = ($_SERVER['HTTP_USER_AGENT'] == 'Apache-HttpClient/UNAVAILABLE (java 1.4)');\r
+\r
+ // Register template engines\r
+ $dc = get_declared_classes();\r
+ foreach ($dc as $k) {\r
+ if (in_array('ITemplateEngine', class_implements($k))) {\r
+ $this->register_template_engine($k);\r
+ }\r
+ }\r
+\r
+ self::$a = $this;\r
+ }\r
+\r
+ /**\r
+ * @brief Returns the base filesystem path of the App\r
+ *\r
+ * It first checks for the internal variable, then for DOCUMENT_ROOT and\r
+ * finally for PWD\r
+ *\r
+ * @return string\r
+ */\r
+ public static function get_basepath() {\r
+ if (isset($this)) {\r
+ $basepath = $this->basepath;\r
+ }\r
+\r
+ if (! $basepath) {\r
+ $basepath = Config::get('system', 'basepath');\r
+ }\r
+\r
+ if (! $basepath && x($_SERVER, 'DOCUMENT_ROOT')) {\r
+ $basepath = $_SERVER['DOCUMENT_ROOT'];\r
+ }\r
+\r
+ if (! $basepath && x($_SERVER, 'PWD')) {\r
+ $basepath = $_SERVER['PWD'];\r
+ }\r
+\r
+ return $basepath;\r
+ }\r
+\r
+ function get_scheme() {\r
+ return $this->scheme;\r
+ }\r
+\r
+ /**\r
+ * @brief Retrieves the Friendica instance base URL\r
+ *\r
+ * This function assembles the base URL from multiple parts:\r
+ * - Protocol is determined either by the request or a combination of\r
+ * system.ssl_policy and the $ssl parameter.\r
+ * - Host name is determined either by system.hostname or inferred from request\r
+ * - Path is inferred from SCRIPT_NAME\r
+ *\r
+ * Note: $ssl parameter value doesn't directly correlate with the resulting protocol\r
+ *\r
+ * @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN\r
+ * @return string Friendica server base URL\r
+ */\r
+ function get_baseurl($ssl = false) {\r
+ // Is the function called statically?\r
+ if (!(isset($this) && get_class($this) == __CLASS__)) {\r
+ return self::$a->get_baseurl($ssl);\r
+ }\r
+\r
+ $scheme = $this->scheme;\r
+\r
+ if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) {\r
+ $scheme = 'https';\r
+ }\r
+\r
+ // Basically, we have $ssl = true on any links which can only be seen by a logged in user\r
+ // (and also the login link). Anything seen by an outsider will have it turned off.\r
+\r
+ if (Config::get('system', 'ssl_policy') == SSL_POLICY_SELFSIGN) {\r
+ if ($ssl) {\r
+ $scheme = 'https';\r
+ } else {\r
+ $scheme = 'http';\r
+ }\r
+ }\r
+\r
+ if (Config::get('config', 'hostname') != '') {\r
+ $this->hostname = Config::get('config', 'hostname');\r
+ }\r
+\r
+ return $scheme . '://' . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' );\r
+ }\r
+\r
+ /**\r
+ * @brief Initializes the baseurl components\r
+ *\r
+ * Clears the baseurl cache to prevent inconstistencies\r
+ *\r
+ * @param string $url\r
+ */\r
+ function set_baseurl($url) {\r
+ $parsed = @parse_url($url);\r
+\r
+ if ($parsed) {\r
+ $this->scheme = $parsed['scheme'];\r
+\r
+ $hostname = $parsed['host'];\r
+ if (x($parsed, 'port')) {\r
+ $hostname .= ':' . $parsed['port'];\r
+ }\r
+ if (x($parsed, 'path')) {\r
+ $this->path = trim($parsed['path'], '\\/');\r
+ }\r
+\r
+ if (file_exists('.htpreconfig.php')) {\r
+ include '.htpreconfig.php';\r
+ }\r
+\r
+ if (Config::get('config', 'hostname') != '') {\r
+ $this->hostname = Config::get('config', 'hostname');\r
+ }\r
+\r
+ if (!isset($this->hostname) OR ( $this->hostname == '')) {\r
+ $this->hostname = $hostname;\r
+ }\r
+ }\r
+ }\r
+\r
+ function get_hostname() {\r
+ if (Config::get('config', 'hostname') != '') {\r
+ $this->hostname = Config::get('config', 'hostname');\r
+ }\r
+\r
+ return $this->hostname;\r
+ }\r
+\r
+ function set_hostname($h) {\r
+ $this->hostname = $h;\r
+ }\r
+\r
+ function set_path($p) {\r
+ $this->path = trim(trim($p), '/');\r
+ }\r
+\r
+ function get_path() {\r
+ return $this->path;\r
+ }\r
+\r
+ function set_pager_total($n) {\r
+ $this->pager['total'] = intval($n);\r
+ }\r
+\r
+ function set_pager_itemspage($n) {\r
+ $this->pager['itemspage'] = ((intval($n) > 0) ? intval($n) : 0);\r
+ $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];\r
+ }\r
+\r
+ function set_pager_page($n) {\r
+ $this->pager['page'] = $n;\r
+ $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];\r
+ }\r
+\r
+ function init_pagehead() {\r
+ $interval = ((local_user()) ? PConfig::get(local_user(), 'system', 'update_interval') : 40000);\r
+\r
+ // If the update is 'deactivated' set it to the highest integer number (~24 days)\r
+ if ($interval < 0) {\r
+ $interval = 2147483647;\r
+ }\r
+\r
+ if ($interval < 10000) {\r
+ $interval = 40000;\r
+ }\r
+\r
+ // compose the page title from the sitename and the\r
+ // current module called\r
+ if (!$this->module == '') {\r
+ $this->page['title'] = $this->config['sitename'] . ' (' . $this->module . ')';\r
+ } else {\r
+ $this->page['title'] = $this->config['sitename'];\r
+ }\r
+\r
+ /* put the head template at the beginning of page['htmlhead']\r
+ * since the code added by the modules frequently depends on it\r
+ * being first\r
+ */\r
+ if (!isset($this->page['htmlhead'])) {\r
+ $this->page['htmlhead'] = '';\r
+ }\r
+\r
+ // If we're using Smarty, then doing replace_macros() will replace\r
+ // any unrecognized variables with a blank string. Since we delay\r
+ // replacing $stylesheet until later, we need to replace it now\r
+ // with another variable name\r
+ if ($this->theme['template_engine'] === 'smarty3') {\r
+ $stylesheet = $this->get_template_ldelim('smarty3') . '$stylesheet' . $this->get_template_rdelim('smarty3');\r
+ } else {\r
+ $stylesheet = '$stylesheet';\r
+ }\r
+\r
+ $shortcut_icon = Config::get('system', 'shortcut_icon');\r
+ if ($shortcut_icon == '') {\r
+ $shortcut_icon = 'images/friendica-32.png';\r
+ }\r
+\r
+ $touch_icon = Config::get('system', 'touch_icon');\r
+ if ($touch_icon == '') {\r
+ $touch_icon = 'images/friendica-128.png';\r
+ }\r
+\r
+ // get data wich is needed for infinite scroll on the network page\r
+ $invinite_scroll = infinite_scroll_data($this->module);\r
+\r
+ $tpl = get_markup_template('head.tpl');\r
+ $this->page['htmlhead'] = replace_macros($tpl, array(\r
+ '$baseurl' => $this->get_baseurl(), // FIXME for z_path!!!!\r
+ '$local_user' => local_user(),\r
+ '$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION,\r
+ '$delitem' => t('Delete this item?'),\r
+ '$showmore' => t('show more'),\r
+ '$showfewer' => t('show fewer'),\r
+ '$update_interval' => $interval,\r
+ '$shortcut_icon' => $shortcut_icon,\r
+ '$touch_icon' => $touch_icon,\r
+ '$stylesheet' => $stylesheet,\r
+ '$infinite_scroll' => $invinite_scroll,\r
+ )) . $this->page['htmlhead'];\r
+ }\r
+\r
+ function init_page_end() {\r
+ if (!isset($this->page['end'])) {\r
+ $this->page['end'] = '';\r
+ }\r
+ $tpl = get_markup_template('end.tpl');\r
+ $this->page['end'] = replace_macros($tpl, array(\r
+ '$baseurl' => $this->get_baseurl() // FIXME for z_path!!!!\r
+ )) . $this->page['end'];\r
+ }\r
+\r
+ function set_curl_code($code) {\r
+ $this->curl_code = $code;\r
+ }\r
+\r
+ function get_curl_code() {\r
+ return $this->curl_code;\r
+ }\r
+\r
+ function set_curl_content_type($content_type) {\r
+ $this->curl_content_type = $content_type;\r
+ }\r
+\r
+ function get_curl_content_type() {\r
+ return $this->curl_content_type;\r
+ }\r
+\r
+ function set_curl_headers($headers) {\r
+ $this->curl_headers = $headers;\r
+ }\r
+\r
+ function get_curl_headers() {\r
+ return $this->curl_headers;\r
+ }\r
+\r
+ function get_cached_avatar_image($avatar_image) {\r
+ return $avatar_image;\r
+ }\r
+\r
+ /**\r
+ * @brief Removes the baseurl from an url. This avoids some mixed content problems.\r
+ *\r
+ * @param string $orig_url\r
+ *\r
+ * @return string The cleaned url\r
+ */\r
+ function remove_baseurl($orig_url) {\r
+\r
+ // Is the function called statically?\r
+ if (!(isset($this) && get_class($this) == __CLASS__)) {\r
+ return self::$a->remove_baseurl($orig_url);\r
+ }\r
+\r
+ // Remove the hostname from the url if it is an internal link\r
+ $nurl = normalise_link($orig_url);\r
+ $base = normalise_link($this->get_baseurl());\r
+ $url = str_replace($base . '/', '', $nurl);\r
+\r
+ // if it is an external link return the orignal value\r
+ if ($url == normalise_link($orig_url)) {\r
+ return $orig_url;\r
+ } else {\r
+ return $url;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * @brief Register template engine class\r
+ *\r
+ * If $name is '', is used class static property $class::$name\r
+ *\r
+ * @param string $class\r
+ * @param string $name\r
+ */\r
+ function register_template_engine($class, $name = '') {\r
+ /// @TODO Really === and not just == ?\r
+ if ($name === '') {\r
+ $v = get_class_vars($class);\r
+ if (x($v, 'name'))\r
+ $name = $v['name'];\r
+ }\r
+ if ($name === '') {\r
+ echo "template engine <tt>$class</tt> cannot be registered without a name.\n";\r
+ killme();\r
+ }\r
+ $this->template_engines[$name] = $class;\r
+ }\r
+\r
+ /**\r
+ * @brief Return template engine instance.\r
+ *\r
+ * If $name is not defined, return engine defined by theme,\r
+ * or default\r
+ *\r
+ * @param strin $name Template engine name\r
+ * @return object Template Engine instance\r
+ */\r
+ function template_engine($name = '') {\r
+ /// @TODO really type-check included?\r
+ if ($name !== '') {\r
+ $template_engine = $name;\r
+ } else {\r
+ $template_engine = 'smarty3';\r
+ if (x($this->theme, 'template_engine')) {\r
+ $template_engine = $this->theme['template_engine'];\r
+ }\r
+ }\r
+\r
+ if (isset($this->template_engines[$template_engine])) {\r
+ if (isset($this->template_engine_instance[$template_engine])) {\r
+ return $this->template_engine_instance[$template_engine];\r
+ } else {\r
+ $class = $this->template_engines[$template_engine];\r
+ $obj = new $class;\r
+ $this->template_engine_instance[$template_engine] = $obj;\r
+ return $obj;\r
+ }\r
+ }\r
+\r
+ echo "template engine <tt>$template_engine</tt> is not registered!\n";\r
+ killme();\r
+ }\r
+\r
+ /**\r
+ * @brief Returns the active template engine.\r
+ *\r
+ * @return string\r
+ */\r
+ function get_template_engine() {\r
+ return $this->theme['template_engine'];\r
+ }\r
+\r
+ function set_template_engine($engine = 'smarty3') {\r
+ $this->theme['template_engine'] = $engine;\r
+ }\r
+\r
+ function get_template_ldelim($engine = 'smarty3') {\r
+ return $this->ldelim[$engine];\r
+ }\r
+\r
+ function get_template_rdelim($engine = 'smarty3') {\r
+ return $this->rdelim[$engine];\r
+ }\r
+\r
+ function save_timestamp($stamp, $value) {\r
+ if (!isset($this->config['system']['profiler']) || !$this->config['system']['profiler']) {\r
+ return;\r
+ }\r
+\r
+ $duration = (float) (microtime(true) - $stamp);\r
+\r
+ if (!isset($this->performance[$value])) {\r
+ // Prevent ugly E_NOTICE\r
+ $this->performance[$value] = 0;\r
+ }\r
+\r
+ $this->performance[$value] += (float) $duration;\r
+ $this->performance['marktime'] += (float) $duration;\r
+\r
+ $callstack = $this->callstack();\r
+\r
+ if (!isset($this->callstack[$value][$callstack])) {\r
+ // Prevent ugly E_NOTICE\r
+ $this->callstack[$value][$callstack] = 0;\r
+ }\r
+\r
+ $this->callstack[$value][$callstack] += (float) $duration;\r
+ }\r
+\r
+ /**\r
+ * @brief Log active processes into the "process" table\r
+ */\r
+ function start_process() {\r
+ $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);\r
+\r
+ $command = basename($trace[0]['file']);\r
+\r
+ $this->remove_inactive_processes();\r
+\r
+ q('START TRANSACTION');\r
+\r
+ $r = q('SELECT `pid` FROM `process` WHERE `pid` = %d', intval(getmypid()));\r
+ if (!\dbm::is_result($r)) {\r
+ q("INSERT INTO `process` (`pid`,`command`,`created`) VALUES (%d, '%s', '%s')", intval(getmypid()), dbesc($command), dbesc(datetime_convert()));\r
+ }\r
+ q('COMMIT');\r
+ }\r
+\r
+ /**\r
+ * @brief Remove inactive processes\r
+ */\r
+ function remove_inactive_processes() {\r
+ q('START TRANSACTION');\r
+\r
+ $r = q('SELECT `pid` FROM `process`');\r
+ if (\dbm::is_result($r)) {\r
+ foreach ($r AS $process) {\r
+ if (!posix_kill($process['pid'], 0)) {\r
+ q('DELETE FROM `process` WHERE `pid` = %d', intval($process['pid']));\r
+ }\r
+ }\r
+ }\r
+ q('COMMIT');\r
+ }\r
+\r
+ /**\r
+ * @brief Remove the active process from the "process" table\r
+ */\r
+ function end_process() {\r
+ q('DELETE FROM `process` WHERE `pid` = %d', intval(getmypid()));\r
+ }\r
+\r
+ /**\r
+ * @brief Returns a string with a callstack. Can be used for logging.\r
+ *\r
+ * @return string\r
+ */\r
+ function callstack() {\r
+ $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 6);\r
+\r
+ // We remove the first two items from the list since they contain data that we don't need.\r
+ array_shift($trace);\r
+ array_shift($trace);\r
+\r
+ $callstack = array();\r
+ foreach ($trace AS $func) {\r
+ $callstack[] = $func['function'];\r
+ }\r
+\r
+ return implode(', ', $callstack);\r
+ }\r
+\r
+ function get_useragent() {\r
+ return\r
+ FRIENDICA_PLATFORM . " '" .\r
+ FRIENDICA_CODENAME . "' " .\r
+ FRIENDICA_VERSION . '-' .\r
+ DB_UPDATE_VERSION . '; ' .\r
+ $this->get_baseurl();\r
+ }\r
+\r
+ function is_friendica_app() {\r
+ return $this->is_friendica_app;\r
+ }\r
+\r
+ /**\r
+ * @brief Checks if the site is called via a backend process\r
+ *\r
+ * This isn't a perfect solution. But we need this check very early.\r
+ * So we cannot wait until the modules are loaded.\r
+ *\r
+ * @return bool Is it a known backend?\r
+ */\r
+ function is_backend() {\r
+ static $backends = array();\r
+ $backends[] = '_well_known';\r
+ $backends[] = 'api';\r
+ $backends[] = 'dfrn_notify';\r
+ $backends[] = 'fetch';\r
+ $backends[] = 'hcard';\r
+ $backends[] = 'hostxrd';\r
+ $backends[] = 'nodeinfo';\r
+ $backends[] = 'noscrape';\r
+ $backends[] = 'p';\r
+ $backends[] = 'poco';\r
+ $backends[] = 'post';\r
+ $backends[] = 'proxy';\r
+ $backends[] = 'pubsub';\r
+ $backends[] = 'pubsubhubbub';\r
+ $backends[] = 'receive';\r
+ $backends[] = 'rsd_xml';\r
+ $backends[] = 'salmon';\r
+ $backends[] = 'statistics_json';\r
+ $backends[] = 'xrd';\r
+\r
+ // Check if current module is in backend or backend flag is set\r
+ return (in_array($this->module, $backends) || $this->backend);\r
+ }\r
+\r
+ /**\r
+ * @brief Checks if the maximum number of database processes is reached\r
+ *\r
+ * @return bool Is the limit reached?\r
+ */\r
+ function max_processes_reached() {\r
+\r
+ if ($this->is_backend()) {\r
+ $process = 'backend';\r
+ $max_processes = Config::get('system', 'max_processes_backend');\r
+ if (intval($max_processes) == 0) {\r
+ $max_processes = 5;\r
+ }\r
+ } else {\r
+ $process = 'frontend';\r
+ $max_processes = Config::get('system', 'max_processes_frontend');\r
+ if (intval($max_processes) == 0) {\r
+ $max_processes = 20;\r
+ }\r
+ }\r
+\r
+ $processlist = \dbm::processlist();\r
+ if ($processlist['list'] != '') {\r
+ logger('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], LOGGER_DEBUG);\r
+\r
+ if ($processlist['amount'] > $max_processes) {\r
+ logger('Processcheck: Maximum number of processes for ' . $process . ' tasks (' . $max_processes . ') reached.', LOGGER_DEBUG);\r
+ return true;\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ * @brief Checks if the minimal memory is reached\r
+ *\r
+ * @return bool Is the memory limit reached?\r
+ */\r
+ public function min_memory_reached() {\r
+ $min_memory = Config::get('system', 'min_memory', 0);\r
+ if ($min_memory == 0) {\r
+ return false;\r
+ }\r
+\r
+ if (!is_readable('/proc/meminfo')) {\r
+ return false;\r
+ }\r
+\r
+ $memdata = explode("\n", file_get_contents('/proc/meminfo'));\r
+\r
+ $meminfo = array();\r
+ foreach ($memdata as $line) {\r
+ list($key, $val) = explode(':', $line);\r
+ $meminfo[$key] = (int) trim(str_replace('kB', '', $val));\r
+ $meminfo[$key] = (int) ($meminfo[$key] / 1024);\r
+ }\r
+\r
+ if (!isset($meminfo['MemAvailable']) OR ! isset($meminfo['MemFree'])) {\r
+ return false;\r
+ }\r
+\r
+ $free = $meminfo['MemAvailable'] + $meminfo['MemFree'];\r
+\r
+ $reached = ($free < $min_memory);\r
+\r
+ if ($reached) {\r
+ logger('Minimal memory reached: ' . $free . '/' . $meminfo['MemTotal'] . ' - limit ' . $min_memory, LOGGER_DEBUG);\r
+ }\r
+\r
+ return $reached;\r
+ }\r
+\r
+ /**\r
+ * @brief Checks if the maximum load is reached\r
+ *\r
+ * @return bool Is the load reached?\r
+ */\r
+ function maxload_reached() {\r
+\r
+ if ($this->is_backend()) {\r
+ $process = 'backend';\r
+ $maxsysload = intval(Config::get('system', 'maxloadavg'));\r
+ if ($maxsysload < 1) {\r
+ $maxsysload = 50;\r
+ }\r
+ } else {\r
+ $process = 'frontend';\r
+ $maxsysload = intval(Config::get('system', 'maxloadavg_frontend'));\r
+ if ($maxsysload < 1) {\r
+ $maxsysload = 50;\r
+ }\r
+ }\r
+\r
+ $load = current_load();\r
+ if ($load) {\r
+ if (intval($load) > $maxsysload) {\r
+ logger('system: load ' . $load . ' for ' . $process . ' tasks (' . $maxsysload . ') too high.');\r
+ return true;\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ function proc_run($args) {\r
+\r
+ if (!function_exists('proc_open')) {\r
+ return;\r
+ }\r
+\r
+ // If the last worker fork was less than 10 seconds before then don't fork another one.\r
+ // This should prevent the forking of masses of workers.\r
+ $cachekey = 'app:proc_run:started';\r
+ $result = \Cache::get($cachekey);\r
+\r
+ if (!is_null($result) AND ( time() - $result) < 10) {\r
+ return;\r
+ }\r
+\r
+ // Set the timestamp of the last proc_run\r
+ \Cache::set($cachekey, time(), CACHE_MINUTE);\r
+\r
+ array_unshift($args, ((x($this->config, 'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php'));\r
+\r
+ // add baseurl to args. cli scripts can't construct it\r
+ $args[] = $this->get_baseurl();\r
+\r
+ for ($x = 0; $x < count($args); $x ++) {\r
+ $args[$x] = escapeshellarg($args[$x]);\r
+ }\r
+\r
+ $cmdline = implode($args, ' ');\r
+\r
+ if ($this->min_memory_reached()) {\r
+ return;\r
+ }\r
+\r
+ if (Config::get('system', 'proc_windows')) {\r
+ $resource = proc_open('cmd /c start /b ' . $cmdline, array(), $foo, $this->get_basepath());\r
+ } else {\r
+ $resource = proc_open($cmdline . ' &', array(), $foo, $this->get_basepath());\r
+ }\r
+ if (!is_resource($resource)) {\r
+ logger('We got no resource for command ' . $cmdline, LOGGER_DEBUG);\r
+ return;\r
+ }\r
+ proc_close($resource);\r
+ }\r
+\r
+ /**\r
+ * @brief Returns the system user that is executing the script\r
+ *\r
+ * This mostly returns something like "www-data".\r
+ *\r
+ * @return string system username\r
+ */\r
+ static function systemuser() {\r
+ if (!function_exists('posix_getpwuid') OR ! function_exists('posix_geteuid')) {\r
+ return '';\r
+ }\r
+\r
+ $processUser = posix_getpwuid(posix_geteuid());\r
+ return $processUser['name'];\r
+ }\r
+\r
+ /**\r
+ * @brief Checks if a given directory is usable for the system\r
+ *\r
+ * @return boolean the directory is usable\r
+ */\r
+ static function directory_usable($directory) {\r
+ if ($directory == '') {\r
+ logger('Directory is empty. This shouldn\'t happen.', LOGGER_DEBUG);\r
+ return false;\r
+ }\r
+\r
+ if (!file_exists($directory)) {\r
+ logger('Path "' . $directory . '" does not exist for user ' . self::systemuser(), LOGGER_DEBUG);\r
+ return false;\r
+ }\r
+ if (is_file($directory)) {\r
+ logger('Path "' . $directory . '" is a file for user ' . self::systemuser(), LOGGER_DEBUG);\r
+ return false;\r
+ }\r
+ if (!is_dir($directory)) {\r
+ logger('Path "' . $directory . '" is not a directory for user ' . self::systemuser(), LOGGER_DEBUG);\r
+ return false;\r
+ }\r
+ if (!is_writable($directory)) {\r
+ logger('Path "' . $directory . '" is not writable for user ' . self::systemuser(), LOGGER_DEBUG);\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+}\r
namespace Friendica;
-use \Friendica\Core\Config;
+use Friendica\Core\Config;
require_once("include/network.php");
require_once("include/Photo.php");
<?php
/**
* tests several functions which are used to prevent xss attacks
- *
+ *
* @package test.util
*/
*/
public function testXmlify() {
$text="<tag>I want to break\n this!11!<?hard?></tag>";
- $xml=xmlify($text);
+ $xml=xmlify($text);
$retext=unxmlify($text);
$this->assertEquals($text, $retext);
}
-
- /**\r
- * xmlify and put in a document\r
- */\r
- public function testXmlifyDocument() {\r
- $tag="<tag>I want to break</tag>";\r
+
+ /**
+ * xmlify and put in a document
+ */
+ public function testXmlifyDocument() {
+ $tag="<tag>I want to break</tag>";
$xml=xmlify($tag);
- $text='<text>'.$xml.'</text>'; \r
-
- $xml_parser=xml_parser_create();
+ $text='<text>'.$xml.'</text>';
+
+ $xml_parser=xml_parser_create();
//should be possible to parse it
- $values=array(); $index=array();
- $this->assertEquals(1, xml_parse_into_struct($xml_parser, $text, $values, $index));
-
- $this->assertEquals(array('TEXT'=>array(0)),
- $index);
- $this->assertEquals(array(array('tag'=>'TEXT', 'type'=>'complete', 'level'=>1, 'value'=>$tag)),\r
+ $values=array(); $index=array();
+ $this->assertEquals(1, xml_parse_into_struct($xml_parser, $text, $values, $index));
+
+ $this->assertEquals(array('TEXT'=>array(0)),
+ $index);
+ $this->assertEquals(array(array('tag'=>'TEXT', 'type'=>'complete', 'level'=>1, 'value'=>$tag)),
$values);
-
- xml_parser_free($xml_parser); \r
+
+ xml_parser_free($xml_parser);
}
/**
//get_mentions
//get_contact_block, bis Zeile 538
}
-?>
// Now sleep for 5 minutes
sleep(300);
}
-?>
<?php
+
/**
-* @package util
-*/
+ * @package util
+ */
+
+use Friendica\App;
-/*
-* require boot.php
-*/
+/*
+ * require boot.php
+ */
require_once("boot.php");
-$a = new App;
+$a = new App(dirname(__DIR__));
@include(".htconfig.php");
$lang = get_browser_language();
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data, false);
- unset($db_host, $db_user, $db_pass, $db_data);
+unset($db_host, $db_user, $db_pass, $db_data);
-$build = get_config('system','build');
+$build = get_config('system', 'build');
echo "Old DB VERSION: " . $build . "\n";
echo "New DB VERSION: " . DB_UPDATE_VERSION . "\n";
-if($build != DB_UPDATE_VERSION) {
+if ($build != DB_UPDATE_VERSION) {
echo "Updating database...";
check_db($a);
echo "Done\n";
<?php
-use \Friendica\Core\Config;
+use Friendica\App;
+use Friendica\Core\Config;
require_once("boot.php");
-$a = new App;
+$a = new App(dirname(__DIR__));
@include(".htconfig.php");
$lang = get_browser_language();
<?php
- /**
- * Read strings.php file and create messages.po
- *
- * php utils/php2po.php <path/to/strings.php>
- *
- * Output to <path/to/messages.po>
- */
-
- DEFINE("NORM_REGEXP", "|[\\\]|");
-
-
- if(! class_exists('App')) {
- class TmpA {
- public $strings = Array();
- }
- $a = new TmpA();
- }
+/**
+ * Read strings.php file and create messages.po
+ *
+ * php utils/php2po.php <path/to/strings.php>
+ *
+ * Output to <path/to/messages.po>
+ */
- if ($argc<2 || in_array('-h', $argv) || in_array('--h', $argv)) {
- print "Usage: ".$argv[0]." [-p <n>] <strings.php>\n\n";
- print "Options:\n";
- print "p\tNumber of plural forms. Default: 2\n";
- print "\n";
- return;
- }
+use Friendica\App;
- $phpfile = $argv[1];
- $pofile = dirname($phpfile)."/messages.po";
+DEFINE("NORM_REGEXP", "|[\\\]|");
- if (!file_exists($phpfile)){
- print "Unable to find '$phpfile'\n";
- return;
+if(! class_exists('App')) {
+ class TmpA {
+ public $strings = Array();
}
+ $a = new TmpA();
+}
- // utility functions
- function startsWith($haystack, $needle) {
- // search backwards starting from haystack length characters from the end
- return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;
- }
+if ($argc<2 || in_array('-h', $argv) || in_array('--h', $argv)) {
+ print "Usage: ".$argv[0]." [-p <n>] <strings.php>\n\n";
+ print "Options:\n";
+ print "p\tNumber of plural forms. Default: 2\n";
+ print "\n";
+ return;
+}
+
+$phpfile = $argv[1];
+$pofile = dirname($phpfile)."/messages.po";
+
+if (!file_exists($phpfile)){
+ print "Unable to find '$phpfile'\n";
+ return;
+}
+// utility functions
+function startsWith($haystack, $needle) {
+ // search backwards starting from haystack length characters from the end
+ return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;
+}
- // start !
- include_once($phpfile);
-
- $out = '';
- $out .= "# FRIENDICA Distributed Social Network\n";
- $out .= "# Copyright (C) 2010, 2011, 2012, 2013 the Friendica Project\n";
- $out .= "# This file is distributed under the same license as the Friendica package.\n";
- $out .= "# \n";
- $out .= 'msgid ""' ."\n";
- $out .= 'msgstr ""' ."\n";
- $out .= '"Project-Id-Version: friendica\n"' ."\n";
- $out .= '"Report-Msgid-Bugs-To: \n"' ."\n";
- $out .= '"POT-Creation-Date: '. date("Y-m-d H:i:sO").'\n"' ."\n";
- $out .= '"MIME-Version: 1.0\n"' ."\n";
- $out .= '"Content-Type: text/plain; charset=UTF-8\n"' ."\n";
- $out .= '"Content-Transfer-Encoding: 8bit\n"' ."\n";
-
- // search for plural info
- $lang = "";
- $lang_logic = "";
- $lang_pnum = 2;
-
- $_idx = array_search('-p', $argv);
- if ($_idx !== false) {
- $lang_pnum = $argv[$_idx+1];
+
+// start !
+include_once($phpfile);
+
+$out = '';
+$out .= "# FRIENDICA Distributed Social Network\n";
+$out .= "# Copyright (C) 2010, 2011, 2012, 2013 the Friendica Project\n";
+$out .= "# This file is distributed under the same license as the Friendica package.\n";
+$out .= "# \n";
+$out .= 'msgid ""' ."\n";
+$out .= 'msgstr ""' ."\n";
+$out .= '"Project-Id-Version: friendica\n"' ."\n";
+$out .= '"Report-Msgid-Bugs-To: \n"' ."\n";
+$out .= '"POT-Creation-Date: '. date("Y-m-d H:i:sO").'\n"' ."\n";
+$out .= '"MIME-Version: 1.0\n"' ."\n";
+$out .= '"Content-Type: text/plain; charset=UTF-8\n"' ."\n";
+$out .= '"Content-Transfer-Encoding: 8bit\n"' ."\n";
+
+// search for plural info
+$lang = "";
+$lang_logic = "";
+$lang_pnum = 2;
+
+$_idx = array_search('-p', $argv);
+if ($_idx !== false) {
+ $lang_pnum = $argv[$_idx+1];
+}
+
+$infile = file($phpfile);
+foreach($infile as $l) {
+ $l = trim($l);
+ if (startsWith($l, 'function string_plural_select_')) {
+ $lang = str_replace( 'function string_plural_select_' , '', str_replace( '($n){','', $l) );
}
-
- $infile = file($phpfile);
- foreach($infile as $l) {
- $l = trim($l);
- if (startsWith($l, 'function string_plural_select_')) {
- $lang = str_replace( 'function string_plural_select_' , '', str_replace( '($n){','', $l) );
- }
- if (startsWith($l, 'return')) {
- $lang_logic = str_replace( '$', '', trim( str_replace( 'return ' , '', $l) , ';') );
- break;
- }
+ if (startsWith($l, 'return')) {
+ $lang_logic = str_replace( '$', '', trim( str_replace( 'return ' , '', $l) , ';') );
+ break;
}
-
- echo "Language: $lang\n";
- echo "Plural forms: $lang_pnum\n";
- echo "Plural logic: $lang_logic;\n";
-
- $out .= sprintf('"Language: %s\n"', $lang) ."\n";
- $out .= sprintf('"Plural-Forms: nplurals=%s; plural=%s;\n"', $lang_pnum, $lang_logic) ."\n";
- $out .= "\n";
+}
- print "\nLoading base message.po...";
-
- // load base messages.po and extract msgids
- $base_msgids = array();
- $norm_base_msgids = array();
- $base_f = file("util/messages.po") or die("No base messages.po\n");
- $_f = 0; $_mid = ""; $_mids = array();
- foreach( $base_f as $l) {
- $l = trim($l);
- //~ print $l."\n";
-
- if (startsWith($l, 'msgstr')) {
- if ($_mid != '""') {
- $base_msgids[$_mid] = $_mids;
- $norm_base_msgids[preg_replace(NORM_REGEXP, "", $_mid)] = $_mid;
- //~ print "\t\t\t".$_mid. print_r($base_msgids[$_mid], true);
- }
-
- $_f = 0;
- $_mid = "";
- $_mids = array();
-
- }
-
- if (startsWith($l, '"') && $_f==2) {
- $_mids[count($_mids)-1] .= "\n".$l;
- //~ print "\t\t+mids: ".print_t($_mids, true);
- }
- if (startsWith($l, 'msgid_plural ')) {
- $_f = 2;
- $_mids[] = str_replace('msgid_plural ', '' , $l);
- //~ print "\t\t mids: ".print_r($_mids, true);
- }
-
- if (startsWith($l, '"') && $_f==1) {
- $_mid .= "\n".$l;
- $_mids[count($_mids)-1] .= "\n".$l;
- //~ print "\t+mid: $_mid \n";
- }
- if (startsWith($l, 'msgid ')) {
- $_f = 1;
- $_mid = str_replace('msgid ', '' , $l);
- $_mids = array($_mid);
- //~ print "\t mid: $_mid \n";
+echo "Language: $lang\n";
+echo "Plural forms: $lang_pnum\n";
+echo "Plural logic: $lang_logic;\n";
+
+$out .= sprintf('"Language: %s\n"', $lang) ."\n";
+$out .= sprintf('"Plural-Forms: nplurals=%s; plural=%s;\n"', $lang_pnum, $lang_logic) ."\n";
+$out .= "\n";
+
+print "\nLoading base message.po...";
+
+// load base messages.po and extract msgids
+$base_msgids = array();
+$norm_base_msgids = array();
+$base_f = file("util/messages.po") or die("No base messages.po\n");
+$_f = 0; $_mid = ""; $_mids = array();
+foreach( $base_f as $l) {
+ $l = trim($l);
+ //~ print $l."\n";
+
+ if (startsWith($l, 'msgstr')) {
+ if ($_mid != '""') {
+ $base_msgids[$_mid] = $_mids;
+ $norm_base_msgids[preg_replace(NORM_REGEXP, "", $_mid)] = $_mid;
+ //~ print "\t\t\t".$_mid. print_r($base_msgids[$_mid], true);
}
- //~ print "\t\t\t\t$_f\n\n";
+
+ $_f = 0;
+ $_mid = "";
+ $_mids = array();
+
}
-
- print " done\n";
- print "Creating '$pofile'...";
- // create msgid and msgstr
-
- /**
- * Get a string and retun a message.po ready text
- * - replace " with \"
- * - replace tab char with \t
- * - manage multiline strings
- */
- function massage_string($str) {
- $str = str_replace('\\','\\\\',$str);
- $str = str_replace('"','\"',$str);
- $str = str_replace("\t",'\t',$str);
- $str = str_replace("\n",'\n"'."\n".'"',$str);
- if (strpos($str, "\n")!==false && $str[0]!=='"') $str = '"'."\n".$str;
- $str = preg_replace("|\n([^\"])|", "\n\"$1", $str);
- return sprintf('"%s"', $str);
+
+ if (startsWith($l, '"') && $_f==2) {
+ $_mids[count($_mids)-1] .= "\n".$l;
+ //~ print "\t\t+mids: ".print_t($_mids, true);
}
-
- function find_original_msgid($str) {
- global $norm_base_msgids;
- $norm_str = preg_replace(NORM_REGEXP, "", $str);
- if (array_key_exists($norm_str, $norm_base_msgids)) {
- return $norm_base_msgids[$norm_str];
- }
- return $str;
+ if (startsWith($l, 'msgid_plural ')) {
+ $_f = 2;
+ $_mids[] = str_replace('msgid_plural ', '' , $l);
+ //~ print "\t\t mids: ".print_r($_mids, true);
}
-
- $warnings = "";
- foreach($a->strings as $key=>$str) {
- $msgid = massage_string($key);
-
- if (preg_match("|%[sd0-9](\$[sn])*|", $msgid)) {
- $out .= "#, php-format\n";
- }
- $msgid = find_original_msgid($msgid);
- $out .= 'msgid '. $msgid . "\n";
-
- if (is_array($str)) {
- if (array_key_exists($msgid, $base_msgids) && isset($base_msgids[$msgid][1])) {
- $out .= 'msgid_plural '. $base_msgids[$msgid][1] . "\n";
- } else {
- $out .= 'msgid_plural '. $msgid . "\n";
- $warnings .= "[W] No source plural form for msgid:\n". str_replace("\n","\n\t", $msgid) . "\n\n";
- }
- foreach ( $str as $n => $msgstr) {
- $out .= 'msgstr['.$n.'] '. massage_string($msgstr) . "\n";
- }
- } else {
- $out .= 'msgstr '. massage_string($str) . "\n";
- }
-
- $out .= "\n";
-
+
+ if (startsWith($l, '"') && $_f==1) {
+ $_mid .= "\n".$l;
+ $_mids[count($_mids)-1] .= "\n".$l;
+ //~ print "\t+mid: $_mid \n";
}
+ if (startsWith($l, 'msgid ')) {
+ $_f = 1;
+ $_mid = str_replace('msgid ', '' , $l);
+ $_mids = array($_mid);
+ //~ print "\t mid: $_mid \n";
+ }
+ //~ print "\t\t\t\t$_f\n\n";
+}
+
+print " done\n";
+print "Creating '$pofile'...";
+// create msgid and msgstr
+
+/**
+ * Get a string and retun a message.po ready text
+ * - replace " with \"
+ * - replace tab char with \t
+ * - manage multiline strings
+ */
+function massage_string($str) {
+ $str = str_replace('\\','\\\\',$str);
+ $str = str_replace('"','\"',$str);
+ $str = str_replace("\t",'\t',$str);
+ $str = str_replace("\n",'\n"'."\n".'"',$str);
+ if (strpos($str, "\n")!==false && $str[0]!=='"') $str = '"'."\n".$str;
+ $str = preg_replace("|\n([^\"])|", "\n\"$1", $str);
+ return sprintf('"%s"', $str);
+}
+
+function find_original_msgid($str) {
+ global $norm_base_msgids;
+ $norm_str = preg_replace(NORM_REGEXP, "", $str);
+ if (array_key_exists($norm_str, $norm_base_msgids)) {
+ return $norm_base_msgids[$norm_str];
+ }
+ return $str;
+}
+
+$warnings = "";
+foreach($a->strings as $key=>$str) {
+ $msgid = massage_string($key);
- file_put_contents($pofile, $out);
-
- print " done\n";
-
- if ($warnings=="") {
- print "No warnings.\n";
+ if (preg_match("|%[sd0-9](\$[sn])*|", $msgid)) {
+ $out .= "#, php-format\n";
+ }
+ $msgid = find_original_msgid($msgid);
+ $out .= 'msgid '. $msgid . "\n";
+
+ if (is_array($str)) {
+ if (array_key_exists($msgid, $base_msgids) && isset($base_msgids[$msgid][1])) {
+ $out .= 'msgid_plural '. $base_msgids[$msgid][1] . "\n";
+ } else {
+ $out .= 'msgid_plural '. $msgid . "\n";
+ $warnings .= "[W] No source plural form for msgid:\n". str_replace("\n","\n\t", $msgid) . "\n\n";
+ }
+ foreach ( $str as $n => $msgstr) {
+ $out .= 'msgstr['.$n.'] '. massage_string($msgstr) . "\n";
+ }
} else {
- print $warnings;
+ $out .= 'msgstr '. massage_string($str) . "\n";
}
-
+
+ $out .= "\n";
+
+}
+
+file_put_contents($pofile, $out);
+
+print " done\n";
+
+if ($warnings=="") {
+ print "No warnings.\n";
+} else {
+ print $warnings;
+}
+#!/usr/bin/env php
<?php
- // Tired of chasing typos and finding them after a commit.
- // Run this from cmdline in basedir and quickly see if we've
- // got any parse errors in our application files.
+// Tired of chasing typos and finding them after a commit.
+// Run this from cmdline in basedir and quickly see if we've
+// got any parse errors in our application files.
- error_reporting(E_ERROR | E_WARNING | E_PARSE );
- ini_set('display_errors', '1');
- ini_set('log_errors','0');
+use Friendica\App;
- include 'boot.php';
+error_reporting(E_ERROR | E_WARNING | E_PARSE);
+ini_set('display_errors', '1');
+ini_set('log_errors', '0');
- $a = new App();
+include 'boot.php';
- if(x($a->config,'php_path'))
- $phpath = $a->config['php_path'];
- else
- $phpath = 'php';
+$a = new App(dirname(__DIR__));
+if (x($a->config, 'php_path')) {
+ $phpath = $a->config['php_path'];
+} else {
+ $phpath = 'php';
+}
- echo "Directory: mod\n";
- $files = glob('mod/*.php');
- foreach($files as $file) {
- passthru("$phpath -l $file", $ret); $ret===0 or die();
- }
+echo 'Directory: src' . PHP_EOL;
+$Iterator = new RecursiveDirectoryIterator('src');
- echo "Directory: include\n";
- $files = glob('include/*.php');
- foreach($files as $file) {
- passthru("$phpath -l $file", $ret); $ret===0 or die();
+foreach (new RecursiveIteratorIterator($Iterator) as $file) {
+ if (substr($file, -4) === '.php') {
+ passthru("$phpath -l $file", $ret);
+ $ret === 0 or die();
}
+}
- echo "Directory: object\n";
- $files = glob('object/*.php');
- foreach($files as $file) {
- passthru("$phpath -l $file", $ret); $ret===0 or die();
- }
+echo "Directory: mod\n";
+$files = glob('mod/*.php');
+foreach ($files as $file) {
+ passthru("$phpath -l $file", $ret);
+ $ret === 0 or die();
+}
- echo "Directory: addon\n";
- $dirs = glob('addon/*');
+echo "Directory: include\n";
+$files = glob('include/*.php');
+foreach ($files as $file) {
+ passthru("$phpath -l $file", $ret);
+ $ret === 0 or die();
+}
- foreach($dirs as $dir) {
- $addon = basename($dir);
- $files = glob($dir . '/' . $addon . '.php');
- foreach($files as $file) {
- passthru("$phpath -l $file", $ret); $ret===0 or die();
- }
- }
+echo "Directory: object\n";
+$files = glob('object/*.php');
+foreach ($files as $file) {
+ passthru("$phpath -l $file", $ret);
+ $ret === 0 or die();
+}
+echo "Directory: addon\n";
+$dirs = glob('addon/*');
- echo "String files\n";
+foreach ($dirs as $dir) {
+ $addon = basename($dir);
+ $files = glob($dir . '/' . $addon . '.php');
+ foreach ($files as $file) {
+ passthru("$phpath -l $file", $ret);
+ $ret === 0 or die();
+ }
+}
- echo 'util/strings.php' . "\n";
- passthru("$phpath -l util/strings.php", $ret); $ret===0 or die();
+echo "String files\n";
- $files = glob('view/lang/*/strings.php');
- foreach($files as $file) {
- passthru("$phpath -l $file", $ret); $ret===0 or die();
- }
+echo 'util/strings.php' . "\n";
+passthru("$phpath -l util/strings.php", $ret);
+$ret === 0 or die();
+
+$files = glob('view/lang/*/strings.php');
+foreach ($files as $file) {
+ passthru("$phpath -l $file", $ret);
+ $ret === 0 or die();
+}
'Archive_Tar' => $vendorDir . '/pear-pear.php.net/Archive_Tar/Archive/Tar.php',
'Console_Getopt' => $vendorDir . '/pear-pear.php.net/Console_Getopt/Console/Getopt.php',
'Detection\\MobileDetect' => $vendorDir . '/mobiledetect/mobiledetectlib/namespaced/Detection/MobileDetect.php',
+ 'Friendica\\App' => $baseDir . '/src/App.php',
'Friendica\\Core\\Config' => $baseDir . '/src/Core/Config.php',
'Friendica\\Core\\PConfig' => $baseDir . '/src/Core/PConfig.php',
'Friendica\\ParseUrl' => $baseDir . '/src/ParseUrl.php',
'Archive_Tar' => __DIR__ . '/..' . '/pear-pear.php.net/Archive_Tar/Archive/Tar.php',
'Console_Getopt' => __DIR__ . '/..' . '/pear-pear.php.net/Console_Getopt/Console/Getopt.php',
'Detection\\MobileDetect' => __DIR__ . '/..' . '/mobiledetect/mobiledetectlib/namespaced/Detection/MobileDetect.php',
+ 'Friendica\\App' => __DIR__ . '/../..' . '/src/App.php',
'Friendica\\Core\\Config' => __DIR__ . '/../..' . '/src/Core/Config.php',
'Friendica\\Core\\PConfig' => __DIR__ . '/../..' . '/src/Core/PConfig.php',
'Friendica\\ParseUrl' => __DIR__ . '/../..' . '/src/ParseUrl.php',
$vendorDir . '/pear-pear.php.net/Structures_Graph',
$vendorDir . '/pear-pear.php.net/XML_Util',
$vendorDir . '/pear-pear.php.net/XML_Parser',
- $vendorDir . '/pear-pear.php.net/PEAR',
$vendorDir . '/pear-pear.php.net/Text_Highlighter',
+ $vendorDir . '/pear-pear.php.net/PEAR',
);
],
"description": "This is an XML parser based on PHPs built-in xml extension.\nIt supports two basic modes of operation: \"func\" and \"event\". In \"func\" mode, it will look for a function named after each element (xmltag_ELEMENT for start tags and xmltag_ELEMENT_ for end tags), and in \"event\" mode it uses a set of generic callbacks.\n\nSince version 1.2.0 there's a new XML_Parser_Simple class that makes parsing of most XML documents easier, by automatically providing a stack for the elements.\nFurthermore its now possible to split the parser from the handler object, so you do not have to extend XML_Parser anymore in order to parse a document with it."
},
- {
- "name": "pear-pear.php.net/PEAR",
- "version": "1.10.3",
- "version_normalized": "1.10.3.0",
- "dist": {
- "type": "file",
- "url": "https://pear.php.net/get/PEAR-1.10.3.tgz",
- "reference": null,
- "shasum": null
- },
- "require": {
- "ext-pcre": "*",
- "ext-xml": "*",
- "pear-pear.php.net/archive_tar": ">=1.4.0.0",
- "pear-pear.php.net/console_getopt": ">=1.4.1.0",
- "pear-pear.php.net/structures_graph": ">=1.1.0.0",
- "pear-pear.php.net/xml_util": ">=1.3.0.0",
- "php": ">=5.4.0.0"
- },
- "conflict": {
- "pear-pear.php.net/pear_frontend_gtk": "<0.4.0.0",
- "pear-pear.php.net/pear_frontend_web": "<=0.4.0.0"
- },
- "replace": {
- "pear-pear/pear": "== 1.10.3.0"
- },
- "type": "pear-library",
- "installation-source": "dist",
- "autoload": {
- "classmap": [
- ""
- ]
- },
- "include-path": [
- "/"
- ],
- "license": [
- "New BSD License"
- ],
- "description": "The PEAR package contains:\n * the PEAR installer, for creating, distributing\n and installing packages\n * the PEAR_Exception PHP5 error handling mechanism\n * the PEAR_ErrorStack advanced error handling mechanism\n * the PEAR_Error error handling mechanism\n * the OS_Guess class for retrieving info about the OS\n where PHP is running on\n * the System class for quick handling of common operations\n with files and directories\n * the PEAR base class\n Features in a nutshell:\n * full support for channels\n * pre-download dependency validation\n * new package.xml 2.0 format allows tremendous flexibility while maintaining BC\n * support for optional dependency groups and limited support for sub-packaging\n * robust dependency support\n * full dependency validation on uninstall\n * remote install for hosts with only ftp access - no more problems with\n restricted host installation\n * full support for mirroring\n * support for bundling several packages into a single tarball\n * support for static dependencies on a url-based package\n * support for custom file roles and installation tasks"
- },
{
"name": "pear-pear.php.net/Text_Highlighter",
"version": "0.8.0",
"html",
"markdown"
]
+ },
+ {
+ "name": "pear-pear.php.net/PEAR",
+ "version": "1.10.4",
+ "version_normalized": "1.10.4.0",
+ "dist": {
+ "type": "file",
+ "url": "https://pear.php.net/get/PEAR-1.10.4.tgz",
+ "reference": null,
+ "shasum": null
+ },
+ "require": {
+ "ext-pcre": "*",
+ "ext-xml": "*",
+ "pear-pear.php.net/archive_tar": ">=1.4.0.0",
+ "pear-pear.php.net/console_getopt": ">=1.4.1.0",
+ "pear-pear.php.net/structures_graph": ">=1.1.0.0",
+ "pear-pear.php.net/xml_util": ">=1.3.0.0",
+ "php": ">=5.4.0.0"
+ },
+ "conflict": {
+ "pear-pear.php.net/pear_frontend_gtk": "<0.4.0.0",
+ "pear-pear.php.net/pear_frontend_web": "<=0.4.0.0"
+ },
+ "replace": {
+ "pear-pear/pear": "== 1.10.4.0"
+ },
+ "type": "pear-library",
+ "installation-source": "dist",
+ "autoload": {
+ "classmap": [
+ ""
+ ]
+ },
+ "include-path": [
+ "/"
+ ],
+ "license": [
+ "New BSD License"
+ ],
+ "description": "The PEAR package contains:\n * the PEAR installer, for creating, distributing\n and installing packages\n * the PEAR_Exception PHP5 error handling mechanism\n * the PEAR_ErrorStack advanced error handling mechanism\n * the PEAR_Error error handling mechanism\n * the OS_Guess class for retrieving info about the OS\n where PHP is running on\n * the System class for quick handling of common operations\n with files and directories\n * the PEAR base class\n Features in a nutshell:\n * full support for channels\n * pre-download dependency validation\n * new package.xml 2.0 format allows tremendous flexibility while maintaining BC\n * support for optional dependency groups and limited support for sub-packaging\n * robust dependency support\n * full dependency validation on uninstall\n * remote install for hosts with only ftp access - no more problems with\n restricted host installation\n * full support for mirroring\n * support for bundling several packages into a single tarball\n * support for static dependencies on a url-based package\n * support for custom file roles and installation tasks"
}
]
* @author Gregory Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2006 The PHP Group
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @see PEAR_Error
* @since Class available since PHP 4.0.2
$destructor = "_$classname";
if (method_exists($this, $destructor)) {
global $_PEAR_destructor_object_list;
- $_PEAR_destructor_object_list[] = &$this;
+ $_PEAR_destructor_object_list[] = $this;
if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
register_shutdown_function("_PEAR_call_destructors");
$GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
protected static function _throwError($object, $message = null, $code = null, $userinfo = null)
{
if ($object !== null) {
- $a = &$object->raiseError($message, $code, null, null, $userinfo);
+ $a = $object->raiseError($message, $code, null, null, $userinfo);
return $a;
}
- $a = &PEAR::raiseError($message, $code, null, null, $userinfo);
+ $a = PEAR::raiseError($message, $code, null, null, $userinfo);
return $a;
}
* @author Gregory Beaver <cellog@php.net>
* @copyright 1997-2006 The PHP Group
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/manual/en/core.pear.pear-error.php
* @see PEAR::raiseError(), PEAR::throwError()
* @since Class available since PHP 4.0.2
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since PHP 4.0.2
* @see http://pear.php.net/manual/en/core.ppm.pear-builder.php
if (!file_exists($build_dir) || !is_dir($build_dir) || !chdir($build_dir)) {
return $this->raiseError("could not chdir to $build_dir");
}
- putenv('PHP_PEAR_VERSION=1.10.3');
+ putenv('PHP_PEAR_VERSION=1.10.4');
foreach ($to_run as $cmd) {
$err = $this->_runCommand($cmd, $callback);
if (PEAR::isError($err)) {
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
* @deprecated since 1.8.0alpha1
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
$pkg = &$param->getPackageFile();
if ($info->getCode() != PEAR_INSTALLER_NOBINARY) {
if (!($info = $pkg->installBinary($this->installer))) {
- $this->ui->outputData('ERROR: ' .$oldinfo->getMessage());
- continue;
+ return $this->raiseError('ERROR: ' .$oldinfo->getMessage());
}
// we just installed a different package than requested,
* @author Alexander Merz <alexmerz@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.2.0
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 2005-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
* @deprecated This class will disappear, and its components will be spread
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
*/
function getPEARVersion()
{
- return '1.10.3';
+ return '1.10.4';
}
function validatePearinstallerDependency($dep)
* @author Tomas V.V.Cox <cox@idec.net.com>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Martin Jansen <mj@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.3.0
*/
}
$request .= $ifmodifiedsince .
- "User-Agent: PEAR/1.10.3/PHP/" . PHP_VERSION . "\r\n";
+ "User-Agent: PEAR/1.10.4/PHP/" . PHP_VERSION . "\r\n";
if ($object !== null) { // only pass in authentication for non-static calls
$username = $config->get('username', null, $channel);
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* $local_stack = new PEAR_ErrorStack('MyPackage');
* </code>
* @author Greg Beaver <cellog@php.net>
- * @version 1.10.3
+ * @version 1.10.4
* @package PEAR_ErrorStack
* @category Debugging
* @copyright 2004-2008 Greg Beaver
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.3.3
*
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 2007-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.7.0
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2006 The PHP Group
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Hannes Magnusson <bjori@php.net>
* @copyright 2011 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.10.0
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 2007-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.7.0
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
function getPackagerVersion()
{
- return '1.10.3';
+ return '1.10.4';
}
/**
);
$ret = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
$ret .= "<!DOCTYPE package SYSTEM \"http://pear.php.net/dtd/package-1.0\">\n";
- $ret .= "<package version=\"1.0\" packagerversion=\"1.10.3\">\n" .
+ $ret .= "<package version=\"1.0\" packagerversion=\"1.10.4\">\n" .
" <name>$pkginfo[package]</name>";
if (isset($pkginfo['extends'])) {
$ret .= "\n<extends>$pkginfo[extends]</extends>";
* @author Stephan Schmidt (original XML_Serializer code)
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
*/
function getPackagerVersion()
{
- return '1.10.3';
+ return '1.10.4';
}
/**
$this->options['beautifyFilelist'] = true;
}
- $arr['attribs']['packagerversion'] = '1.10.3';
+ $arr['attribs']['packagerversion'] = '1.10.4';
if ($this->serialize($arr, $options)) {
return $this->_serializedData . "\n";
}
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
if ($dtype == 'pearinstaller' && $nopearinstaller) {
continue;
}
- if (!isset($deps[0])) {
+ if ((is_array($deps) && !isset($deps[0])) || !is_array($deps)) {
$deps = array($deps);
}
foreach ($deps as $dep) {
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a8
* @access private
isset($test['dependencies']['required']) &&
isset($test['dependencies']['required']['pearinstaller']) &&
isset($test['dependencies']['required']['pearinstaller']['min']) &&
- '1.10.3' != '@package' . '_version@' &&
- version_compare('1.10.3',
+ '1.10.4' != '@package' . '_version@' &&
+ version_compare('1.10.4',
$test['dependencies']['required']['pearinstaller']['min'], '<')
) {
$this->_pearVersionTooLow($test['dependencies']['required']['pearinstaller']['min']);
$this->_stack->push(__FUNCTION__, 'error',
array('version' => $version),
'This package.xml requires PEAR version %version% to parse properly, we are ' .
- 'version 1.10.3');
+ 'version 1.10.4');
}
function _invalidTagOrder($oktags, $actual, $root)
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a8
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
}
$request .= $ifmodifiedsince .
- "User-Agent: PEAR/1.10.3/PHP/" . PHP_VERSION . "\r\n";
+ "User-Agent: PEAR/1.10.4/PHP/" . PHP_VERSION . "\r\n";
$username = $this->config->get('username', null, $channel);
$password = $this->config->get('password', null, $channel);
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a12
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.3
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a12
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.3.3
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
* @abstract
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a10
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a10
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a10
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a10
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a5
*/
* @author Stephan Schmidt (original XML_Unserializer code)
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license New BSD License
- * @version Release: 1.10.3
+ * @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
* @author Tomas V.V. Cox <cox@idecnet.com>
* @copyright 1997-2006 The PHP Group
* @license http://opensource.org/licenses/bsd-license.php New BSD License
-* @version Release: 1.10.3
+* @version Release: 1.10.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
* @static
$_PEAR_PHPDIR = '#$%^&*';
set_error_handler('error_handler');
-$pear_package_version = "1.10.3";
+$pear_package_version = "1.10.4";
require_once 'PEAR.php';
require_once 'PEAR/Frontend.php';
<html itemscope itemtype="http://schema.org/Blog" lang="<?php echo $lang; ?>">\r
<head>\r
<title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
- <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
+ <script>var baseurl="<?php echo Friendica\App::get_baseurl() ?>";</script>\r
<?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
</head>\r
<body>\r
<html>\r
<head>\r
<title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
- <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
+ <script>var baseurl="<?php echo Friendica\App::get_baseurl() ?>";</script>\r
<?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
</head>\r
<body>\r
<?php
+
/**
* Theme settings
*/
+use Friendica\App;
+
function theme_content(App $a) {
if (!local_user()) {
return;
$s_colorset = get_config('duepuntozero','colorset');
$colorset = get_pconfig( $uid, 'duepuntozero', 'colorset');
-if (!x($colorset))
+if (!x($colorset))
$colorset = $s_colorset;
if ($colorset) {
}
echo $setcss;
-
-?>
<?php
+use Friendica\App;
+
function duepuntozero_init(App $a) {
set_template_engine($a, 'smarty3');
<?php
+
+use Friendica\App;
+
require_once('view/theme/frio/php/Image.php');
function theme_content(App $a) {
code {
white-space: pre-wrap;
}
-.help-content-wrapper code {display: inline}
+.help-content-wrapper code, .help-aside-wrapper code {display: inline}
/*
* standard page elements
<head>
<title><?php if(x($page,'title')) echo $page['title'] ?></title>
<meta request="<?php echo htmlspecialchars($_REQUEST['pagename']) ?>">
- <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>
+ <script>var baseurl="<?php echo Friendica\App::get_baseurl() ?>";</script>
<script>var frio="<?php echo "view/theme/frio"; ?>";</script>
- <?php $baseurl = App::get_baseurl(); ?>
+ <?php $baseurl = Friendica\App::get_baseurl(); ?>
<?php $frio = "view/theme/frio"; ?>
- <?php
+ <?php
// Because we use minimal for modals the header and the included js stuff should be only loaded
// if the page is an standard page (so we don't have it twice for modals)
- //
+ //
/// @todo Think about to move js stuff in the footer
if(!$minimal) {
if(x($page,'htmlhead')) echo $page['htmlhead'];
/**
* @file view/theme/frio/php/frio_boot.php
*
- * @brief This file contains functions for page contstruction
+ * @brief This file contains functions for page construction
*
*/
+use Friendica\App;
/**
* @brief Load page template in dependence of the template mode
<title><?php if(x($page,'title')) echo $page['title'] ?></title>
<meta name="viewport" content="initial-scale=1.0">
<meta request="<?php echo htmlspecialchars($_REQUEST['pagename']) ?>">
- <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>
+ <script>var baseurl="<?php echo Friendica\App::get_baseurl() ?>";</script>
<script>var frio="<?php echo "view/theme/frio"; ?>";</script>
- <?php $baseurl = App::get_baseurl(); ?>
+ <?php $baseurl = Friendica\App::get_baseurl(); ?>
<?php $frio = "view/theme/frio"; ?>
<?php if(x($page,'htmlhead')) echo $page['htmlhead']; ?>
</head>
*
*/
+use Friendica\App;
+
$frio = "view/theme/frio";
global $frio;
* Additionally the profile, status and photo page links will be changed
* to don't open in a new tab if the contact is a friendica contact.
*
- * @param app $a The app data
+ * @param App $a The app data
* @param array $args Contains contact data and the original photo_menu
*/
function frio_contact_photo_menu(App $a, &$args){
* Some links will point to the local pages because the user would expect
* local page (these pages are: search, community, help, apps, directory).
*
- * @param app $a The App class
+ * @param App $a The App class
* @param array $nav The original nav menu
*/
function frio_remote_nav($a,&$nav) {
* @param App $a The app data @TODO Unused
* @param array $results The array with the originals from acl_lookup()
*/
-function frio_acl_lookup($a, &$results) {
+function frio_acl_lookup(App $a, &$results) {
require_once("mod/contacts.php");
$nets = ((x($_GET,"nets")) ? notags(trim($_GET["nets"])) : "");
<html lang="<?php echo $lang; ?>">\r
<head>\r
<title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
- <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
+ <script>var baseurl="<?php echo Friendica\App::get_baseurl() ?>";</script>\r
<?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
</head>\r
<body <?php if($a->module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>>\r
* Maintainer: Zach P <techcity@f.shmuz.in>
*/
+use Friendica\App;
+
function frost_mobile_init(App $a) {
$a->sourcename = 'Friendica mobile web';
$a->videowidth = 250;
<html lang="<?php echo $lang; ?>">\r
<head>\r
<title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
- <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
+ <script>var baseurl="<?php echo Friendica\App::get_baseurl() ?>";</script>\r
<?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
</head>\r
<body <?php if($a->module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>>\r
* Maintainer: Zach P <techcity@f.shmuz.in>
*/
+use Friendica\App;
+
function frost_init(App $a) {
$a->videowidth = 400;
$a->videoheight = 330;
<?php
+
/**
* Theme settings
*/
+use Friendica\App;
+
function theme_content(App $a) {
if (!local_user()) {
return;
* Maintainer: Tobias <https://diekershoff.homeunix.net/friendica/profile/tobias>
*/
+use Friendica\App;
+
function quattro_init(App $a) {
$a->page['htmlhead'] .= '<script src="'.App::get_baseurl().'/view/theme/quattro/tinycon.min.js"></script>';
$a->page['htmlhead'] .= '<script src="'.App::get_baseurl().'/view/theme/quattro/js/quattro.js"></script>';;
<html>
<head>
<title><?php if(x($page,'title')) echo $page['title'] ?></title>
- <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>
+ <script>var baseurl="<?php echo Friendica\App::get_baseurl() ?>";</script>
<script type="text/javascript">
function ScrollToBottom(){
window.scrollTo(0,document.body.scrollHeight);
* Screenshot: <a href="screenshot.png">Screenshot</a>
*/
+use Friendica\App;
+
function smoothly_init(App $a) {
set_template_engine($a, 'smarty3');
$cssFile = null;
$ssl_state = null;
$baseurl = App::get_baseurl($ssl_state);
-$a->page['htmlhead'] .= <<< EOT
+ $a->page['htmlhead'] .= <<< EOT
<script>
function insertFormatting(BBcode, id) {
</script>
EOT;
- /** custom css **/
+ /** custom css **/
if (!is_null($cssFile)) {
$a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile);
}
-_js_in_foot();
-
+ _js_in_foot();
}
if (! function_exists('_js_in_foot')) {
<?php
+
/**
* Theme settings
*/
-
+use Friendica\App;
function theme_content(App $a) {
if (!local_user()) {
* Description: "Vier" is a very compact and modern theme. It uses the font awesome font library: http://fortawesome.github.com/Font-Awesome/
*/
+use Friendica\App;
+
require_once "include/plugin.php";
require_once "include/socgraph.php";
require_once "mod/proxy.php";