diff --git a/homepage/participo/.htaccess b/homepage/participo/.htaccess index 362484a..8fc95b3 100644 --- a/homepage/participo/.htaccess +++ b/homepage/participo/.htaccess @@ -1,7 +1,8 @@ # Url-Rewriting aktivieren RewriteEngine on -# Wenn * angefordert wurde und *.php existiert + +# Wenn * angefordert wurde und *.php existiert .. RewriteCond %{REQUEST_FILENAME}.php -f -# Hänge ein \.php an +# .. hänge ein \.php an RewriteRule ^(.*)$ $1\.php diff --git a/homepage/participo/lib/db.php b/homepage/participo/lib/db.php index 0a9be82..d76a942 100644 --- a/homepage/participo/lib/db.php +++ b/homepage/participo/lib/db.php @@ -197,7 +197,8 @@ function isUserInKidIds($uId, $idList){ // @todo: Achtung, als id ist die id der Vormundschaft gespeichert. Unter kidId die des Kindes. -function getUsersKids($db, $userId){ +function getUsersKids($db, $userId, $options = []){ + options['attribute'] ?? $query = <<"; - if( !empty($anRetMessage['error']) ){ + $retHtmlString = ""; + if( !empty($anRetMessage) ){ $retHtmlString .= "
"; - $retHtmlString .= "ERROR:
"; - $retHtmlString .= $anRetMessage['error']; + if( !empty($anRetMessage['error']) ){ + $retHtmlString .= "
"; + $retHtmlString .= "ERROR:
"; + $retHtmlString .= $anRetMessage['error']; + $retHtmlString .= "
"; + } + if( !empty($anRetMessage['warning']) ){ + $retHtmlString .= "
"; + $retHtmlString .= "WARNING:
"; + $retHtmlString .= $anRetMessage['warning']; + $retHtmlString .= "
"; + } + if( !empty($anRetMessage['notice']) ){ + $retHtmlString .= "
"; + $retHtmlString .= "Info:
"; + $retHtmlString .= $anRetMessage['notice']; + $retHtmlString .= "
"; + } + if( !empty($anRetMessage['success']) ){ + $retHtmlString .= "
"; + $retHtmlString .= "SUCCESS:
"; + $retHtmlString .= $anRetMessage['success']; + $retHtmlString .= "
"; + } $retHtmlString .= "
"; } - if( !empty($anRetMessage['warning']) ){ - $retHtmlString .= "
"; - $retHtmlString .= "WARNING:
"; - $retHtmlString .= $anRetMessage['warning']; - $retHtmlString .= "
"; - } - if( !empty($anRetMessage['notice']) ){ - $retHtmlString .= "
"; - $retHtmlString .= "Info:
"; - $retHtmlString .= $anRetMessage['notice']; - $retHtmlString .= "
"; - } - if( !empty($anRetMessage['success']) ){ - $retHtmlString .= "
"; - $retHtmlString .= "SUCCESS:
"; - $retHtmlString .= $anRetMessage['success']; - $retHtmlString .= "
"; - } - $retHtmlString .= ""; -} return $retHtmlString; } @@ -205,4 +212,65 @@ function loadMarkdownFile($fileName){ , 'mdText' => $mdText ); } + + +function checkCredentials($username, $password, $db_server, $db_user, $db_password, $db_name){ + sleep(1); + $mysqli = @new mysqli($db_server, $db_user, $db_password, $db_name); + if ($mysqli->connect_error) { + $message['error'] = 'Datenbankverbindung fehlgeschlagen: ' . $mysqli->connect_error; + } else { + $query = sprintf( + "SELECT id, loginName, pwHash, config FROM wkParticipo_Users WHERE loginName = '%s'", + $mysqli->real_escape_string($_POST['f']['username']) + ); + $result = $mysqli->query($query); + if ($row = $result->fetch_array(MYSQLI_ASSOC)) { + if( password_verify( $_POST['f']['password'], $row['pwHash']) ){ + session_start(); + $_SESSION = array( + 'login' => true, + 'user' => array( + 'username' => $row['loginName'], + 'userId' => $row['id'], + 'userConfig' => json_decode($row['config'], true) + ), + ); + $message['success'] = 'Anmeldung erfolgreich, weiter zum Inhalt.'; + + // Logging Logins + logLoginsToJsonFile($_SESSION['user']['username']); + + header('Location: http://' . $_SERVER['HTTP_HOST'] . '/participo?user=' . $_POST['f']['username']); + } else { + sleep(5); + $message['error'] = 'Das Kennwort ist nicht korrekt.'; + } + } + } +return $message; +} + +/** + * Log the Login of an user into a logFile + * + * @param string $userName name of the user + * @param string $fileName filename to log to + * @return void + */ +function logLoginsToJsonFile($userName, $fileName="lastLogins.json"){ + try{ + $lastLogins = json_decode(file_get_contents($fileName), true); + if(!array_key_exists($userName, $lastLogins)) + $lastLogins[$userName] = []; + if(!array_key_exists('lastLogins', $lastLogins[$userName])) + $lastLogins[$userName]['lastLogins'] = []; + $lastLogins[$userName]['lastLogins'] = array_merge( array( date('Y-m-d H:i:s') ), $lastLogins[$userName]['lastLogins'] ); + file_put_contents($fileName, json_encode($lastLogins)); + } + catch (Exception $e){ + // silently ignore errors + } +} + ?> \ No newline at end of file diff --git a/homepage/participo/login.php b/homepage/participo/login.php index ace1000..fa9aadd 100644 --- a/homepage/participo/login.php +++ b/homepage/participo/login.php @@ -1,79 +1,16 @@ connect_error) { - $message['error'] = 'Datenbankverbindung fehlgeschlagen: ' . $mysqli->connect_error; - } else { - $query = sprintf( - "SELECT id, loginName, pwHash, config FROM wkParticipo_Users WHERE loginName = '%s'", - $mysqli->real_escape_string($_POST['f']['username']) - ); - $result = $mysqli->query($query); - if ($row = $result->fetch_array(MYSQLI_ASSOC)) { - if( password_verify( $_POST['f']['password'], $row['pwHash']) ){ - session_start(); - $_SESSION = array( - 'login' => true, - 'user' => array( - 'username' => $row['loginName'], - 'userId' => $row['id'], - 'userConfig' => json_decode($row['config'], true) - ), - ); - $message['success'] = 'Anmeldung erfolgreich, weiter zum Inhalt.'; - PHPCount::AddHit("participo-Login-".$_POST['f']['username']); - - // Logging Logins - logLoginsToJsonFile($_SESSION['user']['username']); - - header('Location: http://' . $_SERVER['HTTP_HOST'] . '/participo?user=' . $_POST['f']['username']); - } else { - sleep(5); - $message['error'] = 'Das Kennwort ist nicht korrekt.'; - } - } - } -return $message; -} - -/** - * Log the Login of an user into a logFile - * - * @param string $userName name of the user - * @param string $fileName filename to log to - * @return void - */ -function logLoginsToJsonFile($userName, $fileName="lastLogins.json"){ - try{ - $lastLogins = json_decode(file_get_contents($fileName), true); - if(!array_key_exists($userName, $lastLogins)) - $lastLogins[$userName] = []; - if(!array_key_exists('lastLogins', $lastLogins[$userName])) - $lastLogins[$userName]['lastLogins'] = []; - $lastLogins[$userName]['lastLogins'] = array_merge( array( date('Y-m-d H:i:s') ), $lastLogins[$userName]['lastLogins'] ); - file_put_contents($fileName, json_encode($lastLogins)); - } - catch (Exception $e){ - // silently ignore errors - } -} - +// Check, if the login is already set. If so move to the main page. if (isset($_SESSION['login'])) { header('Location: http://' . $_SERVER['HTTP_HOST'] . '/index.php'); } +// Otherwise check credentials if given. else{ if (!empty($_POST)) { if ( @@ -103,7 +40,7 @@ else{ cwsvJudo Online Apps - +

