From: Michael Vogel Date: Mon, 26 Jan 2015 00:07:15 +0000 (+0100) Subject: Scrape now doesn't fetch page data when its twitter and Co./Update script that update... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e8bfa32b37665a6c88e3ae4b43880a7f84be084f;p=friendica.git Scrape now doesn't fetch page data when its twitter and Co./Update script that updates the contacts from the profile --- diff --git a/include/Scrape.php b/include/Scrape.php index 31e2be263f..7df86d9f2d 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -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); diff --git a/include/socgraph.php b/include/socgraph.php index f2ccd946a8..07bbee32ac 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -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']; diff --git a/mod/profiles.php b/mod/profiles.php index e71a4c603a..befeedb2ef 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -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; } diff --git a/update.php b/update.php index 019e4cad34..e80de3526a 100644 --- a/update.php +++ b/update.php @@ -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"]) + ); + } +}