From 27cf228857a84cd5d4e87d8f9803f9589a33e9f7 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Tue, 28 Aug 2018 06:48:57 +0200 Subject: [PATCH 01/96] welcome 2018.08-rc --- VERSION | 2 +- boot.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 607ef5eb6a..40284ee692 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2018.08-dev +2018.08-rc diff --git a/boot.php b/boot.php index b1e98270c0..2236a4d5df 100644 --- a/boot.php +++ b/boot.php @@ -39,7 +39,7 @@ require_once 'include/text.php'; define('FRIENDICA_PLATFORM', 'Friendica'); define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily'); -define('FRIENDICA_VERSION', '2018.08-dev'); +define('FRIENDICA_VERSION', '2018.08-rc'); define('DFRN_PROTOCOL_VERSION', '2.23'); define('DB_UPDATE_VERSION', 1283); define('NEW_UPDATE_ROUTINE_VERSION', 1170); From cf6140e86f64c651168c7687179adc7114770f40 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 28 Aug 2018 11:56:25 +0000 Subject: [PATCH 02/96] Ensure that the post update doesn't end prematurely (#5684) --- src/Database/PostUpdate.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Database/PostUpdate.php b/src/Database/PostUpdate.php index 09e940b149..674fe05531 100644 --- a/src/Database/PostUpdate.php +++ b/src/Database/PostUpdate.php @@ -253,6 +253,12 @@ class PostUpdate $condition = ["`id` > ?", $id]; $params = ['order' => ['id'], 'limit' => 10000]; $items = Item::select($fields, $condition, $params); + + if (DBA::errorNo() != 0) { + logger('Database error ' . DBA::errorNo() . ':' . DBA::errorMessage()); + return false; + } + while ($item = Item::fetch($items)) { $id = $item['id']; @@ -394,6 +400,12 @@ class PostUpdate $condition = ["`id` > ?", $id]; $params = ['order' => ['id'], 'limit' => 10000]; $items = DBA::select('item', $fields, $condition, $params); + + if (DBA::errorNo() != 0) { + logger('Database error ' . DBA::errorNo() . ':' . DBA::errorMessage()); + return false; + } + while ($item = DBA::fetch($items)) { $id = $item['id']; From 8872d86f8d832a26c4f45eab515ffdaff21724db Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Tue, 28 Aug 2018 17:41:09 +0200 Subject: [PATCH 03/96] CS translation update THX Aditoo --- view/lang/cs/messages.po | 38 +++++++++++++++++++------------------- view/lang/cs/strings.php | 36 ++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/view/lang/cs/messages.po b/view/lang/cs/messages.po index 588fdc42ba..8852b2fc32 100644 --- a/view/lang/cs/messages.po +++ b/view/lang/cs/messages.po @@ -13,7 +13,7 @@ msgstr "" "Project-Id-Version: friendica\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-08-25 15:34+0000\n" -"PO-Revision-Date: 2018-08-26 15:02+0000\n" +"PO-Revision-Date: 2018-08-28 14:24+0000\n" "Last-Translator: Aditoo\n" "Language-Team: Czech (http://www.transifex.com/Friendica/friendica/language/cs/)\n" "MIME-Version: 1.0\n" @@ -72,27 +72,27 @@ msgstr "výchozí" #: view/theme/duepuntozero/config.php:55 msgid "greenzero" -msgstr "zelená nula" +msgstr "greenzero" #: view/theme/duepuntozero/config.php:56 msgid "purplezero" -msgstr "fialová nula" +msgstr "purplezero" #: view/theme/duepuntozero/config.php:57 msgid "easterbunny" -msgstr "velikonoční zajíček" +msgstr "easterbunny" #: view/theme/duepuntozero/config.php:58 msgid "darkzero" -msgstr "tmavá nula" +msgstr "darkzero" #: view/theme/duepuntozero/config.php:59 msgid "comix" -msgstr "komiksová" +msgstr "comix" #: view/theme/duepuntozero/config.php:60 msgid "slackr" -msgstr "flákač" +msgstr "slackr" #: view/theme/duepuntozero/config.php:71 view/theme/quattro/config.php:73 #: view/theme/vier/config.php:119 view/theme/frio/config.php:118 @@ -146,7 +146,7 @@ msgstr "Seznam fór s pomocníky, oddělených čárkami" #: view/theme/vier/config.php:115 src/Core/ACL.php:298 msgid "don't show" -msgstr "nikdy nezobrazit" +msgstr "nezobrazit" #: view/theme/vier/config.php:115 src/Core/ACL.php:297 msgid "show" @@ -193,7 +193,7 @@ msgstr "Zadejte jméno nebo zájmy" #: mod/allfriends.php:76 mod/contacts.php:604 mod/contacts.php:610 #: mod/follow.php:143 src/Model/Contact.php:933 src/Content/Widget.php:61 msgid "Connect/Follow" -msgstr "Spojit/Sledovat" +msgstr "Spojit/sledovat" #: view/theme/vier/theme.php:200 src/Content/Widget.php:62 msgid "Examples: Robert Morgenstein, Fishing" @@ -245,7 +245,7 @@ msgstr "zobrazit více" #: view/theme/vier/theme.php:289 msgid "Quick Start" -msgstr "Rychlý start" +msgstr "Rychlý začátek" #: view/theme/vier/theme.php:295 mod/help.php:56 src/Content/Nav.php:134 msgid "Help" @@ -551,7 +551,7 @@ msgstr "%1$s šťouchnul/a uživatele %2$s" #: include/conversation.php:309 mod/tagger.php:108 #, php-format msgid "%1$s tagged %2$s's %3$s with %4$s" -msgstr "%1$s označil/a %3$s uživatele %2$s jako %4$s" +msgstr "%1$s označil/a %3$s uživatele %2$s štítkem %4$s" #: include/conversation.php:331 msgid "post/item" @@ -1093,7 +1093,7 @@ msgstr "[Friendica:Oznámení] %s označil/a Váš příspěvek" #: include/enotify.php:270 #, php-format msgid "%1$s tagged your post at %2$s" -msgstr "%1$s označil/a Váš příspěvek na%2$s" +msgstr "%1$s označil/a Váš příspěvek na %2$s" #: include/enotify.php:271 #, php-format @@ -3818,7 +3818,7 @@ msgstr "Pro více informací o projektu Friendica, prosím, navštivte stránku #: mod/friendica.php:88 msgid "Bug reports and issues: please visit" -msgstr "Pro hlášení chyb a námětů na změny navštivte" +msgstr "Pro hlášení chyb a námětů na změny prosím navštivte" #: mod/friendica.php:88 msgid "the bugtracker at github" @@ -4721,23 +4721,23 @@ msgstr "Normální účet" #: mod/admin.php:883 msgid "Automatic Follower Account" -msgstr "Automatický účet sledovatele" +msgstr "Účet s automatickými sledovateli" #: mod/admin.php:884 msgid "Public Forum Account" -msgstr "Veřejný účet na fóru" +msgstr "Účet veřejného fóra" #: mod/admin.php:885 msgid "Automatic Friend Account" -msgstr "Účet s automatickým schvalováním přátel" +msgstr "Účet s automatickými přáteli" #: mod/admin.php:886 msgid "Blog Account" -msgstr "Účet Blogu" +msgstr "Blogovací účet" #: mod/admin.php:887 msgid "Private Forum Account" -msgstr "Soukromá účet na fóru" +msgstr "Účet soukromého fóra" #: mod/admin.php:909 msgid "Message queues" @@ -4822,7 +4822,7 @@ msgstr "Jeden rok" #: mod/admin.php:1368 msgid "Multi user instance" -msgstr "Více uživatelská instance" +msgstr "Víceuživatelská instance" #: mod/admin.php:1394 msgid "Closed" diff --git a/view/lang/cs/strings.php b/view/lang/cs/strings.php index d775ebe3de..f78c139ca2 100644 --- a/view/lang/cs/strings.php +++ b/view/lang/cs/strings.php @@ -13,12 +13,12 @@ $a->strings["Permission denied"] = "Nedostatečné oprávnění"; $a->strings["Permission denied."] = "Přístup odmítnut."; $a->strings["toggle mobile"] = "přepínat mobilní zobrazení"; $a->strings["default"] = "výchozí"; -$a->strings["greenzero"] = "zelená nula"; -$a->strings["purplezero"] = "fialová nula"; -$a->strings["easterbunny"] = "velikonoční zajíček"; -$a->strings["darkzero"] = "tmavá nula"; -$a->strings["comix"] = "komiksová"; -$a->strings["slackr"] = "flákač"; +$a->strings["greenzero"] = "greenzero"; +$a->strings["purplezero"] = "purplezero"; +$a->strings["easterbunny"] = "easterbunny"; +$a->strings["darkzero"] = "darkzero"; +$a->strings["comix"] = "comix"; +$a->strings["slackr"] = "slackr"; $a->strings["Submit"] = "Odeslat"; $a->strings["Theme settings"] = "Nastavení motivu"; $a->strings["Variations"] = "Variace"; @@ -29,7 +29,7 @@ $a->strings["Color scheme"] = "Barevné schéma"; $a->strings["Posts font size"] = "Velikost písma u příspěvků"; $a->strings["Textareas font size"] = "Velikost písma textů"; $a->strings["Comma separated list of helper forums"] = "Seznam fór s pomocníky, oddělených čárkami"; -$a->strings["don't show"] = "nikdy nezobrazit"; +$a->strings["don't show"] = "nezobrazit"; $a->strings["show"] = "zobrazit"; $a->strings["Set style"] = "Nastavit styl"; $a->strings["Community Pages"] = "Komunitní stránky"; @@ -40,7 +40,7 @@ $a->strings["Find Friends"] = "Najít přátele"; $a->strings["Last users"] = "Poslední uživatelé"; $a->strings["Find People"] = "Najít lidi"; $a->strings["Enter name or interest"] = "Zadejte jméno nebo zájmy"; -$a->strings["Connect/Follow"] = "Spojit/Sledovat"; +$a->strings["Connect/Follow"] = "Spojit/sledovat"; $a->strings["Examples: Robert Morgenstein, Fishing"] = "Příklady: Josef Dvořák, rybaření"; $a->strings["Find"] = "Najít"; $a->strings["Friend Suggestions"] = "Návrhy přátel"; @@ -52,7 +52,7 @@ $a->strings["Local Directory"] = "Lokální adresář"; $a->strings["Forums"] = "Fóra"; $a->strings["External link to forum"] = "Externí odkaz na fórum"; $a->strings["show more"] = "zobrazit více"; -$a->strings["Quick Start"] = "Rychlý start"; +$a->strings["Quick Start"] = "Rychlý začátek"; $a->strings["Help"] = "Nápověda"; $a->strings["Custom"] = "Vlastní"; $a->strings["Note"] = "Poznámka"; @@ -117,7 +117,7 @@ $a->strings["%1\$s doesn't attend %2\$s's %3\$s"] = "%1\$s se neúčastní %3\$s $a->strings["%1\$s attends maybe %2\$s's %3\$s"] = "%1\$s se možná účastní %3\$s uživatele %2\$s"; $a->strings["%1\$s is now friends with %2\$s"] = "%1\$s se nyní přátelí s uživatelem %2\$s"; $a->strings["%1\$s poked %2\$s"] = "%1\$s šťouchnul/a uživatele %2\$s"; -$a->strings["%1\$s tagged %2\$s's %3\$s with %4\$s"] = "%1\$s označil/a %3\$s uživatele %2\$s jako %4\$s"; +$a->strings["%1\$s tagged %2\$s's %3\$s with %4\$s"] = "%1\$s označil/a %3\$s uživatele %2\$s štítkem %4\$s"; $a->strings["post/item"] = "příspěvek/položka"; $a->strings["%1\$s marked %2\$s's %3\$s as favorite"] = "%1\$s označil/a %3\$s uživatele %2\$s jako oblíbené"; $a->strings["Likes"] = "Libí se"; @@ -256,7 +256,7 @@ $a->strings["[Friendica:Notify] %1\$s poked you"] = "[Friendica:Oznámení] %1\$ $a->strings["%1\$s poked you at %2\$s"] = "%1\$s Vás šťouchnul/a na %2\$s"; $a->strings["%1\$s [url=%2\$s]poked you[/url]."] = "%1\$s [url=%2\$s]Vás šťouchnul/a[/url]."; $a->strings["[Friendica:Notify] %s tagged your post"] = "[Friendica:Oznámení] %s označil/a Váš příspěvek"; -$a->strings["%1\$s tagged your post at %2\$s"] = "%1\$s označil/a Váš příspěvek na%2\$s"; +$a->strings["%1\$s tagged your post at %2\$s"] = "%1\$s označil/a Váš příspěvek na %2\$s"; $a->strings["%1\$s tagged [url=%2\$s]your post[/url]"] = "%1\$s označil/a [url=%2\$s]Váš příspěvek[/url]"; $a->strings["[Friendica:Notify] Introduction received"] = "[Friendica:Oznámení] Obdrženo představení"; $a->strings["You've received an introduction from '%1\$s' at %2\$s"] = "Obdržel/a jste představení od uživatele \"%1\$s\" na %2\$s"; @@ -899,7 +899,7 @@ $a->strings["Ignore/Hide"] = "Ignorovat/skrýt"; $a->strings["- select -"] = "- vyberte -"; $a->strings["This is Friendica, version %s that is running at the web location %s. The database version is %s, the post update version is %s."] = "Tohle je Friendica, verze %s, běžící na webové adrese %s. Verze databáze je %s, verze post update je %s."; $a->strings["Please visit Friendi.ca to learn more about the Friendica project."] = "Pro více informací o projektu Friendica, prosím, navštivte stránku Friendi.ca"; -$a->strings["Bug reports and issues: please visit"] = "Pro hlášení chyb a námětů na změny navštivte"; +$a->strings["Bug reports and issues: please visit"] = "Pro hlášení chyb a námětů na změny prosím navštivte"; $a->strings["the bugtracker at github"] = "sledování chyb na GitHubu"; $a->strings["Suggestions, praise, etc. - please email \"info\" at \"friendi - dot - ca"] = "Návrhy, pochvaly atd., prosím, posílejte na adresu \"info\" zavináč \"friendi\"-tečka-\"ca\""; $a->strings["Installed addons/apps:"] = "Nainstalované doplňky/aplikace:"; @@ -1090,11 +1090,11 @@ $a->strings["The last worker execution was on %s UTC. This is older than one hou $a->strings["Friendica's configuration now is stored in config/local.ini.php, please copy config/local-sample.ini.php and move your config from .htconfig.php. See the Config help page for help with the transition."] = "Konfigurace Friendica je nyní uložena v souboru config/local.ini.php, prosím zkopírujte soubor config/local-sample.ini.php a přesuňte svou konfiguraci ze souboru .htconfig.php. Pro pomoc při přechodu navštivte stránku Config v sekci nápovědy."; $a->strings["%s is not reachable on your system. This is a servere configuration issue that prevents the communication.. See the installation page for help."] = "%s není na Vašem systému dosažitelné. Tohle je závažná chyba konfigurace, která brání komunikaci. Pro pomoc navštivte stránku instalace."; $a->strings["Normal Account"] = "Normální účet"; -$a->strings["Automatic Follower Account"] = "Automatický účet sledovatele"; -$a->strings["Public Forum Account"] = "Veřejný účet na fóru"; -$a->strings["Automatic Friend Account"] = "Účet s automatickým schvalováním přátel"; -$a->strings["Blog Account"] = "Účet Blogu"; -$a->strings["Private Forum Account"] = "Soukromá účet na fóru"; +$a->strings["Automatic Follower Account"] = "Účet s automatickými sledovateli"; +$a->strings["Public Forum Account"] = "Účet veřejného fóra"; +$a->strings["Automatic Friend Account"] = "Účet s automatickými přáteli"; +$a->strings["Blog Account"] = "Blogovací účet"; +$a->strings["Private Forum Account"] = "Účet soukromého fóra"; $a->strings["Message queues"] = "Fronty zpráv"; $a->strings["Summary"] = "Shrnutí"; $a->strings["Registered users"] = "Registrovaní uživatelé"; @@ -1115,7 +1115,7 @@ $a->strings["One month"] = "Jeden měsíc"; $a->strings["Three months"] = "Tři měsíce"; $a->strings["Half a year"] = "Půl roku"; $a->strings["One year"] = "Jeden rok"; -$a->strings["Multi user instance"] = "Více uživatelská instance"; +$a->strings["Multi user instance"] = "Víceuživatelská instance"; $a->strings["Closed"] = "Uzavřeno"; $a->strings["Requires approval"] = "Vyžaduje schválení"; $a->strings["Open"] = "Otevřená"; From 91a3bf5610910da8709f0fe9aa3de2201efb124e Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 28 Aug 2018 18:15:25 +0000 Subject: [PATCH 04/96] Fix: The profile page is now ordered after the creation date again (#5690) --- mod/profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/profile.php b/mod/profile.php index 4f2e22d674..2e3ccd28c5 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -333,7 +333,7 @@ function profile_content(App $a, $update = 0) } } - $o .= conversation($a, $items, 'profile', $update, false, 'commented', local_user()); + $o .= conversation($a, $items, 'profile', $update, false, 'created', local_user()); if (!$update) { $o .= alt_pager($a, count($items)); From 99b8f856242346a046152ebe9033846e06c35f3b Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 28 Aug 2018 19:38:28 +0000 Subject: [PATCH 05/96] Poke is fixed (#5689) * Fix: Poke hasn't worked. It does work now partially * Poke are now displayed good again * removed code --- include/conversation.php | 3 +-- mod/poke.php | 37 ++++++++++++++++++------------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index ca01997f6a..f10c79d4be 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -229,12 +229,11 @@ function localize_item(&$item) $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">"; $obj = XML::parseString($xmlhead.$item['object']); - $links = XML::parseString($xmlhead."".unxmlify($obj->link).""); $Bname = $obj->title; $Blink = ""; $Bphoto = ""; - foreach ($links->link as $l) { + foreach ($obj->link as $l) { $atts = $l->attributes(); switch ($atts['rel']) { case "alternate": $Blink = $atts['href']; diff --git a/mod/poke.php b/mod/poke.php index a9dfc73f4e..91f33c0def 100644 --- a/mod/poke.php +++ b/mod/poke.php @@ -24,19 +24,20 @@ use Friendica\Model\Item; require_once 'include/security.php'; require_once 'include/items.php'; -function poke_init(App $a) { - +function poke_init(App $a) +{ if (!local_user()) { return; } $uid = local_user(); - $verb = notags(trim($_GET['verb'])); - if (!$verb) { + if (empty($_GET['verb'])) { return; } + $verb = notags(trim($_GET['verb'])); + $verbs = get_poke_verbs(); if (!array_key_exists($verb, $verbs)) { @@ -99,7 +100,7 @@ function poke_init(App $a) { $arr['guid'] = System::createGUID(32); $arr['uid'] = $uid; $arr['uri'] = $uri; - $arr['parent-uri'] = ($parent_uri ? $parent_uri : $uri); + $arr['parent-uri'] = (!empty($parent_uri) ? $parent_uri : $uri); $arr['wall'] = 1; $arr['contact-id'] = $poster['id']; $arr['owner-name'] = $poster['name']; @@ -121,7 +122,7 @@ function poke_init(App $a) { $arr['origin'] = 1; $arr['body'] = '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' . ' ' . L10n::t($verbs[$verb][0]) . ' ' . '[url=' . $target['url'] . ']' . $target['name'] . '[/url]'; - $arr['object'] = '' . ACTIVITY_OBJ_PERSON . '' . $target['name'] . '' . System::baseUrl() . '/contact/' . $target['id'] . ''; + $arr['object'] = '' . ACTIVITY_OBJ_PERSON . '' . $target['name'] . '' . $target['url'] . ''; $arr['object'] .= '' . xmlify('' . "\n"); $arr['object'] .= xmlify('' . "\n"); @@ -137,10 +138,8 @@ function poke_init(App $a) { return; } - - -function poke_content(App $a) { - +function poke_content(App $a) +{ if (!local_user()) { notice(L10n::t('Permission denied.') . EOL); return; @@ -149,17 +148,17 @@ function poke_content(App $a) { $name = ''; $id = ''; - if (intval($_GET['c'])) { - $r = q("SELECT `id`,`name` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($_GET['c']), - intval(local_user()) - ); - if (DBA::isResult($r)) { - $name = $item['name']; - $id = $item['id']; - } + if (empty($_GET['c'])) { + return; } + $contact = DBA::selectFirst('contact', ['id', 'name'], ['id' => $_GET['c'], 'uid' => local_user()]); + if (!DBA::isResult($contact)) { + return; + } + + $name = $contact['name']; + $id = $contact['id']; $base = System::baseUrl(); From d489712824a8f3fe9840ae793a2be16149afcfcb Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 29 Aug 2018 11:48:40 +0000 Subject: [PATCH 06/96] The post update version can now be set. --- src/Core/Console/PostUpdate.php | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Core/Console/PostUpdate.php b/src/Core/Console/PostUpdate.php index 97c19b0c1e..2ae640d483 100644 --- a/src/Core/Console/PostUpdate.php +++ b/src/Core/Console/PostUpdate.php @@ -3,6 +3,7 @@ namespace Friendica\Core\Console; use Friendica\Core\L10n; +use Friendica\Core\Config; /** * @brief tool to block an account from the node @@ -17,12 +18,39 @@ use Friendica\Core\L10n; */ class PostUpdate extends \Asika\SimpleConsole\Console { + protected $helpOptions = ['h', 'help', '?']; + + protected function getHelp() + { + $help = <<] + +Options + -h|--help|-? Show help information + --reset Reset the post update version +HELP; + return $help; + } + protected function doExecute() { $a = get_app(); - if (count($this->args) > 0) { - throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments'); + if ($this->getOption($this->helpOptions)) { + $this->out($this->getHelp()); + return 0; + } + + $reset_version = $this->getOption('reset'); + if (is_bool($reset_version)) { + $this->out($this->getHelp()); + return 0; + } elseif ($reset_version) { + Config::set('system', 'post_update_version', $reset_version); + echo L10n::t('Post update version number has been set to %s.', $reset_version) . "\n"; + return 0; } if ($a->isInstallMode()) { From 601851f3d0b5439f75c6e984733e850c7beed40c Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 29 Aug 2018 13:00:01 +0000 Subject: [PATCH 07/96] Removed notice - pokes do now work mostly (#5693) --- include/conversation.php | 3 ++- src/Protocol/DFRN.php | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/conversation.php b/include/conversation.php index f10c79d4be..45e5d1caa3 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -231,8 +231,9 @@ function localize_item(&$item) $obj = XML::parseString($xmlhead.$item['object']); $Bname = $obj->title; - $Blink = ""; + $Blink = $obj->id; $Bphoto = ""; + foreach ($obj->link as $l) { $atts = $l->attributes(); switch ($atts['rel']) { diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 0b228b045b..759f7f5f28 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -2252,6 +2252,11 @@ class DFRN if ($Blink && link_compare($Blink, System::baseUrl() . "/profile/" . $importer["nickname"])) { $author = DBA::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]); + $item['id'] = $posted_id; + + $parent = Item::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => $importer["importer_uid"]]); + $item["parent"] = $parent['id']; + // send a notification notification( [ From 67227570d8e9e769fdc5c0383cf56b207372302c Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 29 Aug 2018 13:06:56 +0000 Subject: [PATCH 08/96] "Does" is now "perform" --- src/Core/Console/DatabaseStructure.php | 4 ++-- src/Core/Console/PostUpdate.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Core/Console/DatabaseStructure.php b/src/Core/Console/DatabaseStructure.php index 1b64622dbf..13ed29b9df 100644 --- a/src/Core/Console/DatabaseStructure.php +++ b/src/Core/Console/DatabaseStructure.php @@ -11,7 +11,7 @@ require_once 'boot.php'; require_once 'include/dba.php'; /** - * @brief Does database updates from the command line + * @brief Performs database updates from the command line * * @author Hypolite Petovan */ @@ -22,7 +22,7 @@ class DatabaseStructure extends \Asika\SimpleConsole\Console protected function getHelp() { $help = << [-h|--help|-?] [-v] diff --git a/src/Core/Console/PostUpdate.php b/src/Core/Console/PostUpdate.php index 2ae640d483..3162a725c0 100644 --- a/src/Core/Console/PostUpdate.php +++ b/src/Core/Console/PostUpdate.php @@ -23,7 +23,7 @@ class PostUpdate extends \Asika\SimpleConsole\Console protected function getHelp() { $help = <<] From c7f8f190b9f14c28fe811a2f244534027344e7cc Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 29 Aug 2018 18:28:13 +0000 Subject: [PATCH 09/96] Oh no, even more notices ... (#5697) --- mod/videos.php | 3 ++- src/Model/User.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mod/videos.php b/mod/videos.php index e622e17f0f..e00df10a24 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -367,11 +367,12 @@ function videos_content(App $a) foreach ($r as $rr) { $alt_e = $rr['filename']; /// @todo The album isn't part of the above query. This seems to be some unfinished code that needs to be reworked completely. + $rr['album'] = ''; $name_e = $rr['album']; $videos[] = [ 'id' => $rr['id'], - 'link' => System::baseUrl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'], + 'link' => System::baseUrl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['hash'], 'title' => L10n::t('View Video'), 'src' => System::baseUrl() . '/attach/' . $rr['id'] . '?attachment=0', 'alt' => $alt_e, diff --git a/src/Model/User.php b/src/Model/User.php index a43ef06f97..d65e7d8f96 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -730,7 +730,7 @@ class User DBA::insert('userd', ['username' => $user['nickname']]); // The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php) - DBA::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utc($t . " + 7 day")], ['uid' => $uid]); + DBA::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utc(DateTimeFormat::utcNow() . " + 7 day")], ['uid' => $uid]); Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid); // Send an update to the directory From b8e8b771d4ead88ae08b062fa9fce9352ba3b5b4 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 29 Aug 2018 18:52:48 +0000 Subject: [PATCH 10/96] Issue 5696: Removed old forum link --- doc/Developers-Intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Developers-Intro.md b/doc/Developers-Intro.md index 1e077902d6..5deaf98ff0 100644 --- a/doc/Developers-Intro.md +++ b/doc/Developers-Intro.md @@ -33,7 +33,7 @@ If you don't want to translate the UI, or it is already done to your satisfactio Are you good at designing things? If you have seen Friendica you probably have ideas to improve it, haven't you? -* If you would like to work with us on enhancing the user interface, please join the [UX Watchdogs forum](https://fc.oscp.info/profile/ux-watchdogs) +* If you would like to work with us on enhancing the user interface, please join the [forum for Friendica development](https://forum.friendi.ca/profile/developers). * Make plans for a better Friendica interface design and share them with us. * Tell us if you are able to realize your ideas or what kind of help you need. We can't promise we have the right skills in the group but we'll try. From 9bff31f18f35acba405724f0dacdf20b0c6e8ba4 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 29 Aug 2018 19:11:43 +0000 Subject: [PATCH 11/96] Issue 5691: Post dates of feeds sometimes had been wrong --- src/Protocol/Feed.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index c9c750a83f..0709a9550e 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -271,9 +271,14 @@ class Feed { } $updated = XML::getFirstNodeValue($xpath, 'atom:updated/text()', $entry); - if (empty($updated)) { + if (empty($updated) && !empty($published)) { $updated = $published; } + + if (empty($published) && !empty($updated)) { + $published = $updated; + } + if ($published != "") { $item["created"] = $published; } From c72d1bc8fda4f1088657885fbb47d128a9f4bcad Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 29 Aug 2018 20:46:52 +0000 Subject: [PATCH 12/96] Issue 5653: The mastodonemoji addon hadn't got all needed data. --- src/Model/Item.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index d235f0a7f9..d10a211a59 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1462,15 +1462,6 @@ class Item extends BaseObject return 0; } - // These fields aren't stored anymore in the item table, they are fetched upon request - unset($item['author-link']); - unset($item['author-name']); - unset($item['author-avatar']); - - unset($item['owner-link']); - unset($item['owner-name']); - unset($item['owner-avatar']); - if ($item['network'] == Protocol::PHANTOM) { logger('Missing network. Called by: '.System::callstack(), LOGGER_DEBUG); @@ -1708,6 +1699,15 @@ class Item extends BaseObject unset($item['postopts']); unset($item['inform']); + // These fields aren't stored anymore in the item table, they are fetched upon request + unset($item['author-link']); + unset($item['author-name']); + unset($item['author-avatar']); + + unset($item['owner-link']); + unset($item['owner-name']); + unset($item['owner-avatar']); + DBA::transaction(); $ret = DBA::insert('item', $item); From 02da8275602ab7b360ebfab8e0e2072d2c39aa42 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 30 Aug 2018 04:05:32 +0000 Subject: [PATCH 13/96] and now for something completely different: A removed notice --- src/Protocol/OStatus.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 7052205e17..551b4ad887 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -351,7 +351,7 @@ class OStatus $header["origin"] = 0; $header["gravity"] = GRAVITY_COMMENT; - if (!is_object($doc->firstChild)) { + if (!is_object($doc->firstChild) || empty($doc->firstChild->tagName)) { return false; } From a3570d00273b974270620ccbd5e080d628f422ec Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 30 Aug 2018 09:52:38 +0000 Subject: [PATCH 14/96] Fix: Missing gserver entries - show correct server platform --- src/Model/Contact.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 3e70a5cbde..d53126f6ff 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1076,6 +1076,11 @@ class Contact extends BaseObject if (empty($data)) { $data = Probe::uri($url, "", $uid); + + // Ensure that there is a gserver entry + if (!empty($data['baseurl']) && ($data['network'] != Protocol::PHANTOM)) { + PortableContact::checkServer($data['baseurl']); + } } // Last try in gcontact for unsupported networks From e480da788e7d44f0704441f8879c5ff93d98eaf0 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 30 Aug 2018 08:27:31 -0400 Subject: [PATCH 15/96] Fix unfollow for sharing-only contacts - Add removal when unfollowing sharing-only contacts --- mod/unfollow.php | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/mod/unfollow.php b/mod/unfollow.php index 5c00726e27..5942171247 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -27,29 +27,37 @@ function unfollow_post(App $a) $url = notags(trim($_REQUEST['url'])); $return_url = $_SESSION['return_url']; - $condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?", - $uid, Contact::FRIEND, normalise_link($url), + $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?", + $uid, Contact::SHARING, Contact::FRIEND, normalise_link($url), normalise_link($url), $url, Protocol::STATUSNET]; $contact = DBA::selectFirst('contact', [], $condition); if (!DBA::isResult($contact)) { notice(L10n::t("Contact wasn't found or can't be unfollowed.")); - } else { - if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN])) { - $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid` - WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1", - intval($uid) - ); - if (DBA::isResult($r)) { - Contact::terminateFriendship($r[0], $contact); - } - } - DBA::update('contact', ['rel' => Contact::FOLLOWER], ['id' => $contact['id']]); - - info(L10n::t('Contact unfollowed').EOL); - goaway(System::baseUrl().'/contacts/'.$contact['id']); + goaway($return_url); } - goaway($return_url); + + if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN])) { + $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid` + WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1", + intval($uid) + ); + if (DBA::isResult($r)) { + Contact::terminateFriendship($r[0], $contact); + } + } + + // Sharing-only contacts get deleted as there no relationship any more + if ($contact['rel'] == Contact::SHARING) { + Contact::remove($contact['id']); + $return_path = 'contacts'; + } else { + DBA::update('contact', ['rel' => Contact::FOLLOWER], ['id' => $contact['id']]); + $return_path = 'contacts/' . $contact['id']; + } + + info(L10n::t('Contact unfollowed')); + goaway($return_path); // NOTREACHED } @@ -66,8 +74,8 @@ function unfollow_content(App $a) $submit = L10n::t('Submit Request'); - $condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?", - local_user(), Contact::FRIEND, normalise_link($url), + $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?", + local_user(), Contact::SHARING, Contact::FRIEND, normalise_link($url), normalise_link($url), $url, Protocol::STATUSNET]; $contact = DBA::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition); From b81eaec88576dbbfa5f447df18a36a1866d19a1d Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 30 Aug 2018 08:52:15 -0400 Subject: [PATCH 16/96] Enable unfollowing contacts from all networks (but Statusnet) --- mod/contacts.php | 2 +- mod/unfollow.php | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/mod/contacts.php b/mod/contacts.php index 4e87697172..38896a611a 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -595,7 +595,7 @@ function contacts_content(App $a, $update = 0) /// @todo Only show the following link with DFRN when the remote version supports it $follow = ''; $follow_text = ''; - if (in_array($contact['network'], [Protocol::DIASPORA, Protocol::OSTATUS, Protocol::DFRN])) { + if ($contact['network'] != Protocol::STATUSNET) { if (in_array($contact['rel'], [Contact::FRIEND, Contact::SHARING])) { $follow = System::baseUrl(true) . "/unfollow?url=" . urlencode($contact["url"]); $follow_text = L10n::t("Disconnect/Unfollow"); diff --git a/mod/unfollow.php b/mod/unfollow.php index 5942171247..4bc64e4fc3 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -28,13 +28,20 @@ function unfollow_post(App $a) $return_url = $_SESSION['return_url']; $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?", - $uid, Contact::SHARING, Contact::FRIEND, normalise_link($url), - normalise_link($url), $url, Protocol::STATUSNET]; + $uid, Contact::SHARING, Contact::FRIEND, normalise_link($url), + normalise_link($url), $url]; $contact = DBA::selectFirst('contact', [], $condition); if (!DBA::isResult($contact)) { - notice(L10n::t("Contact wasn't found or can't be unfollowed.")); + notice(L10n::t("You aren't following this contact.")); goaway($return_url); + // NOTREACHED + } + + if ($contact['network'] == Protocol::STATUSNET) { + notice(L10n::t('Unfollowing is currently not supported by your network.')); + goaway($return_url); + // NOTREACHED } if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN])) { @@ -74,21 +81,21 @@ function unfollow_content(App $a) $submit = L10n::t('Submit Request'); - $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?", - local_user(), Contact::SHARING, Contact::FRIEND, normalise_link($url), - normalise_link($url), $url, Protocol::STATUSNET]; + $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)", + local_user(), Contact::SHARING, Contact::FRIEND, normalise_link($url), + normalise_link($url), $url]; $contact = DBA::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition); if (!DBA::isResult($contact)) { - notice(L10n::t("You aren't a friend of this contact.").EOL); - $submit = ""; + notice(L10n::t("You aren't following this contact.")); + goaway('contacts'); // NOTREACHED } - if (!in_array($contact['network'], [Protocol::DIASPORA, Protocol::OSTATUS, Protocol::DFRN])) { - notice(L10n::t("Unfollowing is currently not supported by your network.").EOL); - $submit = ""; + if ($contact['network'] == Protocol::STATUSNET) { + notice(L10n::t('Unfollowing is currently not supported by your network.')); + goaway('contacts/' . $contact['id']); // NOTREACHED } From 55c676d8b0074bf534049cd54dd1eae646a6c590 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 30 Aug 2018 08:54:12 -0400 Subject: [PATCH 17/96] Source cleaning mod/unfollow.php - Normalize quotes - Remove unneeded EOL - Use DBA method where tasteful --- mod/unfollow.php | 89 +++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/mod/unfollow.php b/mod/unfollow.php index 4bc64e4fc3..f82796a6b7 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -11,21 +11,22 @@ use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Model\Profile; -function unfollow_post(App $a) +function unfollow_post() { + $return_url = $_SESSION['return_url']; + if (!local_user()) { - notice(L10n::t('Permission denied.') . EOL); - goaway($_SESSION['return_url']); + notice(L10n::t('Permission denied.')); + goaway($return_url); // NOTREACHED } if ($_REQUEST['cancel']) { - goaway($_SESSION['return_url']); + goaway($return_url); } $uid = local_user(); - $url = notags(trim($_REQUEST['url'])); - $return_url = $_SESSION['return_url']; + $url = notags(trim(defaults($_REQUEST, 'url', ''))); $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?", $uid, Contact::SHARING, Contact::FRIEND, normalise_link($url), @@ -70,8 +71,8 @@ function unfollow_post(App $a) function unfollow_content(App $a) { - if (! local_user()) { - notice(L10n::t('Permission denied.') . EOL); + if (!local_user()) { + notice(L10n::t('Permission denied.')); goaway($_SESSION['return_url']); // NOTREACHED } @@ -79,8 +80,6 @@ function unfollow_content(App $a) $uid = local_user(); $url = notags(trim($_REQUEST['url'])); - $submit = L10n::t('Submit Request'); - $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)", local_user(), Contact::SHARING, Contact::FRIEND, normalise_link($url), normalise_link($url), $url]; @@ -99,58 +98,56 @@ function unfollow_content(App $a) // NOTREACHED } - $request = System::baseUrl()."/unfollow"; + $request = System::baseUrl() . '/unfollow'; $tpl = get_markup_template('auto_request.tpl'); - $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid)); + $self = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]); - if (!$r) { - notice(L10n::t('Permission denied.') . EOL); + if (!DBA::isResult($self)) { + notice(L10n::t('Permission denied.')); goaway($_SESSION['return_url']); // NOTREACHED } - $myaddr = $r[0]["url"]; - // Makes the connection request for friendica contacts easier - $_SESSION["fastlane"] = $contact["url"]; + $_SESSION['fastlane'] = $contact['url']; - $header = L10n::t("Disconnect/Unfollow"); + $header = L10n::t('Disconnect/Unfollow'); - $o = replace_macros($tpl, [ - '$header' => htmlentities($header), - '$desc' => "", - '$pls_answer' => "", - '$does_know_you' => "", - '$add_note' => "", - '$page_desc' => "", - '$friendica' => "", - '$statusnet' => "", - '$diaspora' => "", - '$diasnote' => "", - '$your_address' => L10n::t('Your Identity Address:'), - '$invite_desc' => "", - '$emailnet' => "", - '$submit' => $submit, - '$cancel' => L10n::t('Cancel'), - '$nickname' => "", - '$name' => $contact["name"], - '$url' => $contact["url"], - '$zrl' => Contact::magicLink($contact["url"]), - '$url_label' => L10n::t("Profile URL"), - '$myaddr' => $myaddr, - '$request' => $request, - '$keywords' => "", - '$keywords_label' => "" + $o = replace_macros($tpl, [ + '$header' => htmlentities($header), + '$desc' => '', + '$pls_answer' => '', + '$does_know_you' => '', + '$add_note' => '', + '$page_desc' => '', + '$friendica' => '', + '$statusnet' => '', + '$diaspora' => '', + '$diasnote' => '', + '$your_address' => L10n::t('Your Identity Address:'), + '$invite_desc' => '', + '$emailnet' => '', + '$submit' => L10n::t('Submit Request'), + '$cancel' => L10n::t('Cancel'), + '$nickname' => '', + '$name' => $contact['name'], + '$url' => $contact['url'], + '$zrl' => Contact::magicLink($contact['url']), + '$url_label' => L10n::t('Profile URL'), + '$myaddr' => $self['url'], + '$request' => $request, + '$keywords' => '', + '$keywords_label'=> '' ]); - $a->page['aside'] = ""; - Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"])); + $a->page['aside'] = ''; + Profile::load($a, '', 0, Contact::getDetailsByURL($contact['url'])); $o .= replace_macros(get_markup_template('section_title.tpl'), ['$title' => L10n::t('Status Messages and Posts')]); // Show last public posts - $o .= Contact::getPostsFromUrl($contact["url"]); + $o .= Contact::getPostsFromUrl($contact['url']); return $o; } From 804cfa03200456116db0c96b7f2ae6e3b7bdbfd8 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 30 Aug 2018 17:47:48 -0400 Subject: [PATCH 18/96] Reorganize Protocol constants - Add ActivityPub protocol constant - Add Protocol::NATIVE_SUPPORT - Sort/group constant names --- src/Core/Protocol.php | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/Core/Protocol.php b/src/Core/Protocol.php index 4467bf0027..9e96b7db2f 100644 --- a/src/Core/Protocol.php +++ b/src/Core/Protocol.php @@ -13,27 +13,33 @@ use Friendica\Util\Network; */ class Protocol { - const DFRN = 'dfrn'; // Friendica, Mistpark, other DFRN implementations - const DIASPORA = 'dspr'; // Diaspora - const DIASPORA2 = 'dspc'; // Diaspora connector - const STATUSNET = 'stac'; // Statusnet connector - const OSTATUS = 'stat'; // GNU-social, Pleroma, Mastodon, other OStatus implementations - const FEED = 'feed'; // RSS/Atom feeds with no known "post/notify" protocol - const MAIL = 'mail'; // IMAP/POP - const XMPP = 'xmpp'; // XMPP - Currently unsupported + // Native support + const ACTIVITYPUB = 'apub'; // ActivityPub + const DFRN = 'dfrn'; // Friendica, Mistpark, other DFRN implementations + const DIASPORA = 'dspr'; // Diaspora + const FEED = 'feed'; // RSS/Atom feeds with no known "post/notify" protocol + const MAIL = 'mail'; // IMAP/POP + const OSTATUS = 'stat'; // GNU-social, Pleroma, Mastodon, other OStatus implementations - const FACEBOOK = 'face'; // Facebook API - const LINKEDIN = 'lnkd'; // LinkedIn - const MYSPACE = 'mysp'; // MySpace - Currently unsupported - const GPLUS = 'goog'; // Google+ - const PUMPIO = 'pump'; // pump.io - const TWITTER = 'twit'; // Twitter + const NATIVE_SUPPORT = [self::DFRN, self::DIASPORA, self::OSTATUS, self::FEED, self::MAIL, self::ACTIVITYPUB]; + + // Supported through a connector const APPNET = 'apdn'; // app.net - Dead protocol + const DIASPORA2 = 'dspc'; // Diaspora connector + const FACEBOOK = 'face'; // Facebook API + const GPLUS = 'goog'; // Google+ + const LINKEDIN = 'lnkd'; // LinkedIn + const PUMPIO = 'pump'; // pump.io + const STATUSNET = 'stac'; // Statusnet connector + const TWITTER = 'twit'; // Twitter - const NEWS = 'nntp'; // Network News Transfer Protocol - Currently unsupported - const ICALENDAR = 'ical'; // iCalendar - Currently unsupported - const PNUT = 'pnut'; // pnut.io - Currently unsupported - const ZOT = 'zot!'; // Zot! - Currently unsupported + // Currently unsupported + const ICALENDAR = 'ical'; // iCalendar + const MYSPACE = 'mysp'; // MySpace + const NEWS = 'nntp'; // Network News Transfer Protocol + const PNUT = 'pnut'; // pnut.io + const XMPP = 'xmpp'; // XMPP + const ZOT = 'zot!'; // Zot! const PHANTOM = 'unkn'; // Place holder From 92c4ca091193e571d76a9db7b2d4078e2b3dc473 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 30 Aug 2018 17:53:23 -0400 Subject: [PATCH 19/96] Prevent unfollowing contacts from networks not supported natively --- mod/unfollow.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/mod/unfollow.php b/mod/unfollow.php index f82796a6b7..30aca5688e 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -39,20 +39,18 @@ function unfollow_post() // NOTREACHED } - if ($contact['network'] == Protocol::STATUSNET) { + if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { notice(L10n::t('Unfollowing is currently not supported by your network.')); goaway($return_url); // NOTREACHED } - if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN])) { - $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid` - WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1", - intval($uid) - ); - if (DBA::isResult($r)) { - Contact::terminateFriendship($r[0], $contact); - } + $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid` + WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1", + intval($uid) + ); + if (DBA::isResult($r)) { + Contact::terminateFriendship($r[0], $contact); } // Sharing-only contacts get deleted as there no relationship any more @@ -92,7 +90,7 @@ function unfollow_content(App $a) // NOTREACHED } - if ($contact['network'] == Protocol::STATUSNET) { + if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { notice(L10n::t('Unfollowing is currently not supported by your network.')); goaway('contacts/' . $contact['id']); // NOTREACHED From e25c579c76b0721b06c477f82356cc2e824ce53a Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 30 Aug 2018 21:03:57 -0400 Subject: [PATCH 20/96] Add Protocol::NATIVE_SUPPORT constant usage to mod/contacts --- mod/contacts.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/mod/contacts.php b/mod/contacts.php index 38896a611a..227a48b965 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -595,17 +595,12 @@ function contacts_content(App $a, $update = 0) /// @todo Only show the following link with DFRN when the remote version supports it $follow = ''; $follow_text = ''; - if ($contact['network'] != Protocol::STATUSNET) { - if (in_array($contact['rel'], [Contact::FRIEND, Contact::SHARING])) { + if (in_array($contact['rel'], [Contact::FRIEND, Contact::SHARING])) { + if (in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { $follow = System::baseUrl(true) . "/unfollow?url=" . urlencode($contact["url"]); $follow_text = L10n::t("Disconnect/Unfollow"); - } else { - $follow = System::baseUrl(true) . "/follow?url=" . urlencode($contact["url"]); - $follow_text = L10n::t("Connect/Follow"); } - } - - if ($contact['uid'] == 0) { + } else { $follow = System::baseUrl(true) . "/follow?url=" . urlencode($contact["url"]); $follow_text = L10n::t("Connect/Follow"); } From 380eeaab88febb7f76e69bb6cdf4b44bf2618f13 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 31 Aug 2018 05:08:22 +0000 Subject: [PATCH 21/96] Still there had been notices - must have a good camouflage --- mod/contacts.php | 5 +++-- src/Module/Proxy.php | 4 ++++ src/Object/Image.php | 2 +- src/Protocol/DFRN.php | 5 ++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/mod/contacts.php b/mod/contacts.php index 4e87697172..cfe968226d 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -122,11 +122,12 @@ function contacts_init(App $a) function contacts_batch_actions(App $a) { - $contacts_id = $_POST['contact_batch']; - if (!is_array($contacts_id)) { + if (empty($_POST['contact_batch']) || !is_array($_POST['contact_batch'])) { return; } + $contacts_id = $_POST['contact_batch']; + $orig_records = q("SELECT * FROM `contact` WHERE `id` IN (%s) AND `uid` = %d AND `self` = 0", implode(",", $contacts_id), intval(local_user()) diff --git a/src/Module/Proxy.php b/src/Module/Proxy.php index ccd00c6040..7983e01f7a 100644 --- a/src/Module/Proxy.php +++ b/src/Module/Proxy.php @@ -133,6 +133,10 @@ class Proxy extends BaseModule $direct_cache = false; } + if (empty($_REQUEST['url'])) { + System::httpExit(400, ["title" => L10n::t('Bad Request.')]); + } + if (!$direct_cache) { $urlhash = 'pic:' . sha1($_REQUEST['url']); diff --git a/src/Object/Image.php b/src/Object/Image.php index 9506aedc22..620929df51 100644 --- a/src/Object/Image.php +++ b/src/Object/Image.php @@ -792,7 +792,7 @@ class Image try { if (function_exists("getimagesizefromstring")) { - $data = getimagesizefromstring($img_str); + $data = @getimagesizefromstring($img_str); } else { $tempfile = tempnam(get_temppath(), "cache"); diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 759f7f5f28..c435550313 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -2407,8 +2407,11 @@ class DFRN break; case "enclosure": $enclosure = $href; - if (strlen($item["attach"])) { + + if (!empty($item["attach"])) { $item["attach"] .= ","; + } else { + $item["attach"] = ""; } $item["attach"] .= '[attach]href="' . $href . '" length="' . $length . '" type="' . $type . '" title="' . $title . '"[/attach]'; From 38fd21019be46189ac7cccadca0159f6a34c56c0 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 31 Aug 2018 07:48:44 +0000 Subject: [PATCH 22/96] Invalid pictures could lead to notices, this is removed now --- include/items.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/items.php b/include/items.php index 2d7597dcd6..9fd557a778 100644 --- a/include/items.php +++ b/include/items.php @@ -72,7 +72,8 @@ function add_page_info_data(array $data, $no_photos = false) $text .= " title='".$data["title"]."'"; } - if (!empty($data["images"])) { + // Only embedd a picture link when it seems to be a valid picture ("width" is set) + if (!empty($data["images"]) && !empty($data["images"][0]["width"])) { $preview = str_replace(["[", "]"], ["[", "]"], htmlentities($data["images"][0]["src"], ENT_QUOTES, 'UTF-8', false)); // if the preview picture is larger than 500 pixels then show it in a larger mode // But only, if the picture isn't higher than large (To prevent huge posts) From 76b40cf05ec201811aedb22df0217bd027ebcbd1 Mon Sep 17 00:00:00 2001 From: Benjamin Lorteau Date: Fri, 31 Aug 2018 11:22:51 -0400 Subject: [PATCH 23/96] Use User::getOwnerDataById in mod/unfollow --- mod/unfollow.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mod/unfollow.php b/mod/unfollow.php index 30aca5688e..0af16ec671 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -10,6 +10,7 @@ use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Model\Profile; +use Friendica\Model\User; function unfollow_post() { @@ -45,12 +46,9 @@ function unfollow_post() // NOTREACHED } - $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid` - WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1", - intval($uid) - ); - if (DBA::isResult($r)) { - Contact::terminateFriendship($r[0], $contact); + $owner = User::getOwnerDataById($uid); + if ($owner) { + Contact::terminateFriendship($owner, $contact); } // Sharing-only contacts get deleted as there no relationship any more From 4fcae18289aecfd9bd4abd2df15381eaf64403ca Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 1 Sep 2018 03:23:12 +0000 Subject: [PATCH 24/96] Issue 5262: Comments to a forum post aren't distributed via push --- src/Worker/Notifier.php | 45 +++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 401178ec26..6d2733b8ee 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -217,24 +217,16 @@ class Notifier } // Special treatment for forum posts - if (($target_item['author-id'] != $target_item['owner-id']) && - ($owner['id'] != $target_item['contact-id']) && - ($target_item['uri'] === $target_item['parent-uri'])) { - - $fields = ['forum', 'prv']; - $condition = ['id' => $target_item['contact-id']]; - $contact = DBA::selectFirst('contact', $fields, $condition); - if (!DBA::isResult($contact)) { - // Should never happen - return false; - } - - // Is the post from a forum? - if ($contact['forum'] || $contact['prv']) { - $relay_to_owner = true; - $direct_forum_delivery = true; - } + if (self::isForumPost($target_item, $owner)) { + $relay_to_owner = true; + $direct_forum_delivery = true; } + + // Avoid that comments in a forum thread are sent to OStatus + if (self::isForumPost($parent, $owner)) { + $direct_forum_delivery = true; + } + if ($relay_to_owner) { // local followup to remote post $followup = true; @@ -504,4 +496,23 @@ class Notifier return; } + + private static function isForumPost($item, $owner) { + if (($item['author-id'] == $item['owner-id']) || + ($owner['id'] == $item['contact-id']) || + ($item['uri'] != $item['parent-uri'])) { + return false; + } + + $fields = ['forum', 'prv']; + $condition = ['id' => $item['contact-id']]; + $contact = DBA::selectFirst('contact', $fields, $condition); + if (!DBA::isResult($contact)) { + // Should never happen + return false; + } + + // Is the post from a forum? + return ($contact['forum'] || $contact['prv']); + } } From 4bb45f611f1a43294859dae1c81bf0aff923cf20 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 2 Sep 2018 07:20:04 +0000 Subject: [PATCH 25/96] Fix for timeout issues when posting to the API --- include/api.php | 38 +++++++++++++++++++++----------------- mod/item.php | 10 +++++++--- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/include/api.php b/include/api.php index f40674b894..18027c2434 100644 --- a/include/api.php +++ b/include/api.php @@ -1056,10 +1056,10 @@ function api_statuses_mediap($type) // now that we have the img url in bbcode we can add it to the status and insert the wall item. $_REQUEST['body'] = $txt . "\n\n" . '[url=' . $picture["albumpage"] . '][img]' . $picture["preview"] . "[/img][/url]"; - item_post($a); + $item_id = item_post($a); - // this should output the last post (the one we just posted). - return api_status_show($type); + // output the post that we just posted. + return api_status_show($type, $item_id); } /// @TODO move this to top of file or somewhere better! @@ -1075,7 +1075,6 @@ api_register_func('api/statuses/mediap', 'api_statuses_mediap', true, API_METHOD */ function api_statuses_update($type) { - $a = get_app(); if (api_user() === false) { @@ -1129,7 +1128,7 @@ function api_statuses_update($type) if ($throttle_day > 0) { $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60); - $condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom]; + $condition = ["`uid` = ? AND `wall` AND `changed` > ? AND `gravity` = ?", api_user(), $datefrom, GRAVITY_PARENT]; $posts_day = DBA::count('item', $condition); if ($posts_day > $throttle_day) { @@ -1143,7 +1142,7 @@ function api_statuses_update($type) if ($throttle_week > 0) { $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7); - $condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom]; + $condition = ["`uid` = ? AND `wall` AND `changed` > ? AND `gravity` = ?", api_user(), $datefrom, GRAVITY_PARENT]; $posts_week = DBA::count('item', $condition); if ($posts_week > $throttle_week) { @@ -1157,7 +1156,7 @@ function api_statuses_update($type) if ($throttle_month > 0) { $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30); - $condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom]; + $condition = ["`uid` = ? AND `wall` AND `changed` > ? AND `gravity` = ?", api_user(), $datefrom, GRAVITY_PARENT]; $posts_month = DBA::count('item', $condition); if ($posts_month > $throttle_month) { @@ -1200,10 +1199,10 @@ function api_statuses_update($type) } // call out normal post function - item_post($a); + $item_id = item_post($a); - // this should output the last post (the one we just posted). - return api_status_show($type); + // output the post that we just posted. + return api_status_show($type, $item_id); } /// @TODO move to top of file or somewhere better @@ -1260,7 +1259,7 @@ api_register_func('api/media/upload', 'api_media_upload', true, API_METHOD_POST) * * @return array|string */ -function api_status_show($type) +function api_status_show($type, $item_id = 0) { $a = get_app(); @@ -1274,9 +1273,14 @@ function api_status_show($type) $privacy_sql = ""; } - // get last public wall message - $condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(), - 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]]; + if (!empty($item_id)) { + // Get the item with the given id + $condition = ['id' => $item_id]; + } else { + // get last public wall message + $condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(), + 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]]; + } $lastwall = Item::selectFirst(Item::ITEM_FIELDLIST, $condition, ['order' => ['id' => true]]); if (DBA::isResult($lastwall)) { @@ -1993,14 +1997,14 @@ function api_statuses_repeat($type) $_REQUEST["source"] = api_source(); } - item_post($a); + $item_id = item_post($a); } else { throw new ForbiddenException(); } - // this should output the last post (the one we just posted). + // output the last post tha we just posted. $called_api = []; - return api_status_show($type); + return api_status_show($type, $item_id); } /// @TODO move to top of file or somewhere better diff --git a/mod/item.php b/mod/item.php index 733c6aee85..213a990789 100644 --- a/mod/item.php +++ b/mod/item.php @@ -39,7 +39,7 @@ require_once 'include/items.php'; function item_post(App $a) { if (!local_user() && !remote_user()) { - return; + return 0; } require_once 'include/security.php'; @@ -154,7 +154,7 @@ function item_post(App $a) { if (($message_id != '') && ($profile_uid != 0)) { if (Item::exists(['uri' => $message_id, 'uid' => $profile_uid])) { logger("Message with URI ".$message_id." already exists for user ".$profile_uid, LOGGER_DEBUG); - return; + return 0; } } @@ -183,7 +183,7 @@ function item_post(App $a) { $user = DBA::selectFirst('user', [], ['uid' => $profile_uid]); if (!DBA::isResult($user) && !$parent) { - return; + return 0; } $categories = ''; @@ -843,6 +843,10 @@ function item_post(App $a) { logger('post_complete'); + if ($api_source) { + return $post_id; + } + item_post_return(System::baseUrl(), $api_source, $return_path); // NOTREACHED } From 394526db747eb7419e07ae2ba8d8d63f44788ebb Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 2 Sep 2018 07:35:12 +0000 Subject: [PATCH 26/96] Typo corrected / use the thread table instead --- include/api.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/api.php b/include/api.php index 18027c2434..c8cb57f54d 100644 --- a/include/api.php +++ b/include/api.php @@ -1128,8 +1128,8 @@ function api_statuses_update($type) if ($throttle_day > 0) { $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60); - $condition = ["`uid` = ? AND `wall` AND `changed` > ? AND `gravity` = ?", api_user(), $datefrom, GRAVITY_PARENT]; - $posts_day = DBA::count('item', $condition); + $condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom]; + $posts_day = DBA::count('thread', $condition); if ($posts_day > $throttle_day) { logger('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG); @@ -1142,8 +1142,8 @@ function api_statuses_update($type) if ($throttle_week > 0) { $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7); - $condition = ["`uid` = ? AND `wall` AND `changed` > ? AND `gravity` = ?", api_user(), $datefrom, GRAVITY_PARENT]; - $posts_week = DBA::count('item', $condition); + $condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom]; + $posts_week = DBA::count('thread', $condition); if ($posts_week > $throttle_week) { logger('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG); @@ -1156,8 +1156,8 @@ function api_statuses_update($type) if ($throttle_month > 0) { $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30); - $condition = ["`uid` = ? AND `wall` AND `changed` > ? AND `gravity` = ?", api_user(), $datefrom, GRAVITY_PARENT]; - $posts_month = DBA::count('item', $condition); + $condition = ["`uid` = ? AND `wall` AND `created` > ?", api_user(), $datefrom]; + $posts_month = DBA::count('thread', $condition); if ($posts_month > $throttle_month) { logger('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG); @@ -2002,7 +2002,7 @@ function api_statuses_repeat($type) throw new ForbiddenException(); } - // output the last post tha we just posted. + // output the post that we just posted. $called_api = []; return api_status_show($type, $item_id); } From fd7e45042a66ce9c2d1465044014033efe04dbae Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 2 Sep 2018 07:47:48 +0000 Subject: [PATCH 27/96] The days are getting shorter, like the list of removed notices ... --- src/Util/Emailer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util/Emailer.php b/src/Util/Emailer.php index 4fa5e29057..1dd513c42f 100644 --- a/src/Util/Emailer.php +++ b/src/Util/Emailer.php @@ -49,7 +49,7 @@ class Emailer .rand(10000, 99999); // generate a multipart/alternative message header - $messageHeader = $params['additionalMailHeader'] . + $messageHeader = defaults($params, 'additionalMailHeader', '') . "From: $fromName <{$params['fromEmail']}>\n" . "Reply-To: $fromName <{$params['replyTo']}>\n" . "MIME-Version: 1.0\n" . From 703c668a37781f0d976c7e8c4de893b48c6da78d Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 2 Sep 2018 08:01:13 +0000 Subject: [PATCH 28/96] More notices ... --- include/api.php | 7 +++++-- mod/notifications.php | 3 +-- mod/ping.php | 2 +- src/Model/Profile.php | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/api.php b/include/api.php index f40674b894..3bae11e57d 100644 --- a/include/api.php +++ b/include/api.php @@ -581,7 +581,10 @@ function api_get_user(App $a, $contact_id = null) if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) { $argid = count($called_api); if (!empty($a->argv[$argid])) { - list($user, $null) = explode(".", $a->argv[$argid]); + $data = explode(".", $a->argv[$argid]); + if (count($data) > 1) { + list($user, $null) = $data; + } } if (is_numeric($user)) { $user = DBA::escape(api_unique_id_to_nurl(intval($user))); @@ -4396,7 +4399,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $ if ($filetype == "") { $filetype=Image::guessType($filename); } - $imagedata = getimagesize($src); + $imagedata = @getimagesize($src); if ($imagedata) { $filetype = $imagedata['mime']; } diff --git a/mod/notifications.php b/mod/notifications.php index 145c384350..bc581b6dd3 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -115,7 +115,6 @@ function notifications_content(App $a) } elseif (($a->argc > 1) && ($a->argv[1] == 'home')) { $notif_header = L10n::t('Home Notifications'); $notifs = $nm->homeNotifs($show, $startrec, $perpage); - } @@ -134,7 +133,7 @@ function notifications_content(App $a) $notif_tpl = get_markup_template('notifications.tpl'); if (!isset($notifs['ident'])) { - logger('Missing data in notifs: ' . System::callstack(20), LOGGER_DEBUG); + logger('Missing data in notifs: ' . json_encode($a->argv), LOGGER_DEBUG); } // Process the data for template creation diff --git a/mod/ping.php b/mod/ping.php index 99ebde70c1..9867f03f9a 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -519,7 +519,7 @@ function ping_get_notifications($uid) * @param int $forums_unseen Number of unseen forum items * @return array XML-transform ready data array */ -function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen) +function ping_format_xml_data($data, $sysnotify_count, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen) { $notifications = []; foreach ($notifs as $key => $notif) { diff --git a/src/Model/Profile.php b/src/Model/Profile.php index f6e116fa79..29bc7e680d 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -492,7 +492,7 @@ class Profile if (isset($p['address'])) { $p['address'] = BBCode::convert($p['address']); - } else { + } elseif (isset($p['location'])) { $p['address'] = BBCode::convert($p['location']); } From 58148905f14398895b7a1960beb67a98ec137561 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 2 Sep 2018 17:48:07 +0000 Subject: [PATCH 29/96] Changed documention --- mod/ping.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mod/ping.php b/mod/ping.php index 9867f03f9a..968751a7da 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -510,13 +510,14 @@ function ping_get_notifications($uid) * @brief Backward-compatible XML formatting for ping.php output * @deprecated * - * @param array $data The initial ping data array - * @param int $sysnotify Number of unseen system notifications - * @param array $notifs Complete list of notification - * @param array $sysmsgs List of system notice messages - * @param array $sysmsgs_info List of system info messages - * @param int $groups_unseen Number of unseen group items - * @param int $forums_unseen Number of unseen forum items + * @param array $data The initial ping data array + * @param int $sysnotify_count Number of unseen system notifications + * @param array $notifs Complete list of notification + * @param array $sysmsgs List of system notice messages + * @param array $sysmsgs_info List of system info messages + * @param int $groups_unseen Number of unseen group items + * @param int $forums_unseen Number of unseen forum items + * * @return array XML-transform ready data array */ function ping_format_xml_data($data, $sysnotify_count, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen) From 5250552fe28cd4a5d2b148ca7a431233191e92c9 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 2 Sep 2018 17:48:25 +0000 Subject: [PATCH 30/96] Removed obsolete post update that sometimes never finishes --- src/Database/PostUpdate.php | 85 ------------------------------------- 1 file changed, 85 deletions(-) diff --git a/src/Database/PostUpdate.php b/src/Database/PostUpdate.php index 674fe05531..dbadcbbb1b 100644 --- a/src/Database/PostUpdate.php +++ b/src/Database/PostUpdate.php @@ -27,9 +27,6 @@ class PostUpdate if (!self::update1194()) { return false; } - if (!self::update1198()) { - return false; - } if (!self::update1206()) { return false; } @@ -111,88 +108,6 @@ class PostUpdate logger("Done", LOGGER_DEBUG); } - /** - * @brief set the author-id and owner-id in all item entries - * - * This job has to be started multiple times until all entries are set. - * It isn't started in the update function since it would consume too much time and can be done in the background. - * - * @return bool "true" when the job is done - */ - private static function update1198() - { - // Was the script completed? - if (Config::get("system", "post_update_version") >= 1198) { - return true; - } - - logger("Start", LOGGER_DEBUG); - - // Check if the first step is done (Setting "author-id" and "owner-id" in the item table) - $fields = ['author-link', 'author-name', 'author-avatar', 'owner-link', 'owner-name', 'owner-avatar', 'network', 'uid']; - $r = DBA::select('item', $fields, ['author-id' => 0, 'owner-id' => 0], ['limit' => 1000]); - if (!$r) { - // Are there unfinished entries in the thread table? - $r = q("SELECT COUNT(*) AS `total` FROM `thread` - INNER JOIN `item` ON `item`.`id` =`thread`.`iid` - WHERE `thread`.`author-id` = 0 AND `thread`.`owner-id` = 0 AND - (`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)"); - - if ($r && ($r[0]["total"] == 0)) { - Config::set("system", "post_update_version", 1198); - logger("Done", LOGGER_DEBUG); - return true; - } - - // Update the thread table from the item table - $r = q("UPDATE `thread` INNER JOIN `item` ON `item`.`id`=`thread`.`iid` - SET `thread`.`author-id` = `item`.`author-id`, - `thread`.`owner-id` = `item`.`owner-id` - WHERE `thread`.`author-id` = 0 AND `thread`.`owner-id` = 0 AND - (`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)"); - - logger("Updated threads", LOGGER_DEBUG); - if (DBA::isResult($r)) { - Config::set("system", "post_update_version", 1198); - logger("Done", LOGGER_DEBUG); - return true; - } - return false; - } - - logger("Query done", LOGGER_DEBUG); - - $item_arr = []; - foreach ($r as $item) { - $index = $item["author-link"]."-".$item["owner-link"]."-".$item["uid"]; - $item_arr[$index] = ["author-link" => $item["author-link"], - "owner-link" => $item["owner-link"], - "uid" => $item["uid"]]; - } - - // Set the "author-id" and "owner-id" in the item table and add a new public contact entry if needed - foreach ($item_arr as $item) { - $default = ['url' => $item['author-link'], 'name' => $item['author-name'], - 'photo' => $item['author-avatar'], 'network' => $item['network']]; - $author_id = Contact::getIdForURL($item["author-link"], 0, false, $default); - - $default = ['url' => $item['owner-link'], 'name' => $item['owner-name'], - 'photo' => $item['owner-avatar'], 'network' => $item['network']]; - $owner_id = Contact::getIdForURL($item["owner-link"], 0, false, $default); - - if ($author_id == 0) { - $author_id = -1; - } - if ($owner_id == 0) { - $owner_id = -1; - } - DBA::update('item', ['author-id' => $author_id, 'owner-id' => $owner_id], ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'owner-link' => $item['owner-link'], 'author-id' => 0, 'owner-id' => 0]); - } - - logger("Updated items", LOGGER_DEBUG); - return false; - } - /** * @brief update the "last-item" field in the "self" contact * From 475d3f8f3a71afb94315bbc3264a950a61b26b52 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 2 Sep 2018 17:24:56 -0400 Subject: [PATCH 31/96] Fix formatting in mod/parse_url --- mod/parse_url.php | 102 +++++++++++++++++++++++----------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/mod/parse_url.php b/mod/parse_url.php index 3309a74b9f..ebe34875b7 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -8,128 +8,127 @@ * information and does format this information to BBCode * * @see ParseUrl::getSiteinfo() for more information about scraping embeddable content -*/ - + */ use Friendica\App; use Friendica\Core\Addon; use Friendica\Util\Network; use Friendica\Util\ParseUrl; -require_once("include/items.php"); - -function parse_url_content(App $a) { +require_once 'include/items.php'; +function parse_url_content(App $a) +{ $text = null; - $str_tags = ""; + $str_tags = ''; $br = "\n"; - if (!empty($_GET["binurl"])) { - $url = trim(hex2bin($_GET["binurl"])); + if (!empty($_GET['binurl'])) { + $url = trim(hex2bin($_GET['binurl'])); } else { - $url = trim($_GET["url"]); + $url = trim($_GET['url']); } - if (!empty($_GET["title"])) { - $title = strip_tags(trim($_GET["title"])); + if (!empty($_GET['title'])) { + $title = strip_tags(trim($_GET['title'])); } - if (!empty($_GET["description"])) { - $text = strip_tags(trim($_GET["description"])); + if (!empty($_GET['description'])) { + $text = strip_tags(trim($_GET['description'])); } - if (!empty($_GET["tags"])) { - $arr_tags = ParseUrl::convertTagsToArray($_GET["tags"]); + if (!empty($_GET['tags'])) { + $arr_tags = ParseUrl::convertTagsToArray($_GET['tags']); if (count($arr_tags)) { - $str_tags = $br . implode(" ", $arr_tags) . $br; + $str_tags = $br . implode(' ', $arr_tags) . $br; } } // Add url scheme if it is missing $arrurl = parse_url($url); - if (!x($arrurl, "scheme")) { - if (x($arrurl, "host")) { - $url = "http:".$url; + if (!x($arrurl, 'scheme')) { + if (x($arrurl, 'host')) { + $url = 'http:' . $url; } else { - $url = "http://".$url; + $url = 'http://' . $url; } } - logger("prse_url: " . $url); + logger($url); // Check if the URL is an image, video or audio file. If so format // the URL with the corresponding BBCode media tag $redirects = 0; // Fetch the header of the URL - $result = Network::curl($url, false, $redirects, ["novalidate" => true, "nobody" => true]); - if($result["success"]) { + $result = Network::curl($url, false, $redirects, ['novalidate' => true, 'nobody' => true]); + + if ($result['success']) { // Convert the header fields into an array $hdrs = []; - $h = explode("\n", $result["header"]); + $h = explode("\n", $result['header']); foreach ($h as $l) { - $header = array_map("trim", explode(":", trim($l), 2)); + $header = array_map('trim', explode(':', trim($l), 2)); if (count($header) == 2) { - list($k,$v) = $header; + list($k, $v) = $header; $hdrs[$k] = $v; } } - if (array_key_exists("Content-Type", $hdrs)) { - $type = $hdrs["Content-Type"]; + if (array_key_exists('Content-Type', $hdrs)) { + $type = $hdrs['Content-Type']; } if ($type) { - if(stripos($type, "image/") !== false) { - echo $br . "[img]" . $url . "[/img]" . $br; - killme(); + if (stripos($type, 'image/') !== false) { + echo $br . '[img]' . $url . '[/img]' . $br; + exit(); } - if (stripos($type, "video/") !== false) { - echo $br . "[video]" . $url . "[/video]" . $br; - killme(); + if (stripos($type, 'video/') !== false) { + echo $br . '[video]' . $url . '[/video]' . $br; + exit(); } - if (stripos($type, "audio/") !== false) { - echo $br . "[audio]" . $url . "[/audio]" . $br; - killme(); + if (stripos($type, 'audio/') !== false) { + echo $br . '[audio]' . $url . '[/audio]' . $br; + exit(); } } } - $template = "[bookmark=%s]%s[/bookmark]%s"; + $template = '[bookmark=%s]%s[/bookmark]%s'; - $arr = ["url" => $url, "text" => ""]; + $arr = ['url' => $url, 'text' => '']; - Addon::callHooks("parse_link", $arr); + Addon::callHooks('parse_link', $arr); - if (strlen($arr["text"])) { - echo $arr["text"]; - killme(); + if (strlen($arr['text'])) { + echo $arr['text']; + exit(); } // If there is already some content information submitted we don't // need to parse the url for content. if (!empty($url) && !empty($title) && !empty($text)) { + $title = str_replace(["\r", "\n"], ['', ''], $title); - $title = str_replace(["\r","\n"],["",""],$title); - - $text = "[quote]" . trim($text) . "[/quote]" . $br; + $text = '[quote]' . trim($text) . '[/quote]' . $br; $result = sprintf($template, $url, ($title) ? $title : $url, $text) . $str_tags; - logger("parse_url (unparsed): returns: " . $result); + logger('(unparsed): returns: ' . $result); echo $result; - killme(); + exit(); } // Fetch the information directly from the webpage $siteinfo = ParseUrl::getSiteinfo($url); - unset($siteinfo["keywords"]); + unset($siteinfo['keywords']); // Format it as BBCode attachment $info = add_page_info_data($siteinfo); echo $info; - killme(); + exit(); } /** @@ -151,7 +150,8 @@ function parse_url_content(App $a) { * @todo Remove this function after all Addons has been changed to use * ParseUrl::getSiteinfoCached */ -function parseurl_getsiteinfo_cached($url, $no_guessing = false, $do_oembed = true) { +function parseurl_getsiteinfo_cached($url, $no_guessing = false, $do_oembed = true) +{ $siteinfo = ParseUrl::getSiteinfoCached($url, $no_guessing, $do_oembed); return $siteinfo; } From 69e7c7fecac5d315930c52bfa9fb21954dcf8b5e Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 2 Sep 2018 17:26:05 -0400 Subject: [PATCH 32/96] Fix photo attachment display - Remove double image display - Add domain link display to all attachments --- src/Content/Text/BBCode.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 41f89e65dc..55fc24273d 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -578,9 +578,7 @@ class BBCode extends BaseObject $return .= sprintf('
', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]); } - if (($data["type"] == "photo") && !empty($data["url"]) && !empty($data["image"])) { - $return .= sprintf('', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]); - } else { + if (!empty($data['title']) && !empty($data['url'])) { $return .= sprintf('

%s

', $data['url'], $data['title']); } @@ -589,7 +587,8 @@ class BBCode extends BaseObject $bbcode = HTML::toBBCode($data["description"]); $return .= sprintf('
%s
', trim(self::convert($bbcode))); } - if ($data["type"] == "link") { + + if (!empty($data['url'])) { $return .= sprintf('%s', $data['url'], parse_url($data['url'], PHP_URL_HOST)); } From 8bcc3c68602cb7df05ccf8241dff5d53cfa71afb Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 2 Sep 2018 17:35:55 -0400 Subject: [PATCH 33/96] Fix formatting in Util/ParseUrl - Remove commented out code - Replace double quotes with simple quotes - Remove parentheses for language construct - Add spaces around operators - Rename variables --- src/Util/ParseUrl.php | 265 +++++++++++++++++++++--------------------- 1 file changed, 132 insertions(+), 133 deletions(-) diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 3be372767b..b897c54ee7 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -118,13 +118,13 @@ class ParseUrl // Check if the URL does contain a scheme $scheme = parse_url($url, PHP_URL_SCHEME); - if ($scheme == "") { - $url = "http://".trim($url, "/"); + if ($scheme == '') { + $url = 'http://' . trim($url, '/'); } if ($count > 10) { - logger("parseurl_getsiteinfo: Endless loop detected for ".$url, LOGGER_DEBUG); - return($siteinfo); + logger('Endless loop detected for ' . $url, LOGGER_DEBUG); + return $siteinfo; } $url = trim($url, "'"); @@ -132,220 +132,217 @@ class ParseUrl $url = Network::stripTrackingQueryParams($url); - $siteinfo["url"] = $url; - $siteinfo["type"] = "link"; + $siteinfo['url'] = $url; + $siteinfo['type'] = 'link'; $data = Network::curl($url); if (!$data['success']) { - return($siteinfo); + return $siteinfo; } // If the file is too large then exit - if ($data["info"]["download_content_length"] > 1000000) { - return($siteinfo); + if ($data['info']['download_content_length'] > 1000000) { + return $siteinfo; } // If it isn't a HTML file then exit - if (($data["info"]["content_type"] != "") && !strstr(strtolower($data["info"]["content_type"]), "html")) { - return($siteinfo); + if (($data['info']['content_type'] != '') && !strstr(strtolower($data['info']['content_type']), 'html')) { + return $siteinfo; } - $header = $data["header"]; - $body = $data["body"]; + $header = $data['header']; + $body = $data['body']; if ($do_oembed) { $oembed_data = OEmbed::fetchURL($url); if (!empty($oembed_data->type)) { - if (!in_array($oembed_data->type, ["error", "rich", ""])) { - $siteinfo["type"] = $oembed_data->type; + if (!in_array($oembed_data->type, ['error', 'rich', ''])) { + $siteinfo['type'] = $oembed_data->type; } - if (($oembed_data->type == "link") && ($siteinfo["type"] != "photo")) { + if (($oembed_data->type == 'link') && ($siteinfo['type'] != 'photo')) { if (isset($oembed_data->title)) { - $siteinfo["title"] = trim($oembed_data->title); + $siteinfo['title'] = trim($oembed_data->title); } if (isset($oembed_data->description)) { - $siteinfo["text"] = trim($oembed_data->description); + $siteinfo['text'] = trim($oembed_data->description); } if (isset($oembed_data->thumbnail_url)) { - $siteinfo["image"] = $oembed_data->thumbnail_url; + $siteinfo['image'] = $oembed_data->thumbnail_url; } } } } // Fetch the first mentioned charset. Can be in body or header - $charset = ""; - if (preg_match('/charset=(.*?)['."'".'"\s\n]/', $header, $matches)) { + $charset = ''; + if (preg_match('/charset=(.*?)[\'"\s\n]/', $header, $matches)) { $charset = trim(trim(trim(array_pop($matches)), ';,')); } - if ($charset == "") { - $charset = "utf-8"; + if ($charset == '') { + $charset = 'utf-8'; } - if (($charset != "") && (strtoupper($charset) != "UTF-8")) { - logger("parseurl_getsiteinfo: detected charset ".$charset, LOGGER_DEBUG); - //$body = mb_convert_encoding($body, "UTF-8", $charset); - $body = iconv($charset, "UTF-8//TRANSLIT", $body); + if (($charset != '') && (strtoupper($charset) != 'UTF-8')) { + logger('detected charset ' . $charset, LOGGER_DEBUG); + $body = iconv($charset, 'UTF-8//TRANSLIT', $body); } - $body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8"); + $body = mb_convert_encoding($body, 'HTML-ENTITIES', 'UTF-8'); $doc = new DOMDocument(); @$doc->loadHTML($body); - XML::deleteNode($doc, "style"); - XML::deleteNode($doc, "script"); - XML::deleteNode($doc, "option"); - XML::deleteNode($doc, "h1"); - XML::deleteNode($doc, "h2"); - XML::deleteNode($doc, "h3"); - XML::deleteNode($doc, "h4"); - XML::deleteNode($doc, "h5"); - XML::deleteNode($doc, "h6"); - XML::deleteNode($doc, "ol"); - XML::deleteNode($doc, "ul"); + XML::deleteNode($doc, 'style'); + XML::deleteNode($doc, 'script'); + XML::deleteNode($doc, 'option'); + XML::deleteNode($doc, 'h1'); + XML::deleteNode($doc, 'h2'); + XML::deleteNode($doc, 'h3'); + XML::deleteNode($doc, 'h4'); + XML::deleteNode($doc, 'h5'); + XML::deleteNode($doc, 'h6'); + XML::deleteNode($doc, 'ol'); + XML::deleteNode($doc, 'ul'); $xpath = new DOMXPath($doc); - $list = $xpath->query("//meta[@content]"); + $list = $xpath->query('//meta[@content]'); foreach ($list as $node) { - $attr = []; + $meta_tag = []; if ($node->attributes->length) { foreach ($node->attributes as $attribute) { - $attr[$attribute->name] = $attribute->value; + $meta_tag[$attribute->name] = $attribute->value; } } - if (@$attr["http-equiv"] == "refresh") { - $path = $attr["content"]; - $pathinfo = explode(";", $path); - $content = ""; + if (@$meta_tag['http-equiv'] == 'refresh') { + $path = $meta_tag['content']; + $pathinfo = explode(';', $path); + $content = ''; foreach ($pathinfo as $value) { - if (substr(strtolower($value), 0, 4) == "url=") { + if (substr(strtolower($value), 0, 4) == 'url=') { $content = substr($value, 4); } } - if ($content != "") { + if ($content != '') { $siteinfo = self::getSiteinfo($content, $no_guessing, $do_oembed, ++$count); - return($siteinfo); + return $siteinfo; } } } - $list = $xpath->query("//title"); + $list = $xpath->query('//title'); if ($list->length > 0) { - $siteinfo["title"] = trim($list->item(0)->nodeValue); + $siteinfo['title'] = trim($list->item(0)->nodeValue); } - //$list = $xpath->query("head/meta[@name]"); - $list = $xpath->query("//meta[@name]"); + $list = $xpath->query('//meta[@name]'); foreach ($list as $node) { - $attr = []; + $meta_tag = []; if ($node->attributes->length) { foreach ($node->attributes as $attribute) { - $attr[$attribute->name] = $attribute->value; + $meta_tag[$attribute->name] = $attribute->value; } } - if (!empty($attr["content"])) { - $attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8")); + if (!empty($meta_tag['content'])) { + $meta_tag['content'] = trim(html_entity_decode($meta_tag['content'], ENT_QUOTES, 'UTF-8')); - switch (strtolower($attr["name"])) { - case "fulltitle": - $siteinfo["title"] = trim($attr["content"]); + switch (strtolower($meta_tag['name'])) { + case 'fulltitle': + $siteinfo['title'] = trim($meta_tag['content']); break; - case "description": - $siteinfo["text"] = trim($attr["content"]); + case 'description': + $siteinfo['text'] = trim($meta_tag['content']); break; - case "thumbnail": - $siteinfo["image"] = $attr["content"]; + case 'thumbnail': + $siteinfo['image'] = $meta_tag['content']; break; - case "twitter:image": - $siteinfo["image"] = $attr["content"]; + case 'twitter:image': + $siteinfo['image'] = $meta_tag['content']; break; - case "twitter:image:src": - $siteinfo["image"] = $attr["content"]; + case 'twitter:image:src': + $siteinfo['image'] = $meta_tag['content']; break; - case "twitter:card": - if (($siteinfo["type"] == "") || ($attr["content"] == "photo")) { - $siteinfo["type"] = $attr["content"]; + case 'twitter:card': + if (($siteinfo['type'] == '') || ($meta_tag['content'] == 'photo')) { + $siteinfo['type'] = $meta_tag['content']; } break; - case "twitter:description": - $siteinfo["text"] = trim($attr["content"]); + case 'twitter:description': + $siteinfo['text'] = trim($meta_tag['content']); break; - case "twitter:title": - $siteinfo["title"] = trim($attr["content"]); + case 'twitter:title': + $siteinfo['title'] = trim($meta_tag['content']); break; - case "dc.title": - $siteinfo["title"] = trim($attr["content"]); + case 'dc.title': + $siteinfo['title'] = trim($meta_tag['content']); break; - case "dc.description": - $siteinfo["text"] = trim($attr["content"]); + case 'dc.description': + $siteinfo['text'] = trim($meta_tag['content']); break; - case "keywords": - $keywords = explode(",", $attr["content"]); + case 'keywords': + $keywords = explode(',', $meta_tag['content']); break; - case "news_keywords": - $keywords = explode(",", $attr["content"]); + case 'news_keywords': + $keywords = explode(',', $meta_tag['content']); break; } } - if ($siteinfo["type"] == "summary") { - $siteinfo["type"] = "link"; + if ($siteinfo['type'] == 'summary') { + $siteinfo['type'] = 'link'; } } if (isset($keywords)) { - $siteinfo["keywords"] = []; + $siteinfo['keywords'] = []; foreach ($keywords as $keyword) { - if (!in_array(trim($keyword), $siteinfo["keywords"])) { - $siteinfo["keywords"][] = trim($keyword); + if (!in_array(trim($keyword), $siteinfo['keywords'])) { + $siteinfo['keywords'][] = trim($keyword); } } } - //$list = $xpath->query("head/meta[@property]"); - $list = $xpath->query("//meta[@property]"); + $list = $xpath->query('//meta[@property]'); foreach ($list as $node) { - $attr = []; + $meta_tag = []; if ($node->attributes->length) { foreach ($node->attributes as $attribute) { - $attr[$attribute->name] = $attribute->value; + $meta_tag[$attribute->name] = $attribute->value; } } - if (!empty($attr["content"])) { - $attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8")); + if (!empty($meta_tag['content'])) { + $meta_tag['content'] = trim(html_entity_decode($meta_tag['content'], ENT_QUOTES, 'UTF-8')); - switch (strtolower($attr["property"])) { - case "og:image": - $siteinfo["image"] = $attr["content"]; + switch (strtolower($meta_tag['property'])) { + case 'og:image': + $siteinfo['image'] = $meta_tag['content']; break; - case "og:title": - $siteinfo["title"] = trim($attr["content"]); + case 'og:title': + $siteinfo['title'] = trim($meta_tag['content']); break; - case "og:description": - $siteinfo["text"] = trim($attr["content"]); + case 'og:description': + $siteinfo['text'] = trim($meta_tag['content']); break; } } } - if ((@$siteinfo["image"] == "") && !$no_guessing) { - $list = $xpath->query("//img[@src]"); + if ((@$siteinfo['image'] == '') && !$no_guessing) { + $list = $xpath->query('//img[@src]'); foreach ($list as $node) { - $attr = []; + $img_tag = []; if ($node->attributes->length) { foreach ($node->attributes as $attribute) { - $attr[$attribute->name] = $attribute->value; + $img_tag[$attribute->name] = $attribute->value; } } - $src = self::completeUrl($attr["src"], $url); + $src = self::completeUrl($img_tag['src'], $url); $photodata = Image::getInfoFromURL($src); if (($photodata) && ($photodata[0] > 150) && ($photodata[1] > 150)) { @@ -357,70 +354,72 @@ class ParseUrl $photodata[0] = round($photodata[0] * (300 / $photodata[1])); $photodata[1] = 300; } - $siteinfo["images"][] = ["src" => $src, - "width" => $photodata[0], - "height" => $photodata[1]]; + $siteinfo['images'][] = [ + 'src' => $src, + 'width' => $photodata[0], + 'height' => $photodata[1] + ]; } } - } elseif (!empty($siteinfo["image"])) { - $src = self::completeUrl($siteinfo["image"], $url); + } elseif (!empty($siteinfo['image'])) { + $src = self::completeUrl($siteinfo['image'], $url); - unset($siteinfo["image"]); + unset($siteinfo['image']); $photodata = Image::getInfoFromURL($src); if (($photodata) && ($photodata[0] > 10) && ($photodata[1] > 10)) { - $siteinfo["images"][] = ["src" => $src, - "width" => $photodata[0], - "height" => $photodata[1]]; + $siteinfo['images'][] = ['src' => $src, + 'width' => $photodata[0], + 'height' => $photodata[1]]; } } - if ((@$siteinfo["text"] == "") && (@$siteinfo["title"] != "") && !$no_guessing) { - $text = ""; + if ((@$siteinfo['text'] == '') && (@$siteinfo['title'] != '') && !$no_guessing) { + $text = ''; - $list = $xpath->query("//div[@class='article']"); + $list = $xpath->query('//div[@class="article"]'); foreach ($list as $node) { if (strlen($node->nodeValue) > 40) { - $text .= " ".trim($node->nodeValue); + $text .= ' ' . trim($node->nodeValue); } } - if ($text == "") { - $list = $xpath->query("//div[@class='content']"); + if ($text == '') { + $list = $xpath->query('//div[@class="content"]'); foreach ($list as $node) { if (strlen($node->nodeValue) > 40) { - $text .= " ".trim($node->nodeValue); + $text .= ' ' . trim($node->nodeValue); } } } // If none text was found then take the paragraph content - if ($text == "") { - $list = $xpath->query("//p"); + if ($text == '') { + $list = $xpath->query('//p'); foreach ($list as $node) { if (strlen($node->nodeValue) > 40) { - $text .= " ".trim($node->nodeValue); + $text .= ' ' . trim($node->nodeValue); } } } - if ($text != "") { - $text = trim(str_replace(["\n", "\r"], [" ", " "], $text)); + if ($text != '') { + $text = trim(str_replace(["\n", "\r"], [' ', ' '], $text)); - while (strpos($text, " ")) { - $text = trim(str_replace(" ", " ", $text)); + while (strpos($text, ' ')) { + $text = trim(str_replace(' ', ' ', $text)); } - $siteinfo["text"] = trim(html_entity_decode(substr($text, 0, 350), ENT_QUOTES, "UTF-8").'...'); + $siteinfo['text'] = trim(html_entity_decode(substr($text, 0, 350), ENT_QUOTES, 'UTF-8') . '...'); } } - logger("parseurl_getsiteinfo: Siteinfo for ".$url." ".print_r($siteinfo, true), LOGGER_DEBUG); + logger('Siteinfo for ' . $url . ' ' . print_r($siteinfo, true), LOGGER_DEBUG); - Addon::callHooks("getsiteinfo", $siteinfo); + Addon::callHooks('getsiteinfo', $siteinfo); - return($siteinfo); + return $siteinfo; } /** From 9744f0e7809873bf3bed76b72bcef25e34ebcdd6 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 2 Sep 2018 17:50:27 -0400 Subject: [PATCH 34/96] Update ParseUrl::getSiteinfo type recognition - Added obsolete twitter card type provision --- src/Util/ParseUrl.php | 96 +++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index b897c54ee7..2c134542a0 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -248,55 +248,61 @@ class ParseUrl } } - if (!empty($meta_tag['content'])) { - $meta_tag['content'] = trim(html_entity_decode($meta_tag['content'], ENT_QUOTES, 'UTF-8')); + if (empty($meta_tag['content'])) { + continue; + } - switch (strtolower($meta_tag['name'])) { - case 'fulltitle': - $siteinfo['title'] = trim($meta_tag['content']); - break; - case 'description': - $siteinfo['text'] = trim($meta_tag['content']); - break; - case 'thumbnail': - $siteinfo['image'] = $meta_tag['content']; - break; - case 'twitter:image': - $siteinfo['image'] = $meta_tag['content']; - break; - case 'twitter:image:src': - $siteinfo['image'] = $meta_tag['content']; - break; - case 'twitter:card': - if (($siteinfo['type'] == '') || ($meta_tag['content'] == 'photo')) { - $siteinfo['type'] = $meta_tag['content']; - } - break; - case 'twitter:description': - $siteinfo['text'] = trim($meta_tag['content']); - break; - case 'twitter:title': - $siteinfo['title'] = trim($meta_tag['content']); - break; - case 'dc.title': - $siteinfo['title'] = trim($meta_tag['content']); - break; - case 'dc.description': - $siteinfo['text'] = trim($meta_tag['content']); - break; - case 'keywords': - $keywords = explode(',', $meta_tag['content']); - break; - case 'news_keywords': - $keywords = explode(',', $meta_tag['content']); - break; - } - } - if ($siteinfo['type'] == 'summary') { - $siteinfo['type'] = 'link'; + $meta_tag['content'] = trim(html_entity_decode($meta_tag['content'], ENT_QUOTES, 'UTF-8')); + + switch (strtolower($meta_tag['name'])) { + case 'fulltitle': + $siteinfo['title'] = trim($meta_tag['content']); + break; + case 'description': + $siteinfo['text'] = trim($meta_tag['content']); + break; + case 'thumbnail': + $siteinfo['image'] = $meta_tag['content']; + break; + case 'twitter:image': + $siteinfo['image'] = $meta_tag['content']; + break; + case 'twitter:image:src': + $siteinfo['image'] = $meta_tag['content']; + break; + case 'twitter:card': + // Obsolete card type + if ($meta_tag['content'] == 'photo') { + $siteinfo['type'] = 'summary_large_image'; + } else { + $siteinfo['type'] = $meta_tag['content']; + } + break; + case 'twitter:description': + $siteinfo['text'] = trim($meta_tag['content']); + break; + case 'twitter:title': + $siteinfo['title'] = trim($meta_tag['content']); + break; + case 'dc.title': + $siteinfo['title'] = trim($meta_tag['content']); + break; + case 'dc.description': + $siteinfo['text'] = trim($meta_tag['content']); + break; + case 'keywords': + $keywords = explode(',', $meta_tag['content']); + break; + case 'news_keywords': + $keywords = explode(',', $meta_tag['content']); + break; } } + if ($siteinfo['type'] == 'summary' || $siteinfo['type'] == 'summary_large_image') { + $siteinfo['type'] = 'link'; + } + if (isset($keywords)) { $siteinfo['keywords'] = []; foreach ($keywords as $keyword) { From 821429fdf13ca1bcd442b389d390287921b65e0b Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 4 Sep 2018 17:48:09 +0000 Subject: [PATCH 35/96] Good news, everyone - again somce notices removed --- mod/events.php | 18 ++++++++++-------- mod/notifications.php | 11 ++++------- mod/unfollow.php | 2 +- src/App.php | 6 +++++- src/Util/HTTPSignature.php | 2 ++ 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/mod/events.php b/mod/events.php index 91474022fc..21cf70d20f 100644 --- a/mod/events.php +++ b/mod/events.php @@ -54,11 +54,11 @@ function events_post(App $a) { $cid = (x($_POST, 'cid') ? intval($_POST['cid']) : 0); $uid = local_user(); - $start_text = escape_tags($_REQUEST['start_text']); - $finish_text = escape_tags($_REQUEST['finish_text']); + $start_text = escape_tags(defaults($_REQUEST, 'start_text', '')); + $finish_text = escape_tags(defaults($_REQUEST, 'finish_text', '')); - $adjust = intval($_POST['adjust']); - $nofinish = intval($_POST['nofinish']); + $adjust = intval(defaults($_POST, 'adjust', 0)); + $nofinish = intval(defaults($_POST, 'nofinish', 0)); // The default setting for the `private` field in event_store() is false, so mirror that $private_event = false; @@ -91,9 +91,9 @@ function events_post(App $a) { // and we'll waste a bunch of time responding to it. Time that // could've been spent doing something else. - $summary = escape_tags(trim($_POST['summary'])); - $desc = escape_tags(trim($_POST['desc'])); - $location = escape_tags(trim($_POST['location'])); + $summary = escape_tags(trim(defaults($_POST, 'summary', ''))); + $desc = escape_tags(trim(defaults($_POST, 'desc', ''))); + $location = escape_tags(trim(defaults($_POST, 'location', ''))); $type = 'event'; $action = ($event_id == '') ? 'new' : "event/" . $event_id; @@ -117,7 +117,7 @@ function events_post(App $a) { goaway($onerror_url); } - $share = (intval($_POST['share']) ? intval($_POST['share']) : 0); + $share = intval(defaults($_POST, 'share', 0)); $c = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval(local_user()) @@ -484,6 +484,8 @@ function events_content(App $a) { if ($mode === 'new' || $mode === 'copy') { $acl = ($cid ? '' : ACL::getFullSelectorHTML($a->user, false, $orig_event)); + } else { + $acl = ''; } // If we copy an old event, we need to remove the ID and URI diff --git a/mod/notifications.php b/mod/notifications.php index bc581b6dd3..091323d998 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -87,10 +87,11 @@ function notifications_content(App $a) $perpage = 20; $startrec = ($page * $perpage) - $perpage; + $notif_header = L10n::t('Notifications'); + // Get introductions if ((($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) { Nav::setSelected('introductions'); - $notif_header = L10n::t('Notifications'); $all = (($a->argc > 2) && ($a->argv[2] == 'all')); @@ -132,12 +133,8 @@ function notifications_content(App $a) $notif_tpl = get_markup_template('notifications.tpl'); - if (!isset($notifs['ident'])) { - logger('Missing data in notifs: ' . json_encode($a->argv), LOGGER_DEBUG); - } - // Process the data for template creation - if ($notifs['ident'] === 'introductions') { + if (defaults($notifs, 'ident', '') === 'introductions') { $sugg = get_markup_template('suggestions.tpl'); $tpl = get_markup_template("intros.tpl"); @@ -280,7 +277,7 @@ function notifications_content(App $a) } // Normal notifications (no introductions) - } else { + } elseif (!empty($notifs['notifications'])) { // The template files we need in different cases for formatting the content $tpl_item_like = 'notifications_likes_item.tpl'; $tpl_item_dislike = 'notifications_dislikes_item.tpl'; diff --git a/mod/unfollow.php b/mod/unfollow.php index 0af16ec671..956b6fbdb7 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -22,7 +22,7 @@ function unfollow_post() // NOTREACHED } - if ($_REQUEST['cancel']) { + if (!empty($_REQUEST['cancel'])) { goaway($return_url); } diff --git a/src/App.php b/src/App.php index 2a5fba8541..488c2301b6 100644 --- a/src/App.php +++ b/src/App.php @@ -1074,7 +1074,11 @@ class App $meminfo = []; foreach ($memdata as $line) { - list($key, $val) = explode(':', $line); + $data = explode(':', $line); + if (count($data) != 2) { + continue; + } + list($key, $val) = $data; $meminfo[$key] = (int) trim(str_replace('kB', '', $val)); $meminfo[$key] = (int) ($meminfo[$key] / 1024); } diff --git a/src/Util/HTTPSignature.php b/src/Util/HTTPSignature.php index f88b0423c5..911de4308e 100644 --- a/src/Util/HTTPSignature.php +++ b/src/Util/HTTPSignature.php @@ -125,6 +125,8 @@ class HTTPSignature $key = $key($sig_block['keyId']); } + logger('Got keyID ' . $sig_block['keyId']); + // We don't use Activity Pub at the moment. // if (!$key) { // $result['signer'] = $sig_block['keyId']; From 635c8d7450866cb8b77a6d1d42260257e286a940 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 4 Sep 2018 21:24:30 +0000 Subject: [PATCH 36/96] Beautified the code --- mod/events.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/events.php b/mod/events.php index 21cf70d20f..c4d40252d3 100644 --- a/mod/events.php +++ b/mod/events.php @@ -482,8 +482,8 @@ function events_content(App $a) { $perms = ACL::getDefaultUserPermissions($orig_event); - if ($mode === 'new' || $mode === 'copy') { - $acl = ($cid ? '' : ACL::getFullSelectorHTML($a->user, false, $orig_event)); + if (!$cid && in_array($mode, ['new', 'copy'])) { + $acl = ACL::getFullSelectorHTML($a->user, false, $orig_event); } else { $acl = ''; } From 9de0d354506fdb20929e68d10cf3680181d4382c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 4 Sep 2018 19:29:36 -0400 Subject: [PATCH 37/96] Remove extraneous SQL condition part in mod/unfollow --- mod/unfollow.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/unfollow.php b/mod/unfollow.php index 0af16ec671..f9b0a2fcba 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -29,7 +29,7 @@ function unfollow_post() $uid = local_user(); $url = notags(trim(defaults($_REQUEST, 'url', ''))); - $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?", + $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)", $uid, Contact::SHARING, Contact::FRIEND, normalise_link($url), normalise_link($url), $url]; $contact = DBA::selectFirst('contact', [], $condition); From 9ef1d827f35dfcd779015003bc359e3dd7d6fef6 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 5 Sep 2018 05:02:06 +0000 Subject: [PATCH 38/96] Restore the behaviour to remove the remote contact upon termination --- mod/contacts.php | 2 +- mod/dfrn_notify.php | 4 ++-- mod/dirfind.php | 2 +- mod/unfollow.php | 6 ++++-- src/Model/Contact.php | 12 ++++++++---- src/Protocol/DFRN.php | 13 ++++++++----- src/Worker/Notifier.php | 2 +- 7 files changed, 25 insertions(+), 16 deletions(-) diff --git a/mod/contacts.php b/mod/contacts.php index 70a582c6ee..68f68fec3b 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -368,7 +368,7 @@ function _contact_drop($orig_record) return; } - Contact::terminateFriendship($r[0], $orig_record); + Contact::terminateFriendship($r[0], $orig_record, true); Contact::remove($orig_record['id']); } diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 88f706385b..f653faca95 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -322,8 +322,8 @@ function dfrn_notify_content(App $a) { $encrypted_id = ''; $id_str = $my_id . '.' . mt_rand(1000,9999); - $prv_key = trim($importer['prvkey']); - $pub_key = trim($importer['pubkey']); + $prv_key = trim($importer['cprvkey']); + $pub_key = trim($importer['cpubkey']); $dplx = intval($importer['duplex']); if (($dplx && strlen($prv_key)) || (strlen($prv_key) && !strlen($pub_key))) { diff --git a/mod/dirfind.php b/mod/dirfind.php index f4ddba45d4..332fe90f6c 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -44,7 +44,7 @@ function dirfind_content(App $a, $prefix = "") { $local = Config::get('system','poco_local_search'); - $search = $prefix.notags(trim($_REQUEST['search'])); + $search = $prefix.notags(trim(defaults($_REQUEST, 'search', ''))); $header = ''; diff --git a/mod/unfollow.php b/mod/unfollow.php index 956b6fbdb7..0aa114759f 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -46,13 +46,15 @@ function unfollow_post() // NOTREACHED } + $dissolve = ($contact['rel'] == Contact::SHARING); + $owner = User::getOwnerDataById($uid); if ($owner) { - Contact::terminateFriendship($owner, $contact); + Contact::terminateFriendship($owner, $contact, $dissolve); } // Sharing-only contacts get deleted as there no relationship any more - if ($contact['rel'] == Contact::SHARING) { + if ($dissolve) { Contact::remove($contact['id']); $return_path = 'contacts'; } else { diff --git a/src/Model/Contact.php b/src/Model/Contact.php index d53126f6ff..1bbc0228a8 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -17,6 +17,7 @@ use Friendica\Model\Profile; use Friendica\Network\Probe; use Friendica\Object\Image; use Friendica\Protocol\Diaspora; +use Friendica\Protocol\DFRN; use Friendica\Protocol\OStatus; use Friendica\Protocol\PortableContact; use Friendica\Protocol\Salmon; @@ -528,13 +529,16 @@ class Contact extends BaseObject /** * @brief Sends an unfriend message. Does not remove the contact * - * @param array $user User unfriending - * @param array $contact Contact unfriended + * @param array $user User unfriending + * @param array $contact Contact unfriended + * @param boolean $dissolve Remove the contact on the remote side * @return void */ - public static function terminateFriendship(array $user, array $contact) + public static function terminateFriendship(array $user, array $contact, $dissolve = false) { - if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN])) { + if (($contact['network'] == Protocol::DFRN) && $dissolve) { + DFRN::deliver($user, $contact, 'placeholder', true); + } elseif (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN])) { // create an unfollow slap $item = []; $item['verb'] = NAMESPACE_OSTATUS . "/unfollow"; diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index c435550313..b207c3ca87 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -81,7 +81,8 @@ class DFRN return []; } - $user['importer_uid'] = $user['uid']; + $user['importer_uid'] = $user['uid']; + $user['uprvkey'] = $user['prvkey']; } else { $user = ['importer_uid' => 0, 'uprvkey' => '', 'timezone' => 'UTC', 'nickname' => '', 'sprvkey' => '', 'spubkey' => '', @@ -1168,10 +1169,12 @@ class DFRN $a = get_app(); // At first try the Diaspora transport layer - $ret = self::transmit($owner, $contact, $atom); - if ($ret >= 200) { - logger('Delivery via Diaspora transport layer was successful with status ' . $ret); - return $ret; + if (!$dissolve) { + $ret = self::transmit($owner, $contact, $atom); + if ($ret >= 200) { + logger('Delivery via Diaspora transport layer was successful with status ' . $ret); + return $ret; + } } $idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']); diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 6d2733b8ee..61eaba388b 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -96,7 +96,7 @@ class Notifier return; } foreach ($r as $contact) { - Contact::terminateFriendship($user, $contact); + Contact::terminateFriendship($user, $contact, true); } return; } elseif ($cmd == Delivery::RELOCATION) { From 88d25f977a078dd3e5dfb7d0461cf231ff64358f Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Wed, 5 Sep 2018 14:12:56 +0200 Subject: [PATCH 39/96] fix lockview for photos - use the private field only for items because other tables than the item table don't have the private field --- mod/lockview.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mod/lockview.php b/mod/lockview.php index 893764c4d9..7617d6f736 100644 --- a/mod/lockview.php +++ b/mod/lockview.php @@ -24,11 +24,12 @@ function lockview_content(App $a) { if (!in_array($type, ['item','photo','event'])) killme(); - $fields = ['uid', 'private', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']; + $fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']; $condition = ['id' => $item_id]; if ($type != 'item') { $item = DBA::selectFirst($type, $fields, $condition); } else { + $fields[] = 'private'; $item = Item::selectFirst($fields, $condition); } From bd9d102da254f723436adc544f510a92a8935925 Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Wed, 5 Sep 2018 14:24:51 +0200 Subject: [PATCH 40/96] apply coding standards to lockview module --- mod/lockview.php | 61 +++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/mod/lockview.php b/mod/lockview.php index 7617d6f736..0d87e15510 100644 --- a/mod/lockview.php +++ b/mod/lockview.php @@ -8,24 +8,27 @@ use Friendica\Core\L10n; use Friendica\Database\DBA; use Friendica\Model\Item; -function lockview_content(App $a) { - +function lockview_content(App $a) +{ $type = (($a->argc > 1) ? $a->argv[1] : 0); if (is_numeric($type)) { $item_id = intval($type); - $type='item'; + $type = 'item'; } else { $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0); } - if (!$item_id) + if (!$item_id) { killme(); + } - if (!in_array($type, ['item','photo','event'])) + if (!in_array($type, ['item','photo','event'])) { killme(); + } $fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']; $condition = ['id' => $item_id]; + if ($type != 'item') { $item = DBA::selectFirst($type, $fields, $condition); } else { @@ -44,18 +47,20 @@ function lockview_content(App $a) { killme(); } - - if (($item['private'] == 1) && empty($item['allow_cid']) && empty($item['allow_gid']) - && empty($item['deny_cid']) && empty($item['deny_gid'])) { - + if ($item['private'] == 1 + && empty($item['allow_cid']) + && empty($item['allow_gid']) + && empty($item['deny_cid']) + && empty($item['deny_gid'])) + { echo L10n::t('Remote privacy information not available.') . '
'; killme(); } - $allowed_users = expand_acl($item['allow_cid']); + $allowed_users = expand_acl($item['allow_cid']); $allowed_groups = expand_acl($item['allow_gid']); - $deny_users = expand_acl($item['deny_cid']); - $deny_groups = expand_acl($item['deny_gid']); + $deny_users = expand_acl($item['deny_cid']); + $deny_groups = expand_acl($item['deny_gid']); $o = L10n::t('Visible to:') . '
'; $l = []; @@ -64,36 +69,44 @@ function lockview_content(App $a) { $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )", DBA::escape(implode(', ', $allowed_groups)) ); - if (DBA::isResult($r)) - foreach($r as $rr) + if (DBA::isResult($r)) { + foreach ($r as $rr) { $l[] = '' . $rr['name'] . ''; + } + } } + if (count($allowed_users)) { $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )", - DBA::escape(implode(', ',$allowed_users)) + DBA::escape(implode(', ', $allowed_users)) ); - if (DBA::isResult($r)) - foreach($r as $rr) + if (DBA::isResult($r)) { + foreach ($r as $rr) { $l[] = $rr['name']; - + } + } } if (count($deny_groups)) { $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )", DBA::escape(implode(', ', $deny_groups)) ); - if (DBA::isResult($r)) - foreach($r as $rr) + if (DBA::isResult($r)) { + foreach ($r as $rr) { $l[] = '' . $rr['name'] . ''; + } + } } + if (count($deny_users)) { $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )", - DBA::escape(implode(', ',$deny_users)) + DBA::escape(implode(', ', $deny_users)) ); - if (DBA::isResult($r)) - foreach($r as $rr) + if (DBA::isResult($r)) { + foreach ($r as $rr) { $l[] = '' . $rr['name'] . ''; - + } + } } echo $o . implode(', ', $l); From 85fed927c3e827d471a1c5f6b49d6e7da49a075c Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Wed, 5 Sep 2018 17:30:07 +0200 Subject: [PATCH 41/96] Frio - addToModal() can now be used with an element ID as a parameter --- view/theme/frio/js/modal.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/view/theme/frio/js/modal.js b/view/theme/frio/js/modal.js index 2b3059eaf1..9a15cab52a 100644 --- a/view/theme/frio/js/modal.js +++ b/view/theme/frio/js/modal.js @@ -188,14 +188,25 @@ function loadModalTitle() { } } -// This function loads html content from a friendica page -// into a modal. -function addToModal(url) { + +/** + * This function loads html content from a friendica page into a modal. + * + * @param {string} url The url with html content. + * @param {string} id The ID of a html element (can be undefined). + * @returns {void} + */ +function addToModal(url, id) { var char = qOrAmp(url); url = url + char + 'mode=none'; var modal = $('#modal').modal(); + // Only search for an element if we have an ID. + if (typeof id !== "undefined") { + url = url + " div#" + id; + } + modal .find('#modal-body') .load(url, function (responseText, textStatus) { @@ -215,7 +226,7 @@ function addToModal(url) { }); } -// Add a element (by it's id) to a bootstrap modal. +// Add an element (by its id) to a bootstrap modal. function addElmToModal(id) { var elm = $(id).html(); var modal = $('#modal').modal(); From 7c5e964581480902d7f0571ff92936beda36f4e2 Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Wed, 5 Sep 2018 18:24:04 +0200 Subject: [PATCH 42/96] Frio - fix missing modal for editing albums --- view/theme/frio/js/mod_photos.js | 7 +++++++ view/theme/frio/templates/album_edit.tpl | 23 ++++++++++++----------- view/theme/frio/templates/photo_album.tpl | 4 ++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/view/theme/frio/js/mod_photos.js b/view/theme/frio/js/mod_photos.js index b8d03b5db9..77173385b1 100644 --- a/view/theme/frio/js/mod_photos.js +++ b/view/theme/frio/js/mod_photos.js @@ -15,7 +15,14 @@ $(document).ready(function() { }).trigger('change'); + // Click event listener for the album edit link/button. + $("body").on('click', '#album-edit-link', function() { + var modalUrl = $(this).attr("data-modal-url"); + if (typeof modalUrl !== "undefined") { + addToModal(modalUrl, 'photo-album-edit-wrapper'); + } + }); }); $(window).load(function() { diff --git a/view/theme/frio/templates/album_edit.tpl b/view/theme/frio/templates/album_edit.tpl index 583eb6d1b7..f4a60b7d03 100644 --- a/view/theme/frio/templates/album_edit.tpl +++ b/view/theme/frio/templates/album_edit.tpl @@ -1,14 +1,15 @@
-
- -
- -
- -
- - -
-
+
+ +
+ +
+ +
+ + +
+
+
diff --git a/view/theme/frio/templates/photo_album.tpl b/view/theme/frio/templates/photo_album.tpl index c991b03cfc..235b9c46db 100644 --- a/view/theme/frio/templates/photo_album.tpl +++ b/view/theme/frio/templates/photo_album.tpl @@ -12,9 +12,9 @@ {{if $edit}} - + {{/if}} {{if ! $noorder}} From f9fe162f2fa4a2142e8157ca2a7f20f7b0efeced Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Wed, 5 Sep 2018 18:31:09 +0200 Subject: [PATCH 43/96] Frio - rise version --- view/theme/frio/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php index 4e01289624..72e5ab0b61 100644 --- a/view/theme/frio/theme.php +++ b/view/theme/frio/theme.php @@ -2,7 +2,7 @@ /* * Name: frio * Description: Bootstrap V3 theme. The theme is currently under construction, so it is far from finished. For further information have a look at the ReadMe. - * Version: V.0.8 + * Version: V.0.8.5 * Author: Rabuzarus * */ From 1fe16282370ebec7218537e763e35f608bb68a17 Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Wed, 5 Sep 2018 18:44:47 +0200 Subject: [PATCH 44/96] lockview - prevent notices --- mod/lockview.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mod/lockview.php b/mod/lockview.php index 0d87e15510..a2301b4ccb 100644 --- a/mod/lockview.php +++ b/mod/lockview.php @@ -47,7 +47,8 @@ function lockview_content(App $a) killme(); } - if ($item['private'] == 1 + if (isset($item['private']) + && $item['private'] == 1 && empty($item['allow_cid']) && empty($item['allow_gid']) && empty($item['deny_cid']) From 75a2576f7896d97d1e4127ee9563c0c8927bb5f8 Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Thu, 6 Sep 2018 01:42:35 +0200 Subject: [PATCH 45/96] use magic links in single event view --- src/Model/Event.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Model/Event.php b/src/Model/Event.php index 992b77bada..016d1f8d9e 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -12,6 +12,7 @@ use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Database\DBA; +use Friendica\Model\Contact; use Friendica\Util\DateTimeFormat; use Friendica\Util\Map; @@ -589,6 +590,12 @@ class Event extends BaseObject $title = strip_tags(html_entity_decode($title, ENT_QUOTES, 'UTF-8')); } + $author_link = $event['author-link']; + $plink = $event['plink']; + + $event['author-link'] = Contact::magicLink($author_link); + $event['plink'] = Contact::magicLink($author_link, $plink); + $html = self::getHTML($event); $event['desc'] = BBCode::convert($event['desc']); $event['location'] = BBCode::convert($event['location']); From 04fb88585783f4883b40ec9d49a4a7fa644fb294 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 6 Sep 2018 04:24:34 +0000 Subject: [PATCH 46/96] Fix: Posts with pictures will now look good again on connector networks --- mod/photos.php | 2 +- src/Content/Text/BBCode.php | 5 ++++- src/Util/ParseUrl.php | 10 +++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/mod/photos.php b/mod/photos.php index 5fb6ba3683..16af455997 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1633,7 +1633,7 @@ function photos_content(App $a) '$paginate' => $paginate, ]); - $a->page['htmlhead'] .= "\n" . '' . "\n"; + $a->page['htmlhead'] .= "\n" . '' . "\n"; $a->page['htmlhead'] .= '' . "\n"; $a->page['htmlhead'] .= '' . "\n"; $a->page['htmlhead'] .= '' . "\n"; diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 55fc24273d..3054170fc0 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -578,7 +578,10 @@ class BBCode extends BaseObject $return .= sprintf('
', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]); } - if (!empty($data['title']) && !empty($data['url'])) { + // Show a picture only when the BBCode is meant for posts to connector networks + if (($simplehtml != 0) && ($data["type"] == "photo") && !empty($data["url"]) && !empty($data["image"])) { + $return .= sprintf('', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]); + } elseif (!empty($data['title']) && !empty($data['url'])) { $return .= sprintf('

%s

', $data['url'], $data['title']); } diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 2c134542a0..520100b6d7 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -271,9 +271,9 @@ class ParseUrl $siteinfo['image'] = $meta_tag['content']; break; case 'twitter:card': - // Obsolete card type - if ($meta_tag['content'] == 'photo') { - $siteinfo['type'] = 'summary_large_image'; + // Convert Twitter types in our own + if ($meta_tag['content'] == 'summary_large_image') { + $siteinfo['type'] = 'photo'; } else { $siteinfo['type'] = $meta_tag['content']; } @@ -299,10 +299,6 @@ class ParseUrl } } - if ($siteinfo['type'] == 'summary' || $siteinfo['type'] == 'summary_large_image') { - $siteinfo['type'] = 'link'; - } - if (isset($keywords)) { $siteinfo['keywords'] = []; foreach ($keywords as $keyword) { From f84b39be0b4e7d037c41157537f2864d3f6b7ef4 Mon Sep 17 00:00:00 2001 From: Aditoo17 <42938951+Aditoo17@users.noreply.github.com> Date: Thu, 6 Sep 2018 10:43:15 +0200 Subject: [PATCH 47/96] Fix iframe address --- doc/Quick-Start-groupsandpages.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Quick-Start-groupsandpages.md b/doc/Quick-Start-groupsandpages.md index 652407d642..d4680f65f2 100644 --- a/doc/Quick-Start-groupsandpages.md +++ b/doc/Quick-Start-groupsandpages.md @@ -15,6 +15,6 @@ Remember the link at the top of this page will bring you back here. Once you've added some groups, move on to the next section. - + From 6113fdc940d77fba1871463ee0c5a27e1f22eda7 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 6 Sep 2018 09:20:45 +0000 Subject: [PATCH 48/96] Issue 5733: Changing relationship values does work now again with DFRN --- mod/dfrn_notify.php | 2 +- src/Protocol/Diaspora.php | 37 +++++++++++++++++++++++++++++-------- src/Protocol/OStatus.php | 14 ++++++++++++-- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index f653faca95..666c388a4a 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -182,7 +182,7 @@ function dfrn_notify_post(App $a) { function dfrn_dispatch_public($postdata) { - $msg = Diaspora::decodeRaw([], $postdata); + $msg = Diaspora::decodeRaw([], $postdata, true); if (!$msg) { // We have to fail silently to be able to hand it over to the salmon parser return false; diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index c25eb96898..7af8dbd424 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -365,15 +365,16 @@ class Diaspora /** * @brief: Decodes incoming Diaspora message in the new format * - * @param array $importer Array of the importer user - * @param string $raw raw post message + * @param array $importer Array of the importer user + * @param string $raw raw post message + * @param boolean $no_exit Don't do an http exit on error * * @return array * 'message' -> decoded Diaspora XML message * 'author' -> author diaspora handle * 'key' -> author public key (converted to pkcs#8) */ - public static function decodeRaw(array $importer, $raw) + public static function decodeRaw(array $importer, $raw, $no_exit = false) { $data = json_decode($raw); @@ -388,7 +389,11 @@ class Diaspora if (!is_object($j_outer_key_bundle)) { logger('Outer Salmon did not verify. Discarding.'); - System::httpExit(400); + if ($no_exit) { + return false; + } else { + System::httpExit(400); + } } $outer_iv = base64_decode($j_outer_key_bundle->iv); @@ -403,7 +408,11 @@ class Diaspora if (!is_object($basedom)) { logger('Received data does not seem to be an XML. Discarding. '.$xml); - System::httpExit(400); + if ($no_exit) { + return false; + } else { + System::httpExit(400); + } } $base = $basedom->children(NAMESPACE_SALMON_ME); @@ -425,19 +434,31 @@ class Diaspora $author_addr = base64_decode($key_id); if ($author_addr == '') { logger('No author could be decoded. Discarding. Message: ' . $xml); - System::httpExit(400); + if ($no_exit) { + return false; + } else { + System::httpExit(400); + } } $key = self::key($author_addr); if ($key == '') { logger("Couldn't get a key for handle " . $author_addr . ". Discarding."); - System::httpExit(400); + if ($no_exit) { + return false; + } else { + System::httpExit(400); + } } $verify = Crypto::rsaVerify($signed_data, $signature, $key); if (!$verify) { logger('Message did not verify. Discarding.'); - System::httpExit(400); + if ($no_exit) { + return false; + } else { + System::httpExit(400); + } } return ['message' => (string)base64url_decode($base->data), diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 551b4ad887..ece265c99b 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -74,6 +74,16 @@ class OStatus $author["contact-id"] = $contact["id"]; $contact = null; + +/* + This here would be better, but we would get problems with contacts from the statusnet addon + This is kept here as a reminder for the future + + $cid = Contact::getIdForURL($author["author-link"], $importer["uid"]); + if ($cid) { + $contact = DBA::selectFirst('contact', [], ['id' => $cid]); + } +*/ if ($aliaslink != '') { $condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)", $importer["uid"], $aliaslink, Protocol::STATUSNET, @@ -219,7 +229,7 @@ class OStatus $gcid = GContact::update($contact); GContact::link($gcid, $contact["uid"], $contact["id"]); - } else { + } elseif ($contact["network"] != Protocol::DFRN) { $contact = null; } @@ -312,7 +322,7 @@ class OStatus self::$conv_list = []; } - logger("Import OStatus message", LOGGER_DEBUG); + logger('Import OStatus message for user ' . $importer['uid'], LOGGER_DEBUG); if ($xml == "") { return false; From 26607d4a275c6f2973287836439f5e9b805511d1 Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Thu, 6 Sep 2018 14:40:34 +0200 Subject: [PATCH 49/96] Frio - bugfix - don't show new event button if the button isn't available --- view/theme/frio/templates/events_js.tpl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/view/theme/frio/templates/events_js.tpl b/view/theme/frio/templates/events_js.tpl index 31debbe310..a4ca9004cd 100644 --- a/view/theme/frio/templates/events_js.tpl +++ b/view/theme/frio/templates/events_js.tpl @@ -3,11 +3,13 @@ {{include file="section_title.tpl" title=$title pullright=1}} {{* The link to create a new event *}} + {{if $new_event.0}} + {{/if}} {{* We create our own fullcallendar header (with title & calendar view *}}
From e9a73e4480154fd69195401c970e444159f87964 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 6 Sep 2018 13:27:03 +0000 Subject: [PATCH 50/96] Fix fatal error due to missing "use" --- src/Module/Proxy.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Module/Proxy.php b/src/Module/Proxy.php index 7983e01f7a..0de45b3325 100644 --- a/src/Module/Proxy.php +++ b/src/Module/Proxy.php @@ -8,6 +8,7 @@ namespace Friendica\Module; use Friendica\App; use Friendica\BaseModule; use Friendica\Core\Config; +use Friendica\Core\L10n; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Photo; From 1d4a5402ff1a63ea3f2bd17d834ebce74f44379f Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 6 Sep 2018 20:30:16 +0000 Subject: [PATCH 51/96] Picture posts do work again - everything else should work as well --- src/Content/Text/BBCode.php | 22 +++++++++++----------- src/Util/ParseUrl.php | 9 ++++++--- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 3054170fc0..2dc13ae5e0 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -572,17 +572,17 @@ class BBCode extends BaseObject $return = sprintf('
', $data["type"]); } - if (!empty($data["image"])) { - $return .= sprintf('
', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]); - } elseif (!empty($data["preview"])) { - $return .= sprintf('
', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]); - } - - // Show a picture only when the BBCode is meant for posts to connector networks - if (($simplehtml != 0) && ($data["type"] == "photo") && !empty($data["url"]) && !empty($data["image"])) { - $return .= sprintf('', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]); - } elseif (!empty($data['title']) && !empty($data['url'])) { - $return .= sprintf('

%s

', $data['url'], $data['title']); + if (!empty($data['title']) && !empty($data['url'])) { + if (!empty($data["image"]) && empty($data["text"]) && ($data["type"] == "photo")) { + $return .= sprintf('', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]); + } else { + if (!empty($data["image"])) { + $return .= sprintf('
', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]); + } elseif (!empty($data["preview"])) { + $return .= sprintf('
', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]); + } + $return .= sprintf('

%s

', $data['url'], $data['title']); + } } if (!empty($data["description"]) && $data["description"] != $data["title"]) { diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 520100b6d7..4443da7564 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -271,11 +271,9 @@ class ParseUrl $siteinfo['image'] = $meta_tag['content']; break; case 'twitter:card': - // Convert Twitter types in our own + // Detect photo pages if ($meta_tag['content'] == 'summary_large_image') { $siteinfo['type'] = 'photo'; - } else { - $siteinfo['type'] = $meta_tag['content']; } break; case 'twitter:description': @@ -334,6 +332,11 @@ class ParseUrl } } + // Prevent to have a photo type without an image + if (empty($siteinfo['image']) && (siteinfo['type'] == 'photo')) { + $siteinfo['type'] = 'link'; + } + if ((@$siteinfo['image'] == '') && !$no_guessing) { $list = $xpath->query('//img[@src]'); foreach ($list as $node) { From 2592c3891ce3134d591c890c7bd7f789f554f208 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 6 Sep 2018 21:10:48 +0000 Subject: [PATCH 52/96] forgotten $ --- src/Util/ParseUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 4443da7564..dd39a052a0 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -333,7 +333,7 @@ class ParseUrl } // Prevent to have a photo type without an image - if (empty($siteinfo['image']) && (siteinfo['type'] == 'photo')) { + if (empty($siteinfo['image']) && ($siteinfo['type'] == 'photo')) { $siteinfo['type'] = 'link'; } From 2f7ba1370226bbcb97fd6b9f9b737b8462ce97ac Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 6 Sep 2018 18:42:57 -0400 Subject: [PATCH 53/96] Restore display when there aren't unread notifications --- mod/notifications.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/mod/notifications.php b/mod/notifications.php index 091323d998..5feb3be19a 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -308,18 +308,15 @@ function notifications_content(App $a) '$item_seen' => $it['seen'], ]); } - - $notif_show_lnk = [ - 'href' => ($show ? 'notifications/'.$notifs['ident'] : 'notifications/'.$notifs['ident'].'?show=all' ), - 'text' => ($show ? L10n::t('Show unread') : L10n::t('Show all')), - ]; - - // Output if there aren't any notifications available - if (count($notifs['notifications']) == 0) { - $notif_nocontent = L10n::t('No more %s notifications.', $notifs['ident']); - } + } else { + $notif_nocontent = L10n::t('No more %s notifications.', $notifs['ident']); } + $notif_show_lnk = [ + 'href' => ($show ? 'notifications/'.$notifs['ident'] : 'notifications/'.$notifs['ident'].'?show=all' ), + 'text' => ($show ? L10n::t('Show unread') : L10n::t('Show all')), + ]; + $o .= replace_macros($notif_tpl, [ '$notif_header' => $notif_header, '$tabs' => $tabs, From f85af78097d2ab73a9ee4b020a6a366f3a147de3 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 6 Sep 2018 18:55:06 -0400 Subject: [PATCH 54/96] Source format mod/notifications - Add array alignment - Convert remaining double quotes to quotes - Replace x() with defaults() - Add missing spaces --- mod/notifications.php | 221 +++++++++++++++++++----------------------- 1 file changed, 101 insertions(+), 120 deletions(-) diff --git a/mod/notifications.php b/mod/notifications.php index 5feb3be19a..212736305f 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -21,7 +21,7 @@ function notifications_post(App $a) $request_id = (($a->argc > 1) ? $a->argv[1] : 0); - if ($request_id === "all") { + if ($request_id === 'all') { return; } @@ -68,8 +68,8 @@ function notifications_content(App $a) return; } - $page = (x($_REQUEST,'page') ? $_REQUEST['page'] : 1); - $show = (x($_REQUEST,'show') ? $_REQUEST['show'] : 0); + $page = defaults($_REQUEST, 'page', 1); + $show = defaults($_REQUEST, 'show', 0); Nav::setSelected('notifications'); @@ -118,7 +118,6 @@ function notifications_content(App $a) $notifs = $nm->homeNotifs($show, $startrec, $perpage); } - // Set the pager $a->set_pager_itemspage($perpage); @@ -136,7 +135,7 @@ function notifications_content(App $a) // Process the data for template creation if (defaults($notifs, 'ident', '') === 'introductions') { $sugg = get_markup_template('suggestions.tpl'); - $tpl = get_markup_template("intros.tpl"); + $tpl = get_markup_template('intros.tpl'); // The link to switch between ignored and normal connection requests $notif_show_lnk = [ @@ -146,127 +145,121 @@ function notifications_content(App $a) // Loop through all introduction notifications.This creates an array with the output html for each // introduction - foreach ($notifs['notifications'] as $it) { + foreach ($notifs['notifications'] as $notif) { // There are two kind of introduction. Contacts suggested by other contacts and normal connection requests. // We have to distinguish between these two because they use different data. - switch ($it['label']) { + switch ($notif['label']) { case 'friend_suggestion': $notif_content[] = replace_macros($sugg, [ - '$type' => $it['label'], + '$type' => $notif['label'], '$str_notifytype' => L10n::t('Notification type:'), - '$notify_type' => $it['notify_type'], - '$intro_id' => $it['intro_id'], + '$notify_type'=> $notif['notify_type'], + '$intro_id' => $notif['intro_id'], '$lbl_madeby' => L10n::t('Suggested by:'), - '$madeby' => $it['madeby'], - '$madeby_url' => $it['madeby_url'], - '$madeby_zrl' => $it['madeby_zrl'], - '$madeby_addr' => $it['madeby_addr'], - '$contact_id' => $it['contact_id'], - '$photo' => $it['photo'], - '$fullname' => $it['name'], - '$url' => $it['url'], - '$zrl' => $it['zrl'], - '$lbl_url' => L10n::t('Profile URL'), - '$addr' => $it['addr'], - '$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($it['hidden'] == 1), ''], - - '$knowyou' => $it['knowyou'], - '$approve' => L10n::t('Approve'), - '$note' => $it['note'], - '$request' => $it['request'], - '$ignore' => L10n::t('Ignore'), - '$discard' => L10n::t('Discard'), + '$madeby' => $notif['madeby'], + '$madeby_url' => $notif['madeby_url'], + '$madeby_zrl' => $notif['madeby_zrl'], + '$madeby_addr'=> $notif['madeby_addr'], + '$contact_id' => $notif['contact_id'], + '$photo' => $notif['photo'], + '$fullname' => $notif['name'], + '$url' => $notif['url'], + '$zrl' => $notif['zrl'], + '$lbl_url' => L10n::t('Profile URL'), + '$addr' => $notif['addr'], + '$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($notif['hidden'] == 1), ''], + '$knowyou' => $notif['knowyou'], + '$approve' => L10n::t('Approve'), + '$note' => $notif['note'], + '$request' => $notif['request'], + '$ignore' => L10n::t('Ignore'), + '$discard' => L10n::t('Discard'), ]); break; // Normal connection requests default: - $friend_selected = (($it['network'] !== Protocol::OSTATUS) ? ' checked="checked" ' : ' disabled '); - $fan_selected = (($it['network'] === Protocol::OSTATUS) ? ' checked="checked" disabled ' : ''); - $dfrn_tpl = get_markup_template('netfriend.tpl'); + $friend_selected = (($notif['network'] !== Protocol::OSTATUS) ? ' checked="checked" ' : ' disabled '); + $fan_selected = (($notif['network'] === Protocol::OSTATUS) ? ' checked="checked" disabled ' : ''); - $knowyou = ''; $lbl_knowyou = ''; - $dfrn_text = ''; - $helptext = ''; - $helptext2 = ''; - $helptext3 = ''; + $knowyou = ''; + $helptext = ''; + $helptext2 = ''; + $helptext3 = ''; - if ($it['network'] === Protocol::DFRN || $it['network'] === Protocol::DIASPORA) { - if ($it['network'] === Protocol::DFRN) { - $lbl_knowyou = L10n::t('Claims to be known to you: '); - $knowyou = (($it['knowyou']) ? L10n::t('yes') : L10n::t('no')); - $helptext = L10n::t('Shall your connection be bidirectional or not?'); - $helptext2 = L10n::t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $it['name'], $it['name']); - $helptext3 = L10n::t('Accepting %s as a subscriber allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $it['name']); - } else { - $knowyou = ''; - $helptext = L10n::t('Shall your connection be bidirectional or not?'); - $helptext2 = L10n::t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $it['name'], $it['name']); - $helptext3 = L10n::t('Accepting %s as a sharer allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $it['name']); - } + if ($notif['network'] === Protocol::DFRN) { + $lbl_knowyou = L10n::t('Claims to be known to you: '); + $knowyou = (($notif['knowyou']) ? L10n::t('yes') : L10n::t('no')); + $helptext = L10n::t('Shall your connection be bidirectional or not?'); + $helptext2 = L10n::t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $notif['name'], $notif['name']); + $helptext3 = L10n::t('Accepting %s as a subscriber allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $notif['name']); + } elseif ($notif['network'] === Protocol::DIASPORA) { + $helptext = L10n::t('Shall your connection be bidirectional or not?'); + $helptext2 = L10n::t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $notif['name'], $notif['name']); + $helptext3 = L10n::t('Accepting %s as a sharer allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $notif['name']); } - $dfrn_text = replace_macros($dfrn_tpl,[ - '$intro_id' => $it['intro_id'], + $dfrn_tpl = get_markup_template('netfriend.tpl'); + $dfrn_text = replace_macros($dfrn_tpl, [ + '$intro_id' => $notif['intro_id'], '$friend_selected' => $friend_selected, - '$fan_selected' => $fan_selected, + '$fan_selected'=> $fan_selected, '$approve_as1' => $helptext, '$approve_as2' => $helptext2, '$approve_as3' => $helptext3, - '$as_friend' => L10n::t('Friend'), - '$as_fan' => (($it['network'] == Protocol::DIASPORA) ? L10n::t('Sharer') : L10n::t('Subscriber')) + '$as_friend' => L10n::t('Friend'), + '$as_fan' => (($notif['network'] == Protocol::DIASPORA) ? L10n::t('Sharer') : L10n::t('Subscriber')) ]); - $header = $it["name"]; + $header = $notif['name']; - if ($it["addr"] != "") { - $header .= " <".$it["addr"].">"; + if ($notif['addr'] != '') { + $header .= ' <' . $notif['addr'] . '>'; } - $header .= " (".ContactSelector::networkToName($it['network'], $it['url']).")"; + $header .= ' (' . ContactSelector::networkToName($notif['network'], $notif['url']) . ')'; - if ($it['network'] != Protocol::DIASPORA) { + if ($notif['network'] != Protocol::DIASPORA) { $discard = L10n::t('Discard'); } else { $discard = ''; } $notif_content[] = replace_macros($tpl, [ - '$type' => $it['label'], - '$header' => htmlentities($header), + '$type' => $notif['label'], + '$header' => htmlentities($header), '$str_notifytype' => L10n::t('Notification type:'), - '$notify_type' => $it['notify_type'], - '$dfrn_text' => $dfrn_text, - '$dfrn_id' => $it['dfrn_id'], - '$uid' => $it['uid'], - '$intro_id' => $it['intro_id'], - '$contact_id' => $it['contact_id'], - '$photo' => $it['photo'], - '$fullname' => $it['name'], - '$location' => $it['location'], - '$lbl_location' => L10n::t('Location:'), - '$about' => $it['about'], - '$lbl_about' => L10n::t('About:'), - '$keywords' => $it['keywords'], - '$lbl_keywords' => L10n::t('Tags:'), - '$gender' => $it['gender'], - '$lbl_gender' => L10n::t('Gender:'), - '$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($it['hidden'] == 1), ''], - '$url' => $it['url'], - '$zrl' => $it['zrl'], - '$lbl_url' => L10n::t('Profile URL'), - '$addr' => $it['addr'], + '$notify_type' => $notif['notify_type'], + '$dfrn_text' => $dfrn_text, + '$dfrn_id' => $notif['dfrn_id'], + '$uid' => $notif['uid'], + '$intro_id' => $notif['intro_id'], + '$contact_id' => $notif['contact_id'], + '$photo' => $notif['photo'], + '$fullname' => $notif['name'], + '$location' => $notif['location'], + '$lbl_location'=> L10n::t('Location:'), + '$about' => $notif['about'], + '$lbl_about' => L10n::t('About:'), + '$keywords' => $notif['keywords'], + '$lbl_keywords'=> L10n::t('Tags:'), + '$gender' => $notif['gender'], + '$lbl_gender' => L10n::t('Gender:'), + '$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($notif['hidden'] == 1), ''], + '$url' => $notif['url'], + '$zrl' => $notif['zrl'], + '$lbl_url' => L10n::t('Profile URL'), + '$addr' => $notif['addr'], '$lbl_knowyou' => $lbl_knowyou, '$lbl_network' => L10n::t('Network:'), - '$network' => ContactSelector::networkToName($it['network'], $it['url']), - '$knowyou' => $knowyou, - '$approve' => L10n::t('Approve'), - '$note' => $it['note'], - '$ignore' => L10n::t('Ignore'), - '$discard' => $discard, - + '$network' => ContactSelector::networkToName($notif['network'], $notif['url']), + '$knowyou' => $knowyou, + '$approve' => L10n::t('Approve'), + '$note' => $notif['note'], + '$ignore' => L10n::t('Ignore'), + '$discard' => $discard, ]); break; } @@ -276,36 +269,24 @@ function notifications_content(App $a) info(L10n::t('No introductions.') . EOL); } - // Normal notifications (no introductions) + // Normal notifications (no introductions) } elseif (!empty($notifs['notifications'])) { - // The template files we need in different cases for formatting the content - $tpl_item_like = 'notifications_likes_item.tpl'; - $tpl_item_dislike = 'notifications_dislikes_item.tpl'; - $tpl_item_attend = 'notifications_attend_item.tpl'; - $tpl_item_attendno = 'notifications_attend_item.tpl'; - $tpl_item_attendmaybe = 'notifications_attend_item.tpl'; - $tpl_item_friend = 'notifications_friends_item.tpl'; - $tpl_item_comment = 'notifications_comments_item.tpl'; - $tpl_item_post = 'notifications_posts_item.tpl'; - $tpl_item_notify = 'notify.tpl'; - // Loop trough ever notification This creates an array with the output html for each // notification and apply the correct template according to the notificationtype (label). - foreach ($notifs['notifications'] as $it) { - + foreach ($notifs['notifications'] as $notif) { // We use the notification label to get the correct template file - $tpl_var_name = 'tpl_item_'.$it['label']; + $tpl_var_name = 'tpl_item_' . $notif['label']; $tpl_notif = get_markup_template($$tpl_var_name); - $notif_content[] = replace_macros($tpl_notif,[ - '$item_label' => $it['label'], - '$item_link' => $it['link'], - '$item_image' => $it['image'], - '$item_url' => $it['url'], - '$item_text' => $it['text'], - '$item_when' => $it['when'], - '$item_ago' => $it['ago'], - '$item_seen' => $it['seen'], + $notif_content[] = replace_macros($tpl_notif, [ + '$item_label' => $notif['label'], + '$item_link' => $notif['link'], + '$item_image' => $notif['image'], + '$item_url' => $notif['url'], + '$item_text' => $notif['text'], + '$item_when' => $notif['when'], + '$item_ago' => $notif['ago'], + '$item_seen' => $notif['seen'], ]); } } else { @@ -313,17 +294,17 @@ function notifications_content(App $a) } $notif_show_lnk = [ - 'href' => ($show ? 'notifications/'.$notifs['ident'] : 'notifications/'.$notifs['ident'].'?show=all' ), + 'href' => ($show ? 'notifications/' . $notifs['ident'] : 'notifications/' . $notifs['ident'] . '?show=all' ), 'text' => ($show ? L10n::t('Show unread') : L10n::t('Show all')), ]; $o .= replace_macros($notif_tpl, [ - '$notif_header' => $notif_header, - '$tabs' => $tabs, - '$notif_content' => $notif_content, + '$notif_header' => $notif_header, + '$tabs' => $tabs, + '$notif_content' => $notif_content, '$notif_nocontent' => $notif_nocontent, - '$notif_show_lnk' => $notif_show_lnk, - '$notif_paginate' => alt_pager($a, count($notif_content)) + '$notif_show_lnk' => $notif_show_lnk, + '$notif_paginate' => alt_pager($a, count($notif_content)) ]); return $o; From 99244d33f504349e4e11e5d3a6d0a3c505f12fee Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 7 Sep 2018 06:10:33 +0000 Subject: [PATCH 55/96] Fix for #5732 - too much links had been detected as photos --- src/Util/ParseUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index dd39a052a0..40cb0b8fc0 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -333,7 +333,7 @@ class ParseUrl } // Prevent to have a photo type without an image - if (empty($siteinfo['image']) && ($siteinfo['type'] == 'photo')) { + if ((empty($siteinfo['image']) || !empty($siteinfo['text'])) && ($siteinfo['type'] == 'photo')) { $siteinfo['type'] = 'link'; } From 71215115ebb1e06b461dc5b0fa7ee4c27d8c665c Mon Sep 17 00:00:00 2001 From: Benjamin Lorteau Date: Fri, 7 Sep 2018 11:15:23 -0400 Subject: [PATCH 56/96] Restore template choice by notification label --- mod/notifications.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mod/notifications.php b/mod/notifications.php index 212736305f..acd49de063 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -274,9 +274,19 @@ function notifications_content(App $a) // Loop trough ever notification This creates an array with the output html for each // notification and apply the correct template according to the notificationtype (label). foreach ($notifs['notifications'] as $notif) { - // We use the notification label to get the correct template file - $tpl_var_name = 'tpl_item_' . $notif['label']; - $tpl_notif = get_markup_template($$tpl_var_name); + $notification_templates = [ + 'like' => 'notifications_likes_item.tpl', + 'dislike' => 'notifications_dislikes_item.tpl', + 'attend' => 'notifications_attend_item.tpl', + 'attendno' => 'notifications_attend_item.tpl', + 'attendmaybe' => 'notifications_attend_item.tpl', + 'friend' => 'notifications_friends_item.tpl', + 'comment' => 'notifications_comments_item.tpl', + 'post' => 'notifications_posts_item.tpl', + 'notify' => 'notify.tpl', + ]; + + $tpl_notif = get_markup_template($notification_templates[$notif['label']]); $notif_content[] = replace_macros($tpl_notif, [ '$item_label' => $notif['label'], From 791a77f44133eb3c7f92575668996bcea1bff5e1 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 8 Sep 2018 02:37:53 -0400 Subject: [PATCH 57/96] Add overwrite parameter to App->loadConfigFile --- src/App.php | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/App.php b/src/App.php index 488c2301b6..0dc4b86b95 100644 --- a/src/App.php +++ b/src/App.php @@ -372,13 +372,13 @@ class App } if (file_exists($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php')) { - $this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php'); + $this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php', true); } } /** * Tries to load the specified configuration file into the App->config array. - * Overwrites previously set values. + * Doesn't overwrite previously set values by default to prevent default config files to supersede DB Config. * * The config format is INI and the template for configuration files is the following: * @@ -391,9 +391,10 @@ class App * // Keep this line * * @param type $filepath + * @param bool $overwrite Force value overwrite if the config key already exists * @throws Exception */ - public function loadConfigFile($filepath) + public function loadConfigFile($filepath, $overwrite = false) { if (!file_exists($filepath)) { throw new Exception('Error parsing non-existent config file ' . $filepath); @@ -409,7 +410,11 @@ class App foreach ($config as $category => $values) { foreach ($values as $key => $value) { - $this->setConfigValue($category, $key, $value); + if ($overwrite) { + $this->setConfigValue($category, $key, $value); + } else { + $this->setDefaultConfigValue($category, $key, $value); + } } } } @@ -427,7 +432,7 @@ class App // Load the local addon config file to overwritten default addon config values if (file_exists($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'addon.ini.php')) { - $this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'addon.ini.php'); + $this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'addon.ini.php', true); } } @@ -1244,6 +1249,20 @@ class App return $return; } + /** + * Sets a default value in the config cache. Ignores already existing keys. + * + * @param string $cat Config category + * @param string $k Config key + * @param mixed $v Default value to set + */ + private function setDefaultConfigValue($cat, $k, $v) + { + if (!isset($this->config[$cat][$k])) { + $this->setConfigValue($cat, $k, $v); + } + } + /** * Sets a value in the config cache. Accepts raw output from the config table * From d581318c7cfd78a94abe1aa5b2578be297601df0 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 9 Sep 2018 06:32:01 +0000 Subject: [PATCH 58/96] Notices come, notices go ... --- mod/message.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/message.php b/mod/message.php index 8c9aa657df..223976ddbe 100644 --- a/mod/message.php +++ b/mod/message.php @@ -488,7 +488,7 @@ function render_messages(array $msg, $t) '$id' => $rr['id'], '$from_name' => $participants, '$from_url' => Contact::magicLink($rr['url']), - '$from_addr' => $contact['addr'], + '$from_addr' => defaults($contact, 'addr', ''), '$sparkle' => ' sparkle', '$from_photo' => ProxyUtils::proxifyUrl($from_photo, false, ProxyUtils::SIZE_THUMB), '$subject' => $subject_e, From 071aff223a672ccf3925bf91c5020bd080e7196f Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 9 Sep 2018 09:51:59 -0400 Subject: [PATCH 59/96] Format source of mod/events --- mod/events.php | 118 +++++++++++++++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 47 deletions(-) diff --git a/mod/events.php b/mod/events.php index c4d40252d3..38b632cf49 100644 --- a/mod/events.php +++ b/mod/events.php @@ -20,7 +20,8 @@ use Friendica\Util\Temporal; require_once 'include/items.php'; -function events_init(App $a) { +function events_init(App $a) +{ if (!local_user()) { return; } @@ -42,7 +43,8 @@ function events_init(App $a) { return; } -function events_post(App $a) { +function events_post(App $a) +{ logger('post: ' . print_r($_REQUEST, true), LOGGER_DATA); @@ -50,8 +52,8 @@ function events_post(App $a) { return; } - $event_id = (x($_POST, 'event_id') ? intval($_POST['event_id']) : 0); - $cid = (x($_POST, 'cid') ? intval($_POST['cid']) : 0); + $event_id = !empty($_POST['event_id']) ? intval($_POST['event_id']) : 0; + $cid = !empty($_POST['cid']) ? intval($_POST['cid']) : 0; $uid = local_user(); $start_text = escape_tags(defaults($_REQUEST, 'start_text', '')); @@ -137,7 +139,7 @@ function events_post(App $a) { $str_contact_deny = !empty($_POST['contact_deny']) ? perms2str($_POST['contact_deny']) : ''; // Undo the pseudo-contact of self, since there are real contacts now - if (strpos($str_contact_allow, '<' . $self . '>') !== false ) { + if (strpos($str_contact_allow, '<' . $self . '>') !== false) { $str_contact_allow = str_replace('<' . $self . '>', '', $str_contact_allow); } // Make sure to set the `private` field as true. This is necessary to @@ -187,8 +189,8 @@ function events_post(App $a) { goaway($_SESSION['return_url']); } -function events_content(App $a) { - +function events_content(App $a) +{ if (!local_user()) { notice(L10n::t('Permission denied.') . EOL); return; @@ -244,7 +246,7 @@ function events_content(App $a) { $mode = 'view'; $y = 0; $m = 0; - $ignored = (x($_REQUEST, 'ignored') ? intval($_REQUEST['ignored']) : 0); + $ignored = !empty($_REQUEST['ignored']) ? intval($_REQUEST['ignored']) : 0; if ($a->argc > 1) { if ($a->argc > 2 && $a->argv[1] == 'event') { @@ -272,7 +274,6 @@ function events_content(App $a) { // The view mode part is similiar to /mod/cal.php if ($mode == 'view') { - $thisyear = DateTimeFormat::localNow('Y'); $thismonth = DateTimeFormat::localNow('m'); if (!$y) { @@ -312,10 +313,10 @@ function events_content(App $a) { $finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59); if ($a->argc > 1 && $a->argv[1] === 'json') { - if (x($_GET, 'start')) { - $start = $_GET['start']; + if (!empty($_GET['start'])) { + $start = $_GET['start']; } - if (x($_GET, 'end')) { + if (!empty($_GET['end'])) { $finish = $_GET['end']; } } @@ -349,7 +350,7 @@ function events_content(App $a) { $r = Event::sortByDate($r); foreach ($r as $rr) { $j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j'); - if (!x($links,$j)) { + if (empty($links[$j])) { $links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j; } } @@ -363,12 +364,12 @@ function events_content(App $a) { $events = Event::prepareListForTemplate($r); } - if ($a->argc > 1 && $a->argv[1] === 'json'){ + if ($a->argc > 1 && $a->argv[1] === 'json') { echo json_encode($events); killme(); } - if (x($_GET, 'id')) { + if (!empty($_GET['id'])) { $tpl = get_markup_template("event.tpl"); } else { $tpl = get_markup_template("events_js.tpl"); @@ -378,7 +379,7 @@ function events_content(App $a) { foreach ($events as $key => $event) { $event_item = []; foreach ($event['item'] as $k => $v) { - $k = str_replace('-' ,'_', $k); + $k = str_replace('-', '_', $k); $event_item[$k] = $v; } $events[$key]['item'] = $event_item; @@ -403,7 +404,7 @@ function events_content(App $a) { '$list' => L10n::t('list'), ]); - if (x($_GET, 'id')) { + if (!empty($_GET['id'])) { echo $o; killme(); } @@ -428,41 +429,45 @@ function events_content(App $a) { } // In case of an error the browser is redirected back here, with these parameters filled in with the previous values - if (x($_REQUEST, 'nofinish')) {$orig_event['nofinish'] = $_REQUEST['nofinish'];} - if (x($_REQUEST, 'adjust')) {$orig_event['adjust'] = $_REQUEST['adjust'];} - if (x($_REQUEST, 'summary')) {$orig_event['summary'] = $_REQUEST['summary'];} - if (x($_REQUEST, 'description')) {$orig_event['description'] = $_REQUEST['description'];} - if (x($_REQUEST, 'location')) {$orig_event['location'] = $_REQUEST['location'];} - if (x($_REQUEST, 'start')) {$orig_event['start'] = $_REQUEST['start'];} - if (x($_REQUEST, 'finish')) {$orig_event['finish'] = $_REQUEST['finish'];} - if (x($_REQUEST,'finish')) $orig_event['finish'] = $_REQUEST['finish']; + if (!empty($_REQUEST['nofinish'])) {$orig_event['nofinish'] = $_REQUEST['nofinish'];} + if (!empty($_REQUEST['adjust'])) {$orig_event['adjust'] = $_REQUEST['adjust'];} + if (!empty($_REQUEST['summary'])) {$orig_event['summary'] = $_REQUEST['summary'];} + if (!empty($_REQUEST['description'])) {$orig_event['description'] = $_REQUEST['description'];} + if (!empty($_REQUEST['location'])) {$orig_event['location'] = $_REQUEST['location'];} + if (!empty($_REQUEST['start'])) {$orig_event['start'] = $_REQUEST['start'];} + if (!empty($_REQUEST['finish'])) {$orig_event['finish'] = $_REQUEST['finish'];} - $n_checked = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : ''); - $a_checked = ((x($orig_event) && $orig_event['adjust']) ? ' checked="checked" ' : ''); + $n_checked = (!empty($orig_event['nofinish']) ? ' checked="checked" ' : ''); + $a_checked = (!empty($orig_event['adjust']) ? ' checked="checked" ' : ''); - $t_orig = (x($orig_event) ? $orig_event['summary'] : ''); - $d_orig = (x($orig_event) ? $orig_event['desc'] : ''); - $l_orig = (x($orig_event) ? $orig_event['location'] : ''); - $eid = (x($orig_event) ? $orig_event['id'] : 0); - $cid = (x($orig_event) ? $orig_event['cid'] : 0); - $uri = (x($orig_event) ? $orig_event['uri'] : ''); + $t_orig = !empty($orig_event) ? $orig_event['summary'] : ''; + $d_orig = !empty($orig_event) ? $orig_event['desc'] : ''; + $l_orig = !empty($orig_event) ? $orig_event['location'] : ''; + $eid = !empty($orig_event) ? $orig_event['id'] : 0; + $cid = !empty($orig_event) ? $orig_event['cid'] : 0; + $uri = !empty($orig_event) ? $orig_event['uri'] : ''; $sh_disabled = ''; - $sh_checked = ''; + $sh_checked = ''; - if (x($orig_event)) { - $sh_checked = (($orig_event['allow_cid'] === '<' . local_user() . '>' && !$orig_event['allow_gid'] && !$orig_event['deny_cid'] && !$orig_event['deny_gid']) ? '' : ' checked="checked" '); + if (!empty($orig_event) + && ($orig_event['allow_cid'] !== '<' . local_user() . '>' + || $orig_event['allow_gid'] + || $orig_event['deny_cid'] + || $orig_event['deny_gid'])) + { + $sh_checked = ' checked="checked" '; } if ($cid || $mode === 'edit') { $sh_disabled = 'disabled="disabled"'; } - $sdt = (x($orig_event) ? $orig_event['start'] : 'now'); - $fdt = (x($orig_event) ? $orig_event['finish'] : 'now'); + $sdt = !empty($orig_event) ? $orig_event['start'] : 'now'; + $fdt = !empty($orig_event) ? $orig_event['finish'] : 'now'; $tz = date_default_timezone_get(); - if (x($orig_event)) { + if (!empty($orig_event)) { $tz = ($orig_event['adjust'] ? date_default_timezone_get() : 'UTC'); } @@ -470,15 +475,15 @@ function events_content(App $a) { $smonth = DateTimeFormat::convert($sdt, $tz, 'UTC', 'm'); $sday = DateTimeFormat::convert($sdt, $tz, 'UTC', 'd'); - $shour = (x($orig_event) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'H') : '00'); - $sminute = (x($orig_event) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'i') : '00'); + $shour = !empty($orig_event) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'H') : '00'; + $sminute = !empty($orig_event) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'i') : '00'; $fyear = DateTimeFormat::convert($fdt, $tz, 'UTC', 'Y'); $fmonth = DateTimeFormat::convert($fdt, $tz, 'UTC', 'm'); $fday = DateTimeFormat::convert($fdt, $tz, 'UTC', 'd'); - $fhour = (x($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'H') : '00'); - $fminute = (x($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : '00'); + $fhour = !empty($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'H') : '00'; + $fminute = !empty($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : '00'; $perms = ACL::getDefaultUserPermissions($orig_event); @@ -497,7 +502,7 @@ function events_content(App $a) { $tpl = get_markup_template('event_form.tpl'); - $o .= replace_macros($tpl,[ + $o .= replace_macros($tpl, [ '$post' => System::baseUrl() . '/events', '$eid' => $eid, '$cid' => $cid, @@ -511,11 +516,31 @@ function events_content(App $a) { '$title' => L10n::t('Event details'), '$desc' => L10n::t('Starting date and Title are required.'), '$s_text' => L10n::t('Event Starts:') . ' *', - '$s_dsel' => Temporal::getDateTimeField(new DateTime(), DateTime::createFromFormat('Y', $syear+5), DateTime::createFromFormat('Y-m-d H:i', "$syear-$smonth-$sday $shour:$sminute"), L10n::t('Event Starts:'), 'start_text', true, true, '', '', true), + '$s_dsel' => Temporal::getDateTimeField( + new DateTime(), + DateTime::createFromFormat('Y', $syear+5), + DateTime::createFromFormat('Y-m-d H:i', "$syear-$smonth-$sday $shour:$sminute"), + L10n::t('Event Starts:'), + 'start_text', + true, + true, + '', + '', + true + ), '$n_text' => L10n::t('Finish date/time is not known or not relevant'), '$n_checked' => $n_checked, '$f_text' => L10n::t('Event Finishes:'), - '$f_dsel' => Temporal::getDateTimeField(new DateTime(), DateTime::createFromFormat('Y', $fyear+5), DateTime::createFromFormat('Y-m-d H:i', "$fyear-$fmonth-$fday $fhour:$fminute"), L10n::t('Event Finishes:'), 'finish_text', true, true, 'start_text'), + '$f_dsel' => Temporal::getDateTimeField( + new DateTime(), + DateTime::createFromFormat('Y', $fyear+5), + DateTime::createFromFormat('Y-m-d H:i', "$fyear-$fmonth-$fday $fhour:$fminute"), + L10n::t('Event Finishes:'), + 'finish_text', + true, + true, + 'start_text' + ), '$a_text' => L10n::t('Adjust for viewer timezone'), '$a_checked' => $a_checked, '$d_text' => L10n::t('Description:'), @@ -536,7 +561,6 @@ function events_content(App $a) { '$basic' => L10n::t('Basic'), '$advanced' => L10n::t('Advanced'), '$permissions' => L10n::t('Permissions'), - ]); return $o; From 4edbea3ed01f0891b22b44f74efb6990f9deac6c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 9 Sep 2018 09:54:54 -0400 Subject: [PATCH 60/96] Fix JS error when no acl is defined --- view/js/main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/view/js/main.js b/view/js/main.js index 4788d90a83..4ccbc8044e 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -305,7 +305,9 @@ $(function() { // Asynchronous calls are deferred until the very end of the page load to ease on slower connections window.addEventListener("load", function(){ NavUpdate(); - acl.get(0, 100); + if (typeof acl !== 'undefined') { + acl.get(0, 100); + } }); // Allow folks to stop the ajax page updates with the pause/break key From 11a3b45957c880108aeaeddf4f8bbd3ae64c5a0f Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 9 Sep 2018 10:10:17 -0400 Subject: [PATCH 61/96] [frio] Fix ACL selection in new event modal - Fix this.allow_cid.push isn't a function error --- view/theme/frio/js/event_edit.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/view/theme/frio/js/event_edit.js b/view/theme/frio/js/event_edit.js index da0837223a..628835a5f0 100644 --- a/view/theme/frio/js/event_edit.js +++ b/view/theme/frio/js/event_edit.js @@ -1,7 +1,7 @@ $(document).ready(function() { // Go to the permissions tab if the checkbox is checked. $('body').on("click", "#id_share", function() { - if ($('#id_share').is(':checked') && !( $('#id_share').attr("disabled"))) { + if ($('#id_share').is(':checked') && !( $('#id_share').attr("disabled"))) { $('#acl-wrapper').show(); $("a#event-perms-lnk").parent("li").show(); toggleEventNav("a#event-perms-lnk"); @@ -54,20 +54,19 @@ $(document).ready(function() { // without page reloading (e.g. closing an old modal and open a new modal). // Otherwise we wouldn't get the ACL data. /// @todo: Try to implement some kind of ACL reloading in acl.js. - if (typeof acl !== "undefined") { - var eventPerms = document.getElementById('event-edit-form'); - acl = new ACL( - baseurl + "/acl", - [ - eventPerms.dataset.allow_cid, - eventPerms.dataset.allow_gid, - eventPerms.dataset.deny_cid, - eventPerms.dataset.deny_gid - ] - ); - } + var eventPerms = document.getElementById('event-edit-form'); + acl = new ACL( + baseurl + "/acl", + [ + JSON.parse(eventPerms.dataset.allow_cid), + JSON.parse(eventPerms.dataset.allow_gid), + JSON.parse(eventPerms.dataset.deny_cid), + JSON.parse(eventPerms.dataset.deny_gid) + ] + ); + acl.get(0, 100); }); // Load the html of the actual event and incect the output to the @@ -81,7 +80,7 @@ function doEventPreview() { } -// The following functions show/hide the specific event-edit content +// The following functions show/hide the specific event-edit content // in dependence of the selected nav. function eventAclActive() { $("#event-edit-wrapper, #event-preview, #event-desc-wrapper").hide(); From e461474290f87a1e783100435183cf67217dce1b Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 9 Sep 2018 18:33:14 -0400 Subject: [PATCH 62/96] Fix count being called on the wrong variable in mod/notes --- mod/notes.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mod/notes.php b/mod/notes.php index 68a870e9d6..01f283870e 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -70,8 +70,11 @@ function notes_content(App $a, $update = false) $count = 0; if (DBA::isResult($r)) { - $count = count($r); - $o .= conversation($a, DBA::toArray($r), 'notes', $update); + $notes = DBA::toArray($r); + + $count = count($notes); + + $o .= conversation($a, $notes, 'notes', $update); } $o .= alt_pager($a, $count); From 8b96a53fba794bfd11738772b51015a0390c056b Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 11 Sep 2018 04:10:11 +0000 Subject: [PATCH 63/96] Burn notices, burn --- mod/bookmarklet.php | 4 ++++ mod/photos.php | 6 ++++-- mod/salmon.php | 8 ++++---- mod/webfinger.php | 2 +- src/Model/Profile.php | 2 +- src/Network/Probe.php | 44 +++++++++++++++++++++---------------------- 6 files changed, 36 insertions(+), 30 deletions(-) diff --git a/mod/bookmarklet.php b/mod/bookmarklet.php index 21b2039c58..e1ae9aa64c 100644 --- a/mod/bookmarklet.php +++ b/mod/bookmarklet.php @@ -30,6 +30,10 @@ function bookmarklet_content(App $a) $page = normalise_link(System::baseUrl() . "/bookmarklet"); if (!strstr($referer, $page)) { + if (empty($_REQUEST["url"])) { + System::httpExit(400, ["title" => L10n::t('Bad Request')]); + } + $content = add_page_info($_REQUEST["url"]); $x = [ diff --git a/mod/photos.php b/mod/photos.php index 16af455997..e205d72c6d 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -212,7 +212,7 @@ function photos_post(App $a) } // Check if the user has responded to a delete confirmation query - if ($_REQUEST['canceled']) { + if (!empty($_REQUEST['canceled'])) { goaway($_SESSION['photo_return']); } @@ -762,12 +762,14 @@ function photos_post(App $a) $filesize = $ret['filesize']; $type = $ret['type']; $error = UPLOAD_ERR_OK; - } else { + } elseif (!empty($_FILES['userfile'])) { $src = $_FILES['userfile']['tmp_name']; $filename = basename($_FILES['userfile']['name']); $filesize = intval($_FILES['userfile']['size']); $type = $_FILES['userfile']['type']; $error = $_FILES['userfile']['error']; + } else { + $error = UPLOAD_ERR_NO_FILE; } if ($error !== UPLOAD_ERR_OK) { diff --git a/mod/salmon.php b/mod/salmon.php index d07b06004d..bd4b3773cb 100644 --- a/mod/salmon.php +++ b/mod/salmon.php @@ -41,14 +41,14 @@ function salmon_post(App $a, $xml = '') { $base = null; // figure out where in the DOM tree our data is hiding - if($dom->provenance->data) + if (!empty($dom->provenance->data)) $base = $dom->provenance; - elseif($dom->env->data) + elseif (!empty($dom->env->data)) $base = $dom->env; - elseif($dom->data) + elseif (!empty($dom->data)) $base = $dom; - if(! $base) { + if (empty($base)) { logger('unable to locate salmon data in xml '); System::httpExit(400); } diff --git a/mod/webfinger.php b/mod/webfinger.php index 6f49a8f28c..4f23db6d8f 100644 --- a/mod/webfinger.php +++ b/mod/webfinger.php @@ -23,7 +23,7 @@ function webfinger_content(App $a) $o = '

Webfinger Diagnostic

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

'; diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 29bc7e680d..3a014517da 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -361,7 +361,7 @@ class Profile if ($r) { $remote_url = $r[0]['url']; $message_path = preg_replace('=(.*)/profile/(.*)=ism', '$1/message/new/', $remote_url); - $wallmessage_link = $message_path . base64_encode($profile['addr']); + $wallmessage_link = $message_path . base64_encode(defaults($profile, 'addr', '')); } else if (!empty($profile['nickname'])) { $wallmessage_link = 'wallmessage/' . $profile['nickname']; } diff --git a/src/Network/Probe.php b/src/Network/Probe.php index af2d1c9a16..75231f44ff 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -967,23 +967,23 @@ class Probe $hcard_url = ""; $data = []; foreach ($webfinger["links"] as $link) { - if (($link["rel"] == NAMESPACE_DFRN) && ($link["href"] != "")) { + if (($link["rel"] == NAMESPACE_DFRN) && !empty($link["href"])) { $data["network"] = Protocol::DFRN; - } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) { $data["poll"] = $link["href"]; - } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && ($link["type"] == "text/html") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) { $data["url"] = $link["href"]; - } elseif (($link["rel"] == "http://microformats.org/profile/hcard") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) { $hcard_url = $link["href"]; - } elseif (($link["rel"] == NAMESPACE_POCO) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_POCO) && !empty($link["href"])) { $data["poco"] = $link["href"]; - } elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && !empty($link["href"])) { $data["photo"] = $link["href"]; - } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && !empty($link["href"])) { $data["baseurl"] = trim($link["href"], '/'); - } elseif (($link["rel"] == "http://joindiaspora.com/guid") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) { $data["guid"] = $link["href"]; - } elseif (($link["rel"] == "diaspora-public-key") && ($link["href"] != "")) { + } elseif (($link["rel"] == "diaspora-public-key") && !empty($link["href"])) { $data["pubkey"] = base64_decode($link["href"]); //if (strstr($data["pubkey"], 'RSA ') || ($link["type"] == "RSA")) @@ -1170,21 +1170,21 @@ class Probe $hcard_url = ""; $data = []; foreach ($webfinger["links"] as $link) { - if (($link["rel"] == "http://microformats.org/profile/hcard") && ($link["href"] != "")) { + if (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) { $hcard_url = $link["href"]; - } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && !empty($link["href"])) { $data["baseurl"] = trim($link["href"], '/'); - } elseif (($link["rel"] == "http://joindiaspora.com/guid") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) { $data["guid"] = $link["href"]; - } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && ($link["type"] == "text/html") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) { $data["url"] = $link["href"]; - } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) { $data["poll"] = $link["href"]; - } elseif (($link["rel"] == NAMESPACE_POCO) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_POCO) && !empty($link["href"])) { $data["poco"] = $link["href"]; - } elseif (($link["rel"] == "salmon") && ($link["href"] != "")) { + } elseif (($link["rel"] == "salmon") && !empty($link["href"])) { $data["notify"] = $link["href"]; - } elseif (($link["rel"] == "diaspora-public-key") && ($link["href"] != "")) { + } elseif (($link["rel"] == "diaspora-public-key") && !empty($link["href"])) { $data["pubkey"] = base64_decode($link["href"]); //if (strstr($data["pubkey"], 'RSA ') || ($link["type"] == "RSA")) @@ -1272,15 +1272,15 @@ class Probe if (is_array($webfinger["links"])) { foreach ($webfinger["links"] as $link) { if (($link["rel"] == "http://webfinger.net/rel/profile-page") - && ($link["type"] == "text/html") + && (defaults($link, "type", "") == "text/html") && ($link["href"] != "") ) { $data["url"] = $link["href"]; - } elseif (($link["rel"] == "salmon") && ($link["href"] != "")) { + } elseif (($link["rel"] == "salmon") && !empty($link["href"])) { $data["notify"] = $link["href"]; - } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) { $data["poll"] = $link["href"]; - } elseif (($link["rel"] == "magic-public-key") && ($link["href"] != "")) { + } elseif (($link["rel"] == "magic-public-key") && !empty($link["href"])) { $pubkey = $link["href"]; if (substr($pubkey, 0, 5) === 'data:') { @@ -1436,7 +1436,7 @@ class Probe $data = []; foreach ($webfinger["links"] as $link) { if (($link["rel"] == "http://webfinger.net/rel/profile-page") - && ($link["type"] == "text/html") + && (defaults($link, "type", "") == "text/html") && ($link["href"] != "") ) { $data["url"] = $link["href"]; From f566db52d3b915871fb7c639130daca1746d3eaa Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 11 Sep 2018 08:04:14 +0000 Subject: [PATCH 64/96] And more notices ... --- src/Protocol/PortableContact.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 20ee77a07c..2939f69e55 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -1157,9 +1157,9 @@ class PortableContact if (isset($data['version'])) { $platform = "Mastodon"; - $version = $data['version']; - $site_name = $data['title']; - $info = $data['description']; + $version = defaults($data, 'version', ''); + $site_name = defaults($data, 'title', ''); + $info = defaults($data, 'description', ''); $network = Protocol::OSTATUS; } From 7529fc61dd9169368224a092bcdf7d3cfeee1982 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 11 Sep 2018 19:54:45 -0400 Subject: [PATCH 65/96] Fix introductions notifications links --- mod/notifications.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mod/notifications.php b/mod/notifications.php index acd49de063..3934a32357 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -132,6 +132,11 @@ function notifications_content(App $a) $notif_tpl = get_markup_template('notifications.tpl'); + $notif_show_lnk = [ + 'href' => ($show ? 'notifications/' . $notifs['ident'] : 'notifications/' . $notifs['ident'] . '?show=all' ), + 'text' => ($show ? L10n::t('Show unread') : L10n::t('Show all')), + ]; + // Process the data for template creation if (defaults($notifs, 'ident', '') === 'introductions') { $sugg = get_markup_template('suggestions.tpl'); @@ -303,11 +308,6 @@ function notifications_content(App $a) $notif_nocontent = L10n::t('No more %s notifications.', $notifs['ident']); } - $notif_show_lnk = [ - 'href' => ($show ? 'notifications/' . $notifs['ident'] : 'notifications/' . $notifs['ident'] . '?show=all' ), - 'text' => ($show ? L10n::t('Show unread') : L10n::t('Show all')), - ]; - $o .= replace_macros($notif_tpl, [ '$notif_header' => $notif_header, '$tabs' => $tabs, From 96d10c25e359b74d4b0bcab08c234625c0ecf031 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 12 Sep 2018 06:05:14 +0000 Subject: [PATCH 66/96] Issue 5733: Removing contacts does work now on the same machine as well --- mod/contacts.php | 7 +++++++ mod/dfrn_notify.php | 14 +++++++------- src/Protocol/DFRN.php | 5 +---- src/Worker/RemoveContact.php | 4 ++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/mod/contacts.php b/mod/contacts.php index 68f68fec3b..69bf2b47f9 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -47,6 +47,11 @@ function contacts_init(App $a) if (!DBA::isResult($contact)) { $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => 0]); } + + // Don't display contacts that are about to be deleted + if (($contact['network'] == Protocol::PHANTOM)) { + $contact = false; + } } if (DBA::isResult($contact)) { @@ -719,6 +724,8 @@ function contacts_content(App $a, $update = 0) $sql_extra = " AND `blocked` = 0 "; } + $sql_extra .= sprintf(" AND `network` != '%s' ", Protocol::PHANTOM); + $search = x($_GET, 'search') ? notags(trim($_GET['search'])) : ''; $nets = x($_GET, 'nets' ) ? notags(trim($_GET['nets'])) : ''; diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 666c388a4a..2f76b59b97 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -79,13 +79,13 @@ function dfrn_notify_post(App $a) { $condition = []; switch ($direction) { case (-1): - $condition = ["`issued-id` = ? OR `dfrn-id` = ?", $dfrn_id, $dfrn_id]; + $condition = ["(`issued-id` = ? OR `dfrn-id` = ?) AND `uid` = ?", $dfrn_id, $dfrn_id, $user['uid']]; break; case 0: - $condition = ['issued-id' => $dfrn_id, 'duplex' => true]; + $condition = ['issued-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']]; break; case 1: - $condition = ['dfrn-id' => $dfrn_id, 'duplex' => true]; + $condition = ['dfrn-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']]; break; default: System::xmlExit(3, 'Invalid direction'); @@ -287,15 +287,15 @@ function dfrn_notify_content(App $a) { $condition = []; switch ($direction) { case (-1): - $condition = ["`issued-id` = ? OR `dfrn-id` = ?", $dfrn_id, $dfrn_id]; + $condition = ["(`issued-id` = ? OR `dfrn-id` = ?) AND `uid` = ?", $dfrn_id, $dfrn_id, $user['uid']]; $my_id = $dfrn_id; break; case 0: - $condition = ['issued-id' => $dfrn_id, 'duplex' => true]; + $condition = ['issued-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']]; $my_id = '1:' . $dfrn_id; break; case 1: - $condition = ['dfrn-id' => $dfrn_id, 'duplex' => true]; + $condition = ['dfrn-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']]; $my_id = '0:' . $dfrn_id; break; default: @@ -326,7 +326,7 @@ function dfrn_notify_content(App $a) { $pub_key = trim($importer['cpubkey']); $dplx = intval($importer['duplex']); - if (($dplx && strlen($prv_key)) || (strlen($prv_key) && !strlen($pub_key))) { + if (!empty($prv_key) && empty($pub_key)) { openssl_private_encrypt($hash, $challenge, $prv_key); openssl_private_encrypt($id_str, $encrypted_id, $prv_key); } elseif (strlen($pub_key)) { diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index b207c3ca87..3832e38e16 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -1280,10 +1280,7 @@ class DFRN } } - if (($contact['duplex'] && strlen($contact['pubkey'])) - || ($owner['page-flags'] == Contact::PAGE_COMMUNITY && strlen($contact['pubkey'])) - || ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey'])) - ) { + if (empty($contact['prvkey']) && !empty($contact['pubkey'])) { openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']); openssl_public_decrypt($challenge, $postvars['challenge'], $contact['pubkey']); } else { diff --git a/src/Worker/RemoveContact.php b/src/Worker/RemoveContact.php index b07661b7a9..8f986eab11 100644 --- a/src/Worker/RemoveContact.php +++ b/src/Worker/RemoveContact.php @@ -13,8 +13,8 @@ require_once 'include/dba.php'; class RemoveContact { public static function execute($id) { - // Only delete if the contact is archived - $condition = ['archive' => true, 'network' => Protocol::PHANTOM, 'id' => $id]; + // Only delete if the contact is to be deleted + $condition = ['network' => Protocol::PHANTOM, 'id' => $id]; $r = DBA::exists('contact', $condition); if (!DBA::isResult($r)) { return; From 7daa46503d3f0cd970fce3769ad1e79c9cecc0ef Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 12 Sep 2018 06:13:04 +0000 Subject: [PATCH 67/96] Don't risk incompatibilities --- mod/dfrn_notify.php | 2 +- src/Protocol/DFRN.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 2f76b59b97..8a53ac09b6 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -326,7 +326,7 @@ function dfrn_notify_content(App $a) { $pub_key = trim($importer['cpubkey']); $dplx = intval($importer['duplex']); - if (!empty($prv_key) && empty($pub_key)) { + if (($dplx && strlen($prv_key)) || (strlen($prv_key) && !strlen($pub_key))) { openssl_private_encrypt($hash, $challenge, $prv_key); openssl_private_encrypt($id_str, $encrypted_id, $prv_key); } elseif (strlen($pub_key)) { diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 3832e38e16..b207c3ca87 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -1280,7 +1280,10 @@ class DFRN } } - if (empty($contact['prvkey']) && !empty($contact['pubkey'])) { + if (($contact['duplex'] && strlen($contact['pubkey'])) + || ($owner['page-flags'] == Contact::PAGE_COMMUNITY && strlen($contact['pubkey'])) + || ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey'])) + ) { openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']); openssl_public_decrypt($challenge, $postvars['challenge'], $contact['pubkey']); } else { From c4825a8b5305df009fb548321da423feb112cf20 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 12 Sep 2018 18:49:36 +0000 Subject: [PATCH 68/96] Fixing parentheses --- mod/contacts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/contacts.php b/mod/contacts.php index 69bf2b47f9..1604f0b660 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -49,7 +49,7 @@ function contacts_init(App $a) } // Don't display contacts that are about to be deleted - if (($contact['network'] == Protocol::PHANTOM)) { + if ($contact['network'] == Protocol::PHANTOM) { $contact = false; } } From 63b5cb4fc688f9da2984c4c10439dba3a432633a Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 13 Sep 2018 15:46:37 +0000 Subject: [PATCH 69/96] Issue 5721: Temporarily deactivate the picture upload from private mails --- view/js/main.js | 5 +++++ view/theme/frio/templates/prv_message.tpl | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/view/js/main.js b/view/js/main.js index 4ccbc8044e..83086c82b0 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -81,6 +81,11 @@ $(function() { Dialog.doImageBrowser("comment", id); return; } + + if (bbcode == "imgprv") { + bbcode = "img"; + } + insertFormatting(bbcode, id); }); diff --git a/view/theme/frio/templates/prv_message.tpl b/view/theme/frio/templates/prv_message.tpl index 4c90dcae6d..9077c4d4c1 100644 --- a/view/theme/frio/templates/prv_message.tpl +++ b/view/theme/frio/templates/prv_message.tpl @@ -33,7 +33,7 @@