diff --git a/boot.php b/boot.php index 45029fecd..5815b8db1 100644 --- a/boot.php +++ b/boot.php @@ -1,4 +1,5 @@ \r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); - /** * @brief Image storage quality. * @@ -61,8 +62,8 @@ define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); * below about 50 * */ - define ( 'JPEG_QUALITY', 100 ); + /** * $a->config['system']['png_quality'] from 0 (uncompressed) to 9 */ @@ -86,12 +87,10 @@ define ( 'PNG_QUALITY', 8 ); */ define ( 'MAX_IMAGE_LENGTH', -1 ); - /** * Not yet used */ - -define ( 'DEFAULT_DB_ENGINE', 'MyISAM' ); +define ( 'DEFAULT_DB_ENGINE', 'InnoDB' ); /** * @name SSL Policy @@ -165,7 +164,6 @@ define ( 'UPDATE_SUCCESS', 0); define ( 'UPDATE_FAILED', 1); /** @}*/ - /** * @name page/profile types * @@ -291,20 +289,16 @@ $netgroup_ids = array( NETWORK_PHANTOM => (-127), ); - /** * Maximum number of "people who like (or don't like) this" that we will list by name */ - define ( 'MAX_LIKERS', 75); /** * Communication timeout */ - define ( 'ZCURL_TIMEOUT' , (-1)); - /** * @name Notify * @@ -345,8 +339,6 @@ define ( 'TERM_CONVERSATION', 7 ); define ( 'TERM_OBJ_POST', 1 ); define ( 'TERM_OBJ_PHOTO', 2 ); - - /** * @name Namespaces * @@ -458,14 +450,13 @@ define('SR_SCOPE_TAGS', 'tags'); /** * Lowest possible date time value */ - define ('NULL_DATE', '0001-01-01 00:00:00'); - // Normally this constant is defined - but not if "pcntl" isn't installed if (!defined("SIGTERM")) { define("SIGTERM", 15); } + /** * * Reverse the effect of magic_quotes_gpc if it is enabled. @@ -473,9 +464,7 @@ if (!defined("SIGTERM")) { * See http://php.net/manual/en/security.magicquotes.disabling.php * */ - function startup() { - error_reporting(E_ERROR | E_WARNING | E_PARSE); set_time_limit(0); @@ -483,7 +472,6 @@ function startup() { // This has to be quite large to deal with embedded private photos ini_set('pcre.backtrack_limit', 500000); - if (get_magic_quotes_gpc()) { $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); while (list($key, $val) = each($process)) { @@ -499,989 +487,6 @@ function startup() { } unset($process); } - -} - -/** - * - * class: App - * - * @brief Our main application structure for the life of this page. - * - * Primarily deals with the URL that got us here - * and tries to make some sense of it, and - * stores our page contents and config storage - * and anything else that might need to be passed around - * before we spit the page out. - * - */ -class App { - - /// @TODO decide indending as a colorful mixure is ahead ... - public $module_loaded = false; - public $query_string; - public $config; - public $page; - public $profile; - public $profile_uid; - public $user; - public $cid; - public $contact; - public $contacts; - public $page_contact; - public $content; - public $data = array(); - public $error = false; - public $cmd; - public $argv; - public $argc; - public $module; - public $pager; - public $strings; - public $path; - public $hooks; - public $timezone; - public $interactive = true; - public $plugins; - public $apps = array(); - public $identities; - public $is_mobile = false; - public $is_tablet = false; - public $is_friendica_app; - public $performance = array(); - public $callstack = array(); - public $theme_info = array(); - public $backend = true; - - public $nav_sel; - - public $category; - - - // Allow themes to control internal parameters - // by changing App values in theme.php - - public $sourcename = ''; - public $videowidth = 425; - public $videoheight = 350; - public $force_max_items = 0; - public $theme_thread_allow = true; - public $theme_events_in_profile = true; - - /** - * @brief An array for all theme-controllable parameters - * - * Mostly unimplemented yet. Only options 'template_engine' and - * beyond are used. - */ - public $theme = array( - 'sourcename' => '', - 'videowidth' => 425, - 'videoheight' => 350, - 'force_max_items' => 0, - 'thread_allow' => true, - 'stylesheet' => '', - 'template_engine' => 'smarty3', - ); - - /** - * @brief An array of registered template engines ('name'=>'class name') - */ - public $template_engines = array(); - /** - * @brief An array of instanced template engines ('name'=>'instance') - */ - public $template_engine_instance = array(); - - public $process_id; - - private $ldelim = array( - 'internal' => '', - 'smarty3' => '{{' - ); - private $rdelim = array( - 'internal' => '', - 'smarty3' => '}}' - ); - - private $scheme; - private $hostname; - private $db; - - private $curl_code; - private $curl_content_type; - private $curl_headers; - - private $cached_profile_image; - private $cached_profile_picdate; - - private static $a; - - /** - * @brief App constructor. - */ - function __construct() { - - global $default_timezone; - - $hostname = ""; - - if (file_exists(".htpreconfig.php")) { - include ".htpreconfig.php"; - } - - $this->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC'); - - date_default_timezone_set($this->timezone); - - $this->performance["start"] = microtime(true); - $this->performance["database"] = 0; - $this->performance["database_write"] = 0; - $this->performance["network"] = 0; - $this->performance["file"] = 0; - $this->performance["rendering"] = 0; - $this->performance["parser"] = 0; - $this->performance["marktime"] = 0; - $this->performance["markstart"] = microtime(true); - - $this->callstack["database"] = array(); - $this->callstack["database_write"] = array(); - $this->callstack["network"] = array(); - $this->callstack["file"] = array(); - $this->callstack["rendering"] = array(); - $this->callstack["parser"] = array(); - - $this->config = array(); - $this->page = array(); - $this->pager= array(); - - $this->query_string = ''; - - $this->process_id = uniqid("log", true); - - startup(); - - set_include_path( - get_include_path() . PATH_SEPARATOR - . 'include' . PATH_SEPARATOR - . 'library' . PATH_SEPARATOR - . 'library/langdet' . PATH_SEPARATOR - . '.' ); - - $this->scheme = 'http'; - - if ((x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) || - (x($_SERVER, 'HTTP_FORWARDED') && preg_match("/proto=https/", $_SERVER['HTTP_FORWARDED'])) || - (x($_SERVER, 'HTTP_X_FORWARDED_PROTO') && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') || - (x($_SERVER, 'HTTP_X_FORWARDED_SSL') && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') || - (x($_SERVER, 'FRONT_END_HTTPS') && $_SERVER['FRONT_END_HTTPS'] == 'on') || - (x($_SERVER, 'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) // XXX: reasonable assumption, but isn't this hardcoding too much? - ) { - $this->scheme = 'https'; - } - - if (x($_SERVER, 'SERVER_NAME')) { - $this->hostname = $_SERVER['SERVER_NAME']; - - if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) { - $this->hostname .= ':' . $_SERVER['SERVER_PORT']; - } - /* - * Figure out if we are running at the top of a domain - * or in a sub-directory and adjust accordingly - */ - - /// @TODO This kind of escaping breaks syntax-highlightning on CoolEdit (Midnight Commander) - $path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\'); - if (isset($path) && strlen($path) && ($path != $this->path)) { - $this->path = $path; - } - } - - if ($hostname != "") { - $this->hostname = $hostname; - } - - if (is_array($_SERVER["argv"]) && $_SERVER["argc"] > 1 && substr(end($_SERVER["argv"]), 0, 4) == "http" ) { - $this->set_baseurl(array_pop($_SERVER["argv"])); - $_SERVER["argc"] --; - } - - if ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 9) === "pagename=") { - $this->query_string = substr($_SERVER['QUERY_STRING'], 9); - - // removing trailing / - maybe a nginx problem - $this->query_string = ltrim($this->query_string, '/'); - } elseif ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") { - $this->query_string = substr($_SERVER['QUERY_STRING'], 2); - - // removing trailing / - maybe a nginx problem - $this->query_string = ltrim($this->query_string, '/'); - } - - if (x($_GET, 'pagename')) { - $this->cmd = trim($_GET['pagename'], '/\\'); - } elseif (x($_GET, 'q')) { - $this->cmd = trim($_GET['q'], '/\\'); - } - - - // fix query_string - $this->query_string = str_replace($this->cmd . "&", $this->cmd . "?", $this->query_string); - - // unix style "homedir" - if (substr($this->cmd, 0, 1) === '~') { - $this->cmd = 'profile/' . substr($this->cmd, 1); - } - - // Diaspora style profile url - if (substr($this->cmd, 0, 2) === 'u/') { - $this->cmd = 'profile/' . substr($this->cmd, 2); - } - - - /* - * Break the URL path into C style argc/argv style arguments for our - * modules. Given "http://example.com/module/arg1/arg2", $this->argc - * will be 3 (integer) and $this->argv will contain: - * [0] => 'module' - * [1] => 'arg1' - * [2] => 'arg2' - * - * - * There will always be one argument. If provided a naked domain - * URL, $this->argv[0] is set to "home". - */ - - $this->argv = explode('/', $this->cmd); - $this->argc = count($this->argv); - if ((array_key_exists('0', $this->argv)) && strlen($this->argv[0])) { - $this->module = str_replace(".", "_", $this->argv[0]); - $this->module = str_replace("-", "_", $this->module); - } else { - $this->argc = 1; - $this->argv = array('home'); - $this->module = 'home'; - } - - /* - * See if there is any page number information, and initialise - * pagination - */ - - $this->pager['page'] = ((x($_GET, 'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1); - $this->pager['itemspage'] = 50; - $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage']; - - if ($this->pager['start'] < 0) { - $this->pager['start'] = 0; - } - $this->pager['total'] = 0; - - /* - * Detect mobile devices - */ - - $mobile_detect = new Mobile_Detect(); - $this->is_mobile = $mobile_detect->isMobile(); - $this->is_tablet = $mobile_detect->isTablet(); - - // Friendica-Client - $this->is_friendica_app = ($_SERVER['HTTP_USER_AGENT'] == "Apache-HttpClient/UNAVAILABLE (java 1.4)"); - - /* - * register template engines - */ - $dc = get_declared_classes(); - foreach ($dc as $k) { - if (in_array("ITemplateEngine", class_implements($k))){ - $this->register_template_engine($k); - } - } - - self::$a = $this; - - } - - public static function get_basepath() { - - $basepath = get_config("system", "basepath"); - - if ($basepath == "") { - $basepath = dirname(__FILE__); - } - - if ($basepath == "") { - $basepath = $_SERVER["DOCUMENT_ROOT"]; - } - - if ($basepath == "") { - $basepath = $_SERVER["PWD"]; - } - - return $basepath; - } - - function get_scheme() { - return $this->scheme; - } - - /** - * @brief Retrieves the Friendica instance base URL - * - * This function assembles the base URL from multiple parts: - * - Protocol is determined either by the request or a combination of - * system.ssl_policy and the $ssl parameter. - * - Host name is determined either by system.hostname or inferred from request - * - Path is inferred from SCRIPT_NAME - * - * Note: $ssl parameter value doesn't directly correlate with the resulting protocol - * - * @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN - * @return string Friendica server base URL - */ - function get_baseurl($ssl = false) { - - // Is the function called statically? - if (!(isset($this) && get_class($this) == __CLASS__)) { - return self::$a->get_baseurl($ssl); - } - - $scheme = $this->scheme; - - if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) { - $scheme = 'https'; - } - - // Basically, we have $ssl = true on any links which can only be seen by a logged in user - // (and also the login link). Anything seen by an outsider will have it turned off. - - if (Config::get('system', 'ssl_policy') == SSL_POLICY_SELFSIGN) { - if ($ssl) { - $scheme = 'https'; - } else { - $scheme = 'http'; - } - } - - if (Config::get('config', 'hostname') != '') { - $this->hostname = Config::get('config', 'hostname'); - } - - return $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); - } - - /** - * @brief Initializes the baseurl components - * - * Clears the baseurl cache to prevent inconstistencies - * - * @param string $url - */ - function set_baseurl($url) { - $parsed = @parse_url($url); - - if ($parsed) { - $this->scheme = $parsed['scheme']; - - $hostname = $parsed['host']; - if (x($parsed, 'port')) { - $hostname .= ':' . $parsed['port']; - } - if (x($parsed, 'path')) { - $this->path = trim($parsed['path'], '\\/'); - } - - if (file_exists(".htpreconfig.php")) { - include ".htpreconfig.php"; - } - - if (get_config('config', 'hostname') != '') { - $this->hostname = get_config('config', 'hostname'); - } - - if (!isset($this->hostname) OR ($this->hostname == '')) { - $this->hostname = $hostname; - } - } - } - - function get_hostname() { - if (get_config('config', 'hostname') != "") { - $this->hostname = get_config('config', 'hostname'); - } - - return $this->hostname; - } - - function set_hostname($h) { - $this->hostname = $h; - } - - function set_path($p) { - $this->path = trim(trim($p), '/'); - } - - function get_path() { - return $this->path; - } - - function set_pager_total($n) { - $this->pager['total'] = intval($n); - } - - function set_pager_itemspage($n) { - $this->pager['itemspage'] = ((intval($n) > 0) ? intval($n) : 0); - $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage']; - } - - function set_pager_page($n) { - $this->pager['page'] = $n; - $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage']; - } - - function init_pagehead() { - $interval = ((local_user()) ? get_pconfig(local_user(),'system','update_interval') : 40000); - - // If the update is "deactivated" set it to the highest integer number (~24 days) - if ($interval < 0) { - $interval = 2147483647; - } - - if ($interval < 10000) { - $interval = 40000; - } - - // compose the page title from the sitename and the - // current module called - if (!$this->module == '') { - $this->page['title'] = $this->config['sitename'] . ' (' . $this->module . ')'; - } else { - $this->page['title'] = $this->config['sitename']; - } - - /* put the head template at the beginning of page['htmlhead'] - * since the code added by the modules frequently depends on it - * being first - */ - if (!isset($this->page['htmlhead'])) { - $this->page['htmlhead'] = ''; - } - - // If we're using Smarty, then doing replace_macros() will replace - // any unrecognized variables with a blank string. Since we delay - // replacing $stylesheet until later, we need to replace it now - // with another variable name - if ($this->theme['template_engine'] === 'smarty3') { - $stylesheet = $this->get_template_ldelim('smarty3') . '$stylesheet' . $this->get_template_rdelim('smarty3'); - } else { - $stylesheet = '$stylesheet'; - } - - $shortcut_icon = get_config("system", "shortcut_icon"); - if ($shortcut_icon == "") { - $shortcut_icon = "images/friendica-32.png"; - } - - $touch_icon = get_config("system", "touch_icon"); - if ($touch_icon == "") { - $touch_icon = "images/friendica-128.png"; - } - - // get data wich is needed for infinite scroll on the network page - $invinite_scroll = infinite_scroll_data($this->module); - - $tpl = get_markup_template('head.tpl'); - $this->page['htmlhead'] = replace_macros($tpl,array( - '$baseurl' => $this->get_baseurl(), // FIXME for z_path!!!! - '$local_user' => local_user(), - '$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION, - '$delitem' => t('Delete this item?'), - '$showmore' => t('show more'), - '$showfewer' => t('show fewer'), - '$update_interval' => $interval, - '$shortcut_icon' => $shortcut_icon, - '$touch_icon' => $touch_icon, - '$stylesheet' => $stylesheet, - '$infinite_scroll' => $invinite_scroll, - )) . $this->page['htmlhead']; - } - - function init_page_end() { - if (!isset($this->page['end'])) { - $this->page['end'] = ''; - } - $tpl = get_markup_template('end.tpl'); - $this->page['end'] = replace_macros($tpl,array( - '$baseurl' => $this->get_baseurl() // FIXME for z_path!!!! - )) . $this->page['end']; - } - - function set_curl_code($code) { - $this->curl_code = $code; - } - - function get_curl_code() { - return $this->curl_code; - } - - function set_curl_content_type($content_type) { - $this->curl_content_type = $content_type; - } - - function get_curl_content_type() { - return $this->curl_content_type; - } - - function set_curl_headers($headers) { - $this->curl_headers = $headers; - } - - function get_curl_headers() { - return $this->curl_headers; - } - - function get_cached_avatar_image($avatar_image){ - return $avatar_image; - } - - - /** - * @brief Removes the baseurl from an url. This avoids some mixed content problems. - * - * @param string $orig_url - * - * @return string The cleaned url - */ - function remove_baseurl($orig_url){ - - // Is the function called statically? - if (!(isset($this) && get_class($this) == __CLASS__)) { - return self::$a->remove_baseurl($orig_url); - } - - // Remove the hostname from the url if it is an internal link - $nurl = normalise_link($orig_url); - $base = normalise_link($this->get_baseurl()); - $url = str_replace($base."/", "", $nurl); - - // if it is an external link return the orignal value - if ($url == normalise_link($orig_url)) { - return $orig_url; - } else { - return $url; - } - } - - /** - * @brief Register template engine class - * - * If $name is "", is used class static property $class::$name - * - * @param string $class - * @param string $name - */ - function register_template_engine($class, $name = '') { - /// @TODO Really === and not just == ? - if ($name === "") { - $v = get_class_vars( $class ); - if (x($v,"name")) $name = $v['name']; - } - if ($name === "") { - echo "template engine $class 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 $template_engine is not registered!\n"; killme(); - } - - /** - * @brief Returns the active template engine. - * - * @return string - */ - function get_template_engine() { - return $this->theme['template_engine']; - } - - function set_template_engine($engine = 'smarty3') { - $this->theme['template_engine'] = $engine; - } - - function get_template_ldelim($engine = 'smarty3') { - return $this->ldelim[$engine]; - } - - function get_template_rdelim($engine = 'smarty3') { - return $this->rdelim[$engine]; - } - - function save_timestamp($stamp, $value) { - if (!isset($this->config['system']['profiler']) || !$this->config['system']['profiler']) { - return; - } - - $duration = (float)(microtime(true)-$stamp); - - if (!isset($this->performance[$value])) { - // Prevent ugly E_NOTICE - $this->performance[$value] = 0; - } - - $this->performance[$value] += (float)$duration; - $this->performance["marktime"] += (float)$duration; - - $callstack = $this->callstack(); - - if (!isset($this->callstack[$value][$callstack])) { - // Prevent ugly E_NOTICE - $this->callstack[$value][$callstack] = 0; - } - - $this->callstack[$value][$callstack] += (float)$duration; - - } - - /** - * @brief Log active processes into the "process" table - */ - function start_process() { - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1); - - $command = basename($trace[0]["file"]); - - $this->remove_inactive_processes(); - - q("START TRANSACTION"); - - $r = q("SELECT `pid` FROM `process` WHERE `pid` = %d", intval(getmypid())); - if (!dbm::is_result($r)) { - q("INSERT INTO `process` (`pid`,`command`,`created`) VALUES (%d, '%s', '%s')", - intval(getmypid()), - dbesc($command), - dbesc(datetime_convert())); - } - q("COMMIT"); - } - - /** - * @brief Remove inactive processes - */ - function remove_inactive_processes() { - q("START TRANSACTION"); - - $r = q("SELECT `pid` FROM `process`"); - if (dbm::is_result($r)) { - foreach ($r AS $process) { - if (!posix_kill($process["pid"], 0)) { - q("DELETE FROM `process` WHERE `pid` = %d", intval($process["pid"])); - } - } - } - q("COMMIT"); - } - - /** - * @brief Remove the active process from the "process" table - */ - function end_process() { - q("DELETE FROM `process` WHERE `pid` = %d", intval(getmypid())); - } - - /** - * @brief Returns a string with a callstack. Can be used for logging. - * - * @return string - */ - function callstack() { - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 6); - - // We remove the first two items from the list since they contain data that we don't need. - array_shift($trace); - array_shift($trace); - - $callstack = array(); - foreach ($trace AS $func) { - $callstack[] = $func["function"]; - } - - return implode(", ", $callstack); - } - - function get_useragent() { - return - FRIENDICA_PLATFORM . " '" . - FRIENDICA_CODENAME . "' " . - FRIENDICA_VERSION . "-" . - DB_UPDATE_VERSION . "; " . - $this->get_baseurl(); - } - - function is_friendica_app() { - return $this->is_friendica_app; - } - - /** - * @brief Checks if the site is called via a backend process - * - * This isn't a perfect solution. But we need this check very early. - * So we cannot wait until the modules are loaded. - * - * @return bool Is it a known backend? - */ - function is_backend() { - static $backends = array(); - $backends[] = "_well_known"; - $backends[] = "api"; - $backends[] = "dfrn_notify"; - $backends[] = "fetch"; - $backends[] = "hcard"; - $backends[] = "hostxrd"; - $backends[] = "nodeinfo"; - $backends[] = "noscrape"; - $backends[] = "p"; - $backends[] = "poco"; - $backends[] = "post"; - $backends[] = "proxy"; - $backends[] = "pubsub"; - $backends[] = "pubsubhubbub"; - $backends[] = "receive"; - $backends[] = "rsd_xml"; - $backends[] = "salmon"; - $backends[] = "statistics_json"; - $backends[] = "xrd"; - - // Check if current module is in backend or backend flag is set - return (in_array($this->module, $backends) || $this->backend); - } - - /** - * @brief Checks if the maximum number of database processes is reached - * - * @return bool Is the limit reached? - */ - function max_processes_reached() { - - if ($this->is_backend()) { - $process = "backend"; - $max_processes = get_config('system', 'max_processes_backend'); - if (intval($max_processes) == 0) { - $max_processes = 5; - } - } else { - $process = "frontend"; - $max_processes = get_config('system', 'max_processes_frontend'); - if (intval($max_processes) == 0) { - $max_processes = 20; - } - } - - $processlist = dbm::processlist(); - if ($processlist["list"] != "") { - logger("Processcheck: Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG); - - if ($processlist["amount"] > $max_processes) { - logger("Processcheck: Maximum number of processes for ".$process." tasks (".$max_processes.") reached.", LOGGER_DEBUG); - return true; - } - } - return false; - } - - /** - * @brief Checks if the minimal memory is reached - * - * @return bool Is the memory limit reached? - */ - public function min_memory_reached() { - $min_memory = Config::get('system', 'min_memory', 0); - if ($min_memory == 0) { - return false; - } - - if (!is_readable("/proc/meminfo")) { - return false; - } - - $memdata = explode("\n", file_get_contents('/proc/meminfo')); - - $meminfo = array(); - foreach ($memdata as $line) { - list($key, $val) = explode(":", $line); - $meminfo[$key] = (int)trim(str_replace("kB", "", $val)); - $meminfo[$key] = (int)($meminfo[$key] / 1024); - } - - if (!isset($meminfo['MemAvailable']) OR !isset($meminfo['MemFree'])) { - return false; - } - - $free = $meminfo['MemAvailable'] + $meminfo['MemFree']; - - $reached = ($free < $min_memory); - - if ($reached) { - logger('Minimal memory reached: '.$free.'/'.$meminfo['MemTotal'].' - limit '.$min_memory, LOGGER_DEBUG); - } - - return $reached; - } - - /** - * @brief Checks if the maximum load is reached - * - * @return bool Is the load reached? - */ - function maxload_reached() { - - if ($this->is_backend()) { - $process = "backend"; - $maxsysload = intval(get_config('system', 'maxloadavg')); - if ($maxsysload < 1) { - $maxsysload = 50; - } - } else { - $process = "frontend"; - $maxsysload = intval(get_config('system','maxloadavg_frontend')); - if ($maxsysload < 1) { - $maxsysload = 50; - } - } - - $load = current_load(); - if ($load) { - if (intval($load) > $maxsysload) { - logger('system: load '.$load.' for '.$process.' tasks ('.$maxsysload.') too high.'); - return true; - } - } - return false; - } - - function proc_run($args) { - - if (!function_exists("proc_open")) { - return; - } - - // If the last worker fork was less than 10 seconds before then don't fork another one. - // This should prevent the forking of masses of workers. - $cachekey = "app:proc_run:started"; - $result = Cache::get($cachekey); - - if (!is_null($result) AND (time() - $result) < 10) { - return; - } - - // Set the timestamp of the last proc_run - Cache::set($cachekey, time(), CACHE_MINUTE); - - array_unshift($args, ((x($this->config,'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php')); - - // add baseurl to args. cli scripts can't construct it - $args[] = $this->get_baseurl(); - - for ($x = 0; $x < count($args); $x ++) { - $args[$x] = escapeshellarg($args[$x]); - } - - $cmdline = implode($args, " "); - - if ($this->min_memory_reached()) { - return; - } - - if (get_config('system', 'proc_windows')) { - $resource = proc_open('cmd /c start /b ' . $cmdline, array(), $foo, dirname(__FILE__)); - } else { - $resource = proc_open($cmdline . " &", array(), $foo, dirname(__FILE__)); - } - if (!is_resource($resource)) { - logger('We got no resource for command '.$cmdline, LOGGER_DEBUG); - return; - } - proc_close($resource); - } - - /** - * @brief Returns the system user that is executing the script - * - * This mostly returns something like "www-data". - * - * @return string system username - */ - static function systemuser() { - if (!function_exists('posix_getpwuid') OR !function_exists('posix_geteuid')) { - return ''; - } - - $processUser = posix_getpwuid(posix_geteuid()); - return $processUser['name']; - } - - /** - * @brief Checks if a given directory is usable for the system - * - * @return boolean the directory is usable - */ - static function directory_usable($directory) { - - if ($directory == '') { - logger("Directory is empty. This shouldn't happen.", LOGGER_DEBUG); - return false; - } - - if (!file_exists($directory)) { - logger('Path "'.$directory.'" does not exist for user '.self::systemuser(), LOGGER_DEBUG); - return false; - } - if (is_file($directory)) { - logger('Path "'.$directory.'" is a file for user '.self::systemuser(), LOGGER_DEBUG); - return false; - } - if (!is_dir($directory)) { - logger('Path "'.$directory.'" is not a directory for user '.self::systemuser(), LOGGER_DEBUG); - return false; - } - if (!is_writable($directory)) { - logger('Path "'.$directory.'" is not writable for user '.self::systemuser(), LOGGER_DEBUG); - return false; - } - return true; - } } /** @@ -1494,7 +499,6 @@ function get_app() { return $a; } - /** * @brief Multi-purpose function to check variable state. * @@ -1509,7 +513,7 @@ function get_app() { * * @return bool|int */ -function x($s,$k = NULL) { +function x($s, $k = NULL) { if ($k != NULL) { if ((is_array($s)) && (array_key_exists($k, $s))) { if ($s[$k]) { @@ -1529,7 +533,6 @@ function x($s,$k = NULL) { } } - /** * @brief Called from db initialisation if db is dead. */ @@ -1539,7 +542,6 @@ function system_unavailable() { killme(); } - function clean_urls() { $a = get_app(); return true; @@ -1548,7 +550,7 @@ function clean_urls() { function z_path() { $base = App::get_baseurl(); - if (! clean_urls()) { + if (!clean_urls()) { $base .= '/?q='; } @@ -1575,7 +577,7 @@ function z_root() { * @return string */ function absurl($path) { - if (strpos($path,'/') === 0) { + if (strpos($path, '/') === 0) { return z_path() . $path; } return $path; @@ -1592,25 +594,23 @@ function is_ajax() { function check_db() { - $build = get_config('system','build'); - if (! x($build)) { - set_config('system','build',DB_UPDATE_VERSION); + $build = get_config('system', 'build'); + if (!x($build)) { + set_config('system', 'build', DB_UPDATE_VERSION); $build = DB_UPDATE_VERSION; } if ($build != DB_UPDATE_VERSION) { proc_run(PRIORITY_CRITICAL, 'include/dbupdate.php'); } - } - /** * Sets the base url for use in cmdline programs which don't have * $_SERVER variables */ function check_url(App $a) { - $url = get_config('system','url'); + $url = get_config('system', 'url'); // if the url isn't set or the stored url is radically different // than the currently visited url, store the current value accordingly. @@ -1618,24 +618,23 @@ function check_url(App $a) { // and www.example.com vs example.com. // We will only change the url to an ip address if there is no existing setting - if (! x($url)) { - $url = set_config('system','url',App::get_baseurl()); + if (!x($url)) { + $url = set_config('system', 'url', App::get_baseurl()); } - if ((! link_compare($url,App::get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname))) { - $url = set_config('system','url',App::get_baseurl()); + if ((!link_compare($url, App::get_baseurl())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $a->get_hostname))) { + $url = set_config('system', 'url', App::get_baseurl()); } return; } - /** * @brief Automatic database updates */ function update_db(App $a) { - $build = get_config('system','build'); - if (! x($build)) { - $build = set_config('system','build',DB_UPDATE_VERSION); + $build = get_config('system', 'build'); + if (!x($build)) { + $build = set_config('system', 'build', DB_UPDATE_VERSION); } if ($build != DB_UPDATE_VERSION) { @@ -1646,7 +645,6 @@ function update_db(App $a) { // We're reporting a different version than what is currently installed. // Run any existing update scripts to bring the database up to current. - // make sure that boot.php and update.php are the same release, we might be // updating right this very second and the correct version of the update.php // file may not be here yet. This can happen on a very busy site. @@ -1654,12 +652,12 @@ function update_db(App $a) { if (DB_UPDATE_VERSION == UPDATE_VERSION) { // Compare the current structure with the defined structure - $t = get_config('database','dbupdate_'.DB_UPDATE_VERSION); + $t = get_config('database', 'dbupdate_' . DB_UPDATE_VERSION); if ($t !== false) { return; } - set_config('database','dbupdate_'.DB_UPDATE_VERSION, time()); + set_config('database', 'dbupdate_' . DB_UPDATE_VERSION, time()); // run old update routine (wich could modify the schema and // conflits with new routine) @@ -1683,7 +681,7 @@ function update_db(App $a) { ); return; } else { - set_config('database','dbupdate_'.DB_UPDATE_VERSION, 'success'); + set_config('database', 'dbupdate_' . DB_UPDATE_VERSION, 'success'); } // run any left update_nnnn functions in update.php @@ -1707,15 +705,14 @@ function run_update_function($x) { // We want exactly one process to run the update command. // So store the fact that we're taking responsibility // after first checking to see if somebody else already has. - // If the update fails or times-out completely you may need to // delete the config entry to try again. - $t = get_config('database','update_' . $x); + $t = get_config('database', 'update_' . $x); if ($t !== false) { return false; } - set_config('database','update_' . $x, time()); + set_config('database', 'update_' . $x, time()); // call the specific update @@ -1730,13 +727,13 @@ function run_update_function($x) { ); return false; } else { - set_config('database','update_' . $x, 'success'); - set_config('system','build', $x + 1); + set_config('database', 'update_' . $x, 'success'); + set_config('system', 'build', $x + 1); return true; } } else { - set_config('database','update_' . $x, 'success'); - set_config('system','build', $x + 1); + set_config('database', 'update_' . $x, 'success'); + set_config('system', 'build', $x + 1); return true; } return true; @@ -1765,11 +762,11 @@ function check_plugins(App $a) { $installed = array(); } - $plugins = get_config('system','addon'); + $plugins = get_config('system', 'addon'); $plugins_arr = array(); if ($plugins) { - $plugins_arr = explode(',',str_replace(' ', '',$plugins)); + $plugins_arr = explode(',', str_replace(' ', '', $plugins)); } $a->plugins = $plugins_arr; @@ -1778,7 +775,7 @@ function check_plugins(App $a) { if (count($installed)) { foreach ($installed as $i) { - if (! in_array($i['name'],$plugins_arr)) { + if (!in_array($i['name'], $plugins_arr)) { uninstall_plugin($i['name']); } else { $installed_arr[] = $i['name']; @@ -1788,20 +785,18 @@ function check_plugins(App $a) { if (count($plugins_arr)) { foreach ($plugins_arr as $p) { - if (! in_array($p,$installed_arr)) { + if (!in_array($p, $installed_arr)) { install_plugin($p); } } } - load_hooks(); return; } -function get_guid($size=16, $prefix = "") { - +function get_guid($size = 16, $prefix = "") { if ($prefix == "") { $a = get_app(); $prefix = hash("crc32", $a->get_hostname()); @@ -1834,7 +829,7 @@ function get_guid($size=16, $prefix = "") { * @hooks 'login_hook' * string $o */ -function login($register = false, $hiddens=false) { +function login($register = false, $hiddens = false) { $a = get_app(); $o = ""; $reg = false; @@ -1845,14 +840,14 @@ function login($register = false, $hiddens=false) { ); } - $noid = get_config('system','no_openid'); + $noid = get_config('system', 'no_openid'); $dest_url = $a->query_string; if (local_user()) { $tpl = get_markup_template("logout.tpl"); } else { - $a->page['htmlhead'] .= replace_macros(get_markup_template("login_head.tpl"),array( + $a->page['htmlhead'] .= replace_macros(get_markup_template("login_head.tpl"), array( '$baseurl' => $a->get_baseurl(true) )); @@ -1886,10 +881,9 @@ function login($register = false, $hiddens=false) { '$privacytitle' => t('Website Privacy Policy'), '$privacylink' => t('privacy policy'), - )); - call_hooks('login_hook',$o); + call_hooks('login_hook', $o); return $o; } @@ -1898,7 +892,6 @@ function login($register = false, $hiddens=false) { * @brief Used to end the current process, after saving session state. */ function killme() { - if (!get_app()->is_backend()) { session_write_close(); } @@ -1911,14 +904,13 @@ function killme() { */ function goaway($s) { if (!strstr(normalise_link($s), "http://")) { - $s = App::get_baseurl()."/".$s; + $s = App::get_baseurl() . "/" . $s; } header("Location: $s"); killme(); } - /** * @brief Returns the user id of locally logged in user or false. * @@ -1960,7 +952,7 @@ function public_contact() { * @return int|bool visitor_id or false */ function remote_user() { - if ((x($_SESSION,'authenticated')) && (x($_SESSION,'visitor_id'))) { + if ((x($_SESSION, 'authenticated')) && (x($_SESSION, 'visitor_id'))) { return intval($_SESSION['visitor_id']); } return false; @@ -1975,7 +967,7 @@ function remote_user() { */ function notice($s) { $a = get_app(); - if (! x($_SESSION,'sysmsg')) { + if (!x($_SESSION, 'sysmsg')) { $_SESSION['sysmsg'] = array(); } if ($a->interactive) { @@ -1993,11 +985,11 @@ function notice($s) { function info($s) { $a = get_app(); - if (local_user() AND get_pconfig(local_user(),'system','ignore_info')) { + if (local_user() AND get_pconfig(local_user(), 'system', 'ignore_info')) { return; } - if (! x($_SESSION,'sysmsg_info')) { + if (!x($_SESSION, 'sysmsg_info')) { $_SESSION['sysmsg_info'] = array(); } if ($a->interactive) { @@ -2005,7 +997,6 @@ function info($s) { } } - /** * @brief Wrapper around config to limit the text length of an incoming message * @@ -2013,12 +1004,12 @@ function info($s) { */ function get_max_import_size() { $a = get_app(); - return ((x($a->config,'max_import_size')) ? $a->config['max_import_size'] : 0 ); + return ((x($a->config, 'max_import_size')) ? $a->config['max_import_size'] : 0 ); } /** * @brief Wrap calls to proc_close(proc_open()) and call hook - * so plugins can take part in process :) + * so plugins can take part in process :) * * @param (integer|array) priority or parameter array, $cmd atrings are deprecated and are ignored * @@ -2029,9 +1020,9 @@ function get_max_import_size() { * @note $cmd and string args are surrounded with "" * * @hooks 'proc_run' - * array $arr + * array $arr */ -function proc_run($cmd){ +function proc_run($cmd) { $a = get_app(); @@ -2064,7 +1055,7 @@ function proc_run($cmd){ $arr = array('args' => $args, 'run_cmd' => true); call_hooks("proc_run", $arr); - if (!$arr['run_cmd'] OR !count($args)) { + if (!$arr['run_cmd'] OR ! count($args)) { return; } @@ -2086,8 +1077,7 @@ function proc_run($cmd){ array_shift($argv); $parameters = json_encode($argv); - $found = q("SELECT `id` FROM `workerqueue` WHERE `parameter` = '%s'", - dbesc($parameters)); + $found = q("SELECT `id` FROM `workerqueue` WHERE `parameter` = '%s'", dbesc($parameters)); if (!dbm::is_result($found)) { q("INSERT INTO `workerqueue` (`parameter`, `created`, `priority`) @@ -2123,7 +1113,7 @@ function proc_run($cmd){ $a->proc_run($args); } -function current_theme(){ +function current_theme() { $app_base_themes = array('duepuntozero', 'dispy', 'quattro'); $a = get_app(); @@ -2145,7 +1135,7 @@ function current_theme(){ // This works only if the user is on the same server if ($page_theme && local_user() && (local_user() != $a->profile_uid)) { - if (get_pconfig(local_user(),'system','always_my_theme')) { + if (get_pconfig(local_user(), 'system', 'always_my_theme')) { $page_theme = null; } } @@ -2155,7 +1145,7 @@ function current_theme(){ $is_mobile = $a->is_mobile || $a->is_tablet; $standard_system_theme = Config::get('system', 'theme', ''); - $standard_theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $standard_system_theme); + $standard_theme_name = ((isset($_SESSION) && x($_SESSION, 'theme')) ? $_SESSION['theme'] : $standard_system_theme); if ($is_mobile) { if (isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) { @@ -2166,7 +1156,7 @@ function current_theme(){ if ($system_theme == '') { $system_theme = $standard_system_theme; } - $theme_name = ((isset($_SESSION) && x($_SESSION,'mobile-theme')) ? $_SESSION['mobile-theme'] : $system_theme); + $theme_name = ((isset($_SESSION) && x($_SESSION, 'mobile-theme')) ? $_SESSION['mobile-theme'] : $system_theme); if ($theme_name === '---') { // user has selected to have the mobile theme be the same as the normal one @@ -2188,21 +1178,21 @@ function current_theme(){ } if ($theme_name && - (file_exists('view/theme/' . $theme_name . '/style.css') || - file_exists('view/theme/' . $theme_name . '/style.php'))) { + (file_exists('view/theme/' . $theme_name . '/style.css') || + file_exists('view/theme/' . $theme_name . '/style.php'))) { return($theme_name); } foreach ($app_base_themes as $t) { if (file_exists('view/theme/' . $t . '/style.css') || - file_exists('view/theme/' . $t . '/style.php')) { + file_exists('view/theme/' . $t . '/style.php')) { return($t); } } - $fallback = array_merge(glob('view/theme/*/style.css'),glob('view/theme/*/style.php')); + $fallback = array_merge(glob('view/theme/*/style.css'), glob('view/theme/*/style.php')); if (count($fallback)) { - return (str_replace('view/theme/','', substr($fallback[0],0,-10))); + return (str_replace('view/theme/', '', substr($fallback[0], 0, -10))); } /// @TODO No final return statement? @@ -2222,13 +1212,13 @@ function current_theme_url() { $opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : ''); if (file_exists('view/theme/' . $t . '/style.php')) { - return('view/theme/'.$t.'/style.pcss'.$opts); + return('view/theme/' . $t . '/style.pcss' . $opts); } - return('view/theme/'.$t.'/style.css'); + return('view/theme/' . $t . '/style.css'); } -function feed_birthday($uid,$tz) { +function feed_birthday($uid, $tz) { /** * @@ -2248,11 +1238,9 @@ function feed_birthday($uid,$tz) { * 6:00PM the day before, but that will correspond to midnight to the birthday person. * */ - - $birthday = ''; - if (! strlen($tz)) { + if (!strlen($tz)) { $tz = 'UTC'; } @@ -2261,16 +1249,16 @@ function feed_birthday($uid,$tz) { ); if (dbm::is_result($p)) { - $tmp_dob = substr($p[0]['dob'],5); + $tmp_dob = substr($p[0]['dob'], 5); if (intval($tmp_dob)) { - $y = datetime_convert($tz,$tz,'now','Y'); + $y = datetime_convert($tz, $tz, 'now', 'Y'); $bd = $y . '-' . $tmp_dob . ' 00:00'; $t_dob = strtotime($bd); - $now = strtotime(datetime_convert($tz,$tz,'now')); + $now = strtotime(datetime_convert($tz, $tz, 'now')); if ($t_dob < $now) { $bd = $y + 1 . '-' . $tmp_dob . ' 00:00'; } - $birthday = datetime_convert($tz,'UTC',$bd,ATOM_TIME); + $birthday = datetime_convert($tz, 'UTC', $bd, ATOM_TIME); } } @@ -2288,7 +1276,7 @@ function is_site_admin() { $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email'])); //if(local_user() && x($a->user,'email') && x($a->config,'admin_email') && ($a->user['email'] === $a->config['admin_email'])) - if (local_user() && x($a->user,'email') && x($a->config,'admin_email') && in_array($a->user['email'], $adminlist)) { + if (local_user() && x($a->user, 'email') && x($a->config, 'admin_email') && in_array($a->user['email'], $adminlist)) { return true; } return false; @@ -2310,7 +1298,7 @@ function build_querystring($params, $name = null) { if ($name == null) { $ret .= build_querystring($val, $key); } else { - $ret .= build_querystring($val, $name."[$key]"); + $ret .= build_querystring($val, $name . "[$key]"); } } else { $val = urlencode($val); @@ -2358,10 +1346,10 @@ function explode_querystring($query) { } /** -* Returns the complete URL of the current page, e.g.: http(s)://something.com/network -* -* Taken from http://webcheatsheet.com/php/get_current_page_url.php -*/ + * Returns the complete URL of the current page, e.g.: http(s)://something.com/network + * + * Taken from http://webcheatsheet.com/php/get_current_page_url.php + */ function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") { @@ -2371,9 +1359,9 @@ function curPageURL() { $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443") { - $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; + $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { - $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; + $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } return $pageURL; } @@ -2382,7 +1370,7 @@ function random_digits($digits) { $rn = ''; for ($i = 0; $i < $digits; $i++) { /// @TODO rand() is different to mt_rand() and maybe lesser "random" - $rn .= rand(0,9); + $rn .= rand(0, 9); } return $rn; } @@ -2400,7 +1388,7 @@ function get_server() { function get_cachefile($file, $writemode = true) { $cache = get_itemcachepath(); - if ((! $cache) || (! is_dir($cache))) { + if ((!$cache) || (!is_dir($cache))) { return(""); } @@ -2433,15 +1421,15 @@ function clear_cache($basepath = "", $path = "") { return; } - $cachetime = (int)get_config('system','itemcache_duration'); + $cachetime = (int) get_config('system', 'itemcache_duration'); if ($cachetime == 0) { $cachetime = 86400; } - if (is_writable($path)){ + if (is_writable($path)) { if ($dh = opendir($path)) { while (($file = readdir($dh)) !== false) { - $fullpath = $path."/".$file; + $fullpath = $path . "/" . $file; if ((filetype($fullpath) == "dir") and ($file != ".") and ($file != "..")) { clear_cache($basepath, $fullpath); } @@ -2456,12 +1444,12 @@ function clear_cache($basepath = "", $path = "") { function get_itemcachepath() { // Checking, if the cache is deactivated - $cachetime = (int)get_config('system','itemcache_duration'); + $cachetime = (int) get_config('system', 'itemcache_duration'); if ($cachetime < 0) { return ""; } - $itemcache = get_config('system','itemcache'); + $itemcache = get_config('system', 'itemcache'); if (($itemcache != "") AND App::directory_usable($itemcache)) { return $itemcache; } @@ -2469,7 +1457,7 @@ function get_itemcachepath() { $temppath = get_temppath(); if ($temppath != "") { - $itemcache = $temppath."/itemcache"; + $itemcache = $temppath . "/itemcache"; if (!file_exists($itemcache) && !is_dir($itemcache)) { mkdir($itemcache); } @@ -2488,7 +1476,7 @@ function get_itemcachepath() { * @return string Spool path */ function get_spoolpath() { - $spoolpath = get_config('system','spoolpath'); + $spoolpath = get_config('system', 'spoolpath'); if (($spoolpath != "") AND App::directory_usable($spoolpath)) { // We have a spool path and it is usable return $spoolpath; @@ -2499,7 +1487,7 @@ function get_spoolpath() { if ($temppath != "") { // To avoid any interferences with other systems we create our own directory - $spoolpath = $temppath."/spool"; + $spoolpath = $temppath . "/spool"; if (!is_dir($spoolpath)) { mkdir($spoolpath); } @@ -2535,7 +1523,7 @@ function get_temppath() { // Check if it is usable if (($temppath != "") AND App::directory_usable($temppath)) { // To avoid any interferences with other systems we create our own directory - $new_temppath = $temppath."/".$a->get_hostname(); + $new_temppath = $temppath . "/" . $a->get_hostname(); if (!is_dir($new_temppath)) { /// @TODO There is a mkdir()+chmod() upwards, maybe generalize this (+ configurable) into a function/method? mkdir($new_temppath); @@ -2581,7 +1569,7 @@ function validate_include(&$file) { return false; } - $file = str_replace(getcwd()."/", "", $file, $count); + $file = str_replace(getcwd() . "/", "", $file, $count); if ($count != 1) { return false; } @@ -2633,7 +1621,7 @@ function argc() { * @return string Value of the argv key */ function argv($x) { - if (array_key_exists($x,get_app()->argv)) { + if (array_key_exists($x, get_app()->argv)) { return get_app()->argv[$x]; } @@ -2650,12 +1638,12 @@ function argv($x) { * * @param string $module The name of the module (e.g. "network") * @return array Of infinite scroll data - * 'pageno' => $pageno The number of the actual page - * 'reload_uri' => $reload_uri The URI of the content we have to load + * 'pageno' => $pageno The number of the actual page + * 'reload_uri' => $reload_uri The URI of the content we have to load */ function infinite_scroll_data($module) { - if (get_pconfig(local_user(),'system','infinite_scroll') + if (get_pconfig(local_user(), 'system', 'infinite_scroll') AND ($module == "network") AND ($_GET["mode"] != "minimal")) { // get the page number @@ -2674,7 +1662,7 @@ function infinite_scroll_data($module) { } } - if (($a->page_offset != "") AND !strstr($reload_uri, "&offset=")) { + if (($a->page_offset != "") AND ! strstr($reload_uri, "&offset=")) { $reload_uri .= "&offset=" . urlencode($a->page_offset); } diff --git a/composer.lock b/composer.lock index b46614f6e..f057d0cec 100644 --- a/composer.lock +++ b/composer.lock @@ -226,10 +226,10 @@ }, { "name": "pear-pear.php.net/PEAR", - "version": "1.10.3", + "version": "1.10.4", "dist": { "type": "file", - "url": "https://pear.php.net/get/PEAR-1.10.3.tgz", + "url": "https://pear.php.net/get/PEAR-1.10.4.tgz", "reference": null, "shasum": null }, @@ -247,7 +247,7 @@ "pear-pear.php.net/pear_frontend_web": "<=0.4.0.0" }, "replace": { - "pear-pear/pear": "== 1.10.3.0" + "pear-pear/pear": "== 1.10.4.0" }, "type": "pear-library", "autoload": { diff --git a/doc/Composer.md b/doc/Composer.md index 8310baf3f..02ce61639 100644 --- a/doc/Composer.md +++ b/doc/Composer.md @@ -113,3 +113,8 @@ For Composer, this would be: ```` $> COMPOSER_HOME=/var/tmp/composer sudo -u [web user] util/composer.phar [mode] ```` + +## Related + +* [Class autoloading](help/autoloader) +* [How To Move Classes to `src`](help/Developer-How-To-Move-Classes-to-src) diff --git a/doc/Developer-How-To-Move-Classes-to-src.md b/doc/Developer-How-To-Move-Classes-to-src.md new file mode 100644 index 000000000..25eb39372 --- /dev/null +++ b/doc/Developer-How-To-Move-Classes-to-src.md @@ -0,0 +1,108 @@ +How To Move Classes to `src` +============== + +* [Home](help) + * [Developer Intro](help/Developers-Intro) + +Friendica uses [Composer](help/Composer) to manage autoloading. +This means that all the PHP class files moved to the `src` folder will be [automatically included](help/autoloader) when the class it defines is first used in the flow. +This is an improvement over the current `require` usage since files will be included on an actual usage basis instead of the presence of a `require` call. + +However, there are a significant number of items to check when moving a class file from the `include` folder to the `src` folder, and this page is there to list them. + +## Decide the namespace + +This isn't the most technical decision of them all, but it has long lasting consequences as it will be the name that will be used to refer to this class from now on. +There is [a shared Ethercalc sheet](https://ethercalc.org/friendica_classes) to suggest namespace/class names that lists all the already moved class files for inspiration. + +A few pointers though: +* `Friendica` is the base namespace for all classes in the `src` folder +* Namespaces match the directory structure, with `Friendica` namespace being the base `src` directory. The `Config` class set in the `Friendica\Core` namespace is expected to be found at `src/Core/Config.php`. +* Namespaces can help group classes with a similar purpose or relevant to a particular feature + +When you're done deciding the namespace, it's time to use it. +Let's say we choose `Friendica\Core` for the `Config` class. + +## Use the namespace + +To declare the namespace, the file `src/Core/Config.php` must start with the following statement: + +````php +namespace Friendica\Core; +```` + +From now on, the `Config` class can be referred to as `Friendica\Core\Config`, however it isn't very practical, especially when the class was previously used as `Config`. +Thankfully, PHP provides namespace shortcuts through `use`. + +This language construct just provides a different naming scheme for a namespace or a class, but doesn't trigger the autoload mechanism on its own. +Here are the different ways you can use `use`: + +````php +// No use +$config = new Friendica\Core\Config(); +```` +````php +// Namespace shortcut +use Friendica\Core; + +$config = new Core\Config(); +```` +````php +// Class name shortcut +use Friendica\Core\Config; + +$config = new Config(); +```` +````php +// Aliasing +use Friendica\Core\Config as Cfg; + +$config = new Cfg(); +```` + +Whatever the style chosen, a repository-wide search has to be done to find all the class name usage and either use the fully-qualified class name (including the namespace) or add a `use` statement at the start of each relevant file. + +## Escape non-namespace classes + +The class file you just moved is now in the `Friendica` namespace, but it probably isn't the case for all the classes referenced in this file. +Since we added a `namespace Friendica\Core;` to the file, all the class names still declared in `include` will be implicitly understood as `Friendica\Core\ClassName`, which is rarely what we expect. + +To avoid `Class Friendica\Core\ClassName not found` errors, all the `include`-declared class names have to be prepended with a `\`, it tells the autoloader not to look for the class in the namespace but in the global space where non-namespaced classes are set. +If there are only a handful of references to a single non-namespaced class, just prepending `\` is enough. However, if there are many instance, we can use `use` again. + +````php +namespace Friendica\Core; +... +if (\dbm::is_result($r)) { + ... +} +```` +````php +namespace Friendica\Core; + +use \dbm; + +if (dbm::is_result($r)) { + ... +} +```` + +## Remove any useless `require` + +Now that you successfully moved your class to the autoloaded `src` folder, there's no need to include this file anywhere in the app ever again. +Please remove all the `require_once` mentions of the former file, as they will provoke a Fatal Error even if the class isn't used. + +## Miscellaneous tips + +When you are done with moving the class, please run `php util/typo.php` from the Friendica base directory to check for obvious mistakes. +Howevever, this tool isn't bullet-proof, and a staging install of Friendica is recommended to test your class move without impairing your production server if you host one. + +Most of Friendica processes are run in the background, so make sure to turn on your debug log to check for errors that wouldn't show up while simply browsing Friendica. + +Check the class file for any magic constant `__FILE__` or `__DIR__`, as their value changed since you moved the class in the file tree. +Most of the time it's used for debugging purposes but there can be instances where it's used to create cache folders for example. + +## Related + +* [Class autoloading](help/autoloader) +* [Using Composer](help/Composer) \ No newline at end of file diff --git a/doc/Developers-Intro.md b/doc/Developers-Intro.md index 5568afeb5..3cda8ab46 100644 --- a/doc/Developers-Intro.md +++ b/doc/Developers-Intro.md @@ -52,7 +52,9 @@ Friendica uses [Composer](https://getcomposer.org) to manage dependencies librar It's a command-line tool that downloads required libraries into the `vendor` folder and makes any namespaced class in `src` available through the whole application through `boot.php`. +* [Class autoloading](help/autoloader) * [Using Composer](help/Composer) +* [How To Move Classes to `src`](help/Developer-How-To-Move-Classes-to-src) ###Coding standards diff --git a/doc/Home.md b/doc/Home.md index 5490d171f..4cecec44e 100644 --- a/doc/Home.md +++ b/doc/Home.md @@ -36,21 +36,25 @@ Friendica Documentation and Resources **Developer Manual** -* [Where to get started?](help/Developers-Intro) -* [Help on Github](help/Github) -* [Help on Vagrant](help/Vagrant) -* [How to translate Friendica](help/translations) -* [Bugs and Issues](help/Bugs-and-Issues) -* [Plugin Development](help/Plugins) -* [Theme Development](help/themes) -* [Smarty 3 Templates](help/smarty3-templates) -* [Protocol Documentation](help/Protocol) -* [Database schema documantation](help/database) -* [Class Autoloading](help/autoloader) -* [Using Composer](help/Composer) -* [Code - Reference(Doxygen generated - sets cookies)](doc/html/) -* [Twitter/GNU Social API Functions](help/api) - +* [Get started](help/Developers-Intro) +* Set up development environment + * [Help on Github](help/Github) + * [Help on Vagrant](help/Vagrant) + * [Bugs and Issues](help/Bugs-and-Issues) +* Code structure + * [Plugin Development](help/Plugins) + * [Theme Development](help/themes) + * [Smarty 3 Templates](help/smarty3-templates) +* How To + * [Translate Friendica](help/translations) + * [Use Composer](help/Composer) + * [Move classes to `src`](help/Developer-How-To-Move-Classes-to-src) +* Reference + * [Twitter/GNU Social API Functions](help/api) + * [Code (Doxygen generated - sets cookies)](doc/html/) + * [Protocol Documentation](help/Protocol) + * [Database schema documantation](help/database) + * [Class Autoloading](help/autoloader) **External Resources** diff --git a/doc/autoloader.md b/doc/autoloader.md index 83f101044..af76cf329 100644 --- a/doc/autoloader.md +++ b/doc/autoloader.md @@ -24,14 +24,14 @@ For more info about PHP autoloading, please refer to the [official PHP documenta Let's say you have a PHP file in `src/` that define a very useful class: ```php - // src/ItemsManager.php - getAll(); +function network_content(App $a) { + $itemsmanager = new Friendica\ItemsManager(); + $items = $itemsmanager->getAll(); - // pass $items to template - // return result - } + // pass $items to template + // return result +} ``` That's a quite simple example, but look: no `require()`! @@ -61,132 +61,137 @@ If you need to use a class, you can simply use it and you don't need to do anyth Going further: now we have a bunch of `*Manager` classes that cause some code duplication, let's define a `BaseManager` class, where we move all common code between all managers: ```php - // src/BaseManager.php - diff --git a/include/Emailer.php b/include/Emailer.php index b0cdc3fe6..9df6ac36c 100644 --- a/include/Emailer.php +++ b/include/Emailer.php @@ -81,4 +81,3 @@ class Emailer { return $res; } } -?> diff --git a/include/ForumManager.php b/include/ForumManager.php index c2a20df29..8f38ed3a3 100644 --- a/include/ForumManager.php +++ b/include/ForumManager.php @@ -1,5 +1,7 @@ Notification identifier * int 'total' => Total number of available network notifications @@ -436,7 +435,7 @@ class NotificationsManager { } /** - * @brief Total number of system notifications + * @brief Total number of system notifications * @param int|string $seen * If 0 only include notifications into the query * which aren't marked as "seen" @@ -460,13 +459,13 @@ class NotificationsManager { /** * @brief Get system notifications - * + * * @param int|string $seen * If 0 only include notifications into the query * which aren't marked as "seen" * @param int $start Start the query at this point * @param int $limit Maximum number of query results - * + * * @return array with * string 'ident' => Notification identifier * int 'total' => Total number of available system notifications @@ -502,7 +501,7 @@ class NotificationsManager { /** * @brief Addional SQL query string for the personal notifications - * + * * @return string The additional sql query */ private function _personal_sql_extra() { @@ -520,7 +519,7 @@ class NotificationsManager { } /** - * @brief Total number of personal notifications + * @brief Total number of personal notifications * @param int|string $seen * If 0 only include notifications into the query * which aren't marked as "seen" @@ -550,13 +549,13 @@ class NotificationsManager { /** * @brief Get personal notifications - * + * * @param int|string $seen * If 0 only include notifications into the query * which aren't marked as "seen" * @param int $start Start the query at this point * @param int $limit Maximum number of query results - * + * * @return array with * string 'ident' => Notification identifier * int 'total' => Total number of available personal notifications @@ -573,13 +572,13 @@ class NotificationsManager { $sql_seen = " AND `item`.`unseen` = 1 "; $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, `item`.`unseen`, - `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` AS `object`, - `pitem`.`author-name` AS `pname`, `pitem`.`author-link` AS `plink`, `pitem`.`guid` AS `pguid` + `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` AS `object`, + `pitem`.`author-name` AS `pname`, `pitem`.`author-link` AS `plink`, `pitem`.`guid` AS `pguid` FROM `item` INNER JOIN `item` AS `pitem` ON `pitem`.`id`=`item`.`parent` WHERE `item`.`visible` = 1 $sql_extra $sql_seen - AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 + AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC LIMIT %d, %d " , intval(local_user()), intval($start), @@ -588,7 +587,7 @@ class NotificationsManager { if (dbm::is_result($r)) $notifs = $this->formatNotifs($r, $ident); - + $arr = array ( 'notifications' => $notifs, 'ident' => $ident, @@ -599,7 +598,7 @@ class NotificationsManager { } /** - * @brief Total number of home notifications + * @brief Total number of home notifications * @param int|string $seen * If 0 only include notifications into the query * which aren't marked as "seen" @@ -626,13 +625,13 @@ class NotificationsManager { /** * @brief Get home notifications - * + * * @param int|string $seen * If 0 only include notifications into the query * which aren't marked as "seen" * @param int $start Start the query at this point * @param int $limit Maximum number of query results - * + * * @return array with * string 'ident' => Notification identifier * int 'total' => Total number of available home notifications @@ -673,7 +672,7 @@ class NotificationsManager { } /** - * @brief Total number of introductions + * @brief Total number of introductions * @param bool $all * If false only include introductions into the query * which aren't marked as ignored @@ -698,13 +697,13 @@ class NotificationsManager { /** * @brief Get introductions - * + * * @param bool $all * If false only include introductions into the query * which aren't marked as ignored * @param int $start Start the query at this point * @param int $limit Maximum number of query results - * + * * @return array with * string 'ident' => Notification identifier * int 'total' => Total number of available introductions @@ -749,7 +748,7 @@ class NotificationsManager { /** * @brief Format the notification query in an usable array - * + * * @param array $intros The array from the db query * @return array with the introductions */ diff --git a/include/Photo.php b/include/Photo.php index 828dce82d..504f7e942 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -4,6 +4,8 @@ * @brief This file contains the Photo class for image processing */ +use Friendica\App; + require_once("include/photos.php"); class Photo { diff --git a/include/Probe.php b/include/Probe.php index bed13fdf3..85f64d29b 100644 --- a/include/Probe.php +++ b/include/Probe.php @@ -5,8 +5,9 @@ * */ -use \Friendica\Core\Config; -use \Friendica\Core\PConfig; +use Friendica\App; +use Friendica\Core\Config; +use Friendica\Core\PConfig; require_once("include/feed.php"); require_once('include/email.php'); @@ -1261,4 +1262,3 @@ class Probe { } } -?> diff --git a/include/Smilies.php b/include/Smilies.php index d67b92d8b..f4de32f8f 100644 --- a/include/Smilies.php +++ b/include/Smilies.php @@ -5,6 +5,8 @@ * @brief This file contains the Smilies class which contains functions to handle smiles */ +use Friendica\App; + /** * This class contains functions to handle smiles */ @@ -13,13 +15,13 @@ class Smilies { /** * @brief Function to list all smilies - * + * * Get an array of all smilies, both internal and from addons. - * + * * @return array * 'texts' => smilie shortcut * 'icons' => icon in html - * + * * @hook smilie ('texts' => smilies texts array, 'icons' => smilies html array) */ public static function get_list() { @@ -64,41 +66,41 @@ class Smilies { ); $icons = array( - '<3', - '</3', - '<\\3', - ':-)', - ';-)', - ':-(', - ':-P', - ':-p', - ':-\', - ':-\', - ':-x', - ':-X', - ':-D', - '8-|', - '8-O', - ':-O', - '\\o/', - 'o.O', - 'O.o', - 'o_O', - 'O_o', - ':\'(', - ':-!', - ':-/', - ':-[', - '8-)', - ':beer', - ':homebrew', - ':coffee', - ':facepalm', - ':like', - ':dislike', - '~friendica ~friendica', - 'redred#matrix', - 'redred#matrixmatrix' + '<3', + '</3', + '<\\3', + ':-)', + ';-)', + ':-(', + ':-P', + ':-p', + ':-\', + ':-\', + ':-x', + ':-X', + ':-D', + '8-|', + '8-O', + ':-O', + '\\o/', + 'o.O', + 'O.o', + 'o_O', + 'O_o', + ':\'(', + ':-!', + ':-/', + ':-[', + '8-)', + ':beer', + ':homebrew', + ':coffee', + ':facepalm', + ':like', + ':dislike', + '~friendica ~friendica', + 'redred#matrix', + 'redred#matrixmatrix' ); $params = array('texts' => $texts, 'icons' => $icons); @@ -121,7 +123,7 @@ class Smilies { * * @param string $s * @param boolean $sample - * + * * @return string HML Output of the Smilie */ public static function replace($s, $sample = false) { @@ -166,7 +168,7 @@ class Smilies { * * @param string $x * @return string HTML Output - * + * * @todo: Rework because it doesn't work correctly */ private function preg_heart($x) { @@ -174,7 +176,7 @@ class Smilies { return $x[0]; $t = ''; for($cnt = 0; $cnt < strlen($x[1]); $cnt ++) - $t .= '<3'; + $t .= '<3'; $r = str_replace($x[0],$t,$x[0]); return $r; } diff --git a/include/acl_selectors.php b/include/acl_selectors.php index fbe5d1e69..c7c6bb206 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -4,6 +4,8 @@ * @file include/acl_selectors.php */ +use Friendica\App; + require_once "include/contact_selectors.php"; require_once "include/contact_widgets.php"; require_once "include/DirSearch.php"; diff --git a/include/api.php b/include/api.php index f68c1bb9e..fc38f1bc8 100644 --- a/include/api.php +++ b/include/api.php @@ -6,7 +6,8 @@ * @todo Automatically detect if incoming data is HTML or BBCode */ -use \Friendica\Core\Config; +use Friendica\App; +use Friendica\Core\Config; require_once 'include/HTTPExceptions.php'; require_once 'include/bbcode.php'; diff --git a/include/auth.php b/include/auth.php index c1a6120db..5dfe9d3e0 100644 --- a/include/auth.php +++ b/include/auth.php @@ -1,6 +1,7 @@ rLogFile); } } -?> diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index a07a58353..1dc775887 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -1,5 +1,7 @@ diff --git a/include/cron.php b/include/cron.php index c4299dd4c..bac9c8a3d 100644 --- a/include/cron.php +++ b/include/cron.php @@ -1,5 +1,6 @@ diff --git a/include/dbm.php b/include/dbm.php index 3430577da..db50dae89 100644 --- a/include/dbm.php +++ b/include/dbm.php @@ -110,4 +110,3 @@ class dbm { return date('Y-m-d H:i:s', $timestamp); } } -?> diff --git a/include/dbstructure.php b/include/dbstructure.php index 993ddad40..6a14220c2 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -1,6 +1,7 @@ setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS); $root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET); - xml::add_element($doc, $root, "id", app::get_baseurl()."/profile/".$owner["nick"]); + xml::add_element($doc, $root, "id", App::get_baseurl()."/profile/".$owner["nick"]); xml::add_element($doc, $root, "title", $owner["name"]); $attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION); @@ -448,13 +450,13 @@ class dfrn { // DFRN itself doesn't uses this. But maybe someone else wants to subscribe to the public feed. ostatus::hublinks($doc, $root); - $attributes = array("rel" => "salmon", "href" => app::get_baseurl()."/salmon/".$owner["nick"]); + $attributes = array("rel" => "salmon", "href" => App::get_baseurl()."/salmon/".$owner["nick"]); xml::add_element($doc, $root, "link", "", $attributes); - $attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-replies", "href" => app::get_baseurl()."/salmon/".$owner["nick"]); + $attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-replies", "href" => App::get_baseurl()."/salmon/".$owner["nick"]); xml::add_element($doc, $root, "link", "", $attributes); - $attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-mention", "href" => app::get_baseurl()."/salmon/".$owner["nick"]); + $attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-mention", "href" => App::get_baseurl()."/salmon/".$owner["nick"]); xml::add_element($doc, $root, "link", "", $attributes); } @@ -511,7 +513,7 @@ class dfrn { } xml::add_element($doc, $author, "name", $owner["name"], $attributes); - xml::add_element($doc, $author, "uri", app::get_baseurl().'/profile/'.$owner["nickname"], $attributes); + xml::add_element($doc, $author, "uri", App::get_baseurl().'/profile/'.$owner["nickname"], $attributes); xml::add_element($doc, $author, "dfrn:handle", $owner["addr"], $attributes); $attributes = array("rel" => "photo", "type" => "image/jpeg", @@ -812,7 +814,7 @@ class dfrn { $parent = q("SELECT `guid` FROM `item` WHERE `id` = %d", intval($item["parent"])); $parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']); $attributes = array("ref" => $parent_item, "type" => "text/html", - "href" => app::get_baseurl().'/display/'.$parent[0]['guid'], + "href" => App::get_baseurl().'/display/'.$parent[0]['guid'], "dfrn:diaspora_guid" => $parent[0]['guid']); xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes); } @@ -854,7 +856,7 @@ class dfrn { // We save this value in "plink". Maybe we should read it from there as well? xml::add_element($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html", - "href" => app::get_baseurl()."/display/".$item["guid"])); + "href" => App::get_baseurl()."/display/".$item["guid"])); // "comment-allow" is some old fashioned stuff for old Friendica versions. // It is included in the rewritten code for completeness diff --git a/include/diaspora.php b/include/diaspora.php index 0c3ff68da..51b496f86 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -8,7 +8,8 @@ * This will change in the future. */ -use \Friendica\Core\Config; +use Friendica\App; +use Friendica\Core\Config; require_once 'include/items.php'; require_once 'include/bb2diaspora.php'; @@ -3819,4 +3820,3 @@ class Diaspora { return true; } } -?> diff --git a/include/directory.php b/include/directory.php index 41a3dd784..e507a939f 100644 --- a/include/directory.php +++ b/include/directory.php @@ -1,9 +1,9 @@ $author, "items" => $items); } } -?> diff --git a/include/files.php b/include/files.php index c20a6d832..0ac0078c8 100644 --- a/include/files.php +++ b/include/files.php @@ -47,4 +47,3 @@ function update_files_for_items() { create_files_from_item($message["id"]); } } -?> diff --git a/include/follow.php b/include/follow.php index 57520abe6..161e669e9 100644 --- a/include/follow.php +++ b/include/follow.php @@ -1,4 +1,7 @@ diff --git a/include/html2plain.php b/include/html2plain.php index dc2cb137c..ed338ce71 100644 --- a/include/html2plain.php +++ b/include/html2plain.php @@ -233,4 +233,3 @@ function html2plain($html, $wraplength = 75, $compact = false) return(trim($message)); } -?> diff --git a/include/identity.php b/include/identity.php index 1fea5b25d..dea044b48 100644 --- a/include/identity.php +++ b/include/identity.php @@ -3,6 +3,8 @@ * @file include/identity.php */ +use Friendica\App; + require_once('include/ForumManager.php'); require_once('include/bbcode.php'); require_once("mod/proxy.php"); diff --git a/include/items.php b/include/items.php index 5eac12d89..3c5e88a38 100644 --- a/include/items.php +++ b/include/items.php @@ -4,7 +4,8 @@ * @file include/items.php */ -use \Friendica\ParseUrl; +use Friendica\App; +use Friendica\ParseUrl; require_once 'include/bbcode.php'; require_once 'include/oembed.php'; @@ -339,7 +340,7 @@ function add_page_info_to_body($body, $texturl = false, $no_photos = false) { * Adds a "lang" specification in a "postopts" element of given $arr, * if possible and not already present. * Expects "body" element to exist in $arr. - * + * * @todo Add a parameter to request forcing override */ function item_add_language_opt(&$arr) { diff --git a/include/like.php b/include/like.php index a53b90c03..4f2600271 100644 --- a/include/like.php +++ b/include/like.php @@ -1,4 +1,7 @@ diff --git a/include/nav.php b/include/nav.php index fe4c50818..e2633be0a 100644 --- a/include/nav.php +++ b/include/nav.php @@ -1,5 +1,7 @@ gen_token(); $sec = $this->gen_token(); - + if ($consumer->key){ $k = $consumer->key; } else { $k = $consumer; } - + $r = q("INSERT INTO tokens (id, secret, client_id, scope, expires) VALUES ('%s','%s','%s','%s', UNIX_TIMESTAMP()+%d)", dbesc($key), dbesc($sec), @@ -80,19 +82,19 @@ class FKOAuthDataStore extends OAuthDataStore { function new_access_token($token, $consumer, $verifier = null) { logger(__function__.":".$token.", ". $consumer.", ". $verifier); - + // return a new access token attached to this consumer // for the user associated with this token if the request token // is authorized // should also invalidate the request token - + $ret=Null; - + // get user for this verifier $uverifier = get_config("oauth", $verifier); logger(__function__.":".$verifier.",".$uverifier); if (is_null($verifier) || ($uverifier!==false)){ - + $key = $this->gen_token(); $sec = $this->gen_token(); $r = q("INSERT INTO tokens (id, secret, client_id, scope, expires, uid) VALUES ('%s','%s','%s','%s', UNIX_TIMESTAMP()+%d, %d)", @@ -103,13 +105,13 @@ class FKOAuthDataStore extends OAuthDataStore { intval(ACCESS_TOKEN_DURATION), intval($uverifier)); if ($r) - $ret = new OAuthToken($key,$sec); + $ret = new OAuthToken($key,$sec); } - - + + q("DELETE FROM tokens WHERE id='%s'", $token->key); - - + + if (!is_null($ret) && $uverifier!==false){ del_config("oauth", $verifier); /* $apps = get_pconfig($uverifier, "oauth", "apps"); @@ -117,9 +119,9 @@ class FKOAuthDataStore extends OAuthDataStore { $apps[] = $consumer->key; set_pconfig($uverifier, "oauth", "apps", $apps);*/ } - + return $ret; - + } } @@ -172,9 +174,9 @@ class FKOAuth1 extends OAuthServer { intval($_SESSION['uid']) ); - call_hooks('logged_in', $a->user); + call_hooks('logged_in', $a->user); } - + } /* class FKOAuth2 extends OAuth2 { @@ -190,13 +192,13 @@ class FKOAuth2 extends OAuth2 { dbesc($client_secret), dbesc($redirect_uri) ); - + return $r; } protected function checkClientCredentials($client_id, $client_secret = NULL) { $client_secret = $this->db_secret($client_secret); - + $r = q("SELECT pw FROM clients WHERE client_id = '%s'", dbesc($client_id)); @@ -218,21 +220,21 @@ class FKOAuth2 extends OAuth2 { protected function getAccessToken($oauth_token) { $r = q("SELECT client_id, expires, scope FROM tokens WHERE id = '%s'", dbesc($oauth_token)); - + if (dbm::is_result($r)) return $r[0]; return null; } - + protected function setAccessToken($oauth_token, $client_id, $expires, $scope = NULL) { $r = q("INSERT INTO tokens (id, client_id, expires, scope) VALUES ('%s', '%s', %d, '%s')", dbesc($oauth_token), dbesc($client_id), intval($expires), dbesc($scope)); - + return $r; } @@ -246,23 +248,23 @@ class FKOAuth2 extends OAuth2 { protected function getAuthCode($code) { $r = q("SELECT id, client_id, redirect_uri, expires, scope FROM auth_codes WHERE id = '%s'", dbesc($code)); - + if (dbm::is_result($r)) return $r[0]; return null; } protected function setAuthCode($code, $client_id, $redirect_uri, $expires, $scope = NULL) { - $r = q("INSERT INTO auth_codes - (id, client_id, redirect_uri, expires, scope) VALUES + $r = q("INSERT INTO auth_codes + (id, client_id, redirect_uri, expires, scope) VALUES ('%s', '%s', '%s', %d, '%s')", dbesc($code), dbesc($client_id), dbesc($redirect_uri), intval($expires), dbesc($scope)); - return $r; - } - + return $r; + } + } */ diff --git a/include/oembed.php b/include/oembed.php index 0b8b71366..80b49fbf0 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -4,8 +4,9 @@ * @file include/oembed.php */ -use \Friendica\ParseUrl; -use \Friendica\Core\Config; +use Friendica\App; +use Friendica\ParseUrl; +use Friendica\Core\Config; function oembed_replacecb($matches){ $embedurl=$matches[1]; diff --git a/include/onepoll.php b/include/onepoll.php index 5227b61a1..3483d2493 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -1,6 +1,6 @@ saveXML())); } } -?> diff --git a/include/pgettext.php b/include/pgettext.php index b42dcec11..9b541e8e3 100644 --- a/include/pgettext.php +++ b/include/pgettext.php @@ -10,7 +10,7 @@ * */ -use \Friendica\Core\Config; +use Friendica\Core\Config; require_once("include/dba.php"); diff --git a/include/photos.php b/include/photos.php index e872532a4..38cda3f2b 100644 --- a/include/photos.php +++ b/include/photos.php @@ -4,8 +4,8 @@ * @brief Functions related to photo handling. */ -use \Friendica\Core\Config; -use \Friendica\Core\PConfig; +use Friendica\Core\Config; +use Friendica\Core\PConfig; function getGps($exifCoord, $hemi) { $degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0; diff --git a/include/pidfile.php b/include/pidfile.php index 3093e149a..dda6b3e9c 100644 --- a/include/pidfile.php +++ b/include/pidfile.php @@ -38,4 +38,3 @@ class pidfile { return(posix_kill(file_get_contents($this->_file), SIGTERM)); } } -?> diff --git a/include/plaintext.php b/include/plaintext.php index 6ab4ec77d..215d9f3db 100644 --- a/include/plaintext.php +++ b/include/plaintext.php @@ -4,7 +4,8 @@ * @file include/plaintext.php */ -use \Friendica\ParseUrl; +use Friendica\App; +use Friendica\ParseUrl; require_once("include/Photo.php"); require_once("include/bbcode.php"); @@ -431,4 +432,3 @@ function plaintext(App $a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2 return($post); } -?> diff --git a/include/plugin.php b/include/plugin.php index 83f6f1ab9..336b213aa 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -1,10 +1,11 @@ ($starttime + 3600)) return; } - } /** @@ -687,4 +688,3 @@ if (array_search(__file__,get_included_files())===0){ killme(); } -?> diff --git a/include/post_update.php b/include/post_update.php index f9649961d..9d18b27b4 100644 --- a/include/post_update.php +++ b/include/post_update.php @@ -258,5 +258,3 @@ function post_update_1206() { logger("Done", LOGGER_DEBUG); return true; } - -?> diff --git a/include/pubsubpublish.php b/include/pubsubpublish.php index 1e47c3085..24d7b6963 100644 --- a/include/pubsubpublish.php +++ b/include/pubsubpublish.php @@ -1,5 +1,7 @@ diff --git a/include/redir.php b/include/redir.php index 76e30a6ea..36f982b12 100644 --- a/include/redir.php +++ b/include/redir.php @@ -1,5 +1,7 @@ $id)); } -?> diff --git a/include/security.php b/include/security.php index 05371f71c..09ac03c35 100644 --- a/include/security.php +++ b/include/security.php @@ -1,5 +1,7 @@ diff --git a/include/spool_post.php b/include/spool_post.php index f64b39e4b..2b21e4196 100644 --- a/include/spool_post.php +++ b/include/spool_post.php @@ -4,7 +4,7 @@ * @brief Posts items that wer spooled because they couldn't be posted. */ -use \Friendica\Core\Config; +use Friendica\Core\Config; require_once("include/items.php"); @@ -55,4 +55,3 @@ function spool_post_run($argv, $argc) { } } } -?> diff --git a/include/tags.php b/include/tags.php index d809da2bf..6067f3f4b 100644 --- a/include/tags.php +++ b/include/tags.php @@ -1,4 +1,7 @@ diff --git a/include/text.php b/include/text.php index 01873bff2..c9babba94 100644 --- a/include/text.php +++ b/include/text.php @@ -1,12 +1,13 @@ diff --git a/include/uimport.php b/include/uimport.php index 4cc5b6c04..0ee15952a 100644 --- a/include/uimport.php +++ b/include/uimport.php @@ -1,11 +1,7 @@ t('No'), )); - //echo "
"; var_dump($app); killme();
-
 		return $o;
 	}
 
