- wurden bisher noch nicht verfolgt:

neue Datei:     admin/.htaccess
	neue Datei:     admin/.htgroups
	neue Datei:     admin/.htusers
	neue Datei:     admin/config.inc.php
- Erstellung der news erweitert (promoImg)
	geändert:       admin/newsAdmin.php
	neue Datei:     admin/newsAmpTest.php
	neue Datei:     admin/newsLib.php.inc
	neue Datei:     admin/newsTest.php
	neue Datei:     admin/redirecter/redirectLog.php
	neue Datei:     css/cwsvJudo-2018-quiz.css
	geändert:       md/galerie.md
	geändert:       md/trainingszeiten.md
	neue Datei:     phpLib/cwsvJudo/gallery.lib.php
	geändert:       phpLib/cwsvJudo/miscAssis.php
	geändert:       phpLib/imgGallery/index.php.tmpl
	gelöscht:       phpLib/imgGallery/indexDev.php.tmpl
This commit is contained in:
marko
2018-07-29 18:47:48 +02:00
parent a3234541c7
commit 1865d45e09
16 changed files with 543 additions and 375 deletions

View File

@@ -0,0 +1,6 @@
AuthType Basic
AuthName "cwsvJudoAdmin"
AuthUserFile /users/cwsvjudo/www/admin/.htusers
AuthGroupFile /users/cwsvjudo/www/admin/.htgroups
Require user marko
Require group admin

View File

@@ -0,0 +1 @@
admin: marko

View File

@@ -0,0 +1,2 @@
# userFile
marko:$2y$05$Bt1hCGXhdO2JcJy9SXt96e.DmXvnutpOxmDw233CGaUOQL6kczXQK

View File

@@ -0,0 +1,23 @@
<?php
/// Die Basisdomain, unter der die Hauptseite zu erreichen ist
$baseDomain = "cwsvjudo.bplaced.net";
/// Subdomain, unter dem dieses Verzeichnis zu finden ist (falls der Fall gegeben ist)
$subDomain = "";
/// Basis(/Root)-Verzeichnis auf dem Server (für Dateizugriffe, insbesondere phpIncludes)
$basePath = "/users/cwsvjudo/www";
/// scheme-Part der URL (das Protokol)
$urlScheme = "http";
/// Url zum Zugriff auf "shared Data" unter der Hauptadresse
$baseUrl = $urlScheme."://".$baseDomain;
/// Die kanonische Url dieses Verzeichnisses (unter welcher
/// Domainadresse die Seiten dieses Verzeichnisses bevorzugt zu
/// erreichen seien sollen, also entweder eine SubdomainUrl, oder die
/// baseUrl mit dem Verzeichnis angehängt) evtl. Pfade müssen noch
/// angehangen werden.
/// Achtung: Gedacht für eine einheitliche Bezeichnung bei internem
/// Verlinken. Der canonicalLink im Header ist bei ampSeiten nicht die
/// eigene Adresse, sondern die (kanonische) Adresse der "normalen"
/// Version der Seite.
$canonicalUrlBase = $urlScheme."://".$subDomain.(!empty($subDomain)?".":"").$baseDomain;
?>

View File

