]> git.mxchange.org Git - friendica.git/commitdiff
Scrape now doesn't fetch page data when its twitter and Co./Update script that update...
authorMichael Vogel <icarus@dabo.de>
Mon, 26 Jan 2015 00:07:15 +0000 (01:07 +0100)
committerMichael Vogel <icarus@dabo.de>
Mon, 26 Jan 2015 00:07:15 +0000 (01:07 +0100)
include/Scrape.php
include/socgraph.php
mod/profiles.php
update.php

index 31e2be263fc3c8910ab6deb7d4c58742924d740d..7df86d9f2d7cd4fe3d85372a85e8f80b61873cf9 100644 (file)
@@ -356,6 +356,23 @@ function probe_url($url, $mode = PROBE_NORMAL) {
        $diaspora_key = '';
        $has_lrdd = false;
        $email_conversant = false;
+       $connectornetworks = false;
+       $appnet = false;
+
+       if (strpos($url,'twitter.com')) {
+               $connectornetworks = true;
+               $network = NETWORK_TWITTER;
+       }
+
+       if (strpos($url,'www.facebook.com')) {
+               $connectornetworks = true;
+               $network = NETWORK_FACEBOOK;
+       }
+
+       if (strpos($url,'alpha.app.net')) {
+               $appnet = true;
+               $network = NETWORK_APPNET;
+       }
 
        // Twitter is deactivated since twitter closed its old API
        //$twitter = ((strpos($url,'twitter.com') !== false) ? true : false);
@@ -363,7 +380,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
 
        $at_addr = ((strpos($url,'@') !== false) ? true : false);
 
-       if((! $twitter) && (! $lastfm)) {
+       if((!$appnet) && (!$lastfm) && !$connectornetworks) {
 
                if(strpos($url,'mailto:') !== false && $at_addr) {
                        $url = str_replace('mailto:','',$url);
@@ -606,13 +623,16 @@ function probe_url($url, $mode = PROBE_NORMAL) {
                        // Will leave it to others to figure out how to grab the avatar, which is on the $url page in the open graph meta links
                }
 
-               if($twitter || ! $poll)
+               if($appnet || ! $poll)
                        $check_feed = true;
                if((! isset($vcard)) || (! x($vcard,'fn')) || (! $profile))
                        $check_feed = true;
                if(($at_addr) && (! count($links)))
                        $check_feed = false;
 
+               if ($connectornetworks)
+                       $check_feed = false;
+
                if($check_feed) {
 
                        $feedret = scrape_feed(($poll) ? $poll : $url);
index f2ccd946a8685286fa89f1bb31989a5f43897eb6..07bbee32ac013938f47b0e96f473b790b5607cb7 100644 (file)
@@ -116,20 +116,18 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
                        foreach($entry->tags as $tag)
                                $keywords = implode(", ", $tag);
 
-               if ($network != "") {
-                       poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $gender, $keywords, $connect_url, $updated, $cid, $uid, $zcid);
-
-                       // Update the Friendica contacts. Diaspora is doing it via a message. (See include/diaspora.php)
-                       if (($location != "") OR ($about != "") OR ($keywords != "") OR ($gender != ""))
-                               q("UPDATE `contact` SET `location` = '%s', `about` = '%s', `keywords` = '%s', `gender` = '%s'
-                                       WHERE `nurl` = '%s' AND NOT `self` AND `network` = '%s'",
-                                       dbesc($location),
-                                       dbesc($about),
-                                       dbesc($keywords),
-                                       dbesc($gender),
-                                       dbesc(normalise_link($profile_url)),
-                                       dbesc(NETWORK_DFRN));
-               }
+               poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $gender, $keywords, $connect_url, $updated, $cid, $uid, $zcid);
+
+               // Update the Friendica contacts. Diaspora is doing it via a message. (See include/diaspora.php)
+               if (($location != "") OR ($about != "") OR ($keywords != "") OR ($gender != ""))
+                       q("UPDATE `contact` SET `location` = '%s', `about` = '%s', `keywords` = '%s', `gender` = '%s'
+                               WHERE `nurl` = '%s' AND NOT `self` AND `network` = '%s'",
+                               dbesc($location),
+                               dbesc($about),
+                               dbesc($keywords),
+                               dbesc($gender),
+                               dbesc(normalise_link($profile_url)),
+                               dbesc(NETWORK_DFRN));
        }
        logger("poco_load: loaded $total entries",LOGGER_DEBUG);
 
@@ -147,6 +145,12 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
        if ($profile_url == "")
                return $gcid;
 
+       $x = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
+               dbesc(normalise_link($profile_url))
+       );
+       if(count($x))
+               $network = $x[0]["network"];
+
        if (($network == "") OR ($name == "") OR ($profile_photo == "")) {
                require_once("include/Scrape.php");
 
@@ -156,17 +160,20 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
                $profile_photo = $data["photo"];
        }
 
-       if (!in_array($network, array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_STATUSNET)))
-               return $gcid;
+       if (count($x) AND ($x[0]["network"] == "") AND ($network != "")) {
+               q("UPDATE `gcontact` SET `network` = '%s' WHERE `nurl` = '%s'",
+                       dbesc($network),
+                       dbesc(normalise_link($profile_url))
+               );
+       }
 
        if (($name == "") OR ($profile_photo == ""))
                return $gcid;
 
-       logger("profile-check URL: ".$profile_url." name: ".$name." avatar: ".$profile_photo, LOGGER_DEBUG);
+       if (!in_array($network, array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_STATUSNET)))
+               return $gcid;
 
-       $x = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
-               dbesc(normalise_link($profile_url))
-       );
+       logger("profile-check URL: ".$profile_url." name: ".$name." avatar: ".$profile_photo, LOGGER_DEBUG);
 
        if(count($x)) {
                $gcid = $x[0]['id'];
index e71a4c603aa7ae7dab2abfc040f46344555620d7..befeedb2efac11dceff01e7b0996b507def97bb5 100644 (file)
@@ -149,6 +149,7 @@ function profile_clean_keywords($keywords) {
        $cleaned = array();
        foreach ($keywords as $keyword) {
                $keyword = trim(strtolower($keyword));
+               $keyword = trim($keyword, "#");
                if ($keyword != "")
                        $cleaned[] = $keyword;
        }
index 019e4cad343a64c947cf25c7ac4bc89f5d3de9b4..e80de3526a4b091917a839f39733b221e6556d22 100644 (file)
@@ -1609,3 +1609,24 @@ All following update functions are ONLY for jobs that need to run AFTER the data
 
 Database changes are ONLY applied in the file include/dbstructure.php.
 */
+
+function update_1177() {
+       require_once("mod/profiles.php");
+
+       $profiles = q("SELECT `uid`, `about`, `locality`, `pub_keywords`, `gender` FROM `profile` WHERE `is-default`");
+
+       foreach ($profiles AS $profile) {
+               if ($profile["about"].$profile["locality"].$profile["pub_keywords"].$profile["gender"] == "")
+                       continue;
+
+               $profile["pub_keywords"] = profile_clean_keywords($profile["pub_keywords"]);
+
+               $r = q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d",
+                               dbesc($profile["about"]),
+                               dbesc($profile["locality"]),
+                               dbesc($profile["pub_keywords"]),
+                               dbesc($profile["gender"]),
+                               intval($profile["uid"])
+                       );
+       }
+}