Review update

Rename function, move others
This commit is contained in:
Adam Magness 2018-01-27 11:13:41 -05:00
parent 0f1be37279
commit f04d40a37e
55 changed files with 331 additions and 326 deletions

View file

@ -1132,12 +1132,12 @@ class Contact extends BaseObject
// remove ajax junk, e.g. Twitter
$url = str_replace('/#!/', '/', $url);
if (!Network::allowedURL($url)) {
if (!Network::isUrlAllowed($url)) {
$result['message'] = L10n::t('Disallowed profile URL.');
return $result;
}
if (Network::blockedURL($url)) {
if (Network::isUrlBlocked($url)) {
$result['message'] = L10n::t('Blocked domain');
return $result;
}
@ -1321,4 +1321,37 @@ class Contact extends BaseObject
$result['success'] = true;
return $result;
}
public static function updateSslPolicy($contact, $new_policy)
{
$ssl_changed = false;
if ((intval($new_policy) == SSL_POLICY_SELFSIGN || $new_policy === 'self') && strstr($contact['url'], 'https:')) {
$ssl_changed = true;
$contact['url'] = str_replace('https:', 'http:', $contact['url']);
$contact['request'] = str_replace('https:', 'http:', $contact['request']);
$contact['notify'] = str_replace('https:', 'http:', $contact['notify']);
$contact['poll'] = str_replace('https:', 'http:', $contact['poll']);
$contact['confirm'] = str_replace('https:', 'http:', $contact['confirm']);
$contact['poco'] = str_replace('https:', 'http:', $contact['poco']);
}
if ((intval($new_policy) == SSL_POLICY_FULL || $new_policy === 'full') && strstr($contact['url'], 'http:')) {
$ssl_changed = true;
$contact['url'] = str_replace('http:', 'https:', $contact['url']);
$contact['request'] = str_replace('http:', 'https:', $contact['request']);
$contact['notify'] = str_replace('http:', 'https:', $contact['notify']);
$contact['poll'] = str_replace('http:', 'https:', $contact['poll']);
$contact['confirm'] = str_replace('http:', 'https:', $contact['confirm']);
$contact['poco'] = str_replace('http:', 'https:', $contact['poco']);
}
if ($ssl_changed) {
$fields = ['url' => $contact['url'], 'request' => $contact['request'],
'notify' => $contact['notify'], 'poll' => $contact['poll'],
'confirm' => $contact['confirm'], 'poco' => $contact['poco']];
dba::update('contact', $fields, ['id' => $contact['id']]);
}
return $contact;
}
}

View file

@ -568,7 +568,7 @@ class GContact
$done[] = System::baseUrl() . '/poco';
if (strlen(Config::get('system', 'directory'))) {
$x = Network::fetchURL(get_server()."/pubsites");
$x = Network::fetchUrl(get_server()."/pubsites");
if ($x) {
$j = json_decode($x);
if ($j->entries) {
@ -980,7 +980,7 @@ class GContact
$url = $server."/main/statistics";
$result = Network::zFetchURL($url);
$result = Network::curl($url);
if (!$result["success"]) {
return false;
}

View file

@ -102,7 +102,7 @@ class Photo
$photo_failure = false;
$filename = basename($image_url);
$img_str = Network::fetchURL($image_url, true);
$img_str = Network::fetchUrl($image_url, true);
if ($quit_on_error && ($img_str == "")) {
return false;

View file

@ -964,7 +964,7 @@ class Profile
public static function zrlInit(App $a)
{
$my_url = self::getMyURL();
$my_url = Network::validateURL($my_url);
$my_url = Network::isUrlValid($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

@ -281,7 +281,7 @@ class User
if (!x($username) || !x($email) || !x($nickname)) {
if ($openid_url) {
if (!Network::validateURL($openid_url)) {
if (!Network::isUrlValid($openid_url)) {
throw new Exception(L10n::t('Invalid OpenID url'));
}
$_SESSION['register'] = 1;
@ -304,7 +304,7 @@ class User
throw new Exception(L10n::t('Please enter the required information.'));
}
if (!Network::validateURL($openid_url)) {
if (!Network::isUrlValid($openid_url)) {
$openid_url = '';
}
@ -329,11 +329,11 @@ class User
}
}
if (!Network::allowedEmail($email)) {
if (!Network::isEmailDomainAllowed($email)) {
throw new Exception(L10n::t('Your email domain is not among those allowed on this site.'));
}
if (!valid_email($email) || !Network::validateEmail($email)) {
if (!valid_email($email) || !Network::isEmailDomainValid($email)) {
throw new Exception(L10n::t('Not a valid email address.'));
}
@ -460,7 +460,7 @@ class User
// if we have no OpenID photo try to look up an avatar
if (!strlen($photo)) {
$photo = Network::avatarImg($email);
$photo = Network::lookupAvatarByEmail($email);
}
// unless there is no avatar-addon loaded
@ -468,7 +468,7 @@ class User
$photo_failure = false;
$filename = basename($photo);
$img_str = Network::fetchURL($photo, true);
$img_str = Network::fetchUrl($photo, true);
// guess mimetype from headers or filename
$type = Image::guessType($photo, true);