@@ -11,19 +11,6 @@
require_once($basePath."/ressourcen/phpLib/parsedown/Parsedown.php");
function firstNonEmptyOf($somePossibleEmptyStuff){
if (is_array($somePossibleEmptyStuff) || $somePossibleEmptyStuff instanceof Traversable){
foreach($somePossibleEmptyStuff as $entry){
if(empty($entry))
continue;
else
return $entry;
}
}
return null;
}
// benötigt parsedown
function submitNewsToDb($aNews, $someOptions = array()){
// Standardargumente setzen

View File

@@ -0,0 +1,39 @@
<?php
require_once("config.php.inc");
require_once("newsLib.php.inc");
require_once( $basePath."/bonus/db.inc" );
$mysqlConn = @new mysqli($db_server, $db_user, $db_password, $db_name);
if($mysqlConn->connect_error){
// @ToDo: bessere Fehlerbehandlung
die("Datenbankverbindung fehlgeschlagen: " . $mysqlConn->connect_error . "\n");
//$message['error'] += "Datenbankverbindung fehlgeschlagen: " . $mysqlConn->connect_error . "<br />";
}
$newsId = isset($_GET["newsId"]) ? $_GET["newsId"] : "";
//$newsDate = empty($_GET['date']) ? date("Y-m-d") : $_GET['date'];
$newsById = array();
$prevNewsId = "";
$postNewsId = "";
$news = getNewsById($mysqlConn);
?>
<!doctype html>
<html amp lang="de">
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<title><?php echo($news['betreff']);?></title>
<link rel="canonical" href="http://example.ampproject.org/article-metadata.html">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<script type="application/ld+json"><?php echo(news2json( $news ));?></script>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
</head>
<body>
<h1>cwsvJudo - News</h1>
<?php echo(getAmpNews($news));?>
</body>
</html>

View File

@@ -0,0 +1,296 @@
<?php
/// Eine News per ID abfragen
///
/// Der Rückgabewert sollte vor Verwendung (und zur Fehlerbeheandlung)
/// auf NULL und/oder leeres Array getestet werden.
/// Der Zeichensatz wird von "ISO-8859-1" auf "UTF-8" gesetzt
///
/// @return Eine einzelne Nachricht als Array
function getNewsById($aMysqlConn, $aNewsId = "0", $optionsArray = array("dbCharset" => "ISO-8859-1", "outCharset" => "UTF-8")){
if(!$aMysqlConn) return NULL;
$ret = array();
$query = "";
if( is_positive_integer($aNewsId) ){
$query = sprintf(
"SELECT * FROM nachrichten WHERE nr='%s';",
$aMysqlConn->real_escape_string($aNewsId)
);
}
else{
$query = sprintf(
"SELECT * FROM nachrichten ORDER BY datum DESC, nr DESC LIMIT 0, 1;"
);
}
$results = $aMysqlConn->query($query);
if( !empty($results) ) $ret = $results->fetch_assoc();
// Zeichensatzkonvertierung
array_walk(
$ret,
function (&$value, $key, $optionsArray) {
$value = iconv($optionsArray['dbCharset'], $optionsArray['outCharset'], $value);
},
$optionsArray
);
return $ret;
}
/// Abfrage der Id der vorhergehenden News nach Id
function getPrevNewsId($aMysqlConn, $aNews, $optionsArray = array() ){
$queryNewsId = sprintf("
SELECT nr FROM cwsvjudo.nachrichten
WHERE datum <= '%s' AND nr < '%s'
ORDER BY nr DESC
LIMIT 0, 1;",
$aMysqlConn->real_escape_string( $aNews['datum'] ),
$aMysqlConn->real_escape_string( $aNews['nr'] )
);
$mysqlResults = $aMysqlConn->query($queryNewsId);
if( !$mysqlResults ) return "";
$newsIdResult = $mysqlResults->fetch_assoc();
if( empty($newsIdResult) ) return "";
return $newsIdResult['nr'];
}
/// Abfrage der Id der nachfolgenden News nach Id
function getNextNewsId($aMysqlConn, $aNews, $optionsArray = array() ){
$queryNewsId = sprintf("
SELECT nr FROM cwsvjudo.nachrichten
WHERE datum >= '%s' AND nr > '%s'
ORDER BY nr DESC
LIMIT 0, 1;",
$aMysqlConn->real_escape_string( $aNews['datum'] ),
$aMysqlConn->real_escape_string( $aNews['nr'] )
);
$mysqlResults = $aMysqlConn->query($queryNewsId);
if( !$mysqlResults ) return "";
$newsIdResult = $mysqlResults->fetch_assoc();
if( empty($newsIdResult) ) return "";
return $newsIdResult['nr'];
}
/// Zu einer Nachricht strukurierte Daten als json bereit stellen
function news2json($aNews){
$ret = "";
$ret .= "{";
$ret .= " \"@context\": \"http://schema.org\",";
$ret .= " \"@type\": \"NewsArticle\",";
$ret .= " \"mainEntityOfPage\": {";
$ret .= " \"@type\": \"WebPage\",";
$ret .= " \"@id\": \"http://cwsvjudo.bplaced.net/pages/amp/news.php?newsId=" . $aNews['nr'] . "\"";
$ret .= " },";
$ret .= " \"headline\": \"". $aNews['betreff'] ."\",";
$ret .= " \"image\": {";
$ret .= " \"@type\": \"ImageObject\",";
//$ret .= " \"url\": \"http://cwsvjudo.bplaced.net/ressourcen/graphiken/logos/cwsvJudoLogoWappen-696x-nq8.png\",";
//$ret .= " \"url\": \"". $baseUrl . str_replace( ".png", ".jpg", str_replace( "/thumbs/", "/images/", newsPromoImage( getNewsById($mysqlConn, "118") )['src'][0]));
//$ret .= " \"height\": 563,";
//$ret .= " \"width\": 696";
$ret .= " \"url\": \"http://cwsvjudo.bplaced.net" . str_replace( ".png", ".jpg", str_replace( "/thumbs/", "/images/", getHtmlImgTags( $aNews['nachricht'] )[0]['src'])) ."\",";
$ret .= " \"height\": 786,";
$ret .= " \"width\": 1024";
$ret .= " },";
$ret .= " \"datePublished\": \"" . $aNews['datum'] . "\",";
$ret .= " \"dateModified\": \"" . $aNews['datum'] . "\",";
$ret .= " \"author\": {";
$ret .= " \"@type\": \"Person\",";
$ret .= " \"name\": \"" . $aNews['autor'] . "\"";
$ret .= " },";
$ret .= " \"publisher\": " . file_get_contents("/users/cwsvjudo/www/ressourcen/structuredData/json/cwsvJudoAsPublisher.json") . ",";
//$ret .= " \"publisher\": {";
//$ret .= " \"@type\": \"Organization\",";
//$ret .= " \"name\": \"Google\",";
//$ret .= " \"logo\": {";
//$ret .= " \"@type\": \"ImageObject\",";
//$ret .= " \"url\": \"https://google.com/logo.jpg\",";
//$ret .= " \"width\": 600,";
//$ret .= " \"height\": 60";
//$ret .= " }";
//$ret .= " },";
//$ret .= " \"description\": \"".$aNews['betreff']."\"";
$ret .= " \"description\": \"".preg_replace( '/[\p{Z}\s]{2,}/s', ' ', strip_tags( $aNews['nachricht'] ) )."\"";
$ret .= "}";
return $ret;
/*
Property list for article structured data
Properties
mainEntityOfPage
URL; recommended (AMP), ignored (non-AMP)
The canonical URL of the article page. Specify mainEntityOfPage when the article is the primary topic of the article page.
headline
Text; required (AMP), recommended (non-AMP)
The headline of the article. Headlines should not exceed 110 characters.
image
ImageObject; required (AMP), recommended (non-AMP)
The representative image of the article. Only a marked-up image that directly belongs to the article should be specified.
Images should be at least 696 pixels wide.
Images should be in .jpg, .png, or. gif format.
Image URLs should be crawlable and indexable.
image.url
URL; required (AMP), recommended (non-AMP)
The URL of the image.
image.height
Number; required (AMP), recommended (non-AMP)
The height of the image, in pixels.
image.width
Number; required (AMP), recommended (non-AMP)
The width of the image, in pixels. Images should be at least 696 pixels wide.
publisher
Organization; required (AMP), ignored (non-AMP)
The publisher of the article.
publisher.name
Text; required (AMP), ignored (non-AMP)
The name of the publisher.
publisher.logo
ImageObject; required (AMP), ignored (non-AMP)
The logo of the publisher. See the AMP logo guidelines for details.
publisher.logo.url
URL; required (AMP), ignored (non-AMP)
The URL of the logo.
publisher.logo.height
Number; required (AMP), ignored (non-AMP)
The height of the logo, in pixels.
publisher.logo.width
Number; required (AMP), ignored (non-AMP)
The width of the logo, in pixels.
datePublished
DateTime; required (AMP), ignored (non-AMP)
The date and time the article was first published, in ISO 8601 format.
dateModified
DateTime; recommended (AMP), ignored (non-AMP)
The date and time the article was most recently modified, in ISO 8601 format.
author
Person or Organization; required (AMP), ignored (non-AMP)
The author of the article.
author.name
Text; required (AMP), ignored (non-AMP)
The name of the author.
description
Text; recommended (AMP), ignored (non-AMP)
A short description of the article.
*/
}
/// Aus einer Nachricht das Bild extrahieren
///
/// Früher^(tm) waren die Promobilder für die Nachrichten direkt im
/// htmlCode der Nachricht. Diese Funktion extrahiert aus (einem
/// Fragment) htmlCode das enthaltene <img>-Tag.
/// @ToDo: Der Funktion gemäß umbenennen (allgemeiner)
/// @ToDo: Auf eine beliebige Anzahl von <img>Tags erweitern
function newsPromoImage($aNews){
$retImage = array();
preg_match_all("/<img([\w\W]+?)\/>/s", $aNews['nachricht'], $imgMatches);
// echo(" imgMatch: "); print_r($imgMatches);
if(!empty($imgMatches[0])){
preg_match_all("/src=\"([^\"]*)\"/s", $imgMatches[0][0], $srcMatches);
$retImage['src'] = $srcMatches[1];
// echo(" found src in ".$imgMatches[0][0].": "); print_r($srcMatches);
preg_match_all("/alt=\"([^\"]*)\"/s", $imgMatches[0][0], $altMatches);
$retImage['alt'] = $altMatches[1];
// echo(" found alt in ".$imgMatches[0][0].": "); print_r($altMatches);
preg_match_all("/title=\"([^\"]*)\"/s", $imgMatches[0][0], $titleMatches);
$retImage['title'] = $titleMatches[1];
// echo(" found title in ".$imgMatches[0][0].": "); print_r($titleMatches);
}
return $retImage;
}
/// Aus einem Fragment htmlCode die <img>Tags extrahieren
///
/// Früher^(tm) waren die Promobilder für die Nachrichten direkt im
/// htmlCode der Nachricht. Diese Funktion extrahiert aus (einem
/// Fragment) htmlCode die enthaltenen <img>-Tags.
function getHtmlImgTags($someHtmlCode){
$retImages = array();
// Alle <img>Tags matchen
preg_match_all("/<img([\w\W]+?)\/>/s", $someHtmlCode, $imgMatches, PREG_SET_ORDER);
foreach($imgMatches as $imgMatch){
// mehrere src/alt/title-Attribute dürften nicht vorkommen!
// Falls doch: Wir nehmen immer das erste!
$retImage = array();
preg_match_all("/src=\"([^\"]*)\"/s", $imgMatch[0], $srcMatches);
$retImage['src'] = $srcMatches[1][0];
preg_match_all("/alt=\"([^\"]*)\"/s", $imgMatch[0], $altMatches);
$retImage['alt'] = $altMatches[1][0];
preg_match_all("/title=\"([^\"]*)\"/s", $imgMatch[0], $titleMatches);
$retImage['title'] = $titleMatches[1][0];
array_push($retImages, $retImage);
}
return $retImages;
}
/// Aus einer abgefragten News (als Array) ampCode erzeugen
/// Noch ohne Strukturierte Daten
function getAmpNews($anAmpNews){
if(empty($anAmpNews)) return "";
$retAmpCode = "";
// $retAmpCode .= "<article class=\"clearBoth\"itemscope itemtype=\"http://schema.org/NewsArticle\">";
$retAmpCode .= "<article class=\"ampNewsBox\" >";
// $retAmpCode .= "<meta itemprop=\"dateModified\" content=\"".mb_convert_encoding($news['datum'], 'UTF-8', 'ISO-8859-1')."\"/>";
// $retAmpCode .= "<meta itemscope itemprop=\"mainEntityOfPage\" itemType=\"https://schema.org/WebPage\" itemid=\"http://cwsvjudo.bplaced.net/pages/amp/news.php".(empty($newsId?"":"?newsId=".$newsId))."\"/>";
// $retAmpCode .= "<span itemprop=\"publisher\" itemscope itemtype=\"https://schema.org/Organization\"><span itemprop=\"logo\" itemscope itemtype=\"https://schema.org/ImageObject\"><meta itemprop=\"url\" content=\"http://cwsvjudo.bplaced.net/cwsvJudo.png\"><meta itemprop=\"width\" content=\"192\"><meta itemprop=\"height\" content=\"192\"></span><meta itemprop=\"name\" content=\"Abteilung Judo des Chemnitzer WSV\"></span>";
// $retAmpCode .= "<span itemprop=\"image\" itemscope itemtype=\"https://schema.org/ImageObject\"><meta itemprop=\"url\" content=\"http://cwsvjudo.bplaced.net/cwsvJudo.png\" /><meta itemprop=\"width\" content=\"192\" /><meta itemprop=\"height\" content=\"192\" /></span>";
// $retAmpCode .= "<div class=\"newsTable\">";
// $retAmpCode .= "<div class=\"newsTableHeader\">";
$retAmpCode .= "<div class=\"ampNewsBoxHeader\" >";
// $retAmpCode .= "<span><time itemprop=\"datePublished\" datetime=\"".mb_convert_encoding($news['datum'], 'UTF-8', 'ISO-8859-1')."\">".mb_convert_encoding($news['datum'], 'UTF-8', 'ISO-8859-1')."</time></span>";
$retAmpCode .= "<span><time datetime=\"" . $anAmpNews['datum'] . "\" >" . $anAmpNews['datum'] . "</time></span>";
// $retAmpCode .= "<span><h3 itemprop=\"headline\">".mb_convert_encoding($news['betreff'], 'UTF-8', 'ISO-8859-1')."</h3></span>";
/// @ToDo: headingsLevel variabel gestalten
$retAmpCode .= "<span><h3>" . $anAmpNews['betreff'] . "</h3></span>";
$retAmpCode .= "</div>";//Ende ampNewsBoxHeader
// $retAmpCode .= "<div>".ampify( mb_convert_encoding( addImgSize("<div>".$news['nachricht']."</div>"), 'UTF-8', 'ISO-8859-1') )."</div>";
$imgs = getHtmlImgTags( $anAmpNews['nachricht'] );
if(!empty($imgs)){
list($width, $height) = getimagesize( "/users/cwsvjudo/www/".urldecode($imgs[0]['src']));
$retAmpCode .= "<amp-img layout=\"responsive\" title=\"".$imgs[0]['title']."\" alt=\"".$imgs[0]['alt']."\" src=\"".$imgs[0]['src']."\" width=\"".$width."\" height=\"".$height."\"/></amp-img>";
}
// $retAmpCode .= $anAmpNews['nachricht'];
// print_r( $anAmpNews );
// $retAmpCode .= strip_tags( $anAmpNews['nachricht'] );
// $retAmpCode .= preg_replace( '/[\p{Z}\s]{2,}/s', ' ', strip_tags( $anAmpNews['nachricht'] ) );
$retAmpCode .= preg_replace( '/[\p{Z}\s]{2,}/s', ' ', strip_tags( $anAmpNews['nachricht'], '<p><a>' ) );
$retAmpCode .= "<div class=\"ampNewsBoxFooter\">MfG&nbsp;".$anAmpNews['autor']."</span></div>";
$retAmpCode .= "</div>";
$retAmpCode .= "</article>";
return $retAmpCode;
}
///---
/// Hilfsfunktionen
///---
?>

View File

@@ -0,0 +1,33 @@
<?php
require_once("config.inc.php");
require_once("newsLib.php.inc");
require_once( "/users/cwsvjudo/www/bonus/db.inc");
$mysqlConn = @new mysqli($db_server, $db_user, $db_password, $db_name);
if($mysqlConn->connect_error){
die("Datenbankverbindung fehlgeschlagen: " . $mysqlConn->connect_error . "\n");
//$message['error'] += "Datenbankverbindung fehlgeschlagen: " . $mysqlConn->connect_error . "<br />";
}
?>
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>newsTest</title>
</head>
<body>
<?php $news = getNewsById($mysqlConn, "118");?>
<?php //echo("News: "); print_r( getNewsById($mysqlConn, "118") );?>
<?php //echo("Found Img: " ); print_r( newsPromoImage( getNewsById($mysqlConn, "118") ) );?>
<?php echo("PromoImg: " . str_replace( ".png", ".jpg", str_replace( "/thumbs/", "/images/", newsPromoImage( getNewsById($mysqlConn, "118") )['src'][0])) );?>
<?php echo("imgTags: "); print_r(getHtmlImgTags($news['nachricht']));?>
<script type="application/ld+json"><?php echo(news2json( $news ));?></script>
</body>
</html>
<?php
$mysqlConn->close();
exit();
?>

View File

@@ -0,0 +1,54 @@
<?php
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'deu_deu');
//echo "Preferred locale for german on this system is '$loc_de'";
// getting a dbConnection
try{
$dbConnection = new PDO(
'mysql:host=localhost;dbname=cwsvjudo',
'cwsvjudo',
'***REMOVED***'
);
$redirectQuery = $dbConnection->prepare(
"SELECT * FROM cwsvjudo.redirecter ORDER BY id ASC;"
);
$redirectQuery->execute();
$redirectList = $redirectQuery->fetchAll(PDO::FETCH_ASSOC);
}
catch(PDOException $db_error){
die( "Error!: " . $db_error->getMessage() );
}
?>
<html>
<header>
<!--
<style>
.phpcountCounterTables{
display: flex;
flex-basis: 50%;
}
</style>
</header>
-->
<body>
<div>
<table>
<tr><th>id</th><th>REQUEST_URI</th><th>HTTP_USER_AGENT</th></tr>
<?php foreach($redirectList as $redirectEntry){
//var_dump($redirectEntry['jsonServer']);
//var_dump( json_decode($redirectEntry['jsonServer'], true) );
$redirectServerArray = json_decode($redirectEntry['jsonServer'], true);
echo( "\t\t\t\t");
echo( "<tr>");
echo( "<td>".$redirectEntry['id']."</td>" );
echo( "<td>".$redirectServerArray['REQUEST_URI']."</td>" );
echo( "<td>".$redirectServerArray['HTTP_USER_AGENT']."</td>" );
echo( "</tr>\n" );
}
?>
</table>
</div>
</body>
</html>