diff --git a/mod/apps.php b/mod/apps.php
index 199ce0f91..0c0df7654 100644
--- a/mod/apps.php
+++ b/mod/apps.php
@@ -1,25 +1,25 @@
 apps)==0)
-		notice( t('No installed applications.') . EOL);
+	if (count($a->apps) == 0) {
+		notice(t('No installed applications.') . EOL);
+	}
 
-
-	$tpl = get_markup_template("apps.tpl");
+	$tpl = get_markup_template('apps.tpl');
 	return replace_macros($tpl, array(
 		'$title' => $title,
 		'$apps' => $a->apps,
 	));
-
-
-
 }
diff --git a/mod/attach.php b/mod/attach.php
index dd7154dfe..6155a3f99 100644
--- a/mod/attach.php
+++ b/mod/attach.php
@@ -1,5 +1,7 @@
  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,
+	));
 }
diff --git a/mod/crepair.php b/mod/crepair.php
index 902a12930..59ac620a3 100644
--- a/mod/crepair.php
+++ b/mod/crepair.php
@@ -1,4 +1,7 @@
 set_pager_itemspage(60);
 
@@ -9,24 +11,18 @@ function directory_init(App $a) {
 		$a->page['aside'] .= findpeople_widget();
 
 		$a->page['aside'] .= follow_widget();
-
 	}
 	else {
 		unset($_SESSION['theme']);
 		unset($_SESSION['mobile-theme']);
 	}
