Skip to content

Commit

Permalink
changed config to write htaccess file
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Clark Hess committed Mar 24, 2008
1 parent 0c57a4e commit 3b99611
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion htaccess → MTS/Source/htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -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]
15 changes: 12 additions & 3 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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";
Expand All @@ -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();
Expand Down
5 changes: 0 additions & 5 deletions htaccess2

This file was deleted.

13 changes: 5 additions & 8 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down

0 comments on commit 3b99611

Please sign in to comment.