From f28fa7b51b394f489f39b5e22c312b1c04b1f5be Mon Sep 17 00:00:00 2001 From: marko Date: Fri, 7 Nov 2025 10:37:25 +0100 Subject: [PATCH] WIP: bring participo back - consistent use of bootstrap - formatting - phpstan level 0 error free - fixes for kyu subpage - move mams into participo framework - remove legacy `lib/db.php` usage - add attributer admin function - add newsposter - fixing apiKey creation --- homepage/cwsvJudo/.aiignore | 13 + homepage/cwsvJudo/.gitignore | 7 + homepage/cwsvJudo/Makefile.heliohost | 61 +- homepage/cwsvJudo/PHP.dockerfile | 4 + .../cwsvJudo/configs/heliohost/config.json | 5 +- .../configs/heliohost/participo/config.php | 5 + .../cwsvJudo/configs/localDocker/config.json | 27 +- .../localDocker/config/cwsvJudo.config.php | 8 + .../configs/localDocker/pages.config.inc.php | 5 +- .../configs/localDocker/participo/config.php | 5 + .../participo/config/participo.php | 20 + .../localDocker/participo/local/cwsvJudo.php | 8 + .../localDocker/participo/local/dbConf.php | 6 + homepage/cwsvJudo/docker-compose.yaml | 9 +- .../cwsvJudo/pandocTemplate/amp-template.html | 196 --- .../cwsvJudo.amp.pandocTemplate | 258 ---- .../cwsvJudo.html5.pandocTemplate | 276 ---- .../pandocTemplate/html5.pandocTemplate | 71 - .../materialize-fromScratch.html | 191 --- .../materialize-parallax.pandocTemplate | 137 -- homepage/cwsvJudo/participo | 1 + homepage/cwsvJudo/phpLib/.htaccess | 125 ++ .../cwsvJudo/phpLib/cwsvJudo/miscAssis.php | 366 ++--- homepage/cwsvJudo/phpLib/cwsvJudo/newsLib.php | 475 ++++--- homepage/cwsvJudo/phpmyadmin.yaml | 16 + homepage/cwsvJudo/phpstan | 3 + homepage/cwsvJudo/phpstan.bootstrap.php | 7 + homepage/cwsvJudo/phpstan.neon | 11 + homepage/cwsvJudo/podman-clean | 9 + homepage/cwsvJudo/scripts/upload-heliohost | 7 +- .../src/pages/responsive/bootstrap.php | 4 +- homepage/mams/.htaccess | 6 - homepage/mams/index.php | 112 -- homepage/mams/lib/.htaccess | 1 - homepage/mams/lib/api.php | 152 -- homepage/mams/lib/db.php | 190 --- homepage/mams/lib/mams/materializeInit.php | 15 - homepage/mams/local/.htaccess | 1 - homepage/mams/local/cwsvJudo.config.php | 6 - homepage/participo/.gitignore | 8 + homepage/participo/addEvent.php | 172 +++ homepage/participo/admin.inc.php | 34 +- homepage/participo/admin.php | 77 +- homepage/participo/admin.sidenav.inc.php | 10 +- homepage/participo/api.apiKeys.add.php | 57 +- homepage/participo/api.starter.add.php | 31 +- homepage/participo/api.starter.remove.php | 27 +- homepage/participo/api.user.add.php | 34 +- homepage/participo/api/bootstrap.php | 52 + homepage/participo/api/inc/bootstrap.php | 31 +- homepage/participo/api/shiai.php | 95 +- homepage/participo/api/trainees.php | 6 +- homepage/participo/api/users.php | 19 +- homepage/participo/apiKeyTest.php | 29 +- homepage/participo/attendance.php | 497 ++++--- homepage/participo/attributer.php | 300 ++++ homepage/participo/bootstrap.php | 31 + homepage/participo/config/participo.php | 12 - homepage/participo/css/material-icons.css | 53 +- homepage/participo/event.php | 29 +- homepage/participo/events.inc.php | 34 +- homepage/participo/events.php | 26 +- homepage/participo/events.sidenav.inc.php | 12 +- homepage/participo/index.inc.php | 37 +- homepage/participo/index.php | 226 ++- homepage/participo/infoZettel.php | 106 +- homepage/participo/init-venv | 6 + homepage/participo/kyu.php | 322 +++-- homepage/participo/lib/api.php | 252 ++-- homepage/participo/lib/db.php | 411 ------ .../participo/lib/participoLib/apiKey.php | 381 +++--- .../participo/lib/participoLib/attendance.php | 230 ++++ .../lib/participoLib/dbConnector.php | 280 ++-- homepage/participo/lib/participoLib/event.php | 809 ++++++----- .../participo/lib/participoLib/eventPage.php | 14 +- .../participo/lib/participoLib/participo.php | 1219 +++++++++-------- .../participo/lib/participoLib/planer.php | 247 ++-- homepage/participo/lib/participoLib/ride.php | 321 +++-- homepage/participo/lib/participoLib/shiai.php | 29 +- .../participo/lib/participoLib/starter.php | 932 +++++++------ homepage/participo/lib/participoLib/user.php | 809 ++++++----- homepage/participo/local/achievementsConf.php | 10 +- homepage/participo/login.php | 90 +- homepage/participo/logout.php | 32 +- homepage/participo/mams.js | 28 + homepage/participo/mams.php | 135 ++ .../mams.sidenav.php} | 0 homepage/participo/newnews.php | 316 +++++ homepage/participo/pmelo.inc.php | 216 +-- homepage/participo/pmelo.php | 12 +- homepage/participo/shared/imports.php | 4 +- homepage/participo/shared/sidenav.inc.php | 14 +- homepage/participo/user.php | 112 +- homepage/participo/wk.api.php | 32 +- submodules/wkOrg | 2 +- training/partnerübungen.md~ | 76 - 96 files changed, 6152 insertions(+), 6053 deletions(-) create mode 100644 homepage/cwsvJudo/.aiignore create mode 100644 homepage/cwsvJudo/configs/heliohost/participo/config.php create mode 100644 homepage/cwsvJudo/configs/localDocker/config/cwsvJudo.config.php create mode 100644 homepage/cwsvJudo/configs/localDocker/participo/config.php create mode 100644 homepage/cwsvJudo/configs/localDocker/participo/config/participo.php create mode 100644 homepage/cwsvJudo/configs/localDocker/participo/local/cwsvJudo.php create mode 100644 homepage/cwsvJudo/configs/localDocker/participo/local/dbConf.php delete mode 100644 homepage/cwsvJudo/pandocTemplate/amp-template.html delete mode 100644 homepage/cwsvJudo/pandocTemplate/cwsvJudo.amp.pandocTemplate delete mode 100644 homepage/cwsvJudo/pandocTemplate/cwsvJudo.html5.pandocTemplate delete mode 100644 homepage/cwsvJudo/pandocTemplate/html5.pandocTemplate delete mode 100644 homepage/cwsvJudo/pandocTemplate/materialize-fromScratch.html delete mode 100644 homepage/cwsvJudo/pandocTemplate/materialize-parallax.pandocTemplate create mode 120000 homepage/cwsvJudo/participo create mode 100644 homepage/cwsvJudo/phpLib/.htaccess create mode 100644 homepage/cwsvJudo/phpmyadmin.yaml create mode 100644 homepage/cwsvJudo/phpstan create mode 100644 homepage/cwsvJudo/phpstan.bootstrap.php create mode 100644 homepage/cwsvJudo/phpstan.neon create mode 100644 homepage/cwsvJudo/podman-clean delete mode 100644 homepage/mams/.htaccess delete mode 100644 homepage/mams/index.php delete mode 100644 homepage/mams/lib/.htaccess delete mode 100644 homepage/mams/lib/api.php delete mode 100644 homepage/mams/lib/db.php delete mode 100644 homepage/mams/lib/mams/materializeInit.php delete mode 100644 homepage/mams/local/.htaccess delete mode 100644 homepage/mams/local/cwsvJudo.config.php create mode 100644 homepage/participo/addEvent.php create mode 100644 homepage/participo/api/bootstrap.php create mode 100644 homepage/participo/attributer.php create mode 100644 homepage/participo/bootstrap.php delete mode 100644 homepage/participo/config/participo.php create mode 100755 homepage/participo/init-venv delete mode 100644 homepage/participo/lib/db.php create mode 100644 homepage/participo/lib/participoLib/attendance.php create mode 100644 homepage/participo/mams.js create mode 100644 homepage/participo/mams.php rename homepage/{mams/lib/mams/sidenav.php => participo/mams.sidenav.php} (100%) create mode 100644 homepage/participo/newnews.php delete mode 100644 training/partnerübungen.md~ diff --git a/homepage/cwsvJudo/.aiignore b/homepage/cwsvJudo/.aiignore new file mode 100644 index 0000000..fac7b93 --- /dev/null +++ b/homepage/cwsvJudo/.aiignore @@ -0,0 +1,13 @@ +# This file contains rules for the AI assistant to ignore files and patterns in this project. + +# Ignore all files matching the glob pattern *.local +*.local + +# Ignore the build folder +build/ + +# Ignore all files containing the string 'password' +*password* + +# Ignore all files with a 'credentials' in the name +*credentials* diff --git a/homepage/cwsvJudo/.gitignore b/homepage/cwsvJudo/.gitignore index d80be2e..698ac30 100644 --- a/homepage/cwsvJudo/.gitignore +++ b/homepage/cwsvJudo/.gitignore @@ -1,6 +1,8 @@ build/* temp/* +participo/.venv + scripts/* !scripts/*.template @@ -10,3 +12,8 @@ node_modules Makefile.local db_root_password.txt db_password.txt + + +# temporary +# @todo include content and adjusted theming from JudoWiki +src/JudoWiki diff --git a/homepage/cwsvJudo/Makefile.heliohost b/homepage/cwsvJudo/Makefile.heliohost index 8d59df5..a962644 100644 --- a/homepage/cwsvJudo/Makefile.heliohost +++ b/homepage/cwsvJudo/Makefile.heliohost @@ -14,9 +14,14 @@ configFiles = $(wildcard config/*.php) LN = ln -f + +participoSource = ./participo +participoTarget = $(distWebRoot)/participo + + .PHONY: all all: build/css/cwsvJudo.css images -# @todo This should only be temporary. Better outsource the graphics to it's own Makefile. +# @todo This should only be temporary. Better outsource the graphics to their own Makefile. make -j graphiken make build/css/cwsvJudo.css @@ -66,6 +71,10 @@ installDependencies: tar xf submodules/parsedown/$(VERSION_PARSEDOWN).tar.gz --directory submodules/parsedown # - php-markdown (alternative markdown parser) if [ ! -d "submodules/php-markdown" ]; then cd submodules; git clone https://github.com/michelf/php-markdown.git; fi + cd submodules/php-markdown; git checkout lib; git pull; +# - spyc (yaml parser in php) + if [ ! -d "submodules/spyc" ]; then cd submodules; git clone https://github.com/mustangostang/spyc.git; fi + cd submodules/spyc; git checkout master; git pull; # copy/link all together to get a "distributable" package @@ -126,11 +135,18 @@ dist: all # - api mkdir -p $(distDir)/ # - parsedown +# @todo Legacy location! Remove! Either completely switch to php-markdown (Michelf) or at least but it in a common phpLib directory. mkdir -p $(distWebRoot)/pages/responsive/phpLibs/parsedown $(LN) submodules/parsedown/parsedown-$(VERSION_PARSEDOWN)/Parsedown.php $(distWebRoot)/pages/responsive/phpLibs/parsedown +# Current location: + mkdir -p $(distDir)/libs/php/parsedown + $(LN) submodules/parsedown/parsedown-$(VERSION_PARSEDOWN)/Parsedown.php $(distDir)/libs/php/parsedown/ # - php-markdown mkdir -p $(distWebRoot)/pages/responsive/phpLibs/php-markdown/Michelf find submodules/php-markdown/Michelf -type f -exec $(LN) {} $(distWebRoot)/pages/responsive/phpLibs/php-markdown/Michelf \; +# - spyc + mkdir -p $(distDir)/libs/php/spyc + $(LN) submodules/spyc/Spyc.php $(distDir)/libs/php/spyc/ # graphics mkdir -p $(distWebRoot)/ressourcen/graphiken/logos/favIcons @@ -170,23 +186,44 @@ dist: all find ./res/fonts -type f -exec $(LN) {} $(distDir)/httpdocs/ressourcen/fonts \; find ./submodules/material-design-icons/material-design-icons-$(GOOGLE_MATERIAL_ICONS_VERSION)/font/ -type f -exec $(LN) {} $(distDir)/httpdocs/ressourcen/fonts \; -# htaccess - $(LN) ./src/htaccess/heliohost/.htaccess $(distDir)/httpdocs/.htaccess - $(LN) ./src/htaccess/heliohost/pages/responsive/.htaccess $(distDir)/httpdocs/pages/responsive/.htaccess - -# config files - $(LN) ./configs/localDocker/pages.config.inc.php $(distDir)/httpdocs/pages/responsive/config.php - - mkdir -p $(distDir)/.local - $(LN) configs/heliohost/config.json $(distDir)/.local/config.json - $(LN) configs/heliohost/secrets.json $(distDir)/.local/secrets.json - # sitemap $(LN) ./sitemaps/cwsvjudo-de.xml $(distWebRoot)/sitemap.xml # @todo shouldn't be used any more $(LN) configs/local/db.config.php $(distDir)/.local/db.config.php +# participo + + mkdir -p $(participoTarget) + for dir in api api/inc config css images lib lib/participoLib local shared sidenav; do mkdir $(participoTarget)/$$dir; done; + $(LN) $(participoSource)/.htaccess $(participoTarget) + $(LN) $(participoSource)/api/*.php $(participoTarget)/api/ + $(LN) $(participoSource)/api/inc/*.php $(participoTarget)/api/inc + $(LN) $(participoSource)/*.php $(participoTarget) + $(LN) $(participoSource)/*.js $(participoTarget) + $(LN) $(participoSource)/css/*.css $(participoTarget)/css/ + $(LN) $(participoSource)/images/*.svg $(participoTarget)/images/ + for dir in lib lib/participoLib shared sidenav; do $(LN) $(participoSource)/$$dir/*.php $(participoTarget)/$$dir; done; + # @todo Make bash call work in Makefile + # ./scripts/deep-directory-linking $(participoSource)/markdown $(participoTarget)/markdown + cp -r $(participoSource)/markdown/ $(participoTarget)/ + # @todo check why a linked file isn't validating as php function `is_file` proberly. + cp -r $(participoSource)/videos/ $(participoTarget)/ + + # htaccess + $(LN) ./src/htaccess/heliohost/.htaccess $(distDir)/httpdocs/.htaccess + $(LN) ./src/htaccess/heliohost/pages/responsive/.htaccess $(distDir)/httpdocs/pages/responsive/.htaccess + +# config files +# - server specific configs +# - participo + $(LN) ./configs/localDocker/participo/config.php $(participoTarget)/ + $(LN) ./configs/localDocker/participo/api/config.php $(participoTarget)/api +# - common configs + mkdir -p $(distDir)/.local + $(LN) configs/localDocker/*.json $(distDir)/.local/ +# - pages + $(LN) ./configs/localDocker/pages.config.inc.php $(distWebRoot)/pages/responsive/config.php docker-compose restart diff --git a/homepage/cwsvJudo/PHP.dockerfile b/homepage/cwsvJudo/PHP.dockerfile index fed6cd6..2bfff58 100644 --- a/homepage/cwsvJudo/PHP.dockerfile +++ b/homepage/cwsvJudo/PHP.dockerfile @@ -17,3 +17,7 @@ RUN apt-get -y update \ RUN pecl install xdebug && docker-php-ext-enable xdebug RUN ln /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/ + +# add phpstan +# @todo Check again if phpstan could be included in the dist dockerfile. +# COPY --from=ghcr.io/phpstan/phpstan:latest-php8.3 /composer/vendor/phpstan/phpstan/phpstan.phar /app/phpstan.phar diff --git a/homepage/cwsvJudo/configs/heliohost/config.json b/homepage/cwsvJudo/configs/heliohost/config.json index 80a2a54..1c932f1 100644 --- a/homepage/cwsvJudo/configs/heliohost/config.json +++ b/homepage/cwsvJudo/configs/heliohost/config.json @@ -1,5 +1,8 @@ { "cwsvJudo": { + "http": { + "serve_dir": "httpdocs" + }, "db": { "host": "localhost", "name": "cwsvjudo_main", @@ -11,4 +14,4 @@ "wallpapers": "/ressourcen/graphiken/wallpapers" } } -} \ No newline at end of file +} diff --git a/homepage/cwsvJudo/configs/heliohost/participo/config.php b/homepage/cwsvJudo/configs/heliohost/participo/config.php new file mode 100644 index 0000000..1361589 --- /dev/null +++ b/homepage/cwsvJudo/configs/heliohost/participo/config.php @@ -0,0 +1,5 @@ + diff --git a/homepage/cwsvJudo/configs/localDocker/pages.config.inc.php b/homepage/cwsvJudo/configs/localDocker/pages.config.inc.php index 631af40..1ea638e 100644 --- a/homepage/cwsvJudo/configs/localDocker/pages.config.inc.php +++ b/homepage/cwsvJudo/configs/localDocker/pages.config.inc.php @@ -4,11 +4,12 @@ $baseDomain = "localhost"; /// Subdomain, unter dem dieses Verzeichnis zu finden ist (falls der Fall gegeben ist) $subDomain = ""; /// homeverzeichnis auf dem server -$home = "/home/cwsvjudo.de"; +$home = "/var/www"; +$serve_dir = "html"; /// Basis(/Root)-Verzeichnis auf dem Server (für Dateizugriffe, insbesondere phpIncludes) /// (ist eigentlich das serve verzeichnis, aka www-data) -$basePath = "/var/www/html"; +$basePath = join("/", [$home, $serve_dir]); /// Url zum Zugriff auf "shared Data" unter der Hauptadresse $baseUrl = "http://" . $baseDomain; diff --git a/homepage/cwsvJudo/configs/localDocker/participo/config.php b/homepage/cwsvJudo/configs/localDocker/participo/config.php new file mode 100644 index 0000000..4a46280 --- /dev/null +++ b/homepage/cwsvJudo/configs/localDocker/participo/config.php @@ -0,0 +1,5 @@ + diff --git a/homepage/cwsvJudo/configs/localDocker/participo/local/dbConf.php b/homepage/cwsvJudo/configs/localDocker/participo/local/dbConf.php new file mode 100644 index 0000000..59f4005 --- /dev/null +++ b/homepage/cwsvJudo/configs/localDocker/participo/local/dbConf.php @@ -0,0 +1,6 @@ + diff --git a/homepage/cwsvJudo/docker-compose.yaml b/homepage/cwsvJudo/docker-compose.yaml index 8b839b3..8e5ea3d 100644 --- a/homepage/cwsvJudo/docker-compose.yaml +++ b/homepage/cwsvJudo/docker-compose.yaml @@ -16,10 +16,11 @@ services: volumes: # this line maps the content of ./html in your pc to the /var/www/html of the container - ./build/dist/heliohost/httpdocs:/var/www/html - - ./build/dist/heliohost/pages:/home/cwsvjudo.de/pages - - ./build/dist/heliohost/shared:/home/cwsvjudo.de/shared - - ./configs/localDocker/config.json:/home/cwsvjudo.de/.local/config.json - - ./configs/localDocker/secrets.json:/home/cwsvjudo.de/.local/secrets.json + - ./build/dist/heliohost/pages:/var/www/pages + - ./build/dist/heliohost/shared:/var/www/shared + - ./build/dist/heliohost/libs:/var/www/libs + - ./configs/localDocker/config.json:/var/www/.local/config.json + - ./configs/localDocker/secrets.json:/var/www/.local/secrets.json db: # check the mysql version you need for your project image: mariadb:latest diff --git a/homepage/cwsvJudo/pandocTemplate/amp-template.html b/homepage/cwsvJudo/pandocTemplate/amp-template.html deleted file mode 100644 index 9fcc197..0000000 --- a/homepage/cwsvJudo/pandocTemplate/amp-template.html +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - - - - <%= @var pages_title -escape xml %> - - - - - - - - - - - - - - - - - <%= @var pages_content %> - <%= @var after-content %> - <%= @var inquiry %> - - - \ No newline at end of file diff --git a/homepage/cwsvJudo/pandocTemplate/cwsvJudo.amp.pandocTemplate b/homepage/cwsvJudo/pandocTemplate/cwsvJudo.amp.pandocTemplate deleted file mode 100644 index b9e9b4e..0000000 --- a/homepage/cwsvJudo/pandocTemplate/cwsvJudo.amp.pandocTemplate +++ /dev/null @@ -1,258 +0,0 @@ - -$else$ - PHPCount::AddHit("$title$ (Amp)");?> -$endif$ - - - - - -$for(author-meta)$ - -$endfor$ -$if(date-meta)$ - -$endif$ -$if(keywords)$ - -$endif$ -$if(phpTitleString)$ - <?php echo( $phpTitleString$ );?> -$else$$if(title)$ - $if(title-prefix)$$title-prefix$ – $endif$$pagetitle$ -$endif$$endif$ -$if(phpDescriptionString)$ - -$else$$if(description)$ - -$endif$$endif$ -$if(canonicalPath)$ - -$endif$ -$if(ampVersionLink)$ - -$endif$ - - -$if(math)$ - $math$ -$endif$ -$for(header-includes)$ - $header-includes$ -$endfor$ - - - - -$if(jsonSdFiles)$ - $for(jsonSdFiles)$ - - $endfor$ -$endif$ - - - - -
- Dies ist die "mobile" Version für Smartphones etc.
- Hier gibt es die Desktop-Variante -
- -
-
- - - Judo - - - -
- -$if(mainNav)$ - -$endif$ - -$if(subNav)$ - -
- -
-$endif$ - -$for(include-before)$ - $include-before$ -$endfor$ -$if(toc)$ - -$endif$ - -
-$body$ -
- - - - - -$for(include-after)$ -$include-after$ -$endfor$ - - diff --git a/homepage/cwsvJudo/pandocTemplate/cwsvJudo.html5.pandocTemplate b/homepage/cwsvJudo/pandocTemplate/cwsvJudo.html5.pandocTemplate deleted file mode 100644 index 5512d20..0000000 --- a/homepage/cwsvJudo/pandocTemplate/cwsvJudo.html5.pandocTemplate +++ /dev/null @@ -1,276 +0,0 @@ - -$else$ - // PHPCount::AddHit("$title$");?> -$endif$ - - - - - - -$for(author-meta)$ - -$endfor$ -$if(date-meta)$ - -$endif$ -$if(keywords)$ - -$endif$ -$if(canonicalPath)$ - -$endif$ -$if(ampVersionLink)$ - -$endif$ -$if(phpTitleString)$ - <?php echo( $phpTitleString$ );?> -$else$$if(title)$ - $if(title-prefix)$$title-prefix$ – $endif$$pagetitle$ -$endif$$endif$ -$if(phpDescriptionString)$ - -$else$$if(description)$ - -$endif$$endif$ - -$if(css)$ - -$endif$ - -$if(quotes)$ - -$endif$ -$if(highlighting-css)$ - -$endif$ -$for(extraCss)$ - -$endfor$ -$if(math)$ - $math$ -$endif$ - - - -$if(jsonSdFiles)$ - $for(jsonSdFiles)$ - - $endfor$ -$endif$ -$if(jsLibs)$ - $for(jsLibs)$ - - $endfor$ -$endif$ - - -$for(header-includes)$ - $header-includes$ -$endfor$ - - - -
- Judo im Chemnitzer WSV - Promo - - Judo - - - Judo im Chemnitzer WSV - Logo -
- -$if(mainNav)$ - -$endif$ - -$if(subNav)$ - -$endif$ - -$for(include-before)$ - $include-before$ -$endfor$ -$if(toc)$ - -$endif$ - -
-$body$ -
- - - - - -$for(include-after)$ -$include-after$ -$endfor$ - - diff --git a/homepage/cwsvJudo/pandocTemplate/html5.pandocTemplate b/homepage/cwsvJudo/pandocTemplate/html5.pandocTemplate deleted file mode 100644 index 22b885c..0000000 --- a/homepage/cwsvJudo/pandocTemplate/html5.pandocTemplate +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - -$for(author-meta)$ - -$endfor$ -$if(date-meta)$ - -$endif$ - $if(title-prefix)$$title-prefix$ - $endif$$pagetitle$ - - -$if(quotes)$ - -$endif$ -$if(highlighting-css)$ - -$endif$ - -$for(css)$ - -$endfor$ -$if(math)$ - $math$ -$endif$ -$for(header-includes)$ - $header-includes$ -$endfor$ - - -$for(include-before)$ -$include-before$ -$endfor$ -$if(title)$ -
-

