diff --git a/.gitignore b/.gitignore index cd299f2d85..374fbc532c 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,6 @@ venv/ #ignore git projects in vendor vendor/**/.git + +#ignore config files from JetBrains +/.idea \ No newline at end of file diff --git a/INSTALL.txt b/INSTALL.txt index 81dfdfd272..592d3f5557 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -71,9 +71,14 @@ write or create files in your web directory, create an empty file called .htconfig.php and make it writable by the web server. 5. Visit your website with a web browser and follow the instructions. Please -note any error messages and correct these before continuing. If you are using -SSL with a known signature authority (recommended), use the https: link to your -website. If you are using a self-signed cert or no cert, use the http: link. +note any error messages and correct these before continuing. + +If you are using SSL with a known signature authority (recommended), use the +https: link to your website. If you are using a self-signed cert or no cert, +use the http: link. + +If you need to specify a port for the connection to the database, you can do +so in the host name setting for the database. 6. *If* the automated installation fails for any reason, check the following: @@ -135,7 +140,17 @@ $a->config['system']['addon'] = 'js_upload,poormancron'; and save your changes. -9. (Optional) Reverse-proxying and HTTPS +9. (Recommended) Set up a backup plan + +Bad things will happen. Let there be a hardware failure, a corrupted +database or whatever you can think of. So once the installation of your +Friendica node is done, you should make yoursef a backup plan. + +The most important file is the `.htconfig.php` file in the base directory. +As it stores all your data, you should also have a recent dump of your +Friendica database at hand, should you have to recover your node. + +10. (Optional) Reverse-proxying and HTTPS Friendica looks for some well-known HTTP headers indicating a reverse-proxy terminating an HTTPS connection. While the standard from RFC 7239 specifies diff --git a/VERSION b/VERSION index 3fec5bc901..b35d44161c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.5.3dev +3.5.3-dev diff --git a/Vagrantfile b/Vagrantfile index ff38151520..3d58ef7a5a 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -47,7 +47,7 @@ Vagrant.configure(2) do |config| ###################################################################### # Share a folder between host and guest - config.vm.synced_folder "./", "/vagrant/", owner: "www-data", group: "vagrant" + config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", owner: "www-data", group: "vagrant" # Provider-specific configuration so you can fine-tune various diff --git a/boot.php b/boot.php index 5f83cb3e40..b69fd91c45 100644 --- a/boot.php +++ b/boot.php @@ -22,6 +22,7 @@ require_once(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'a use Friendica\App; use Friendica\Core\Config; +use Friendica\Util\Lock; require_once 'include/config.php'; require_once 'include/network.php'; @@ -35,12 +36,13 @@ require_once 'include/features.php'; require_once 'include/identity.php'; require_once 'update.php'; require_once 'include/dbstructure.php'; +require_once 'include/poller.php'; define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Asparagus'); -define ( 'FRIENDICA_VERSION', '3.5.3dev' ); +define ( 'FRIENDICA_VERSION', '3.5.3-dev' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1227 ); +define ( 'DB_UPDATE_VERSION', 1232 ); /** * @brief Constant with a HTML line break. @@ -992,7 +994,7 @@ function notice($s) { function info($s) { $a = get_app(); - if (local_user() AND get_pconfig(local_user(), 'system', 'ignore_info')) { + if (local_user() && get_pconfig(local_user(), 'system', 'ignore_info')) { return; } @@ -1062,12 +1064,13 @@ 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'] || ! count($args)) { return; } $priority = PRIORITY_MEDIUM; $dont_fork = get_config("system", "worker_dont_fork"); + $created = datetime_convert(); if (is_int($run_parameter)) { $priority = $run_parameter; @@ -1075,6 +1078,9 @@ function proc_run($cmd) { if (isset($run_parameter['priority'])) { $priority = $run_parameter['priority']; } + if (isset($run_parameter['created'])) { + $created = $run_parameter['created']; + } if (isset($run_parameter['dont_fork'])) { $dont_fork = $run_parameter['dont_fork']; } @@ -1084,10 +1090,10 @@ function proc_run($cmd) { array_shift($argv); $parameters = json_encode($argv); - $found = dba::select('workerqueue', array('id'), array('parameter' => $parameters), array('limit' => 1)); + $found = dba::select('workerqueue', array('id'), array('parameter' => $parameters, 'done' => false), array('limit' => 1)); if (!dbm::is_result($found)) { - dba::insert('workerqueue', array('parameter' => $parameters, 'created' => datetime_convert(), 'priority' => $priority)); + dba::insert('workerqueue', array('parameter' => $parameters, 'created' => $created, 'priority' => $priority)); } // Should we quit and wait for the poller to be called as a cronjob? @@ -1095,18 +1101,16 @@ function proc_run($cmd) { return; } - // Checking number of workers - $workers = q("SELECT COUNT(*) AS `workers` FROM `workerqueue` WHERE `executed` > '%s'", dbesc(NULL_DATE)); - - // Get number of allowed number of worker threads - $queues = intval(get_config("system", "worker_queues")); - - if ($queues == 0) { - $queues = 4; + // If there is a lock then we don't have to check for too much worker + if (!Lock::set('poller_worker', 0)) { + return; } // If there are already enough workers running, don't fork another one - if ($workers[0]["workers"] >= $queues) { + $quit = poller_too_much_workers(); + Lock::remove('poller_worker'); + + if ($quit) { return; } @@ -1388,6 +1392,43 @@ function get_server() { return($server); } +function get_temppath() { + $a = get_app(); + + $temppath = get_config("system", "temppath"); + + if (($temppath != "") && App::directory_usable($temppath)) { + // We have a temp path and it is usable + return $temppath; + } + + // We don't have a working preconfigured temp path, so we take the system path. + $temppath = sys_get_temp_dir(); + + // Check if it is usable + if (($temppath != "") && App::directory_usable($temppath)) { + // To avoid any interferences with other systems we create our own directory + $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); + } + + if (App::directory_usable($new_temppath)) { + // The new path is usable, we are happy + set_config("system", "temppath", $new_temppath); + return $new_temppath; + } else { + // We can't create a subdirectory, strange. + // But the directory seems to work, so we use it but don't store it. + return $temppath; + } + } + + // Reaching this point means that the operating system is configured badly. + return ''; +} + function get_cachefile($file, $writemode = true) { $cache = get_itemcachepath(); @@ -1416,7 +1457,7 @@ function clear_cache($basepath = "", $path = "") { $path = $basepath; } - if (($path == "") OR (!is_dir($path))) { + if (($path == "") || (!is_dir($path))) { return; } @@ -1433,10 +1474,10 @@ function clear_cache($basepath = "", $path = "") { if ($dh = opendir($path)) { while (($file = readdir($dh)) !== false) { $fullpath = $path . "/" . $file; - if ((filetype($fullpath) == "dir") and ($file != ".") and ($file != "..")) { + if ((filetype($fullpath) == "dir") && ($file != ".") && ($file != "..")) { clear_cache($basepath, $fullpath); } - if ((filetype($fullpath) == "file") and (filectime($fullpath) < (time() - $cachetime))) { + if ((filetype($fullpath) == "file") && (filectime($fullpath) < (time() - $cachetime))) { unlink($fullpath); } } @@ -1453,7 +1494,7 @@ function get_itemcachepath() { } $itemcache = get_config('system', 'itemcache'); - if (($itemcache != "") AND App::directory_usable($itemcache)) { + if (($itemcache != "") && App::directory_usable($itemcache)) { return $itemcache; } @@ -1480,7 +1521,7 @@ function get_itemcachepath() { */ function get_spoolpath() { $spoolpath = get_config('system', 'spoolpath'); - if (($spoolpath != "") AND App::directory_usable($spoolpath)) { + if (($spoolpath != "") && App::directory_usable($spoolpath)) { // We have a spool path and it is usable return $spoolpath; } @@ -1510,43 +1551,6 @@ function get_spoolpath() { return ""; } -function get_temppath() { - $a = get_app(); - - $temppath = get_config("system", "temppath"); - - if (($temppath != "") AND App::directory_usable($temppath)) { - // We have a temp path and it is usable - return $temppath; - } - - // We don't have a working preconfigured temp path, so we take the system path. - $temppath = sys_get_temp_dir(); - - // 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(); - if (!is_dir($new_temppath)) { - /// @TODO There is a mkdir()+chmod() upwards, maybe generalize this (+ configurable) into a function/method? - mkdir($new_temppath); - } - - if (App::directory_usable($new_temppath)) { - // The new path is usable, we are happy - set_config("system", "temppath", $new_temppath); - return $new_temppath; - } else { - // We can't create a subdirectory, strange. - // But the directory seems to work, so we use it but don't store it. - return $temppath; - } - } - - // Reaching this point means that the operating system is configured badly. - return ''; -} - /// @deprecated function set_template_engine(App $a, $engine = 'internal') { /// @note This function is no longer necessary, but keep it as a wrapper to the class method @@ -1647,7 +1651,7 @@ function argv($x) { function infinite_scroll_data($module) { if (get_pconfig(local_user(), 'system', 'infinite_scroll') - AND ($module == "network") AND ($_GET["mode"] != "minimal")) { + && ($module == "network") && ($_GET["mode"] != "minimal")) { // get the page number if (is_string($_GET["page"])) { @@ -1660,12 +1664,12 @@ function infinite_scroll_data($module) { // try to get the uri from which we load the content foreach ($_GET AS $param => $value) { - if (($param != "page") AND ($param != "q")) { + if (($param != "page") && ($param != "q")) { $reload_uri .= "&" . $param . "=" . urlencode($value); } } - if (($a->page_offset != "") AND ! strstr($reload_uri, "&offset=")) { + if (($a->page_offset != "") && ! strstr($reload_uri, "&offset=")) { $reload_uri .= "&offset=" . urlencode($a->page_offset); } diff --git a/database.sql b/database.sql index 4a5946ef38..a3f937587c 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ --- Friendica 3.5.2-rc (Asparagus) --- DB_UPDATE_VERSION 1227 +-- Friendica 3.5.3-dev (Asparagus) +-- DB_UPDATE_VERSION 1231 -- ------------------------------------------ @@ -580,7 +580,7 @@ CREATE TABLE IF NOT EXISTS `locks` ( `id` int(11) NOT NULL auto_increment, `name` varchar(128) NOT NULL DEFAULT '', `locked` tinyint(1) NOT NULL DEFAULT 0, - `created` datetime DEFAULT '0001-01-01 00:00:00', + `pid` int(10) unsigned NOT NULL DEFAULT 0, PRIMARY KEY(`id`) ) DEFAULT COLLATE utf8mb4_general_ci; @@ -1114,8 +1114,11 @@ CREATE TABLE IF NOT EXISTS `workerqueue` ( `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `pid` int(11) NOT NULL DEFAULT 0, `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `done` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY(`id`), INDEX `pid` (`pid`), - INDEX `priority_created` (`priority`,`created`) + INDEX `parameter` (`parameter`(64)), + INDEX `priority_created` (`priority`,`created`), + INDEX `executed` (`executed`) ) DEFAULT COLLATE utf8mb4_general_ci; diff --git a/doc/Account-Basics.md b/doc/Account-Basics.md index 854e78b14e..6d7f86c085 100644 --- a/doc/Account-Basics.md +++ b/doc/Account-Basics.md @@ -89,7 +89,10 @@ A ['Tips for New Members'](newmember) link will show up on your network and home Retrieving Personal Data --- -You can export a copy of your personal data in XML format from the "Export personal data" link at the top of your settings page. +You can export a copy of your personal data in JSON format from the "Export personal data" link at the top of your settings page. + +You need this file to relocate your Friendica account to another node. +This might be necessary, e.g. if your node suffers a severe hardware problem and is not recoverable. See Also --- diff --git a/doc/Developers-Intro.md b/doc/Developers-Intro.md index 3cda8ab466..137e5aaf54 100644 --- a/doc/Developers-Intro.md +++ b/doc/Developers-Intro.md @@ -64,6 +64,7 @@ Here's a few primers if you are new to Friendica or to the PSR-2 coding standard * By default, strings are enclosed in single quotes, but feel free to use double quotes if it makes more sense (SQL queries, adding tabs and line feeds). * Operators are wrapped by spaces, e.g. `$var === true`, `$var = 1 + 2` and `'string' . $concat . 'enation'` * Braces are mandatory in conditions + * Boolean operators are `&&` and `||` for PHP conditions, `AND` and `OR` for SQL queries * No closing PHP tag * No trailing spaces diff --git a/doc/Install.md b/doc/Install.md index a8ea2c0503..a57888f98b 100644 --- a/doc/Install.md +++ b/doc/Install.md @@ -82,6 +82,8 @@ Restart mysql and you should be fine. Point your web browser to the new site and follow the instructions. Please note any error messages and correct these before continuing. +If you need to specify a port for the connection to the database, you can do so in the host name setting for the database. + *If* the automated installation fails for any reason, check the following: * Does ".htconfig.php" exist? If not, edit htconfig.php and change the system settings. Rename to .htconfig.php @@ -142,3 +144,11 @@ The addon tree has to be updated separately like so: cd mywebsite/addon git pull + +###Set up a backup plan +Bad things will happen. +Let there be a hardware failure, a corrupted database or whatever you can think of. +So once the installation of your Friendica node is done, you should make yoursef a backup plan. + +The most important file is the `.htconfig.php` file in the base directory. +As it stores all your data, you should also have a recent dump of your Friendica database at hand, should you have to recover your node. diff --git a/doc/database/db_locks.md b/doc/database/db_locks.md index 00556dd953..4de6fbf961 100644 --- a/doc/database/db_locks.md +++ b/doc/database/db_locks.md @@ -1,11 +1,11 @@ Table locks =========== -| Field | Description | Type | Null | Key | Default | Extra | -|---------|------------------|--------------|------|-----|---------------------|----------------| -| id | sequential ID | int(11) | NO | PRI | NULL | auto_increment | -| name | | varchar(128) | NO | | | | -| locked | | tinyint(1) | NO | | 0 | | -| created | | datetime | YES | | 0001-01-01 00:00:00 | | +| Field | Description | Type | Null | Key | Default | Extra | +|---------|------------------|------------------|------|-----|---------------------|----------------| +| id | sequential ID | int(11) | NO | PRI | NULL | auto_increment | +| name | | varchar(128) | NO | | | | +| locked | | tinyint(1) | NO | | 0 | | +| pid | Process ID | int(10) unsigned | NO | | 0 | | Return to [database documentation](help/database) diff --git a/doc/database/db_workerqueue.md b/doc/database/db_workerqueue.md index 8ab68466be..182358a4c4 100644 --- a/doc/database/db_workerqueue.md +++ b/doc/database/db_workerqueue.md @@ -9,5 +9,6 @@ Table workerqueue | created | | datetime | NO | MUL | 0001-01-01 00:00:00 | | | pid | | int(11) | NO | | 0 | | | executed | | datetime | NO | | 0001-01-01 00:00:00 | | +| done | set to 1 if done | tinyint(1) | NO | | 0 | | Return to [database documentation](help/database) diff --git a/doc/de/Account-Basics.md b/doc/de/Account-Basics.md index 5052598154..bfeba69ffe 100644 --- a/doc/de/Account-Basics.md +++ b/doc/de/Account-Basics.md @@ -9,37 +9,37 @@ Account - Basics Nicht alle Friendica-Knoten bieten die Möglichkeit zur Registrierung. Wenn die Registrierung möglich ist, wird ein "Registrieren"-Link unter dem Login-Feld auf der Startseite angezeigt, der zur Registrierungsseite führt. Die Stärke unseres Netzwerks ist, dass die verschiedenen Knoten komplett kompatibel zueinander sind. -Wenn der Knoten, den Du besuchst, keine Registrierung anbietet, oder wenn Du glaubst, dass Dir eine andere Seite möglicherweise besser gefällt, dann kannst Du hier eine Liste von öffentlichen Servern (Knoten) finden und den Knoten heraus suchen, der am Besten zu Deinen Anforderungen passt. +Wenn der Knoten, den Du besuchst, keine Registrierung anbietet, oder wenn Du glaubst, dass Dir eine andere Seite möglicherweise besser gefällt, dann kannst Du hier eine Liste von öffentlichen Servern (Knoten) finden und den Knoten heraus suchen, der am Besten zu Deinen Anforderungen passt. -Wenn Du Deinen eigenen Server aufsetzen willst, kannst Du das ebenfalls machen. -Besuche die Friendica-Webseite, um den Code mit den Installationsanleitungen herunterzuladen. +Wenn Du Deinen eigenen Server aufsetzen willst, kannst Du das ebenfalls machen. +Besuche die Friendica-Webseite, um den Code mit den Installationsanleitungen herunterzuladen. Es ist ein einfacher Installationsprozess, den jeder mit ein wenig Erfahrungen im Webseiten-Hosting oder mit grundlegenden Linux-Erfahrungen einfach handhaben kann. *OpenID* -Das erste Feld auf der Registrierungsseite ist für eine OpenID-Adresse. -Wenn Du keine OpenID-Adresse hast oder nicht wünschst, diese zu nutzen, dann lasse das Feld frei. -Wenn Du einen OpenID-Account hast und diesen nutzen willst, gib die Adresse in das Feld ein und klicke auf "Registrieren". -Friendica wird versuchen, so viele Informationen wie möglich von Deinem OpenID-Provider zu übernehmen, um diese in Dein Profil auf dieser Seite einzutragen. +Das erste Feld auf der Registrierungsseite ist für eine OpenID-Adresse. +Wenn Du keine OpenID-Adresse hast oder nicht wünschst, diese zu nutzen, dann lasse das Feld frei. +Wenn Du einen OpenID-Account hast und diesen nutzen willst, gib die Adresse in das Feld ein und klicke auf "Registrieren". +Friendica wird versuchen, so viele Informationen wie möglich von Deinem OpenID-Provider zu übernehmen, um diese in Dein Profil auf dieser Seite einzutragen. *Dein vollständiger Name* -Bitte trage Deinen vollständigen Namen **so ein, wie Du ihn im System anzeigen lassen willst**. +Bitte trage Deinen vollständigen Namen **so ein, wie Du ihn im System anzeigen lassen willst**. Viele Leute nutzen ihren richtigen Namen hierfür, allerdings besteht für dich keine Pflicht, das auch so zu machen. *Email-Adresse* -Bitte trage eine richtige Email-Adresse ein. -Deine Email-Adresse wird **niemals** veröffentlicht. -Wir benötigen diese, um Dir Account-Informationen und die Login-Daten zu schicken. -Du erhältst zudem von Zeit zu Zeit Benachrichtigungen über eingegangene Nachrichten oder Punkte, die Deine Aufmerksamkeit benötigen. -Du hast aber auch die Möglichkeit, diese Nachrichten in Deinen Account-Einstellungen komplett abzuschalten. +Bitte trage eine richtige Email-Adresse ein. +Deine Email-Adresse wird **niemals** veröffentlicht. +Wir benötigen diese, um Dir Account-Informationen und die Login-Daten zu schicken. +Du erhältst zudem von Zeit zu Zeit Benachrichtigungen über eingegangene Nachrichten oder Punkte, die Deine Aufmerksamkeit benötigen. +Du hast aber auch die Möglichkeit, diese Nachrichten in Deinen Account-Einstellungen komplett abzuschalten. -Du musst nicht Deine Haupt-Email-Adresse sein, jedoch wird eine funktionierende Adresse benötigt. -Ohne dieses kannst Du weder Dein Initialpasswort erhalten, noch Dein Passwort zurücksetzen. +Du musst nicht Deine Haupt-Email-Adresse sein, jedoch wird eine funktionierende Adresse benötigt. +Ohne dieses kannst Du weder Dein Initialpasswort erhalten, noch Dein Passwort zurücksetzen. Dies ist die einzige persönliche Information, die korrekt sein muss. @@ -85,7 +85,7 @@ Falls Du Schwierigkeiten beim Login hast, prüfe bitte, ob z. B. Deine Feststell **Passwort ändern** -Besuche nach Deinem ersten Login bitte die Einstellungsseite und wechsle das Passwort in eines, dass Du Dir merken kannst. +Besuche nach Deinem ersten Login bitte die Einstellungsseite und wechsle das Passwort in eines, dass Du Dir merken kannst. **Der Anfang** @@ -95,9 +95,11 @@ Ein ['Tipp für neue Mitglieder'](newmember)-Link zeigt sich in den ersten beide **Persönliche Daten exportieren** -Du kannst eine Kopie Deiner persönlichen Daten in einer XML-Datei exportieren. +Du kannst eine Kopie Deiner persönlichen Daten in einer JSON-Datei exportieren. Gehe hierzu in Deinen Einstellungen auf "Persönliche Daten exportieren". +Dies ist z.B. dann nützlich wenn du mit deinem Account auf einen anderen Friendica Knoten umziehen möchstest. +Ein Grund hierfür könnte sein, dass der Server auf dem dieser Friendica Knoten läuft dauerhaft wegen eines Hardware Problems ausfällt. **Schau Dir ebenfalls folgende Seiten an** diff --git a/doc/de/Install.md b/doc/de/Install.md index db8fb965d4..7c0b87fbb7 100644 --- a/doc/de/Install.md +++ b/doc/de/Install.md @@ -108,3 +108,11 @@ Du kannst auch weitere Addons/Plugins ergänzen. Ändere den Eintrag folgenderma `$a->config['system']['addon'] = 'js_upload,poormancron';` und speichere deine Änderungen. + +###Erstelle einen Backup Plan +Es werden schlimme Dinge geschehen. +Sei es nun ein Hardwareversage oder eine korrumpierte Datenbank. +Deshalb solltest du dir nachdem die Installation deines Friendica Knotens abgeschlossen ist einen Backup Plan erstellen. + +Die wichtigste Datei ist die `.htconfig.php` im Stammverzeichnis deiner Friendica Installation. +Und da alle Daten in der Datenbank gespeichert werden, solltest du einen nicht all zu alten Dump der Friendica Datenbank zur Hand haben, solltest du deinen Knoten wieder herstellen müssen. diff --git a/doc/htconfig.md b/doc/htconfig.md index 542b42b29e..a452ecfc14 100644 --- a/doc/htconfig.md +++ b/doc/htconfig.md @@ -35,8 +35,8 @@ Example: To set the directory value please add this line to your .htconfig.php: * **db_loglimit_index_high** - Number of index rows to be logged anyway (for any index) * **db_log_index_blacklist** - Blacklist of indexes that shouldn't be watched * **dbclean** (Boolean) - Enable the automatic database cleanup process +* **dbclean-expire-days** (Integer) - Days after which remote items will be deleted. Own items, and marked or filed items are kept. * **default_service_class** - -* **delivery_batch_count** - Number of deliveries per process. Default value is 1. (Disabled when using the worker) * **diaspora_test** (Boolean) - For development only. Disables the message transfer. * **directory** - The path to global directory. If not set then "http://dir.friendica.social" is used. * **disable_email_validation** (Boolean) - Disables the check if a mail address is in a valid format and can be resolved via DNS. @@ -67,6 +67,8 @@ Example: To set the directory value please add this line to your .htconfig.php: * **ostatus_poll_timeframe** - Defines how old an item can be to try to complete the conversation with it. * **paranoia** (Boolean) - Log out users if their IP address changed. * **permit_crawling** (Boolean) - Restricts the search for not logged in users to one search per minute. +* **worker_debug** (Boolean) - If enabled, it prints out the number of running processes split by priority. +* **worker_fetch_limit** - Number of worker tasks that are fetched in a single query. Default is 5. * **profiler** (Boolean) - Enable internal timings to help optimize code. Needed for "rendertime" addon. Default is false. * **free_crawls** - Number of "free" searches when "permit_crawling" is activated (Default value is 10) * **crawl_permit_period** - Period in seconds between allowed searches when the number of free searches is reached and "permit_crawling" is activated (Default value is 60) @@ -116,3 +118,10 @@ If more then one account should be able to access the admin panel, seperate the If you want to have a more personalized closing line for the notification emails you can set a variable for the admin_name. $a->config['admin_name'] = "Marvin"; + +## Database Settings + +The configuration variables db_host, db_user, db_pass and db_data are holding your credentials for the database connection. +If you need to specify a port to access the database, you can do so by appending ":portnumber" to the db_host variable. + + $db_host = 'your.mysqlhost.com:123456'; diff --git a/include/Contact.php b/include/Contact.php index bb6d8c1981..feeb040acc 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -262,33 +262,33 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) { $profile = $default; } - if (($profile["photo"] == "") AND isset($default["photo"])) { + if (($profile["photo"] == "") && isset($default["photo"])) { $profile["photo"] = $default["photo"]; } - if (($profile["name"] == "") AND isset($default["name"])) { + if (($profile["name"] == "") && isset($default["name"])) { $profile["name"] = $default["name"]; } - if (($profile["network"] == "") AND isset($default["network"])) { + if (($profile["network"] == "") && isset($default["network"])) { $profile["network"] = $default["network"]; } - if (($profile["thumb"] == "") AND isset($profile["photo"])) { + if (($profile["thumb"] == "") && isset($profile["photo"])) { $profile["thumb"] = $profile["photo"]; } - if (($profile["micro"] == "") AND isset($profile["thumb"])) { + if (($profile["micro"] == "") && isset($profile["thumb"])) { $profile["micro"] = $profile["thumb"]; } - if ((($profile["addr"] == "") OR ($profile["name"] == "")) AND ($profile["gid"] != 0) AND + if ((($profile["addr"] == "") || ($profile["name"] == "")) && ($profile["gid"] != 0) && in_array($profile["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) { proc_run(PRIORITY_LOW, "include/update_gcontact.php", $profile["gid"]); } // Show contact details of Diaspora contacts only if connected - if (($profile["cid"] == 0) AND ($profile["network"] == NETWORK_DIASPORA)) { + if (($profile["cid"] == 0) && ($profile["network"] == NETWORK_DIASPORA)) { $profile["location"] = ""; $profile["about"] = ""; $profile["gender"] = ""; @@ -517,7 +517,7 @@ function contacts_not_grouped($uid,$start = 0,$count = 0) { * @return integer Contact ID */ function get_contact($url, $uid = 0, $no_update = false) { - logger("Get contact data for url ".$url." and user ".$uid." - ".App::callstack(), LOGGER_DEBUG);; + logger("Get contact data for url ".$url." and user ".$uid." - ".App::callstack(), LOGGER_DEBUG); $data = array(); $contact_id = 0; @@ -527,39 +527,28 @@ function get_contact($url, $uid = 0, $no_update = false) { } // We first try the nurl (http://server.tld/nick), most common case - $contacts = q("SELECT `id`, `avatar-date` FROM `contact` - WHERE `nurl` = '%s' - AND `uid` = %d", - dbesc(normalise_link($url)), - intval($uid)); - + $contact = dba::select('contact', array('id', 'avatar-date'), array('nurl' => normalise_link($url), 'uid' => $uid), array('limit' => 1)); // Then the addr (nick@server.tld) - if (! dbm::is_result($contacts)) { - $contacts = q("SELECT `id`, `avatar-date` FROM `contact` - WHERE `addr` = '%s' - AND `uid` = %d", - dbesc($url), - intval($uid)); + if (!dbm::is_result($contact)) { + $contact = dba::select('contact', array('id', 'avatar-date'), array('addr' => $url, 'uid' => $uid), array('limit' => 1)); } // Then the alias (which could be anything) - if (! dbm::is_result($contacts)) { - $contacts = q("SELECT `id`, `avatar-date` FROM `contact` - WHERE `alias` IN ('%s', '%s') - AND `uid` = %d", - dbesc($url), - dbesc(normalise_link($url)), - intval($uid)); + if (!dbm::is_result($contact)) { + $r = dba::p("SELECT `id`, `avatar-date` FROM `contact` WHERE `alias` IN (?, ?) AND `uid` = ? LIMIT 1", + $url, normalise_link($url), $uid); + $contact = dba::fetch($r); + dba::close($r); } - if (dbm::is_result($contacts)) { - $contact_id = $contacts[0]["id"]; + if (dbm::is_result($contact)) { + $contact_id = $contact["id"]; // Update the contact every 7 days - $update_photo = ($contacts[0]['avatar-date'] < datetime_convert('','','now -7 days')); + $update_contact = ($contact['avatar-date'] < datetime_convert('','','now -7 days')); - if (!$update_photo OR $no_update) { + if (!$update_contact || $no_update) { return $contact_id; } } elseif ($uid != 0) { @@ -576,45 +565,29 @@ function get_contact($url, $uid = 0, $no_update = false) { } // Get data from the gcontact table - $gcontacts = q("SELECT `name`, `nick`, `url`, `photo`, `addr`, `alias`, `network` FROM `gcontact` WHERE `nurl` = '%s'", - dbesc(normalise_link($url))); - if (!$gcontacts) { + $gcontacts = dba::select('gcontact', array('name', 'nick', 'url', 'photo', 'addr', 'alias', 'network'), + array('nurl' => normalise_link($url)), array('limit' => 1)); + if (!dbm::is_result($gcontacts)) { return 0; } - $data = $gcontacts[0]; + $data = array_merge($data, $gcontacts); } $url = $data["url"]; - if (!$contact_id) { - q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`, - `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`, - `batch`, `request`, `confirm`, `poco`, `name-date`, `uri-date`, - `writable`, `blocked`, `readonly`, `pending`) - VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', 1, 0, 0, 0)", - intval($uid), - dbesc(datetime_convert()), - dbesc($data["url"]), - dbesc(normalise_link($data["url"])), - dbesc($data["addr"]), - dbesc($data["alias"]), - dbesc($data["notify"]), - dbesc($data["poll"]), - dbesc($data["name"]), - dbesc($data["nick"]), - dbesc($data["photo"]), - dbesc($data["network"]), - dbesc($data["pubkey"]), - intval(CONTACT_IS_SHARING), - intval($data["priority"]), - dbesc($data["batch"]), - dbesc($data["request"]), - dbesc($data["confirm"]), - dbesc($data["poco"]), - dbesc(datetime_convert()), - dbesc(datetime_convert()) - ); + dba::insert('contact', array('uid' => $uid, 'created' => datetime_convert(), 'url' => $data["url"], + 'nurl' => normalise_link($data["url"]), 'addr' => $data["addr"], + 'alias' => $data["alias"], 'notify' => $data["notify"], 'poll' => $data["poll"], + 'name' => $data["name"], 'nick' => $data["nick"], 'photo' => $data["photo"], + 'keywords' => $data["keywords"], 'location' => $data["location"], 'about' => $data["about"], + 'network' => $data["network"], 'pubkey' => $data["pubkey"], + 'rel' => CONTACT_IS_SHARING, 'priority' => $data["priority"], + 'batch' => $data["batch"], 'request' => $data["request"], + 'confirm' => $data["confirm"], 'poco' => $data["poco"], + 'name-date' => datetime_convert(), 'uri-date' => datetime_convert(), + 'avatar-date' => datetime_convert(), 'writable' => 1, 'blocked' => 0, + 'readonly' => 0, 'pending' => 0)); $contacts = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d ORDER BY `id` LIMIT 2", dbesc(normalise_link($data["url"])), @@ -626,49 +599,65 @@ function get_contact($url, $uid = 0, $no_update = false) { $contact_id = $contacts[0]["id"]; // Update the newly created contact from data in the gcontact table - $gcontacts = q("SELECT `location`, `about`, `keywords`, `gender` FROM `gcontact` WHERE `nurl` = '%s'", - dbesc(normalise_link($data["url"]))); - if (dbm::is_result($gcontacts)) { - logger("Update contact " . $data["url"] . ' from gcontact'); - q("UPDATE `contact` SET `location` = '%s', `about` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `id` = %d", - dbesc($gcontacts[0]["location"]), dbesc($gcontacts[0]["about"]), dbesc($gcontacts[0]["keywords"]), - dbesc($gcontacts[0]["gender"]), intval($contact_id)); + $gcontact = dba::select('gcontact', array('location', 'about', 'keywords', 'gender'), + array('nurl' => normalise_link($data["url"])), array('limit' => 1)); + if (dbm::is_result($gcontact)) { + // Only use the information when the probing hadn't fetched these values + if ($data['keywords'] != '') { + unset($gcontact['keywords']); + } + if ($data['location'] != '') { + unset($gcontact['location']); + } + if ($data['about'] != '') { + unset($gcontact['about']); + } + dba::update('contact', $gcontact, array('id' => $contact_id)); } - } - if (count($contacts) > 1 AND $uid == 0 AND $contact_id != 0 AND $url != "") { - q("DELETE FROM `contact` WHERE `nurl` = '%s' AND `id` != %d AND NOT `self`", - dbesc(normalise_link($url)), - intval($contact_id)); + if (count($contacts) > 1 && $uid == 0 && $contact_id != 0 && $data["url"] != "") { + dba::e("DELETE FROM `contact` WHERE `nurl` = ? AND `uid` = 0 AND `id` != ? AND NOT `self`", + normalise_link($data["url"]), $contact_id); + } } require_once "Photo.php"; update_contact_avatar($data["photo"], $uid, $contact_id); - $contacts = q("SELECT `addr`, `alias`, `name`, `nick` FROM `contact` WHERE `id` = %d", intval($contact_id)); + $contact = dba::select('contact', array('addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date'), + array('id' => $contact_id), array('limit' => 1)); // This condition should always be true - if (!dbm::is_result($contacts)) { + if (!dbm::is_result($contact)) { return $contact_id; } - // Only update if there had something been changed - if ($data["addr"] != $contacts[0]["addr"] OR - $data["alias"] != $contacts[0]["alias"] OR - $data["name"] != $contacts[0]["name"] OR - $data["nick"] != $contacts[0]["nick"]) { - q("UPDATE `contact` SET `addr` = '%s', `alias` = '%s', `name` = '%s', `nick` = '%s', - `name-date` = '%s', `uri-date` = '%s' WHERE `id` = %d", - dbesc($data["addr"]), - dbesc($data["alias"]), - dbesc($data["name"]), - dbesc($data["nick"]), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($contact_id) - ); + $updated = array('addr' => $data['addr'], + 'alias' => $data['alias'], + 'name' => $data['name'], + 'nick' => $data['nick']); + + if ($data['keywords'] != '') { + $updated['keywords'] = $data['keywords']; } + if ($data['location'] != '') { + $updated['location'] = $data['location']; + } + if ($data['about'] != '') { + $updated['about'] = $data['about']; + } + + if (($data["addr"] != $contact["addr"]) || ($data["alias"] != $contact["alias"])) { + $updated['uri-date'] = datetime_convert(); + } + if (($data["name"] != $contact["name"]) || ($data["nick"] != $contact["nick"])) { + $updated['name-date'] = datetime_convert(); + } + + $updated['avatar-date'] = datetime_convert(); + + dba::update('contact', $updated, array('id' => $contact_id), $contact); return $contact_id; } @@ -769,7 +758,7 @@ function formatted_location($profile) { if($profile['locality']) $location .= $profile['locality']; - if($profile['region'] AND ($profile['locality'] != $profile['region'])) { + if($profile['region'] && ($profile['locality'] != $profile['region'])) { if($location) $location .= ', '; diff --git a/include/NotificationsManager.php b/include/NotificationsManager.php index ad0ede6dbe..57c315c9d7 100644 --- a/include/NotificationsManager.php +++ b/include/NotificationsManager.php @@ -512,7 +512,7 @@ class NotificationsManager { $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); - $sql_extra = sprintf(" AND ( `item`.`author-link` regexp '%s' or `item`.`tag` regexp '%s' or `item`.`tag` regexp '%s' ) ", + $sql_extra = sprintf(" AND ( `item`.`author-link` regexp '%s' OR `item`.`tag` regexp '%s' OR `item`.`tag` regexp '%s' ) ", dbesc($myurl . '$'), dbesc($myurl . '\\]'), dbesc($diasp_url . '\\]') @@ -829,11 +829,11 @@ class NotificationsManager { } /** - * @brief Check for missing contact data and try to fetch the data from + * @brief Check for missing contact data and try to fetch the data from * from other sources - * + * * @param array $arr The input array with the intro data - * + * * @return array The array with the intro data */ private function getMissingIntroData($arr) { diff --git a/include/Photo.php b/include/Photo.php index 5920f80b38..5c3a52ffd5 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -785,7 +785,7 @@ function update_contact_avatar($avatar, $uid, $cid, $force = false) { $data = array($r[0]["photo"], $r[0]["thumb"], $r[0]["micro"]); } - if (($r[0]["avatar"] != $avatar) OR $force) { + if (($r[0]["avatar"] != $avatar) || $force) { $photos = import_profile_photo($avatar, $uid, $cid, true); if ($photos) { @@ -825,7 +825,7 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) { $filename = basename($photo); $img_str = fetch_url($photo, true); - if ($quit_on_error AND ($img_str == "")) { + if ($quit_on_error && ($img_str == "")) { return false; } @@ -883,7 +883,7 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) { $photo_failure = true; } - if ($photo_failure AND $quit_on_error) { + if ($photo_failure && $quit_on_error) { return false; } @@ -902,7 +902,7 @@ function get_photo_info($url) { $data = Cache::get($url); - if (is_null($data) OR !$data OR !is_array($data)) { + if (is_null($data) || !$data || !is_array($data)) { $img_str = fetch_url($url, true, $redirects, 4); $filesize = strlen($img_str); @@ -996,7 +996,7 @@ function store_photo(App $a, $uid, $imagedata = "", $url = "") { /// $default_cid = $r[0]['id']; /// $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false); - if ((strlen($imagedata) == 0) AND ($url == "")) { + if ((strlen($imagedata) == 0) && ($url == "")) { logger("No image data and no url provided", LOGGER_DEBUG); return(array()); } elseif (strlen($imagedata) == 0) { @@ -1102,7 +1102,7 @@ function store_photo(App $a, $uid, $imagedata = "", $url = "") { } } - if ($width > 160 AND $height > 160) { + if ($width > 160 && $height > 160) { $x = 0; $y = 0; diff --git a/include/acl_selectors.php b/include/acl_selectors.php index c7c6bb206a..6f08523ca9 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -209,7 +209,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $tabindex = ($tabindex > 0 ? "tabindex=\"$tabindex\"" : ""); - if ($privmail AND $preselected) { + if ($privmail && $preselected) { $sql_extra .= " AND `id` IN (".implode(",", $preselected).")"; $hidepreselected = ' style="display: none;"'; } else { @@ -261,7 +261,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $o .= "\r\n"; - if ($privmail AND $preselected) { + if ($privmail && $preselected) { $o .= implode(", ", $receiverlist); } @@ -388,6 +388,9 @@ function populate_acl($user = null, $show_jotnets = false) { } function construct_acl_data(App $a, $user) { + // This function is now deactivated. It seems as if the generated data isn't used anywhere. + /// @todo Remove this function and all function calls before releasing Friendica 3.5.3 + return; // Get group and contact information for html ACL selector $acl_data = acl_lookup($a, 'html'); diff --git a/include/api.php b/include/api.php index 5d962ecd03..16ff0f4a05 100644 --- a/include/api.php +++ b/include/api.php @@ -483,7 +483,7 @@ $called_api = null; logger("api_get_user: Fetching user data for user ".$contact_id, LOGGER_DEBUG); // Searching for contact URL - if (!is_null($contact_id) AND (intval($contact_id) == 0)) { + if (!is_null($contact_id) && (intval($contact_id) == 0)) { $user = dbesc(normalise_link($contact_id)); $url = $user; $extra_query = "AND `contact`.`nurl` = '%s' "; @@ -493,7 +493,7 @@ $called_api = null; } // Searching for contact id with uid = 0 - if (!is_null($contact_id) AND (intval($contact_id) != 0)) { + if (!is_null($contact_id) && (intval($contact_id) != 0)) { $user = dbesc(api_unique_id_to_url($contact_id)); if ($user == "") { @@ -538,7 +538,7 @@ $called_api = null; } } - if (is_null($user) AND ($a->argc > (count($called_api) - 1)) AND (count($called_api) > 0)) { + if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) { $argid = count($called_api); list($user, $null) = explode(".", $a->argv[$argid]); if (is_numeric($user)) { @@ -600,7 +600,7 @@ $called_api = null; $network_name = network_to_name($r[0]['network'], $r[0]['url']); // If no nick where given, extract it from the address - if (($r[0]['nick'] == "") OR ($r[0]['name'] == $r[0]['nick'])) { + if (($r[0]['nick'] == "") || ($r[0]['name'] == $r[0]['nick'])) { $r[0]['nick'] = api_get_nick($r[0]["url"]); } @@ -716,7 +716,7 @@ $called_api = null; $starred = 0; // Add a nick if it isn't present there - if (($uinfo[0]['nick'] == "") OR ($uinfo[0]['name'] == $uinfo[0]['nick'])) { + if (($uinfo[0]['nick'] == "") || ($uinfo[0]['name'] == $uinfo[0]['nick'])) { $uinfo[0]['nick'] = api_get_nick($uinfo[0]["url"]); } @@ -749,7 +749,7 @@ $called_api = null; 'contributors_enabled' => false, 'is_translator' => false, 'is_translation_enabled' => false, - 'following' => (($uinfo[0]['rel'] == CONTACT_IS_FOLLOWER) OR ($uinfo[0]['rel'] == CONTACT_IS_FRIEND)), + 'following' => (($uinfo[0]['rel'] == CONTACT_IS_FOLLOWER) || ($uinfo[0]['rel'] == CONTACT_IS_FRIEND)), 'follow_request_sent' => false, 'statusnet_blocking' => false, 'notifications' => false, @@ -777,10 +777,10 @@ $called_api = null; $status_user = api_get_user($a, $item["author-link"]); - $status_user["protected"] = (($item["allow_cid"] != "") OR - ($item["allow_gid"] != "") OR - ($item["deny_cid"] != "") OR - ($item["deny_gid"] != "") OR + $status_user["protected"] = (($item["allow_cid"] != "") || + ($item["allow_gid"] != "") || + ($item["deny_cid"] != "") || + ($item["deny_gid"] != "") || $item["private"]); if ($item['thr-parent'] == $item['uri']) { @@ -1305,9 +1305,9 @@ $called_api = null; $status_info["entities"] = $converted["entities"]; } - if (($lastwall['item_network'] != "") AND ($status["source"] == 'web')) { + if (($lastwall['item_network'] != "") && ($status["source"] == 'web')) { $status_info["source"] = network_to_name($lastwall['item_network'], $user_info['url']); - } elseif (($lastwall['item_network'] != "") AND (network_to_name($lastwall['item_network'], $user_info['url']) != $status_info["source"])) { + } elseif (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $status_info["source"])) { $status_info["source"] = trim($status_info["source"].' ('.network_to_name($lastwall['item_network'], $user_info['url']).')'); } @@ -1393,11 +1393,11 @@ $called_api = null; $user_info["status"]["entities"] = $converted["entities"]; } - if (($lastwall['item_network'] != "") AND ($user_info["status"]["source"] == 'web')) { + if (($lastwall['item_network'] != "") && ($user_info["status"]["source"] == 'web')) { $user_info["status"]["source"] = network_to_name($lastwall['item_network'], $user_info['url']); } - if (($lastwall['item_network'] != "") AND (network_to_name($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) { + if (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) { $user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . network_to_name($lastwall['item_network'], $user_info['url']) . ')'); } @@ -2178,7 +2178,7 @@ $called_api = null; `contact`.`id` AS `cid` FROM `item`, `contact` WHERE `item`.`uid` = %d - AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0 + AND `item`.`visible` = 1 AND `item`.`moderated` = 0 AND `item`.`deleted` = 0 AND `item`.`starred` = 1 AND `contact`.`id` = `item`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`) @@ -2263,13 +2263,13 @@ $called_api = null; $statustitle = trim($item['title']); - if (($statustitle != '') and (strpos($statusbody, $statustitle) !== false)) { + if (($statustitle != '') && (strpos($statusbody, $statustitle) !== false)) { $statustext = trim($statusbody); } else { $statustext = trim($statustitle."\n\n".$statusbody); } - if (($item["network"] == NETWORK_FEED) and (strlen($statustext)> 1000)) { + if (($item["network"] == NETWORK_FEED) && (strlen($statustext)> 1000)) { $statustext = substr($statustext, 0, 1000)."... \n".$item["plink"]; } @@ -2289,11 +2289,11 @@ $called_api = null; $statushtml = "