View File

@@ -0,0 +1,16 @@
.zuordnungs-quiz {
display: block;
display: flex;
flex-basis: 100%;
flex-wrap: wrap;
justify-content: space-between;
}
.zuordnungs-quiz .loesungs-paar {
flex-basis: 0;
}
.zuordnungs-quiz .daten-pool {
display: flex;
justify-content: space-around;
}

View File

@@ -7,4 +7,4 @@ keywords:
- Bilder
- Videos
...
<iframe src=<?php echo("\"".getGalleryLink($_GET['galId'])."\"");?>>Hier sollte jetzt eigentlich die Galerie Nr. <?php echo( $_GET['galId'] );?> zu sehen sein...</iframe>
<?php $basePath = "/users/cwsvjudo/www"; require_once($basePath."/ressourcen/phpLib/cwsvJudo/gallery.lib.php"); var_dump(getGalleryById($_GET['galId']));?>

View File

@@ -20,6 +20,11 @@ einem &bdquo;Schnuppertraining&ldquo; vorbei.
Als Sportkleidung seien reißfeste, lange Sachen möglichst ohne
Reißverschluss empfohlen.
Auch wer bereits Mitglied in einem Judoverein ist, aber zum Beispiel
während des Studiums in Chemnitz wohnt, darf gerne mit uns trainieren.
Eine Ummeldung ist dafür nicht nötig.
## Trainingszeiten
- Mittwoch (Kinder+Jugend)

