diff --git a/include/api.php b/include/api.php index 0f7fa85bd..10ee29287 100644 --- a/include/api.php +++ b/include/api.php @@ -43,6 +43,7 @@ use Friendica\Protocol\Diaspora; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; use Friendica\Util\Proxy as ProxyUtils; +use Friendica\Util\Strings; use Friendica\Util\XML; require_once 'include/conversation.php'; @@ -4802,7 +4803,7 @@ function api_friendica_remoteauth() $dfrn_id = '0:' . $orig_id; } - $sec = random_string(); + $sec = Strings::getRandomHex(); $fields = ['uid' => api_user(), 'cid' => $cid, 'dfrn_id' => $dfrn_id, 'sec' => $sec, 'expire' => time() + 45]; diff --git a/include/enotify.php b/include/enotify.php index d6ca12327..2033027e3 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -15,6 +15,7 @@ use Friendica\Model\Contact; use Friendica\Model\Item; use Friendica\Util\DateTimeFormat; use Friendica\Util\Emailer; +use Friendica\Util\Strings; /** * @brief Creates a notification entry and possibly sends a mail @@ -457,7 +458,7 @@ function notification($params) Logger::log("adding notification entry", Logger::DEBUG); do { $dups = false; - $hash = random_string(); + $hash = Strings::getRandomHex(); if (DBA::exists('notify', ['hash' => $hash])) { $dups = true; } diff --git a/include/items.php b/include/items.php index 9929f535f..adc5bf013 100644 --- a/include/items.php +++ b/include/items.php @@ -21,6 +21,7 @@ use Friendica\Protocol\OStatus; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; use Friendica\Util\ParseUrl; +use Friendica\Util\Strings; use Friendica\Util\Temporal; require_once 'include/text.php'; @@ -308,7 +309,7 @@ function subscribe_to_hub($url, array $importer, array $contact, $hubmode = 'sub $push_url = System::baseUrl() . '/pubsub/' . $user['nickname'] . '/' . $contact['id']; // Use a single verify token, even if multiple hubs - $verify_token = ((strlen($contact['hub-verify'])) ? $contact['hub-verify'] : random_string()); + $verify_token = ((strlen($contact['hub-verify'])) ? $contact['hub-verify'] : Strings::getRandomHex()); $params= 'hub.mode=' . $hubmode . '&hub.callback=' . urlencode($push_url) . '&hub.topic=' . urlencode($contact['poll']) . '&hub.verify=async&hub.verify_token=' . $verify_token; diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 0f001b11a..8d4594c15 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -33,6 +33,7 @@ use Friendica\Protocol\ActivityPub; use Friendica\Util\Crypto; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; +use Friendica\Util\Strings; use Friendica\Util\XML; require_once 'include/enotify.php'; @@ -263,7 +264,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) break; case 1: // birthday paradox - generate new dfrn-id and fall through. - $new_dfrn_id = random_string(); + $new_dfrn_id = Strings::getRandomHex(); q("UPDATE contact SET `issued-id` = '%s' WHERE `id` = %d AND `uid` = %d", DBA::escape($new_dfrn_id), intval($contact_id), diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index b14c71fb8..ba2332bcb 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -14,6 +14,7 @@ use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Protocol\DFRN; use Friendica\Protocol\Diaspora; +use Friendica\Util\Strings; require_once 'include/items.php'; @@ -267,7 +268,7 @@ function dfrn_notify_content(App $a) { $dfrn_id = substr($dfrn_id,2); } - $hash = random_string(); + $hash = Strings::getRandomHex(); $status = 0; diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index a961506d1..9cd110917 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -14,6 +14,7 @@ use Friendica\Module\Login; use Friendica\Protocol\DFRN; use Friendica\Protocol\OStatus; use Friendica\Util\Network; +use Friendica\Util\Strings; use Friendica\Util\XML; require_once 'include/items.php'; @@ -415,7 +416,7 @@ function dfrn_poll_content(App $a) if ($dfrn_id != '') { // initial communication from external contact - $hash = random_string(); + $hash = Strings::getRandomHex(); $status = 0; diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index fdb1a42ee..e5d5a3fe2 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -28,6 +28,7 @@ use Friendica\Module\Login; use Friendica\Network\Probe; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; +use Friendica\Util\Strings; require_once 'include/enotify.php'; @@ -320,7 +321,7 @@ function dfrn_request_post(App $a) } } - $issued_id = random_string(); + $issued_id = Strings::getRandomHex(); if (is_array($contact_record)) { // There is a contact record but no issued-id, so this @@ -415,7 +416,7 @@ function dfrn_request_post(App $a) return; } - $hash = random_string() . (string) time(); // Generate a confirm_key + $hash = Strings::getRandomHex() . (string) time(); // Generate a confirm_key if (is_array($contact_record)) { $ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime`) diff --git a/mod/fsuggest.php b/mod/fsuggest.php index 35710bb33..f87046f6c 100644 --- a/mod/fsuggest.php +++ b/mod/fsuggest.php @@ -9,6 +9,7 @@ use Friendica\Core\L10n; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; +use Friendica\Util\Strings; function fsuggest_post(App $a) { @@ -34,7 +35,7 @@ function fsuggest_post(App $a) $new_contact = intval($_POST['suggest']); - $hash = random_string(); + $hash = Strings::getRandomHex(); $note = escape_tags(trim(defaults($_POST, 'note', ''))); diff --git a/mod/pubsubhubbub.php b/mod/pubsubhubbub.php index ea27f0482..26a157e2f 100644 --- a/mod/pubsubhubbub.php +++ b/mod/pubsubhubbub.php @@ -93,7 +93,7 @@ function pubsubhubbub_init(App $a) { } // do subscriber verification according to the PuSH protocol - $hub_challenge = random_string(40); + $hub_challenge = Strings::getRandomHex(40); $params = 'hub.mode=' . ($subscribe == 1 ? 'subscribe' : 'unsubscribe') . '&hub.topic=' . urlencode($hub_topic) . diff --git a/mod/redir.php b/mod/redir.php index 088a5f55e..6077a26f9 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -8,6 +8,7 @@ use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Model\Profile; +use Friendica\Util\Strings; function redir_init(App $a) { @@ -93,7 +94,7 @@ function redir_init(App $a) { $dfrn_id = '0:' . $orig_id; } - $sec = random_string(); + $sec = Strings::getRandomHex(); $fields = ['uid' => local_user(), 'cid' => $cid, 'dfrn_id' => $dfrn_id, 'sec' => $sec, 'expire' => time() + 45]; diff --git a/mod/removeme.php b/mod/removeme.php index c2ceb7d4c..44671ef07 100644 --- a/mod/removeme.php +++ b/mod/removeme.php @@ -68,7 +68,7 @@ function removeme_content(App $a) $a->internalRedirect(); } - $hash = random_string(); + $hash = Strings::getRandomHex(); require_once("mod/settings.php"); settings_init($a); diff --git a/spec/dfrn2_contact_request.svg b/spec/dfrn2_contact_request.svg index cc78be55c..34de340f3 100644 --- a/spec/dfrn2_contact_request.svg +++ b/spec/dfrn2_contact_request.svg @@ -38,7 +38,7 @@ text { font:12px Dialog; } where self = 0 to look if this contact is already there (if issued-id or rel is already available return here because it seems that we are already connected) -- create a issued-id with $issued_id = random_string(); +- create a issued-id with $issued_id = Strings::getRandomHex(); - if we already found a contact record above update the issued-id with the one we have created - otherwise if Bob is not already in the contact table scrape diff --git a/src/Content/Text/HTML.php b/src/Content/Text/HTML.php index cdfd41c11..9b73da56d 100644 --- a/src/Content/Text/HTML.php +++ b/src/Content/Text/HTML.php @@ -7,6 +7,7 @@ namespace Friendica\Content\Text; use DOMDocument; use DOMXPath; +use Friendica\Content\Feature; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\Config; @@ -17,9 +18,9 @@ use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Util\Network; use Friendica\Util\Proxy as ProxyUtils; +use Friendica\Util\Strings; use Friendica\Util\XML; use League\HTMLToMarkdown\HtmlConverter; -use Friendica\Content\Feature; class HTML { @@ -1011,7 +1012,7 @@ class HTML $tpl = Renderer::getMarkupTemplate('wall/content_filter.tpl'); $html = Renderer::replaceMacros($tpl, [ '$reasons' => $reasons, - '$rnd' => random_string(8), + '$rnd' => Strings::getRandomHex(8), '$openclose' => L10n::t('Click to open/close'), '$html' => $html ]); diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 5d571e30e..1a6349d9c 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -25,6 +25,7 @@ use Friendica\Protocol\PortableContact; use Friendica\Protocol\Salmon; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; +use Friendica\Util\Strings; require_once 'boot.php'; require_once 'include/dba.php'; @@ -1889,7 +1890,7 @@ class Contact extends BaseObject $user = DBA::selectFirst('user', $fields, ['uid' => $importer['uid']]); if (DBA::isResult($user) && !in_array($user['page-flags'], [self::PAGE_SOAPBOX, self::PAGE_FREELOVE, self::PAGE_COMMUNITY])) { // create notification - $hash = random_string(); + $hash = Strings::getRandomHex(); if (is_array($contact_record)) { DBA::insert('intro', ['uid' => $importer['uid'], 'contact-id' => $contact_record['id'], diff --git a/src/Model/Item.php b/src/Model/Item.php index 1eb96609f..35dfb7264 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -33,6 +33,7 @@ use Friendica\Util\DateTimeFormat; use Friendica\Util\Map; use Friendica\Util\XML; use Friendica\Util\Security; +use Friendica\Util\Strings; use Text_LanguageDetect; require_once 'boot.php'; @@ -3479,7 +3480,7 @@ class Item extends BaseObject while ((strpos($s, $spoilersearch) !== false)) { $pos = strpos($s, $spoilersearch); - $rnd = random_string(8); + $rnd = Strings::getRandomHex(8); $spoilerreplace = '
' . L10n::t('Click to open/close') . ''. '