Yet more standards

This commit is contained in:
Hypolite Petovan 2017-05-02 22:42:29 -04:00
parent a76256e6e9
commit 3437e73ae4
6 changed files with 153 additions and 178 deletions

View file

@ -1,4 +1,5 @@
<?php
/** @file boot.php
*
* This file defines some global constants and includes the central App class.
@ -22,18 +23,18 @@ require_once(__DIR__ . DIRECTORY_SEPARATOR. 'vendor' . DIRECTORY_SEPARATOR . 'au
use Friendica\App;
use Friendica\Core\Config;
require_once('include/config.php');
require_once('include/network.php');
require_once('include/plugin.php');
require_once('include/text.php');
require_once('include/datetime.php');
require_once('include/pgettext.php');
require_once('include/nav.php');
require_once('include/cache.php');
require_once('include/features.php');
require_once('include/identity.php');
require_once('update.php');
require_once('include/dbstructure.php');
require_once 'include/config.php';
require_once 'include/network.php';
require_once 'include/plugin.php';
require_once 'include/text.php';
require_once 'include/datetime.php';
require_once 'include/pgettext.php';
require_once 'include/nav.php';
require_once 'include/cache.php';
require_once 'include/features.php';
require_once 'include/identity.php';
require_once 'update.php';
require_once 'include/dbstructure.php';
define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_CODENAME', 'Asparagus');
@ -51,7 +52,6 @@ define ( 'DB_UPDATE_VERSION', 1222 );
define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
/**
* @brief Image storage quality.
*
@ -62,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
*/
@ -87,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
@ -166,7 +164,6 @@ define ( 'UPDATE_SUCCESS', 0);
define ( 'UPDATE_FAILED', 1);
/** @}*/
/**
* @name page/profile types
*
@ -292,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
*
@ -346,8 +339,6 @@ define ( 'TERM_CONVERSATION', 7 );
define ( 'TERM_OBJ_POST', 1 );
define ( 'TERM_OBJ_PHOTO', 2 );
/**
* @name Namespaces
*
@ -459,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.
@ -474,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);
@ -484,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)) {
@ -500,7 +487,6 @@ function startup() {
}
unset($process);
}
}
/**
@ -513,7 +499,6 @@ function get_app() {
return $a;
}
/**
* @brief Multi-purpose function to check variable state.
*
@ -548,7 +533,6 @@ function x($s,$k = NULL) {
}
}
/**
* @brief Called from db initialisation if db is dead.
*/
@ -558,7 +542,6 @@ function system_unavailable() {
killme();
}
function clean_urls() {
$a = get_app();
return true;
@ -619,10 +602,8 @@ function check_db() {
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
@ -647,7 +628,6 @@ function check_url(App $a) {
return;
}
/**
* @brief Automatic database updates
*/
@ -665,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.
@ -726,7 +705,6 @@ 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.
@ -813,14 +791,12 @@ function check_plugins(App $a) {
}
}
load_hooks();
return;
}
function get_guid($size = 16, $prefix = "") {
if ($prefix == "") {
$a = get_app();
$prefix = hash("crc32", $a->get_hostname());
@ -905,7 +881,6 @@ function login($register = false, $hiddens=false) {
'$privacytitle' => t('Website Privacy Policy'),
'$privacylink' => t('privacy policy'),
));
call_hooks('login_hook', $o);
@ -917,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();
}
@ -937,7 +911,6 @@ function goaway($s) {
killme();
}
/**
* @brief Returns the user id of locally logged in user or false.
*
@ -1024,7 +997,6 @@ function info($s) {
}
}
/**
* @brief Wrapper around config to limit the text length of an incoming message
*
@ -1105,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`)
@ -1267,8 +1238,6 @@ function feed_birthday($uid,$tz) {
* 6:00PM the day before, but that will correspond to midnight to the birthday person.
*
*/
$birthday = '';
if (!strlen($tz)) {

View file

@ -91,7 +91,6 @@ function poller_run($argv, $argc){
if (time() > ($starttime + 3600))
return;
}
}
/**

View file

@ -16,8 +16,8 @@
use Friendica\App;
use Friendica\Core\Config;
require_once('boot.php');
require_once('object/BaseObject.php');
require_once 'boot.php';
require_once 'object/BaseObject.php';
$a = new App;
BaseObject::set_app($a);
@ -74,7 +74,7 @@ if (!$install) {
exit();
}
require_once("include/session.php");
require_once 'include/session.php';
load_hooks();
call_hooks('init_1');

View file

@ -375,8 +375,8 @@ class App {
include '.htpreconfig.php';
}
if (get_config('config', 'hostname') != '') {
$this->hostname = get_config('config', 'hostname');
if (Config::get('config', 'hostname') != '') {
$this->hostname = Config::get('config', 'hostname');
}
if (!isset($this->hostname) OR ( $this->hostname == '')) {
@ -386,8 +386,8 @@ class App {
}
function get_hostname() {
if (get_config('config', 'hostname') != '') {
$this->hostname = get_config('config', 'hostname');
if (Config::get('config', 'hostname') != '') {
$this->hostname = Config::get('config', 'hostname');
}
return $this->hostname;
@ -420,7 +420,7 @@ class App {
}
function init_pagehead() {
$interval = ((local_user()) ? get_pconfig(local_user(), 'system', 'update_interval') : 40000);
$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) {
@ -457,12 +457,12 @@ class App {
$stylesheet = '$stylesheet';
}
$shortcut_icon = get_config('system', 'shortcut_icon');
$shortcut_icon = Config::get('system', 'shortcut_icon');
if ($shortcut_icon == '') {
$shortcut_icon = 'images/friendica-32.png';
}
$touch_icon = get_config('system', 'touch_icon');
$touch_icon = Config::get('system', 'touch_icon');
if ($touch_icon == '') {
$touch_icon = 'images/friendica-128.png';
}
@ -773,13 +773,13 @@ class App {
if ($this->is_backend()) {
$process = 'backend';
$max_processes = get_config('system', 'max_processes_backend');
$max_processes = Config::get('system', 'max_processes_backend');
if (intval($max_processes) == 0) {
$max_processes = 5;
}
} else {
$process = 'frontend';
$max_processes = get_config('system', 'max_processes_frontend');
$max_processes = Config::get('system', 'max_processes_frontend');
if (intval($max_processes) == 0) {
$max_processes = 20;
}
@ -845,13 +845,13 @@ class App {
if ($this->is_backend()) {
$process = 'backend';
$maxsysload = intval(get_config('system', 'maxloadavg'));
$maxsysload = intval(Config::get('system', 'maxloadavg'));
if ($maxsysload < 1) {
$maxsysload = 50;
}
} else {
$process = 'frontend';
$maxsysload = intval(get_config('system', 'maxloadavg_frontend'));
$maxsysload = intval(Config::get('system', 'maxloadavg_frontend'));
if ($maxsysload < 1) {
$maxsysload = 50;
}
@ -957,5 +957,4 @@ class App {
}
return true;
}
}

View file

@ -1,4 +1,5 @@
<?php
/**
* @package util
*/

View file

@ -1,4 +1,5 @@
<?php
// Tired of chasing typos and finding them after a commit.
// Run this from cmdline in basedir and quickly see if we've
// got any parse errors in our application files.
@ -13,28 +14,31 @@ include 'boot.php';
$a = new App();
if(x($a->config,'php_path'))
if (x($a->config, 'php_path')) {
$phpath = $a->config['php_path'];
else
} else {
$phpath = 'php';
}
echo "Directory: mod\n";
$files = glob('mod/*.php');
foreach ($files as $file) {
passthru("$phpath -l $file", $ret); $ret===0 or die();
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();
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();
passthru("$phpath -l $file", $ret);
$ret === 0 or die();
}
echo "Directory: addon\n";
@ -44,7 +48,8 @@ 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();
passthru("$phpath -l $file", $ret);
$ret === 0 or die();
}
}
@ -52,9 +57,11 @@ foreach($dirs as $dir) {
echo "String files\n";
echo 'util/strings.php' . "\n";
passthru("$phpath -l util/strings.php", $ret); $ret===0 or die();
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();
passthru("$phpath -l $file", $ret);
$ret === 0 or die();
}