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';
$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];
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
Logger::log("adding notification entry", Logger::DEBUG);
do {
$dups = false;
- $hash = random_string();
+ $hash = Strings::getRandomHex();
if (DBA::exists('notify', ['hash' => $hash])) {
$dups = true;
}
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';
$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;
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';
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),
use Friendica\Model\Contact;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\Diaspora;
+use Friendica\Util\Strings;
require_once 'include/items.php';
$dfrn_id = substr($dfrn_id,2);
}
- $hash = random_string();
+ $hash = Strings::getRandomHex();
$status = 0;
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';
if ($dfrn_id != '') {
// initial communication from external contact
- $hash = random_string();
+ $hash = Strings::getRandomHex();
$status = 0;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
+use Friendica\Util\Strings;
require_once 'include/enotify.php';
}
}
- $issued_id = random_string();
+ $issued_id = Strings::getRandomHex();
if (is_array($contact_record)) {
// There is a contact record but no issued-id, so this
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`)
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Strings;
function fsuggest_post(App $a)
{
$new_contact = intval($_POST['suggest']);
- $hash = random_string();
+ $hash = Strings::getRandomHex();
$note = escape_tags(trim(defaults($_POST, 'note', '')));
}
// 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) .
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
+use Friendica\Util\Strings;
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];
$a->internalRedirect();
}
- $hash = random_string();
+ $hash = Strings::getRandomHex();
require_once("mod/settings.php");
settings_init($a);
<text x="904" y="1084" style="font:13px Open Sans">where self = 0 to look if this contact is already there (if </text>
<text x="904" y="1107" style="font:13px Open Sans">issued-id or rel is already available return here because it </text>
<text x="904" y="1130" style="font:13px Open Sans">seems that we are already connected)</text>
-<text x="904" y="1176" style="font:13px Open Sans">- create a issued-id with $issued_id = random_string();</text>
+<text x="904" y="1176" style="font:13px Open Sans">- create a issued-id with $issued_id = Strings::getRandomHex();</text>
<text x="904" y="1222" style="font:13px Open Sans">- if we already found a contact record above update the </text>
<text x="904" y="1245" style="font:13px Open Sans">issued-id with the one we have created</text>
<text x="904" y="1291" style="font:13px Open Sans">- otherwise if Bob is not already in the contact table scrape </text>
use DOMDocument;
use DOMXPath;
+use Friendica\Content\Feature;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\Config;
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
{
$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
]);
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';
$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'],
use Friendica\Util\Map;
use Friendica\Util\XML;
use Friendica\Util\Security;
+use Friendica\Util\Strings;
use Text_LanguageDetect;
require_once 'boot.php';
while ((strpos($s, $spoilersearch) !== false)) {
$pos = strpos($s, $spoilersearch);
- $rnd = random_string(8);
+ $rnd = Strings::getRandomHex(8);
$spoilerreplace = '<br /> <span id="spoiler-wrap-' . $rnd . '" class="spoiler-wrap fakelink" onclick="openClose(\'spoiler-' . $rnd . '\');">' . L10n::t('Click to open/close') . '</span>'.
'<blockquote class="spoiler" id="spoiler-' . $rnd . '" style="display: none;">';
$s = substr($s, 0, $pos) . $spoilerreplace . substr($s, $pos + strlen($spoilersearch));
while ((strpos($s, $authorsearch) !== false)) {
$pos = strpos($s, $authorsearch);
- $rnd = random_string(8);
+ $rnd = Strings::getRandomHex(8);
$authorreplace = '<br /> <span id="author-wrap-' . $rnd . '" class="author-wrap fakelink" onclick="openClose(\'author-' . $rnd . '\');">' . L10n::t('Click to open/close') . '</span>'.
'<blockquote class="author" id="author-' . $rnd . '" style="display: block;">';
$s = substr($s, 0, $pos) . $authorreplace . substr($s, $pos + strlen($authorsearch));
use Friendica\Database\DBA;
use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Strings;
/**
* Class interacting with the register database table
*/
public static function createForApproval($uid, $language, $note = '')
{
- $hash = random_string();
+ $hash = Strings::getRandomHex();
if (!User::exists($uid)) {
return false;
use Friendica\Model\Contact;
use Friendica\Util\HTTPSignature;
use Friendica\Util\Network;
+use Friendica\Util\Strings;
/**
* Magic Auth (remote authentication) module.
$headers = [];
$headers['Accept'] = 'application/x-dfrn+json';
- $headers['X-Open-Web-Auth'] = random_string();
+ $headers['X-Open-Web-Auth'] = Strings::getRandomHex();
// Create a header that is signed with the local users private key.
$headers = HTTPSignature::createSig(
use Friendica\Model\Contact;
use Friendica\Model\OpenWebAuthToken;
use Friendica\Util\HTTPSignature;
+use Friendica\Util\Strings;
/**
* @brief OpenWebAuth verifier and token generator
Logger::log('OWA success: ' . $contact['addr'], Logger::DATA);
$ret['success'] = true;
- $token = random_string(32);
+ $token = Strings::getRandomHex(32);
// Store the generated token in the databe.
OpenWebAuthToken::create('owt', 0, $token, $contact['addr']);
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
+use Friendica\Util\Strings;
use Friendica\Util\XML;
use DomXPath;
$data["nick"] = $data["name"];
$data["photo"] = Network::lookupAvatarByEmail($uri);
$data["url"] = 'mailto:'.$uri;
- $data["notify"] = 'smtp '.random_string();
- $data["poll"] = 'email '.random_string();
+ $data["notify"] = 'smtp ' . Strings::getRandomHex();
+ $data["poll"] = 'email ' . Strings::getRandomHex();
$x = Email::messageMeta($mbox, $msgs[0]);
if (stristr($x[0]->from, $uri)) {
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
+use Friendica\Util\Strings;
use Friendica\Util\XML;
use HTMLPurifier;
use HTMLPurifier_Config;
$fid = $r[0]["id"];
- $hash = random_string();
+ $hash = Strings::getRandomHex();
$r = q(
"INSERT INTO `intro` (`uid`, `fid`, `contact-id`, `note`, `hash`, `datetime`, `blocked`)
return;
}
- $sec = random_string();
+ $sec = Strings::getRandomHex();
DBA::insert('profile_check', ['uid' => local_user(), 'cid' => $cid, 'dfrn_id' => $dfrn_id, 'sec' => $sec, 'expire' => time() + 45]);
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
use Friendica\Util\Network;
+use Friendica\Util\Strings;
use Friendica\Util\XML;
use SimpleXMLElement;
if (in_array($importer["page-flags"], [Contact::PAGE_NORMAL, Contact::PAGE_PRVGROUP])) {
Logger::log("Sending intra message for author ".$author.".", Logger::DEBUG);
- $hash = random_string().(string)time(); // Generate a confirm_key
+ $hash = Strings::getRandomHex().(string)time(); // Generate a confirm_key
$ret = q(
"INSERT INTO `intro` (`uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime`)
return 200;
}
- $logid = random_string(4);
+ $logid = String::getRandomHex(4);
$dest_url = ($public_batch ? $contact["batch"] : $contact["notify"]);
{
$options = [
'type' => 'RsaSignature2017',
- 'nonce' => random_string(64),
+ 'nonce' => Strings::getRandomHex(64),
'creator' => $owner['url'] . '#main-key',
'created' => DateTimeFormat::utcNow(DateTimeFormat::ATOM)
];
* @param int $size
* @return string
*/
- public static function getRandomHex($size = 64) // random_string()
+ public static function getRandomHex($size = 64)
{
$byte_size = ceil($size / 2);