View File

@@ -0,0 +1,41 @@
<?php
$basePath = "/users/cwsvjudo/www";
require_once($basePath."/config/phpcount.config.php");
require_once($basePath."/config/cwsvJudo.config.php");
require_once($basePath."/ressourcen/phpLib/phpcount/phpcount.php");
require_once($basePath."/ressourcen/phpLib/cwsvJudo/miscAssis.php");
$cwsvJudoDbConnection = getCwsvJudoDbConn();
function getGalleryById( $aGalleryId, $someOptions = array() ){
//var_dump($aGalleryId, $someOptions);
$retGallery = null;
$someOptions['galCharset'] = firstNonEmptyOf([$someOptions['newsCharset'], "UTF-8"]);
$someOptions['dbCharset'] = firstNonEmptyOf([$someOptions['dbCharset'] , "ISO-8859-1"]);
if($someOptions['dbConnection'])
$dbConnection = $someOptions['dbConnection'];
else
$dbConnection = getCwsvJudoDbConn();
try{
$stmt = $dbConnection->prepare(
"SELECT * FROM wkGalerien WHERE id = :galId ;"
);
$stmt->bindParam(':galId', $aGalleryId);
$stmt->execute();
$retGallery = $stmt->fetchAll(PDO::FETCH_ASSOC); // wir fragen einen primary key ab, deshalb kann es nur einer oder keiner sein!
var_dump($ret);
}
catch(PDOException $e){
echo( "Error: " . $e->getMessage() );
}
return $retGallery;
}