$title$

-$if(subtitle)$ -

$subtitle$

-$endif$ -$for(author)$ -

$author$

-$endfor$ -$if(date)$ -

$date$

-$endif$ -
-$endif$ -$if(toc)$ - -$endif$ -$body$ -$for(include-after)$ -$include-after$ -$endfor$ - - diff --git a/homepage/cwsvJudo/pandocTemplate/materialize-fromScratch.html b/homepage/cwsvJudo/pandocTemplate/materialize-fromScratch.html deleted file mode 100644 index 4b29b98..0000000 --- a/homepage/cwsvJudo/pandocTemplate/materialize-fromScratch.html +++ /dev/null @@ -1,191 +0,0 @@ - - - - - - - - - - $for(author-meta)$ - $endfor$ - $if(date-meta)$ - $endif$ - $if(keywords)$ - - $endif$ - $if(canonicalPath)$ - - $endif$ - $if(ampVersionLink)$ - - $endif$ - $if(phpTitleString)$ - - <?php echo( $phpTitleString$ );?> - - $else$$if(title)$ - $if(title-prefix)$$title-prefix$ – $endif$$pagetitle$ - $endif$$endif$ - $if(phpDescriptionString)$ - - $else$$if(description)$ - - $endif$$endif$ - - $if(css)$$for(css)$ - - $endfor$$endif$ - - - - - - - - - - - - - $if(extraCss)$$for(extraCss)$ - - $endfor$$endif$ - - $if(jsLibs)$$for(jsLibs)$ - - $endfor$$endif$ - - - - - -
- -
- -
- $body$ -
- - - - - - - - - diff --git a/homepage/cwsvJudo/pandocTemplate/materialize-parallax.pandocTemplate b/homepage/cwsvJudo/pandocTemplate/materialize-parallax.pandocTemplate deleted file mode 100644 index c1f0802..0000000 --- a/homepage/cwsvJudo/pandocTemplate/materialize-parallax.pandocTemplate +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - - - - - - - -
- -
- -
-
- -
-
- -
- $body$ -
- -
-
-
- -
- Lorem Ipsum -
- -
-
-
- -
- Lorem Ipsum -
-
- -
- - - - - - - - - - diff --git a/homepage/cwsvJudo/participo b/homepage/cwsvJudo/participo new file mode 120000 index 0000000..2a5f484 --- /dev/null +++ b/homepage/cwsvJudo/participo @@ -0,0 +1 @@ +../participo/ \ No newline at end of file diff --git a/homepage/cwsvJudo/phpLib/.htaccess b/homepage/cwsvJudo/phpLib/.htaccess new file mode 100644 index 0000000..0eada0e --- /dev/null +++ b/homepage/cwsvJudo/phpLib/.htaccess @@ -0,0 +1,125 @@ +## EXPIRES CACHING ## + +ExpiresActive On +ExpiresByType image/jpg "access 1 year" +ExpiresByType image/jpeg "access 1 year" +ExpiresByType image/gif "access 1 year" +ExpiresByType image/png "access 1 year" +ExpiresByType text/css "access 1 month" +ExpiresByType text/html "access 1 month" +ExpiresByType application/pdf "access 1 month" +ExpiresByType text/x-javascript "access 1 month" +ExpiresByType application/x-shockwave-flash "access 1 month" +ExpiresByType image/x-icon "access 1 year" +ExpiresDefault "access 1 month" + +## END EXPIRES CACHING ## + +### +# Weiterleitungen +### + +## Hotfixes + + +RewriteEngine On +RewriteBase / + +## https-Anfragen (auf Port 443) auf http umleiten +RewriteCond %{SERVER_PORT} ^443$ +RewriteRule (.*) http://%{HTTP_HOST}/$1 [R=302,L] + +## www auf nichtwww umleiten +RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] +RewriteRule ^(.*)$ http://%1/$1 [R=301,L] + +#RewriteRule ^wk/([0-9]+)$ pages/desktop/verein.wettkampf.php?wkId=$1 +RewriteRule ^wk/([0-9]+)$ wkKalender/$1 [R=301,L] + +RewriteRule ^gallery/([0-9]+)$ ?galId=$1 [L] +RewriteRule ^gallery/([0-9]+)/.*$ ?galId=$1 [L] + +RewriteRule ^galerie/([0-9]+)$ ?galId=$1 [L] +RewriteRule ^galerie/([0-9]+)/.*$ ?galId=$1 [L] + +RewriteRule ^news/([0-9]+)$ pages/responsive/news.php?newsId=$1 [L] +RewriteRule ^news/([0-9]+)/.*$ pages/responsive/news.php?newsId=$1 [L] + + + +Header set Content-Security-Policy "script-src 'self'" + + +Header always set X-FRAME-OPTIONS "DENY" + + + +# Auf die Fontdatei wird von der Subdomain aus zugegriffen +# - das gesamte ressourcenVerzeichnis wird auf die Maindomain umgeleitet +# - die mainDomain erlaubt aber anscheinend nicht, das fremde domains bei ihr anfragen startet +# - deshalb zumindest für das otf-File den cross domain zugriff erlauben +# (seltsam, dass der Zugriff auf die Bilder unter Photoalben aber erlaubt wird...) + + + Header set Access-Control-Allow-Origin "*" + + + + +### +# redesign2018 Test +### + + +# Url-Rewriting aktivieren +RewriteEngine on +# Das Request ist für diese Domain +# Für uns eigentlich irrelevant, da alle Domains (mit/ohne +# www/ch/de/net) auf das Unterverzeichnis geleitet werden sollen, aber +# interessant zu wissen +# Und jetzt nützlich: Ich kann es unter der .de-Domain testen! +#RewriteCond %{HTTP_HOST} ^(www.)?cwsvjudo.bplaced.de$ [NC] + +# einige hotfixes +RewriteRule ^pages/desktop/verein.wettkampfkalender.php$ pages/responsive/wkKalender.php [L] +RewriteRule ^ressourcen/(.*)$ ressourcen/$1 [L] +#RewriteRule ^photoalben/(.*)$ https:\\photoalben/$1 [L] +RewriteRule ^photoalben/(.*) https://cwsvjudo.lima-city.de/photoalben/$1 [L] +RewriteRule ^videoalben/(.*)$ videoalben/$1 [L] +RewriteRule ^downloads/(.*)$ downloads/$1 [L] +RewriteRule ^temp/(.*)$ temp/$1 [L] +RewriteRule ^admin/(.*)$ admin/$1 [L] + + +RewriteCond %{REQUEST_URI} ^/$ +RewriteCond %{QUERY_STRING} ^wkId=([0-9]+)$ +RewriteRule ^(.*)$ /pages/responsive/wkKalender.php [L] + + +# Die angeforderte Ressource ist nicht bereits in dem Zielverzeichnis: +RewriteCond %{REQUEST_URI} !^/pages/responsive/ + +# Die angeforderte Ressource (als Datei) ist nicht im Rootverzeichnis +RewriteCond %{REQUEST_FILENAME} !-f + +# Die angeforderte Ressource (als Verzeichnis) ist nicht im +# Rootverzeichnis +RewriteCond %{REQUEST_FILENAME} !-d + +# An die angeforderte Ressource das Zielverzeichnis präfixen +RewriteRule ^(.*)$ /pages/responsive/$1 + +RewriteRule ^(.*)wkKalender/([0-9]+)(.*)$ $1/wkKalender?wkId=$2 +#RewriteCond %{HTTP_HOST} ^(www.)?cwsvjudo.bplaced.de$ [NC] +RewriteRule ^gallery/([0-9]+)$ ?galId=$1 [L] +RewriteRule ^galerie/([0-9]+)$ ?galId=$1 [L] + + +# Ein Request für die Root-Ressource auf die index.php im +# Zielverzeichnis umleiten + +#RewriteCond %{HTTP_HOST} ^(www.)?cwsvjudo.bplaced.de$ [NC] +RewriteRule ^(/)?$ pages/responsive/index.php [L] + + +# Ende redesign2018-Test diff --git a/homepage/cwsvJudo/phpLib/cwsvJudo/miscAssis.php b/homepage/cwsvJudo/phpLib/cwsvJudo/miscAssis.php index b146adf..e8d3953 100644 --- a/homepage/cwsvJudo/phpLib/cwsvJudo/miscAssis.php +++ b/homepage/cwsvJudo/phpLib/cwsvJudo/miscAssis.php @@ -1,210 +1,248 @@ 0 && $str == round($str)); +function is_positive_integer($str) +{ + return is_numeric($str) && $str > 0 && $str == round($str); } -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 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 getCwsvJudoDbConn(){ -global $cwsvJudoConfig; -// Datenbankverbindung bereit stellen - try{ - $db_connection = new PDO( - 'mysql:host='.$cwsvJudoConfig["db"]["host"].';dbname='.$cwsvJudoConfig["db"]["name"],//.';charset=utf8', - $cwsvJudoConfig["db"]["user"], - $cwsvJudoConfig["db"]["password"] - ); - } - catch(PDOException $db_error){ - echo( "Error whilst getting a dbConnection!: " . $db_error->getMessage() ); - } -return $db_connection; +function getCwsvJudoDbConn() +{ + global $cwsvJudoConfig; + // Datenbankverbindung bereit stellen + try { + $db_connection = new PDO( + "mysql:host=" . + $cwsvJudoConfig["db"]["host"] . + ";dbname=" . + $cwsvJudoConfig["db"]["name"], //.';charset=utf8', + $cwsvJudoConfig["db"]["user"], + $cwsvJudoConfig["db"]["password"], + ); + } catch (PDOException $db_error) { + echo "Error whilst getting a dbConnection!: " . $db_error->getMessage(); + } + 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; +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){ -$retKeyValueArray = array(); - foreach( explode(",", $aKeyValueStringList) as $keyValueString){ - $keyValuePair = explode("=", $keyValueString); - $retKeyValueArray[$keyValuePair[0]] = $keyValuePair[1]; - } -return $retKeyValueArray; -} - -/// @brief Gibt die URL der gerade aufgerufenen Seite zurück -function getCurPagesUrl(){ - $pageURL = 'http'; - if ($_SERVER["HTTPS"]??null == "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 getKeyValueArray($aKeyValueStringList) +{ + $retKeyValueArray = []; + if ($aKeyValueStringList != "") { + foreach (explode(",", $aKeyValueStringList) as $keyValueString) { + $keyValuePair = explode("=", $keyValueString); + $retKeyValueArray[$keyValuePair[0]] = $keyValuePair[1]; + }; + } + return $retKeyValueArray; } /// ein zufälliges Zitat aus der Datenbank abfragen -function getRandomCite($aDbConnection, $optionsArray = array("dbCharset" => "ISO-8859-1", "outCharset" => "UTF-8") ){ -if(!$aDbConnection) return NULL; +function getRandomCite( + $aDbConnection, + $optionsArray = ["dbCharset" => "ISO-8859-1", "outCharset" => "UTF-8"], +) { + if (!$aDbConnection) { + return null; + } -if( empty($optionsArray['dbCharset']) ) $optionsArray['dbCharset'] = "ISO-8859-1"; -if( empty($optionsArray['outCharset']) ) $optionsArray['outCharset'] = "UTF-8"; + if (empty($optionsArray["dbCharset"])) { + $optionsArray["dbCharset"] = "ISO-8859-1"; + } + if (empty($optionsArray["outCharset"])) { + $optionsArray["outCharset"] = "UTF-8"; + } - try{ - $pdoStatementForQuerryingZitat = $aDbConnection->prepare( - "SELECT * FROM zitate ORDER BY RAND() LIMIT 1;" - ); - $pdoStatementForQuerryingZitat->execute(); - $retZitat = $pdoStatementForQuerryingZitat->fetchAll(PDO::FETCH_ASSOC); + try { + $pdoStatementForQuerryingZitat = $aDbConnection->prepare( + "SELECT * FROM zitate ORDER BY RAND() LIMIT 1;", + ); + $pdoStatementForQuerryingZitat->execute(); + $retZitat = $pdoStatementForQuerryingZitat->fetchAll(PDO::FETCH_ASSOC); - // Zeichensatzkonvertierung - foreach($retZitat as &$entry){ - array_walk( - $entry, - function (&$value, $key, $optionsArray) { - $value = iconv($optionsArray['dbCharset'], $optionsArray['outCharset'], $value); - }, - $optionsArray - ); - } - $retZitat = $retZitat[0]; - } - catch(PDOException $db_error){ - $retZitat['zitat'] = "There is no spoon!"; - } -return $retZitat; + // Zeichensatzkonvertierung + foreach ($retZitat as &$entry) { + array_walk( + $entry, + function (&$value, $key, $optionsArray) { + $value = iconv( + $optionsArray["dbCharset"], + $optionsArray["outCharset"], + $value, + ); + }, + $optionsArray, + ); + } + $retZitat = $retZitat[0]; + } catch (PDOException $db_error) { + $retZitat["zitat"] = "There is no spoon!"; + } + return $retZitat; } /// filtert aus einem Array einträge in der gegebenen Reihenfolge -function arrayKeyFilter($anArray, $someKeys){ -// var_dump($anArray, $someKeys); - if( (is_array( $anArray ) || is_object( $anArray )) && ( is_array( $someKeys ) || is_object( $someKeys ) ) ){ - $retArray = array(); - foreach($someKeys as $key){ - if( array_key_exists($key, $anArray) ){ - $retArray[] = $anArray[$key]; - } - } - return $retArray; - } -return null; +function arrayKeyFilter($anArray, $someKeys) +{ + // var_dump($anArray, $someKeys); + if ( + (is_array($anArray) || is_object($anArray)) && + (is_array($someKeys) || is_object($someKeys)) + ) { + $retArray = []; + foreach ($someKeys as $key) { + if (array_key_exists($key, $anArray)) { + $retArray[] = $anArray[$key]; + } + } + return $retArray; + } + return null; } /// Linkeinträge aus einer jsonDatei laden -function jsonLinkFile2NavLinkList($aJsonFileName, $someLinkNames, $someOptions = [] ){ -if( !file_exists($aJsonFileName) ) return null; -if( !(is_array( $someLinkNames ) || is_object( $someLinkNames )) ) return null; +function jsonLinkFile2NavLinkList( + $aJsonFileName, + $someLinkNames, + $someOptions = [], +) { + if (!file_exists($aJsonFileName)) { + return null; + } + if (!(is_array($someLinkNames) || is_object($someLinkNames))) { + return null; + } -return arrayKeyFilter( - json_decode( - file_get_contents($aJsonFileName), - true - ), - $someLinkNames -); + return arrayKeyFilter( + json_decode(file_get_contents($aJsonFileName), true), + $someLinkNames, + ); } -function echoThisOrThat($This, $that){ - echo( !empty($This) ? $This : $that ); +function echoThisOrThat($This, $that) +{ + echo !empty($This) ? $This : $that; } -function echoThisWhenThat($This, $that){ - if( !empty($that) ) echo( $This ); +function echoThisWhenThat($This, $that) +{ + if (!empty($that)) { + echo $This; + } } -function thisWhenThat($This, $that){ - if( empty($that) ) return ""; - return $This; +function thisWhenThat($This, $that) +{ + if (empty($that)) { + return ""; + } + return $This; } -setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge'); -function toAscii($str, $replace=array(), $delimiter='-') { - if( !empty($replace) ) { - $str = str_replace((array)$replace, ' ', $str); - } +setlocale(LC_ALL, "de_DE@euro", "de_DE", "de", "ge"); +function toAscii($str, $replace = [], $delimiter = "-") +{ + if (!empty($replace)) { + $str = str_replace((array) $replace, " ", $str); + } - $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str); - $clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean); - $clean = strtolower(trim($clean, '-')); - $clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean); + $clean = iconv("UTF-8", "ASCII//TRANSLIT", $str); + $clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", "", $clean); + $clean = strtolower(trim($clean, "-")); + $clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean); - return $clean; + return $clean; } /// Wrapper function for a query to the /// $aDbConnection connection to a db -function dbQuery($aDbConnection, $aQueryString, $aBindArray = array(), $someOptions = array( "dbCharset" => "ISO-8859-1", "outCharset" => "UTF-8" ) ){ -if( empty($someOptions['dbCharset']) ) $someOptions['dbCharset'] = "ISO-8859-1"; -if( empty($someOptions['outCharset']) ) $someOptions['outCharset'] = "UTF-8"; -/// @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. - 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) - ); - } - $pdoStatement->execute(); - $ret = $pdoStatement->fetchAll(PDO::FETCH_ASSOC); - } - catch(PDOException $db_error){ - print "Error!: " . $db_error->getMessage() . "
"; - return null; - } +function dbQuery( + $aDbConnection, + $aQueryString, + $aBindArray = [], + $someOptions = ["dbCharset" => "ISO-8859-1", "outCharset" => "UTF-8"], +) { + if (empty($someOptions["dbCharset"])) { + $someOptions["dbCharset"] = "ISO-8859-1"; + } + if (empty($someOptions["outCharset"])) { + $someOptions["outCharset"] = "UTF-8"; + } + /// @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. + 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, + ); + } + $pdoStatement->execute(); + $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; + // 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; } /** checks if the page is a amp page by checking the requested url for our amp source */ -function check_for_amp_site(){ - return (strpos( $_SERVER['REQUEST_URI']??null, "pages/amp" ) !== false ); +function check_for_amp_site() +{ + return strpos($_SERVER["REQUEST_URI"] ?? null, "pages/amp") !== false; } ?> diff --git a/homepage/cwsvJudo/phpLib/cwsvJudo/newsLib.php b/homepage/cwsvJudo/phpLib/cwsvJudo/newsLib.php index 7f1a946..24b0de5 100644 --- a/homepage/cwsvJudo/phpLib/cwsvJudo/newsLib.php +++ b/homepage/cwsvJudo/phpLib/cwsvJudo/newsLib.php @@ -1,19 +1,18 @@ childNodes; - foreach ($children as $child) { - $innerHTML .= $child->ownerDocument->saveXML( $child ); - } +function get_inner_html($node) +{ + $innerHTML = ""; + $children = $node->childNodes; + foreach ($children as $child) { + $innerHTML .= $child->ownerDocument->saveXML($child); + } - return $innerHTML; + return $innerHTML; } - - /// Eine Liste mit News abfragen /// /// Der Rückgabewert sollte vor Verwendung (und zur Fehlerbeheandlung) @@ -21,221 +20,313 @@ function get_inner_html( $node ) { /// Der Zeichensatz wird von "ISO-8859-1" auf "UTF-8" gesetzt /// /// @return Array mit News (die wiederum assoziative arrays sind -function getNews($aMysqlConn, $optionsArray = array("dbCharset" => "ISO-8859-1", "outCharset" => "UTF-8", "limit" => "1")){ -if(!$aMysqlConn) return NULL; +function getNews( + $aMysqlConn, + $optionsArray = [ + "dbCharset" => "ISO-8859-1", + "outCharset" => "UTF-8", + "limit" => "1", + ], +) { + if (!$aMysqlConn) { + return null; + } -if( empty($optionsArray['dbCharset']) ) $optionsArray['dbCharset'] = "ISO-8859-1"; -if( empty($optionsArray['outCharset']) ) $optionsArray['outCharset'] = "UTF-8"; + if (empty($optionsArray["dbCharset"])) { + $optionsArray["dbCharset"] = "ISO-8859-1"; + } + if (empty($optionsArray["outCharset"])) { + $optionsArray["outCharset"] = "UTF-8"; + } -if( !is_positive_integer($optionsArray['limit']) ) $optionsArray['limit'] = "1"; + if (!is_positive_integer($optionsArray["limit"])) { + $optionsArray["limit"] = "1"; + } -$ret = array(); -// Falls eine konkrete newsId angegeben wurde, wollen wir ab dieser News haben - if( is_positive_integer($optionsArray['newsId']??null) ){ - $pdoStatementForQuerryingNews = $aMysqlConn->prepare( - "SELECT * FROM nachrichten WHERE nachrichten.datum <= (SELECT nachrichten.datum FROM nachrichten WHERE nachrichten.nr = :newsId ) ORDER BY nachrichten.datum DESC LIMIT :limit OFFSET 0;" - ); - $pdoStatementForQuerryingNews->bindParam(':newsId', intval($optionsArray['newsId']), PDO::PARAM_INT); - } -// Ansonsten die aktuellsten - else{ - $query = "SELECT * FROM nachrichten"; + $ret = []; + // Falls eine konkrete newsId angegeben wurde, wollen wir ab dieser News haben + if (is_positive_integer($optionsArray["newsId"] ?? null)) { + $pdoStatementForQuerryingNews = $aMysqlConn->prepare( + "SELECT * FROM nachrichten WHERE nachrichten.datum <= (SELECT nachrichten.datum FROM nachrichten WHERE nachrichten.nr = :newsId ) ORDER BY nachrichten.datum DESC LIMIT :limit OFFSET 0;", + ); + $pdoStatementForQuerryingNews->bindParam( + ":newsId", + intval($optionsArray["newsId"]), + PDO::PARAM_INT, + ); + } + // Ansonsten die aktuellsten + else { + $query = "SELECT * FROM nachrichten"; - if( is_positive_integer($optionsArray['jahr']??null) ) - $query .= " WHERE DATE_FORMAT( datum, '%Y') = :jahr"; + if (is_positive_integer($optionsArray["jahr"] ?? null)) { + $query .= " WHERE DATE_FORMAT( datum, '%Y') = :jahr"; + } - $query .= " ORDER BY datum DESC, nr DESC LIMIT :limit;"; + $query .= " ORDER BY datum DESC, nr DESC LIMIT :limit;"; - //echo( $query ); + //echo( $query ); - $pdoStatementForQuerryingNews = $aMysqlConn->prepare( - $query - ); - } + $pdoStatementForQuerryingNews = $aMysqlConn->prepare($query); + } - $limit = intval($optionsArray['limit']); - $pdoStatementForQuerryingNews->bindParam(':limit', $limit, PDO::PARAM_INT); -// $pdoStatementForQuerryingNews->bindParam(':jahr', intval($optionsArray['jahr']), PDO::PARAM_INT); - $pdoStatementForQuerryingNews->execute(); - $ret = $pdoStatementForQuerryingNews->fetchAll(PDO::FETCH_ASSOC); + $limit = intval($optionsArray["limit"]); + $pdoStatementForQuerryingNews->bindParam(":limit", $limit, PDO::PARAM_INT); + // $pdoStatementForQuerryingNews->bindParam(':jahr', intval($optionsArray['jahr']), PDO::PARAM_INT); + $pdoStatementForQuerryingNews->execute(); + $ret = $pdoStatementForQuerryingNews->fetchAll(PDO::FETCH_ASSOC); -// Zeichensatzkonvertierung - foreach($ret as &$entry){ - array_walk( - $entry, - function (&$value, $key, $optionsArray) { - $value = iconv($optionsArray['dbCharset'], $optionsArray['outCharset'], $value); - }, - $optionsArray - ); - } + // Zeichensatzkonvertierung + foreach ($ret as &$entry) { + array_walk( + $entry, + function (&$value, $key, $optionsArray) { + $value = iconv( + $optionsArray["dbCharset"], + $optionsArray["outCharset"], + $value, + ); + }, + $optionsArray, + ); + } -return $ret; + return $ret; } /// Aus einer abgefragten News den htmlCode erzeugen -function getHtmlNews($aNews, $someOptions=""){ -$options = getKeyValueArray($someOptions); +function getHtmlNews($aNews, $someOptions = "") +{ + $options = getKeyValueArray($someOptions); -// schlechter Hack solange die Browser nicht von selbst ordentlich trennen - $aNews['betreff'] = - str_replace("meisterschaft", "­meisterschaft", $aNews['betreff']); - $aNews['betreff'] = - str_replace("turnier", "­turnier", $aNews['betreff']); - $aNews['betreff'] = - str_replace("randori", "­randori", $aNews['betreff']); - $aNews['betreff'] = - str_replace("spiele", "­spiele", $aNews['betreff']); + // schlechter Hack solange die Browser nicht von selbst ordentlich trennen + $aNews["betreff"] = str_replace( + "meisterschaft", + "­meisterschaft", + $aNews["betreff"], + ); + $aNews["betreff"] = str_replace( + "turnier", + "­turnier", + $aNews["betreff"], + ); + $aNews["betreff"] = str_replace( + "randori", + "­randori", + $aNews["betreff"], + ); + $aNews["betreff"] = str_replace("spiele", "­spiele", $aNews["betreff"]); - $retHtml = ""; - $retHtml .= "
"; - $retHtml .= ""; - $retHtml .= "
"; - $retHtml .= "
"; - $retHtml .= "
" . $aNews['betreff'] . "
"; - $retHtml .= "
"; - $retHtml .= "
"; + $retHtml = ""; + $retHtml .= "
"; + $retHtml .= + ""; + $retHtml .= "
"; + $retHtml .= + "
"; + $retHtml .= + "
" . + $aNews["betreff"] . + "
"; + $retHtml .= "
"; + $retHtml .= "
"; -// phpMyAdmin fügte manchmal die falschen Zeilenenden ein - $aNews['nachricht'] = str_replace("\r\n", "\n", $aNews['nachricht']); + // phpMyAdmin fügte manchmal die falschen Zeilenenden ein + $aNews["nachricht"] = str_replace("\r\n", "\n", $aNews["nachricht"]); -// falls KEIN explizites PromoImage gesetzt ist, versuche es aus dem -// Nachrichtentext heraus zu lesen -// @toDo: woher bekomme ich width and height bei explizitem promoImg? - if(!array_key_exists("promoImg", $aNews)){ - $aNews['promoImg'] = array('src'=>""); - } - if(is_string($aNews['promoImg'])){ - if(json_decode($aNews['promoImg'])){ - $aNews['promoImg'] = json_decode($aNews['promoImg'], true); - } - } - if( !filter_var($aNews['promoImg'], FILTER_VALIDATE_URL) && !filter_var($aNews['promoImg']['src'], FILTER_VALIDATE_URL) ){ - $domDoc = new DOMDocument(); - // @todo With php8.4 use Dom\HTMLDocument::createFromString() and don't ignore the warnings. - @$domDoc->loadHTML( mb_convert_encoding($aNews['nachricht'], 'HTML-ENTITIES', "UTF-8") ); - foreach($domDoc->getElementsByTagName('a') as $anchor){ - $anchorDad = $anchor->parentNode; - foreach($anchor->getElementsByTagName('img') as $img){ - $aNews['promoImg']['src'] = $img->getAttribute('src'); - $aNews['promoImg']['alt'] = $img->getAttribute('alt'); - $aNews['promoImg']['width'] = $img->getAttribute('width'); - $aNews['promoImg']['height'] = $img->getAttribute('height'); - $anchorDad->removeChild($anchor); - break; - } - $xpath = new DOMXPath($domDoc); + // falls KEIN explizites PromoImage gesetzt ist, versuche es aus dem + // Nachrichtentext heraus zu lesen + // @toDo: woher bekomme ich width and height bei explizitem promoImg? + if (!array_key_exists("promoImg", $aNews)) { + $aNews["promoImg"] = ["src" => ""]; + } + if (is_string($aNews["promoImg"])) { + if (json_decode($aNews["promoImg"])) { + $aNews["promoImg"] = json_decode($aNews["promoImg"], true); + } + } + if ( + !filter_var($aNews["promoImg"], FILTER_VALIDATE_URL) && + !filter_var($aNews["promoImg"]["src"], FILTER_VALIDATE_URL) + ) { + $domDoc = new DOMDocument(); + // @todo With php8.4 use Dom\HTMLDocument::createFromString() and don't ignore the warnings. + @$domDoc->loadHTML( + mb_convert_encoding($aNews["nachricht"], "HTML-ENTITIES", "UTF-8"), + ); + foreach ($domDoc->getElementsByTagName("a") as $anchor) { + $anchorDad = $anchor->parentNode; + foreach ($anchor->getElementsByTagName("img") as $img) { + $aNews["promoImg"]["src"] = $img->getAttribute("src"); + $aNews["promoImg"]["alt"] = $img->getAttribute("alt"); + $aNews["promoImg"]["width"] = $img->getAttribute("width"); + $aNews["promoImg"]["height"] = $img->getAttribute("height"); + $anchorDad->removeChild($anchor); + break; + } + $xpath = new DOMXPath($domDoc); - foreach( $xpath->query('//*[not(node())]') as $node ) { - $node->parentNode->removeChild($node); - } + foreach ($xpath->query("//*[not(node())]") as $node) { + $node->parentNode->removeChild($node); + } - $domDoc->formatOutput = true; - $aNews['nachricht'] = get_inner_html( $domDoc->getElementsByTagName('body')[0] ); - } - } + $domDoc->formatOutput = true; + $aNews["nachricht"] = get_inner_html( + $domDoc->getElementsByTagName("body")[0], + ); + } + } - if( !empty($aNews['promoImg']) ){ - if( !empty($aNews['promoImg']['src']) ){ - $retHtml .= ""; - } - if( filter_var($aNews['promoImg'], FILTER_VALIDATE_URL) ){ - $retHtml .= ""; - } + if (!empty($aNews["promoImg"])) { + if (!empty($aNews["promoImg"]["src"])) { + $retHtml .= + ""; + } + if (filter_var($aNews["promoImg"], FILTER_VALIDATE_URL)) { + $retHtml .= + ""; + } - // Für den Fall einer ampSeite müssen die imgTags angepasst werden - if( check_for_amp_site() ){ - $retHtml = str_replace("", ">", $retHtml); - } - } + // Für den Fall einer ampSeite müssen die imgTags angepasst werden + if (check_for_amp_site()) { + $retHtml = str_replace( + "", ">", $retHtml); + } + } - $retHtml .= "
".ampTagReplace( $aNews['nachricht'] )."
"; - $retHtml .= "
"; - $retHtml .= "
"; - $retHtml .= "
".$aNews['autor']."
"; - $retHtml .= "
"; - $retHtml .= "
"; -return $retHtml; + $retHtml .= + "
" . + ampTagReplace($aNews["nachricht"]) . + "
"; + $retHtml .= "
"; + $retHtml .= "
"; + $retHtml .= "
" . $aNews["autor"] . "
"; + $retHtml .= "
"; + $retHtml .= "
"; + return $retHtml; } -function news2jsonSdArticle($aNews){ -return json_encode( - array( - '@context'=>"http://schema.org", - '@type'=>"NewsArticle", - 'mainEntityOfPage'=>array( - '@type'=>"WebPage", - '@id'=>"http://cwsvjudo.bplaced.net/news/".$aNews['nr']."/".toAscii($aNews['datum']."-".$aNews['betreff']) - ), - 'headline'=>$aNews['betreff'], - 'image'=>array( - "http://cwsvjudo.bplaced.net/ressourcen/graphiken/logos/cwsvJudoLogoWappen.256w.png" - ), - 'datePublished'=>$aNews['datum'], - 'dateModified'=>$aNews['datum'], - 'author'=>array( - '@type'=>"Person", - 'name'=>$aNews['autor'], - 'url'=>"://cwsvjudo.bplaced.net" - ), - 'publisher'=>array( - '@type'=>"Organization", - 'name'=>"cwsvJudo", - 'logo'=>array( - '@type'=>"ImageObject", - 'url'=>"http://cwsvjudo.bplaced.net/ressourcen/graphiken/logos/cwsvJudoLogoWappen.256w.png" - ) - ), - 'description'=>$aNews['betreff'] - ) -); +function news2jsonSdArticle($aNews) +{ + return json_encode([ + "@context" => "http://schema.org", + "@type" => "NewsArticle", + "mainEntityOfPage" => [ + "@type" => "WebPage", + "@id" => + "http://cwsvjudo.bplaced.net/news/" . + ($aNews["nr"] ?? "") . + "/" . + toAscii($aNews["datum"] . "-" . $aNews["betreff"]), + ], + "headline" => $aNews["betreff"], + "image" => [ + "http://cwsvjudo.bplaced.net/ressourcen/graphiken/logos/cwsvJudoLogoWappen.256w.png", + ], + "datePublished" => $aNews["datum"], + "dateModified" => $aNews["datum"], + "author" => [ + "@type" => "Person", + "name" => $aNews["autor"], + "url" => "://cwsvjudo.bplaced.net", + ], + "publisher" => [ + "@type" => "Organization", + "name" => "cwsvJudo", + "logo" => [ + "@type" => "ImageObject", + "url" => + "http://cwsvjudo.bplaced.net/ressourcen/graphiken/logos/cwsvJudoLogoWappen.256w.png", + ], + ], + "description" => $aNews["betreff"], + ]); } -function getHtmlNewsTitle(){ - $htmlTitle = "Neuigkeiten der Judoka des Chemnitzer Freizeit- und Wohngebiets­sportvereines e. V."; - if($_GET['newsId']){ - $dbConn = getCwsvJudoDbConn(); - $options['newsId']=$_GET['newsId']; - $mainNews=getNews(getCwsvJudoDbConn(), $options); - if($mainNews) - $htmlTitle = $mainNews[0]['betreff']." - ".$htmlTitle; - } - return $htmlTitle; +function getHtmlNewsTitle() +{ + $htmlTitle = + "Neuigkeiten der Judoka des Chemnitzer Freizeit- und Wohngebiets­sportvereines e. V."; + if ($_GET["newsId"]) { + $dbConn = getCwsvJudoDbConn(); + $options["newsId"] = $_GET["newsId"]; + $mainNews = getNews(getCwsvJudoDbConn(), $options); + if ($mainNews) { + $htmlTitle = $mainNews[0]["betreff"] . " - " . $htmlTitle; + } + } + return $htmlTitle; } -function img2ampimg($inText){ - $outText = $inText; - // Zuweilen sind im Nachtrichtentext selbst auch schon Bilder, auch diese müssen bei ampSeiten angepasst werden - if( check_for_amp_site() ){ - // bei bereits im Newstext vorhandenen Bildern, gehen wir davon aus, dass widt+heigth bereits gesetzt sind - $outText = str_replace("", ">", $outText); - } +function img2ampimg($inText) +{ + $outText = $inText; + // Zuweilen sind im Nachtrichtentext selbst auch schon Bilder, auch diese müssen bei ampSeiten angepasst werden + if (check_for_amp_site()) { + // bei bereits im Newstext vorhandenen Bildern, gehen wir davon aus, dass widt+heigth bereits gesetzt sind + $outText = str_replace( + "", ">", $outText); + } - return $outText; + return $outText; } -function video2ampvideo($inText){ - $outText = $inText; - // Zuweilen sind im Nachtrichtentext selbst auch schon Bilder, auch diese müssen bei ampSeiten angepasst werden - if( check_for_amp_site() ){ - // bei bereits im Newstext vorhandenen Bildern, gehen wir davon aus, dass widt+heigth bereits gesetzt sind - $outText = str_replace("