" . bbcode($item['title']) . "

\n" . $statushtml; } - // feeds without body should contain the link - if (($item['network'] == NETWORK_FEED) && (strlen($item['body']) == 0)) { - $statushtml .= bbcode($item['plink']); - } - + // feeds without body should contain the link + if (($item['network'] == NETWORK_FEED) && (strlen($item['body']) == 0)) { + $statushtml .= bbcode($item['plink']); + } + $entities = api_get_entitities($statustext, $body); return array( @@ -2402,8 +2402,8 @@ $called_api = null; $offset = 0; //foreach ($urls[1] AS $id=>$url) { foreach ($ordered_urls AS $url) { - if ((substr($url["title"], 0, 7) != "http://") AND (substr($url["title"], 0, 8) != "https://") AND - !strpos($url["title"], "http://") AND !strpos($url["title"], "https://")) + if ((substr($url["title"], 0, 7) != "http://") && (substr($url["title"], 0, 8) != "https://") && + !strpos($url["title"], "http://") && !strpos($url["title"], "https://")) $display_url = $url["title"]; else { $display_url = str_replace(array("http://www.", "https://www."), array("", ""), $url["url"]); @@ -2455,7 +2455,7 @@ $called_api = null; $scale = scale_image($image[0], $image[1], 150); $sizes["thumb"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"); - if (($image[0] > 150) OR ($image[1] > 150)) { + if (($image[0] > 150) || ($image[1] > 150)) { $scale = scale_image($image[0], $image[1], 340); $sizes["small"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"); } @@ -2463,7 +2463,7 @@ $called_api = null; $scale = scale_image($image[0], $image[1], 600); $sizes["medium"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"); - if (($image[0] > 600) OR ($image[1] > 600)) { + if (($image[0] > 600) || ($image[1] > 600)) { $scale = scale_image($image[0], $image[1], 1024); $sizes["large"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"); } @@ -2668,7 +2668,7 @@ $called_api = null; list($status_user, $owner_user) = api_item_get_user($a, $item); // Look if the posts are matching if they should be filtered by user id - if ($filter_user AND ($status_user["id"] != $user_info["id"])) { + if ($filter_user && ($status_user["id"] != $user_info["id"])) { continue; } @@ -2712,9 +2712,9 @@ $called_api = null; $status["entities"] = $converted["entities"]; } - if (($item['item_network'] != "") AND ($status["source"] == 'web')) { + if (($item['item_network'] != "") && ($status["source"] == 'web')) { $status["source"] = network_to_name($item['item_network'], $user_info['url']); - } elseif (($item['item_network'] != "") AND (network_to_name($item['item_network'], $user_info['url']) != $status["source"])) { + } elseif (($item['item_network'] != "") && (network_to_name($item['item_network'], $user_info['url']) != $status["source"])) { $status["source"] = trim($status["source"].' ('.network_to_name($item['item_network'], $user_info['url']).')'); } @@ -2723,7 +2723,7 @@ $called_api = null; // It doesn't work reliable with the link if its a feed //$IsRetweet = ($item['owner-link'] != $item['author-link']); //if ($IsRetweet) - // $IsRetweet = (($item['owner-name'] != $item['author-name']) OR ($item['owner-avatar'] != $item['author-avatar'])); + // $IsRetweet = (($item['owner-name'] != $item['author-name']) || ($item['owner-avatar'] != $item['author-avatar'])); if ($item["id"] == $item["parent"]) { @@ -3022,7 +3022,7 @@ $called_api = null; if (api_user() === false) throw new ForbiddenException(); - if (!x($_POST, "text") OR (!x($_POST,"screen_name") AND !x($_POST,"user_id"))) return; + if (!x($_POST, "text") || (!x($_POST,"screen_name") && !x($_POST,"user_id"))) return; $sender = api_get_user($a); @@ -3982,7 +3982,7 @@ $called_api = null; } function prepare_photo_data($type, $scale, $photo_id) { - $scale_sql = ($scale === false ? "" : sprintf("and scale=%d", intval($scale))); + $scale_sql = ($scale === false ? "" : sprintf("AND scale=%d", intval($scale))); $data_sql = ($scale === false ? "" : "data, "); // added allow_cid, allow_gid, deny_cid, deny_gid to output as string like stored in database @@ -4334,7 +4334,7 @@ $called_api = null; $in_reply_to['user_id_str'] = NULL; $in_reply_to['screen_name'] = NULL; - if (($item['thr-parent'] != $item['uri']) AND (intval($item['parent']) != intval($item['id']))) { + if (($item['thr-parent'] != $item['uri']) && (intval($item['parent']) != intval($item['id']))) { $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1", intval($item['uid']), dbesc($item['thr-parent'])); @@ -4415,7 +4415,7 @@ $called_api = null; if (isset($data["text"])) $body = $data["text"]; - if (($body == "") AND (isset($data["title"]))) + if (($body == "") && (isset($data["title"]))) $body = $data["title"]; if (isset($data["url"])) diff --git a/include/auth.php b/include/auth.php index 5dfe9d3e06..d301f87055 100644 --- a/include/auth.php +++ b/include/auth.php @@ -29,7 +29,7 @@ if (isset($_COOKIE["Friendica"])) { new_cookie($authcookiedays*24*60*60, $r[0]); // Do the authentification if not done by now - if (!isset($_SESSION) OR !isset($_SESSION['authenticated'])) { + if (!isset($_SESSION) || !isset($_SESSION['authenticated'])) { authenticate_success($r[0]); if (get_config('system','paranoia')) diff --git a/include/auth_ejabberd.php b/include/auth_ejabberd.php index 9211c5baf0..490ea0d1cb 100755 --- a/include/auth_ejabberd.php +++ b/include/auth_ejabberd.php @@ -89,7 +89,7 @@ class exAuth { // Open the logfile if the logfile name is defined if ($this->sLogFile != '') - $this->rLogFile = fopen($this->sLogFile, "a") or die("Error opening log file: ". $this->sLogFile); + $this->rLogFile = fopen($this->sLogFile, "a") || die("Error opening log file: ". $this->sLogFile); $this->writeLog("[exAuth] start"); diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 80ee1b50dc..832dab7e8d 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -188,7 +188,7 @@ function bb2diaspora($Text, $preserve_nl = false, $fordiaspora = true) { $Text = $converter->convert($Text); // unmask the special chars back to HTML - $Text = str_replace(array('&_lt_;', '&_gt_;', '&_amp_;'), array('<', '>', '&'), $Text); + $Text = str_replace(array('&\_lt\_;', '&\_gt\_;', '&\_amp\_;'), array('<', '>', '&'), $Text); $a->save_timestamp($stamp1, "parser"); diff --git a/include/bbcode.php b/include/bbcode.php index 9a43cdb305..0c4e12c9ad 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -49,14 +49,14 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) { $data["title"] = str_replace(array("http://", "https://"), "", $data["title"]); } - if (((strpos($data["text"], "[img=") !== false) OR (strpos($data["text"], "[img]") !== false)) AND ($data["image"] != "")) { + if (((strpos($data["text"], "[img=") !== false) || (strpos($data["text"], "[img]") !== false)) && ($data["image"] != "")) { $data["preview"] = $data["image"]; $data["image"] = ""; } if ($simplehtml == 7) { $text = style_url_for_mastodon($data["url"]); - } elseif (($simplehtml != 4) AND ($simplehtml != 0)) { + } elseif (($simplehtml != 4) && ($simplehtml != 0)) { $text = sprintf('%s
', $data["url"], $data["title"]); } else { $text = sprintf('', $data["type"]); @@ -71,13 +71,13 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) { if (strstr(strtolower($oembed), "