Loginseite der Online-Apps der Judoka des CWSV

@@ -125,7 +62,8 @@ else{
Hinweise
    -
  • Logindaten sind über den Übungsleiter zu beantragen.
  • +
  • Logindaten sollten vom Übungsleiter vergeben worden sein.
  • +
    • Verlorene oder vergessene Logins oder Passwörter können über den Übungsleiter neu vergeben werden.
  • Dieses Projekt ist in mehr oder weniger aktiven Entwicklung. Sollte mal was nicht funktionieren, kann es sein, dass ich gerade daran herumschreibe. Also ruhig zu einem späteren Zeitpunkt noch einmal probieren.
diff --git a/homepage/ressourcen/material-icons/fonts/MaterialIcons-Regular.ttf b/homepage/ressourcen/material-icons/fonts/MaterialIcons-Regular.ttf new file mode 100644 index 0000000..48c69b5 Binary files /dev/null and b/homepage/ressourcen/material-icons/fonts/MaterialIcons-Regular.ttf differ diff --git a/homepage/ressourcen/material-icons/material-icons.css b/homepage/ressourcen/material-icons/material-icons.css new file mode 100644 index 0000000..314cbc7 --- /dev/null +++ b/homepage/ressourcen/material-icons/material-icons.css @@ -0,0 +1,33 @@ +@font-face { + font-family: 'Material Icons'; + font-style: normal; + font-weight: 400; + src: local('Material Icons'), + local('MaterialIcons-Regular'), + url(fonts/MaterialIcons-Regular.ttf) format('truetype'); +} + +.material-icons { + font-family: 'Material Icons'; + font-weight: normal; + font-style: normal; + font-size: 24px; /* Preferred icon size */ + display: inline-block; + line-height: 1; + text-transform: none; + letter-spacing: normal; + word-wrap: normal; + white-space: nowrap; + direction: ltr; + + /* Support for all WebKit browsers. */ + -webkit-font-smoothing: antialiased; + /* Support for Safari and Chrome. */ + text-rendering: optimizeLegibility; + + /* Support for Firefox. */ + -moz-osx-font-smoothing: grayscale; + + /* Support for IE. */ + font-feature-settings: 'liga'; +} \ No newline at end of file