implement compareLink function.
if (strpos($search,'@') === 0) {
$search = substr($search,1);
$header = L10n::t('People Search - %s', $search);
- if ((valid_email($search) && Network::isEmailDomainValid($search)) ||
+ if ((Strings::isValidEmail($search) && Network::isEmailDomainValid($search)) ||
(substr(normalise_link($search), 0, 7) == "http://")) {
$user_data = Probe::uri($search);
$discover_user = (in_array($user_data["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA]));
foreach ($recipients as $recipient) {
$recipient = trim($recipient);
- if (! valid_email($recipient)) {
+ if (! Strings::isValidEmail($recipient)) {
notice(L10n::t('%s : Not a valid email address.', $recipient) . EOL);
continue;
}
$str_tags = '';
$inform = '';
- $tags = get_tags($body);
+ $tags = Strings::getTags($body);
// Add a tag if the parent contact is from ActivityPub or OStatus (This will notify them)
if ($parent && in_array($thr_parent_contact['network'], [Protocol::OSTATUS, Protocol::ACTIVITYPUB])) {
foreach ($msg as $rr) {
if ($rr['unknown']) {
$participants = L10n::t("Unknown sender - %s", $rr['from-name']);
- } elseif (link_compare($rr['from-url'], $myprofile)) {
+ } elseif (Strings::compareLink($rr['from-url'], $myprofile)) {
$participants = L10n::t("You and %s", $rr['name']);
} else {
$participants = L10n::t("%s and You", $rr['from-name']);
AND `blocked` = 0 AND `account_expired` = 0
AND `account_removed` = 0 AND `verified` = 1
LIMIT 1",
- DBA::escape($authid), DBA::escape(normalise_openid($authid))
+ DBA::escape($authid), DBA::escape(Strings::normaliseOpenID($authid))
);
if (DBA::isResult($r)) {
}
$taginfo = [];
- $tags = get_tags($rawtags);
+ $tags = Strings::getTags($rawtags);
if (count($tags)) {
foreach ($tags as $tag) {
hub_return(false, '');
}
- if (!empty($hub_topic) && !link_compare($hub_topic, $contact['poll'])) {
+ if (!empty($hub_topic) && !Strings::compareLink($hub_topic, $contact['poll'])) {
Logger::log('Hub topic ' . $hub_topic . ' != ' . $contact['poll']);
hub_return(false, '');
}
// sanity check that topic URLs are the same
$hub_topic2 = str_replace('/feed/', '/dfrn_poll/', $hub_topic);
- if (!link_compare($hub_topic, $contact['poll']) && !link_compare($hub_topic2, $contact['poll'])) {
+ if (!Strings::compareLink($hub_topic, $contact['poll']) && !Strings::compareLink($hub_topic2, $contact['poll'])) {
Logger::log('Hub topic ' . $hub_topic . ' != ' . $contact['poll']);
System::httpExit(404);
}
if (!empty($url)) {
$my_profile = Profile::getMyURL();
- if (!empty($my_profile) && !link_compare($my_profile, $url)) {
+ if (!empty($my_profile) && !Strings::compareLink($my_profile, $url)) {
$separator = strpos($url, '?') ? '&' : '?';
$url .= $separator . 'zrl=' . urlencode($my_profile);
$email = $a->user['email'];
}
// check the email is valid
- if (!valid_email($email)) {
+ if (!Strings::isValidEmail($email)) {
$err .= L10n::t('Invalid email.');
}
// ensure new email is not the admin mail
$str_contact_deny = !empty($_POST['contact_deny']) ? perms2str($_POST['contact_deny']) : '';
$openidserver = $a->user['openidserver'];
- //$openid = normalise_openid($openid);
+ //$openid = Strings::normaliseOpenID($openid);
// If openid has changed or if there's an openid but no openidserver, try and discover it.
if ($openid != $a->user['openid'] || (strlen($openid) && (!strlen($openidserver)))) {
// and www.example.com vs example.com.
// We will only change the url to an ip address if there is no existing setting
- if (empty($url) || (!link_compare($url, $this->getBaseURL())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $this->getHostName()))) {
+ if (empty($url) || (!Util\Strings::compareLink($url, $this->getBaseURL())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $this->getHostName()))) {
Core\Config::set('system', 'url', $this->getBaseURL());
}
}
public static function setHashtags(&$item)
{
- $tags = get_tags($item["body"]);
+ $tags = Strings::getTags($item["body"]);
// No hashtags?
if (!count($tags)) {
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism', $item['body'], $matches, PREG_SET_ORDER);
if ($cnt) {
foreach ($matches as $mtch) {
- if (link_compare($link, $mtch[1]) || link_compare($dlink, $mtch[1])) {
+ if (Strings::compareLink($link, $mtch[1]) || Strings::compareLink($dlink, $mtch[1])) {
$mention = true;
Logger::log('mention found: ' . $mtch[2]);
}
}
$achar = strpos($s, '?') ? '&' : '?';
$mine = self::getMyURL();
- if ($mine && !link_compare($mine, $s)) {
+ if ($mine && !Strings::compareLink($mine, $s)) {
return $s . $achar . 'zrl=' . urlencode($mine);
}
return $s;
throw new Exception(L10n::t('Your email domain is not among those allowed on this site.'));
}
- if (!valid_email($email) || !Network::isEmailDomainValid($email)) {
+ if (!Strings::isValidEmail($email) || !Network::isEmailDomainValid($email)) {
throw new Exception(L10n::t('Not a valid email address.'));
}
if (self::isNicknameBlocked($nickname)) {
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Proxy as ProxyUtils;
+use Friendica\Util\Strings;
use Friendica\Util\Temporal;
require_once 'include/dba.php';
$shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != 1;
- if (local_user() && link_compare($a->contact['url'], $item['author-link'])) {
+ if (local_user() && Strings::compareLink($a->contact['url'], $item['author-link'])) {
if ($item["event-id"] != 0) {
$edpost = ["events/event/" . $item['event-id'], L10n::t("Edit")];
} else {
$this->owner_name = $a->page_contact['name'];
$this->wall_to_wall = true;
} elseif ($this->getDataValue('owner-link')) {
- $owner_linkmatch = (($this->getDataValue('owner-link')) && link_compare($this->getDataValue('owner-link'), $this->getDataValue('author-link')));
- $alias_linkmatch = (($this->getDataValue('alias')) && link_compare($this->getDataValue('alias'), $this->getDataValue('author-link')));
+ $owner_linkmatch = (($this->getDataValue('owner-link')) && Strings::compareLink($this->getDataValue('owner-link'), $this->getDataValue('author-link')));
+ $alias_linkmatch = (($this->getDataValue('alias')) && Strings::compareLink($this->getDataValue('alias'), $this->getDataValue('author-link')));
$owner_namematch = (($this->getDataValue('owner-name')) && $this->getDataValue('owner-name') == $this->getDataValue('author-name'));
if (!$owner_linkmatch && !$alias_linkmatch && !$owner_namematch) {
}
}
- if ($Blink && link_compare($Blink, System::baseUrl() . "/profile/" . $importer["nickname"])) {
+ if ($Blink && Strings::compareLink($Blink, System::baseUrl() . "/profile/" . $importer["nickname"])) {
$author = DBA::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]);
$item['id'] = $posted_id;
Logger::log("Contact ".$importer["id"]." isn't known to user ".$importer["importer_uid"].". The post will be ignored.", Logger::DEBUG);
return;
}
- if (!link_compare($item["owner-link"], $importer["url"])) {
+ if (!Strings::compareLink($item["owner-link"], $importer["url"])) {
/*
* The item owner info is not our contact. It's OK and is to be expected if this is a tgroup delivery,
* but otherwise there's a possible data mixup on the sender's system.
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism', $item['body'], $matches, PREG_SET_ORDER);
if ($cnt) {
foreach ($matches as $mtch) {
- if (link_compare($link, $mtch[1]) || link_compare($dlink, $mtch[1])) {
+ if (Strings::compareLink($link, $mtch[1]) || Strings::compareLink($dlink, $mtch[1])) {
$mention = true;
Logger::log('mention found: ' . $mtch[2]);
}
// Now we are collecting all relay contacts
foreach ($serverlist as $server_url) {
// We don't send messages to ourselves
- if (link_compare($server_url, System::baseUrl())) {
+ if (Strings::compareLink($server_url, System::baseUrl())) {
continue;
}
$contact = self::getRelayContact($server_url);
$parent = Item::selectFirst(['author-link'], ['id' => $item["parent"]]);
// Only delete it if the parent author really fits
- if (!link_compare($parent["author-link"], $contact["url"]) && !link_compare($item["author-link"], $contact["url"])) {
+ if (!Strings::compareLink($parent["author-link"], $contact["url"]) && !Strings::compareLink($item["author-link"], $contact["url"])) {
Logger::log("Thread author ".$parent["author-link"]." and item author ".$item["author-link"]." don't fit to expected contact ".$contact["url"], Logger::DEBUG);
continue;
}
*
* @return array List of tag and person names
*/
- public static function getTags($string) // get_tags()
+ public static function getTags($string)
{
$ret = [];
*
* @return boolean Value indicating whether or not the string is a valid email address.
*/
- public static function isValidEmail($email_address) // valid_email()
+ public static function isValidEmail($email_address)
{
return preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/', $email_address);
}
*
* @return string normalized OpenId Identity
*/
- function normaliseOpenID($s) // normalize_openid()
+ function normaliseOpenID($s)
{
return trim(str_replace(['http://', 'https://'], ['', ''], $s), '/');
}
* @return boolean True if the URLs match, otherwise False
*
*/
- public static function compareLink($a, $b) // link_compare()
+ public static function compareLink($a, $b)
{
- return (strcasecmp(normalise_link($a), normalise_link($b)) === 0);
+ return (strcasecmp(self::normaliseLink($a), self::normaliseLink($b)) === 0);
}
}
use Friendica\Protocol\DFRN;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\Email;
+use Friendica\Util\Strings;
require_once 'include/items.php';
// perform local delivery if we are on the same site
- if (link_compare($basepath, System::baseUrl())) {
+ if (Strings::compareLink($basepath, System::baseUrl())) {
$condition = ['nurl' => normalise_link($contact['url']), 'self' => true];
$target_self = DBA::selectFirst('contact', ['uid'], $condition);
if (!DBA::isResult($target_self)) {