From 782588c613d51f55f097b324b523da4c2dd773af Mon Sep 17 00:00:00 2001 From: marko Date: Sun, 25 Oct 2020 16:19:27 +0100 Subject: [PATCH] First Version --- homepage/mams/.htaccess | 6 ++ homepage/mams/index.php | 64 ++++++++++++ homepage/mams/lib/db.php | 126 ++++++++++++++++++++++++ homepage/mams/local/cwsvJudo.config.php | 6 ++ 4 files changed, 202 insertions(+) create mode 100644 homepage/mams/.htaccess create mode 100644 homepage/mams/index.php create mode 100644 homepage/mams/lib/db.php create mode 100644 homepage/mams/local/cwsvJudo.config.php 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..3d2eff6 --- /dev/null +++ b/homepage/mams/index.php @@ -0,0 +1,64 @@ + + + +
+ + " /> + + +
+ $attendees);{ + echo("

".$date."

"); + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); + foreach($attendees as $a){ + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); + echo(""); + } + echo("
namevornamePLZTelefoneMail
".$a[0]['name']."".$a[0]['vorname']."".$a[0]['corona_PLZ']."".$a[0]['corona_telephon']."".$a[0]['corona_eMail']."
"); + } + ?> + + diff --git a/homepage/mams/lib/db.php b/homepage/mams/lib/db.php new file mode 100644 index 0000000..e00cd2d --- /dev/null +++ b/homepage/mams/lib/db.php @@ -0,0 +1,126 @@ +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(!$pdoResult) + //echo("Strange! \"".$aQueryString."\" failed without exception!"); + + 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 + ); + } + } +return $ret; +} + +function getLastAttendances($db){ + $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 giveJudokasAttendence($dbConnection, $date, $ids){ + $values = array(); + 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]); +} +?> 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 @@ +