Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/cydrobolt/polr.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTarulia <takuja@gmx.de>2015-09-26 05:04:45 +0300
committerTarulia <takuja@gmx.de>2015-09-26 05:04:45 +0300
commit64ca436d3971fcb5a83802efa28e0efe24493626 (patch)
tree78c88d1681a8e86dfe36dff115742e640fde914c
parente56fd23b39daaf364e0098bee12890753ac717a7 (diff)
[setup] Proper check for trailing slash on path
* also fixed double slash // in .nginx-config
-rw-r--r--setup.php21
1 files changed, 12 insertions, 9 deletions
diff --git a/setup.php b/setup.php
index d629846..10e124a 100644
--- a/setup.php
+++ b/setup.php
@@ -128,7 +128,10 @@ PHP;
require_once('lib-core.php');
$path = $_POST['path'];
- if (strlen($path) > 2) { // why 2? Is a folder like /r possible?
+ // check if path ends with / , validating it for .htaccess
+ if ( !(substr( $path, -1) == "/") ) {
+ die("<p class='alert alert-danger'>Path needs trailing slash (<code>/</code>).</p>");
+ } else {
$data = "<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase $path
@@ -157,18 +160,18 @@ PHP;
listen 80;
server_name %SERVER_NAME%;
index index.php
- location = $path/api {
- rewrite ^(.*)$ $path/api.php;
+ location = {$path}api {
+ rewrite ^(.*)$ {$path}api.php;
}
- location $path/ {
+ location {$path} {
if (!-e \$request_filename){
- rewrite ^$path/([a-zA-Z0-9]+)\?([a-zA-Z0-9]+)$ $path/r.php?u=$1&lkey=$2;
+ rewrite ^{$path}([a-zA-Z0-9]+)\?([a-zA-Z0-9]+)$ {$path}r.php?u=$1&lkey=$2;
}
- rewrite ^$path/([a-zA-Z0-9]+)/?$ $path/r.php?u=$1;
- rewrite ^$path/?\+([a-zA-Z0-9]+)$ $path/stats.php?bv=$1;
+ rewrite ^{$path}([a-zA-Z0-9]+)/?$ {$path}r.php?u=$1;
+ rewrite ^{$path}?\+([a-zA-Z0-9]+)$ {$path}stats.php?bv=$1;
}
- location $path/t {
- rewrite ^$path/t-([a-zA-Z0-9]+)/?$ $path/r.php?u=t-$1;
+ location {$path}t {
+ rewrite ^{$path}t-([a-zA-Z0-9]+)/?$ {$path}r.php?u=t-$1;
}
}";
$handle = fopen('.nginx-config', 'w');