From df4a7e1a041d3f3efd2715c4ae1fa48d1a57c488 Mon Sep 17 00:00:00 2001 From: aschwarz Date: Fri, 24 Mar 2023 16:56:24 +0100 Subject: [PATCH] =?UTF-8?q?Login=20auf=20jquery=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.inc.php | 2 +- controller/admin_create_user.php | 22 +- controller/admin_login.php | 47 ++++ dashboard/create_user.php | 3 +- dashboard/index.php | 71 +---- js/components/admin_login.js | 35 +++ templates/modern/dashboard/index.html | 36 +-- templates/modern/dashboard/navtop.html | 17 ++ templates/modern/dashboard/startseite.html | 2 +- ...27c3ff810b1d3ec06fd_0.file.navtop.html.php | 28 +- ...401c286ca72b20b_0.file.startseite.html.php | 10 +- ...2d57da65ac1c94_0.file.create_user.html.php | 257 ++++++++++++++++++ ...5a84936653b20b0c_0.file.changepwd.html.php | 176 ++++++++++++ ...cdfcb9f2ad878a473b1db6_0.file.nav.html.php | 24 +- ...c30536bdf206de07b30e_0.file.index.html.php | 49 ++-- ...a2015207b5d9beac_0.file.parameter.html.php | 11 +- 16 files changed, 654 insertions(+), 136 deletions(-) create mode 100644 controller/admin_login.php create mode 100644 js/components/admin_login.js create mode 100644 templates_c/248e68c5bd756c9289901a93382d57da65ac1c94_0.file.create_user.html.php create mode 100644 templates_c/753dd0aa5f0b34da5600ce1f5a84936653b20b0c_0.file.changepwd.html.php diff --git a/config.inc.php b/config.inc.php index 99d358e..51423c0 100644 --- a/config.inc.php +++ b/config.inc.php @@ -42,7 +42,7 @@ $uid = $_SESSION["global_uid"]; $login_dateiname = basename($_SERVER['PHP_SELF']); if($uid == "" AND $login_dateiname !='index.php'){ - echo""; + echo""; exit; } diff --git a/controller/admin_create_user.php b/controller/admin_create_user.php index 6994ac4..ee188ed 100644 --- a/controller/admin_create_user.php +++ b/controller/admin_create_user.php @@ -101,24 +101,36 @@ if ($function == 'usersave') { - Benutzerkennung: + Benutzerkennung: - $mail + $mail - Passwort: + Passwort: - $password + $password + + + + + + + Login: + + + + + http://admin.ju-and-mi.de @@ -146,7 +158,7 @@ if ($function == 'usersave') { $return = @mail($empfaenger, $betreff, $text, $headers); - if ($return) { // Abfrage ob Mailversand funktioniert hat + if (!$return) { // Abfrage ob Mailversand funktioniert hat echo '
BenutzerIn wurde angelegt. Es konnte allerdings keine Mail verschickt werden!
|***|success'; exit; } else { diff --git a/controller/admin_login.php b/controller/admin_login.php new file mode 100644 index 0000000..c5af187 --- /dev/null +++ b/controller/admin_login.php @@ -0,0 +1,47 @@ + Bitte füllen Sie alle Felder aus!|***|error'; + exit; + }else{ + + + $db = dbconnect(); + $result = $db->query("SELECT uid, mail, passwort FROM jumi_admin WHERE UPPER(mail)='$mail'"); + $row = $result->fetch_array(); + + + if (md5($password) != $row['passwort'] or $row['mail'] == ''){ //verschlüsseltes Passwort überprüfen + # Cookies werden bereits gesetzt, falls sich jemand ein passwort zusenden lässt. + # $_SESSION["global_uid"] = $row['uid']; + # $_SESSION["global_mail"] = $row['mail']; + echo '
Bitte prüfen Sie Ihre Zugangsdaten
|***|error'; + exit; + }else{ + + $db = dbconnect(); + $datum=date("Y-m-d H:i:s"); + $ip=getenv("REMOTE_ADDR"); + $agent=getenv("HTTP_USER_AGENT"); + $user_admin = $row['uid']; + $_SESSION["global_uid"] = $user_admin; + $_SESSION["global_mail"] = $row['mail']; + $result_1 = $db->query("INSERT INTO jumi_adminlog (Datum, IP, user_agent, uid) VALUES ('$datum', '$ip', '$agent', '$user_admin')"); + echo '
Login wird durchgeführt
|***|success'; + } + } +} + + +?> \ No newline at end of file diff --git a/dashboard/create_user.php b/dashboard/create_user.php index 82b3b3f..46a1a1b 100644 --- a/dashboard/create_user.php +++ b/dashboard/create_user.php @@ -57,6 +57,7 @@ if($action == ''){ $smarty->assign('user_anlegen_mail', $_SESSION["anlegen_mail"]); } # Daten aufbereiten für Zurückbutton ENDE +*/ $query = "SELECT rid, bezeichnung FROM jumi_admin_rolle ORDER BY bezeichnung ASC"; $result = $db->query( $query) or die ("Cannot execute query1"); @@ -65,7 +66,7 @@ if($action == ''){ $value[] = $row; } $smarty->assign('table_data', $value); -*/ + } diff --git a/dashboard/index.php b/dashboard/index.php index 1c7c5b9..45ad65d 100644 --- a/dashboard/index.php +++ b/dashboard/index.php @@ -12,79 +12,10 @@ require_once "../language/german.inc.php"; $action = $_GET['action']; if($action == ''){ - if(isset($_GET['error'])){ - - $errorno = $_GET['error']; - - $smarty->assign('index_error', 1); - - if($errorno == 1){ - $smarty->assign('index_error_text', "Es müssen alle Felder ausgefüllt werden"); - } - - if($errorno == 2){ - $smarty->assign('index_error_text', "Der Benutzername ist im System nicht vorhanden"); - } - - if($errorno == 3){ - $smarty->assign('index_error_text', "Der Benutzername oder das Passwort ist nicht korrekt."); - } - - if($errorno == 4){ - $smarty->assign('index_error_text', "Sie müssen sich einloggen!"); - } - - # Daten aufbereiten bei Fehler - if(isset($_SESSION["global_username"])){ - $smarty->assign('index_user', $_SESSION["global_username"]); - } - } - + } -if($action == 'anmeld'){ - $mail=strtoupper($_POST["mail"]); //remove case sensitivity on the mail - $password=$_POST["password"]; - - if($_POST["mail"] != ""){ - $_SESSION["global_mail"]=$mail; - } - - if($mail == "" OR $password == ""){ - echo ""; - }else{ - - - $db = dbconnect(); - $result = $db->query("SELECT uid, mail, passwort FROM jumi_admin WHERE UPPER(mail)='$mail'"); - $row = $result->fetch_array(); - - - if ($mail != strtoupper($row['mail'])) { - - } - // Passwort falsch - elseif (md5($password) != $row['passwort']){ //verschlüsseltes Passwort überprüfen - # Cookies werden bereits gesetzt, falls sich jemand ein passwort zusenden lässt. - $_SESSION["global_uid"] = $row['uid']; - $_SESSION["global_mail"] = $row['mail']; - echo ""; - }else{ - - $db = dbconnect(); - $datum=date("Y-m-d H:i:s"); - $ip=getenv("REMOTE_ADDR"); - $agent=getenv("HTTP_USER_AGENT"); - $user_admin = $row['uid']; - $_SESSION["global_uid"] = $user_admin; - $_SESSION["global_mail"] = $row['mail']; - $result_1 = $db->query("INSERT INTO jumi_adminlog (Datum, IP, user_agent, uid) VALUES ('$datum', '$ip', '$agent', '$user_admin')"); - $smarty->assign('index_login', "1"); - } - } - -} $smarty->assign('action', "$action"); $smarty->display("modern/dashboard/$templatename"); diff --git a/js/components/admin_login.js b/js/components/admin_login.js new file mode 100644 index 0000000..6d3cd03 --- /dev/null +++ b/js/components/admin_login.js @@ -0,0 +1,35 @@ +function login(){ + var mail = document.getElementById("mail").value; + var password = document.getElementById("password").value; + + $.ajax({ + type: 'POST', + url: '../controller/admin_login.php', + data: { + 'function': 'login', + 'mail': mail, + 'password': password + }, + success: function(result) { //we got the response + if(result!=''){ + var a = result.split('|***|'); + if(a[1]=="success"){ + document.getElementById("mail").value =""; + document.getElementById("password").value =""; + $('#msg').show().delay(1000).fadeOut(500); + $('#msg').html(a[0]); + $(document).ajaxStop(function(){ + setTimeout(() => { window.location = "startseite.php"; }, 1000); + }); + + }else{ + $('#msg').show().delay(10000).fadeOut(500); + $('#msg').html(a[0]); + } + } + }, + error: function(xhr, status, exception) { + console.log(xhr); + } + }); +} \ No newline at end of file diff --git a/templates/modern/dashboard/index.html b/templates/modern/dashboard/index.html index b75a694..f718360 100644 --- a/templates/modern/dashboard/index.html +++ b/templates/modern/dashboard/index.html @@ -1,6 +1,6 @@ {if $action == ''} - + @@ -28,6 +28,10 @@ {literal}
@@ -50,13 +51,12 @@

Login

-
- +
- +
  - +
-
+
@@ -89,6 +89,15 @@ }); + {literal} + + {/literal} @@ -123,6 +124,17 @@ if ($_smarty_tpl->tpl_vars['action']->value == '') {?> > + + + type="text/javascript"> + function keysave(ele) { + if(event.key === 'Enter') { + login(); + } + } + +> +