From: Hypolite Petovan Date: Sun, 15 Jul 2018 19:04:48 +0000 (-0400) Subject: Enforce systen.register_policy value type X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=67dc08d120828fe277584ba4127340eeb447f8d4;p=friendica.git Enforce systen.register_policy value type --- diff --git a/include/api.php b/include/api.php index d307afa953..58f086c012 100644 --- a/include/api.php +++ b/include/api.php @@ -3345,7 +3345,7 @@ function api_statusnet_config($type) $server = $a->get_hostname(); $logo = System::baseUrl() . '/images/friendica-64.png'; $email = Config::get('config', 'admin_email'); - $closed = Config::get('config', 'register_policy') == REGISTER_CLOSED ? 'true' : 'false'; + $closed = intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 'true' : 'false'; $private = Config::get('system', 'block_public') ? 'true' : 'false'; $textlimit = (string) Config::get('config', 'api_import_size', Config::get('config', 'max_import_size', 200000)); $ssl = Config::get('system', 'have_ssl') ? 'true' : 'false'; diff --git a/mod/bookmarklet.php b/mod/bookmarklet.php index 88097eb910..a26757740a 100644 --- a/mod/bookmarklet.php +++ b/mod/bookmarklet.php @@ -22,7 +22,7 @@ function bookmarklet_content(App $a) { if (!local_user()) { $o = '

' . L10n::t('Login') . '

'; - $o .= Login::form($a->query_string, Config::get('config', 'register_policy') === REGISTER_CLOSED ? false : true); + $o .= Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? false : true); return $o; } diff --git a/mod/friendica.php b/mod/friendica.php index b3cea56dc6..f1b0fb4761 100644 --- a/mod/friendica.php +++ b/mod/friendica.php @@ -58,7 +58,7 @@ function friendica_init(App $a) 'url' => System::baseUrl(), 'addons' => $visible_addons, 'locked_features' => $locked_features, - 'register_policy' => $register_policy[Config::get('config', 'register_policy')], + 'register_policy' => $register_policy[intval(Config::get('config', 'register_policy'))], 'admin' => $admin, 'site_name' => Config::get('config', 'sitename'), 'platform' => FRIENDICA_PLATFORM, diff --git a/mod/home.php b/mod/home.php index c386763ca3..d28bf3cb43 100644 --- a/mod/home.php +++ b/mod/home.php @@ -47,7 +47,7 @@ function home_content(App $a) { } } - $login = Login::form($a->query_string, Config::get('config', 'register_policy') === REGISTER_CLOSED ? 0 : 1); + $login = Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1); $content = ''; Addon::callHooks("home_content",$content); diff --git a/mod/invite.php b/mod/invite.php index bea479a8f7..d8d98bec28 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -126,14 +126,14 @@ function invite_content(App $a) { $dirloc = Config::get('system', 'directory'); if (strlen($dirloc)) { - if (Config::get('config', 'register_policy') === REGISTER_CLOSED) { + if (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED) { $linktxt = L10n::t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.', $dirloc . '/servers'); } else { $linktxt = L10n::t('To accept this invitation, please visit and register at %s or any other public Friendica website.', System::baseUrl()) . "\r\n" . "\r\n" . L10n::t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.', $dirloc . '/servers'); } } else { // there is no global directory URL defined - if (Config::get('config', 'register_policy') === REGISTER_CLOSED) { + if (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED) { $o = L10n::t('Our apologies. This system is not currently configured to connect with other public sites or invite members.'); return $o; } else { diff --git a/mod/nodeinfo.php b/mod/nodeinfo.php index 74645bc66d..fad7246075 100644 --- a/mod/nodeinfo.php +++ b/mod/nodeinfo.php @@ -61,7 +61,7 @@ function nodeinfo_init(App $a) { $nodeinfo['usage'] = []; - $nodeinfo['openRegistrations'] = Config::get('config', 'register_policy') !== REGISTER_CLOSED; + $nodeinfo['openRegistrations'] = intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED; $nodeinfo['metadata'] = ['nodeName' => Config::get('config', 'sitename')]; diff --git a/mod/openid.php b/mod/openid.php index 7be8544cd9..3baeec28d0 100644 --- a/mod/openid.php +++ b/mod/openid.php @@ -62,7 +62,7 @@ function openid_content(App $a) { // Successful OpenID login - but we can't match it to an existing account. // New registration? - if (Config::get('config', 'register_policy') === REGISTER_CLOSED) { + if (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED) { notice(L10n::t('Account not found and OpenID registration is not permitted on this site.') . EOL); goaway(System::baseUrl()); } diff --git a/mod/ping.php b/mod/ping.php index 47c8cb40d7..f68040a2cb 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -201,7 +201,7 @@ function ping_init(App $a) ); $mail_count = count($mails); - if (Config::get('config', 'register_policy') === REGISTER_APPROVE && is_site_admin()) { + if (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE && is_site_admin()) { $regs = q( "SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created` FROM `contact` RIGHT JOIN `register` ON `register`.`uid` = `contact`.`uid` diff --git a/mod/register.php b/mod/register.php index 53bca68405..aa0f2f59bc 100644 --- a/mod/register.php +++ b/mod/register.php @@ -74,7 +74,7 @@ function register_post(App $a) $user = $result['user']; - if ($netpublish && Config::get('config', 'register_policy') !== REGISTER_APPROVE) { + if ($netpublish && intval(Config::get('config', 'register_policy')) !== REGISTER_APPROVE) { $url = System::baseUrl() . '/profile/' . $user['nickname']; Worker::add(PRIORITY_LOW, "Directory", $url); } @@ -83,7 +83,7 @@ function register_post(App $a) $num_invites = Config::get('system', 'number_invites'); $invite_id = ((x($_POST, 'invite_id')) ? notags(trim($_POST['invite_id'])) : ''); - if (Config::get('config', 'register_policy') === REGISTER_OPEN) { + if (intval(Config::get('config', 'register_policy')) === REGISTER_OPEN) { if ($using_invites && $invite_id) { q("delete * from register where hash = '%s' limit 1", dbesc($invite_id)); PConfig::set($user['uid'], 'system', 'invites_remaining', $num_invites); @@ -109,7 +109,7 @@ function register_post(App $a) info(L10n::t('Registration successful.') . EOL); goaway(System::baseUrl()); } - } elseif (Config::get('config', 'register_policy') === REGISTER_APPROVE) { + } elseif (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE) { if (!strlen(Config::get('config', 'admin_email'))) { notice(L10n::t('Your registration can not be processed.') . EOL); goaway(System::baseUrl()); @@ -177,7 +177,7 @@ function register_content(App $a) return; } - if ((!local_user()) && (Config::get('config', 'register_policy') === REGISTER_CLOSED)) { + if ((!local_user()) && (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED)) { notice("Permission denied." . EOL); return; } @@ -256,7 +256,7 @@ function register_content(App $a) $o = replace_macros($tpl, [ '$oidhtml' => $oidhtml, '$invitations' => Config::get('system', 'invitation_only'), - '$permonly' => Config::get('config', 'register_policy') === REGISTER_APPROVE, + '$permonly' => intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE, '$permonlybox' => ['permonlybox', L10n::t('Note for the admin'), '', L10n::t('Leave a message for the admin, why you want to join this node')], '$invite_desc' => L10n::t('Membership on this site is by invitation only.'), '$invite_label' => L10n::t('Your invitation code: '), diff --git a/mod/regmod.php b/mod/regmod.php index 2a418fcda0..2b7df0bd13 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -99,7 +99,7 @@ function regmod_content(App $a) { if (!local_user()) { info(L10n::t('Please login.') . EOL); - $o = '

' . Login::form($a->query_string, Config::get('config', 'register_policy') === REGISTER_CLOSED ? 0 : 1); + $o = '

' . Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1); return $o; } diff --git a/mod/statistics_json.php b/mod/statistics_json.php index 0dbe0ea492..c197060ff5 100644 --- a/mod/statistics_json.php +++ b/mod/statistics_json.php @@ -20,7 +20,7 @@ function statistics_json_init(App $a) { "name" => Config::get('config', 'sitename'), "network" => FRIENDICA_PLATFORM, "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION, - "registrations_open" => Config::get('config', 'register_policy') !== REGISTER_CLOSED, + "registrations_open" => intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED, "total_users" => Config::get('nodeinfo', 'total_users'), "active_users_halfyear" => Config::get('nodeinfo', 'active_users_halfyear'), "active_users_monthly" => Config::get('nodeinfo', 'active_users_monthly'), diff --git a/mod/uimport.php b/mod/uimport.php index 660544b471..1dbc571e2f 100644 --- a/mod/uimport.php +++ b/mod/uimport.php @@ -42,7 +42,7 @@ function uimport_post(App $a) function uimport_content(App $a) { - if ((!local_user()) && (Config::get('config', 'register_policy') === REGISTER_CLOSED)) { + if ((!local_user()) && (intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED)) { notice("Permission denied." . EOL); return; } diff --git a/src/Content/Nav.php b/src/Content/Nav.php index 93090c06ec..92ca714df8 100644 --- a/src/Content/Nav.php +++ b/src/Content/Nav.php @@ -124,7 +124,7 @@ class Nav $nav['home'] = [$homelink, L10n::t('Home'), '', L10n::t('Home Page')]; } - if ((Config::get('config', 'register_policy') === REGISTER_OPEN) && (! local_user()) && (! remote_user())) { + if (intval(Config::get('config', 'register_policy')) === REGISTER_OPEN && !local_user() && !remote_user()) { $nav['register'] = ['register', L10n::t('Register'), '', L10n::t('Create an account')]; } diff --git a/src/Module/Login.php b/src/Module/Login.php index 46cb3a85d2..06d724bb2a 100644 --- a/src/Module/Login.php +++ b/src/Module/Login.php @@ -43,7 +43,7 @@ class Login extends BaseModule goaway(self::getApp()->get_baseurl()); } - return self::form(self::getApp()->get_baseurl(), Config::get('config', 'register_policy') !== REGISTER_CLOSED); + return self::form(self::getApp()->get_baseurl(), intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED); } public static function post()