From ea721d380be15d06a9f0974dc98487523fcdfb58 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 10 Apr 2021 10:53:27 +0000 Subject: register: move some html out of the code and provide a basic template --- Zotlabs/Module/Regate.php | 55 ++++++++++++++++++++++++++------------------ Zotlabs/Module/Register.php | 9 ++++---- view/tpl/regate.tpl | 2 -- view/tpl/regate_pre.tpl | 56 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 29 deletions(-) create mode 100644 view/tpl/regate_pre.tpl diff --git a/Zotlabs/Module/Regate.php b/Zotlabs/Module/Regate.php index 4c7c96284..16b669dfc 100644 --- a/Zotlabs/Module/Regate.php +++ b/Zotlabs/Module/Regate.php @@ -252,35 +252,46 @@ class Regate extends \Zotlabs\Web\Controller { return $o; } - if ( argc() > 1 ) { - $did2 = hex2bin( substr( argv(1), 0, -1) ); - $didx = substr( argv(1), -1 ); - $deny = argc() > 2 ? argv(2) : ''; - $deny = preg_match('/^[0-9a-f]{8,8}$/', $deny) ? hex2bin($deny) : false; - } - - if ($_SESSION['zar']['msg']) { - $o = replace_macros(get_markup_template('plain.tpl'), [ - '$title' => t('Your Registration'), - '$now' => '', - '$infos' => $_SESSION['zar']['msg'] . EOL, + if ($_SESSION['zar']['delayed']) { + $o = replace_macros(get_markup_template('regate_pre.tpl'), [ + '$title' => t('Register Verification'), + '$id' => $_SESSION['zar']['id'], + '$pin' => $_SESSION['zar']['pin'], + '$regdelay' => $_SESSION['zar']['regdelay'], + '$regexpire' => $_SESSION['zar']['regexpire'], + '$desc' => [ + t('Please remember your validation token and ID'), + t('Your ID'), + t('Your token') + ], + '$delay_desc' => [ + t('Hold on, you can start verification in'), + t('Token validity') + ] ]); - unset($_SESSION['zar']['msg']); + unset($_SESSION['zar']['delayed']); return $o; } - $now = datetime_convert(); - $ip = $_SERVER['REMOTE_ADDR']; + if (argc() < 2) + return; + + $did2 = hex2bin( substr( argv(1), 0, -1) ); + $didx = substr( argv(1), -1 ); + $deny = argc() > 2 ? argv(2) : ''; + $deny = preg_match('/^[0-9a-f]{8,8}$/', $deny) ? hex2bin($deny) : false; + $now = datetime_convert(); + $ip = $_SERVER['REMOTE_ADDR']; $isduty = zar_register_dutystate(); $nowfmt = $isduty['nowfmt']; $atform = $isduty['atform']; + $pin = ''; - $pin = $_SESSION['zar']['pin'] ?? ''; - unset($_SESSION['zar']['pin']); - - - $title = t('Register Verification'); + if(isset($_SESSION['zar']['pin'])) { + $pin = $_SESSION['zar']['pin']; + unset($_SESSION['zar']['pin']); + } // do we have a valid dId2 ? if (($didx == 'a' && substr( $did2 , -2) == substr( base_convert( md5( substr( $did2, 1, -2) ),16 ,10), -2)) || ($didx == 'e') || ($didx == 'i')) { @@ -342,7 +353,7 @@ class Regate extends \Zotlabs\Web\Controller { if ( $r['reg_startup'] <= $now && $r['reg_expires'] >= $now) { $o = replace_macros(get_markup_template('regate.tpl'), [ '$form_security_token' => get_form_security_token("regate"), - '$title' => $title, + '$title' => t('Register Verification'), '$desc' => $pin ? t('Please enter your validation token') . ' ' . $pin . '' : t('Please enter your validation token'), '$did2' => bin2hex($did2) . $didx, '$now' => $nowfmt, @@ -361,7 +372,7 @@ class Regate extends \Zotlabs\Web\Controller { } $o = replace_macros(get_markup_template('plain.tpl'), [ - '$title' => $title, + '$title' => t('Register Verification'), '$now' => $nowf, '$countdown' => datetime_convert('UTC', 'UTC', $r['reg_startup'], 'c'), '$infos' => t('Hold on, you can start verification in') . EOL, diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php index a08cc6d0d..e96037760 100644 --- a/Zotlabs/Module/Register.php +++ b/Zotlabs/Module/Register.php @@ -426,12 +426,11 @@ class Register extends Controller { if($reg_delayed) { // this could be removed to make registration harder + $_SESSION['zar']['id'] = 'd' . $didnew; $_SESSION['zar']['pin'] = $pass2; - - $_SESSION['zar']['msg'] = t('Your validation token is') . EOL - . '

' . $pass2 . '

' . EOL - . t('Hold on, you can start verification in') - . '
' . datetime_convert('UTC', 'UTC', $regdelay, 'c') . ' ' . t('and') . ' ' . datetime_convert('UTC', 'UTC', $regexpire, 'c') . '
'; + $_SESSION['zar']['delayed'] = true; + $_SESSION['zar']['regdelay'] = datetime_convert('UTC', 'UTC', $regdelay, 'c'); + $_SESSION['zar']['regexpire'] = datetime_convert('UTC', 'UTC', $regexpire, 'c'); } else { $_SESSION['zar']['pin'] = $pass2; diff --git a/view/tpl/regate.tpl b/view/tpl/regate.tpl index 04a9df1de..6eaac1478 100644 --- a/view/tpl/regate.tpl +++ b/view/tpl/regate.tpl @@ -1,7 +1,5 @@

{{$title}}

-

{{$now}}

-

{{$desc}}

diff --git a/view/tpl/regate_pre.tpl b/view/tpl/regate_pre.tpl new file mode 100644 index 000000000..adc63b181 --- /dev/null +++ b/view/tpl/regate_pre.tpl @@ -0,0 +1,56 @@ +

{{$title}}

+ +{{$delay_desc.0}} +
+ +{{$desc.0}}
+
+{{$desc.1}}
+{{$id}}
+
+{{$desc.2}}
+{{$pin}}
+
+
+ {{$delay_desc.1}}
+ + {{$regdelay}} + +  ‐  + + {{$regexpire}} + +
+ -- cgit v1.2.3