<?php
require("header.php");
require("forumfunctions.php");
if($_GET['act']==2)
{
unset($_SESSION['authenticated'], $_SESSION['username'], $_SESSION['password'], $_SESSION['rank']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Scribe - Free, click-efficient forum that runs without databases.</title>
<link rel="stylesheet" type="text/css" href="Styles/main.css" />
<script type="text/javascript" src="javascript/nopop.js"></script>
<?
switch($_SESSION['theme'])
{
case "Storm": echo("<link rel=\"stylesheet\" type=\"text/css\" href=\"Styles/Storm.css\" />"); break;
case "Baloon": echo("<link rel=\"stylesheet\" type=\"text/css\" href=\"Styles/Baloon.css\" />"); break;
default: echo("<link rel=\"stylesheet\" type=\"text/css\" href=\"Styles/Storm.css\" />"); break;
}
?>
</head>
<body>
<div id="alignment">
<div id="main">
<div id="navi">
<?php
function listdir($dir, $urlmod)
{
if($dir!="" && file_exists($dir))
{
$x=0;
$songs;
foreach (glob($dir . "*") as $file)
{
if(is_dir($file))
{
listdir($file . "/", "");
}
elseif($file!=$dir . "index.php")
{
$file = str_replace(".php", "", $file);
$file = str_replace($dir, "", $file);
if($_GET['page']==$file)
{
echo("<a href=\"index.php?page=" . $file . $urlmod . "\" class=\"navs\">" . $file . "</a> ");
}
else
{
echo("<a href=\"index.php?page=" . $file . $urlmod . "\" class=\"nav\">" . $file . "</a> ");
}
}
$x++;
}
}
else
{
echo("<div class=\"pagesubtitle\">Error</div>Document path does not exist");
}
}
//Set extra parameters to be automatically added to navigation urls
$urlmod = "";
if(!isset($_SESSION['theme'])||$_SESSION['theme']!="")
{
$_SESSION['theme'] = "Storm";
}
//Set your document directory
$dir="docs/";
switch($_GET['theme'])
{
case "Storm": echo("<img src=\"Styles/Storm.jpg\" alt=\"header\" style=\"margin-bottom:5px;\"/>"); break;
case "Baloon": echo("<img src=\"Styles/Baloon.jpg\" alt=\"header\" style=\"margin-bottom:5px;\"/>"); break;
case "Redrock": echo("<img src=\"Styles/Redrock.jpg\" alt=\"header\" style=\"margin-bottom:5px;\"/>"); break;
default: echo("<img src=\"Styles/Storm.jpg\" alt=\"header\" style=\"margin-bottom:5px;\"/>"); break;
}
echo("<br />");
echo("<a href=\"index.php\" class=\"nav\">Home</a> <a href=\"forum.php?" . $urlmod . "\" class=\"navs\">Forum</a> ");
listdir($dir, $urlmod);
?>
<iframe style="visibility:hidden; width:0px; height:0px;" frameborder="0" src="http://www.halfempty.co.uk/giga/Scribe2/Development/hitrep.php"></iframe>
<iframe style="visibility:hidden; width:0px; height:0px;" src="http://www.halfempty.co.uk/giga/Scribe2/Development/addhit.php"></iframe>
</div>
<div id="navbar">
<a class="navlink" href="forum.php?act=6">Forum</a> |
<?php
//navbar content generation
if($_SESSION['authenticated']=="yes")
{
echo("
<span class=\"subtitle\">Logged in as " . $_SESSION['username'] . "
Rank: " . $_SESSION['rank'] . "</span>
| <a class=\"navlink\" href=\"forum.php?act=2\">Log Out</a>"
);
}
else
{
echo("
<a class=\"navlink\" href=\"forum.php?act=1\">Log In</a> |
<a class=\"navlink\" href=\"forum.php?act=7\">Register</a>");
}
?>
</div>
<div id="content">
<?php
switch($_GET['act'])
{
case 1:
//Log in
if(!isset($_SESSION['authenticated']))
{
echo("
<span class=\"pagetitle\">Log into " . $sitetitle . "</span><br><br>
<form action=\"forum.php?act=1\" method=\"post\">
Username:<br>
<input type=\"text\" name=\"username\"><br>
Password:<br>
<input type=\"password\" name=\"password\"><br>
<input type=\"submit\" name=\"login\" value=\"Log In\">
</form>
");
}
elseif($_SESSION['authenticated']!="yes")
{
echo("
<span class=\"pagetitle\">Log into " . $sitetitle . "</span><br><br>
Login attempt failed<br />
<form action=\"forum.php?act=1\" method=\"post\">
Username:<br>
<input type=\"text\" name=\"username\"><br>
Password:<br>
<input type=\"password\" name=\"password\"><br>
<input type=\"submit\" name=\"login\" value=\"Log In\">
</form>
");
}
else
{
echo("<span class=\"pagetitle\">Logged in</span>");
}
break;
case 2:
//Log out
echo("<span class=\"pagetitle\">
You have been logged out of " . $sitetitle . ".</span>
");
break;
case 3:
if($_SESSION['authenticated']=="yes")
{
//New Thread
if(isset($_POST['psubmit']))
{
$tid = nextthread($_POST['fid']);
//Filter Title
$tdata = filterdata( $_POST['title']);
$tdata = str_replace("\n", "",$tdata);
//Filter post
$pdata = filterdata( $_POST['pdata']);
$pdata = str_replace("\n", "<br />",$pdata);
threadgen($_POST['fid'],$tid,$tdata,$pdata, $sitetitle);
}
else
{
newthread($_GET['showforum'], $sitetitle);
}
}
else
{
echo("Error: You must be logged in to do that.");
}
break;
case 4:
//Reply
if($_SESSION['authenticated']=="yes")
{
if(isset($_POST['psubmit']))
{
$tid = nextthread($_POST['fid']);
$pdata = filterdata($_POST['pdata']);
$pdata = str_replace("\n", "<br />", $pdata);
replygen($_POST['tid'], $_POST['fid'], $pdata, $sitetitle);
}
else
{
newreply($_GET['thread'], $_GET['forum'], $sitetitle);
}
}
else
{
echo("Error: You must be logged in to do that.");
}
break;
case 5:
//Modules
break;
case 6:
//Idle/viewing forum
if(isset($_GET['showforum']) && $_GET['showforum']!="")
{
if(isset($_GET['thread']) && $_GET['thread']!="")
{
listposts($_GET['thread'], $_GET['showforum'], $sitetitle);
}
else
{
listforums($_GET['showforum'], $sitetitle);
}
}
else
{
listforums(0, $sitetitle);
}
break;
case 7:
//Register
if($_POST['confirm']=="Register")
{
register($_POST['username'],$_POST['password'],$_POST['cpassword'],$_POST['email']);
}
else
{
newmember();
}
break;
case 8:
generatenavigation($_GET['showforum'], $sitetitle);
echo("<div class=\"editorheader\">Delete threads");
echo("</div>");
echo("<div class=\"editorstack\">");
//Delete thread
if($_POST['forum']!="" && $_POST['threadstodelete']!="" && $_SESSION['rank'] =="admin" && $_POST['kill']=="Confirm")
{
$threadarray = explode("S",$_POST['threadstodelete']);
foreach($threadarray as $threaddel)
{
$threaddel = str_replace("S","",$threaddel);
$threaddel = str_replace("E","",$threaddel);
if($threaddel!="")
{
deletethread($_POST['forum'], $threaddel);
$dir = "forum/forums/" . $forum . "/threads/" . $threaddel;
rmdir($dir);
echo($dir . "<br />");
}
}
echo("<br />The thread(s) has been deleted.<br /><a href=\"forum.php?act=6&showforum=" . $_POST['fid'] . "\">Return to forum</a>");
}
elseif($_SESSION['rank'] =="admin")
{
echo("
<form action=\"forum.php?act=8\" method=\"post\">
Confirm deletion of the following threads:<br />
<input type=\"text\" id=\"threadstodelete\" name=\"threadstodelete\" /><br />
In the forum below:<br />
<input type=\"text\" name=\"forum\" value=\"" . $_GET['showforum'] . "\"/><br />
<input type=\"submit\" name=\"kill\" value=\"Confirm\" />
</form>
");
}
echo("</div>");
echo("<div class=\"editorheader\"></div>");
break;
case 9:
//Delete post
if($_GET['forum']!="" && $_GET['thread']!="" && $_SESSION['rank'] =="admin")
{
include_once("forum/forums/" . $_GET['forum'] . "/threads/" . $_GET['thread'] . "/info.php");
echo("
<form action=\"forum.php?act=9\" method=\"post\">
<input type=\"hidden\" name=\"forum\" value=\"" . $_GET['forum'] . "\"/>
<input type=\"hidden\" name=\"thread\" value=\"" . $_GET['thread'] . "\"/>
<input type=\"hidden\" name=\"post\" value=\"" . $_GET['post'] . "\"/>
Are you sure you want to delete the post in \"" . $threadtitle . "\"?<br />
<input type=\"submit\" name=\"kill\" value=\"Confirm\" />
</form>
");
}
elseif($_POST['forum']!="" && $_POST['thread']!="" && $_POST['post']!="" && $_SESSION['rank'] =="admin" && $_POST['kill']=="Confirm")
{
include_once("forum/forums/" . $_POST['forum'] . "/threads/" . $_POST['thread'] . "/info.php");
deletepost($_POST['forum'], $_POST['thread'], $_POST['post']);
echo("<br />The post in \"" . $threadtitle . "\" has been deleted.<br /><a href=\"forum.php?act=6&showforum=" . $_POST['forum'] . "&thread=" . $_POST['thread'] . "\">Return to thread</a>");
}
break;
case 10:
//Edit post
if($_SESSION['authenticated']=="yes")
{
if(isset($_POST['psubmit']))
{
$pdata = filterdata($_POST['pdata']);
$pdata = str_replace("\n", "<br />", $pdata);
editpost($_POST['fid'], $_POST['tid'], $_POST['pid'], $pdata, $sitetitle);
}
else
{
newedit($_GET['forum'], $_GET['thread'], $_GET['post'], $sitetitle);
}
}
else
{
echo("Error: You must be logged in to do that.");
}
break;
case 11:
//Registered members
generatenavigation($_GET['showforum'], $sitetitle);
echo("<div class=\"editorheader\">Registered members");
echo("</div>");
echo("<div class=\"editorstack\">");
//Members
$dir = opendir("regged");
$counter = 1;
while (($member = readdir($dir))!==false)
{
if($member!="." && $member!="..")
{
$member = str_replace(".php", "", "$member");
echo $counter . " - " . $member;
if($_SESSION['rank']=="admin")
{
echo(" <a href=\"forum.php?act=12&username=" . $member . "\"><img border=\"0\" src=\"gfx/member.gif\" alt=\" [Moderate]\"></a>");
}
echo("<br />");
$counter++;
}
}
closedir($dir);
echo("</div>");
echo("<div class=\"editorheader\"></div>");
break;
case 12:
//Member edit
generatenavigation($_GET['showforum'], $sitetitle);
echo("<div class=\"editorheader\">Member Edit");
echo("</div>");
echo("<div class=\"editorstack\">");
if($_SESSION['rank']=="admin" && isset($_POST['promote']))
{
changeranks($_POST['mid'],$_POST['aid']);
}
elseif(isset($_POST['deluser']) && $_SESSION['rank'] =="admin")
{
//Delete user
deleteuser($_POST['mid']);
}
else
{
?>
<div class="pagesubtitle">Change Member Rank</div>
Currently only the rank of 'admin' is given special rights.
<form action="forum.php?act=12" method="post">
Username: <br />
<input name="mid" value="<?php echo($_GET['username']); ?>"/>
<br />
Rank:<br />
<input name="aid"/><br />
<input type="submit" name="promote" value="Confirm" />
</form>
<div class="pagesubtitle">Delete user</div>
<form action="forum.php?act=12" method="post">
<input name="mid" value="<?php echo($_GET['username']); ?>" />
<input type="submit" name="deluser" value="Confirm" />
</form>
<?
}
echo("</div>");
echo("<div class=\"editorheader\"></div>");
break;
case 13:
//Delete thread
if($_GET['forum']!="" && $_GET['thread']!="" && $_SESSION['rank'] =="admin")
{
deletethread($_GET['forum'], $_GET['thread']);
$dir = "forum/forums/" . $_GET['forum'] . "/threads/" . $_GET['thread'];
@rmdir($dir);
echo("<br /><a href=\"forum.php?showforum=" . $_GET['forum'] . "\">Return to forum</a>");
}
break;
case 14:
if(isset($_GET['target'])&&$_SESSION['rank']=="admin")
{
echo("<div class=\"pagesubtitle\">Forums</div>(Select any forum to view helpful information about it)<br />");
forumlist();
getForumInfo($_GET['target']);
}
else
{
echo("<div class=\"pagesubtitle\">Error</div>You are not authorized to view this");
}
break;
default:
//Idle/viewing forum
listforums(0, $sitetitle);
break;
}
//INFO CENTER
//the time
$thetime = date("l, g:i:s O j/M/y");
$timestamp = date('U');
//registered users
$dir = opendir("regged");
$regged = 0;
$memberarray;
$membersOn = false;
while (($member = readdir($dir))!==false)
{
if($member!="." && $member!="..")
{
$path = "regged/" . $member;
$lastmodded=filemtime($path);
$difference=$timestamp-$lastmodded;
$member = str_replace(".php", "", $member);
if($difference<=900)
{
$lastactive[10000000]="";
while(array_key_exists($difference, $lastactive))
{
$difference++;
}
$lastactive[$difference]=$member;
$membersOn = true;
}
$regged++;
}
}
closedir($dir);
?>
<div id="footer">
<?php
echo("
Threads flagged:<input readonly=\"readonly\" id=\"markedthreads\" type=\"text\" />
<a href=\"javascript:clearMarked(" . $forumReserved . ");\"><img border=\"0\" src=\"gfx/clear.gif\" alt=\"Clear\" /></a>
<a href=\"javascript:clearCookies(" . $forumReserved . ");\"><img border=\"0\" src=\"gfx/clear-all.gif\" alt=\"Clear all\" /></a>");
if($_SESSION['rank']=="admin")
{
echo(" <a href=\"forum.php?act=8&showforum=" . $forumReserved . "\"><img src=\"gfx/delete.gif\" alt=\"Delete\" border=\"none\" /></a>");
echo(" <a href=\"forum.php?act=12\"><img src=\"gfx/member.gif\" alt=\"Member Moderation\" border=\"none\" /></a>");
echo(" <a href=\"forum.php?act=14&target=" . $forumReserved . "\"><img src=\"gfx/forummanager.gif\" alt=\"Forum Manager\" border=\"none\" /></a><br />");
}
echo("<form action=\"#\"><input type=\"hidden\" id=\"fidjs\" value=\"" . $forumReserved . "\" />");
echo("<input type=\"hidden\" id=\"threadstodelete\" value=\"\" /></form>");
//Count registered users
$dir = opendir("regged");
$regged = 0;
while (($member = readdir($dir))!==false)
{
if($member!="." && $member!="..")
{
$regged++;
}
}
closedir($dir);
//Uncomment the following few lines to log unique ip addresses.
/*
$cache=file_get_contents("activecache.txt");
$count=explode("]", $cache);
$unique = count($count)-1;
if(!strstr($cache, "[" . $_SERVER["REMOTE_ADDR"] . "]"))
{
putcontents("activecache.txt", "[" . $_SERVER["REMOTE_ADDR"] . "]\n", 'a+');
}
*/
echo("<br />It is now " . $thetime);
echo("<br />We have <a href=\"forum.php?act=11\">" . $regged . " registered users.</a>");
?>
<br />
Powered by: Scribe 0.2
</div>
</div>
</div>
</div>
</body>
</html>