pupupu

simple static CMS for crappy servers
git clone https://git.ce9e.org/pupupu.git

commit
6f2858d98c40517d1d333f37b3a7f669e45034b2
parent
0499ac65085605c1c78529e4e5535316d396d3de
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2018-10-19 09:25
ensure trailing slash

Diffstat

M index.php 16 ++++++++++++++++

1 files changed, 16 insertions, 0 deletions


diff --git a/index.php b/index.php

@@ -236,6 +236,20 @@ class Pupupu
  236   236     }
  237   237 }
  238   238 
   -1   239 function ensureTrailingSlash()
   -1   240 {
   -1   241     $parts = explode('?', $_SERVER['REQUEST_URI']);
   -1   242     if (substr($parts[0], -9) === 'index.php') {
   -1   243         $parts[0] = substr($parts[0], 0, -9);
   -1   244         header('Location: ' . implode('?', $parts), true, 301);
   -1   245         die();
   -1   246     } elseif (substr($parts[0], -1) !== '/') {
   -1   247         $parts[0] = $parts[0] . '/';
   -1   248         header('Location: ' . implode('?', $parts), true, 301);
   -1   249         die();
   -1   250     }
   -1   251 }
   -1   252 
  239   253 function uploadView($pupupu, $twig)
  240   254 {
  241   255     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
@@ -303,6 +317,8 @@ function pageView($pupupu, $twig)
  303   317 $pupupu = new Pupupu('..', '..');
  304   318 
  305   319 if (isset($_SERVER['REQUEST_METHOD'])) {
   -1   320     ensureTrailingSlash();
   -1   321 
  306   322     $loader = new Twig_Loader_Filesystem('templates');
  307   323     $twig = new Twig_Environment($loader);
  308   324