X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fdfrn.php;h=09688586a3599fe19214c01f88ae0564a0d52321;hb=a941199760420298d5977b285e2016d860b1e073;hp=877b529badba4a752379f69c9da081c2ebecba39;hpb=fd468f20fd4f5bc54db3659a8567301007c0c1cc;p=friendica.git diff --git a/include/dfrn.php b/include/dfrn.php index 877b529bad..09688586a3 100644 --- a/include/dfrn.php +++ b/include/dfrn.php @@ -216,13 +216,10 @@ class dfrn { dbesc($sort) ); - if (!dbm::is_result($r)) { - /// @TODO Some logging? - killme(); - } - - // Will check further below if this actually returned results. - // We will provide an empty feed if that is the case. + /* + * Will check further below if this actually returned results. + * We will provide an empty feed if that is the case. + */ $items = $r; @@ -243,10 +240,10 @@ class dfrn { $root = self::add_header($doc, $owner, $author, $alternatelink, true); - // This hook can't work anymore + /// @TODO This hook can't work anymore // call_hooks('atom_feed', $atom); - if (!count($items) OR $onlyheader) { + if (!dbm::is_result($items) OR $onlyheader) { $atom = trim($doc->saveXML()); call_hooks('atom_feed_end', $atom); @@ -557,7 +554,7 @@ class dfrn { xml::add_element($doc, $author, "poco:displayName", $profile["name"]); xml::add_element($doc, $author, "poco:updated", $namdate); - if (trim($profile["dob"]) != "0000-00-00") + if (trim($profile["dob"]) > '0001-01-01') xml::add_element($doc, $author, "poco:birthday", "0000-".date("m-d", strtotime($profile["dob"]))); xml::add_element($doc, $author, "poco:note", $profile["about"]); @@ -918,12 +915,7 @@ class dfrn { intval($owner["uid"]), dbesc(normalise_link($mention))); - if (!dbm::is_result($r)) { - /// @TODO Maybe some logging? - killme(); - } - - if ($r[0]["forum"] OR $r[0]["prv"]) { + if (dbm::is_result($r) AND ($r[0]["forum"] OR $r[0]["prv"])) { xml::add_element($doc, $entry, "link", "", array("rel" => "mentioned", "ostatus:object-type" => ACTIVITY_OBJ_GROUP, "href" => $mention)); @@ -939,6 +931,30 @@ class dfrn { return $entry; } + /** + * @brief encrypts data via AES + * + * @param string $data The data that is to be encrypted + * @param string $key The AES key + * + * @return string encrypted data + */ + private static function aes_encrypt($data, $key) { + return openssl_encrypt($data, 'aes-128-ecb', $key, OPENSSL_RAW_DATA); + } + + /** + * @brief decrypts data via AES + * + * @param string $encrypted The encrypted data + * @param string $key The AES key + * + * @return string decrypted data + */ + public static function aes_decrypt($encrypted, $key) { + return openssl_decrypt($encrypted, 'aes-128-ecb', $key, OPENSSL_RAW_DATA); + } + /** * @brief Delivers the atom content to the contacts * @@ -963,14 +979,9 @@ class dfrn { $idtosend = '1:' . $orig_id; } - $rino = get_config('system','rino_encrypt'); + $rino = get_config('system', 'rino_encrypt'); $rino = intval($rino); - // use RINO1 if mcrypt isn't installed and RINO2 was selected - if ($rino == 2 and !function_exists('mcrypt_create_iv')) { - $rino = 1; - } - logger("Local rino version: ". $rino, LOGGER_DEBUG); $ssl_val = intval(get_config('system','ssl_policy')); @@ -1101,8 +1112,8 @@ class dfrn { switch ($rino_remote_version) { case 1: // Deprecated rino version! - $key = substr(random_string(), 0, 16); - $data = aes_encrypt($postvars['data'],$key); + $key = openssl_random_pseudo_bytes(16); + $data = self::aes_encrypt($postvars['data'], $key); break; case 2: // RINO 2 based on php-encryption @@ -1137,10 +1148,9 @@ class dfrn { if ($dfrn_version >= 2.1) { - if (($contact['duplex'] && strlen($contact['pubkey'])) { - || ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey'])) - || ($contact['rel'] == CONTACT_IS_SHARING && strlen($contact['pubkey']))) - + if (($contact['duplex'] && strlen($contact['pubkey'])) + || ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey'])) + || ($contact['rel'] == CONTACT_IS_SHARING && strlen($contact['pubkey']))) { openssl_public_encrypt($key,$postvars['key'],$contact['pubkey']); } else { openssl_private_encrypt($key,$postvars['key'],$contact['prvkey']); @@ -1392,7 +1402,7 @@ class dfrn { // "poco:birthday" is the birthday in the format "yyyy-mm-dd" $value = $xpath->evaluate($element . "/poco:birthday/text()", $context)->item(0)->nodeValue; - if (!in_array($value, array("", "0000-00-00"))) { + if (!in_array($value, array("", "0000-00-00", "0001-01-01"))) { $bdyear = date("Y"); $value = str_replace("0000", $bdyear, $value); @@ -1467,7 +1477,9 @@ class dfrn { $poco["photo"] = $author["avatar"]; $poco["hide"] = $hide; $poco["contact-type"] = $contact["contact-type"]; - update_gcontact($poco); + $gcid = update_gcontact($poco); + + link_gcontact($gcid, $importer["uid"], $contact["id"]); } return($author); @@ -1751,11 +1763,7 @@ class dfrn { intval($importer["importer_uid"])); if (!dbm::is_result($r)) { - /* - * @TODO maybe one day: logger("Query failed to execute, no result returned in " . __FUNCTION__); - killme(); - */ return false; } @@ -2121,11 +2129,7 @@ class dfrn { ); if (!dbm::is_result($r)) { - /* - * @TODO maybe one day: logger("Query failed to execute, no result returned in " . __FUNCTION__); - killme(); - */ return false; }