Move multiple functions

move multiple smaller functions
This commit is contained in:
Adam Magness 2018-01-26 23:51:41 -05:00
commit 1eb7c19c1e
11 changed files with 24 additions and 56 deletions

View file

@ -312,7 +312,7 @@ class OEmbed
$allowed = explode(',', $str_allowed);
return allowed_domain($domain, $allowed);
return Network::allowedDomain($domain, $allowed);
}
public static function getHTML($url, $title = null)

View file

@ -20,6 +20,7 @@ use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus;
use Friendica\Protocol\PortableContact;
use Friendica\Protocol\Salmon;
use Friendica\Util\Network;
use dba;
require_once 'boot.php';
@ -1131,12 +1132,12 @@ class Contact extends BaseObject
// remove ajax junk, e.g. Twitter
$url = str_replace('/#!/', '/', $url);
if (!allowed_url($url)) {
if (!Network::allowedURL($url)) {
$result['message'] = L10n::t('Disallowed profile URL.');
return $result;
}
if (blocked_url($url)) {
if (Network::blockedURL($url)) {
$result['message'] = L10n::t('Blocked domain');
return $result;
}

View file

@ -17,6 +17,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Protocol\Diaspora;
use Friendica\Util\Network;
use dba;
require_once 'include/dba.php';
@ -963,7 +964,7 @@ class Profile
public static function zrlInit(App $a)
{
$my_url = self::getMyURL();
$my_url = validate_url($my_url);
$my_url = Network::validateURL($my_url);
if ($my_url) {
// Is it a DDoS attempt?
// The check fetches the cached value from gprobe to reduce the load for this system

View file

@ -282,7 +282,7 @@ class User
if (!x($username) || !x($email) || !x($nickname)) {
if ($openid_url) {
if (!validate_url($openid_url)) {
if (!Network::validateURL($openid_url)) {
throw new Exception(L10n::t('Invalid OpenID url'));
}
$_SESSION['register'] = 1;
@ -305,7 +305,7 @@ class User
throw new Exception(L10n::t('Please enter the required information.'));
}
if (!validate_url($openid_url)) {
if (!Network::validateURL($openid_url)) {
$openid_url = '';
}
@ -330,11 +330,11 @@ class User
}
}
if (!allowed_email($email)) {
if (!Network::allowedEmail($email)) {
throw new Exception(L10n::t('Your email domain is not among those allowed on this site.'));
}
if (!valid_email($email) || !validate_email($email)) {
if (!valid_email($email) || !Network::validateEmail($email)) {
throw new Exception(L10n::t('Not a valid email address.'));
}
@ -461,7 +461,7 @@ class User
// if we have no OpenID photo try to look up an avatar
if (!strlen($photo)) {
$photo = avatar_img($email);
$photo = Network::avatarImg($email);
}
// unless there is no avatar-addon loaded

View file

@ -10,6 +10,7 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Database\DBM;
use Friendica\Model\User;
use Friendica\Util\Network;
use dba;
require_once 'boot.php';
@ -59,7 +60,7 @@ class Login extends BaseModule
$openid_url = trim($_POST['openid_url'] ? : $_POST['username']);
// if it's an email address or doesn't resolve to a URL, fail.
if ($noid || strpos($openid_url, '@') || !validate_url($openid_url)) {
if ($noid || strpos($openid_url, '@') || !Network::validateURL($openid_url)) {
notice(L10n::t('Login failed.') . EOL);
goaway(self::getApp()->get_baseurl());
// NOTREACHED

View file

@ -1510,7 +1510,7 @@ class Probe
*/
private static function mail($uri, $uid)
{
if (!validate_email($uri)) {
if (!Network::validateEmail($uri)) {
return false;
}
@ -1544,7 +1544,7 @@ class Probe
$data["network"] = NETWORK_MAIL;
$data["name"] = substr($uri, 0, strpos($uri, '@'));
$data["nick"] = $data["name"];
$data["photo"] = avatar_img($uri);
$data["photo"] = Network::avatarImg($uri);
$data["url"] = 'mailto:'.$uri;
$data["notify"] = 'smtp '.random_string();
$data["poll"] = 'email '.random_string();

View file

@ -79,7 +79,7 @@ class Network
$a = get_app();
if (blocked_url($url)) {
if (self::blockedURL($url)) {
logger('z_fetch_url: domain of ' . $url . ' is blocked', LOGGER_DATA);
return $ret;
}
@ -281,7 +281,7 @@ class Network
{
$stamp1 = microtime(true);
if (blocked_url($url)) {
if (self::blockedURL($url)) {
logger('post_url: domain of ' . $url . ' is blocked', LOGGER_DATA);
return false;
}
@ -622,7 +622,7 @@ class Network
$allowed = explode(',', $str_allowed);
return allowed_domain($domain, $allowed);
return self::allowedDomain($domain, $allowed);
}
/**