From 9b8e234c6c9ae545df3788c0603a5dd97ffc62b4 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Mon, 20 Jun 2016 22:41:47 +0200 Subject: support php internal webserver --- .htaccess | 2 +- README.md | 15 +++++++++++++++ index.php | 18 +++++++++++++++++- serve.sh | 2 ++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100755 serve.sh diff --git a/.htaccess b/.htaccess index 431bbb1..85a4c06 100644 --- a/.htaccess +++ b/.htaccess @@ -5,4 +5,4 @@ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l -RewriteRule (.*) index.php?route=$1 [L] +RewriteRule (.*) index.php?route=$1&htaccess=1 [L] diff --git a/README.md b/README.md index 97b16aa..3b29819 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,21 @@ zu haben, die mit wenigen Konfigurationsoptionen und ein paar CSS-Rules an die Gegebenheiten und die Gestaltung der Konferenz angepasst werden können. +## Development + +Während der Entwicklung kann der eingebaute PHP-Webserver verwendet werden: +``` +$ ./serve.sh +PHP 7.0.4-7ubuntu2.1 Development Server started at Mon Jun 20 22:40:17 2016 +Listening on http://localhost:8000 +Document root is /home/peter/VOC/streaming-website +Press Ctrl-C to quit. +… +``` + +Unterstützt wird PHP ab 5.4. + + ## Setup diff --git a/index.php b/index.php index eeaca82..2d6a575 100644 --- a/index.php +++ b/index.php @@ -28,7 +28,23 @@ require_once('model/Upcoming.php'); ob_start(); try { - $route = @$_GET['route']; + if(isset($_GET['htaccess'])) + { + $route = @$_GET['route']; + } + elseif(isset($_SERVER["REQUEST_URI"])) + { + $route = ltrim(@$_SERVER["REQUEST_URI"], '/'); + + // serve static + if($route != '' && file_exists($_SERVER["DOCUMENT_ROOT"].'/'.$route)) + { + return false; + } + + } + else $route = ''; + $route = rtrim($route, '/'); // generic template diff --git a/serve.sh b/serve.sh new file mode 100755 index 0000000..88881f4 --- /dev/null +++ b/serve.sh @@ -0,0 +1,2 @@ +#!/bin/sh +php -S localhost:8000 -d short_open_tag=true index.php -- cgit v1.2.3