modules/webmailtotp/test.php
b7bc5c81
 <?php
 /*
 This file belongs to the Webinterface of schokokeks.org Hosting
 
cf54502a
 Written 2008-2018 by schokokeks.org Hosting, namely
b7bc5c81
   Bernd Wurst <bernd@schokokeks.org>
   Hanno Böck <hanno@schokokeks.org>
 
 To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
 
2626dd47
 You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
b7bc5c81
 http://creativecommons.org/publicdomain/zero/1.0/
 
 Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
 */
 
 require_once('inc/base.php');
 require_once('inc/icons.php');
 require_role(ROLE_SYSTEMUSER);
 
00532760
 require_once('totp.php');
b7bc5c81
 
00532760
 $section='webmailtotp_overview';
 title('Test der Zwei-Faktor-Anmeldung');
b7bc5c81
 
0efeb504
 if (isset($_REQUEST['username'])) {
2626dd47
     $username = $_REQUEST['username'];
     $webmailpw = $_REQUEST['webmailpass'];
     $ga_code = $_REQUEST['totp_code'];
9086c9ad
 
2626dd47
     if (! strstr($username, '@')) {
         // Default-Domainname
         $username = $username.'@'.config('masterdomain');
     }
1d76d27b
 
2626dd47
     $success = true;
9086c9ad
 
2626dd47
     if (! check_webmail_password($username, $webmailpw)) {
         input_error('Das Webmail-Passwort hat nicht gestimmt.');
         $success = false;
     }
0efeb504
 
2626dd47
     if (check_locked($username)) {
         input_error('Aufgrund einiger Fehlversuche wurde dieses Konto übergangsweise deaktiviert. Bitte warten Sie ein paar Minuten.');
         $success = false;
     } elseif (! check_totp($username, $ga_code)) {
         input_error('Der TOTP-Code wurde nicht akzeptiert.');
         $success = false;
     }
0efeb504
 
5fae5f10
 
2626dd47
     if ($success) {
         output('<p>'.icon_ok().' Der Test war erfolgreich!');
     } else {
         output('<p>'.icon_error().' Der Test war leider nicht erfolgreich.');
     }
0efeb504
 
 
2626dd47
     output('<h3>Weiterer Test</h3>');
b7bc5c81
 } else {
2626dd47
     $username = '';
     output('<p>Geben Sie hier die Login-Daten ein um Ihren Zugang zu testen.</p>');
b7bc5c81
 }
 
 $form = '<p>Ihr Webmail-Benutzername: <input type="text" name="username" value="'.filter_input_general($username).'" /></p>
 <p>Ihr neues Webmail-Passwort: <input type="password" name="webmailpass" /></p>
00532760
 <p>Der aktuellste Einmal-Code: <input type="text" name="totp_code" /></p>
b7bc5c81
 <p><input type="submit" value="Prüfen!" /></p>';
 
 
00532760
 output(html_form('webmailtotp_test', 'test', '', $form));