-
-
 }
 
-
 function directory_post(App $a) {
 	if(x($_POST,'search'))
 		$a->data['search'] = $_POST['search'];
 }
 
-
-
 function directory_content(App $a) {
 	global $db;
 
diff --git a/mod/dirfind.php b/mod/dirfind.php
index c5844d13d..c24ab9dbd 100644
--- a/mod/dirfind.php
+++ b/mod/dirfind.php
@@ -1,4 +1,7 @@
 page['aside'] .= follow_widget();
 }
 
-
-
 function dirfind_content(App $a, $prefix = "") {
 
 	$community = false;
diff --git a/mod/display.php b/mod/display.php
index 1f1fd1120..ca6809eba 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -1,5 +1,7 @@
 
  */
 
+use Friendica\App;
+
 require_once('include/Photo.php');
 
 /**
diff --git a/mod/fetch.php b/mod/fetch.php
index b87fc0e8e..0afd7af10 100644
--- a/mod/fetch.php
+++ b/mod/fetch.php
@@ -2,6 +2,9 @@
 /*
 This file is part of the Diaspora protocol. It is used for fetching single public posts.
 */
+
+use Friendica\App;
+
 require_once("include/crypto.php");
 require_once("include/diaspora.php");
 require_once("include/xml.php");
diff --git a/mod/filer.php b/mod/filer.php
index 47c4aa5e4..6259879de 100644
--- a/mod/filer.php
+++ b/mod/filer.php
@@ -1,10 +1,11 @@
 argv[1] == "json"){
diff --git a/mod/fsuggest.php b/mod/fsuggest.php
index b3d543971..32ed63b4c 100644
--- a/mod/fsuggest.php
+++ b/mod/fsuggest.php
@@ -1,5 +1,6 @@
 ";
 		$html = implode("\n",$lines);
 
-		$a->page['aside'] = $toc.$a->page['aside'];
+		$a->page['aside'] = '
' . $toc . $a->page['aside'] . '
'; } $html = " diff --git a/mod/home.php b/mod/home.php index b1708d80a..bd77a840d 100644 --- a/mod/home.php +++ b/mod/home.php @@ -1,5 +1,7 @@ config['register_policy'] == REGISTER_CLOSED) ? false : true); - } diff --git a/mod/lostpass.php b/mod/lostpass.php index 455a9b1e2..37ef3e2f8 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -1,5 +1,7 @@ App::get_baseurl(), - '$touch_icon' => $touch_icon, - '$title' => Config::get('config', 'sitename', 'Friendica'), - )); - - echo $o; - - killme(); + header('Content-type: application/manifest+json'); + $touch_icon = Config::get('system', 'touch_icon', 'images/friendica-128.png'); + if ($touch_icon == '') { + $touch_icon = 'images/friendica-128.png'; } -?> + + $o = replace_macros($tpl, array( + '$baseurl' => App::get_baseurl(), + '$touch_icon' => $touch_icon, + '$title' => Config::get('config', 'sitename', 'Friendica'), + )); + + echo $o; + + killme(); +} diff --git a/mod/match.php b/mod/match.php index 44f5141ad..4119bf8e8 100644 --- a/mod/match.php +++ b/mod/match.php @@ -1,5 +1,8 @@ ' . t('Welcome to Friendica') . ''; - $o .= '

' . t('New Member Checklist') . '

'; - $o .= '
'; - $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 .= '

' . t('Getting Started') . '

'; - $o .= ''; - $o .= '

' . t('Settings') . '

'; - $o .= ''; - $o .= '

' . t('Profile') . '

'; - $o .= ''; - $o .= '

' . t('Connecting') . '

'; - $o .= ''; - $o .= '

' . t('Groups') . '

'; - $o .= ''; - $o .= '

' . t('Getting Help') . '

'; - $o .= ''; - $o .= '
'; return $o; diff --git a/mod/nodeinfo.php b/mod/nodeinfo.php index 7f010cee4..5d8e8f2a2 100644 --- a/mod/nodeinfo.php +++ b/mod/nodeinfo.php @@ -5,7 +5,8 @@ * Documentation: http://nodeinfo.diaspora.software/schema.html */ -use \Friendica\Core\Config; +use Friendica\App; +use Friendica\Core\Config; require_once 'include/plugin.php'; @@ -251,5 +252,3 @@ function nodeinfo_cron() { logger('cron_end'); Config::set('nodeinfo', 'last_calucation', time()); } - -?> diff --git a/mod/nogroup.php b/mod/nogroup.php index 11b7bdc7a..ecbfb9176 100644 --- a/mod/nogroup.php +++ b/mod/nogroup.php @@ -1,5 +1,7 @@ argc > 1) diff --git a/mod/notes.php b/mod/notes.php index c7cfe8d70..835627586 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -1,5 +1,7 @@ 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; +} diff --git a/mod/notifications.php b/mod/notifications.php index fdaec05cc..396361e91 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -5,6 +5,8 @@ * @brief The notifications module */ +use Friendica\App; + require_once("include/NotificationsManager.php"); require_once("include/contact_selectors.php"); require_once("include/network.php"); diff --git a/mod/notify.php b/mod/notify.php index 0026f5ca6..e38068193 100644 --- a/mod/notify.php +++ b/mod/notify.php @@ -1,4 +1,7 @@ argc > 1) && ($a->argv[1] === 'xrd')) { diff --git a/mod/openid.php b/mod/openid.php index 60de55a50..5707b1b72 100644 --- a/mod/openid.php +++ b/mod/openid.php @@ -1,9 +1,9 @@ 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(); +} diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php index a9f7c3a90..a36821aa2 100644 --- a/mod/ostatus_subscribe.php +++ b/mod/ostatus_subscribe.php @@ -1,5 +1,7 @@ argc > 1) { diff --git a/mod/ping.php b/mod/ping.php index dcef73ffb..17180c74e 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -1,5 +1,8 @@ get_theme_screenshot($theme), 'desc' => $desc, 'version' => $version, 'credits' => $credits)); } + killme(); } diff --git a/mod/probe.php b/mod/probe.php index 8c951a7fc..2911bc05c 100644 --- a/mod/probe.php +++ b/mod/probe.php @@ -1,31 +1,32 @@ 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 .= '

Probe Diagnostic

'; $o .= '
'; - $o .= 'Lookup address: '; + $o .= 'Lookup address: '; $o .= '
'; $o .= '

'; - if(x($_GET,'addr')) { - + if (x($_GET, 'addr')) { $addr = trim($_GET['addr']); $res = probe_url($addr); $o .= '
';
-		$o .= str_replace("\n",'
',print_r($res,true)); + $o .= str_replace("\n", '
', print_r($res, true)); $o .= '
'; } + return $o; } diff --git a/mod/profile.php b/mod/profile.php index 838a55094..7a11e9bc6 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -1,9 +1,10 @@ page,'aside')) diff --git a/mod/profile_photo.php b/mod/profile_photo.php index f9bf60cf5..b2bf6e3b1 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -1,5 +1,7 @@ user['nickname']); - } - function profile_photo_post(App $a) { if (! local_user()) { diff --git a/mod/profiles.php b/mod/profiles.php index bd57f106d..42699e5e0 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -1,4 +1,7 @@ +use Friendica\App; + define('PROXY_DEFAULT_TIME', 86400); // 1 Day define('PROXY_SIZE_MICRO', 'micro'); diff --git a/mod/pubsub.php b/mod/pubsub.php index 2ba1958a2..ba5e05b0e 100644 --- a/mod/pubsub.php +++ b/mod/pubsub.php @@ -1,5 +1,7 @@ diff --git a/mod/qsearch.php b/mod/qsearch.php index 8512bea51..ba62fce0d 100644 --- a/mod/qsearch.php +++ b/mod/qsearch.php @@ -1,5 +1,7 @@ - - - Friendica - http://friendica.com/ - - - - http://status.net/wiki/TwitterCompatibleAPI - false - - - - - - '; -die(); + + + Friendica + http://friendica.com/ + + + + http://status.net/wiki/TwitterCompatibleAPI + false + + + + +'; + + killme(); } \ No newline at end of file diff --git a/mod/salmon.php b/mod/salmon.php index 10b1046b0..f42e05dea 100644 --- a/mod/salmon.php +++ b/mod/salmon.php @@ -1,5 +1,7 @@ argc > 1) ? intval($a->argv[1]) : 0); diff --git a/mod/smilies.php b/mod/smilies.php index 4d8ab6bca..289ad887f 100644 --- a/mod/smilies.php +++ b/mod/smilies.php @@ -3,19 +3,19 @@ /** * @file mod/smilies.php */ +use Friendica\App; require_once("include/Smilies.php"); function smilies_content(App $a) { - if ($a->argv[1]==="json"){ + if ($a->argv[1] === "json") { $tmp = Smilies::get_list(); $results = array(); - for($i = 0; $i < count($tmp['texts']); $i++) { + for ($i = 0; $i < count($tmp['texts']); $i++) { $results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]); } json_return_and_die($results); - } - else { - return Smilies::replace('',true); + } else { + return Smilies::replace('', true); } } diff --git a/mod/starred.php b/mod/starred.php index 46d3fcff6..e1b38cfc4 100644 --- a/mod/starred.php +++ b/mod/starred.php @@ -1,5 +1,6 @@ $a->config["sitename"], - "network" => FRIENDICA_PLATFORM, - "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION, - "registrations_open" => ($a->config['register_policy'] != 0), - "total_users" => get_config('nodeinfo','total_users'), - "active_users_halfyear" => get_config('nodeinfo','active_users_halfyear'), - "active_users_monthly" => get_config('nodeinfo','active_users_monthly'), - "local_posts" => get_config('nodeinfo','local_posts') - ); + "name" => $a->config["sitename"], + "network" => FRIENDICA_PLATFORM, + "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION, + "registrations_open" => ($a->config['register_policy'] != 0), + "total_users" => get_config('nodeinfo', 'total_users'), + "active_users_halfyear" => get_config('nodeinfo', 'active_users_halfyear'), + "active_users_monthly" => get_config('nodeinfo', 'active_users_monthly'), + "local_posts" => get_config('nodeinfo', 'local_posts') + ); $statistics["services"] = array(); $statistics["services"]["appnet"] = plugin_enabled("appnet"); @@ -53,7 +56,7 @@ function statistics_json_init(App $a) { $statistics["wordpress"] = $statistics["services"]["wordpress"]; header("Content-Type: application/json"); - echo json_encode($statistics, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); - logger("statistics_init: printed ".print_r($statistics, true), LOGGER_DATA); + echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); + logger("statistics_init: printed " . print_r($statistics, true), LOGGER_DATA); killme(); } diff --git a/mod/subthread.php b/mod/subthread.php index 646a4230c..0745fc0ee 100644 --- a/mod/subthread.php +++ b/mod/subthread.php @@ -1,10 +1,11 @@ tab where wanted function uexport_content(App $a) { if ($a->argc > 1) { header("Content-type: application/json"); - header('Content-Disposition: attachment; filename="'.$a->user['nickname'].'.'.$a->argv[1].'"'); - switch($a->argv[1]) { + header('Content-Disposition: attachment; filename="' . $a->user['nickname'] . '.' . $a->argv[1] . '"'); + switch ($a->argv[1]) { case "backup": uexport_all($a); killme(); @@ -51,9 +52,9 @@ function _uexport_multirow($query) { $result = array(); $r = q($query); if (dbm::is_result($r)) { - foreach($r as $rr){ + foreach ($r as $rr) { $p = array(); - foreach($rr as $k => $v) { + foreach ($rr as $k => $v) { $p[$k] = $v; } $result[] = $p; @@ -66,8 +67,8 @@ function _uexport_row($query) { $result = array(); $r = q($query); if (dbm::is_result($r)) { - foreach($r as $rr) { - foreach($rr as $k => $v) { + foreach ($r as $rr) { + foreach ($rr as $k => $v) { $result[$k] = $v; } } @@ -75,39 +76,38 @@ function _uexport_row($query) { return $result; } - -function uexport_account($a){ +function uexport_account($a) { $user = _uexport_row( - sprintf( "SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval(local_user()) ) + sprintf("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval(local_user())) ); $contact = _uexport_multirow( - sprintf( "SELECT * FROM `contact` WHERE `uid` = %d ",intval(local_user()) ) + sprintf("SELECT * FROM `contact` WHERE `uid` = %d ", intval(local_user())) ); - $profile =_uexport_multirow( - sprintf( "SELECT * FROM `profile` WHERE `uid` = %d ", intval(local_user()) ) + $profile = _uexport_multirow( + sprintf("SELECT * FROM `profile` WHERE `uid` = %d ", intval(local_user())) ); $photo = _uexport_multirow( - sprintf( "SELECT * FROM `photo` WHERE uid = %d AND profile = 1", intval(local_user()) ) + sprintf("SELECT * FROM `photo` WHERE uid = %d AND profile = 1", intval(local_user())) ); foreach ($photo as &$p) { $p['data'] = bin2hex($p['data']); } $pconfig = _uexport_multirow( - sprintf( "SELECT * FROM `pconfig` WHERE uid = %d",intval(local_user()) ) + sprintf("SELECT * FROM `pconfig` WHERE uid = %d", intval(local_user())) ); $group = _uexport_multirow( - sprintf( "SELECT * FROM `group` WHERE uid = %d",intval(local_user()) ) + sprintf("SELECT * FROM `group` WHERE uid = %d", intval(local_user())) ); $group_member = _uexport_multirow( - sprintf( "SELECT * FROM `group_member` WHERE uid = %d",intval(local_user()) ) + sprintf("SELECT * FROM `group_member` WHERE uid = %d", intval(local_user())) ); $output = array( @@ -150,13 +150,8 @@ function uexport_all(App $a) { intval($x), intval(500) ); - /*if (dbm::is_result($r)) { - foreach($r as $rr) - foreach($rr as $k => $v) - $item[][$k] = $v; - }*/ $output = array('item' => $r); - echo json_encode($output)."\n"; + echo json_encode($output) . "\n"; } } diff --git a/mod/uimport.php b/mod/uimport.php index 336ec1c2d..127933b96 100644 --- a/mod/uimport.php +++ b/mod/uimport.php @@ -1,35 +1,37 @@ config['register_policy']) { - case REGISTER_OPEN: - $blocked = 0; - $verified = 1; - break; + switch ($a->config['register_policy']) { + case REGISTER_OPEN: + $blocked = 0; + $verified = 1; + break; - case REGISTER_APPROVE: - $blocked = 1; - $verified = 0; - break; + case REGISTER_APPROVE: + $blocked = 1; + $verified = 0; + break; - default: - case REGISTER_CLOSED: - if ((! x($_SESSION,'authenticated') && (! x($_SESSION,'administrator')))) { - notice( t('Permission denied.') . EOL ); - return; - } - $blocked = 1; - $verified = 0; - break; + default: + case REGISTER_CLOSED: + if ((!x($_SESSION, 'authenticated') && (!x($_SESSION, 'administrator')))) { + notice(t('Permission denied.') . EOL); + return; + } + $blocked = 1; + $verified = 0; + break; } - if (x($_FILES,'accountfile')){ + if (x($_FILES, 'accountfile')) { /// @TODO Pass $blocked / $verified, send email to admin on REGISTER_APPROVE import_account($a, $_FILES['accountfile']); return; @@ -38,26 +40,26 @@ function uimport_post(App $a) { function uimport_content(App $a) { - if ((! local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) { + if ((!local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) { notice("Permission denied." . EOL); return; } - $max_dailies = intval(get_config('system','max_daily_registrations')); + $max_dailies = intval(get_config('system', 'max_daily_registrations')); if ($max_dailies) { $r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day"); if ($r && $r[0]['total'] >= $max_dailies) { logger('max daily registrations exceeded.'); - notice( t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL); + notice(t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL); return; } } - if (x($_SESSION,'theme')) { + if (x($_SESSION, 'theme')) { unset($_SESSION['theme']); } - if (x($_SESSION,'mobile-theme')) { + if (x($_SESSION, 'mobile-theme')) { unset($_SESSION['mobile-theme']); } @@ -65,11 +67,11 @@ function uimport_content(App $a) { return replace_macros($tpl, array( '$regbutt' => t('Import'), '$import' => array( - 'title' => t("Move account"), - 'intro' => t("You can import an account from another Friendica server."), - 'instruct' => t("You need to export your account from the old server and upload it here. We will recreate your old account here with all your contacts. We will try also to inform your friends that you moved here."), - 'warn' => t("This feature is experimental. We can't import contacts from the OStatus network (GNU Social/Statusnet) or from Diaspora"), - 'field' => array('accountfile', t('Account file'),'', t('To export your account, go to "Settings->Export your personal data" and select "Export account"')), + 'title' => t("Move account"), + 'intro' => t("You can import an account from another Friendica server."), + 'instruct' => t("You need to export your account from the old server and upload it here. We will recreate your old account here with all your contacts. We will try also to inform your friends that you moved here."), + 'warn' => t("This feature is experimental. We can't import contacts from the OStatus network (GNU Social/Statusnet) or from Diaspora"), + 'field' => array('accountfile', t('Account file'), '', t('To export your account, go to "Settings->Export your personal data" and select "Export account"')), ), )); } diff --git a/mod/update_community.php b/mod/update_community.php index 9a39489dc..f0e96af48 100644 --- a/mod/update_community.php +++ b/mod/update_community.php @@ -2,6 +2,8 @@ // See update_profile.php for documentation +use Friendica\App; + require_once("mod/community.php"); function update_community_content(App $a) { diff --git a/mod/update_display.php b/mod/update_display.php index 86f4db825..b8538a256 100644 --- a/mod/update_display.php +++ b/mod/update_display.php @@ -2,6 +2,8 @@ // See update_profile.php for documentation +use Friendica\App; + require_once("mod/display.php"); require_once("include/group.php"); diff --git a/mod/update_network.php b/mod/update_network.php index 869973ace..42172486d 100644 --- a/mod/update_network.php +++ b/mod/update_network.php @@ -2,6 +2,8 @@ // See update_profile.php for documentation +use Friendica\App; + require_once("mod/network.php"); require_once("include/group.php"); diff --git a/mod/update_notes.php b/mod/update_notes.php index d27cc4ca9..9fc886155 100644 --- a/mod/update_notes.php +++ b/mod/update_notes.php @@ -5,6 +5,8 @@ * Purpose: AJAX synchronisation of notes page */ +use Friendica\App; + require_once("mod/notes.php"); function update_notes_content(App $a) { diff --git a/mod/update_profile.php b/mod/update_profile.php index b77a9cdcf..5b15f06d3 100644 --- a/mod/update_profile.php +++ b/mod/update_profile.php @@ -5,6 +5,8 @@ * Purpose: AJAX synchronisation of profile page */ +use Friendica\App; + require_once("mod/profile.php"); function update_profile_content(App $a) { diff --git a/mod/videos.php b/mod/videos.php index 269d53785..2ee73c211 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -1,11 +1,13 @@ argc > 1) diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php index 5912f6cc7..f7bf912fd 100644 --- a/mod/viewcontacts.php +++ b/mod/viewcontacts.php @@ -1,4 +1,7 @@ diff --git a/object/Conversation.php b/object/Conversation.php index eb5b3b9b4..f03b3b1c1 100644 --- a/object/Conversation.php +++ b/object/Conversation.php @@ -164,4 +164,3 @@ class Conversation extends BaseObject { return false; } } -?> diff --git a/object/Item.php b/object/Item.php index b693520b9..0042e070a 100644 --- a/object/Item.php +++ b/object/Item.php @@ -112,7 +112,7 @@ class Item extends BaseObject { $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); @@ -754,20 +754,20 @@ class Item extends BaseObject { 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 { @@ -807,5 +807,3 @@ class Item extends BaseObject { } } -/// @TODO These are discouraged and should be removed: -?> diff --git a/src/App.php b/src/App.php new file mode 100644 index 000000000..efb60c038 --- /dev/null +++ b/src/App.php @@ -0,0 +1,980 @@ + '', + '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. + * + * @param string $basepath Path to the app base folder + */ + function __construct($basepath) { + + 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(); + + $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 (! static::directory_usable($basepath)) { + throw new Exception('Basepath ' . $basepath . ' isn\'t usable.'); + } + + $this->basepath = rtrim($basepath, DIRECTORY_SEPARATOR); + + set_include_path( + get_include_path() . PATH_SEPARATOR + . $this->basepath . DIRECTORY_SEPARATOR . 'include' . PATH_SEPARATOR + . $this->basepath . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR + . $this->basepath . DIRECTORY_SEPARATOR . 'library/langdet' . PATH_SEPARATOR + . $this->basepath); + + + 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; + } + + /** + * @brief Returns the base filesystem path of the App + * + * It first checks for the internal variable, then for DOCUMENT_ROOT and + * finally for PWD + * + * @return string + */ + public static function get_basepath() { + if (isset($this)) { + $basepath = $this->basepath; + } + + if (! $basepath) { + $basepath = Config::get('system', 'basepath'); + } + + if (! $basepath && x($_SERVER, 'DOCUMENT_ROOT')) { + $basepath = $_SERVER['DOCUMENT_ROOT']; + } + + if (! $basepath && x($_SERVER, 'PWD')) { + $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 (Config::get('config', 'hostname') != '') { + $this->hostname = Config::get('config', 'hostname'); + } + + if (!isset($this->hostname) OR ( $this->hostname == '')) { + $this->hostname = $hostname; + } + } + } + + function get_hostname() { + if (Config::get('config', 'hostname') != '') { + $this->hostname = Config::get('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()) ? PConfig::get(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 = Config::get('system', 'shortcut_icon'); + if ($shortcut_icon == '') { + $shortcut_icon = 'images/friendica-32.png'; + } + + $touch_icon = Config::get('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 $class 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 $template_engine 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 = Config::get('system', 'max_processes_backend'); + if (intval($max_processes) == 0) { + $max_processes = 5; + } + } else { + $process = 'frontend'; + $max_processes = Config::get('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(Config::get('system', 'maxloadavg')); + if ($maxsysload < 1) { + $maxsysload = 50; + } + } else { + $process = 'frontend'; + $maxsysload = intval(Config::get('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 (Config::get('system', 'proc_windows')) { + $resource = proc_open('cmd /c start /b ' . $cmdline, array(), $foo, $this->get_basepath()); + } else { + $resource = proc_open($cmdline . ' &', array(), $foo, $this->get_basepath()); + } + 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; + } +} diff --git a/src/ParseUrl.php b/src/ParseUrl.php index e9ac527a1..943725ffe 100644 --- a/src/ParseUrl.php +++ b/src/ParseUrl.php @@ -7,7 +7,7 @@ namespace Friendica; -use \Friendica\Core\Config; +use Friendica\Core\Config; require_once("include/network.php"); require_once("include/Photo.php"); diff --git a/tests/xss_filter_test.php b/tests/xss_filter_test.php index 3fb6ac310..5bc8e0ad3 100644 --- a/tests/xss_filter_test.php +++ b/tests/xss_filter_test.php @@ -1,7 +1,7 @@ I want to break\n this!11!"; - $xml=xmlify($text); + $xml=xmlify($text); $retext=unxmlify($text); $this->assertEquals($text, $retext); } - - /** - * xmlify and put in a document - */ - public function testXmlifyDocument() { - $tag="I want to break"; + + /** + * xmlify and put in a document + */ + public function testXmlifyDocument() { + $tag="I want to break"; $xml=xmlify($tag); - $text=''.$xml.''; - - $xml_parser=xml_parser_create(); + $text=''.$xml.''; + + $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)), + $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); + + xml_parser_free($xml_parser); } /** @@ -68,4 +68,3 @@ class AntiXSSTest extends PHPUnit_Framework_TestCase { //get_mentions //get_contact_block, bis Zeile 538 } -?> diff --git a/util/createdoxygen.php b/util/createdoxygen.php index 163c94bb9..798c81474 100644 --- a/util/createdoxygen.php +++ b/util/createdoxygen.php @@ -91,4 +91,3 @@ function add_documentation($line) { return $block; } -?> diff --git a/util/daemon.php b/util/daemon.php index 266ddcd75..4accef396 100644 --- a/util/daemon.php +++ b/util/daemon.php @@ -98,4 +98,3 @@ while (true) { // Now sleep for 5 minutes sleep(300); } -?> diff --git a/util/db_update.php b/util/db_update.php index 32b44e6d0..1e717e987 100644 --- a/util/db_update.php +++ b/util/db_update.php @@ -1,14 +1,17 @@ - * - * Output to - */ - - DEFINE("NORM_REGEXP", "|[\\\]|"); - - - if(! class_exists('App')) { - class TmpA { - public $strings = Array(); +/** + * Read strings.php file and create messages.po + * + * php utils/php2po.php + * + * Output to + */ + +use Friendica\App; + +DEFINE("NORM_REGEXP", "|[\\\]|"); + +if(! class_exists('App')) { + class TmpA { + public $strings = Array(); + } + $a = new TmpA(); +} + +if ($argc<2 || in_array('-h', $argv) || in_array('--h', $argv)) { + print "Usage: ".$argv[0]." [-p ] \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]; +} + +$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; + } +} + +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); } - $a = new TmpA(); + + $_f = 0; + $_mid = ""; + $_mids = array(); + } - if ($argc<2 || in_array('-h', $argv) || in_array('--h', $argv)) { - print "Usage: ".$argv[0]." [-p ] \n\n"; - print "Options:\n"; - print "p\tNumber of plural forms. Default: 2\n"; - print "\n"; - return; + 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); } - $phpfile = $argv[1]; - $pofile = dirname($phpfile)."/messages.po"; - - if (!file_exists($phpfile)){ - print "Unable to find '$phpfile'\n"; - return; + if (startsWith($l, '"') && $_f==1) { + $_mid .= "\n".$l; + $_mids[count($_mids)-1] .= "\n".$l; + //~ print "\t+mid: $_mid \n"; } - - // 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 (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 - // start ! - include_once($phpfile); +/** + * 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); +} - $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]; +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]; } - - $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) ); + return $str; +} + +$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"; } - if (startsWith($l, 'return')) { - $lang_logic = str_replace( '$', '', trim( str_replace( 'return ' , '', $l) , ';') ); - break; + foreach ( $str as $n => $msgstr) { + $out .= 'msgstr['.$n.'] '. massage_string($msgstr) . "\n"; } + } else { + $out .= 'msgstr '. massage_string($str) . "\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); - } - - $_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"; - } - //~ 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); - - 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"; - - } +} - file_put_contents($pofile, $out); - - print " done\n"; - - if ($warnings=="") { - print "No warnings.\n"; - } else { - print $warnings; - } - +file_put_contents($pofile, $out); + +print " done\n"; + +if ($warnings=="") { + print "No warnings.\n"; +} else { + print $warnings; +} diff --git a/util/typo.php b/util/typo.php old mode 100644 new mode 100755 index d68ac2ac9..1b84181db --- a/util/typo.php +++ b/util/typo.php @@ -1,59 +1,77 @@ +#!/usr/bin/env php 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'); + +foreach (new RecursiveIteratorIterator($Iterator) as $file) { + if (substr($file, -4) === '.php') { + passthru("$phpath -l $file", $ret); + $ret === 0 or die(); } +} - echo "Directory: include\n"; - $files = glob('include/*.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: include\n"; +$files = glob('include/*.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/*'); + +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 "String files\n"; - echo "Directory: addon\n"; - $dirs = glob('addon/*'); +echo 'util/strings.php' . "\n"; +passthru("$phpath -l util/strings.php", $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 "String files\n"; - - 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(); - } +$files = glob('view/lang/*/strings.php'); +foreach ($files as $file) { + passthru("$phpath -l $file", $ret); + $ret === 0 or die(); +} diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 4553da2e2..58744c098 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -9,6 +9,7 @@ return array( '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', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 37d3c878b..0ea04c537 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -53,6 +53,7 @@ class ComposerStaticInitFriendica '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', diff --git a/vendor/composer/include_paths.php b/vendor/composer/include_paths.php index e10abddcd..1d4a52943 100644 --- a/vendor/composer/include_paths.php +++ b/vendor/composer/include_paths.php @@ -11,6 +11,6 @@ return array( $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', ); diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 45038987b..d6cca604f 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -256,47 +256,6 @@ ], "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", @@ -396,5 +355,46 @@ "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" } ] diff --git a/vendor/pear-pear.php.net/PEAR/OS/Guess.php b/vendor/pear-pear.php.net/PEAR/OS/Guess.php index 7e8e8d3f8..ffa15355c 100644 --- a/vendor/pear-pear.php.net/PEAR/OS/Guess.php +++ b/vendor/pear-pear.php.net/PEAR/OS/Guess.php @@ -86,7 +86,7 @@ * @author Gregory Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR.php b/vendor/pear-pear.php.net/PEAR/PEAR.php index 7aa3c4ce5..5737f71b1 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR.php @@ -75,7 +75,7 @@ $GLOBALS['_PEAR_error_handler_stack'] = array(); * @author Greg Beaver * @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 @@ -170,7 +170,7 @@ class PEAR $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; @@ -598,11 +598,11 @@ class PEAR 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; } @@ -823,7 +823,7 @@ function _PEAR_call_destructors() * @author Gregory Beaver * @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 diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Builder.php b/vendor/pear-pear.php.net/PEAR/PEAR/Builder.php index 9df3b9eac..d69bc14f1 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Builder.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Builder.php @@ -33,7 +33,7 @@ require_once 'System.php'; * @author Greg Beaver * @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 @@ -385,7 +385,7 @@ class PEAR_Builder extends PEAR_Common 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)) { diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/ChannelFile.php b/vendor/pear-pear.php.net/PEAR/PEAR/ChannelFile.php index 9e990d134..d81deb43a 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/ChannelFile.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/ChannelFile.php @@ -145,7 +145,7 @@ $GLOBALS['_PEAR_CHANNELS_MIRROR_TYPES'] = array('server'); * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/ChannelFile/Parser.php b/vendor/pear-pear.php.net/PEAR/PEAR/ChannelFile/Parser.php index 56376add6..01bb7f3fb 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/ChannelFile/Parser.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/ChannelFile/Parser.php @@ -25,7 +25,7 @@ require_once 'PEAR/ChannelFile.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Command.php b/vendor/pear-pear.php.net/PEAR/PEAR/Command.php index 39823c674..411f7a49b 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Command.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Command.php @@ -93,7 +93,7 @@ $GLOBALS['_PEAR_Command_objects'] = array(); * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Auth.php b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Auth.php index fa2b22bf5..fecfd875e 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Auth.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Auth.php @@ -29,7 +29,7 @@ require_once 'PEAR/Command/Channels.php'; * @author Greg Beaver * @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 diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Build.php b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Build.php index 3bb99454d..aecc90d8b 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Build.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Build.php @@ -30,7 +30,7 @@ require_once 'PEAR/Command/Common.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Channels.php b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Channels.php index b9286370a..fa190d39c 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Channels.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Channels.php @@ -31,7 +31,7 @@ define('PEAR_COMMAND_CHANNELS_CHANNEL_EXISTS', -500); * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Common.php b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Common.php index 41384ef0b..8d972b6f1 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Common.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Common.php @@ -28,7 +28,7 @@ require_once 'PEAR.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Config.php b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Config.php index 63efb07be..18dd61451 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Config.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Config.php @@ -28,7 +28,7 @@ require_once 'PEAR/Command/Common.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Install.php b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Install.php index a1d3a7023..42c1f5586 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Install.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Install.php @@ -29,7 +29,7 @@ require_once 'PEAR/Command/Common.php'; * @author Greg Beaver * @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 */ @@ -717,8 +717,7 @@ Run post-installation scripts in package , if any exist. $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, diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Mirror.php b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Mirror.php index 473c62867..616417cb3 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Mirror.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Mirror.php @@ -26,7 +26,7 @@ require_once 'PEAR/Command/Common.php'; * @author Alexander Merz * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Package.php b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Package.php index 25125fd98..8847112e6 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Package.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Package.php @@ -31,7 +31,7 @@ require_once 'PEAR/Command/Common.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Pickle.php b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Pickle.php index 8ac3fcb6b..7a7bd81c0 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Pickle.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Pickle.php @@ -26,7 +26,7 @@ require_once 'PEAR/Command/Common.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Registry.php b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Registry.php index 3a78b0330..b5423c762 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Registry.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Registry.php @@ -28,7 +28,7 @@ require_once 'PEAR/Command/Common.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Remote.php b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Remote.php index c0a8e92a8..817b73328 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Remote.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Remote.php @@ -30,7 +30,7 @@ require_once 'PEAR/REST.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Test.php b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Test.php index 69c72c4aa..0f6c8dc24 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Command/Test.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Command/Test.php @@ -30,7 +30,7 @@ require_once 'PEAR/Command/Common.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Common.php b/vendor/pear-pear.php.net/PEAR/PEAR/Common.php index 1c4f79ceb..0b00b00bc 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Common.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Common.php @@ -117,7 +117,7 @@ $GLOBALS['_PEAR_Common_script_phases'] = array('pre-install', 'post-install', 'p * @author Greg Beaver * @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 diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Config.php b/vendor/pear-pear.php.net/PEAR/PEAR/Config.php index d9b4d273c..e86c50134 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Config.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Config.php @@ -264,7 +264,7 @@ if (getenv('PHP_PEAR_SIG_KEYDIR')) { * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Dependency2.php b/vendor/pear-pear.php.net/PEAR/PEAR/Dependency2.php index 77646f1f9..b142883b3 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Dependency2.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Dependency2.php @@ -30,7 +30,7 @@ require_once 'PEAR/Validate.php'; * @author Greg Beaver * @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 */ @@ -540,7 +540,7 @@ class PEAR_Dependency2 */ function getPEARVersion() { - return '1.10.3'; + return '1.10.4'; } function validatePearinstallerDependency($dep) diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/DependencyDB.php b/vendor/pear-pear.php.net/PEAR/PEAR/DependencyDB.php index 5421929a2..0d48613ac 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/DependencyDB.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/DependencyDB.php @@ -29,7 +29,7 @@ $GLOBALS['_PEAR_DEPENDENCYDB_INSTANCE'] = array(); * @author Tomas V.V.Cox * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Downloader.php b/vendor/pear-pear.php.net/PEAR/PEAR/Downloader.php index 15f26bcef..a498f134b 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Downloader.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Downloader.php @@ -39,7 +39,7 @@ define('PEAR_INSTALLER_ERROR_NO_PREF_STATE', 2); * @author Martin Jansen * @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 */ @@ -1635,7 +1635,7 @@ class PEAR_Downloader extends PEAR_Common } $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); diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Downloader/Package.php b/vendor/pear-pear.php.net/PEAR/PEAR/Downloader/Package.php index 925c0ecd5..42b35b5b6 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Downloader/Package.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Downloader/Package.php @@ -49,7 +49,7 @@ define('PEAR_DOWNLOADER_PACKAGE_PHPVERSION', -1004); * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/ErrorStack.php b/vendor/pear-pear.php.net/PEAR/PEAR/ErrorStack.php index b4412744a..53eda7c3d 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/ErrorStack.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/ErrorStack.php @@ -131,7 +131,7 @@ define('PEAR_ERRORSTACK_ERR_OBJTOSTRING', 2); * $local_stack = new PEAR_ErrorStack('MyPackage'); * * @author Greg Beaver - * @version 1.10.3 + * @version 1.10.4 * @package PEAR_ErrorStack * @category Debugging * @copyright 2004-2008 Greg Beaver diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Exception.php b/vendor/pear-pear.php.net/PEAR/PEAR/Exception.php index d83950b13..d0e84dc1f 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Exception.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Exception.php @@ -88,7 +88,7 @@ * @author Greg Beaver * @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 * diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Frontend.php b/vendor/pear-pear.php.net/PEAR/PEAR/Frontend.php index bd002c374..a9d9b73cc 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Frontend.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Frontend.php @@ -38,7 +38,7 @@ $GLOBALS['_PEAR_FRONTEND_SINGLETON'] = null; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Frontend/CLI.php b/vendor/pear-pear.php.net/PEAR/PEAR/Frontend/CLI.php index 4e68c065a..5e83216ed 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Frontend/CLI.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Frontend/CLI.php @@ -26,7 +26,7 @@ require_once 'PEAR/Frontend.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Installer.php b/vendor/pear-pear.php.net/PEAR/PEAR/Installer.php index acaaa7fd0..b96b8e011 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Installer.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Installer.php @@ -35,7 +35,7 @@ define('PEAR_INSTALLER_NOBINARY', -240); * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role.php b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role.php index 58b661bbf..0ca3bac63 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role.php @@ -24,7 +24,7 @@ require_once 'PEAR/XMLParser.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Cfg.php b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Cfg.php index 5b75c44cc..eb126b62d 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Cfg.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Cfg.php @@ -19,7 +19,7 @@ * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Common.php b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Common.php index 3e15d8778..1bd8f78cc 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Common.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Common.php @@ -23,7 +23,7 @@ * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Data.php b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Data.php index 75acfef80..ad2957780 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Data.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Data.php @@ -19,7 +19,7 @@ * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Doc.php b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Doc.php index 9374990c4..31c069fed 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Doc.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Doc.php @@ -19,7 +19,7 @@ * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Ext.php b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Ext.php index 6cd4d2b0a..71d07d422 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Ext.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Ext.php @@ -19,7 +19,7 @@ * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Man.php b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Man.php index 68b79366a..91a586b3a 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Man.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Man.php @@ -20,7 +20,7 @@ * @author Hannes Magnusson * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Php.php b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Php.php index 6a7a937de..e07743ab8 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Php.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Php.php @@ -19,7 +19,7 @@ * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Script.php b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Script.php index 387fdb3f5..907b10114 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Script.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Script.php @@ -19,7 +19,7 @@ * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Src.php b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Src.php index c92f2cf0b..aaa9622e5 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Src.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Src.php @@ -19,7 +19,7 @@ * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Test.php b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Test.php index 87133af46..b21450fe5 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Test.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Test.php @@ -19,7 +19,7 @@ * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Www.php b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Www.php index e211c1e8f..043cd360a 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Www.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Installer/Role/Www.php @@ -19,7 +19,7 @@ * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile.php b/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile.php index 21d26b6df..d73671dd5 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile.php @@ -34,7 +34,7 @@ define('PEAR_PACKAGEFILE_ERROR_INVALID_PACKAGEVERSION', 2); * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/Generator/v1.php b/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/Generator/v1.php index 707781c30..5e379f85b 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/Generator/v1.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/Generator/v1.php @@ -28,7 +28,7 @@ require_once 'PEAR/PackageFile/v2.php'; * @author Greg Beaver * @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 */ @@ -45,7 +45,7 @@ class PEAR_PackageFile_Generator_v1 function getPackagerVersion() { - return '1.10.3'; + return '1.10.4'; } /** @@ -196,7 +196,7 @@ class PEAR_PackageFile_Generator_v1 ); $ret = "\n"; $ret .= "\n"; - $ret .= "\n" . + $ret .= "\n" . " $pkginfo[package]"; if (isset($pkginfo['extends'])) { $ret .= "\n$pkginfo[extends]"; diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/Generator/v2.php b/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/Generator/v2.php index 1c97296b7..a44a9c5a5 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/Generator/v2.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/Generator/v2.php @@ -30,7 +30,7 @@ require_once 'XML/Util.php'; * @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 */ @@ -112,7 +112,7 @@ http://pear.php.net/dtd/package-2.0.xsd', */ function getPackagerVersion() { - return '1.10.3'; + return '1.10.4'; } /** @@ -397,7 +397,7 @@ http://pear.php.net/dtd/package-2.0.xsd', $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"; } diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v1.php b/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v1.php index 6bb3276ee..d9d19f654 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v1.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v1.php @@ -274,7 +274,7 @@ define('PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME', 52); * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v2.php b/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v2.php index 248997a6a..ab2f539b4 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v2.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v2.php @@ -22,7 +22,7 @@ require_once 'PEAR/ErrorStack.php'; * @author Greg Beaver * @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 */ @@ -1668,7 +1668,7 @@ class PEAR_PackageFile_v2 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) { diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v2/Validator.php b/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v2/Validator.php index f7c8921e1..a6b01d57b 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v2/Validator.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v2/Validator.php @@ -20,7 +20,7 @@ * @author Greg Beaver * @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 @@ -111,8 +111,8 @@ class PEAR_PackageFile_v2_Validator 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']); @@ -1350,7 +1350,7 @@ class PEAR_PackageFile_v2_Validator $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) diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v2/rw.php b/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v2/rw.php index c52ff4f3c..3346639b8 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v2/rw.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/PackageFile/v2/rw.php @@ -22,7 +22,7 @@ require_once 'PEAR/PackageFile/v2.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Packager.php b/vendor/pear-pear.php.net/PEAR/PEAR/Packager.php index 713bc708c..f92565bd5 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Packager.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Packager.php @@ -30,7 +30,7 @@ require_once 'System.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/REST.php b/vendor/pear-pear.php.net/PEAR/PEAR/REST.php index aec7cf234..419b7fbfa 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/REST.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/REST.php @@ -28,7 +28,7 @@ require_once 'PEAR/Proxy.php'; * @author Greg Beaver * @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 */ @@ -384,7 +384,7 @@ class PEAR_REST } $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); diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/REST/10.php b/vendor/pear-pear.php.net/PEAR/PEAR/REST/10.php index ac0aeab3a..040371cdb 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/REST/10.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/REST/10.php @@ -26,7 +26,7 @@ require_once 'PEAR/REST.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/REST/11.php b/vendor/pear-pear.php.net/PEAR/PEAR/REST/11.php index a7e713ac4..e2d3875fd 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/REST/11.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/REST/11.php @@ -26,7 +26,7 @@ require_once 'PEAR/REST.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/REST/13.php b/vendor/pear-pear.php.net/PEAR/PEAR/REST/13.php index 6469fd30d..0509897b8 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/REST/13.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/REST/13.php @@ -27,7 +27,7 @@ require_once 'PEAR/REST/10.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Registry.php b/vendor/pear-pear.php.net/PEAR/PEAR/Registry.php index c599c61ee..5588f23f4 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Registry.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Registry.php @@ -36,7 +36,7 @@ define('PEAR_REGISTRY_ERROR_CHANNEL_FILE', -6); * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/RunTest.php b/vendor/pear-pear.php.net/PEAR/PEAR/RunTest.php index 271ef86bd..95797665e 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/RunTest.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/RunTest.php @@ -37,7 +37,7 @@ putenv("PHP_PEAR_RUNTESTS=1"); * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Common.php b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Common.php index e433c3e26..3ae59159b 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Common.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Common.php @@ -47,7 +47,7 @@ define('PEAR_TASK_PACKAGEANDINSTALL', 3); * @author Greg Beaver * @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 diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Postinstallscript.php b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Postinstallscript.php index 457ac28f6..154952f4f 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Postinstallscript.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Postinstallscript.php @@ -27,7 +27,7 @@ require_once 'PEAR/Task/Common.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Postinstallscript/rw.php b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Postinstallscript/rw.php index 10f5e7b26..7aa699bb3 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Postinstallscript/rw.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Postinstallscript/rw.php @@ -23,7 +23,7 @@ require_once 'PEAR/Task/Postinstallscript.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Replace.php b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Replace.php index 1ea71bfe5..a5fc779ef 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Replace.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Replace.php @@ -23,7 +23,7 @@ require_once 'PEAR/Task/Common.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Replace/rw.php b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Replace/rw.php index a2ffc24b1..608014646 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Replace/rw.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Replace/rw.php @@ -23,7 +23,7 @@ require_once 'PEAR/Task/Replace.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Unixeol.php b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Unixeol.php index 3b1d84c9a..5bf2ac051 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Unixeol.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Unixeol.php @@ -23,7 +23,7 @@ require_once 'PEAR/Task/Common.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Unixeol/rw.php b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Unixeol/rw.php index 7e98f2184..7316ba05f 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Unixeol/rw.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Unixeol/rw.php @@ -23,7 +23,7 @@ require_once 'PEAR/Task/Unixeol.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Windowseol.php b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Windowseol.php index e0f2f26d8..190f21381 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Windowseol.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Windowseol.php @@ -24,7 +24,7 @@ require_once 'PEAR/Task/Common.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Windowseol/rw.php b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Windowseol/rw.php index 2f10c5eb2..4ef537b7c 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Task/Windowseol/rw.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Task/Windowseol/rw.php @@ -24,7 +24,7 @@ require_once 'PEAR/Task/Windowseol.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Validate.php b/vendor/pear-pear.php.net/PEAR/PEAR/Validate.php index 0dc7433c1..4b98b3ad5 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Validate.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Validate.php @@ -31,7 +31,7 @@ require_once 'PEAR/Validator/PECL.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/Validator/PECL.php b/vendor/pear-pear.php.net/PEAR/PEAR/Validator/PECL.php index 157cda327..44bfb4f48 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/Validator/PECL.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/Validator/PECL.php @@ -23,7 +23,7 @@ require_once 'PEAR/Validate.php'; * @author Greg Beaver * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/PEAR/XMLParser.php b/vendor/pear-pear.php.net/PEAR/PEAR/XMLParser.php index 85b10a72a..f0fa553d3 100644 --- a/vendor/pear-pear.php.net/PEAR/PEAR/XMLParser.php +++ b/vendor/pear-pear.php.net/PEAR/PEAR/XMLParser.php @@ -22,7 +22,7 @@ * @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 */ diff --git a/vendor/pear-pear.php.net/PEAR/System.php b/vendor/pear-pear.php.net/PEAR/System.php index 3184f4694..146346b57 100644 --- a/vendor/pear-pear.php.net/PEAR/System.php +++ b/vendor/pear-pear.php.net/PEAR/System.php @@ -50,7 +50,7 @@ $GLOBALS['_System_temp_files'] = array(); * @author Tomas V.V. Cox * @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 diff --git a/vendor/pear-pear.php.net/PEAR/pearcmd.php b/vendor/pear-pear.php.net/PEAR/pearcmd.php index e089c818e..60cb9769b 100644 --- a/vendor/pear-pear.php.net/PEAR/pearcmd.php +++ b/vendor/pear-pear.php.net/PEAR/pearcmd.php @@ -41,7 +41,7 @@ ob_implicit_flush(true); $_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'; diff --git a/view/php/default.php b/view/php/default.php index e51b531b5..17d4961fc 100644 --- a/view/php/default.php +++ b/view/php/default.php @@ -2,7 +2,7 @@ <?php if(x($page,'title')) echo $page['title'] ?> - + diff --git a/view/php/minimal.php b/view/php/minimal.php index e93aac112..39888630a 100644 --- a/view/php/minimal.php +++ b/view/php/minimal.php @@ -2,7 +2,7 @@ <?php if(x($page,'title')) echo $page['title'] ?> - + diff --git a/view/theme/duepuntozero/config.php b/view/theme/duepuntozero/config.php index 381b06716..b1ec4bae5 100644 --- a/view/theme/duepuntozero/config.php +++ b/view/theme/duepuntozero/config.php @@ -1,8 +1,11 @@ diff --git a/view/theme/duepuntozero/theme.php b/view/theme/duepuntozero/theme.php index c674a99d9..dc8f29b2f 100644 --- a/view/theme/duepuntozero/theme.php +++ b/view/theme/duepuntozero/theme.php @@ -1,5 +1,7 @@ <?php if(x($page,'title')) echo $page['title'] ?> - + - + - - + - + diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php index a873e4513..e0c382661 100644 --- a/view/theme/frio/theme.php +++ b/view/theme/frio/theme.php @@ -7,6 +7,8 @@ * */ +use Friendica\App; + $frio = "view/theme/frio"; global $frio; @@ -130,7 +132,7 @@ function frio_item_photo_menu(App $a, &$arr) { * 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){ @@ -182,7 +184,7 @@ 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) { @@ -271,7 +273,7 @@ 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"])) : ""); diff --git a/view/theme/frost-mobile/php/default.php b/view/theme/frost-mobile/php/default.php index d739f56f2..062ec3b8a 100644 --- a/view/theme/frost-mobile/php/default.php +++ b/view/theme/frost-mobile/php/default.php @@ -2,7 +2,7 @@ <?php if(x($page,'title')) echo $page['title'] ?> - + module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>> diff --git a/view/theme/frost-mobile/theme.php b/view/theme/frost-mobile/theme.php index 7e4262cb6..24f41073e 100644 --- a/view/theme/frost-mobile/theme.php +++ b/view/theme/frost-mobile/theme.php @@ -9,6 +9,8 @@ * Maintainer: Zach P */ +use Friendica\App; + function frost_mobile_init(App $a) { $a->sourcename = 'Friendica mobile web'; $a->videowidth = 250; diff --git a/view/theme/frost/php/default.php b/view/theme/frost/php/default.php index 0fe3404f6..306345d39 100644 --- a/view/theme/frost/php/default.php +++ b/view/theme/frost/php/default.php @@ -2,7 +2,7 @@ <?php if(x($page,'title')) echo $page['title'] ?> - + module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>> diff --git a/view/theme/frost/theme.php b/view/theme/frost/theme.php index 4c22f0a11..b09153876 100644 --- a/view/theme/frost/theme.php +++ b/view/theme/frost/theme.php @@ -9,6 +9,8 @@ * Maintainer: Zach P */ +use Friendica\App; + function frost_init(App $a) { $a->videowidth = 400; $a->videoheight = 330; diff --git a/view/theme/quattro/config.php b/view/theme/quattro/config.php index 993f778f8..47210012c 100644 --- a/view/theme/quattro/config.php +++ b/view/theme/quattro/config.php @@ -1,8 +1,11 @@ */ +use Friendica\App; + function quattro_init(App $a) { $a->page['htmlhead'] .= ''; $a->page['htmlhead'] .= '';; diff --git a/view/theme/smoothly/php/default.php b/view/theme/smoothly/php/default.php index 1e97c6b46..568f267c1 100644 --- a/view/theme/smoothly/php/default.php +++ b/view/theme/smoothly/php/default.php @@ -2,7 +2,7 @@ <?php if(x($page,'title')) echo $page['title'] ?> - + EOT; - /** custom css **/ + /** custom css **/ if (!is_null($cssFile)) { $a->page['htmlhead'] .= sprintf('', $cssFile); } -_js_in_foot(); - + _js_in_foot(); } if (! function_exists('_js_in_foot')) { diff --git a/view/theme/vier/config.php b/view/theme/vier/config.php index 9fd19e8ab..0747770d3 100644 --- a/view/theme/vier/config.php +++ b/view/theme/vier/config.php @@ -1,9 +1,10 @@