From 3b9961169b7e25abd8080cb64ef51fbd17ff4dc1 Mon Sep 17 00:00:00 2001 From: Sean Clark Hess Date: Mon, 24 Mar 2008 12:06:45 -0600 Subject: [PATCH] changed config to write htaccess file --- htaccess => MTS/Source/htaccess | 2 +- config.php | 15 ++++++++++++--- htaccess2 | 5 ----- index.php | 13 +++++-------- 4 files changed, 18 insertions(+), 17 deletions(-) rename htaccess => MTS/Source/htaccess (64%) delete mode 100644 htaccess2 diff --git a/htaccess b/MTS/Source/htaccess similarity index 64% rename from htaccess rename to MTS/Source/htaccess index de0fb46..a734911 100644 --- a/htaccess +++ b/MTS/Source/htaccess @@ -2,4 +2,4 @@ Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^(.*[^/])/?$ /~sean/mts/index.php?source=$1 [QSA,L] \ No newline at end of file +RewriteRule ^(.*[^/])/?$ /index.php?source=$1 [QSA,L] \ No newline at end of file diff --git a/config.php b/config.php index e72f899..ed79f96 100755 --- a/config.php +++ b/config.php @@ -31,7 +31,8 @@ //////////////////////////////////////////////////////////////////////////////// */ - $userspath = "MTS/Source/users.php"; + $userspath = "MTS/Source/users.php"; + $htaccesspath = "MTS/Source/htaccess"; if (file_exists($userspath)) { ?>

Config Complete

The users file already exists \"$adminpass\",\n"; $userstext .= ");\n"; @@ -58,8 +59,16 @@ { echo "

User File Writing Error

MTS was unable to create users.php, the file that stores login information.

"; exit(); - } + }*/ + + // 2 // Generate .htaccess + $rooturl = preg_replace(':/[^/]*$:i','/',$_SERVER['REQUEST_URI']); + $htaccess = file_get_contents($htaccesspath); + $htaccess = preg_replace(':/index:i', $rooturl.'index', $htaccess); + if (!file_put_contents('.htaccess', $htaccess)) + echo "

htaccess error

MTS was unable to create your .htaccess file $htaccess foo

"; + // 4 // Redirect echo "User Created
Return to your default wiki"; exit(); diff --git a/htaccess2 b/htaccess2 deleted file mode 100644 index 6f752f6..0000000 --- a/htaccess2 +++ /dev/null @@ -1,5 +0,0 @@ -Options +FollowSymLinks -RewriteEngine On -# RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^(.*\.html?)$ /demo/index.php?htmlsource=$1 [QSA,L] \ No newline at end of file diff --git a/index.php b/index.php index e0081db..d41240b 100755 --- a/index.php +++ b/index.php @@ -23,15 +23,12 @@ ////////////////////////////////////////////////////////////////////////////////*/ // PHP SOURCE // This file is copied as the php source for each file. - - if (isset($_GET['htmlsource'])) - $wikipath = $_GET['htmlsource']; + + if (isset($_GET['source'])) + $wikipath = preg_replace('/.htm.?$/i','', $_GET['source']).'.html'; - else if (isset($_GET['source'])) - $wikipath = $_GET['source'].'html'; - - else - $wikipath = 'defaultsource.html'; + //else + // $wikipath = 'defaultsource.html'; // $wikipath = isset($_GET['source']) ? $_GET['source'].'.html' : "defaultsource.html";