gateway to cwsvJudoApps
This commit is contained in:
16
homepage/participo/auth.php
Normal file
16
homepage/participo/auth.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
session_start();
|
||||
// Falls der serverseitige Logincookie nicht gesetzt ist,
|
||||
// leite zur loginSeite weiter
|
||||
if (empty($_SESSION['login'])) {
|
||||
header('Location: login', TRUE, 301);
|
||||
exit;
|
||||
} else {
|
||||
$login_status =
|
||||
"<div style=\"border: 1px solid black\">".
|
||||
"Datum: ".date("Y-m-d")."<br />".
|
||||
"Angemeldet als <strong>".htmlspecialchars($_SESSION['user']['username'])."</strong>.<br />".
|
||||
"<a href=\"logout.php\">Sitzung beenden</a>".
|
||||
"</div>";
|
||||
}
|
||||
?>
|
||||
8
homepage/participo/config/participo.php
Normal file
8
homepage/participo/config/participo.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/// @file some variable definitions
|
||||
|
||||
$config['basePath'] = "/users/cwsvjudo/www";
|
||||
$config['baseUrl'] = "http://cwsvjudo.bplaced.net";
|
||||
$config['ressourceUrl'] = "http://cwsvjudo.bplaced.net/ressourcen";
|
||||
|
||||
?>
|
||||
@@ -1,20 +1,19 @@
|
||||
<?php
|
||||
setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||
require_once("config.php");
|
||||
require_once("config/participo.php");
|
||||
|
||||
require_once("./local/dbConf.php");
|
||||
require_once("./local/achievementsConf.php");
|
||||
require_once("./local/cwsvJudo.php");
|
||||
|
||||
require_once("./lib/db.php");
|
||||
require_once("./lib/achievementsLib.php");
|
||||
require_once("./lib/api.php");
|
||||
|
||||
$dbConnection = getPdoDbConnection(
|
||||
$cwsvJudoConfig["db"]["host"],
|
||||
$cwsvJudoConfig["db"]["name"],
|
||||
$cwsvJudoConfig["db"]["user"],
|
||||
$cwsvJudoConfig["db"]["password"]
|
||||
);
|
||||
// $dbConnection = getPdoDbConnection(
|
||||
// $cwsvJudoConfig["db"]["host"],
|
||||
// $cwsvJudoConfig["db"]["name"],
|
||||
// $cwsvJudoConfig["db"]["user"],
|
||||
// $cwsvJudoConfig["db"]["password"]
|
||||
// );
|
||||
require_once("./auth.php");
|
||||
|
||||
$basePath = "/users/cwsvjudo/www";
|
||||
@@ -31,90 +30,46 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@materializecss/materialize@1.1.0-alpha/dist/css/materialize.min.css">
|
||||
<!-- Compiled and minified JavaScript -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/@materializecss/materialize@1.1.0-alpha/dist/js/materialize.min.js"></script>
|
||||
<!--Import Google Icon Font-->
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
|
||||
<!-- inits for the materializeCss -->
|
||||
<?php include("lib/machs/materializeInit.php");?>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var elems = document.querySelectorAll('.sidenav');
|
||||
var instances = M.Sidenav.init(elems, {
|
||||
// specify options here
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
// include("lib/machs/materializeInit.php");
|
||||
?>
|
||||
|
||||
<title>participo</title>
|
||||
<meta name="description" content="Online apps der judoka des Chemnitzer WSV">
|
||||
<meta name="description" content="Online-Apps der Judoka des Chemnitzer WSV">
|
||||
|
||||
<link rel="icon" href="<?echo($config['ressourceUrl']);?>/graphiken/icons/cwsv.ico" />
|
||||
<link rel="apple-touch-icon" href="<?echo($config['baseUrl']);?>/apple-touch-icon.png">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav> <!-- navbar content here --> </nav>
|
||||
|
||||
<?php if($_SESSION['login']){ ?>
|
||||
<ul id="slide-out" class="sidenav">
|
||||
<li>
|
||||
<div class="user-view">
|
||||
<div class="background">
|
||||
<img src="images/office.jpg">
|
||||
</div>
|
||||
<a href="#user"><img class="circle" src="images/yuna.jpg"></a>
|
||||
<a href="#name"><span class="white-text name">John Doe</span></a>
|
||||
<a href="#email"><span class="white-text email">jdoe@example.com</span></a>
|
||||
</div></li>
|
||||
<li><a href="#!"><i class="material-icons">cloud</i>First Link With Icon</a></li>
|
||||
<li><a href="#!">Second Link</a></li>
|
||||
<li><div class="divider"></div></li>
|
||||
<li><a class="subheader">Subheader</a></li>
|
||||
<li><a class="waves-effect" href="#!">Third Link With Waves</a></li>
|
||||
</ul>
|
||||
<a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a>
|
||||
<?php require_once("sidenav/loginStatus.php");?>
|
||||
</ul>
|
||||
<a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
||||
<?php echo $login_status; ?>
|
||||
|
||||
<?php
|
||||
if( hasUserAttribute($dbConnection, $_SESSION['user']['userId'], "inTraining" ) ){
|
||||
echo( "<h2>Eigene Achievements</h2>" );
|
||||
echo( htmlUsersUploadBox($dbConnection, $_SESSION['user']['userId']) );
|
||||
echo(htmlAchievementListForUser(
|
||||
$dbConnection,
|
||||
$achievementGroups,
|
||||
$_SESSION['user']['userId'],
|
||||
getUsersAchievements($dbConnection, $_SESSION['user']['userId'])
|
||||
));
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
$usersKids = getUsersKids($dbConnection, $_SESSION['user']['userId']);
|
||||
foreach($usersKids as $k){
|
||||
if( hasUserAttribute($dbConnection, $k['kidId'], "inTraining" ) and ($k['kidId']!=$_SESSION['user']['userId']) ){
|
||||
echo( "<h2>".$k['vorname']." ".$k['name']."</h2>" );
|
||||
echo( htmlUsersUploadBox($dbConnection, $k['kidId']) );
|
||||
echo(htmlAchievementListForUser(
|
||||
$dbConnection,
|
||||
$achievementGroups,
|
||||
$k['id'],
|
||||
getUsersAchievements($dbConnection, $k['id'])
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if(isUserAdmin($dbConnection, $_SESSION['user']['userId'])){
|
||||
echo("<h2 id=\"addAchievementBox\">Add Achievements</h2>");
|
||||
echo(htmlAddAchievementBox());
|
||||
|
||||
echo("<h2>Update Achievements</h2>");
|
||||
$achievements = getAchievements($dbConnection);
|
||||
foreach($achievements as $a){
|
||||
echo( htmlUpdateAchievementBox(
|
||||
$a['id'],
|
||||
$a['name'],
|
||||
$a['description'],
|
||||
$a['rootId'],
|
||||
$a['level']
|
||||
));
|
||||
echo("<hr />");
|
||||
}
|
||||
}
|
||||
?>
|
||||
<span id="endOfUpdateAchievementBoxes" style="display:none;" ></span>
|
||||
if($_SESSION['login']){
|
||||
?>
|
||||
<ul>
|
||||
<li><a href="kyu">Kyu</a></li>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
256
homepage/participo/kyu.php
Normal file
256
homepage/participo/kyu.php
Normal file
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
require_once("./auth.php");
|
||||
|
||||
require("lib/Parsedown.php");
|
||||
require("lib/Spyc.php");
|
||||
|
||||
$mdRoot = "markdown/".(array_key_exists('kyu', $_GET)?$_GET['kyu']:"8")."terKyu";
|
||||
|
||||
$Parsedown = new Parsedown();
|
||||
|
||||
//! loading a markdownfile with yaml-header
|
||||
//! returns an assocative array('yaml'=>array(..), 'mdText'=>string)
|
||||
function loadMarkdownFile($fileName){
|
||||
$fileText = file_get_contents($fileName);
|
||||
|
||||
$fileParts = preg_split('/[\n]*[-]{3}[\n]/', $fileText, 3);
|
||||
|
||||
return array(
|
||||
'yaml' => Spyc::YAMLLoadString($fileParts[1])
|
||||
, 'mdText' => preg_replace("/^#(.*)$/m", "", $fileParts[2])
|
||||
);
|
||||
}
|
||||
|
||||
/// @brief Gibt die URL der gerade aufgerufenen Seite zurück
|
||||
function getCurPagesUrl(){
|
||||
$pageURL = 'http';
|
||||
if ($_SERVER["HTTPS"] == "on"){
|
||||
$pageURL .= "s";
|
||||
}
|
||||
$pageURL .= "://";
|
||||
if($_SERVER["SERVER_PORT"] != "80"){
|
||||
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
||||
}
|
||||
else{
|
||||
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
|
||||
}
|
||||
return $pageURL;
|
||||
}
|
||||
|
||||
function htmlCardCode($article, $Parsedown){
|
||||
if(
|
||||
empty($article['yaml'])
|
||||
&& empty($article['mdText'])
|
||||
) return "";
|
||||
$videoFrame = (
|
||||
array_key_exists('yaml', $article)
|
||||
?(
|
||||
array_key_exists('video', $article['yaml'])
|
||||
?(
|
||||
"<div style=\"text-align: center;width=100%;height=auto;\">".html5VideoFrame($article['yaml']['video'])."</div>"
|
||||
)
|
||||
:""
|
||||
)
|
||||
:""
|
||||
);
|
||||
$ytVideoFrame = (
|
||||
array_key_exists('yaml', $article)
|
||||
?(
|
||||
array_key_exists('youtube', $article['yaml'])
|
||||
?(
|
||||
ytLightEmbed($article['yaml']['youtube'])
|
||||
)
|
||||
:""
|
||||
)
|
||||
:""
|
||||
);
|
||||
return
|
||||
"<div class=\"col s12 m6\">"
|
||||
."<div class=\"card blue-grey darken-1\">"
|
||||
."<div class=\"card-image\">"
|
||||
.(!empty($videoFrame)?$videoFrame:$ytVideoFrame)
|
||||
."</div>"
|
||||
."<div class=\"card-content white-text\">"
|
||||
."<span class=\"card-title activator\">"
|
||||
.$article['yaml']['title']
|
||||
."<i class=\"material-icons right\">more_vert</i>"
|
||||
."</span>"
|
||||
."</div>"
|
||||
."<div class=\"card-reveal\">"
|
||||
."<span class=\"card-title\">"
|
||||
.$article['yaml']['title']
|
||||
."<i class=\"material-icons right\">close</i>"
|
||||
."</span>"
|
||||
.$Parsedown->text($article['mdText'])
|
||||
."</div>"
|
||||
."</div>"
|
||||
."</div>";
|
||||
}
|
||||
|
||||
//! create the <video>Tag for videoJs
|
||||
function videoJsFrame($item){
|
||||
return "<video "
|
||||
."id=\"".str_replace("/", "-", $item['url'])."\" "
|
||||
."class=\"video-js\" "
|
||||
."controls "
|
||||
."preload=\"auto\" "
|
||||
// ."poster=\"//vjs.zencdn.net/v/oceans.png\""
|
||||
."data-setup='{}' "
|
||||
.">"
|
||||
."<source src=\"".$item['url']."\" type=\"video/webm\">"//</source>"
|
||||
."<p class=\"vjs-no-js\">"
|
||||
."To view this video please enable JavaScript, and consider upgrading to a web browser that "
|
||||
."<a href=\"https://videojs.com/html5-video-support/\" target=\"_blank\">"
|
||||
."supports HTML5 video"
|
||||
."</a>"
|
||||
."</p>"
|
||||
."</video>";
|
||||
}
|
||||
|
||||
function html5VideoFrame($item){
|
||||
return "<video "
|
||||
."style=\"max-width:100%;height: auto;\""
|
||||
." src=\"".$item['url']."\""
|
||||
." width=\"".$item['width']."\""
|
||||
." height=\"".$item['height']."\""
|
||||
." controls"
|
||||
."></video>";
|
||||
}
|
||||
|
||||
//! embed youtube
|
||||
function ytLightEmbed($item){
|
||||
return "<lite-youtube "
|
||||
."videoid=\"".$item['videoid']."\" "
|
||||
// ."playlabel=\"".$title."\""
|
||||
."params=\""
|
||||
."start=".$item['from']
|
||||
."&end=".$item['to']
|
||||
."&modestbranding=1"
|
||||
."&playsinline=0"
|
||||
."&loop=1"
|
||||
."\" "
|
||||
."></lite-youtube>";
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Gürtelprüfungsordnung</title>
|
||||
|
||||
<!-- Compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@materializecss/materialize@1.1.0-alpha/dist/css/materialize.min.css">
|
||||
<!-- Compiled and minified JavaScript -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/@materializecss/materialize@1.1.0-alpha/dist/js/materialize.min.js"></script>
|
||||
<!--Import Google Icon Font-->
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<!-- unpkg : use the latest version of Video.js -->
|
||||
<link href="https://unpkg.com/video.js/dist/video-js.min.css" rel="stylesheet">
|
||||
<script src="https://unpkg.com/video.js/dist/video.min.js"></script>
|
||||
|
||||
<!-- Include the CSS & JS.. (This could be direct from the package or bundled) -->
|
||||
<link rel="stylesheet" href="lib/lite-youtube-embed/lite-yt-embed.css" />
|
||||
<script src="lib/lite-youtube-embed/lite-yt-embed.js"></script>
|
||||
|
||||
<!--- AutoInit -->
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var materialboxElements = document.querySelectorAll('.materialboxed');
|
||||
var materialboxInstances = M.Materialbox.init(materialboxElements, {
|
||||
// specify options here
|
||||
});
|
||||
});
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var elems = document.querySelectorAll('.sidenav');
|
||||
var instances = M.Sidenav.init(elems, {
|
||||
// specify options here
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
h1{
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
h2{
|
||||
font-size: 2.25rem;
|
||||
}
|
||||
h3{
|
||||
font-size: 2.0rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!--Let browser know website is optimized for mobile-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<style>
|
||||
ul:not(.browser-default) > li{
|
||||
list-style-type: circle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<ul id="slide-out" class="sidenav">
|
||||
<?php require_once("sidenav/loginStatus.php");?>
|
||||
<li><div class="divider"></div></li>
|
||||
<?php require_once("sidenav/kyu.php"); ?>
|
||||
<li><div class="divider"></div></li>
|
||||
<?php require_once("sidenav/backToMain.php"); ?>
|
||||
</ul>
|
||||
<a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a>
|
||||
<?php
|
||||
$kyuMetadata = Spyc::YAMLLoad( $mdRoot."/meta.yaml" );
|
||||
echo("<h1>".$kyuMetadata['title']."</h1>");
|
||||
|
||||
$dirNames = [];
|
||||
$dirIterator = new DirectoryIterator( $mdRoot );
|
||||
foreach ( $dirIterator as $dirInfo ) {
|
||||
if(!$dirInfo->isDir() || $dirInfo->isDot()) continue;
|
||||
$dirNames[] = $dirInfo->__toString();
|
||||
}
|
||||
sort($dirNames);
|
||||
foreach($dirNames as $dirName){
|
||||
$fullDirName = $mdRoot."/".$dirName;
|
||||
$sectionMetadata = Spyc::YAMLLoad( $fullDirName."/meta.yaml" );
|
||||
echo("<div class=\"row\">");
|
||||
echo("<h2>".$sectionMetadata['title']."</h2>");
|
||||
|
||||
$fileIterator = new DirectoryIterator($fullDirName);
|
||||
$fileNames = [];
|
||||
foreach($fileIterator as $fileInfo){
|
||||
if(!$fileInfo->isFile()) continue;
|
||||
if( $fileInfo->getExtension() != "md") continue;
|
||||
$fileNames[] = $fileInfo->__toString();
|
||||
}
|
||||
sort($fileNames);
|
||||
foreach( $fileNames as $fileName){
|
||||
$fullFileName = $fullDirName."/".$fileName;
|
||||
$article = loadMarkdownFile( $fullFileName );
|
||||
echo( htmlCardCode($article, $Parsedown) );
|
||||
}
|
||||
echo("</div>");
|
||||
};
|
||||
?>
|
||||
|
||||
<footer class="page-footer blue-grey darken-1">
|
||||
<div class="container">
|
||||
<div class="col l4 offset-l2 s12">
|
||||
<ul>
|
||||
<li>
|
||||
<a
|
||||
title="Seite auf HTML 5 Konformität prüfen"
|
||||
href="http://validator.w3.org/check?uri=<?php echo(urlencode(getCurPagesUrl()));?>"
|
||||
rel="nofollow"
|
||||
>Valid <img
|
||||
src="/ressourcen/graphiken/icons/HTML5_1Color_Black.svg"
|
||||
alt="HTML 5"
|
||||
title="HTML 5 Logo"
|
||||
style="height:1em;display:inline;vertical-align:middle;">
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
166
homepage/participo/lib/api.php
Normal file
166
homepage/participo/lib/api.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
function processPostData($db, $post, $redirectLocation = "."){
|
||||
if($post['action']){
|
||||
if($post['action']=="giveUserAnAchievement"){
|
||||
giveUserAnAchievement(
|
||||
$db,
|
||||
$post['userId'],
|
||||
$post['achievementId']
|
||||
);
|
||||
$u = getUserData($db, $post['userId']);
|
||||
$a = getAchievement($db, $post['achievementId']);
|
||||
sendEmail(
|
||||
"cwsvjudo@arcor.de",
|
||||
"kwT",
|
||||
$u['vorname']." ".$u['name']." got achievement ".$a[0]['name']
|
||||
);
|
||||
}
|
||||
if($post['action']=="addAchievement"){
|
||||
addAchievement(
|
||||
$db,
|
||||
$post['name'],
|
||||
$post['rootId'],
|
||||
$post['achievementGroupId'],
|
||||
$post['level'],
|
||||
$post['description'],
|
||||
$post['imgUrl']
|
||||
);
|
||||
}
|
||||
|
||||
if($post['action']=="addAchievementGroup"){
|
||||
addAchievementGroup(
|
||||
$db,
|
||||
$post['name'],
|
||||
$post['rootId'],
|
||||
$post['unlockingAchievementId'],
|
||||
$post['imgUrl']
|
||||
);
|
||||
}
|
||||
|
||||
if($post['action']=="autoAddAchievements"){
|
||||
$g=new achievementGroup;
|
||||
$g->setDbConnection($db);
|
||||
$g->loadAchievementGroupFromDb($post['achievementGroupId']);
|
||||
$g->autoAddAchievements(
|
||||
$post['messageTemplate'],
|
||||
$post['from'],
|
||||
$post['to'],
|
||||
$post['step']
|
||||
);
|
||||
}
|
||||
|
||||
if($post['action']=="updateAchievement"){
|
||||
updateAchievement(
|
||||
$db,
|
||||
$post['achievementId'],
|
||||
$post['name'],
|
||||
$post['rootId'],
|
||||
$post['achievementGroupId'],
|
||||
$post['level'],
|
||||
$post['description'],
|
||||
$post['imgUrl']
|
||||
);
|
||||
}
|
||||
|
||||
if($post['action']=="updateAchievementGroup"){
|
||||
updateAchievement(
|
||||
$db,
|
||||
$post['achievementGroupId'],
|
||||
$post['name'],
|
||||
$post['rootId'],
|
||||
$post['unlockingAchievementId'],
|
||||
$post['imgUrl']
|
||||
);
|
||||
}
|
||||
|
||||
if($post['action']=="setBday"){
|
||||
setBday(
|
||||
$db,
|
||||
$post['userId'],
|
||||
$post['bday']
|
||||
);
|
||||
}
|
||||
if($post['action']=="setRecord"){
|
||||
$u = getUserData($db, $post['userId']);
|
||||
$g = new achievementGroup;
|
||||
$g->setDbConnection($db);
|
||||
$g->loadAchievementGroupFromDb($post['achievementGroupId']);
|
||||
sendEmail(
|
||||
"cwsvjudo@arcor.de",
|
||||
$u['vorname']." ".$u['name']." got ".$post['value']." in ".$g->getName(),
|
||||
"[machs] Rekord eingetragen"
|
||||
);
|
||||
setRecord(
|
||||
$db,
|
||||
$post['userId'],
|
||||
$post['achievementGroupId'],
|
||||
$post['value']
|
||||
);
|
||||
}
|
||||
if($post['action']=="reportRecord"){
|
||||
# $u = getUserData($db, $post['userId']);
|
||||
# $ag = new achievementGroup;
|
||||
# achievementGroup::setDbConnection($db);
|
||||
# $ag->loadAchievementGroupFromDb($post['achievementGroupId']);
|
||||
$m = $post['userId']." hat in ".$post['achievementGroupId']." ".$post['value']." geschafft!";
|
||||
# $m = $u['vorname']." ".$u['name']." hat in ".$ag->getName()." ".$post['value']." geschafft!";
|
||||
sendEmail("cwsvjudo@arcor.de", $m, "[machs] Rekordmeldung");
|
||||
}
|
||||
if($post['redirectLocation'])
|
||||
$redirectLocation = $post['redirectLocation'];
|
||||
header("Location: ".$redirectLocation);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function sendEmail($toEmail, $emailText, $emailSubject){
|
||||
try{
|
||||
$date=new DateTime();
|
||||
mail(
|
||||
$toEmail,
|
||||
$emailSubject,
|
||||
$emailText
|
||||
);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
echo 'Message: ' .$e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
function attendancesAssocArray2text($attendancesAssocArray){
|
||||
$ret = "";
|
||||
foreach($attendancesAssocArray as $date => $attendees){
|
||||
$ret .= $date."\n";
|
||||
foreach($attendees as $a){
|
||||
$ret .= "\n";
|
||||
$ret .= "Name: ".$a['name'].", ".$a['vorname']."\n";
|
||||
$ret .= "PLZ: ".$a['corona_PLZ']."\n";
|
||||
$ret .= "Tel.: ".$a['corona_telephon']."\n";
|
||||
$ret .= "eMail: ".$a['corona_eMail']."\n";
|
||||
}
|
||||
$ret .= "\n";
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function attendancesAssocArray2mdList($attendancesAssocArray, $date=null){
|
||||
if($date == null)
|
||||
$date=new DateTime();
|
||||
$ret = "# Anwesenheitsliste zur Corona-Kontaktverfolgung der Abteilung Judo des CWSV vom ".$date->format("Y-m-d")."\n\n";
|
||||
foreach($attendancesAssocArray as $d => $attendees){
|
||||
$ret .= "## ".$d."\n";
|
||||
$i=0;
|
||||
foreach($attendees as $a){
|
||||
$i += 1;
|
||||
$ret .= "\n";
|
||||
$ret .= $i." ".$a['name'].", ".$a['vorname']."\n";
|
||||
$ret .= " - PLZ: ".$a['corona_PLZ']."\n";
|
||||
$ret .= " - Tel.: ".$a['corona_telephon']."\n";
|
||||
$ret .= " - eMail: ".$a['corona_eMail']."\n";
|
||||
}
|
||||
$ret .= "\n";
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
?>
|
||||
420
homepage/participo/lib/db.php
Normal file
420
homepage/participo/lib/db.php
Normal file
@@ -0,0 +1,420 @@
|
||||
<?php
|
||||
// get a Connection to the database
|
||||
function getPdoDbConnection($hostname, $dbName, $user, $password){
|
||||
try{
|
||||
$dbConnection = new PDO(
|
||||
'mysql:host='.$hostname.';dbname='.$dbName,
|
||||
$user,
|
||||
$password
|
||||
);
|
||||
}
|
||||
catch(PDOException $dbError){
|
||||
echo( "Error whilst getting a dbConnection!: " . $dbError->getMessage() );
|
||||
}
|
||||
return $dbConnection;
|
||||
}
|
||||
|
||||
function createDb($dbConnection){
|
||||
<<<SQL
|
||||
CREATE TABLE `cwsvjudo`.`anwesenheit` (
|
||||
`id` INT UNSIGNED NOT NULL ,
|
||||
`userId` INT UNSIGNED NOT NULL ,
|
||||
`date` DATE NOT NULL DEFAULT CURRENT_TIMESTAMP ,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB;
|
||||
ALTER TABLE `cwsvjudo`.`anwesenheit` ADD UNIQUE `attandence` (`userId`, `id`);
|
||||
SQL;
|
||||
}
|
||||
|
||||
/// perform a pdo-query
|
||||
///
|
||||
/// @param aDbConnection
|
||||
/// @param $aQueryString
|
||||
/// @param $aBindArray e.g. array(
|
||||
/// ':userId' => array('value'=>$anUserId, 'data_type'=>PDO::PARAM_INT),
|
||||
/// ':attributeId'=> array('value'=>$anAttributeId, 'data_type'=>PDO::PARAM_INT) )
|
||||
/// @param $someOption
|
||||
function dbQuery($aDbConnection, $aQueryString, $aBindArray = array(), $someOptions = array()){
|
||||
// Standardbelegungen
|
||||
if( empty($someOptions['dbCharset' ]) ) $someOptions['dbCharset' ] = "ISO-8859-1";
|
||||
if( empty($someOptions['outCharset']) ) $someOptions['outCharset'] = "UTF-8";
|
||||
if( empty($someOptions['dontFetch' ]) ) $someOptions['dontFetch' ] = false;
|
||||
/// @toDo: Bisher wird nur die Rückgabe konvertiert. Eigentlich muss
|
||||
/// doch auch die Eingabe konvertiert werden. Aber das jetzt
|
||||
/// umzustellen wird schwer! Die User m Wettkampfplaner sind ja z.B.
|
||||
/// als UTF8 in latin1(?) gespeichert.
|
||||
/// @toDo: Die Standardwerte sollten vielleicht aus einer config
|
||||
/// kommen, nicht hardcoded
|
||||
try{
|
||||
$pdoStatement = $aDbConnection->prepare( $aQueryString );
|
||||
foreach( $aBindArray as $bindName => $bind ){
|
||||
if( $bind['data_type'] == PDO::PARAM_STR)
|
||||
$bind['value'] = iconv(
|
||||
$someOptions['outCharset'],
|
||||
$someOptions['dbCharset'],
|
||||
$bind['value']
|
||||
);
|
||||
$pdoStatement->bindValue(
|
||||
$bindName,
|
||||
$bind['value'],
|
||||
(isset($bind['data_type'])?$bind['data_type']:PDO::PARAM_STR)
|
||||
);
|
||||
}
|
||||
$pdoResult = $pdoStatement->execute();
|
||||
if(!$pdoResult){
|
||||
echo("Error during dbQuery!\n");
|
||||
echo("DB-Error:\n"); var_dump($aDbConnection->errorInfo());
|
||||
// var_dump($aQueryString);
|
||||
// var_dump($aBindArray);
|
||||
// echo($pdoStatement.errorInfo());
|
||||
}
|
||||
if($someOptions['dontFetch']){
|
||||
$ret = NULL;
|
||||
}
|
||||
else{
|
||||
$ret = $pdoStatement->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
}
|
||||
catch(PDOException $db_error){
|
||||
print "Error!: " . $db_error->getMessage() . "<br/>";
|
||||
return null;
|
||||
}
|
||||
// Zeichensatzkonvertierung
|
||||
if( is_array($ret) ){
|
||||
foreach($ret as &$entry){
|
||||
array_walk(
|
||||
$entry,
|
||||
function (&$value, $key, $someOptions) {
|
||||
$value = iconv($someOptions['dbCharset'], $someOptions['outCharset'], $value);
|
||||
},
|
||||
$someOptions
|
||||
);
|
||||
}
|
||||
}
|
||||
//var_dump($ret);
|
||||
//var_dump($aQueryString);
|
||||
//var_dump($aBindArray);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function getLastAttendances($db, $minDate=null){
|
||||
if ($minDate == null){
|
||||
$minDate = new DateTime;
|
||||
$minDate->sub(new DateInterval("P1M")); // from the current date subtract a *P*eriod of *1* *M*onth
|
||||
}
|
||||
|
||||
$query = <<<SQL
|
||||
SELECT userId, date, vorname, name, corona_PLZ, corona_telephon, corona_eMail
|
||||
FROM `cwsvjudo`.`anwesenheit`
|
||||
JOIN `cwsvjudo`.`wkParticipo_Users`
|
||||
ON `cwsvjudo`.`anwesenheit`.`userId` = `cwsvjudo`.`wkParticipo_Users`.`id`
|
||||
WHERE :minDate <= date
|
||||
ORDER BY `date` DESC, `name`;
|
||||
SQL;
|
||||
$params = array(
|
||||
'minDate' => array('value' => $minDate->format('Y-m-d'), 'data_type' => PDO::PARAM_STR)
|
||||
);
|
||||
$options = array();
|
||||
$ret = dbQuery($db, $query, $params, $options);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function getUsersWithAttribute($dbConnection, $attributeName){
|
||||
$query = <<<SQL
|
||||
SELECT userId, name, vorname
|
||||
FROM `cwsvjudo`.`wkParticipo_Users`
|
||||
JOIN `cwsvjudo`.`wkParticipo_user<=>userAttributes`
|
||||
ON `cwsvjudo`.`wkParticipo_Users`.`id` =`cwsvjudo`.`wkParticipo_user<=>userAttributes`.`userId`
|
||||
WHERE `cwsvjudo`.`wkParticipo_user<=>userAttributes`.`attributeId` IN (
|
||||
SELECT `id` FROM `cwsvjudo`.`wkParticipo_userAttributes` WHERE `name` = :attributeName
|
||||
);
|
||||
SQL;
|
||||
$params = array(
|
||||
':attributeName' => array('value'=>$attributeName, 'data_type'=>PDO::PARAM_STR)
|
||||
);
|
||||
return dbQuery($dbConnection, $query, $params);
|
||||
}
|
||||
|
||||
function giveUserAnUserAttribute($dbConnection, $userId, $attributeName){
|
||||
$query = <<<SQL
|
||||
INSERT INTO `cwsvjudo`.`wkParticipo_user<=>userAttributes` (`userId`, `attributeId`)
|
||||
SELECT :userId, `id`
|
||||
FROM `cwsvjudo`.`wkParticipo_userAttributes`
|
||||
WHERE `name` = :attributeName;
|
||||
SQL;
|
||||
$params = array(
|
||||
':userId' => array('value'=>$userId, 'data_type'=>PDO::PARAM_INT),
|
||||
':attributeName' => array('value'=>$attributeName, 'data_type'=>PDO::PARAM_STR)
|
||||
);
|
||||
return dbQuery($dbConnection, $query, $params);
|
||||
}
|
||||
|
||||
function hasUserAttribute($dbConnection, $userId, $attributeName){
|
||||
$query = <<<SQL
|
||||
SELECT `wkParticipo_user<=>userAttributes`.userId, `wkParticipo_userAttributes`.name
|
||||
FROM `wkParticipo_user<=>userAttributes` LEFT JOIN `wkParticipo_userAttributes`
|
||||
ON `wkParticipo_user<=>userAttributes`.`attributeId` = `wkParticipo_userAttributes`.`id`
|
||||
WHERE `wkParticipo_userAttributes`.name = :attributeName AND userId=:userId;",
|
||||
SQL;
|
||||
$params = array(
|
||||
':userId' => array('value'=>$userId, 'data_type'=>PDO::PARAM_INT),
|
||||
':attributeName' => array('value'=>$attributeName, 'data_type'=>PDO::PARAM_STR)
|
||||
);
|
||||
$attributedUsers = dbQuery($dbConnection, $query, $params);
|
||||
foreach($attributedUsers as $u)
|
||||
if($u['userId']==$userId)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function giveJudokasAttendence($dbConnection, $date, $ids){
|
||||
$values = array();
|
||||
try{
|
||||
foreach( $ids as $id){
|
||||
array_push( $values, "(\"".$date."\", ".$id.")");;
|
||||
}
|
||||
$query = "INSERT INTO `cwsvjudo`.`anwesenheit` (`date`, `userId`) VALUES ".join(",", $values).";";
|
||||
dbQuery($dbConnection, $query, array(), ['dontFetch' => true]);
|
||||
}
|
||||
catch(PDOException $db_error){
|
||||
print "Error!: " . $db_error->getMessage() . "<br/>";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function getUsersKidsIds($db, $userId){
|
||||
$query = <<<SQL
|
||||
SELECT `kidId`
|
||||
FROM `vormundschaft`
|
||||
WHERE userId = :userId;
|
||||
SQL;
|
||||
$params = [':userId'=>['value'=>$userId, 'data_type'=>PDO::PARAM_INT]];
|
||||
$result = dbQuery($db, $query, $params);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getUsersKids($db, $userId){
|
||||
$query = <<<SQL
|
||||
SELECT *
|
||||
FROM `wkParticipo_Users`
|
||||
JOIN `vormundschaft`
|
||||
ON `wkParticipo_Users`.`id` = `vormundschaft`.`kidId`
|
||||
WHERE `vormundschaft`.`userId` = :userId;
|
||||
SQL;
|
||||
$params = [':userId'=>['value'=>$userId, 'data_type'=>PDO::PARAM_INT]];
|
||||
$result = dbQuery($db, $query, $params);
|
||||
return $result;
|
||||
}
|
||||
|
||||
// updates corona data of an user
|
||||
function updateCoronaData($db, $userId, $columnName, $columnValue){
|
||||
$coronaColumnNames = ["corona_PLZ", "corona_telephon", "corona_eMail"];
|
||||
|
||||
if( !in_array( $columnName, $coronaColumnNames) ){
|
||||
return;
|
||||
}
|
||||
$query = "UPDATE `cwsvjudo`.`wkParticipo_Users` SET `".$columnName."`=:val WHERE `id`=:id;";
|
||||
$params = array(
|
||||
':val' => array('value'=>$columnValue, 'data_type'=>PDO::PARAM_STR),
|
||||
':id' => array('value'=>$userId, 'data_type'=>PDO::PARAM_INT)
|
||||
);
|
||||
dbQuery($db, $query, $params);
|
||||
return;
|
||||
}
|
||||
|
||||
function addCoronaUser($db, $name, $vorname, $corona_PLZ, $corona_telephon, $corona_eMail){
|
||||
$query = <<<SQL
|
||||
INSERT INTO `cwsvjudo`.`wkParticipo_Users` (name, vorname, corona_PLZ, corona_telephon, corona_eMail)
|
||||
VALUES (:name, :vorname, :plz, :telephon, :email);
|
||||
SQL;
|
||||
$params = array(
|
||||
':name' => array('value'=>$name, 'data_type'=>PDO::PARAM_STR),
|
||||
':vorname' => array('value'=>$vorname, 'data_type'=>PDO::PARAM_STR),
|
||||
':plz' => array('value'=>$corona_PLZ, 'data_type'=>PDO::PARAM_STR),
|
||||
':telephon' => array('value'=>$corona_telephon, 'data_type'=>PDO::PARAM_STR),
|
||||
':email' => array('value'=>$corona_eMail, 'data_type'=>PDO::PARAM_STR),
|
||||
);
|
||||
dbQuery($db, $query, $params);
|
||||
|
||||
$newId = $db->lastInsertId();
|
||||
giveUserAnUserAttribute($db, $newId, "inTraining");
|
||||
return;
|
||||
}
|
||||
|
||||
function giveUserAnAchievement($db, $userId, $achievementId){
|
||||
$query = <<<SQL
|
||||
INSERT INTO `cwsvjudo`.`achievements<=>user` (`userId`, `achievementId`) VALUE (:userId, :achievementId);
|
||||
SQL;
|
||||
$params = [':userId'=>['value'=>$userId, 'data_type'=>PDO::PARAM_INT], 'achievementId'=>['value'=>$achievementId, 'data_type'=>PDO::PARAM_INT]];
|
||||
dbQuery($db, $query, $params);
|
||||
return;
|
||||
}
|
||||
|
||||
function isUserAdmin($dbConn, $userId){
|
||||
$adminUsers =
|
||||
dbQuery(
|
||||
$dbConn,
|
||||
"SELECT `wkParticipo_user<=>userAttributes`.userId, `wkParticipo_userAttributes`.name from `wkParticipo_user<=>userAttributes` LEFT JOIN `wkParticipo_userAttributes` ON `wkParticipo_user<=>userAttributes`.attributeId = `wkParticipo_userAttributes`.id WHERE `wkParticipo_userAttributes`.name = :attributeName;",
|
||||
array(":attributeName"=>array('value'=>"isAdmin", 'data_type'=>PDO::PARAM_STR))
|
||||
);
|
||||
foreach($adminUsers as $adminUser)
|
||||
if($adminUser['userId']==$userId)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function getUserData($db, $userId){
|
||||
$query = <<<SQL
|
||||
SELECT *
|
||||
FROM `cwsvjudo`.`wkParticipo_Users`
|
||||
WHERE `id` = :userId;
|
||||
SQL;
|
||||
$params = [':userId'=>['value'=>$userId, 'data_type'=>PDO::PARAM_INT]];
|
||||
$userData = dbQuery($db, $query, $params);
|
||||
return $userData[0];
|
||||
}
|
||||
|
||||
function getAchievements($db){
|
||||
$query = <<<SQL
|
||||
SELECT *
|
||||
FROM `cwsvjudo`.`achievements`;
|
||||
SQL;
|
||||
return dbQuery($db, $query);
|
||||
}
|
||||
|
||||
function getAchievement($db, $id){
|
||||
$query = <<<SQL
|
||||
SELECT *
|
||||
FROM `cwsvjudo`.`achievements`
|
||||
WHERE `id`=:id;
|
||||
SQL;
|
||||
$params = [':id'=>['value'=>$id, 'data_type'=>PDO::PARAM_INT]];
|
||||
return dbQuery($db, $query, $params);
|
||||
}
|
||||
|
||||
function addAchievement($db, $name, $rootId, $achievementGroupId, $level, $description, $imgUrl){
|
||||
// var_dump($db);
|
||||
if($rootId=="")
|
||||
$rootId=null;
|
||||
if($imgUrl=="")
|
||||
$imgUrl=null;
|
||||
$query = <<<SQL
|
||||
INSERT INTO `cwsvjudo`.`achievements` (name, rootId, achievementGroupId, level, description, imgUrl)
|
||||
VALUES (:name, :rootId, :achievementGroupId, :level, :description, :imgUrl);
|
||||
SQL;
|
||||
$params=[
|
||||
':name' => ['value'=>$name, 'data_type'=>PDO::PARAM_STR],
|
||||
':rootId' => ['value'=>$rootId, 'data_type'=>PDO::PARAM_INT],
|
||||
':achievementGroupId' => ['value'=>$achievementGroupId, 'data_type'=>PDO::PARAM_INT],
|
||||
':level' => ['value'=>$level, 'data_type'=>PDO::PARAM_INT],
|
||||
':description' => ['value'=>$description, 'data_type'=>PDO::PARAM_STR],
|
||||
':imgUrl' => ['value'=>$imgUrl, 'data_type'=>PDO::PARAM_STR],
|
||||
];
|
||||
dbQuery($db, $query, $params, ['dontFetch'=>true]);
|
||||
return;
|
||||
}
|
||||
|
||||
function addAchievementGroup($db, $name, $unlockingAchievementId, $imgUrl){
|
||||
if($unlockingAchievementId=="")
|
||||
$unlockingAchievementId=null;
|
||||
if($imgUrl=="")
|
||||
$imgUrl=null;
|
||||
$query = <<<SQL
|
||||
INSERT INTO `cwsvjudo`.`machs_achievementGroups` (name, unlockingAchievementId, imgUrl)
|
||||
VALUES (:name, :unlockingAchievementId, :imgUrl);
|
||||
SQL;
|
||||
$params=[
|
||||
':name' => ['value'=>$name, 'data_type'=>PDO::PARAM_STR],
|
||||
':unlockingAchievementId' => ['value'=>$unlockingAchievementId, 'data_type'=>PDO::PARAM_INT],
|
||||
':imgUrl' => ['value'=>$imgUrl, 'data_type'=>PDO::PARAM_STR],
|
||||
];
|
||||
dbQuery($db, $query, $params, ['dontFetch'=>true]);
|
||||
return;
|
||||
}
|
||||
|
||||
function updateAchievement($db, $achievementId, $name, $rootId, $achievementGroupId, $level, $description, $imgUrl){
|
||||
if($rootId=="")
|
||||
$rootId=null;
|
||||
if($imgUrl=="")
|
||||
$imgUrl=null;
|
||||
$query = <<<SQL
|
||||
UPDATE `cwsvjudo`.`achievements`
|
||||
SET name=:name, rootId=:rootId, achievementGroupId=:achievementGroupId, level=:level, description=:description, imgUrl:=imgUrl
|
||||
WHERE `id`=:achievementId;
|
||||
SQL;
|
||||
$params=[
|
||||
':name' => ['value'=>$name, 'data_type'=>PDO::PARAM_STR],
|
||||
':achievementGroupId' => ['value'=>$achievementGroupId, 'data_type'=>PDO::PARAM_INT],
|
||||
':rootId' => ['value'=>$rootId, 'data_type'=>PDO::PARAM_INT],
|
||||
':level' => ['value'=>$level, 'data_type'=>PDO::PARAM_INT],
|
||||
':description' => ['value'=>$description, 'data_type'=>PDO::PARAM_STR],
|
||||
':imgUrl' => ['value'=>$imgUrl, 'data_type'=>PDO::PARAM_STR],
|
||||
':achievementId' => ['value'=>$achievementId, 'data_type'=>PDO::PARAM_INT],
|
||||
];
|
||||
dbQuery($db, $query, $params, ['dontFetch'=>true]);
|
||||
return;
|
||||
}
|
||||
|
||||
function updateAchievementGroup($db, $achievementGroupId, $name, $unlockingAchievementId, $imgUrl){
|
||||
if($unlockingAchievementId=="")
|
||||
$unlockingAchievementId=null;
|
||||
if($imgUrl=="")
|
||||
$imgUrl=null;
|
||||
$query = <<<SQL
|
||||
UPDATE `cwsvjudo`.`machs_achievementGroups`
|
||||
SET name=:name, rootId=:rootId, achievementGroupId=:achievementGroupId, level=:level, description=:description, imgUrl:=imgUrl
|
||||
WHERE `id`=:achievementGroupId;
|
||||
SQL;
|
||||
$params=[
|
||||
':achievementGroupId' => ['value'=>$achievementGroupId, 'data_type'=>PDO::PARAM_INT],
|
||||
':name' => ['value'=>$name, 'data_type'=>PDO::PARAM_STR],
|
||||
':unlockingAchievementId' => ['value'=>$unlockingAchievementId, 'data_type'=>PDO::PARAM_INT],
|
||||
':imgUrl' => ['value'=>$imgUrl, 'data_type'=>PDO::PARAM_STR],
|
||||
];
|
||||
dbQuery($db, $query, $params, ['dontFetch'=>true]);
|
||||
return;
|
||||
}
|
||||
|
||||
function setBday($db, $userId, $bday){
|
||||
$query = <<<SQL
|
||||
UPDATE `cwsvjudo`.`wkParticipo_Users`
|
||||
SET gebDatum=:bday
|
||||
WHERE `id`=:userId;
|
||||
SQL;
|
||||
$params=[
|
||||
':bday' => ['value'=>$bday, 'data_type'=>PDO::PARAM_STR],
|
||||
':userId' => ['value'=>$userId, 'data_type'=>PDO::PARAM_INT]
|
||||
];
|
||||
dbQuery($db, $query, $params, ['dontFetch'=>true]);
|
||||
return;
|
||||
}
|
||||
|
||||
function setRecord($db, $userId, $achievementGroupId, $value){
|
||||
$u = getUserData($db, $userId);
|
||||
$query = <<<SQL
|
||||
INSERT `cwsvjudo`.`machs_records`
|
||||
SET achievementGroupId=:achievementGroupId, ageClass=:ageClass, userId=:userId, value=:value
|
||||
SQL;
|
||||
$params=[
|
||||
':achievementGroupId' => ['value'=>$achievementGroupId, 'data_type'=>PDO::PARAM_INT],
|
||||
':ageClass' => ['value'=>record::birthday2ageClass($u['gebDatum']), 'data_type'=>PDO::PARAM_INT],
|
||||
':userId' => ['value'=>$userId, 'data_type'=>PDO::PARAM_INT],
|
||||
':value' => ['value'=>$value, 'data_type'=>PDO::PARAM_INT],
|
||||
];
|
||||
dbQuery($db, $query, $params, ['dontFetch'=>true]);
|
||||
//var_dump($userId, $achievementGroupId, $value);
|
||||
//var_dump($query, $params);
|
||||
return;
|
||||
}
|
||||
|
||||
function canUserGetAchievementToday($db, $userId){
|
||||
$achievements = getUsersAchievements($db, $userId);
|
||||
foreach($achievements as $a){
|
||||
if( date('Ymd') == date('Ymd', strtotime($a['timestamp'])) ){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
34
homepage/participo/lib/participoLib/participo.php
Normal file
34
homepage/participo/lib/participoLib/participo.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/// Eine Fehler/Warnung/Notiz/Erfolgsmeldung als divBox im String zurückgeben
|
||||
function htmlRetMessage($anRetMessage){
|
||||
$retHtmlString = "";
|
||||
if( !empty($anRetMessage) ){
|
||||
$retHtmlString .= "<div style=\"border: 1px solid;\">";
|
||||
if( !empty($anRetMessage['error']) ){
|
||||
$retHtmlString .= "<div style=\"border: 1px solid;\">";
|
||||
$retHtmlString .= "ERROR:<br />";
|
||||
$retHtmlString .= $anRetMessage['error'];
|
||||
$retHtmlString .= "</div>";
|
||||
}
|
||||
if( !empty($anRetMessage['warning']) ){
|
||||
$retHtmlString .= "<div style=\"border: 1px solid;\">";
|
||||
$retHtmlString .= "WARNING:<br />";
|
||||
$retHtmlString .= $anRetMessage['warning'];
|
||||
$retHtmlString .= "</div>";
|
||||
}
|
||||
if( !empty($anRetMessage['notice']) ){
|
||||
$retHtmlString .= "<div style=\"border: 1px solid;\">";
|
||||
$retHtmlString .= "Info:<br />";
|
||||
$retHtmlString .= $anRetMessage['notice'];
|
||||
$retHtmlString .= "</div>";
|
||||
}
|
||||
if( !empty($anRetMessage['success']) ){
|
||||
$retHtmlString .= "<div style=\"border: 1px solid;\">";
|
||||
$retHtmlString .= "SUCCESS:<br />";
|
||||
$retHtmlString .= $anRetMessage['success'];
|
||||
$retHtmlString .= "</div>";
|
||||
}
|
||||
$retHtmlString .= "</div>";
|
||||
}
|
||||
return $retHtmlString;
|
||||
}?>
|
||||
1
homepage/participo/local/.htaccess
Normal file
1
homepage/participo/local/.htaccess
Normal file
@@ -0,0 +1 @@
|
||||
Deny from all
|
||||
10
homepage/participo/local/achievementsConf.php
Normal file
10
homepage/participo/local/achievementsConf.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
// Die Domains, Basedomain und Subdomain sind nicht wörtlich zu nehmen
|
||||
// effektiv ist es einfach eine Zweiteilung des Domainnamens
|
||||
$wkParticipoConf['baseDomain'] = "cwsvjudo.bplaced.net";
|
||||
$wkParticipoConf['subDomain'] = "";
|
||||
/// Basis(/Root)-Verzeichnis auf dem Server (für Dateizugriffe, insbesondere phpIncludes)
|
||||
$wkParticipoConf['basePath'] = "/users/cwsvjudo/www";
|
||||
$wkParticipoConf['rootDir'] = "/pages/desktop/wkParticipo";
|
||||
$wkParticipoConf['adminEmail'] = "cwsvjudo@arcor.de";
|
||||
?>
|
||||
6
homepage/participo/local/cwsvJudo.php
Normal file
6
homepage/participo/local/cwsvJudo.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$cwsvJudoConfig["db"]["host"] = "localhost";
|
||||
$cwsvJudoConfig["db"]["name"] = "cwsvjudo";
|
||||
$cwsvJudoConfig["db"]["user"] = "cwsvjudo";
|
||||
$cwsvJudoConfig["db"]["password"] = "***REMOVED***";
|
||||
?>
|
||||
8
homepage/participo/local/dbConf.php
Normal file
8
homepage/participo/local/dbConf.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$db_server='localhost';
|
||||
$db_user='cwsvjudo';
|
||||
$db_password='***REMOVED***';
|
||||
$db_name='cwsvjudo';
|
||||
|
||||
?>
|
||||
114
homepage/participo/login.php
Normal file
114
homepage/participo/login.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
|
||||
|
||||
require_once("lib/participoLib/participo.php");
|
||||
require_once("config/participo.php");
|
||||
|
||||
require_once("./local/dbConf.php");
|
||||
// require_once("./local/achievementsConf.php");
|
||||
|
||||
// require_once("./lib/achievementsLib.php");
|
||||
|
||||
$basePath = $config['basePath'];
|
||||
require_once($basePath."/config/phpcount.config.php");
|
||||
require_once($basePath."/ressourcen/phpLib/phpcount/phpcount.php");
|
||||
|
||||
|
||||
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, <a href="index.php">weiter zum Inhalt</a>.';
|
||||
PHPCount::AddHit("participo-Login ".$_POST['f']['username']);
|
||||
header('Location: http://' . $_SERVER['HTTP_HOST'] . '/participo?user=' . $_POST['f']['username']);
|
||||
} else {
|
||||
sleep(5);
|
||||
$message['error'] = 'Das Kennwort ist nicht korrekt.';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
||||
|
||||
if (isset($_SESSION['login'])) {
|
||||
header('Location: http://' . $_SERVER['HTTP_HOST'] . '/index.php');
|
||||
}
|
||||
else{
|
||||
if (!empty($_POST)) {
|
||||
if (
|
||||
empty($_POST['f']['username']) ||
|
||||
empty($_POST['f']['password'])
|
||||
) {
|
||||
$message['error'] = 'Es wurden nicht alle Felder ausgefüllt.';
|
||||
} else {
|
||||
|
||||
$message = checkCredentials($_POST['f']['username'], $_POST['f']['password'], $db_server, $db_user, $db_password, $db_name);
|
||||
if( !isset($message['error']) )
|
||||
$message['notice'] = "Achievement-System der Judoka des Chemnitzer WSV";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<!-- Materialize: Compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
|
||||
<!-- Materialize: Compiled and minified JavaScript -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
||||
|
||||
<title>Login des Achievementsystemes der Judoka des Chemnitzer WSV</title>
|
||||
<meta name="description" content="Loginseite der Online-Apps der Judoka des CWSV">
|
||||
</head>
|
||||
<body class="container">
|
||||
<h1>Loginseite der Online-Apps der Judoka des CWSV</h1>
|
||||
<?php echo(htmlRetMessage($message));?>
|
||||
<form action="./login.php" method="post">
|
||||
<fieldset>
|
||||
<legend>Benutzerdaten</legend>
|
||||
<div>
|
||||
<label for="username">Benutzername</label>
|
||||
<input id="username"type="text" name="f[username]" <?php echo isset($_POST['f']['username']) ? ' value="' . htmlspecialchars($_POST['f']['username']) . '"' : '' ?> />
|
||||
</div>
|
||||
<div>
|
||||
<label for="password">Kennnwort</label>
|
||||
<input id="password" type="password" name="f[password]" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div>
|
||||
<button type="submit" name="submit" value="Anmelden">Anmelden</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset class="notice"><legend>Hinweise</legend>
|
||||
<ul style="padding-left: inherit;">
|
||||
<li style="list-style-type: circle;" >Logindaten sind über den Übungsleiter zu beantragen.</li>
|
||||
<li style="list-style-type: circle;" >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.</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
18
homepage/participo/logout.php
Normal file
18
homepage/participo/logout.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
session_start();
|
||||
$_SESSION = array();
|
||||
if (ini_get('session.use_cookies')) {
|
||||
$params = session_get_cookie_params();
|
||||
setcookie(
|
||||
session_name(),
|
||||
'',
|
||||
time() - 42000,
|
||||
$params['path'],
|
||||
$params['domain'],
|
||||
$params['secure"'],
|
||||
$params['httponly']
|
||||
);
|
||||
}
|
||||
session_destroy();
|
||||
header('Location: ./login.php');
|
||||
?>
|
||||
1
homepage/participo/sidenav/backToMain.php
Normal file
1
homepage/participo/sidenav/backToMain.php
Normal file
@@ -0,0 +1 @@
|
||||
<li><a href=".">zurück zur Hauptseite</a></li>
|
||||
15
homepage/participo/sidenav/kyu.php
Normal file
15
homepage/participo/sidenav/kyu.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<li>
|
||||
<a href="kyu.php?kyu=8">8. Kyu - weiß-gelb</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="kyu.php?kyu=7">7. Kyu - gelb</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="kyu.php?kyu=6">6. Kyu - gelb-orange</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="kyu.php?kyu=5">5. Kyu - orange</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="kyu.php?kyu=4">4. Kyu - orange-grün</a>
|
||||
</li>
|
||||
6
homepage/participo/sidenav/loginStatus.php
Normal file
6
homepage/participo/sidenav/loginStatus.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<li>
|
||||
Angemeldet als <?php echo($_SESSION['user']['username']); ?>
|
||||
</li>
|
||||
<li>
|
||||
<a href="./logout.php">Logout</a>
|
||||
</li>
|
||||
Reference in New Issue
Block a user