View File

@@ -20,6 +20,20 @@ global $cwsvJudoConfig;
return $db_connection;
}
/// Gibt entweder das erste, nichtleere Element zurück, oder null
function firstNonEmptyOf($somePossibleEmptyStuff){
if (is_array($somePossibleEmptyStuff) || $somePossibleEmptyStuff instanceof Traversable){
foreach($somePossibleEmptyStuff as $entry){
if(empty($entry))
continue;
else
return $entry;
}
}
return null;
}
/// Eine als String gegebene Liste kommagetrennter key=value Paare in
/// ein assoziatives Array überführen
function getKeyValueArray($aKeyValueStringList){

View File

@@ -1,10 +1,9 @@
<?php
$basePath = "/users/cwsvjudo/www";
require_once($basePath."/config/phpcount.config.php");
require_once($basePath."/config/cwsvJudo.config.php");
require_once($basePath."/ressourcen/phpLib/phpcount/phpcount.php");
$basePath = "/users/cwsvjudo/www";
require_once($basePath."/config/phpcount.config.php");
require_once($basePath."/config/cwsvJudo.config.php");
require_once($basePath."/ressourcen/phpLib/phpcount/phpcount.php");
function startsWith($haystack, $needle){
$length = strlen($needle);
@@ -139,7 +138,7 @@ return $retVal;
<html lang="de">
<head>
<title><?php echo $wkName?> - Bilderalbum<?php echo( !empty($showAllMode)?($showAllMode == "true" ? " - alle Bilder" : "") : "");?></title>
<?php PHPCount::AddHit($wkName." - Bilderalbum");?>
<?php PHPCount::AddHit($wkName." Bilderalbum");?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="
<?php
@@ -148,11 +147,6 @@ return $retVal;
?>
">
<meta name="keywords" content="Album, Fotos">
<!-- BluimpGallery Zeug -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/ressourcen/blueimpGallery/css/blueimp-gallery.css">
<link rel="stylesheet" href="/ressourcen/blueimpGallery/css/blueimp-gallery-indicator.css">
<link rel="stylesheet" href="/ressourcen/blueimpGallery/css/blueimp-gallery-video.css">
<!-- favIcon und Co nach der empfehlung von https://github.com/audreyr/favicon-cheat-sheet -->
<link rel="shortcut icon" type="image/x-icon" sizes="16x16 32x32 48x48 64x64" href="/ressourcen/graphiken/logos/favicon/favicon.ico">
@@ -164,9 +158,15 @@ return $retVal;
<!--https://github.com/aFarkas/lazysizes-->
<script src="/ressourcen/jsLib/lazysizes.min.js" async=""></script>
<style>
.no-js img.lazyload {
display: none;
}
</style>
<!-- BluimpGallery Zeug -->
<link rel="stylesheet" href="/ressourcen/blueimpGallery/css/blueimp-gallery.min.css">
<script src="/ressourcen/blueimpGallery/js/blueimp-gallery.min.js"></script>
<style>
.smallFont{font-size: small;}
.centerText{text-align: center;}

View File

@@ -1,349 +0,0 @@
<?php
// Daten der Datenbank laden
require_once($_SERVER['DOCUMENT_ROOT']."/bonus/db.inc");
function startsWith($haystack, $needle){
$length = strlen($needle);
return (substr($haystack, 0, $length) === $needle);
}
/// Abfrage der ausgewählten Bilder einer Galerie
function getPickedImages($aMysqlConn, $aGalId){
$retPickedImages = array();
/// Erstmal bisher ausgewählte Bilder abfragen ...
$queryPickedImages = sprintf(
"SELECT * FROM cwsvjudo.galImgPicker WHERE galId = '%s';",
$aMysqlConn->real_escape_string($aGalId)
);
// die($queryPickedImages);
$resultsPickedImages = $aMysqlConn->query($queryPickedImages);
/// @todo Wie kann ich hier sinnvoll einen Fehler zurückliefern? Nullpointer?
if( !$resultsPickedImages ){
$retMessage['error'] .= "Fehler ('".$aMysqlConn->error."') bei Datenbankabfrage '".$queryPickedImages."'<br />";
die( "Fehler ('".$aMysqlConn->error."') bei Datenbankabfrage '".$queryPickedImages."'<br />");
}
else{
while( $pickedImagesResult = $resultsPickedImages->fetch_assoc() ){
$retPickedImages = array_merge($retPickedImages, explode(',', $pickedImagesResult['pickedImages']) );
}
}
//echo("retPickedImages: ");print_r($retPickedImages); die();
return array_unique( $retPickedImages );
}/// Ende getPickedImages
/// Hilfsfunktion zum Anpassen der htmlDescription
function descrName($aName){
$retVal = "Bilder der Judoka des Chemnitzer WSV beim Wettkampf ".$aName;
if( strpos($aName, "Sommerabschlussgrillen") >= 0 ) $retVal = "Bilder der Judoka des Chemnitzer WSV beim ".$aName;
if( strpos($aName, "Jahrendefeier") >= 0 ) $retVal = "Bilder der Judoka des Chemnitzer WSV bei der ".$aName;
return $retVal;
}/// Ende descrName
$loginStatus = "false";
$chooseMode = "false";
$showAllMode = "false";
$messages = array();
$galleryId = "0";
$pickedImages = array();
// echo("imgList: "); print_r($imgList);
// foreach($imgList as $img){
// echo(" ".$img." startsWith images/ :".startsWith($img, "images/")."\n");
// }
/// Übergebene galleryId abfragen
if( !empty($_GET['galId'] ) ) $galleryId = $_GET['galId'];
/// @todo Woher erhalte ich die galleryID, wenn sie nicht übergeben wird?
/// Nachschauen, ob alle Bilder gezeigt werden sollen
if( $_GET['showAll'] == "true" )
$showAllMode = "true";
// Testen, ob wir im Bilderauswahlmodus sind...
if($_GET['chooseMode'] == "true"){
$showAllMode = "true"; // Im Bildauswahlmodus sollten auch alle Bilder angezeigt werden
$chooseMode = "true";
// Falls ja, dann teste, ob man angemeldet ist
/// @todo brauche ich das, wenn ich nur testen will, ob bereits angemeldet ist? -> anscheinend ja!
session_start();
session_regenerate_id();
// Falls der serverseitige Logincookie nicht gesetzt ist
if( empty($_SESSION['login']) ){
$loginStatus = "false";
$messages['info'] .= "Info: Der Bilderauswahlmodus ist nur möglich, wenn man angemeldet ist!<br />";
}
else{
$loginStatus = "true";
/// @todo Testen, ob eine intZahl vorliegt
/// @todo Testen, ob wir in der richtigen Galerie sind
$messages['info'] .= "Info: Der Bilderauswahlmodus für Galerie ".$galleryId." ist aktiv!<br />";
}
}
$mysqlConn = @new mysqli($db_server, $db_user, $db_password, $db_name);
if($mysqlConn->connect_error){
$message['error'] .= "Fehler: Datenbankverbindung fehlgeschlagen: " . $mysqlConn->connect_error . "<br />";
}
else{
$pickedImages = getPickedImages( $mysqlConn, $galleryId );
$mysqlConn->close();
}
/// Überschreiben der imgList mit den ausgewählten Bildern
$allImgList = $imgList; // Sicherungskopie
//echo("imgList:");print_r($imgList);
// echo("pickedImages: "); print_r($pickedImages);
if( count($pickedImages) > 24 )
$pickedImages = array_rand( $pickedImages, 24);
else{
$restImages = array_diff( $allImgList, $pickedImages );
//echo("restImages: "); print_r($restImages);
//echo("count(restImages): ".count($restImages));
//echo("count(24-count($pickedImages)): ".(24-count($pickedImages)));
foreach( array_rand( $restImages, min(24, count($restImages))-count($pickedImages) ) as $k ) {
$pickedImages[] = $restImages[$k];
}
// echo("pickedImages: "); print_r($pickedImages);
}
$imgList = $pickedImages;
// echo("imgList: "); print_r($imgList);
/// @todo ein Sortieren nach dem ursprünglichen Index fehlt
usort($imgList, function($a, $b) use($allImgList){return array_search($a, $allImgList) > array_search($b, $allImgList);} );
$imgList = array_values( $imgList );// Zum reNummerieren
// echo("imgList: "); print_r($imgList);
if( $showAllMode == "true") $imgList = $allImgList;
$imgInfos = array();
foreach( $imgList as $imgName ){
if(startsWith($imgName, "images/")){
array_push( $imgInfos, getimagesize(str_replace("images", "thumbs", str_replace(".jpg", ".png", $imgName))));
}
else{
array_push( $imgInfos, getimagesize("thumbs/".str_replace(".jpg", ".png", $imgName)));
}
}
?>
<!DOCTYPE HTML>
<html lang="de">
<head>
<title><?php echo $wkName?> - Bilderalbum<?php echo( !empty($showAllMode)?($showAllMode == "true" ? " - alle Bilder" : "") : "");?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="
<?php
echo descrName($wkName);
echo( !empty($showAllMode)?($showAllMode == "true" ? " - alle Bilder" : "") : "");
?>
">
<meta name="keywords" content="Album, Fotos">
<!-- BluimpGallery Zeug -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/ressourcen/blueimpGallery/css/blueimp-gallery.css">
<link rel="stylesheet" href="/ressourcen/blueimpGallery/css/blueimp-gallery-indicator.css">
<link rel="stylesheet" href="/ressourcen/blueimpGallery/css/blueimp-gallery-video.css">
<!-- favIcon und Co nach der empfehlung von https://github.com/audreyr/favicon-cheat-sheet -->
<link rel="shortcut icon" type="image/x-icon" sizes="16x16 32x32 48x48 64x64" href="/ressourcen/graphiken/logos/favicon/favicon.ico">
<link rel="apple-touch-icon" sizes="152x152" href="/ressourcen/graphiken/logos/apple-touch-icon/apple-touch-icon-152.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/ressourcen/graphiken/logos/apple-touch-icon/apple-touch-icon-180.png" />
<link rel="manifest" href="/manifest.json">
<link rel="canonical" href="http://cwsvjudo.bplaced.net<?php echo $_SERVER['REQUEST_URI']?>" />
<script type="text/javascript" src="/ressourcen/jsLib/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="/ressourcen/jsLib/jquery.lazyload.min.js"></script>
<style>
.lazy{ display: none;}
.smallFont{font-size: small;}
.centerText{text-align: center;}
.navButton{
box-sizing: border-box;
border-color: white;
border-style: outset;
border-radius: 1em;
text-align: center;
text-decoration: none;
cursor: pointer;
display: inline-block;
padding-left: .5em;
padding-right: .5em;
padding: 0;
margin: 0;
}
</style>
</head>
<body style="color: #000000; background-color: #FFAE00" >
<?php
require_once( $_SERVER['DOCUMENT_ROOT'].'/ressourcen/phpLib/is_mobile.php');
if(is_mobile()) echo "<a title=\"Galerien der Judoka des Chemnitzer WSV\" href=\"/pages/mobile/verein.wettkampfgalerien.php\">Zur Galerieübersicht</a>";
else echo "<a title=\"Galerien der Judoka des Chemnitzer WSV\" href=\"/pages/desktop/verein.galerien.php\">Zur Galerieübersicht</a>";
?>
<?php
/// Eine kleine Messagebox
if( !empty($messages) ){
?>
<div style="border: 1px solid black">
<?php
if( !empty( $messages['info'] ) ) echo( $messages['info'] );
?>
</div>
<?php
}
// echo("pickedImages: "); print_r($pickedImages);
/// Ende MessageBox
?>
<h1 class="centerText" >
Photoalbum [<b><?php echo $wkName?></b>]
</h1>
<?php
if( $showAllMode == "true" ){
?>
<p class="centerText smallFont">
[<?php echo count($imgList)?> Bilder]
</p>
<?php
}
else{
?>
<a href=<?php echo( "\"?galId=".(empty($galleryId)?"0":$galleryId)."&showAll=true".($chooseMode=="true"?"&chooseMode=true":"")."\"");?>><div class="navButton" style="width: 100%;">Alle Bilder einblenden </div></a>
<?php
}
?>
<p class="centerText smallFont">
Auf die jeweiligen Bilder klicken um eine größere Ansicht zu bekommen.
</p>
<hr/>
<style type="text/css">
.galImgList{
/*flex: auto;*/
display: flex;
flex-flow: row wrap;
justify-content: space-around;
align-items: center;
}
</style>
<!-- The container for the list of example images -->
<?php
if( $chooseMode == "true" ){
echo( "<form action=\"http://cwsvjudo.bplaced.net/ressourcen/phpLib/imgGallery/imgPicker.php\" method=\"post\">" );
echo( "<input type=\"hidden\" name=\"galId\" value=\"".$galleryId."\" />" );
}
?>
<div id="links" class="galImgList">
<?php
$imgSize = count( $imgList );
for( $imgIndex = 0; $imgIndex < $imgSize; ++$imgIndex){
echo( "<div ".( ($chooseMode=="true")?"style=\"border: 1px solid black;\"":"" ).">" );
if( $chooseMode == "true" ){
echo("<label>");
echo( "<input type=\"checkbox\" name=\"pickedImages[]\" value=\"".$imgList[$imgIndex]."\" />" );
}
echo "<img class=\"lazy\" ".
"id=\"Image".( $imgIndex )."\" ".
// "data-original=\"./thumbs/".( startsWith( $imgList[$imgIndex], "images/")?str_replace("images/", "", str_replace(".jpg", ".png", $imgName)):str_replace(".jpg", ".png", $imgList[$imgIndex]) )."\" ".
// "data-original=\"./thumbs/".str_replace(".jpg", ".png", $imgList[$imgIndex])."\" ".
"data-original=\"".( startsWith( $imgList[$imgIndex], "images/")?str_replace("images", "thumbs", str_replace(".jpg", ".png", $imgList[$imgIndex])):"./thumbs/".str_replace(".jpg", ".png", $imgList[$imgIndex]) )."\" ".
$imgInfos[$imgIndex][3]." ".
"alt=\"[".( $imgIndex )."/".( $imgSize )."]\" ".
"title=\"".( $wkName )." Bild ".( $imgIndex +1 )." von ".( $imgSize )."\" ".
"onclick=\"startGalleryShow(" . $imgIndex . ");\"".
" />";
echo "<noscript><a href=\"view.php?index=".( $imgIndex )."\" >".
"<img id=\"Image".( $imgIndex + 1)."\" ".
"src=\"".( startsWith( $imgList[$imgIndex], "images/")?str_replace("images", "thumbs", str_replace(".jpg", ".png", $imgList[$imgIndex])):"./thumbs/".str_replace(".jpg", ".png", $imgList[$imgIndex]) )."\" ".
"alt=\"[".( $imgIndex )."/".( $imgSize )."]\" ".
"title=\"".( $wkName )." Bild ".( $imgIndex + 1 )." von ".( $imgSize )."\" ".
"/></a></noscript>";
if( $chooseMode == "true" ) echo( "</label>" );
echo("</div>");
}
?>
</div><!-- Ende galImgList -->
<?php
if( $chooseMode == "true" ){
echo( "<button type=\"submit\">Eingaben absenden</button>" );
echo( "</form>" );
}
?>
</div>
<script type="text/javascript" charset="utf-8">
$(function() {
$("img.lazy").show().lazyload();
// $("img.lazy").lazyload();
});
</script>
<!-- BluimpGalerry Lightbox Version -->
<!-- The Gallery as lightbox dialog, should be a child element of the document body -->
<div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls">
<div class="slides"></div>
<h2 class="title"><?php echo $wkName?></h2>
<a class="prev"></a>
<a class="next"></a>
<a class="close">×</a>
<a class="play-pause"></a>
<ol class="indicator"></ol>
</div>
<script type="text/javascript" src="/ressourcen/blueimpGallery/js/blueimp-gallery.min.js"></script>
<script type="text/javascript" src="/ressourcen/blueimpGallery/js/jquery.blueimp-gallery.min.js"></script>
<script>
function startGalleryShow(startIndex = 0){
var imgList = [
<?php
$imgSize = count( $imgList );
for( $imgIndex = 0; $imgIndex < $imgSize; ++$imgIndex){
echo "\"".( $imgList[ $imgIndex ] )."\", ";
}
?>];
var gallery = blueimp.Gallery(
imgList,
{
onslide: function (index, slide) {
var counterUrl = "/expCounter/counter.php";
var pageUrl = encodeURIComponent( window.location.href ) + "?index=" + index.toString();
var pageTitle = document.title + " [" + index.toString() + "]";
var callUrl = counterUrl + "?jscode_version=1.2&chCounter_mode=js&status=active&visible=0&page_title=" + pageTitle + "&page_url=" + pageUrl;
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", callUrl, true); // true for asynchronous
xmlHttp.send(null);
},
startSlideshow: true,
stretchImages: true,
index: startIndex,
}
);
};
window.onload = function () {
startGalleryShow();
};
// startGalleryShow();
</script>
<hr/>
<!--Beginn der Einbindung des Counters-->
<?php
$chCounter_template = <<<TEMPLATE
<table>
<tr>
<td>Besucher online: {V_VISITORS_CURRENTLY_ONLINE}</td>
<td>Besucher bisher: {V_PAGE_VIEWS_THIS_PAGE}</td>
</tr>
</table>
TEMPLATE;
$chCounter_page_title = "Photoalbum ".$wkName;
$chCounter_visible=1; include( $_SERVER['DOCUMENT_ROOT'].'/expCounter/counter.php');?>
<!--Ende der Einbindung des Counters-->
</body>
</html>