Promoted markdownexperiment to standard homepage

This commit is contained in:
marko
2021-10-21 16:30:00 +02:00
parent bc24589dd0
commit f9c3405754
464 changed files with 9272 additions and 3372 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,58 @@
<?php
include_once("config.inc.php");
$basePath = "/users/cwsvjudo/www";
require_once($basePath."/config/cwsvJudo.config.php");
require_once($basePath."/config/phpcount.config.php");
require_once($basePath."/ressourcen/phpLib/phpcount/phpcount.php");
require_once($basePath."/ressourcen/phpLib/cwsvJudo/miscAssis.php");
$cwsvJudoDbConnection = getCwsvJudoDbConn();
$cwsvJudoDbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$akQuery =
$cwsvJudoDbConnection->prepare(
"SELECT lfdeNr, Datum, Veranstaltung, Altersklassen FROM cwsvjudo.`wettkampfkalender` WHERE DATUM > CURRENT_DATE() ORDER BY Datum ASC, lfdeNr ASC LIMIT 24;"
);
$akQuery->execute();
$wkList = $akQuery->fetchAll(PDO::FETCH_ASSOC);
// Zeichensatzkonvertierung
$someOptions = array();
if( empty($someOptions['dbCharset']) )
$someOptions['dbCharset'] = "ISO-8859-1";
if( empty($someOptions['outCharset']) )
$someOptions['outCharset'] = "UTF-8";
foreach($wkList as &$entry){
array_walk(
$entry,
function (&$value, $key, $someOptions) {
$value = iconv($someOptions['dbCharset'], $someOptions['outCharset'], $value);
},
$someOptions
);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<table>
<?php
foreach($wkList as $wk){
$jg=array();
$jg=akListString2jgArray($wk['Altersklassen'], date('Y', strtotime($wk['Datum'])) );
echo("<tr><td>".$wk['lfdeNr']."</td><td>".$wk['Datum']."</td><td>".$wk['Veranstaltung']."</td><td>".$wk['Altersklassen']."</td><td>".json_encode($jg)."</td></tr>");
}
?>
</table>
</body>
</html>

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

@@ -0,0 +1,34 @@
<?php
$basePath = "/users/cwsvjudo/www";
require_once($basePath."/ressourcen/phpLib/parsedown/Parsedown.php");
require_once($basePath."/ressourcen/phpLib/parsedown-extra/ParsedownExtra.php");
$fileList = glob($basePath."/admin/mdDisplayer/*.md");
rsort($fileList);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>mdDisplayer</title>
<meta name="description" content="mdDisplayer">
</head>
<body>
<?php
echo("<ul>");
foreach($fileList as $file){
echo("<li><a href=\"#".$file."\">".mb_convert_encoding( basename($file), "UTF-8", "ISO-8859-1" )."</a></li>");
}
echo("</ul>");
foreach($fileList as $file){
echo("<hr /><a name=\"".$file."\"></a>");
echo("<div class=\"infoZettel\">" . ParsedownExtra::instance()->text( file_get_contents($file) ) . "</div><hr />");
}
?>
</body>
</html>

View File

@@ -0,0 +1,256 @@
<?php
// Laden von Konfigurationsdaten
require_once("config.inc.php");
// require_once($basePath."/bonus/db.inc");
require_once($basePath."/config/cwsvJudo.config.php");
require_once($basePath."/ressourcen/phpLib/cwsvJudo/newsLib.php");
require_once($basePath."/ressourcen/phpLib/cwsvJudo/miscAssis.php");
require_once($basePath."/ressourcen/phpLib/parsedown/Parsedown.php");
// benötigt parsedown
function submitNewsToDb($aNews, $someOptions = array()){
// Standardargumente setzen
$someOptions['tableName'] = firstNonEmptyOf([$someOptions['tableName'], "cwsvjudo.nachrichtenDev"]);
$someOptions['newsCharset'] = firstNonEmptyOf([$someOptions['newsCharset'], "UTF-8"]);
$someOptions['dbCharset'] = firstNonEmptyOf([$someOptions['dbCharset'], "ISO-8859-1"]);
//@toDo: $aNews auf Validität testen
if($someOptions['dbConnection'])
$dbConnection = $someOptions['dbConnection'];
else{
try{
$dbConnection =
new PDO(
"mysql:host=".$someOptions['dbConfig']['host'].";dbname=".$someOptions['dbConfig']['name'],
$someOptions['dbConfig']['user'],
$someOptions['dbConfig']['password']
);
// set the PDO error mode to exception
// Warum weiß ich nicht mehr
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e){
echo( "Error: " . $e->getMessage() );
}
}
try{
// prepare sql and bind parameters
$stmt = $dbConnection->prepare(
"INSERT INTO ".$someOptions['tableName']." (datum, betreff, nachricht, autor, promoImg) VALUES (:datum, :betreff, :nachricht, :autor, :promoImg)"
);
$stmt->bindParam(':datum', $aNews['datum']);
$stmt->bindParam(':betreff', iconv($someOptions['newsCharset'], $someOptions['dbCharset'], $aNews['betreff']));
$stmt->bindParam(':nachricht', iconv($someOptions['newsCharset'], $someOptions['dbCharset'], Parsedown::instance()->text( $aNews['text'] )));
$stmt->bindParam(':autor', iconv($someOptions['newsCharset'], $someOptions['dbCharset'], $aNews['autor']));
$stmt->bindParam(':promoImg', json_encode( $aNews['promoImg'] ) );
// insert a row
$stmt->execute();
echo "New records created successfully";
}
catch(PDOException $e){
echo( "Error: " . $e->getMessage() );
}
return;
}
$defaultPromoImg['src'] = "http://cwsvjudo.bplaced.net/ressourcen/graphiken/logos/cwsvJudoLogoWappen.x256.png";
$defaultPromoImg['width'] = "207";
$defaultPromoImg['height'] = "256";
$defaultPromoImg['alt'] = "cwsvJudo";
/// Auslesen des Newsarrays
if( empty($_POST['nachrichtenPromoImg']) )
$newsArticle['promoImg'] = $defaultPromoImg;
else{
$newsArticle['promoImg']['src'] = $_POST['nachrichtenPromoImg']['src'];
$newsArticle['promoImg']['width'] = $_POST['nachrichtenPromoImg']['width'];
$newsArticle['promoImg']['height'] = $_POST['nachrichtenPromoImg']['heigth'];
if( !is_positive_integer($newsArticle['promoImg']['width']) || !is_positive_integer($newsArticle['promoImg']['height']) ){
$newsArticle['promoImg']['path'] = $basePath.urldecode(parse_url( $newsArticle['promoImg']['src'] )['path']);
if(file_exists( $newsArticle['promoImg']['path'] ) ){
list(
$newsArticle['promoImg']['width'],
$newsArticle['promoImg']['height']
) = array_slice( getimagesize( $newsArticle['promoImg']['path'] ), 0, 2);
}
else{
// @todo: Wirklich nötig? Es könnte ja auch auf einem anderen Server liegen...
// $newsArticle['promoImg'] = null;
}
}
}
// @todo Validierung!
$newsArticle['datum'] = !empty($_POST['nachrichtenDatum']) ? $_POST['nachrichtenDatum'] : strftime ( "%F" );
$newsArticle['betreff'] = !empty($_POST['nachrichtenBetreff']) ? $_POST['nachrichtenBetreff'] : "Kein Betreff!";
if(empty($newsArticle['promoImg']['alt'])) $newsArticle['promoImg']['alt'] = $newsArticle['betreff']." (Promobildchen)";
$newsArticle['text'] = !empty($_POST['nachrichtenText']) ? $_POST['nachrichtenText'] : "Kein Text!";
$newsArticle['autor'] = !empty($_POST['nachrichtenAutor']) ? $_POST['nachrichtenAutor'] : "Kein Autor!";
if( !empty($_POST['action']) ){
if( $_POST['action'] == "submitToDb" ){
submitNewsToDb( $newsArticle, ['dbConfig' => $cwsvJudoConfig['db']] );
$dbConnection = null;
}
}
?>
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nachrichtenadministration</title>
<style>
body{
background-color: #FF8100;
}
.noDisplay{
display: none;
}
.fullWidth{
width: 100%;
}
.newsPromoImage{
float: left;
}
.newsFooter{
clear: both;
}
.newsSubmitForm{
width=100%;
}
.newsPreviewForm textarea{
width: 100%;
}
</style>
<link rel="stylesheet" href="http://cwsvjudo.bplaced.net/pages/desktop2018/cwsvJudo-2018-news.css">
</head>
<body>
<?php echo(getHtmlNews(array(
'datum' => $newsArticle['datum'],
'betreff' => $newsArticle['betreff'],
'promoImg' => $newsArticle['promoImg'],
'nachricht' => Parsedown::instance()->text($newsArticle['text']),
'autor' => $newsArticle['autor']
)));?>
<hr />
<form class="newsSubmitForm" action="newsAdmin.php" method="post" id="nachricht">
<input
id="nachrichtenDatum"
name="nachrichtenDatum"
type="hidden"
value="<?php echo($newsArticle['datum']);?>"
/>
<textarea class="noDisplay"
id="nachrichtenBetreff"
name="nachrichtenBetreff"
><?php echo( htmlentities($newsArticle['betreff']) );?></textarea>
<input
id="nachrichtenPromoImg[src]"
name="nachrichtenPromoImg[src]"
type="hidden"
value="<?php echo($newsArticle['promoImg']['src']);?>"
/>
<input
id="nachrichtenPromoImg[width]"
name="nachrichtenPromoImg[width]"
type="hidden"
value="<?php echo($newsArticle['promoImg']['width']);?>"
/>
<input
id="nachrichtenPromoImg[height]"
name="nachrichtenPromoImg[height]"
type="hidden"
value="<?php echo($newsArticle['promoImg']['height']);?>"
/>
<textarea class="noDisplay"
id="nachrichtenText"
name="nachrichtenText"
><?php echo( htmlentities($newsArticle['text']));//textarea ersetzt selbständig htmlEnt, ohne dass man es verhindern kann?></textarea>
<input
id="nachrichtenAutor"
name="nachrichtenAutor"
type="hidden"
value="<?php echo($newsArticle['autor']);?>"
/>
<input
id="action"
name="action"
type="hidden"
value="submitToDb"
/>
<div>
<button type="submit">In Datenbank eintragen</button>
</div>
</form>
<hr />
<form class="newsPreviewForm" action="newsAdmin.php" method="post" id="nachricht">
<label for="nachricht">Nachricht</label>
<div>
<label for="nachrichtenDatum">Nachrichtendatum</label>
<input id="nachrichtenDatum" name="nachrichtenDatum" type="text" value="<?php echo( $newsArticle['datum'] );?>" />
</div>
<div>
<label for="nachrichtenBetreff">Nachrichtenbetreff</label>
<!--Achtung: Textarea nimmt alle Zeilenumbrüche, Tabulatoren etc. mit! Also keine Quellcodeformatierung mit Einschüben. -->
<textarea id="nachrichtenBetreff" name="nachrichtenBetreff" rows="1" ><?php echo( htmlentities($newsArticle['betreff']) );?></textarea>
</div>
<div>
<label for="nachrichtenPromoImg[src]">SrcUrl des Nachrichtenbildes</label>
<input id="nachrichtenPromoImg[src]" name="nachrichtenPromoImg[src]" type="text" value="<?php echo( empty($newsArticle['promoImg']['src'])?"":$newsArticle['promoImg']['src'] );?>"/>
<label for="nachrichtenPromoImg[width]">width des Nachrichtenbildes</label>
<input id="nachrichtenPromoImg[width]" name="nachrichtenPromoImg[width]" type="text" value="<?php echo( empty($newsArticle['promoImg']['width'])?"":$newsArticle['promoImg']['width'] );?>"/>
<label for="nachrichtenPromoImg[height]">height des Nachrichtenbildes</label>
<input id="nachrichtenPromoImg[height]" name="nachrichtenPromoImg[height]" type="text" value="<?php echo( empty($newsArticle['promoImg']['height'])?"":$newsArticle['promoImg']['height'] );?>"/>
</div>
<div>
<label for="nachrichtenText">Nachrichtentext</label>
<textarea id="nachrichtenText" name="nachrichtenText" rows="12" ><?php echo( htmlentities($newsArticle['text']) );//textarea ersetzt selbständig htmlEnt, ohne dass man es verhindern kann?></textarea>
</div>
<div>
<label for="nachrichtenAutor">Nachrichtenautor</label>
<input id="nachrichtenAutor" name="nachrichtenAutor" type="text" value="<?php echo( $newsArticle['autor'] );?>" />
</div>
<div>
<button type="reset">Eingaben zurücksetzen</button>
<button type="submit">Vorschau</button>
</div>
</form>
<?php
try{
$dbConnection = new PDO('mysql:host='.$cwsvJudoConfig['db']['host'].';dbname='.$cwsvJudoConfig['db']['name'], $cwsvJudoConfig['db']['user'], $cwsvJudoConfig['db']['password']);
// set the PDO error mode to exception
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$newsList = getNews($dbConnection, array('limit'=>6));
}
catch(PDOException $e){
echo "Error: " . $e->getMessage();
}
$dbConnection = null;
if(!empty($newsList))
foreach( $newsList as $news)
echo("<hr />".getHtmlNews($news));
else echo("Keine Nachrichten gefunden!")
?>
<div>
</body>
</html>

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,78 @@
<?php
$basePath = "/users/cwsvjudo/www";
require_once($basePath."/config/cwsvJudo.config.php");
require_once($basePath."/ressourcen/phpLib/phplot/phplot.php");
require_once($basePath."/ressourcen/phpLib/phplot/rgb.inc.php");
try{
$dbConnection = new PDO(
'mysql:host='.$cwsvJudoConfig["db"]["host"].';dbname='.$cwsvJudoConfig["db"]["name"],
$cwsvJudoConfig["db"]["user"],
$cwsvJudoConfig["db"]["password"]
);
$dailyHitsQuery = $dbConnection->prepare(
"SELECT COUNT(*) AS anz, DATE(timeStamp) as date FROM `phpcount_pageHits` GROUP BY date ORDER BY date DESC;"
);
$dailyHitsQuery->execute();
$dailyHitsList = $dailyHitsQuery->fetchAll(PDO::FETCH_ASSOC);
$whereClauses=array();
if($_GET['userHash'])
$whereClauses[]="userHash='".$_GET['userHash']."'";
if($_GET['date'])
$whereClauses[]="DATE(timestamp)='".$_GET['date']."'";
if($_GET['pageId'])
$whereClauses[]="pageId='".urldecode($_GET['pageId'])."'";
$whereClause = join(" AND ", $whereClauses);
$pagehitsQuery = $dbConnection->prepare(
"SELECT DATE(timeStamp) as date, TIME(timestamp) as time, pageId, userHash, userAgentString FROM `phpcount_pageHits` ".
($whereClause?"WHERE ".$whereClause." ":"").
"ORDER BY timeStamp DESC;"
);
$pagehitsQuery->execute();
$pagehitsList = $pagehitsQuery->fetchAll(PDO::FETCH_ASSOC);
// var_dump($_GET);
if($_GET['action']=="deleteHitter"){
//var_dump($_GET['action']);
$deleteHitterQuery = $dbConnection->prepare(
"DELETE FROM `phpcount_pageHits` WHERE userHash=:userHash;"
);
$deleteHitterQuery->bindParam(':userHash', $_GET['userHash']);
if($deleteHitterQuery->execute());
else echo("FEHLER\n");
}
}
catch(PDOException $db_error){
die( "Error!: " . $db_error->getMessage() );
}
//var_dump($dailyHitsList);
?>
<html>
<body>
<img src="visitorCount.phplot.php" />
<a href="?">RESET</a>
<?php if(isset($_GET['userHash']))?><form action="./phpcountLog.php"><input type="hidden" name="userHash" id="userHash" value="<?php echo($_GET['userHash']);?>"><input type="hidden" name="action" id="action" value="deleteHitter"><button type="submit">DeleteHitter</button></form>
<table>
<tr><th><?php echo( join( "</th><th>", array_column($dailyHitsList, 'date') ) );?></th></tr>
<tr><td><?php echo( join( "</td><td>", array_column($dailyHitsList, 'anz') ) );?></td></tr>
</table>
<hr />
<table>
<tr><th>date</th><th>time</th><th>pageId</th><th>userHash</th><th>userAgentString</th></tr>
<?php foreach($pagehitsList as $pagehitsEntry)
echo( "\t\t\t\t<tr>".
"<td><a href=\"?date=".$pagehitsEntry['date']."\">".$pagehitsEntry['date']."</a></td>".
"<td>".$pagehitsEntry['time']."</td>".
"<td><a href=\"?pageId=".urlencode( $pagehitsEntry['pageId'] )."\">".urldecode($pagehitsEntry['pageId'])."</a></td>".
"<td><a href=\"?userHash=".$pagehitsEntry['userHash']."\">".substr($pagehitsEntry['userHash'], 0, 5)."...</a><td>" ).
"<td>".$pagehitsEntry['userAgentString']."</a><td></tr>";
?>
</table>
</body>
</html>

View File

@@ -0,0 +1,32 @@
<?php
$basePath = "/users/cwsvjudo/www";
require_once($basePath."/config/cwsvJudo.config.php");
require_once($basePath."/ressourcen/phpLib/phplot/phplot.php");
require_once($basePath."/ressourcen/phpLib/phplot/rgb.inc.php");
// getting a dbConnection
try{
$dbConnection = new PDO(
'mysql:host='.$cwsvJudoConfig["db"]["host"].';dbname='.$cwsvJudoConfig["db"]["name"],
$cwsvJudoConfig["db"]["user"],
$cwsvJudoConfig["db"]["password"]
);
$nodupesQuery = $dbConnection->prepare(
"SELECT COUNT(*) AS anz, DATE(FROM_UNIXTIME( time )) as date FROM `phpcount_nodupes` GROUP BY date ORDER BY date DESC"
);
$nodupesQuery->execute();
$nodupesList = $nodupesQuery->fetchAll(PDO::FETCH_ASSOC);
}
catch(PDOException $db_error){
die( "Error!: " . $db_error->getMessage() );
}
$plot = new PHPlot();
$data = array();
foreach($nodupesList as $nodupesEntry)
$data[] = array( $nodupesEntry['date'], $nodupesEntry['anz'] );
$plot->SetDataValues($data);
$plot->DrawGraph();

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>