+
+ /**
+ * Returns contact ID for given user ID
+ *
+ * @param integer $uid User ID
+ * @return integer Contact ID of visitor for given user ID
+ */
+ public static function getRemoteContactID($uid)
+ {
+ if (empty($_SESSION['remote'][$uid])) {
+ return false;
+ }
+
+ return $_SESSION['remote'][$uid];
+ }
+
+ /**
+ * Returns User ID for given contact ID of the visitor
+ *
+ * @param integer $cid Contact ID
+ * @return integer User ID for given contact ID of the visitor
+ */
+ public static function getUserIDForVisitorContactID($cid)
+ {
+ if (empty($_SESSION['remote'])) {
+ return false;
+ }
+
+ return array_search($cid, $_SESSION['remote']);
+ }
+
+ /**
+ * Set the session variable that contains the contact IDs for the visitor's contact URL
+ *
+ * @param string $url Contact URL
+ */
+ public static function setVisitorsContacts()
+ {
+ $_SESSION['remote'] = [];
+
+ $remote_contacts = DBA::select('contact', ['id', 'uid'], ['nurl' => Strings::normaliseLink($_SESSION['my_url']), 'rel' => [Contact::FOLLOWER, Contact::FRIEND], 'self' => false]);
+ while ($contact = DBA::fetch($remote_contacts)) {
+ if (($contact['uid'] == 0) || Contact::isBlockedByUser($contact['id'], $contact['uid'])) {
+ continue;
+ }
+
+ $_SESSION['remote'][$contact['uid']] = $contact['id'];
+ }
+ DBA::close($remote_contacts);
+ }
+
+ /**
+ * Returns if the current visitor is authenticated
+ *
+ * @return boolean "true" when visitor is either a local or remote user
+ */
+ public static function isAuthenticated()
+ {
+ if (empty($_SESSION['authenticated'])) {
+ return false;
+ }
+
+ return $_SESSION['authenticated'];
+ }