aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHilmar R <u02@u29lx193>2021-01-27 00:20:18 +0100
committerHilmar R <u02@u29lx193>2021-01-27 00:20:18 +0100
commitd0d6170a71a1acd73995450e16586a7b69abb3e1 (patch)
treeb5f3562d5a19480ef4c58322cad82d0676a009d1
parentcd98e75a42023f568a73556ec8e2a7bd4b406118 (diff)
downloadvolse-hubzilla-d0d6170a71a1acd73995450e16586a7b69abb3e1.tar.gz
volse-hubzilla-d0d6170a71a1acd73995450e16586a7b69abb3e1.tar.bz2
volse-hubzilla-d0d6170a71a1acd73995450e16586a7b69abb3e1.zip
login panel, reg limits.
-rw-r--r--Zotlabs/Module/Admin/Site.php29
-rw-r--r--Zotlabs/Module/Register.php38
-rwxr-xr-xview/tpl/admin_site.tpl4
-rwxr-xr-xview/tpl/register.tpl23
4 files changed, 56 insertions, 38 deletions
diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php
index cb919746b..879923132 100644
--- a/Zotlabs/Module/Admin/Site.php
+++ b/Zotlabs/Module/Admin/Site.php
@@ -5,6 +5,10 @@ namespace Zotlabs\Module\Admin;
class Site {
+ // system cfgs
+ const ivo = 'invitation_only';
+ const iva = 'invitation_also';
+
/**
* @brief POST handler for Admin Site Page.
*
@@ -42,8 +46,8 @@ class Site {
$minimum_age = ((x($_POST,'minimum_age')) ? intval(trim($_POST['minimum_age'])) : 13);
$access_policy = ((x($_POST,'access_policy')) ? intval(trim($_POST['access_policy'])) : 0);
$reg_autochannel = ((x($_POST,'auto_channel_create')) ? True : False);
- $invite_only = ((x($_POST,'invite_only')) ? True : False);
- $invite_also = ((x($_POST,'invite_also')) ? True : False);
+ $invitation_only = ((x($_POST,'invitation_only')) ? True : False);
+ $invitation_also = ((x($_POST,'invitation_also')) ? True : False);
$abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0);
$register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : '');
@@ -192,8 +196,8 @@ class Site {
set_config('system','register_policy', $register_policy);
set_config('system','minimum_age', $minimum_age);
set_config('system','auto_channel_create', $reg_autochannel);
- set_config('system','invitation_only', $invite_only);
- set_config('system','invitation_also', $invite_also);
+ set_config('system',self::ivo, $invitation_only);
+ set_config('system',self::iva, $invitation_also);
set_config('system','access_policy', $access_policy);
set_config('system','account_abandon_days', $abandon_days);
set_config('system','register_text', $register_text);
@@ -399,6 +403,8 @@ class Site {
'rabot' => $reg_rabots
)
);
+ $invitation_only = get_config('system',self::ivo);
+ $invitation_also = get_config('system',self::iva);
$tao = '';
$t = get_markup_template("admin_site.tpl");
@@ -478,16 +484,19 @@ class Site {
get_config('system','auto_channel_create'),
t("Auto create a channel when register a new account. When On, the register form will show additional fields for the channel-name and the nickname."),
"", "", 'ZAR0870C'),
- '$invite_only' => array('invite_only',
- t("Invitation only"),
- get_config('system','invitation_only'),
+
+ '$invitation_only' => array(self::ivo,
+ ($invitation_only === false ? '✗' : '✓') . ' ' . t("Invitation only"),
+ $invitation_only,
t("Only allow new member registrations with an invitation code. Above register policy must be set to Yes."),
"", "", 'ZAR0880C'),
- '$invite_also' => array('invite_also',
- t("Invitation also"),
- get_config('system','invitation_also'),
+
+ '$invitation_also' => array(self::iva,
+ ($invitation_also === false ? '✗' : '✓') . ' ' . t("Invitation also"),
+ $invitation_also,
t("Also allow new member registrations with an invitation code. Above register policy must be set to Yes."),
"", "", 'ZAR0881C'),
+
'$verify_email' => array('verify_email',
t("Verify Email Addresses"),
get_config('system','verify_email'),
diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php
index 60d08caf0..64db7a253 100644
--- a/Zotlabs/Module/Register.php
+++ b/Zotlabs/Module/Register.php
@@ -109,7 +109,7 @@ class Register extends Controller {
}
// s2 max daily
- if ( self::check_max_daily_exceeded() ) return;
+ if ( self::check_reg_limits() ) return;
// accept tos
if(! x($_POST,'tos')) {
@@ -423,8 +423,9 @@ class Register extends Controller {
$invitations = true;
}
- if ( self::check_max_daily_exceeded() )
- $duty['atform'] = 'disabled';
+ $opal = self::check_reg_limits();
+ if ( $opal['is'])
+ $duty['atform'] = 'disabled';
$privacy_role = ((x($_REQUEST,'permissions_role')) ? $_REQUEST['permissions_role'] : "");
@@ -496,6 +497,7 @@ class Register extends Controller {
'$reg_is' => $registration_is,
'$registertext' => bbcode(get_config('system','register_text')),
'$other_sites' => $other_sites,
+ '$msg' => $opal['rn'] . ',' . $opal['an'],
'$invitations' => $invitations,
'$invite_code' => $invite_code,
'$haveivc' => t('I have an invite code') . '.<sup>ZAR0134I</sup>',
@@ -521,28 +523,36 @@ class Register extends Controller {
return $o;
}
- function check_max_daily_exceeded() {
+ function check_reg_limits() {
// check against register, account
+ $rear = array( 'is' => false, 'rn' => 0, 'an' => 0, 'msg' => '' );
+
$max_dailies = intval(get_config('system','max_daily_registrations'));
+
if ( $max_dailies ) {
+
$r = q("SELECT COUNT(reg_id) AS nr FROM register WHERE reg_vital = 1 AND reg_created > %s - INTERVAL %s",
db_utcnow(), db_quoteinterval('1 day')
);
- $re = ( $r && $r[0]['nr'] >= $max_dailies ) ? true : false;
- if ( !$re ) {
+
+ $rear['is'] = ( $r && $r[0]['nr'] >= $max_dailies ) ? true : false;
+ $rear['rn'] = $r[0]['nr'];
+
+ if ( !$rear['is']) {
$r = q("SELECT COUNT(account_id) AS nr FROM account WHERE account_created > %s - INTERVAL %s",
db_utcnow(), db_quoteinterval('1 day')
);
- $re = ( $r && $r[0]['nr'] >= $max_dailies ) ? true : false;
+
+ $rear['is'] = ( $r && ($r[0]['nr'] + $rear['rn']) >= $max_dailies ) ? true : false;
+ $rear['ra'] = $r[0]['nr'];
}
- if ( $re ) {
- zar_log('ZAR0333W max daily registrations exceeded.');
- notice( 'ZAR0333W '
- . t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.')
- . EOL);
- return true;
+
+ if ( $rear['is']) {
+ $rear['msg'] = 'ZAR0333W ' . t('This site has exceeded the number of allowed daily account registrations');
+ zar_log($msg);
+ $rear['is'] = true;
}
}
- return false;
+ return $rear;
}
}
diff --git a/view/tpl/admin_site.tpl b/view/tpl/admin_site.tpl
index f438a5256..6af867e8c 100755
--- a/view/tpl/admin_site.tpl
+++ b/view/tpl/admin_site.tpl
@@ -39,8 +39,8 @@
{{$reg_delay}}
{{$reg_expire}}
{{include file="field_checkbox.tpl" field=$reg_autochannel}}
- {{include file="field_checkbox.tpl" field=$invite_only}}
- {{include file="field_checkbox.tpl" field=$invite_also}}
+ {{include file="field_checkbox.tpl" field=$invitation_only}}
+ {{include file="field_checkbox.tpl" field=$invitation_also}}
{{include file="field_checkbox.tpl" field=$verify_email}}
{{include file="field_input.tpl" field=$abandon_days}}
{{include file="field_input.tpl" field=$minimum_age}}
diff --git a/view/tpl/register.tpl b/view/tpl/register.tpl
index 451a16c2a..dd6e2e937 100755
--- a/view/tpl/register.tpl
+++ b/view/tpl/register.tpl
@@ -5,13 +5,13 @@
<div class="section-content-wrapper">
<form action="register" method="post" id="register-form">
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
- {{if $reg_is}}
<div class="section-content-warning-wrapper">
+ {{if $reg_is}}
<div id="register-desc" class="descriptive-paragraph">{{$reg_is}}</div>
+ {{/if}}
<div id="register-sites" class="descriptive-paragraph">{{$other_sites}}</div>
<h2>{{$now}}</h2>
</div>
- {{/if}}
{{if $registertext}}
<div class="section-content-info-wrapper">
@@ -19,16 +19,16 @@
</div>
{{/if}}
- {{if $invitations}}
<div style="text-align: center;">
+ {{if $invitations}}
<a id="zar014" href="javascript:;" style="display: inline-block;">{{$haveivc}}</a>
- </div>
- <div id="zar015" style="display: none;">
- {{include file="field_input.tpl" field=[$invite_code.0,$invite_code.1,"","","",$atform]}}
- </div>
+ <div id="zar015" style="display: none;">
+ {{include file="field_input.tpl" field=[$invite_code.0,$invite_code.1,"","",""]}}
+ </div>
{{/if}}
{{include file="field_input.tpl" field=[$email.0,$email.1,"",$email.3,"",""]}}
+ </div>
{{include file="field_password.tpl" field=[$pass1.0,$pass1.1,"","","",$atform]}}
@@ -44,10 +44,10 @@
{{include file="field_select_grouped.tpl" field=$role}}
{{/if}}
- {{include file="field_input.tpl" field=$name}}
+ {{include file="field_input.tpl" field=[$name.0,$name.1,"","","",$atform]}}
<div id="name-spinner" class="spinner-wrapper"><div class="spinner m"></div></div>
- {{include file="field_input.tpl" field=$nickname}}
+ {{include file="field_input.tpl" field=[$nickname.0,$nickname.1,"","","",$atform]}}
<div id="nick-spinner" class="spinner-wrapper"><div class="spinner m"></div></div>
{{/if}}
@@ -60,9 +60,8 @@
<button class="btn btn-primary" type="submit" name="submit" id="newchannel-submit-button" value="{{$submit}}" {{$atform}}>{{$submit}}</button>
<div id="register-submit-end" class="register-field-end"></div>
</form>
- <br />
- <div class="descriptive-text">{{$verify_note}}</div>
-
+ <br />
+ <div class="descriptive-text">{{$verify_note}} {{$msg}}</div>
</div>
</div>
{{*