GitHost.io will be shut down on June 1, 2019. At that point this instance will be unreachable and all data will be irrevocably deleted. More details at https://about.gitlab.com/gitlab-hosted/#githost-is-shutting-down-on-june-1st-2019

Commit 98cd4ed6 authored by hannes's avatar hannes

possibility to block ip addresses from registration

parent 0de788b7
......@@ -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;
}
/**
......
......@@ -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;
````
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment