Permalink
Browse files

changed config to write htaccess file

  • Loading branch information...
1 parent 0c57a4e commit 3b9961169b7e25abd8080cb64ef51fbd17ff4dc1 Sean Clark Hess committed Mar 24, 2008
Showing with 18 additions and 17 deletions.
  1. +1 −1 { → MTS/Source}/htaccess
  2. +12 −3 config.php
  3. +0 −5 htaccess2
  4. +5 −8 index.php
@@ -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]
+RewriteRule ^(.*[^/])/?$ /index.php?source=$1 [QSA,L]
View
@@ -31,7 +31,8 @@
////////////////////////////////////////////////////////////////////////////////
*/
- $userspath = "MTS/Source/users.php";
+ $userspath = "MTS/Source/users.php";
+ $htaccesspath = "MTS/Source/htaccess";
if (file_exists($userspath))
{
?><h2>Config Complete</h2><p>The users file already exists</h2><?php
@@ -45,7 +46,7 @@
if (isset($adminpass) && isset($adminuser) && $adminpass != "" && $adminuser != "") {
// 1 // Create a new users.php with the admin password
- $userstext = "<?php\n";
+ /*$userstext = "<?php\n";
$userstext .= "\$users = array(\n";
$userstext .= "\t\"$adminuser\" => \"$adminpass\",\n";
$userstext .= ");\n";
@@ -58,8 +59,16 @@
{
echo "<h2>User File Writing Error</h2><p>MTS was unable to create users.php, the file that stores login information.</p>";
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 "<h2>htaccess error</h2><p>MTS was unable to create your .htaccess file $htaccess foo</p>";
+
// 4 // Redirect
echo "User Created<br><a href='index.php'>Return to your default wiki</a>";
exit();
View
@@ -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]
View
@@ -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";

0 comments on commit 3b99611

Please sign in to comment.