diff --git a/homepage/mams/.htaccess b/homepage/mams/.htaccess
new file mode 100644
index 0000000..34b4883
--- /dev/null
+++ b/homepage/mams/.htaccess
@@ -0,0 +1,6 @@
+AuthType Basic
+AuthName "tempDirectory"
+AuthUserFile /users/cwsvjudo/www/.htusers
+#AuthGroupFile /users/cwsvjudo/www/.htgroups
+Require user marko
+#Require group admin
diff --git a/homepage/mams/index.php b/homepage/mams/index.php
new file mode 100644
index 0000000..b6c87d1
--- /dev/null
+++ b/homepage/mams/index.php
@@ -0,0 +1,100 @@
+
+
+
+
+ Corona-Anwesenheitsliste der Judoka des Chemnitzer WSV
+ Anwesenheiten hinzufügen
+
+ Anwesenheiten
+ Sende Anwesenheitsliste an eMail
+
+ $attendees){
+ echo("".$date."
");
+ echo("");
+ echo("");
+ echo("| name | ");
+ echo("vorname | ");
+ echo("PLZ | ");
+ echo("Telefon | ");
+ echo("eMail | ");
+ echo("
");
+ foreach($attendees as $a){
+ echo("");
+ echo("| ".$a['name']." | ");
+ echo("".$a['vorname']." | ");
+ echo("".( $a['corona_PLZ'] ? $a['corona_PLZ'] : "")." | ");
+ echo("".( $a['corona_telephon'] ? $a['corona_telephon'] : "")." | ");
+ echo("".( $a['corona_eMail'] ? $a['corona_eMail'] : "")." | ");
+ echo("
");
+ }
+ echo("
");
+ }
+ ?>
+ Trainee hinzufügen
+
+
+
diff --git a/homepage/mams/lib/.htaccess b/homepage/mams/lib/.htaccess
new file mode 100644
index 0000000..3a42882
--- /dev/null
+++ b/homepage/mams/lib/.htaccess
@@ -0,0 +1 @@
+Deny from all
diff --git a/homepage/mams/lib/api.php b/homepage/mams/lib/api.php
new file mode 100644
index 0000000..ff7a13f
--- /dev/null
+++ b/homepage/mams/lib/api.php
@@ -0,0 +1,83 @@
+format("Y-m-d"),
+ $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;
+}
+?>
diff --git a/homepage/mams/lib/db.php b/homepage/mams/lib/db.php
new file mode 100644
index 0000000..493fa49
--- /dev/null
+++ b/homepage/mams/lib/db.php
@@ -0,0 +1,189 @@
+getMessage() );
+ }
+return $dbConnection;
+}
+
+function createDb($dbConnection){
+<< 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 ){
+ $pdoStatement->bindValue(
+ $bindName,
+ $bind['value'],
+ (isset($bind['data_type'])?$bind['data_type']:PDO::PARAM_STR)
+ );
+ }
+ $pdoResult = $pdoStatement->execute();
+
+ if($someOptions['dontFetch']){
+ $ret = NULL;
+ }
+ else{
+ $ret = $pdoStatement->fetchAll(PDO::FETCH_ASSOC);
+ }
+ }
+ catch(PDOException $db_error){
+ print "Error!: " . $db_error->getMessage() . "
";
+ 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 = << 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 = <<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 = <<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 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() . "
";
+ return null;
+ }
+}
+
+// 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 = << 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;
+}
+?>
diff --git a/homepage/mams/local/.htaccess b/homepage/mams/local/.htaccess
new file mode 100644
index 0000000..3a42882
--- /dev/null
+++ b/homepage/mams/local/.htaccess
@@ -0,0 +1 @@
+Deny from all
diff --git a/homepage/mams/local/cwsvJudo.config.php b/homepage/mams/local/cwsvJudo.config.php
new file mode 100644
index 0000000..3998c08
--- /dev/null
+++ b/homepage/mams/local/cwsvJudo.config.php
@@ -0,0 +1,6 @@
+