possibility to block ip addresses from registration
This commit is contained in:
parent
0de788b744
commit
98cd4ed66a
|
@ -75,6 +75,9 @@ class QvitterPlugin extends Plugin {
|
|||
// CUSTOM TERMS OF USE
|
||||
$settings['customtermsofuse'] = false;
|
||||
|
||||
// IP ADDRESSES BLOCKED FROM REGISTRATION
|
||||
$settings['blocked_ips'] = array();
|
||||
|
||||
|
||||
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
||||
· ·
|
||||
|
@ -775,6 +778,25 @@ class QvitterPlugin extends Plugin {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add unread notification count to all API responses
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
````
|
||||
|
||||
|
|
|
@ -75,6 +75,11 @@ class QvitterAction extends ApiAction
|
|||
$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');
|
||||
$qvitterpath = Plugin::staticPath('Qvitter', '');
|
||||
|
@ -82,6 +87,8 @@ class QvitterAction extends ApiAction
|
|||
$attachmentroot = common_path('attachment/', StatusNet::isHTTPS());
|
||||
$instanceurl = common_path('', StatusNet::isHTTPS());
|
||||
|
||||
|
||||
|
||||
common_set_returnto(''); // forget this
|
||||
|
||||
// if this is a profile we add a link header for LRDD Discovery (see WebfingerPlugin.php)
|
||||
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue
Block a user