And some more removed notices in the core (#5465)
This commit is contained in:
parent
cd52d0b3e9
commit
53876abfda
5 changed files with 48 additions and 46 deletions
2
boot.php
2
boot.php
|
@ -1108,7 +1108,7 @@ function explode_querystring($query)
|
||||||
function curPageURL()
|
function curPageURL()
|
||||||
{
|
{
|
||||||
$pageURL = 'http';
|
$pageURL = 'http';
|
||||||
if ($_SERVER["HTTPS"] == "on") {
|
if (!empty($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on")) {
|
||||||
$pageURL .= "s";
|
$pageURL .= "s";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,8 @@ function hovercard_content()
|
||||||
// Get the photo_menu - the menu if possible contact actions
|
// Get the photo_menu - the menu if possible contact actions
|
||||||
if (local_user()) {
|
if (local_user()) {
|
||||||
$actions = Contact::photoMenu($contact);
|
$actions = Contact::photoMenu($contact);
|
||||||
|
} else {
|
||||||
|
$actions = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the contact data to the profile array so we can deliver it to
|
// Move the contact data to the profile array so we can deliver it to
|
||||||
|
|
|
@ -1218,9 +1218,16 @@ class DFRN
|
||||||
|
|
||||||
$res = XML::parseString($xml);
|
$res = XML::parseString($xml);
|
||||||
|
|
||||||
if ((intval($res->status) != 0) || !strlen($res->challenge) || !strlen($res->dfrn_id)) {
|
if (!is_object($res) || (intval($res->status) != 0) || !strlen($res->challenge) || !strlen($res->dfrn_id)) {
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
return ($res->status ? $res->status : 3);
|
|
||||||
|
if (empty($res->status)) {
|
||||||
|
$status = 3;
|
||||||
|
} else {
|
||||||
|
$status = $res->status;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
$postvars = [];
|
$postvars = [];
|
||||||
|
|
|
@ -1040,48 +1040,28 @@ class Diaspora
|
||||||
*/
|
*/
|
||||||
private static function contactByHandle($uid, $handle)
|
private static function contactByHandle($uid, $handle)
|
||||||
{
|
{
|
||||||
// First do a direct search on the contact table
|
|
||||||
$r = q(
|
|
||||||
"SELECT * FROM `contact` WHERE `uid` = %d AND `addr` = '%s' LIMIT 1",
|
|
||||||
intval($uid),
|
|
||||||
dbesc($handle)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
return $r[0];
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* We haven't found it?
|
|
||||||
* We use another function for it that will possibly create a contact entry.
|
|
||||||
*/
|
|
||||||
$cid = Contact::getIdForURL($handle, $uid);
|
$cid = Contact::getIdForURL($handle, $uid);
|
||||||
|
if (!$cid) {
|
||||||
if ($cid > 0) {
|
|
||||||
/// @TODO Contact retrieval should be encapsulated into an "entity" class like `Contact`
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($cid));
|
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
return $r[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$handle_parts = explode("@", $handle);
|
$handle_parts = explode("@", $handle);
|
||||||
$nurl_sql = "%%://" . $handle_parts[1] . "%%/profile/" . $handle_parts[0];
|
$nurl_sql = "%%://" . $handle_parts[1] . "%%/profile/" . $handle_parts[0];
|
||||||
$r = q(
|
$cid = Contact::getIdForURL($nurl_sql, $uid);
|
||||||
"SELECT * FROM `contact` WHERE `network` = '%s' AND `uid` = %d AND `nurl` LIKE '%s' LIMIT 1",
|
|
||||||
dbesc(NETWORK_DFRN),
|
|
||||||
intval($uid),
|
|
||||||
dbesc($nurl_sql)
|
|
||||||
);
|
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
return $r[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger("Haven't found contact for user ".$uid." and handle ".$handle, LOGGER_DEBUG);
|
if (!$cid) {
|
||||||
|
logger("Haven't found a contact for user " . $uid . " and handle " . $handle, LOGGER_DEBUG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$contact = dba::selectFirst('contact', [], ['id' => $cid]);
|
||||||
|
if (!DBM::is_result($contact)) {
|
||||||
|
// This here shouldn't happen at all
|
||||||
|
logger("Haven't found a contact for user " . $uid . " and handle " . $handle, LOGGER_DEBUG);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $contact;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if posting is allowed for this contact
|
* @brief Check if posting is allowed for this contact
|
||||||
*
|
*
|
||||||
|
@ -1147,7 +1127,9 @@ class Diaspora
|
||||||
if (!$contact) {
|
if (!$contact) {
|
||||||
logger("A Contact for handle ".$handle." and user ".$importer["uid"]." was not found");
|
logger("A Contact for handle ".$handle." and user ".$importer["uid"]." was not found");
|
||||||
// If a contact isn't found, we accept it anyway if it is a comment
|
// If a contact isn't found, we accept it anyway if it is a comment
|
||||||
if ($is_comment) {
|
if ($is_comment && ($importer["uid"] != 0)) {
|
||||||
|
return self::contactByHandle(0, $handle);
|
||||||
|
} elseif ($is_comment) {
|
||||||
return $importer;
|
return $importer;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1268,6 +1250,11 @@ class Diaspora
|
||||||
private static function storeByGuid($guid, $server, $uid = 0)
|
private static function storeByGuid($guid, $server, $uid = 0)
|
||||||
{
|
{
|
||||||
$serverparts = parse_url($server);
|
$serverparts = parse_url($server);
|
||||||
|
|
||||||
|
if (empty($serverparts["host"]) || empty($serverparts["scheme"])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$server = $serverparts["scheme"]."://".$serverparts["host"];
|
$server = $serverparts["scheme"]."://".$serverparts["host"];
|
||||||
|
|
||||||
logger("Trying to fetch item ".$guid." from ".$server, LOGGER_DEBUG);
|
logger("Trying to fetch item ".$guid." from ".$server, LOGGER_DEBUG);
|
||||||
|
|
|
@ -1229,19 +1229,25 @@ class PortableContact
|
||||||
|
|
||||||
$site_name = $data->site->name;
|
$site_name = $data->site->name;
|
||||||
|
|
||||||
$data->site->closed = self::toBoolean($data->site->closed);
|
$private = false;
|
||||||
|
$inviteonly = false;
|
||||||
|
$closed = false;
|
||||||
|
|
||||||
|
if (!empty($data->site->closed)) {
|
||||||
|
$closed = self::toBoolean($data->site->closed);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($data->site->private)) {
|
if (!empty($data->site->private)) {
|
||||||
$data->site->private = self::toBoolean($data->site->private);
|
$private = self::toBoolean($data->site->private);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data->site->inviteonly)) {
|
if (!empty($data->site->inviteonly)) {
|
||||||
$data->site->inviteonly = self::toBoolean($data->site->inviteonly);
|
$inviteonly = self::toBoolean($data->site->inviteonly);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$data->site->closed && !$data->site->private and $data->site->inviteonly) {
|
if (!$closed && !$private and $inviteonly) {
|
||||||
$register_policy = REGISTER_APPROVE;
|
$register_policy = REGISTER_APPROVE;
|
||||||
} elseif (!$data->site->closed && !$data->site->private) {
|
} elseif (!$closed && !$private) {
|
||||||
$register_policy = REGISTER_OPEN;
|
$register_policy = REGISTER_OPEN;
|
||||||
} else {
|
} else {
|
||||||
$register_policy = REGISTER_CLOSED;
|
$register_policy = REGISTER_CLOSED;
|
||||||
|
@ -1649,7 +1655,7 @@ class PortableContact
|
||||||
}
|
}
|
||||||
$last_update = date("c", time() - (60 * 60 * 24 * $requery_days));
|
$last_update = date("c", time() - (60 * 60 * 24 * $requery_days));
|
||||||
|
|
||||||
$r = q("SELECT `id`, `url`, `network` FROM `gserver` WHERE `last_contact` >= `last_failure` AND `poco` != '' AND `last_poco_query` < '%s' ORDER BY RAND()", dbesc($last_update));
|
$r = q("SELECT `id`, `url`, `nurl`, `network` FROM `gserver` WHERE `last_contact` >= `last_failure` AND `poco` != '' AND `last_poco_query` < '%s' ORDER BY RAND()", dbesc($last_update));
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($r)) {
|
||||||
foreach ($r as $server) {
|
foreach ($r as $server) {
|
||||||
if (!self::checkServer($server["url"], $server["network"])) {
|
if (!self::checkServer($server["url"], $server["network"])) {
|
||||||
|
|
Loading…
Reference in a new issue