]> git.mxchange.org Git - friendica.git/blobdiff - include/socgraph.php
Merge remote-tracking branch 'upstream/develop' into rewrites/coding-convention
[friendica.git] / include / socgraph.php
index ec7446cdc58e580d5f24c473dd1bdf308bf2ed30..4dedd33d398f22a600c2b1112580204236c963d0 100644 (file)
@@ -81,7 +81,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
                $connect_url = '';
                $name = '';
                $network = '';
-               $updated = '0000-00-00 00:00:00';
+               $updated = NULL_DATE;
                $location = '';
                $about = '';
                $keywords = '';
@@ -239,12 +239,12 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
        );
 
        if (count($x)) {
-               if (($network == "") AND ($x[0]["network"] != NETWORK_STATUSNET))
+               if (($network == "") AND ($x[0]["network"] != NETWORK_STATUSNET)) {
                        $network = $x[0]["network"];
-
-               if ($updated == "0000-00-00 00:00:00")
+               }
+               if ($updated <= NULL_DATE) {
                        $updated = $x[0]["updated"];
-
+               }
                $created = $x[0]["created"];
                $server_url = $x[0]["server_url"];
                $nick = $x[0]["nick"];
@@ -252,7 +252,7 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
                $alias =  $x[0]["alias"];
                $notify =  $x[0]["notify"];
        } else {
-               $created = "0000-00-00 00:00:00";
+               $created = NULL_DATE;
                $server_url = "";
 
                $urlparts = parse_url($profile_url);
@@ -465,10 +465,10 @@ function poco_last_updated($profile, $force = false) {
        $gcontacts = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s'",
                        dbesc(normalise_link($profile)));
 
-       if ($gcontacts[0]["created"] == "0000-00-00 00:00:00")
+       if ($gcontacts[0]["created"] <= NULL_DATE) {
                q("UPDATE `gcontact` SET `created` = '%s' WHERE `nurl` = '%s'",
                        dbesc(datetime_convert()), dbesc(normalise_link($profile)));
-
+       }
        if ($gcontacts[0]["server_url"] != "") {
                $server_url = $gcontacts[0]["server_url"];
        }
@@ -664,10 +664,11 @@ function poco_last_updated($profile, $force = false) {
        }
 
        // Maybe there aren't any entries. Then check if it is a valid feed
-       if ($last_updated == "")
-               if ($xpath->query('/atom:feed')->length > 0)
-                       $last_updated = "0000-00-00 00:00:00";
-
+       if ($last_updated == "") {
+               if ($xpath->query('/atom:feed')->length > 0) {
+                       $last_updated = NULL_DATE;
+               }
+       }
        q("UPDATE `gcontact` SET `updated` = '%s', `last_contact` = '%s' WHERE `nurl` = '%s'",
                dbesc(dbm::date($last_updated)), dbesc(dbm::date()), dbesc(normalise_link($profile)));
 
@@ -946,10 +947,10 @@ function poco_check_server($server_url, $network = "", $force = false) {
        $servers = q("SELECT * FROM `gserver` WHERE `nurl` = '%s'", dbesc(normalise_link($server_url)));
        if (dbm::is_result($servers)) {
 
-               if ($servers[0]["created"] == "0000-00-00 00:00:00")
+               if ($servers[0]["created"] <= NULL_DATE) {
                        q("UPDATE `gserver` SET `created` = '%s' WHERE `nurl` = '%s'",
                                dbesc(datetime_convert()), dbesc(normalise_link($server_url)));
-
+               }
                $poco = $servers[0]["poco"];
                $noscrape = $servers[0]["noscrape"];
 
@@ -977,8 +978,8 @@ function poco_check_server($server_url, $network = "", $force = false) {
                $info = "";
                $register_policy = -1;
 
-               $last_contact = "0000-00-00 00:00:00";
-               $last_failure = "0000-00-00 00:00:00";
+               $last_contact = NULL_DATE;
+               $last_failure = NULL_DATE;
        }
        logger("Server ".$server_url." is outdated or unknown. Start discovery. Force: ".$force." Created: ".$servers[0]["created"]." Failure: ".$last_failure." Contact: ".$last_contact, LOGGER_DEBUG);
 
@@ -1503,7 +1504,7 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
                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)
-               AND `gcontact`.`updated` != '0000-00-00 00:00:00'
+               AND `gcontact`.`updated` >= '%s'
                AND `gcontact`.`last_contact` >= `gcontact`.`last_failure`
                AND `gcontact`.`network` IN (%s)
                GROUP BY `glink`.`gcid` ORDER BY `gcontact`.`updated` DESC,`total` DESC LIMIT %d, %d",
@@ -1511,6 +1512,7 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
                intval($uid),
                intval($uid),
                intval($uid),
+               dbesc(NULL_DATE),
                $sql_network,
                intval($start),
                intval($limit)
@@ -1529,13 +1531,14 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
                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'
+               AND `gcontact`.`updated` >= '%s'
                AND `gcontact`.`last_contact` >= `gcontact`.`last_failure`
                AND `gcontact`.`network` IN (%s)
                ORDER BY rand() LIMIT %d, %d",
                intval($uid),
                intval($uid),
                intval($uid),
+               dbesc(NULL_DATE),
                $sql_network,
                intval($start),
                intval($limit)
@@ -1784,7 +1787,7 @@ function poco_discover_server($data, $default_generation = 0) {
                $connect_url = '';
                $name = '';
                $network = '';
-               $updated = '0000-00-00 00:00:00';
+               $updated = NULL_DATE;
                $location = '';
                $about = '';
                $keywords = '';