possibility to block ip addresses from registration

This commit is contained in:
Hannes Mannerheim 2015-02-04 14:44:04 +01:00
parent 0de788b744
commit 98cd4ed66a
3 changed files with 35 additions and 4 deletions

View File

@ -74,6 +74,9 @@ class QvitterPlugin extends Plugin {
// CUSTOM TERMS OF USE
$settings['customtermsofuse'] = false;
// IP ADDRESSES BLOCKED FROM REGISTRATION
$settings['blocked_ips'] = array();
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
@ -772,7 +775,26 @@ class QvitterPlugin extends Plugin {
'top_nav_doc_faq');
return true;
}
}
/**
* No registration for blocked ips
*
* @return boolean hook flag
*/
public function onStartUserRegister($profile)
{
if(is_array(self::settings("blocked_ips"))) {
if(in_array($_SERVER['REMOTE_ADDR'], self::settings("blocked_ips"))) {
return false;
}
}
return true;
}
/**

View File

@ -27,7 +27,8 @@ Setup
2. Put all files in /plugins/Qvitter
3. Replace your lib/apiauthaction.php file with the one supplied in
edited-gnu-social-files/lib/apiauthaction.php.
edited-gnu-social-files/lib/apiauthaction.php. (this might not be needed if you are
running the latest GNU social nightly)
4. Add `addPlugin('Qvitter');` to your /config.php file.
@ -55,6 +56,7 @@ $config['site']['qvitter']['urlshortenerapiurl'] = 'http://qttr.at/yourls-api.ph
$config['site']['qvitter']['urlshortenersignature'] = 'b6afeec983';
$config['site']['qvitter']['sitebackground'] = 'img/vagnsmossen.jpg';
$config['site']['qvitter']['favicon'] = 'img/favicon.ico?v=4';
$config['site']['qvitter']['blocked_ips'] = array();
$config['thumbnail']['maxsize'] = 3000;
````

View File

@ -74,6 +74,11 @@ class QvitterAction extends ApiAction
if(common_config('site','closed') == 1 || common_config('site','inviteonly') == 1) {
$registrationsclosed = true;
}
// check if the client's ip address is blocked for registration
if(is_array(QvitterPlugin::settings("blocked_ips"))) {
$client_ip_is_blocked = in_array($_SERVER['REMOTE_ADDR'], QvitterPlugin::settings("blocked_ips"));
}
$sitetitle = common_config('site','name');
$siterootdomain = common_config('site','server');
@ -81,6 +86,8 @@ class QvitterAction extends ApiAction
$apiroot = common_path('api/', StatusNet::isHTTPS());
$attachmentroot = common_path('attachment/', StatusNet::isHTTPS());
$instanceurl = common_path('', StatusNet::isHTTPS());
common_set_returnto(''); // forget this
@ -191,7 +198,7 @@ class QvitterAction extends ApiAction
window.siteEmail = '<?php print common_config('site', 'email'); ?>';
window.siteLicenseTitle = '<?php print common_config('license', 'title'); ?>';
window.siteLicenseURL = '<?php print common_config('license', 'url'); ?>';
window.customTermsOfUse = <?php print json_encode(QvitterPlugin::settings("customtermsofuse")); ?>;
window.customTermsOfUse = <?php print json_encode(QvitterPlugin::settings("customtermsofuse")); ?>;
</script>
<style>
@ -401,7 +408,7 @@ class QvitterAction extends ApiAction
</form>
</div>
<?php
if($registrationsclosed === false) {
if($registrationsclosed === false && $client_ip_is_blocked === false) {
?><div class="front-signup">
<h2></h2>
<div class="signup-input-container"><input placeholder="" type="text" name="user[name]" autocomplete="off" class="text-input" id="signup-user-name"></div>