From 38a45d325fbd9e71f9c274bd1bee70a3bc6a2eea Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 2 Jan 2015 00:01:17 +0100 Subject: [PATCH 01/83] See issue 1218: generate $argv and $argc from $_SERVER if it wasn't defined. --- boot.php | 8 ++++++++ include/dbupdate.php | 3 +-- testargs.php | 10 ++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/boot.php b/boot.php index 34836a97aa..fa4f8b072e 100644 --- a/boot.php +++ b/boot.php @@ -2388,3 +2388,11 @@ if(!function_exists('exif_imagetype')) { return($size[2]); } } + +// See https://github.com/friendica/friendica/issues/1218 +// Try to get the values for $argv and $argc via the $_SERVER array +if (!isset($argv) && array_key_exists('argv', $_SERVER)) + $argv = $_SERVER['argv']; + +if (!isset($argc) && array_key_exists('argc', $_SERVER)) + $argv = $_SERVER['argc']; diff --git a/include/dbupdate.php b/include/dbupdate.php index eb2eda48da..3fcd6b7f05 100644 --- a/include/dbupdate.php +++ b/include/dbupdate.php @@ -8,7 +8,7 @@ function dbupdate_run(&$argv, &$argc) { if(is_null($a)){ $a = new App; } - + if(is_null($db)) { @include(".htconfig.php"); require_once("include/dba.php"); @@ -26,4 +26,3 @@ if (array_search(__file__,get_included_files())===0){ dbupdate_run($argv,$argc); killme(); } - diff --git a/testargs.php b/testargs.php index 4c9bce4e93..8c6da430e9 100644 --- a/testargs.php +++ b/testargs.php @@ -8,14 +8,16 @@ * During installation we need to check if register_argc_argv is * enabled for the command line PHP processor, because otherwise * deliveries will fail. So we will do a shell exec of php and - * execute this file with a command line argument, and see if it - * echoes the argument back to us. Otherwise notify the person + * execute this file with a command line argument, and see if it + * echoes the argument back to us. Otherwise notify the person * that their installation doesn't meet the system requirements. * - */ + */ + - if(($argc > 1) && isset($argv[1])) echo $argv[1]; +elseif(($_SERVER["argc"] > 1) && isset($_SERVER["argv"][1])) + echo $_SERVER["argv"][1]; else echo ''; From bf147ca9d96df6e3ab38001b34349dae0e74ed45 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 2 Jan 2015 01:43:31 +0100 Subject: [PATCH 02/83] Hashtags in attached link description now don't create misformatted text anymore. --- include/bbcode.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index 724b8e2fdd..1f635e051b 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -41,7 +41,9 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) { if ($matches[1] != "") $title = $matches[1]; - $title = htmlentities($title, ENT_QUOTES, 'UTF-8', false); + //$title = htmlentities($title, ENT_QUOTES, 'UTF-8', false); + $title = bbcode(html_entity_decode($title), false, false, true); + $title = str_replace(array("[", "]"), array("[", "]"), $title); $image = ""; if ($type != "video") { @@ -1171,6 +1173,6 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $a->save_timestamp($stamp1, "parser"); - return $Text; + return trim($Text); } ?> From b5beb4c69ae8b762365291ec0cc174c6b03412d0 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 2 Jan 2015 07:50:21 +0100 Subject: [PATCH 03/83] Litte typo ... --- boot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot.php b/boot.php index fa4f8b072e..258fd49ee6 100644 --- a/boot.php +++ b/boot.php @@ -2395,4 +2395,4 @@ if (!isset($argv) && array_key_exists('argv', $_SERVER)) $argv = $_SERVER['argv']; if (!isset($argc) && array_key_exists('argc', $_SERVER)) - $argv = $_SERVER['argc']; + $argc = $_SERVER['argc']; From 882f9c83d671fe2c4cf6e83d57c50e85e4baa9cd Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Fri, 2 Jan 2015 08:26:08 +0100 Subject: [PATCH 04/83] FR update to the strings --- view/fr/messages.po | 22 +++++++++++----------- view/fr/strings.php | 18 +++++++++--------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/view/fr/messages.po b/view/fr/messages.po index 78fe85714d..593c174ce7 100644 --- a/view/fr/messages.po +++ b/view/fr/messages.po @@ -9,7 +9,7 @@ # Lionel Triay , 2013 # Marquis_de_Carabas , 2012 # Olivier , 2011-2012 -# Sylvain Lagacé, 2014 +# Sylvain Lagacé, 2014-2015 # tomamplius , 2014 # Tubuntu , 2013-2014 msgid "" @@ -17,7 +17,7 @@ msgstr "" "Project-Id-Version: friendica\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2014-10-22 10:05+0200\n" -"PO-Revision-Date: 2014-12-30 15:30+0000\n" +"PO-Revision-Date: 2015-01-02 00:18+0000\n" "Last-Translator: Sylvain Lagacé\n" "Language-Team: French (http://www.transifex.com/projects/p/friendica/language/fr/)\n" "MIME-Version: 1.0\n" @@ -3194,7 +3194,7 @@ msgstr "Fichier du compte" msgid "" "To export your account, go to \"Settings->Export your personal data\" and " "select \"Export account\"" -msgstr "" +msgstr "Pour exporter votre compte, allez dans \"Paramètres> Exporter vos données personnelles\" et sélectionnez \"exportation de compte\"" #: ../../mod/subthread.php:103 #, php-format @@ -3829,11 +3829,11 @@ msgstr "" #: ../../mod/settings.php:966 msgid "User Types" -msgstr "" +msgstr "Types d'utilisateurs" #: ../../mod/settings.php:967 msgid "Community Types" -msgstr "" +msgstr "Genre de communautés" #: ../../mod/settings.php:968 msgid "Normal Account Page" @@ -4247,7 +4247,7 @@ msgstr "%1$s a mis à jour son %2$s, en modifiant %3$s." #: ../../mod/profiles.php:617 msgid "Hide contacts and friends:" -msgstr "" +msgstr "Cacher mes contacts et amis:" #: ../../mod/profiles.php:622 msgid "Hide your contact/friend list from viewers of this profile?" @@ -4279,23 +4279,23 @@ msgstr "Supprimer ce profil" #: ../../mod/profiles.php:651 msgid "Basic information" -msgstr "" +msgstr "Information de base" #: ../../mod/profiles.php:652 msgid "Profile picture" -msgstr "" +msgstr "Image de profil" #: ../../mod/profiles.php:654 msgid "Preferences" -msgstr "" +msgstr "Préférences" #: ../../mod/profiles.php:655 msgid "Status information" -msgstr "" +msgstr "Information sur le statut" #: ../../mod/profiles.php:656 msgid "Additional information" -msgstr "" +msgstr "Information additionnelle" #: ../../mod/profiles.php:659 msgid "Profile Name:" diff --git a/view/fr/strings.php b/view/fr/strings.php index 66ffd6f63f..45bd95a726 100644 --- a/view/fr/strings.php +++ b/view/fr/strings.php @@ -707,7 +707,7 @@ $a->strings["You can import an account from another Friendica server."] = "Vous $a->strings["You need to export your account from the old server and upload it here. We will recreate your old account here with all your contacts. We will try also to inform your friends that you moved here."] = "Vous devez exporter votre compte à partir de l'ancien serveur et le téléverser ici. Nous recréerons votre ancien compte ici avec tous vos contacts. Nous tenterons également d'informer vos amis que vous avez déménagé ici."; $a->strings["This feature is experimental. We can't import contacts from the OStatus network (statusnet/identi.ca) or from Diaspora"] = "Cette fonctionnalité est expérimentale. Nous ne pouvons importer les contacts des réseaux OStatus (statusnet/identi.ca) ou Diaspora"; $a->strings["Account file"] = "Fichier du compte"; -$a->strings["To export your account, go to \"Settings->Export your personal data\" and select \"Export account\""] = ""; +$a->strings["To export your account, go to \"Settings->Export your personal data\" and select \"Export account\""] = "Pour exporter votre compte, allez dans \"Paramètres> Exporter vos données personnelles\" et sélectionnez \"exportation de compte\""; $a->strings["%1\$s is following %2\$s's %3\$s"] = "%1\$s suit les %3\$s de %2\$s"; $a->strings["Friends of %s"] = "Amis de %s"; $a->strings["No friends to display."] = "Pas d'amis à afficher."; @@ -847,8 +847,8 @@ $a->strings["Don't show emoticons"] = "Ne pas afficher les émoticônes (smileys $a->strings["Don't show notices"] = "Ne plus afficher les avis"; $a->strings["Infinite scroll"] = "Défilement infini"; $a->strings["Automatic updates only at the top of the network page"] = ""; -$a->strings["User Types"] = ""; -$a->strings["Community Types"] = ""; +$a->strings["User Types"] = "Types d'utilisateurs"; +$a->strings["Community Types"] = "Genre de communautés"; $a->strings["Normal Account Page"] = "Compte normal"; $a->strings["This account is a normal personal profile"] = "Ce compte correspond à un profil normal, pour une seule personne (physique, généralement)"; $a->strings["Soapbox Page"] = "Compte \"boîte à savon\""; @@ -950,7 +950,7 @@ $a->strings["public profile"] = "profil public"; $a->strings["%1\$s changed %2\$s to “%3\$s”"] = "%1\$s a changé %2\$s en “%3\$s”"; $a->strings[" - Visit %1\$s's %2\$s"] = "Visiter le %2\$s de %1\$s"; $a->strings["%1\$s has an updated %2\$s, changing %3\$s."] = "%1\$s a mis à jour son %2\$s, en modifiant %3\$s."; -$a->strings["Hide contacts and friends:"] = ""; +$a->strings["Hide contacts and friends:"] = "Cacher mes contacts et amis:"; $a->strings["Hide your contact/friend list from viewers of this profile?"] = "Cacher ma liste d'amis/contacts des visiteurs de ce profil?"; $a->strings["Edit Profile Details"] = "Éditer les détails du profil"; $a->strings["Change Profile Photo"] = "Changer la photo du profil"; @@ -958,11 +958,11 @@ $a->strings["View this profile"] = "Voir ce profil"; $a->strings["Create a new profile using these settings"] = "Créer un nouveau profil en utilisant ces réglages"; $a->strings["Clone this profile"] = "Cloner ce profil"; $a->strings["Delete this profile"] = "Supprimer ce profil"; -$a->strings["Basic information"] = ""; -$a->strings["Profile picture"] = ""; -$a->strings["Preferences"] = ""; -$a->strings["Status information"] = ""; -$a->strings["Additional information"] = ""; +$a->strings["Basic information"] = "Information de base"; +$a->strings["Profile picture"] = "Image de profil"; +$a->strings["Preferences"] = "Préférences"; +$a->strings["Status information"] = "Information sur le statut"; +$a->strings["Additional information"] = "Information additionnelle"; $a->strings["Profile Name:"] = "Nom du profil:"; $a->strings["Your Full Name:"] = "Votre nom complet:"; $a->strings["Title/Description:"] = "Titre/Description:"; From 715629405563b28d56a187e2fbb8616f9fa02f7a Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 2 Jan 2015 12:45:09 +0100 Subject: [PATCH 05/83] Items that were stored via "remote-self" hadn't contained a valid avatar picture. --- include/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/items.php b/include/items.php index ed91fc7e4e..d6da0ed5a5 100644 --- a/include/items.php +++ b/include/items.php @@ -2668,14 +2668,14 @@ function item_is_remote_self($contact, &$datarray) { $datarray2 = $datarray; logger('remote-self start - Contact '.$contact['url'].' - '.$contact['remote_self'].' Item '.print_r($datarray, true), LOGGER_DEBUG); if ($contact['remote_self'] == 2) { - $r = q("SELECT `id`,`url`,`name`,`photo`,`network` FROM `contact` WHERE `uid` = %d AND `self`", + $r = q("SELECT `id`,`url`,`name`,`thumb` FROM `contact` WHERE `uid` = %d AND `self`", intval($contact['uid'])); if (count($r)) { $datarray['contact-id'] = $r[0]["id"]; $datarray['owner-name'] = $r[0]["name"]; $datarray['owner-link'] = $r[0]["url"]; - $datarray['owner-avatar'] = $r[0]["avatar"]; + $datarray['owner-avatar'] = $r[0]["thumb"]; $datarray['author-name'] = $datarray['owner-name']; $datarray['author-link'] = $datarray['owner-link']; From a86c143e24c9dcf58ad79e455285364a782903c3 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 4 Jan 2015 11:56:41 +0100 Subject: [PATCH 06/83] The "scrape" bugfix lead to partly damaged encodings. This is fixed now. --- boot.php | 2 +- include/dbstructure.php | 1 + include/lock.php | 18 ++++++++++-------- library/HTML5/Parser.php | 7 ++++++- update.php | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/boot.php b/boot.php index 34836a97aa..7ba74c4f6f 100644 --- a/boot.php +++ b/boot.php @@ -18,7 +18,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Ginger'); define ( 'FRIENDICA_VERSION', '3.3.2' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1175 ); +define ( 'DB_UPDATE_VERSION', 1176 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/include/dbstructure.php b/include/dbstructure.php index 66e67c0a9a..469ae10030 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -823,6 +823,7 @@ function db_definition() { "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""), "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), + "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( "PRIMARY" => array("id"), diff --git a/include/lock.php b/include/lock.php index caf1f855ab..70cf4b787b 100644 --- a/include/lock.php +++ b/include/lock.php @@ -11,20 +11,22 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) { $start = time(); do { - q("LOCK TABLE locks WRITE"); - $r = q("SELECT locked FROM locks WHERE name = '%s' LIMIT 1", + q("LOCK TABLE `locks` WRITE"); + $r = q("SELECT `locked`, `created` FROM `locks` WHERE `name` = '%s' LIMIT 1", dbesc($fn_name) ); - if((count($r)) && (! $r[0]['locked'])) { - q("UPDATE locks SET locked = 1 WHERE name = '%s'", + if((count($r)) AND (!$r[0]['locked'] OR (strtotime($r[0]['created']) < time() - 3600))) { + q("UPDATE `locks` SET `locked` = 1, `created` = '%s' WHERE `name` = '%s'", + dbesc(datetime_convert()), dbesc($fn_name) ); $got_lock = true; } elseif(! $r) { // the Boolean value for count($r) should be equivalent to the Boolean value of $r - q("INSERT INTO locks ( name, locked ) VALUES ( '%s', 1 )", - dbesc($fn_name) + q("INSERT INTO `locks` (`name`, `created`, `locked`) VALUES ('%s', '%s', 1)", + dbesc($fn_name), + dbesc(datetime_convert()) ); $got_lock = true; } @@ -37,7 +39,7 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) { } while(($block) && (! $got_lock) && ((time() - $start) < $timeout)); logger('lock_function: function ' . $fn_name . ' with blocking = ' . $block . ' got_lock = ' . $got_lock . ' time = ' . (time() - $start), LOGGER_DEBUG); - + return $got_lock; }} @@ -65,7 +67,7 @@ function block_on_function_lock($fn_name, $wait_sec = 2, $timeout = 30) { if(! function_exists('unlock_function')) { function unlock_function($fn_name) { - $r = q("UPDATE locks SET locked = 0 WHERE name = '%s'", + $r = q("UPDATE `locks` SET `locked` = 0, `created` = '0000-00-00 00:00:00' WHERE `name` = '%s'", dbesc($fn_name) ); diff --git a/library/HTML5/Parser.php b/library/HTML5/Parser.php index c7faf875ad..e101d3e545 100644 --- a/library/HTML5/Parser.php +++ b/library/HTML5/Parser.php @@ -20,7 +20,12 @@ class HTML5_Parser // Cleanup invalid HTML $doc = new DOMDocument(); - @$doc->loadHTML($text); + + if (mb_detect_encoding($text, "UTF-8", true) == "UTF-8") + @$doc->loadHTML(''.$text); + else + @$doc->loadHTML($text); + $text = $doc->saveHTML(); $tokenizer = new HTML5_Tokenizer($text, $builder); diff --git a/update.php b/update.php index 10195c1baa..97b0bd58dc 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@ Date: Sun, 4 Jan 2015 13:24:16 +0100 Subject: [PATCH 07/83] Replaced $argv and $argc with the $_SERVER array --- boot.php | 16 ++++------------ include/cronhooks.php | 2 +- include/dbstructure.php | 2 +- include/dbupdate.php | 2 +- include/delivery.php | 2 +- include/directory.php | 2 +- include/dsprphotoq.php | 2 +- include/expire.php | 2 +- include/gprobe.php | 2 +- include/notifier.php | 20 ++++++++++---------- include/onepoll.php | 6 +++--- include/poller.php | 2 +- include/queue.php | 2 +- testargs.php | 4 +--- util/po2php.php | 38 +++++++++++++++++++------------------- 15 files changed, 47 insertions(+), 57 deletions(-) diff --git a/boot.php b/boot.php index 258fd49ee6..2e76292f45 100644 --- a/boot.php +++ b/boot.php @@ -435,7 +435,7 @@ if(! class_exists('App')) { function __construct() { - global $default_timezone, $argv, $argc; + global $default_timezone; $hostname = ""; @@ -504,9 +504,9 @@ if(! class_exists('App')) { if ($hostname != "") $this->hostname = $hostname; - if (is_array($argv) && $argc>1 && substr(end($argv), 0, 4)=="http" ) { - $this->set_baseurl(array_pop($argv) ); - $argc --; + if (is_array($_SERVER["argv"]) && $_SERVER["argc"]>1 && substr(end($_SERVER["argv"]), 0, 4)=="http" ) { + $this->set_baseurl(array_pop($_SERVER["argv"]) ); + $_SERVER["argc"] --; } #set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path()); @@ -2388,11 +2388,3 @@ if(!function_exists('exif_imagetype')) { return($size[2]); } } - -// See https://github.com/friendica/friendica/issues/1218 -// Try to get the values for $argv and $argc via the $_SERVER array -if (!isset($argv) && array_key_exists('argv', $_SERVER)) - $argv = $_SERVER['argv']; - -if (!isset($argc) && array_key_exists('argc', $_SERVER)) - $argc = $_SERVER['argc']; diff --git a/include/cronhooks.php b/include/cronhooks.php index c0549dfff8..3a09da48ce 100644 --- a/include/cronhooks.php +++ b/include/cronhooks.php @@ -66,6 +66,6 @@ function cronhooks_run(&$argv, &$argc){ } if (array_search(__file__,get_included_files())===0){ - cronhooks_run($argv,$argc); + cronhooks_run($_SERVER["argv"],$_SERVER["argc"]); killme(); } diff --git a/include/dbstructure.php b/include/dbstructure.php index 66e67c0a9a..2a014cd0a4 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -1339,6 +1339,6 @@ function dbstructure_run(&$argv, &$argc) { } if (array_search(__file__,get_included_files())===0){ - dbstructure_run($argv,$argc); + dbstructure_run($_SERVER["argv"],$_SERVER["argc"]); killme(); } diff --git a/include/dbupdate.php b/include/dbupdate.php index 3fcd6b7f05..28f1de340b 100644 --- a/include/dbupdate.php +++ b/include/dbupdate.php @@ -23,6 +23,6 @@ function dbupdate_run(&$argv, &$argc) { } if (array_search(__file__,get_included_files())===0){ - dbupdate_run($argv,$argc); + dbupdate_run($_SERVER["argv"],$_SERVER["argc"]); killme(); } diff --git a/include/delivery.php b/include/delivery.php index bf41b3d13a..1def8ad2cc 100644 --- a/include/delivery.php +++ b/include/delivery.php @@ -565,6 +565,6 @@ function delivery_run(&$argv, &$argc){ } if (array_search(__file__,get_included_files())===0){ - delivery_run($argv,$argc); + delivery_run($_SERVER["argv"],$_SERVER["argc"]); killme(); } diff --git a/include/directory.php b/include/directory.php index 5c1a7c4b4c..aed700fa8a 100644 --- a/include/directory.php +++ b/include/directory.php @@ -46,6 +46,6 @@ function directory_run(&$argv, &$argc){ } if (array_search(__file__,get_included_files())===0){ - directory_run($argv,$argc); + directory_run($_SERVER["argv"],$_SERVER["argc"]); killme(); } diff --git a/include/dsprphotoq.php b/include/dsprphotoq.php index 47592006d7..7e252cd843 100644 --- a/include/dsprphotoq.php +++ b/include/dsprphotoq.php @@ -45,6 +45,6 @@ function dsprphotoq_run($argv, $argc){ if (array_search(__file__,get_included_files())===0){ - dsprphotoq_run($argv,$argc); + dsprphotoq_run($_SERVER["argv"],$_SERVER["argc"]); killme(); } diff --git a/include/expire.php b/include/expire.php index a7b561bf0c..3086804216 100644 --- a/include/expire.php +++ b/include/expire.php @@ -55,6 +55,6 @@ function expire_run(&$argv, &$argc){ } if (array_search(__file__,get_included_files())===0){ - expire_run($argv,$argc); + expire_run($_SERVER["argv"],$_SERVER["argc"]); killme(); } diff --git a/include/gprobe.php b/include/gprobe.php index 36650eb9ae..52c5483c87 100644 --- a/include/gprobe.php +++ b/include/gprobe.php @@ -63,6 +63,6 @@ function gprobe_run(&$argv, &$argc){ } if (array_search(__file__,get_included_files())===0){ - gprobe_run($argv,$argc); + gprobe_run($_SERVER["argv"],$_SERVER["argc"]); killme(); } diff --git a/include/notifier.php b/include/notifier.php index d222fd9426..79de674705 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -5,16 +5,16 @@ require_once('include/html2plain.php'); /* * This file was at one time responsible for doing all deliveries, but this caused - * big problems on shared hosting systems, where the process might get killed by the - * hosting provider and nothing would get delivered. + * big problems on shared hosting systems, where the process might get killed by the + * hosting provider and nothing would get delivered. * It now only delivers one message under certain cases, and invokes a queued - * delivery mechanism (include/deliver.php) to deliver individual contacts at + * delivery mechanism (include/deliver.php) to deliver individual contacts at * controlled intervals. * This has a much better chance of surviving random processes getting killed - * by the hosting provider. + * by the hosting provider. * A lot of this code is duplicated in include/deliver.php until we have time to go back - * and re-structure the delivery procedure based on the obstacles that have been thrown at - * us by hosting providers. + * and re-structure the delivery procedure based on the obstacles that have been thrown at + * us by hosting providers. */ /* @@ -50,7 +50,7 @@ function notifier_run(&$argv, &$argc){ if(is_null($a)){ $a = new App; } - + if(is_null($db)) { @include(".htconfig.php"); require_once("include/dba.php"); @@ -946,7 +946,7 @@ function notifier_run(&$argv, &$argc){ } if((! $mail) && (! $fsuggest) && (! $followup)) { - logger('notifier: delivery agent: ' . $rr['name'] . ' ' . $rr['id']); + logger('notifier: delivery agent: ' . $rr['name'] . ' ' . $rr['id']); proc_run('php','include/delivery.php',$cmd,$item_id,$rr['id']); if($interval) @time_sleep_until(microtime(true) + (float) $interval); @@ -966,7 +966,7 @@ function notifier_run(&$argv, &$argc){ if ($h === '[internal]') { // Set push flag for PuSH subscribers to this topic, // they will be notified in queue.php - q("UPDATE `push_subscriber` SET `push` = 1 " . + q("UPDATE `push_subscriber` SET `push` = 1 " . "WHERE `nickname` = '%s'", dbesc($owner['nickname'])); } else { @@ -1001,6 +1001,6 @@ function notifier_run(&$argv, &$argc){ if (array_search(__file__,get_included_files())===0){ - notifier_run($argv,$argc); + notifier_run($_SERVER["argv"],$_SERVER["argc"]); killme(); } diff --git a/include/onepoll.php b/include/onepoll.php index bb5b8905ab..72c1d65c00 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -586,8 +586,8 @@ function onepoll_run(&$argv, &$argc){ // load current friends if possible. - if($contact['poco']) { - $r = q("SELECT count(*) as total from glink + if($contact['poco']) { + $r = q("SELECT count(*) as total from glink where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY", intval($contact['id']) ); @@ -602,6 +602,6 @@ function onepoll_run(&$argv, &$argc){ } if (array_search(__file__,get_included_files())===0){ - onepoll_run($argv,$argc); + onepoll_run($_SERVER["argv"],$_SERVER["argc"]); killme(); } diff --git a/include/poller.php b/include/poller.php index 0edda8170a..68f65999e3 100644 --- a/include/poller.php +++ b/include/poller.php @@ -301,6 +301,6 @@ function poller_run(&$argv, &$argc){ } if (array_search(__file__,get_included_files())===0){ - poller_run($argv,$argc); + poller_run($_SERVER["argv"],$_SERVER["argc"]); killme(); } diff --git a/include/queue.php b/include/queue.php index 3c28cefaf2..128dfcba57 100644 --- a/include/queue.php +++ b/include/queue.php @@ -265,6 +265,6 @@ function queue_run(&$argv, &$argc){ } if (array_search(__file__,get_included_files())===0){ - queue_run($argv,$argc); + queue_run($_SERVER["argv"],$_SERVER["argc"]); killme(); } diff --git a/testargs.php b/testargs.php index 8c6da430e9..a6042f8eb9 100644 --- a/testargs.php +++ b/testargs.php @@ -15,9 +15,7 @@ */ -if(($argc > 1) && isset($argv[1])) - echo $argv[1]; -elseif(($_SERVER["argc"] > 1) && isset($_SERVER["argv"][1])) +if(($_SERVER["argc"] > 1) && isset($_SERVER["argv"][1])) echo $_SERVER["argv"][1]; else echo ''; diff --git a/util/po2php.php b/util/po2php.php index 881a9b2679..30d77342bf 100644 --- a/util/po2php.php +++ b/util/po2php.php @@ -8,7 +8,7 @@ function po2php_run(&$argv, &$argc) { print "Usage: ".$argv[0]." \n\n"; return; } - + $pofile = $argv[1]; $outfile = dirname($pofile)."/strings.php"; @@ -23,11 +23,11 @@ function po2php_run(&$argv, &$argc) { print "Unable to find '$pofile'\n"; return; } - + print "Out to '$outfile'\n"; - + $out="strings["'.$k.'"] = '; } if ($inv) { $inv = False; $out .= '"'.$v.'"'; } - + $v = substr($l,8,$len-10); $v = preg_replace_callback($escape_s_exp,'escape_s',$v); $inv = True; @@ -69,28 +69,28 @@ function po2php_run(&$argv, &$argc) { if ($k!="" && substr($l,0,7)=="msgstr["){ if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; } if ($inv) { $inv = False; $out .= '"'.$v.'"'; } - + if (!$arr) { $arr=True; $out .= "array(\n"; } $match=Array(); preg_match("|\[([0-9]*)\] (.*)|", $l, $match); - $out .= "\t". + $out .= "\t". preg_replace_callback($escape_s_exp,'escape_s',$match[1]) ." => " .preg_replace_callback($escape_s_exp,'escape_s',$match[2]) .",\n"; } - + if (substr($l,0,6)=="msgid_") { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }; if ($ink) { - $k .= trim($l,"\"\r\n"); + $k .= trim($l,"\"\r\n"); $k = preg_replace_callback($escape_s_exp,'escape_s',$k); //$out .= '$a->strings['.$k.'] = '; } - + if (substr($l,0,6)=="msgid "){ if ($inv) { $inv = False; $out .= '"'.$v.'"'; } if ($k!="") $out .= $arr?");\n":";\n"; @@ -101,28 +101,28 @@ function po2php_run(&$argv, &$argc) { } else { $k = ""; } - + $k = preg_replace_callback($escape_s_exp,'escape_s',$k); $ink = True; } - + if ($inv && substr($l,0,6)!="msgstr") { - $v .= trim($l,"\"\r\n"); + $v .= trim($l,"\"\r\n"); $v = preg_replace_callback($escape_s_exp,'escape_s',$v); //$out .= '$a->strings['.$k.'] = '; } - - + + } if ($inv) { $inv = False; $out .= '"'.$v.'"'; } if ($k!="") $out .= $arr?");\n":";\n"; - + $out = str_replace(DQ_ESCAPE, '\"', $out); file_put_contents($outfile, $out); - + } if (array_search(__file__,get_included_files())===0){ - po2php_run($argv,$argc); + po2php_run($_SERVER["argv"],$_SERVER["argc"]); } From aa6275356ae7e5b0b652b9503762e25fd7e0e1ff Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 4 Jan 2015 15:31:47 +0100 Subject: [PATCH 08/83] The function to fetch the original url (without shortener) failed if a linked file was too large. --- include/network.php | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/include/network.php b/include/network.php index 6a37f4a549..190dce326e 100644 --- a/include/network.php +++ b/include/network.php @@ -1159,13 +1159,8 @@ function original_url($url, $depth=1, $fetchbody = false) { $siteinfo = array(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_HEADER, 1); - - if ($fetchbody) - curl_setopt($ch, CURLOPT_NOBODY, 0); - else - curl_setopt($ch, CURLOPT_NOBODY, 1); - + curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent()); @@ -1183,16 +1178,33 @@ function original_url($url, $depth=1, $fetchbody = false) { return(original_url($curl_info['location'], ++$depth, $fetchbody)); } - $pos = strpos($header, "\r\n\r\n"); + // Check for redirects in the meta elements of the body if there are no redirects in the header. + if (!$fetchbody) + return(original_url($url, ++$depth, true)); - if ($pos) - $body = trim(substr($header, $pos)); - else - $body = $header; + // if the file is too large then exit + if ($curl_info["download_content_length"] > 1000000) + return($url); + + // if it isn't a HTML file then exit + if (($curl_info["content_type"] != "") AND !strstr(strtolower($curl_info["content_type"]),"html")) + return($url); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_NOBODY, 0); + curl_setopt($ch, CURLOPT_TIMEOUT, 10); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent()); + + $body = curl_exec($ch); + curl_close($ch); if (trim($body) == "") - return(original_url($url, ++$depth, true)); + return($url); + // Check for redirect in meta elements $doc = new DOMDocument(); @$doc->loadHTML($body); From 11c82816b330f247ce317d064f91c1ac7dd72990 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 4 Jan 2015 19:19:47 +0100 Subject: [PATCH 09/83] Poco now returns the last update date as well. This date will be stored in the gcontact table. --- boot.php | 2 +- include/dbstructure.php | 1 + include/items.php | 10 ++++++++++ include/socgraph.php | 18 ++++++++++++------ mod/poco.php | 21 ++++++++++++++++++--- update.php | 2 +- 6 files changed, 43 insertions(+), 11 deletions(-) diff --git a/boot.php b/boot.php index 34836a97aa..ec2a4a1acf 100644 --- a/boot.php +++ b/boot.php @@ -18,7 +18,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Ginger'); define ( 'FRIENDICA_VERSION', '3.3.2' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1175 ); +define ( 'DB_UPDATE_VERSION', 1177 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/include/dbstructure.php b/include/dbstructure.php index 66e67c0a9a..08d772ef7c 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -616,6 +616,7 @@ function db_definition() { "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"), ), "indexes" => array( "PRIMARY" => array("id"), diff --git a/include/items.php b/include/items.php index d6da0ed5a5..b82b5dc971 100644 --- a/include/items.php +++ b/include/items.php @@ -1343,6 +1343,16 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa $current_post = $r[0]['id']; logger('item_store: created item ' . $current_post); + // Set "success_update" to the date of the last time we heard from this contact + // This can be used to filter for inactive contacts and poco. + // Only do this for public postings to avoid privacy problems, since poco data is public. + // Don't set this value if it isn't from the owner (could be an author that we don't know) + if (!$arr['private'] AND (($arr["author-link"] === $arr["owner-link"]) OR ($arr["parent-uri"] === $arr["uri"]))) + $r = q("UPDATE `contact` SET `success_update` = '%s' WHERE `id` = %d", + dbesc($arr['received']), + intval($arr['contact-id']) + ); + // Only check for notifications on start posts if ($arr['parent-uri'] === $arr['uri']) { add_thread($r[0]['id']); diff --git a/include/socgraph.php b/include/socgraph.php index daec03726e..333d2f04b1 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -39,7 +39,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { if(! $url) return; - $url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos' : '?fields=displayName,urls,photos') ; + $url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos' : '?fields=displayName,urls,photos,updated') ; logger('poco_load: ' . $url, LOGGER_DEBUG); @@ -67,6 +67,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { $profile_photo = ''; $connect_url = ''; $name = ''; + $updated = '0000-00-00 00:00:00'; $name = $entry->displayName; @@ -82,7 +83,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { } } } - if(isset($entry->photos)) { + if(isset($entry->photos)) { foreach($entry->photos as $photo) { if($photo->type == 'profile') { $profile_photo = $photo->value; @@ -91,6 +92,9 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { } } + if(isset($entry->updated)) + $updated = date("Y-m-d H:i:s", strtotime($entry->updated)); + if((! $name) || (! $profile_url) || (! $profile_photo)) continue; @@ -101,25 +105,27 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { if(count($x)) { $gcid = $x[0]['id']; - if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo) { - q("update gcontact set `name` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s' + if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo || $x[0]['updated'] < $updated) { + q("update gcontact set `name` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s', `updated` = '%s' where `nurl` = '%s'", dbesc($name), dbesc($profile_photo), dbesc($connect_url), dbesc($profile_url), + dbesc($updated), dbesc(normalise_link($profile_url)) ); } } else { - q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`,`connect`) + q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`,`connect`, `updated`) values ( '%s', '%s', '%s', '%s','%s') ", dbesc($name), dbesc($profile_url), dbesc(normalise_link($profile_url)), dbesc($profile_photo), - dbesc($connect_url) + dbesc($connect_url), + dbesc($updated) ); $x = q("select * from `gcontact` where `nurl` = '%s' limit 1", dbesc(normalise_link($profile_url)) diff --git a/mod/poco.php b/mod/poco.php index 624a48d9ff..9c08749f20 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -30,7 +30,7 @@ function poco_init(&$a) { $justme = true; if($a->argc > 4 && intval($a->argv[4]) && $justme == false) $cid = intval($a->argv[4]); - + if(! $system_mode) { $r = q("SELECT `user`.*,`profile`.`hide-friends` from user left join profile on `user`.`uid` = `profile`.`uid` @@ -106,6 +106,7 @@ function poco_init(&$a) { 'id' => false, 'displayName' => false, 'urls' => false, + 'updated' => false, 'preferredUsername' => false, 'photos' => false ); @@ -130,10 +131,24 @@ function poco_init(&$a) { if($fields_ret['urls']) { $entry['urls'] = array(array('value' => $rr['url'], 'type' => 'profile')); if($rr['addr'] && ($rr['network'] !== NETWORK_MAIL)) - $entry['urls'][] = array('value' => 'acct:' . $rr['addr'], 'type' => 'webfinger'); + $entry['urls'][] = array('value' => 'acct:' . $rr['addr'], 'type' => 'webfinger'); } if($fields_ret['preferredUsername']) $entry['preferredUsername'] = $rr['nick']; + if($fields_ret['updated']) { + $entry['updated'] = $rr['success_update']; + + if ($rr['name-date'] > $entry['updated']) + $entry['updated'] = $rr['name-date']; + + if ($rr['uri-date'] > $entry['updated']) + $entry['updated'] = $rr['uri-date']; + + if ($rr['avatar-date'] > $entry['updated']) + $entry['updated'] = $rr['avatar-date']; + + $entry['updated'] = date("c", strtotime($entry['updated'])); + } if($fields_ret['photos']) $entry['photos'] = array(array('value' => $rr['photo'], 'type' => 'profile')); $ret['entry'][] = $entry; @@ -153,7 +168,7 @@ function poco_init(&$a) { if($format === 'json') { header('Content-type: application/json'); echo json_encode($ret); - killme(); + killme(); } else http_status_exit(500); diff --git a/update.php b/update.php index 10195c1baa..b4fb640486 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@ Date: Sun, 4 Jan 2015 20:04:59 +0100 Subject: [PATCH 10/83] Check for filesize before trying to fetch site infos. --- mod/parse_url.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/mod/parse_url.php b/mod/parse_url.php index 06e59b8691..9df35c7612 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -73,7 +73,7 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); - curl_setopt($ch, CURLOPT_NOBODY, 0); + curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); @@ -93,6 +93,28 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co return($siteinfo); } + // if the file is too large then exit + if ($curl_info["download_content_length"] > 1000000) + return($siteinfo); + + // if it isn't a HTML file then exit + if (($curl_info["content_type"] != "") AND !strstr(strtolower($curl_info["content_type"]),"html")) + return($siteinfo); + + // Now fetch the body as well + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, CURLOPT_NOBODY, 0); + curl_setopt($ch, CURLOPT_TIMEOUT, 10); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent()); + + $header = curl_exec($ch); + $curl_info = @curl_getinfo($ch); + $http_code = $curl_info['http_code']; + curl_close($ch); + if ($do_oembed) { require_once("include/oembed.php"); From d49c3e99ac19d5f9a78cb5598ff67a25112d4cac Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 5 Jan 2015 08:03:29 +0100 Subject: [PATCH 11/83] Suggest only active accounts. Remove duplicates from gcontact table. --- include/dbstructure.php | 2 ++ include/socgraph.php | 41 +++++++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/include/dbstructure.php b/include/dbstructure.php index 1f6a7c4ef3..008003e1b0 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -413,6 +413,8 @@ function db_definition() { "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "about" => array("type" => "text", "not null" => "1"), "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "photo" => array("type" => "text", "not null" => "1"), "thumb" => array("type" => "text", "not null" => "1"), diff --git a/include/socgraph.php b/include/socgraph.php index 333d2f04b1..b9e890427c 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -98,7 +98,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { if((! $name) || (! $profile_url) || (! $profile_photo)) continue; - $x = q("select * from `gcontact` where `nurl` = '%s' limit 1", + $x = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", dbesc(normalise_link($profile_url)) ); @@ -116,8 +116,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { dbesc(normalise_link($profile_url)) ); } - } - else { + } else { q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`,`connect`, `updated`) values ( '%s', '%s', '%s', '%s','%s') ", dbesc($name), @@ -127,7 +126,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { dbesc($connect_url), dbesc($updated) ); - $x = q("select * from `gcontact` where `nurl` = '%s' limit 1", + $x = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", dbesc(normalise_link($profile_url)) ); if(count($x)) @@ -136,14 +135,14 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { if(! $gcid) return; - $r = q("select * from glink where `cid` = %d and `uid` = %d and `gcid` = %d and `zcid` = %d limit 1", + $r = q("SELECT * FROM `glink` WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d LIMIT 1", intval($cid), intval($uid), intval($gcid), intval($zcid) ); if(! count($r)) { - q("insert into glink ( `cid`,`uid`,`gcid`,`zcid`, `updated`) values (%d,%d,%d,%d, '%s') ", + q("INSERT INTO `glink` (`cid`,`uid`,`gcid`,`zcid`, `updated`) VALUES (%d,%d,%d,%d, '%s') ", intval($cid), intval($uid), intval($gcid), @@ -152,7 +151,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { ); } else { - q("update glink set updated = '%s' where `cid` = %d and `uid` = %d and `gcid` = %d and zcid = %d", + q("UPDATE `glink` SET `updated` = '%s' WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d", dbesc(datetime_convert()), intval($cid), intval($uid), @@ -161,10 +160,17 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { ); } + // For unknown reasons there are sometimes duplicates + q("DELETE FROM `gcontact` WHERE `nurl` = '%s' AND `id` != %d AND + NOT EXISTS (SELECT `gcid` FROM `glink` WHERE `gcid` = `gcontact`.`id`)", + dbesc(normalise_link($profile_url)), + intval($gcid) + ); + } logger("poco_load: loaded $total entries",LOGGER_DEBUG); - q("delete from glink where `cid` = %d and `uid` = %d and `zcid` = %d and `updated` < UTC_TIMESTAMP - INTERVAL 2 DAY", + q("DELETE FROM `glink` WHERE `cid` = %d AND `uid` = %d AND `zcid` = %d AND `updated` < UTC_TIMESTAMP - INTERVAL 2 DAY", intval($cid), intval($uid), intval($zcid) @@ -295,12 +301,13 @@ function suggestion_query($uid, $start = 0, $limit = 80) { if(! $uid) return array(); - $r = q("SELECT count(glink.gcid) as `total`, gcontact.* from gcontact - INNER JOIN glink on glink.gcid = gcontact.id + $r = q("SELECT count(glink.gcid) as `total`, gcontact.* from gcontact + INNER JOIN glink on glink.gcid = gcontact.id where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d ) and not gcontact.name in ( select name from contact where uid = %d ) and not gcontact.id in ( select gcid from gcign where uid = %d ) - group by glink.gcid order by total desc limit %d, %d ", + AND `gcontact`.`updated` != '0000-00-00 00:00:00' + group by glink.gcid order by gcontact.updated desc,total desc limit %d, %d ", intval($uid), intval($uid), intval($uid), @@ -312,11 +319,12 @@ function suggestion_query($uid, $start = 0, $limit = 80) { if(count($r) && count($r) >= ($limit -1)) return $r; - $r2 = q("SELECT gcontact.* from gcontact - INNER JOIN glink on glink.gcid = gcontact.id + $r2 = q("SELECT gcontact.* from gcontact + INNER JOIN glink on glink.gcid = gcontact.id where glink.uid = 0 and glink.cid = 0 and glink.zcid = 0 and not gcontact.nurl in ( select nurl from contact where uid = %d ) and not gcontact.name in ( select name from contact where uid = %d ) and not gcontact.id in ( select gcid from gcign where uid = %d ) + AND `gcontact`.`updated` != '0000-00-00 00:00:00' order by rand() limit %d, %d ", intval($uid), intval($uid), @@ -325,9 +333,14 @@ function suggestion_query($uid, $start = 0, $limit = 80) { intval($limit) ); + $list = array(); + foreach ($r2 AS $suggestion) + $list[$suggestion["nurl"]] = $suggestion; - return array_merge($r,$r2); + foreach ($r AS $suggestion) + $list[$suggestion["nurl"]] = $suggestion; + return $list; } function update_suggestions() { From b0ffe11b21b9a608fb61ef7582bd12581438b35d Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Mon, 5 Jan 2015 09:05:27 +0100 Subject: [PATCH 12/83] add thread un/ignore functionality to quattro theme --- view/theme/quattro/templates/wall_thread.tpl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/view/theme/quattro/templates/wall_thread.tpl b/view/theme/quattro/templates/wall_thread.tpl index caeee83d26..64e3794ccb 100644 --- a/view/theme/quattro/templates/wall_thread.tpl +++ b/view/theme/quattro/templates/wall_thread.tpl @@ -94,6 +94,10 @@ {{$item.star.do}} {{$item.star.undo}} {{/if}} + {{if $item.ignore}} + {{$item.ignore.do}} + {{$item.ignore.undo}} + {{/if}} {{if $item.tagger}} {{$item.tagger.add}} {{/if}} From 6c66ebf8066281e0fe013169ff86fe4f24be3234 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Mon, 5 Jan 2015 11:59:12 +0100 Subject: [PATCH 13/83] remove `util/typohelper.php` and call `php -l` in `util/typo.php` to check syntax errors --- util/typo.php | 30 ++++++++++++------------------ util/typohelper.php | 11 ----------- 2 files changed, 12 insertions(+), 29 deletions(-) delete mode 100644 util/typohelper.php diff --git a/util/typo.php b/util/typo.php index a8055c8418..0e2177c706 100644 --- a/util/typo.php +++ b/util/typo.php @@ -12,25 +12,28 @@ $a = new App(); + if(x($a->config,'php_path')) + $phpath = $a->config['php_path']; + else + $phpath = 'php'; + + echo "Directory: mod\n"; $files = glob('mod/*.php'); foreach($files as $file) { - echo $file . "\n"; - include_once($file); + passthru("$phpath -l $file", $ret); $ret===0 or die(); } echo "Directory: include\n"; $files = glob('include/*.php'); foreach($files as $file) { - echo $file . "\n"; - include_once($file); + passthru("$phpath -l $file", $ret); $ret===0 or die(); } echo "Directory: object\n"; $files = glob('object/*.php'); foreach($files as $file) { - echo $file . "\n"; - include_once($file); + passthru("$phpath -l $file", $ret); $ret===0 or die(); } echo "Directory: addon\n"; @@ -40,26 +43,17 @@ $addon = basename($dir); $files = glob($dir . '/' . $addon . '.php'); foreach($files as $file) { - echo $file . "\n"; - include_once($file); + passthru("$phpath -l $file", $ret); $ret===0 or die(); } } - if(x($a->config,'php_path')) - $phpath = $a->config['php_path']; - else - $phpath = 'php'; echo "String files\n"; echo 'util/strings.php' . "\n"; - include_once('util/strings.php'); - echo count($a->strings) . ' strings' . "\n"; + passthru("$phpath -l util/strings.php", $ret); $ret===0 or die(); $files = glob('view/*/strings.php'); - foreach($files as $file) { - echo $file . "\n"; - passthru($phpath . ' util/typohelper.php ' . $file); -// include_once($file); + passthru("$phpath -l $file", $ret); $ret===0 or die(); } diff --git a/util/typohelper.php b/util/typohelper.php deleted file mode 100644 index 589702a02a..0000000000 --- a/util/typohelper.php +++ /dev/null @@ -1,11 +0,0 @@ - Date: Mon, 5 Jan 2015 14:28:17 +0100 Subject: [PATCH 14/83] Bugfix: Postings disappeared due to a small variable ... --- include/items.php | 2 +- mod/parse_url.php | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/items.php b/include/items.php index b82b5dc971..9d1e36f39b 100644 --- a/include/items.php +++ b/include/items.php @@ -1348,7 +1348,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa // Only do this for public postings to avoid privacy problems, since poco data is public. // Don't set this value if it isn't from the owner (could be an author that we don't know) if (!$arr['private'] AND (($arr["author-link"] === $arr["owner-link"]) OR ($arr["parent-uri"] === $arr["uri"]))) - $r = q("UPDATE `contact` SET `success_update` = '%s' WHERE `id` = %d", + q("UPDATE `contact` SET `success_update` = '%s' WHERE `id` = %d", dbesc($arr['received']), intval($arr['contact-id']) ); diff --git a/mod/parse_url.php b/mod/parse_url.php index 9df35c7612..9f7b31be30 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -93,6 +93,15 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co return($siteinfo); } + if ($do_oembed) { + require_once("include/oembed.php"); + + $oembed_data = oembed_fetch_url($url); + + if ($oembed_data->type != "error") + $siteinfo["type"] = $oembed_data->type; + } + // if the file is too large then exit if ($curl_info["download_content_length"] > 1000000) return($siteinfo); @@ -115,15 +124,6 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co $http_code = $curl_info['http_code']; curl_close($ch); - if ($do_oembed) { - require_once("include/oembed.php"); - - $oembed_data = oembed_fetch_url($url); - - if ($oembed_data->type != "error") - $siteinfo["type"] = $oembed_data->type; - } - // Fetch the first mentioned charset. Can be in body or header $charset = ""; if (preg_match('/charset=(.*?)['."'".'"\s\n]/', $header, $matches)) From 16e4e61cc5162b8f65584464002d8e337a759519 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 5 Jan 2015 22:44:55 +0100 Subject: [PATCH 15/83] Only show contacts from open networks --- mod/poco.php | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/mod/poco.php b/mod/poco.php index 9c08749f20..9b3e8d06af 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -12,7 +12,7 @@ function poco_init(&$a) { $user = notags(trim($a->argv[1])); } if(! x($user)) { - $c = q("select * from pconfig where cat = 'system' and k = 'suggestme' and v = 1"); + $c = q("SELECT * FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1"); if(! count($c)) http_status_exit(401); $system_mode = true; @@ -30,7 +30,7 @@ function poco_init(&$a) { $justme = true; if($a->argc > 4 && intval($a->argv[4]) && $justme == false) $cid = intval($a->argv[4]); - + if(! $system_mode) { $r = q("SELECT `user`.*,`profile`.`hide-friends` from user left join profile on `user`.`uid` = `profile`.`uid` @@ -44,21 +44,28 @@ function poco_init(&$a) { } if($justme) - $sql_extra = " and `contact`.`self` = 1 "; + $sql_extra = " AND `contact`.`self` = 1 "; else - $sql_extra = " and `contact`.`self` = 0 "; + $sql_extra = " AND `contact`.`self` = 0 "; if($cid) - $sql_extra = sprintf(" and `contact`.`id` = %d ",intval($cid)); + $sql_extra = sprintf(" AND `contact`.`id` = %d ",intval($cid)); if($system_mode) { - $r = q("SELECT count(*) as `total` from `contact` where self = 1 - and uid in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = 1) "); + $r = q("SELECT count(*) AS `total` FROM `contact` WHERE `self` = 1 AND `network` IN ('%s', '%s', '%s', '') + AND `uid` IN (SELECT `uid` FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1) ", + dbesc(NETWORK_DFRN), + dbesc(NETWORK_DIASPORA), + dbesc(NETWORK_OSTATUS) + ); } else { - $r = q("SELECT count(*) as `total` from `contact` where `uid` = %d and blocked = 0 and pending = 0 and hidden = 0 and archive = 0 - $sql_extra ", - intval($user['uid']) + $r = q("SELECT count(*) AS `total` FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 + AND `network` IN ('%s', '%s', '%s', '') $sql_extra", + intval($user['uid']), + dbesc(NETWORK_DFRN), + dbesc(NETWORK_DIASPORA), + dbesc(NETWORK_OSTATUS) ); } if(count($r)) @@ -73,17 +80,22 @@ function poco_init(&$a) { if($system_mode) { - $r = q("SELECT * from contact where self = 1 - and uid in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = 1) limit %d, %d ", + $r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `network` IN ('%s', '%s', '%s', '') + AND `uid` IN (SELECT `uid` FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1) LIMIT %d, %d", + dbesc(NETWORK_DFRN), + dbesc(NETWORK_DIASPORA), + dbesc(NETWORK_OSTATUS), intval($startIndex), intval($itemsPerPage) ); } else { - - $r = q("SELECT * from `contact` where `uid` = %d and blocked = 0 and pending = 0 and hidden = 0 and archive = 0 - $sql_extra LIMIT %d, %d", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 + AND `network` IN ('%s', '%s', '%s', '') $sql_extra LIMIT %d, %d", intval($user['uid']), + dbesc(NETWORK_DFRN), + dbesc(NETWORK_DIASPORA), + dbesc(NETWORK_OSTATUS), intval($startIndex), intval($itemsPerPage) ); From 1a5a00bef8c90524b094dddd4de5dcc6a1a6545f Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 6 Jan 2015 07:23:11 +0100 Subject: [PATCH 16/83] While storing an item, now every contact is stored in the gcontact table. --- include/items.php | 7 ++++ include/socgraph.php | 78 +++++++++++++++++++++++++------------------- 2 files changed, 52 insertions(+), 33 deletions(-) diff --git a/include/items.php b/include/items.php index 9d1e36f39b..a7e996015e 100644 --- a/include/items.php +++ b/include/items.php @@ -11,6 +11,7 @@ require_once('include/text.php'); require_once('include/email.php'); require_once('include/ostatus_conversation.php'); require_once('include/threads.php'); +require_once('include/socgraph.php'); function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) { @@ -1343,6 +1344,12 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa $current_post = $r[0]['id']; logger('item_store: created item ' . $current_post); + // Add every contact to the global contact table + // Contacts from the statusnet connector are also added since you could add them in OStatus as well. + if (!$arr['private'] AND in_array($arr["network"], + array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_STATUSNET, ""))) + poco_check($arr["author-link"], $arr["author-name"], $arr["author-avatar"], "", $arr["received"]); + // Set "success_update" to the date of the last time we heard from this contact // This can be used to filter for inactive contacts and poco. // Only do this for public postings to avoid privacy problems, since poco data is public. diff --git a/include/socgraph.php b/include/socgraph.php index b9e890427c..8b8eb915cc 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -98,40 +98,8 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { if((! $name) || (! $profile_url) || (! $profile_photo)) continue; - $x = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", - dbesc(normalise_link($profile_url)) - ); + $gcid = poco_check($profile_url, $name, $profile_photo, $connect_url, $updated); - if(count($x)) { - $gcid = $x[0]['id']; - - if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo || $x[0]['updated'] < $updated) { - q("update gcontact set `name` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s', `updated` = '%s' - where `nurl` = '%s'", - dbesc($name), - dbesc($profile_photo), - dbesc($connect_url), - dbesc($profile_url), - dbesc($updated), - dbesc(normalise_link($profile_url)) - ); - } - } else { - q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`,`connect`, `updated`) - values ( '%s', '%s', '%s', '%s','%s') ", - dbesc($name), - dbesc($profile_url), - dbesc(normalise_link($profile_url)), - dbesc($profile_photo), - dbesc($connect_url), - dbesc($updated) - ); - $x = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", - dbesc(normalise_link($profile_url)) - ); - if(count($x)) - $gcid = $x[0]['id']; - } if(! $gcid) return; @@ -178,6 +146,50 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { } +function poco_check($profile_url, $name, $profile_photo, $connect_url, $updated) { + $gcid = ""; + + if (($profile_url == "") OR ($name == "") OR ($profile_photo == "")) + return $gcid; + + logger("profile-check URL: ".$profile_url." name: ".$name." avatar: ".$profile_photo, LOGGER_DEBUG); + + $x = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", + dbesc(normalise_link($profile_url)) + ); + + if(count($x)) { + $gcid = $x[0]['id']; + + if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo || $x[0]['updated'] < $updated) { + q("update gcontact set `name` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s', `updated` = '%s' + where `nurl` = '%s'", + dbesc($name), + dbesc($profile_photo), + dbesc($connect_url), + dbesc($profile_url), + dbesc($updated), + dbesc(normalise_link($profile_url)) + ); + } + } else { + q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`,`connect`, `updated`) + values ('%s', '%s', '%s', '%s','%s', '%s')", + dbesc($name), + dbesc($profile_url), + dbesc(normalise_link($profile_url)), + dbesc($profile_photo), + dbesc($connect_url), + dbesc($updated) + ); + $x = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", + dbesc(normalise_link($profile_url)) + ); + if(count($x)) + $gcid = $x[0]['id']; + } + return $gcid; +} function count_common_friends($uid,$cid) { From 5684ba4442b3db9ea0c135f1013a70f515d98e1f Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 6 Jan 2015 08:16:15 +0100 Subject: [PATCH 17/83] Now the glink table is written as well in the poco_check function. --- include/socgraph.php | 77 +++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/include/socgraph.php b/include/socgraph.php index 8b8eb915cc..623cf88cea 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -95,45 +95,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { if(isset($entry->updated)) $updated = date("Y-m-d H:i:s", strtotime($entry->updated)); - if((! $name) || (! $profile_url) || (! $profile_photo)) - continue; - - $gcid = poco_check($profile_url, $name, $profile_photo, $connect_url, $updated); - - if(! $gcid) - return; - - $r = q("SELECT * FROM `glink` WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d LIMIT 1", - intval($cid), - intval($uid), - intval($gcid), - intval($zcid) - ); - if(! count($r)) { - q("INSERT INTO `glink` (`cid`,`uid`,`gcid`,`zcid`, `updated`) VALUES (%d,%d,%d,%d, '%s') ", - intval($cid), - intval($uid), - intval($gcid), - intval($zcid), - dbesc(datetime_convert()) - ); - } - else { - q("UPDATE `glink` SET `updated` = '%s' WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d", - dbesc(datetime_convert()), - intval($cid), - intval($uid), - intval($gcid), - intval($zcid) - ); - } - - // For unknown reasons there are sometimes duplicates - q("DELETE FROM `gcontact` WHERE `nurl` = '%s' AND `id` != %d AND - NOT EXISTS (SELECT `gcid` FROM `glink` WHERE `gcid` = `gcontact`.`id`)", - dbesc(normalise_link($profile_url)), - intval($gcid) - ); + poco_check($profile_url, $name, $profile_photo, $connect_url, $updated, $cid, $uid, $zcid); } logger("poco_load: loaded $total entries",LOGGER_DEBUG); @@ -146,7 +108,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) { } -function poco_check($profile_url, $name, $profile_photo, $connect_url, $updated) { +function poco_check($profile_url, $name, $profile_photo, $connect_url, $updated, $cid = 0, $uid = 0, $zcid = 0) { $gcid = ""; if (($profile_url == "") OR ($name == "") OR ($profile_photo == "")) @@ -188,6 +150,41 @@ function poco_check($profile_url, $name, $profile_photo, $connect_url, $updated) if(count($x)) $gcid = $x[0]['id']; } + + if(! $gcid) + return $gcid; + + $r = q("SELECT * FROM `glink` WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d LIMIT 1", + intval($cid), + intval($uid), + intval($gcid), + intval($zcid) + ); + if(! count($r)) { + q("INSERT INTO `glink` (`cid`,`uid`,`gcid`,`zcid`, `updated`) VALUES (%d,%d,%d,%d, '%s') ", + intval($cid), + intval($uid), + intval($gcid), + intval($zcid), + dbesc(datetime_convert()) + ); + } else { + q("UPDATE `glink` SET `updated` = '%s' WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d", + dbesc(datetime_convert()), + intval($cid), + intval($uid), + intval($gcid), + intval($zcid) + ); + } + + // For unknown reasons there are sometimes duplicates + q("DELETE FROM `gcontact` WHERE `nurl` = '%s' AND `id` != %d AND + NOT EXISTS (SELECT `gcid` FROM `glink` WHERE `gcid` = `gcontact`.`id`)", + dbesc(normalise_link($profile_url)), + intval($gcid) + ); + return $gcid; } From a2a393a3c6c0446751f41c009dd5ae5a47b445d0 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 6 Jan 2015 12:31:44 +0100 Subject: [PATCH 18/83] Better check for Diaspora accounts so you can connect them from the /suggest page. --- include/Scrape.php | 9 +++++++++ include/items.php | 2 +- include/threads.php | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/Scrape.php b/include/Scrape.php index 99784af336..629f7a063b 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -750,5 +750,14 @@ function probe_url($url, $mode = PROBE_NORMAL) { logger('probe_url: ' . print_r($result,true), LOGGER_DEBUG); + // Trying if it maybe a diaspora account + if ($result['network'] == NETWORK_FEED) { + require_once('include/bbcode.php'); + $address = GetProfileUsername($url, "", true); + $result2 = probe_url($address, $mode); + if ($result2['network'] != "") + $result = $result2; + } + return $result; } diff --git a/include/items.php b/include/items.php index a7e996015e..c1352cebbe 100644 --- a/include/items.php +++ b/include/items.php @@ -1348,7 +1348,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa // Contacts from the statusnet connector are also added since you could add them in OStatus as well. if (!$arr['private'] AND in_array($arr["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_STATUSNET, ""))) - poco_check($arr["author-link"], $arr["author-name"], $arr["author-avatar"], "", $arr["received"]); + poco_check($arr["author-link"], $arr["author-name"], $arr["author-avatar"], "", $arr["received"], $arr['contact-id'], $arr['uid']); // Set "success_update" to the date of the last time we heard from this contact // This can be used to filter for inactive contacts and poco. diff --git a/include/threads.php b/include/threads.php index 28bf87f4da..8febe49e9b 100644 --- a/include/threads.php +++ b/include/threads.php @@ -153,6 +153,8 @@ function delete_thread_uri($itemuri, $uid) { } function delete_thread($itemid) { + // To-Do: + // There is no "uri" in the thread table ... $item = q("SELECT `uri`, `uid` FROM `thread` WHERE `iid` = %d", intval($itemid)); $result = q("DELETE FROM `thread` WHERE `iid` = %d", intval($itemid)); From b36d79904497bab6255a995921010a39eefc4a7e Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 7 Jan 2015 01:46:13 +0100 Subject: [PATCH 19/83] Fetching "location" and "about" from diaspora. Displaying them on the "display" page. --- boot.php | 5 ++++- include/diaspora.php | 21 +++++++++++-------- include/items.php | 2 +- include/threads.php | 16 +++++++------- mod/display.php | 23 +++++++++++---------- view/templates/profile_vcard.tpl | 2 ++ view/theme/vier/templates/profile_vcard.tpl | 2 ++ 7 files changed, 40 insertions(+), 31 deletions(-) diff --git a/boot.php b/boot.php index ec2a4a1acf..9e5a32b66b 100644 --- a/boot.php +++ b/boot.php @@ -1649,8 +1649,10 @@ if(! function_exists('profile_sidebar')) { $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False); + $about = ((x($profile,'about') == 1) ? t('About:') : False); + if(($profile['hidewall'] || $block) && (! local_user()) && (! remote_user())) { - $location = $pdesc = $gender = $marital = $homepage = False; + $location = $pdesc = $gender = $marital = $homepage = $about = False; } $firstname = ((strpos($profile['name'],' ')) @@ -1695,6 +1697,7 @@ if(! function_exists('profile_sidebar')) { '$pdesc' => $pdesc, '$marital' => $marital, '$homepage' => $homepage, + '$about' => $about, '$network' => t('Network:'), '$diaspora' => $diaspora, '$contact_block' => $contact_block, diff --git a/include/diaspora.php b/include/diaspora.php index 99288b773c..b5cb0f0e23 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -2028,7 +2028,7 @@ function diaspora_retraction($importer,$xml) { dbesc(datetime_convert()), intval($r[0]['id']) ); - delete_thread($r[0]['id']); + delete_thread($r[0]['id'], $r[0]['parent-uri']); } } } @@ -2101,7 +2101,7 @@ function diaspora_signed_retraction($importer,$xml,$msg) { dbesc(datetime_convert()), intval($r[0]['id']) ); - delete_thread($r[0]['id']); + delete_thread($r[0]['id'], $r[0]['parent-uri']); // Now check if the retraction needs to be relayed by us // @@ -2161,14 +2161,15 @@ function diaspora_profile($importer,$xml,$msg) { $name = unxmlify($xml->first_name) . ((strlen($xml->last_name)) ? ' ' . unxmlify($xml->last_name) : ''); $image_url = unxmlify($xml->image_url); $birthday = unxmlify($xml->birthday); + $location = unxmlify($xml->location); + $about = diaspora2bb(unxmlify($xml->bio)); $handle_parts = explode("@", $diaspora_handle); if($name === '') { $name = $handle_parts[0]; } - - + if( preg_match("|^https?://|", $image_url) === 0) { $image_url = "http://" . $handle_parts[1] . $image_url; } @@ -2182,8 +2183,8 @@ function diaspora_profile($importer,$xml,$msg) { require_once('include/Photo.php'); $images = import_profile_photo($image_url,$importer['uid'],$contact['id']); - - // Generic birthday. We don't know the timezone. The year is irrelevant. + + // Generic birthday. We don't know the timezone. The year is irrelevant. $birthday = str_replace('1000','1901',$birthday); @@ -2196,9 +2197,9 @@ function diaspora_profile($importer,$xml,$msg) { $birthday = $contact['bd']; // TODO: update name on item['author-name'] if the name changed. See consume_feed() - // Not doing this currently because D* protocol is scheduled for revision soon. + // Not doing this currently because D* protocol is scheduled for revision soon. - $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s' WHERE `id` = %d AND `uid` = %d", + $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s', `location` = '%s', `about` = '%s' WHERE `id` = %d AND `uid` = %d", dbesc($name), dbesc(datetime_convert()), dbesc($images[0]), @@ -2206,9 +2207,11 @@ function diaspora_profile($importer,$xml,$msg) { dbesc($images[2]), dbesc(datetime_convert()), dbesc($birthday), + dbesc($location), + dbesc($about), intval($contact['id']), intval($importer['uid']) - ); + ); /* if($r) { if($oldphotos) { diff --git a/include/items.php b/include/items.php index c1352cebbe..1637de15b3 100644 --- a/include/items.php +++ b/include/items.php @@ -4509,7 +4509,7 @@ function drop_item($id,$interactive = true) { ); create_tags_from_item($item['id']); create_files_from_item($item['id']); - delete_thread($item['id']); + delete_thread($item['id'], $item['parent-uri']); // clean up categories and tags so they don't end up as orphans diff --git a/include/threads.php b/include/threads.php index 8febe49e9b..e9a0d7f1f2 100644 --- a/include/threads.php +++ b/include/threads.php @@ -149,28 +149,26 @@ function delete_thread_uri($itemuri, $uid) { if(count($messages)) foreach ($messages as $message) - delete_thread($message["id"]); + delete_thread($message["id"], $itemuri); } -function delete_thread($itemid) { - // To-Do: - // There is no "uri" in the thread table ... - $item = q("SELECT `uri`, `uid` FROM `thread` WHERE `iid` = %d", intval($itemid)); +function delete_thread($itemid, $itemuri = "") { + $item = q("SELECT `uid` FROM `thread` WHERE `iid` = %d", intval($itemid)); $result = q("DELETE FROM `thread` WHERE `iid` = %d", intval($itemid)); logger("delete_thread: Deleted thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG); - if (count($item)) { + if ($itemuri != "") { $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND NOT (`uid` IN (%d, 0))", - dbesc($item["uri"]), + dbesc($itemuri), intval($item["uid"]) ); if (!count($r)) { $r = q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = 0)", - dbesc($item["uri"]) + dbesc($itemuri) ); - logger("delete_thread: Deleted shadow for item ".$item["uri"]." - ".print_r($result, true), LOGGER_DEBUG); + logger("delete_thread: Deleted shadow for item ".$itemuri." - ".print_r($result, true), LOGGER_DEBUG); } } } diff --git a/mod/display.php b/mod/display.php index abb03b6d5b..d1da53cf16 100644 --- a/mod/display.php +++ b/mod/display.php @@ -16,7 +16,7 @@ function display_init(&$a) { // Does the local user have this item? if (local_user()) { - $r = q("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body` FROM `item` + $r = q("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid` FROM `item` WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `guid` = '%s' AND `uid` = %d", $a->argv[1], local_user()); if (count($r)) { @@ -43,7 +43,7 @@ function display_init(&$a) { } if (count($r)) { if ($r[0]["id"] != $r[0]["parent"]) - $r = q("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body` FROM `item` + $r = q("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid` FROM `item` WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `id` = %d", $r[0]["parent"]); @@ -88,21 +88,22 @@ function display_fetchauthor($a, $item) { $profiledata["photo"] = proxy_url($item["author-avatar"]); $profiledata["url"] = $item["author-link"]; $profiledata["network"] = $item["network"]; + $profiledata["address"] = "Ort".print_r($item, true); - // Fetching profile data from unique contacts - // To-do: Extend "unique contacts" table for further contact data like location, ... - $r = q("SELECT `avatar`, `nick` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"])); + // Fetching further contact data from the contact table + $r = q("SELECT `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d", + normalise_link($profiledata["url"]), $item["uid"]); if (count($r)) { - $profiledata["photo"] = proxy_url($r[0]["avatar"]); + $profiledata["photo"] = proxy_url($r[0]["photo"]); + $profiledata["address"] = $r[0]["location"]; + $profiledata["about"] = $r[0]["about"]; if ($r[0]["nick"] != "") $profiledata["nickname"] = $r[0]["nick"]; } else { - // Is this case possible? - // Fetching further contact data from the contact table, when it isn't available in the "unique contacts" - $r = q("SELECT `photo`, `nick` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d", - normalise_link($profiledata["url"]), $itemuid); + // Fetching profile data from unique contacts + $r = q("SELECT `avatar`, `nick` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"])); if (count($r)) { - $profiledata["photo"] = proxy_url($r[0]["photo"]); + $profiledata["photo"] = proxy_url($r[0]["avatar"]); if ($r[0]["nick"] != "") $profiledata["nickname"] = $r[0]["nick"]; } diff --git a/view/templates/profile_vcard.tpl b/view/templates/profile_vcard.tpl index e72d25371d..9bbb7f8a42 100644 --- a/view/templates/profile_vcard.tpl +++ b/view/templates/profile_vcard.tpl @@ -35,6 +35,8 @@ {{if $homepage}}
{{$homepage}}
{{$profile.homepage}}
{{/if}} + {{if $about}}
{{$about}}
{{$profile.about}}
{{/if}} + {{include file="diaspora_vcard.tpl"}}