/blog/add-post.php |
---|
1,91 → 1,96 |
<?php |
function getParentID() |
{ |
if (isset($_GET['id'])) |
{ |
return $_GET['id']; |
} |
else |
{ |
return -1; |
} |
} |
require '../_taios.php'; |
$page = new Taios_Page('Blog Posts', '../'); |
$page->checkLoggedIn(); |
$error = ''; |
if (isset($_POST['post'])) |
{ |
$title = $_POST['title']; |
$content = $_POST['content']; |
$parentID = $_POST['parentID']; |
$category = $_POST['category']; |
if (empty($title)) |
{ |
$error = "No Title Specified"; |
} |
else if (empty($content)) |
{ |
$error = "No Content Specified"; |
} |
else if (empty($parentID)) |
{ |
$error = "No Parent ID Specified"; |
} |
else |
{ |
$page->query('INSERT INTO BlogPosts VALUES(0, ' . $parentID . ', "' . $page->getLoggedInUser()->ID . '", "' . $title . '", "' . $content . '", NOW(), "' . $category . '", 0)'); |
$page->redirect('index.php'); |
} |
} |
$page->drawHeader(); |
$page->drawBlogCategoriesMenu(); |
$page->drawMiddle(); |
if (!empty($error)) |
{ |
$page->drawError($error, false); |
} |
?> |
<form action="add-post.php?id=<?php echo getParentID(); ?>" method="post"> |
<table> |
<tr> |
<td class="bold">Title: </td> |
<td><input type="text" name="title" /></td> |
</tr> |
<tr> |
<td class="bold">Content: </td> |
<td><textarea name="content" style="width: 500px; height: 300px;"></textarea></td> |
</tr> |
<tr> |
<td class="bold">Catagory: </td> |
<td><input type="text" name="category" /></td> |
</tr> |
<input type="hidden" name="post" value="yes" /> |
<?php |
write('<input type="hidden" name="parentID" value="' . getParentID() . '" />'); |
?> |
<tr> |
<td class="bold"></td> |
<td><input type="submit" value="Post" /></td> |
</tr> |
</table> |
</form> |
<?php |
$page->drawFooter(); |
?> |
<?php |
function getParentID() |
{ |
if (isset($_GET['id'])) |
{ |
return $_GET['id']; |
} |
else |
{ |
return -1; |
} |
} |
require '../_taios.php'; |
$page = new Taios_Page('Blog Posts', '../'); |
$page->checkLoggedIn(); |
$error = ''; |
if (isset($_POST['post'])) |
{ |
$title = $_POST['title']; |
$content = $_POST['content']; |
$parentID = $_POST['parentID']; |
$category = $_POST['category']; |
if (empty($title)) |
{ |
$error = "No Title Specified"; |
} |
else if (empty($content)) |
{ |
$error = "No Content Specified"; |
} |
else if (empty($parentID)) |
{ |
$error = "No Parent ID Specified"; |
} |
else |
{ |
if ($page->isUserNormal($page->getLoggedInUser()) && $parentID == -1) |
{ |
$page->drawError('You do not have permission to access this page.'); |
} |
$page->query('INSERT INTO BlogPosts VALUES(0, ' . $parentID . ', "' . $page->getLoggedInUser()->ID . '", "' . $title . '", "' . $content . '", NOW(), "' . $category . '", 0)'); |
$page->redirect('post.php?id=' . $parentID); |
} |
} |
$page->drawHeader(); |
$page->drawBlogCategoriesMenu(); |
$page->drawMiddle(); |
if (!empty($error)) |
{ |
$page->drawError($error, false); |
} |
?> |
<form action="add-post.php?id=<?php echo getParentID(); ?>" method="post"> |
<table> |
<tr> |
<td class="bold">Title: </td> |
<td><input type="text" name="title" /></td> |
</tr> |
<tr> |
<td class="bold">Content: </td> |
<td><textarea name="content" style="width: 500px; height: 300px;"></textarea></td> |
</tr> |
<tr> |
<td class="bold">Catagory: </td> |
<td><input type="text" name="category" /></td> |
</tr> |
<input type="hidden" name="post" value="yes" /> |
<?php |
write('<input type="hidden" name="parentID" value="' . getParentID() . '" />'); |
?> |
<tr> |
<td class="bold"></td> |
<td><input type="submit" value="Post" /></td> |
</tr> |
</table> |
</form> |
<?php |
$page->drawFooter(); |
?> |
/blog/edit-post.php |
---|
4,12 → 4,18 |
$page = new Taios_Page('Blog Posts', '../'); |
if (!isset($_GET['id'])) |
if (isset($_GET['id'])) |
{ |
$id = $_GET['id']; |
else if (!isset($_POST['id'])) |
} |
else if (isset($_POST['id'])) |
{ |
$id = $_POST['id']; |
} |
else |
$page->redirect("index.php"); |
{ |
$page->drawError('No ID set.'); |
} |
$page->checkLoggedIn(); |
37,7 → 43,7 |
} |
else |
{ |
$page->query('update table BlogPosts set Content="' . $content . '", Title="' . $title . '", Category="' . $category . '" where ID=' . $id); |
$page->query('UPDATE BlogPosts SET Content = "' . $content . '", Title = "' . $title . '", Category = "' . $category . '" WHERE ID = ' . $id); |
$page->redirect('index.php'); |
} |
} |
53,7 → 59,7 |
?> |
<form action="add-post.php?id=<?php echo getParentID(); ?>" method="post"> |
<form action="edit-post.php" method="post"> |
<table> |
<tr> |
<td class="bold">Title: </td> |
69,7 → 75,7 |
</tr> |
<?php |
write('<input type="hidden" name="is" value="' . $id . '" />'); |
write('<input type="hidden" name="id" value="' . $id . '" />'); |
?> |
<tr> |
/admin/account-do.php |
---|
1,53 → 1,53 |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Update Account', '../'); |
$userID = $page->getPostID(); |
$page->checkLoggedIn(); |
$accessID = $_POST['accessID']; |
$password = $_POST['password']; |
$email = $_POST['email']; |
$name = $_POST['name']; |
$user = $page->getUserByID($userID); |
if (($page->getLoggedInUser()->ID == $userID || $page->isUserAdmin($page->getLoggedInUser())) && $user) |
{ |
if (isset($accessID) && $page->isUserAdmin($page->getLoggedInUser())) |
{ |
$page->query('UPDATE Users SET AccessID = "' . $accessID . '" WHERE ID = ' . $userID); |
} |
if (!empty($password)) |
{ |
$page->query('UPDATE Users SET Password = "' . sha1($password) . '" WHERE ID = ' . $userID); |
} |
if (!empty($email)) |
{ |
$page->query('UPDATE Users SET EmailAddress = "' . $email . '" WHERE ID = ' . $userID); |
} |
if (!empty($name)) |
{ |
$page->query('UPDATE Users SET Name = "' . $name . '" WHERE ID = ' . $userID); |
} |
} |
else |
{ |
if (!$user) |
{ |
drawError('No such user, #' . $userID); |
} |
else |
{ |
drawError('You do not have permission to access this page.'); |
} |
} |
$page->redirect('account.php?id=' . $userID); |
?> |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Update Account', '../'); |
$userID = $page->getPostID(); |
$page->checkLoggedIn(); |
$accessID = $_POST['accessID']; |
$password = $_POST['password']; |
$email = $_POST['email']; |
$name = $_POST['name']; |
$user = $page->getUserByID($userID); |
if (($page->getLoggedInUser()->ID == $userID || $page->isUserAdmin($page->getLoggedInUser())) && $user) |
{ |
if (isset($accessID) && $page->isUserAdmin($page->getLoggedInUser())) |
{ |
$page->query('UPDATE Users SET AccessID = "' . $accessID . '" WHERE ID = ' . $userID); |
} |
if (!empty($password)) |
{ |
$page->query('UPDATE Users SET Password = "' . sha1($password) . '" WHERE ID = ' . $userID); |
} |
if (!empty($email)) |
{ |
$page->query('UPDATE Users SET EmailAddress = "' . $email . '" WHERE ID = ' . $userID); |
} |
if (!empty($name)) |
{ |
$page->query('UPDATE Users SET Name = "' . $name . '" WHERE ID = ' . $userID); |
} |
} |
else |
{ |
if (!$user) |
{ |
drawError('No such user, #' . $userID); |
} |
else |
{ |
drawError('You do not have permission to access this page.'); |
} |
} |
$page->redirect('account.php?id=' . $userID); |
?> |
/admin/account.php |
---|
1,60 → 1,60 |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Manage Account', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
$page->checkLoggedIn(); |
$userID = $page->getGetID(); |
$user = $page->getUserByID($userID); |
if (($page->getLoggedInUser()->ID == $userID || $page->isUserAdmin($page->getLoggedInUser())) && $user) |
{ |
?> |
<p class="bold">Here you can edit your account.</p> |
<p>Only change the password value if you want to change your password.</p> |
<br /> |
<form action="account-do.php" method="POST"> |
<table> |
<tr><td class="bold">ID: </td><td><?php echo $user->ID; ?></td></tr> |
<?php |
if ($page->isUserAdmin($page->getLoggedInUser())) |
{ |
write('<tr><td class="bold">AccessID: </td><td><input type="text" name="accessID" value="' . $user->accessID . '" /></td></tr>'); |
} |
else |
{ |
write('<tr><td class="bold">AccessID: </td><td>' . $user->accessID . '</td></tr>'); |
} |
?> |
<tr><td class="bold">Username: </td><td><?php echo $user->username; ?></td></tr> |
<tr><td class="bold">Password: </td><td><input type="password" name="password" /></td></tr> |
<tr><td class="bold">Email Address: </td><td><input type="text" name="email" value="<?php echo $user->emailAddress; ?>" /></td></tr> |
<tr><td class="bold">Name: </td><td><input type="text" name="name" value="<?php echo $user->name; ?>" /></td></tr> |
<tr><td></td><td><input type="submit" value="Update Account" /></td></tr> |
</table> |
</form> |
<?php |
} |
else |
{ |
if (!$user) |
{ |
drawError('No such user, #' . $userID); |
} |
else |
{ |
drawError('You do not have permission to access this page.'); |
} |
} |
$page->drawFooter(); |
?> |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Manage Account', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
$page->checkLoggedIn(); |
$userID = $page->getGetID(); |
$user = $page->getUserByID($userID); |
if (($page->getLoggedInUser()->ID == $userID || $page->isUserAdmin($page->getLoggedInUser())) && $user) |
{ |
?> |
<p class="bold">Here you can edit your account.</p> |
<p>Only change the password value if you want to change your password.</p> |
<br /> |
<form action="account-do.php" method="POST"> |
<table> |
<tr><td class="bold">ID: </td><td><?php echo $user->ID; ?></td></tr> |
<?php |
if ($page->isUserAdmin($page->getLoggedInUser())) |
{ |
write('<tr><td class="bold">AccessID: </td><td><input type="text" name="accessID" value="' . $user->accessID . '" /></td></tr>'); |
} |
else |
{ |
write('<tr><td class="bold">AccessID: </td><td>' . $user->accessID . '</td></tr>'); |
} |
?> |
<tr><td class="bold">Username: </td><td><?php echo $user->username; ?></td></tr> |
<tr><td class="bold">Password: </td><td><input type="password" name="password" /></td></tr> |
<tr><td class="bold">Email Address: </td><td><input type="text" name="email" value="<?php echo $user->emailAddress; ?>" /></td></tr> |
<tr><td class="bold">Name: </td><td><input type="text" name="name" value="<?php echo $user->name; ?>" /></td></tr> |
<tr><td></td><td><input type="submit" value="Update Account" /></td></tr> |
</table> |
</form> |
<?php |
} |
else |
{ |
if (!$user) |
{ |
drawError('No such user, #' . $userID); |
} |
else |
{ |
drawError('You do not have permission to access this page.'); |
} |
} |
$page->drawFooter(); |
?> |
/admin/all-blog-posts.php |
---|
1,60 → 1,60 |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Manage All Blog Posts', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
$page->checkLoggedIn(); |
if ($page->isUserAdmin($page->getLoggedInUser())) |
{ |
write('<p class="bold">Use this to manage all the blog posts on the Tim32 Website.</p><br />'); |
write('<table>'); |
write('<tr>'); |
write('<td class="bold">ID</td>'); |
write('<td class="bold">Parent</td>'); |
write('<td class="bold">Author</td>'); |
write('<td class="bold">Title</td>'); |
write('<td class="bold">Content</td>'); |
write('<td class="bold">Date Posted</td>'); |
write('<td class="bold">Category</td>'); |
write('<td class="bold">Spam</td>'); |
write('</tr>'); |
$ids = $page->findIDs('BlogPosts'); |
for ($i = 0; $i < count($ids); $i++) |
{ |
$post = $page->getBlogPost($ids[$i]); |
write('<tr>'); |
write('<td><a href="../blog/edit-post.php?id=' . $post->ID . '">' . $post->ID . '</a></td>'); |
if ($post->parent == -1) |
{ |
write('<td style="color: #444444;">No Parent</td>'); |
} |
else |
{ |
write('<td>' . $post->parent->title . '</td>'); |
} |
write('<td><a href="account.php?id=' . $post->author->ID . '">' . $post->author->name . '</a></td>'); |
write('<td>' . $post->title . '</td>'); |
write('<td>' . $post->content . '</td>'); |
write('<td>' . date('j/m/Y H:i', $post->datePosted) . '</td>'); |
write('<td>' . $post->category . '</td>'); |
write('<td>' . $post->spam . '</td>'); |
write('</tr>'); |
} |
write('</table>'); |
} |
else |
{ |
drawError('You do not have permission to access this page.'); |
} |
$page->drawFooter(); |
?> |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Manage All Blog Posts', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
$page->checkLoggedIn(); |
if ($page->isUserAdmin($page->getLoggedInUser())) |
{ |
write('<p class="bold">Use this to manage all the blog posts on the Tim32 Website.</p><br />'); |
write('<table>'); |
write('<tr>'); |
write('<td class="bold">ID</td>'); |
write('<td class="bold">Parent</td>'); |
write('<td class="bold">Author</td>'); |
write('<td class="bold">Title</td>'); |
write('<td class="bold">Content</td>'); |
write('<td class="bold">Date Posted</td>'); |
write('<td class="bold">Category</td>'); |
write('<td class="bold">Spam</td>'); |
write('</tr>'); |
$ids = $page->findIDs('BlogPosts'); |
for ($i = 0; $i < count($ids); $i++) |
{ |
$post = $page->getBlogPost($ids[$i]); |
write('<tr>'); |
write('<td><a href="../blog/edit-post.php?id=' . $post->ID . '">' . $post->ID . '</a></td>'); |
if ($post->parent == -1) |
{ |
write('<td style="color: #444444;">No Parent</td>'); |
} |
else |
{ |
write('<td>' . $post->parent->title . '</td>'); |
} |
write('<td><a href="account.php?id=' . $post->author->ID . '">' . $post->author->name . '</a></td>'); |
write('<td>' . $post->title . '</td>'); |
write('<td>' . $post->content . '</td>'); |
write('<td>' . date('j/m/Y H:i', $post->datePosted) . '</td>'); |
write('<td>' . $post->category . '</td>'); |
write('<td>' . $post->spam . '</td>'); |
write('</tr>'); |
} |
write('</table>'); |
} |
else |
{ |
drawError('You do not have permission to access this page.'); |
} |
$page->drawFooter(); |
?> |
/admin/all-accounts.php |
---|
1,51 → 1,51 |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Manage All Accounts', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
$page->checkLoggedIn(); |
if ($page->isUserAdmin($page->getLoggedInUser())) |
{ |
write('<p class="bold">Use this to manage all the accounts on the Tim32 Website.</p><br />'); |
write('<table>'); |
write('<tr>'); |
write('<td class="bold">ID</td>'); |
write('<td class="bold">AccessID</td>'); |
write('<td class="bold">Username</td>'); |
write('<td class="bold">Password</td>'); |
write('<td class="bold">Name</td>'); |
write('<td class="bold">Email Address</td>'); |
write('<td class="bold">Challenge ID</td>'); |
write('</tr>'); |
$ids = $page->findIDs('Users'); |
for ($i = 0; $i < count($ids); $i++) |
{ |
$user = $page->getUserByID($ids[$i]); |
write('<tr>'); |
write('<td><a href="account.php?id=' . $user->ID . '">' . $user->ID . '</a></td>'); |
write('<td>' . $user->accessID . '</td>'); |
write('<td>' . $user->username . '</td>'); |
write('<td>' . $user->password . '</td>'); |
write('<td>' . $user->name . '</td>'); |
write('<td>' . $user->emailAddress . '</td>'); |
write('<td>' . $user->challengeID . '</td>'); |
write('</tr>'); |
} |
write('</table>'); |
} |
else |
{ |
drawError('You do not have permission to access this page.'); |
} |
$page->drawFooter(); |
?> |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Manage All Accounts', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
$page->checkLoggedIn(); |
if ($page->isUserAdmin($page->getLoggedInUser())) |
{ |
write('<p class="bold">Use this to manage all the accounts on the Tim32 Website.</p><br />'); |
write('<table>'); |
write('<tr>'); |
write('<td class="bold">ID</td>'); |
write('<td class="bold">AccessID</td>'); |
write('<td class="bold">Username</td>'); |
write('<td class="bold">Password</td>'); |
write('<td class="bold">Name</td>'); |
write('<td class="bold">Email Address</td>'); |
write('<td class="bold">Challenge ID</td>'); |
write('</tr>'); |
$ids = $page->findIDs('Users'); |
for ($i = 0; $i < count($ids); $i++) |
{ |
$user = $page->getUserByID($ids[$i]); |
write('<tr>'); |
write('<td><a href="account.php?id=' . $user->ID . '">' . $user->ID . '</a></td>'); |
write('<td>' . $user->accessID . '</td>'); |
write('<td>' . $user->username . '</td>'); |
write('<td>' . $user->password . '</td>'); |
write('<td>' . $user->name . '</td>'); |
write('<td>' . $user->emailAddress . '</td>'); |
write('<td>' . $user->challengeID . '</td>'); |
write('</tr>'); |
} |
write('</table>'); |
} |
else |
{ |
drawError('You do not have permission to access this page.'); |
} |
$page->drawFooter(); |
?> |
/admin/index.php |
---|
1,27 → 1,27 |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Administration', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
$page->checkLoggedIn(); |
$user = $page->getLoggedInUser(); |
write('<h4><a href="account.php?id=' . $user->ID. '">Manage Account</a></h4>'); |
if ($page->isUserAdmin($user)) |
{ |
write('<h4><a href="all-accounts.php">Manage All Accounts</a></h4>'); |
write('<h4><a href="all-blog-posts.php">Manage All Blog Posts</a></h4>'); |
write('<h4><a href="all-projects.php">Manage All Projects</a></h4>'); |
write('<h4><a href="all-forum-categories.php">Manage All Forum Categories</a></h4>'); |
write('<h4><a href="all-forum-topics.php">Manage All Forum Topics</a></h4>'); |
write('<h4><a href="all-forum-posts.php">Manage All Forum Posts</a></h4>'); |
} |
$page->drawFooter(); |
?> |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Administration', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
$page->checkLoggedIn(); |
$user = $page->getLoggedInUser(); |
write('<h4><a href="account.php?id=' . $user->ID. '">Manage Account</a></h4>'); |
if ($page->isUserAdmin($user)) |
{ |
write('<h4><a href="all-accounts.php">Manage All Accounts</a></h4>'); |
write('<h4><a href="all-blog-posts.php">Manage All Blog Posts</a></h4>'); |
write('<h4><a href="all-projects.php">Manage All Projects</a></h4>'); |
write('<h4><a href="all-forum-categories.php">Manage All Forum Categories</a></h4>'); |
write('<h4><a href="all-forum-topics.php">Manage All Forum Topics</a></h4>'); |
write('<h4><a href="all-forum-posts.php">Manage All Forum Posts</a></h4>'); |
} |
$page->drawFooter(); |
?> |
/projects/index.php |
---|
1,14 → 1,14 |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Projects', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
write('<br /><p class="bold">This page is currently under construction.</p>'); |
$page->drawFooter(); |
?> |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Projects', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
write('<br /><p class="bold">This page is currently under construction.</p>'); |
$page->drawFooter(); |
?> |
/404.php |
---|
1,28 → 1,28 |
<?php |
require '_taios.php'; |
$page = new Taios_Page('404'); |
$page->drawHeader(); |
write('<h3>Pages</h3>'); |
$page->drawMenuItem('Biggles', '/~biggles/'); |
$page->drawMenuItem('Freddie', '/~freddie/'); |
$page->drawMenuItem('Muzer', '/~muzer/'); |
$page->drawMenuItem('Sh4rk', '/~szabot/'); |
$page->drawMenuItem('Tom', '/~tom/'); |
$page->drawMiddle(); |
?> |
<p class="bold">404 - Page not found</p> |
<p>The page you requested could not be found.</p> |
<h4>Useful Links</h4> |
<?php |
$page->drawMenuItem('Tim32 Homepage', 'index.php'); |
$page->drawFooter(); |
?> |
<?php |
require '_taios.php'; |
$page = new Taios_Page('404'); |
$page->drawHeader(); |
write('<h3>Pages</h3>'); |
$page->drawMenuItem('Biggles', '/~biggles/'); |
$page->drawMenuItem('Freddie', '/~freddie/'); |
$page->drawMenuItem('Muzer', '/~muzer/'); |
$page->drawMenuItem('Sh4rk', '/~szabot/'); |
$page->drawMenuItem('Tom', '/~tom/'); |
$page->drawMiddle(); |
?> |
<p class="bold">404 - Page not found</p> |
<p>The page you requested could not be found.</p> |
<h4>Useful Links</h4> |
<?php |
$page->drawMenuItem('Tim32 Homepage', 'index.php'); |
$page->drawFooter(); |
?> |
/index.php |
---|
1,39 → 1,39 |
<?php |
require '_taios.php'; |
$page = new Taios_Page('Home'); |
$page->drawHeader(); |
write('<h3>Pages</h3>'); |
$page->drawMenuItem('Biggles', '/~biggles/'); |
$page->drawMenuItem('Freddie', '/~freddie/'); |
$page->drawMenuItem('Muzer', '/~muzer/'); |
$page->drawMenuItem('Sh4rk', '/~szabot/'); |
$page->drawMenuItem('Tom', '/~tom/'); |
$page->drawMiddle(); |
?> |
<p class="bold">Welcome to Tim32!</p> |
<p>Tim32 is a 10 year-old laptop running Ubuntu Server Edition 10.04.</p> |
<br /> |
<h3>Latest Blog Posts</h3> |
<?php |
$ids = $page->findIDs('BlogPosts', 'WHERE ParentID = -1 ORDER BY DatePosted DESC'); |
for ($i = 0; $i < 5 && $i < count($ids); $i++) |
{ |
$id = $ids[$i]; |
$post = $page->getBlogPost($id); |
write('<h4>' . $post->title. '</h4>'); |
write('<h5 style="color: #666666;">Posted On ' . date('l j F Y', $post->datePosted) . ' by ' . $post->user->name . ' (' . $post->user->username . ')</h5>'); |
write('<p>' . $post->content . '</p>'); |
write('<br />'); |
} |
$page->drawFooter(); |
?> |
<?php |
require '_taios.php'; |
$page = new Taios_Page('Home'); |
$page->drawHeader(); |
write('<h3>Pages</h3>'); |
$page->drawMenuItem('Biggles', '/~biggles/'); |
$page->drawMenuItem('Freddie', '/~freddie/'); |
$page->drawMenuItem('Muzer', '/~muzer/'); |
$page->drawMenuItem('Sh4rk', '/~szabot/'); |
$page->drawMenuItem('Tom', '/~tom/'); |
$page->drawMiddle(); |
?> |
<p class="bold">Welcome to Tim32!</p> |
<p>Tim32 is a 10 year-old laptop running Ubuntu Server Edition 10.04.</p> |
<br /> |
<h3>Latest Blog Posts</h3> |
<?php |
$ids = $page->findIDs('BlogPosts', 'WHERE ParentID = -1 ORDER BY DatePosted DESC'); |
for ($i = 0; $i < 5 && $i < count($ids); $i++) |
{ |
$id = $ids[$i]; |
$post = $page->getBlogPost($id); |
write('<h4>' . $post->title. '</h4>'); |
write('<h5 style="color: #666666;">Posted On ' . date('l j F Y', $post->datePosted) . ' by ' . $post->user->name . ' (' . $post->user->username . ')</h5>'); |
write('<p>' . $post->content . '</p>'); |
write('<br />'); |
} |
$page->drawFooter(); |
?> |
/login-do.php |
---|
1,37 → 1,37 |
<?php |
require '_taios.php'; |
$page = new Taios_Page('Login'); |
$username = $_POST['username']; |
$password = $_POST['password']; |
$remember = $_POST['remember'] == 'yes'; |
if (empty($username)) |
{ |
$page->redirect('login.php?error=No Username Specified'); |
} |
if (empty($password)) |
{ |
$page->redirect('login.php?error=No Password Specified'); |
} |
$user = $page->getUserByUsername($username); |
if (!$user || $user->password != sha1($password)) |
{ |
$page->redirect('login.php?error=Incorrect Username or Password'); |
} |
$expires = -1; |
if ($remember) |
{ |
$expires = time() + 60 * 60 * 24 * 30; |
} |
setcookie('Tim32_Login', $user->username . '|~|' . $user->password, $expires, '/'); |
$page->redirect('index.php'); |
?> |
<?php |
require '_taios.php'; |
$page = new Taios_Page('Login'); |
$username = $_POST['username']; |
$password = $_POST['password']; |
$remember = $_POST['remember'] == 'yes'; |
if (empty($username)) |
{ |
$page->redirect('login.php?error=No Username Specified'); |
} |
if (empty($password)) |
{ |
$page->redirect('login.php?error=No Password Specified'); |
} |
$user = $page->getUserByUsername($username); |
if (!$user || $user->password != sha1($password)) |
{ |
$page->redirect('login.php?error=Incorrect Username or Password'); |
} |
$expires = -1; |
if ($remember) |
{ |
$expires = time() + 60 * 60 * 24 * 30; |
} |
setcookie('Tim32_Login', $user->username . '|~|' . $user->password, $expires, '/'); |
$page->redirect('index.php'); |
?> |
/login.php |
---|
1,48 → 1,48 |
<?php |
require '_taios.php'; |
$page = new Taios_Page('Login'); |
$page->drawHeader(); |
$page->drawMiddle(); |
?> |
<p class="bold">Here you can login to Tim32 using your Tim32 account.</p> |
<br /> |
<?php |
if (isset($_GET['error'])) |
{ |
$page->drawError($_GET['error'], false); |
} |
?> |
<form action="login-do.php" method="POST"> |
<table> |
<tr> |
<td class="bold">Username: </td> |
<td><input type="text" name="username" /></td> |
</tr> |
<tr> |
<td class="bold">Password: </td> |
<td><input type="password" name="password" /></td> |
</tr> |
<tr> |
<td class="bold">Remember Me: </td> |
<td><input type="checkbox" name="remember" value="yes" /></td> |
</tr> |
<tr> |
<td class="bold"></td> |
<td><input type="submit" value="Login" /></td> |
</tr> |
</table> |
</form> |
<?php |
$page->drawFooter(); |
?> |
<?php |
require '_taios.php'; |
$page = new Taios_Page('Login'); |
$page->drawHeader(); |
$page->drawMiddle(); |
?> |
<p class="bold">Here you can login to Tim32 using your Tim32 account.</p> |
<br /> |
<?php |
if (isset($_GET['error'])) |
{ |
$page->drawError($_GET['error'], false); |
} |
?> |
<form action="login-do.php" method="POST"> |
<table> |
<tr> |
<td class="bold">Username: </td> |
<td><input type="text" name="username" /></td> |
</tr> |
<tr> |
<td class="bold">Password: </td> |
<td><input type="password" name="password" /></td> |
</tr> |
<tr> |
<td class="bold">Remember Me: </td> |
<td><input type="checkbox" name="remember" value="yes" /></td> |
</tr> |
<tr> |
<td class="bold"></td> |
<td><input type="submit" value="Login" /></td> |
</tr> |
</table> |
</form> |
<?php |
$page->drawFooter(); |
?> |
/logout-do.php |
---|
1,6 → 1,6 |
<?php |
setcookie('Tim32_Login', '', -1, '/'); |
header('Location: index.php'); |
?> |
<?php |
setcookie('Tim32_Login', '', -1, '/'); |
header('Location: index.php'); |
?> |
/wiki/index.php |
---|
1,14 → 1,14 |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Wiki', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
write('<br /><p class="bold">This page is currently under construction.</p>'); |
$page->drawFooter(); |
?> |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Wiki', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
write('<br /><p class="bold">This page is currently under construction.</p>'); |
$page->drawFooter(); |
?> |
/_taios.php |
---|
1,432 → 1,432 |
<?php |
require '_config.php'; |
class Taios_Page |
{ |
function __construct($title, $url = "") |
{ |
$this->title = $title; |
$this->url = $url; |
$this->drawnHeader = false; |
$this->drawnMiddle = false; |
$this->drawnFooter = false; |
$this->db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD); |
if (!$this->db) |
{ |
$this->drawError('Failed to connect to database: ' . mysql_error()); |
} |
if (!mysql_select_db('Tim32')) |
{ |
$this->drawError('Failed to select database: ' . mysql_error()); |
} |
} |
function drawHeader() |
{ |
if (!$this->drawnHeader) |
{ |
write('<!DOCTYPE html>'); |
write('<html>'); |
write('<head>'); |
write('<meta http-equiv="Content-Type" content="text/html;charset=utf-8">'); |
write('<title>Tim32 · ' . $this->title . '</title>'); |
write('<link href="' . $this->url . 'styles.css" rel="stylesheet" type="text/css" media="screen">'); |
write('</head>'); |
write('<body>'); |
write('<div class="sidebar">'); |
write('<div class="sidebar-header">'); |
write('<h1>Tim32</h1>'); |
write('</div>'); |
write('<div class="sidebar-menu">'); |
$this->drawMenuItem('Home', 'index.php'); |
$this->drawMenuItem('Blog', 'blog/'); |
$this->drawMenuItem('Projects', 'projects/'); |
$this->drawMenuItem('Forums', 'forums/'); |
$this->drawMenuItem('Wiki', 'wiki/'); |
$this->drawMenuItem('Photos', 'photos/'); |
write('<br />'); |
if ($this->isLoggedIn()) |
{ |
$this->drawMenuItem('Administration', 'admin/'); |
$this->drawMenuItem('Logout', 'logout-do.php'); |
} |
else |
{ |
$this->drawMenuItem('Login', 'login.php'); |
$this->drawMenuItem('Register', 'register.php'); |
} |
write('<br />'); |
$this->drawnHeader = true; |
} |
} |
function drawMenuItem($t, $u) |
{ |
write('<p><a href="' . $this->url . $u . '">' . $t . '</a></p>'); |
} |
function drawMiddle() |
{ |
if (!$this->drawnMiddle) |
{ |
write('<br />'); |
write('</div>'); |
write('</div>'); |
write('<div class="content">'); |
write('<h2>' . $this->title . '</h2>'); |
$this->drawnMiddle = true; |
} |
} |
function drawFooter() |
{ |
if (!$this->drawnFooter) |
{ |
write('</div>'); |
write('</body>'); |
write('</html>'); |
$this->drawnFooter = true; |
} |
die(); |
} |
function drawError($text, $die = true) |
{ |
$this->drawHeader(); |
$this->drawMiddle(); |
write('<h4 style="color: red;">Error: ' . $text . '</h4>'); |
if ($die) |
{ |
$this->drawFooter(); |
die(); |
} |
} |
function drawBlogPostTree($id, $first = false) |
{ |
$post = $this->getBlogPost($id); |
if ($first) |
write('<h3><a href="post.php?id=' . $id . '">' . $post->title. '</a> <a href="post.php?id=' . $post->parent->ID . '">^</a></h3>'); |
else |
write('<a href="post.php?id=' . $id . '"><h3>' . $post->title. '</h3></a>'); |
write('<h5 style="color: #666666;">Posted On ' . date('l j F Y', $post->datePosted) . ' by ' . $post->user->name . ' (' . $post->user->username . ')</h5>'); |
write('<p>' . $post->content . '</p>'); |
write('<br />'); |
if ($this->isUserNormal($this->getLoggedInUser())) |
{ |
echo '<p class="bold"><a href="add-post.php?id=' . $id . '">Add Comment</a>'; |
if ($this->isUserAdmin($this->getLoggedInUser()) || $this->getLoggedInUser() == $post->author->ID) |
echo ' · <a href="del-post.php?id=' . $id . '">Delete Post</a>'; |
write('</p><br />'); |
} |
$ids = $this->findIDs('BlogPosts', 'WHERE ParentID=' . $id); |
for ($i = 0; $i < count($ids); $i++) |
{ |
write('<div class="indent">'); |
$this->drawBlogPostTree($ids[$i]); |
write('</div>'); |
} |
} |
function drawBlogCategoriesMenu() |
{ |
$cats = array(); |
$ids = $this->findIDs('BlogPosts', 'WHERE ParentID = -1'); |
for ($i = 0; $i < count($ids); $i++) |
{ |
$cat = $this->getBlogPost($ids[$i])->category; |
if (!in_array($cat, $cats)) |
{ |
array_push($cats, $cat); |
} |
} |
write('<h3>Categories</h3>'); |
for ($i = 0; $i < count($cats); $i++) |
{ |
$this->drawMenuItem($cats[$i], 'blog/index.php?cat=' . $cats[$i]); |
} |
} |
function replaceBBCode($str) |
{ |
$newstr = str_replace("\n", '</p><p>', $str); |
$newstr = str_replace(' ', ' ', $newstr); |
$newstr = str_replace(' :)', ' <img src="' . $this->url . 'data/smilies/face-smile.png" class="smiley" />', $newstr); |
$newstr = str_replace(' :p', ' <img src="' . $this->url . 'data/smilies/face-raspberry.png" class="smiley" />', $newstr); |
$newstr = str_replace(' :P', ' <img src="' . $this->url . 'data/smilies/face-raspberry.png" class="smiley" />',$newstr); |
$newstr = str_replace(' :|', ' <img src="' . $this->url . 'data/smilies/face-plain.png" class="smiley" />',$newstr); |
$newstr = str_replace(' :D', ' <img src="' . $this->url . 'data/smilies/face-laugh.png" class="smiley" />',$newstr); |
$newstr = str_replace(' =D', ' <img src="' . $this->url . 'data/smilies/face-laugh.png" class="smiley" />',$newstr); |
$newstr = str_replace(' :(', ' <img src="' . $this->url . 'data/smilies/face-sad.png" class="smiley" />',$newstr); |
$newstr = str_replace(' :0', ' <img src="' . $this->url . 'data/smilies/face-surprise.png" class="smiley" />',$newstr); |
$newstr = str_replace(' :o', ' <img src="' . $this->url . 'data/smilies/face-surprise.png" class="smiley" />',$newstr); |
$newstr = str_replace(' :O', ' <img src="' . $this->url . 'data/smilies/face-surprise.png" class="smiley" />',$newstr); |
$newstr = str_replace(' :/', ' <img src="' . $this->url . 'data/smilies/face-uncertain.png" class="smiley" />',$newstr); |
$newstr = str_replace(' ;)', ' <img src="' . $this->url . 'data/smilies/face-wink.png" class="smiley" />',$newstr); |
$bbcode = array( |
'/\[b\](.+?)\[\/b\]/is', |
'/\[i\](.+?)\[\/i\]/is', |
'/\[u\](.+?)\[\/u\]/is', |
'/\[url\](.+?)\[\/url\]/is', |
'/\[code\](.+?)\[\/code\]/is', |
'/\[img\](.+?)\[\/img\]/is' |
); |
$html = array( |
'<b>$1</b>', |
'<i>$1</i>', |
'<u>$1</u>', |
'<a href="$1">$1</a>', |
'<div class="code">$1</div>', |
'<img src="$1" />' |
); |
$newstr = preg_replace($bbcode, $html, $newstr); |
return $newstr; |
} |
function redirect($u) |
{ |
header('Location: ' . $u); |
die(); |
} |
function isLoggedIn() |
{ |
$cookie = $_COOKIE['Tim32_Login']; |
if (!empty($cookie)) |
{ |
$clist = explode('|~|', $cookie); |
$user = $this->getUserByUsername($clist[0]); |
if ($user) |
{ |
if ($user->password == $clist[1]) |
{ |
return true; |
} |
} |
} |
return false; |
} |
function isUserAdmin() |
{ |
if ($this->isLoggedIn()) |
{ |
if ($this->getLoggedInUser()->accessID <= 0) |
{ |
return true; |
} |
} |
return false; |
} |
function isUserGM() |
{ |
if ($this->isLoggedIn()) |
{ |
if ($this->getLoggedInUser()->accessID <= 1) |
{ |
return true; |
} |
} |
return false; |
} |
function isUserNormal() |
{ |
if ($this->isLoggedIn()) |
{ |
if ($this->getLoggedInUser()->accessID <= 2) |
{ |
return true; |
} |
} |
return false; |
} |
function checkLoggedIn() |
{ |
if (!$this->isLoggedIn()) |
{ |
$this->drawError('You need to be logged in.'); |
} |
} |
function query($query) |
{ |
$result = mysql_query($query); |
if (!$result) |
{ |
$this->drawError('MySQL Error: ' . mysql_error()); |
} |
return $result; |
} |
function findIDs($table, $query = '') |
{ |
$array = array(); |
$result = $this->query('SELECT ID FROM ' . $table . ' ' . $query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($array, $row['ID']); |
} |
return $array; |
} |
function getUserByID($id) |
{ |
$result = $this->query('SELECT * FROM Users WHERE ID = ' . $id); |
while ($row = mysql_fetch_array($result)) |
{ |
$user = new User; |
$user->ID = $row['ID']; |
$user->accessID = $row['AccessID']; |
$user->username = $row['Username']; |
$user->password = $row['Password']; |
$user->emailAddress = $row['EmailAddress']; |
$user->name = $row['Name']; |
$user->challengeID = $row['ChallengeID']; |
return $user; |
} |
return false; |
} |
function getUserByUsername($username) |
{ |
$result = $this->query('SELECT * FROM Users WHERE Username = "' . $username . '"'); |
while ($row = mysql_fetch_array($result)) |
{ |
return $this->getUserByID($row['ID']); |
} |
return false; |
} |
function getLoggedInUser() |
{ |
if ($this->isLoggedIn()) |
{ |
$clist = explode('|~|', $_COOKIE['Tim32_Login']); |
return $this->getUserByUsername($clist[0]); |
} |
return false; |
} |
function getBlogPost($id) |
{ |
$result = $this->query('SELECT * FROM BlogPosts WHERE ID = ' . $id); |
while ($row = mysql_fetch_array($result)) |
{ |
$post = new BlogPost; |
$post->ID = $row['ID']; |
if ($row['ParentID'] == -1) |
{ |
$post->parent = -1; |
} |
else |
{ |
$post->parent = $this->getBlogPost($row['ParentID']); |
} |
$post->author = $this->getUserByID($row['AuthorID']); |
$post->user = $this->getUserByID($row['AuthorID']); // For some older pages |
$post->title = $row['Title']; |
$post->content = $this->replaceBBCode($row['Content']); |
$post->datePosted = strtotime($row['DatePosted']); |
$post->category = $row['Category']; |
$post->spam = $row['Spam']; |
return $post; |
} |
$this->drawError('Cannot find blog post, #' . $id); |
} |
function delBlogPost($id) |
{ |
$ids = $this->findIDs('BlogPosts', 'WHERE ParentID=' . $id); |
for ($i = 0; $i < count($ids); $i++) |
$this->delBlogPost($ids[$i]); |
$this->query('delete from BlogPosts where ID=' . $id); |
} |
function getGetID() |
{ |
$id = $_GET['id']; |
if (empty($id)) |
{ |
$id = 1; |
} |
return $id; |
} |
function getPostID() |
{ |
$id = $_POST['id']; |
if (empty($id)) |
{ |
$id = 1; |
} |
return $id; |
} |
} |
class User |
{ |
public $ID; |
public $accessID; |
public $username; |
public $password; |
public $emailAddress; |
public $name; |
public $challengeID; |
} |
class BlogPost |
{ |
public $ID; |
public $parent; |
public $author; |
public $title; |
public $content; |
public $datePosted; |
public $category; |
public $spam; |
} |
function write($str) |
{ |
echo $str; |
echo "\n"; |
} |
?> |
<?php |
require '_config.php'; |
class Taios_Page |
{ |
function __construct($title, $url = "") |
{ |
$this->title = $title; |
$this->url = $url; |
$this->drawnHeader = false; |
$this->drawnMiddle = false; |
$this->drawnFooter = false; |
$this->db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD); |
if (!$this->db) |
{ |
$this->drawError('Failed to connect to database: ' . mysql_error()); |
} |
if (!mysql_select_db('Tim32')) |
{ |
$this->drawError('Failed to select database: ' . mysql_error()); |
} |
} |
function drawHeader() |
{ |
if (!$this->drawnHeader) |
{ |
write('<!DOCTYPE html>'); |
write('<html>'); |
write('<head>'); |
write('<meta http-equiv="Content-Type" content="text/html;charset=utf-8">'); |
write('<title>Tim32 · ' . $this->title . '</title>'); |
write('<link href="' . $this->url . 'styles.css" rel="stylesheet" type="text/css" media="screen">'); |
write('</head>'); |
write('<body>'); |
write('<div class="sidebar">'); |
write('<div class="sidebar-header">'); |
write('<h1>Tim32</h1>'); |
write('</div>'); |
write('<div class="sidebar-menu">'); |
$this->drawMenuItem('Home', 'index.php'); |
$this->drawMenuItem('Blog', 'blog/'); |
$this->drawMenuItem('Projects', 'projects/'); |
$this->drawMenuItem('Forums', 'forums/'); |
$this->drawMenuItem('Wiki', 'wiki/'); |
$this->drawMenuItem('Photos', 'photos/'); |
write('<br />'); |
if ($this->isLoggedIn()) |
{ |
$this->drawMenuItem('Administration', 'admin/'); |
$this->drawMenuItem('Logout', 'logout-do.php'); |
} |
else |
{ |
$this->drawMenuItem('Login', 'login.php'); |
$this->drawMenuItem('Register', 'register.php'); |
} |
write('<br />'); |
$this->drawnHeader = true; |
} |
} |
function drawMenuItem($t, $u) |
{ |
write('<p><a href="' . $this->url . $u . '">' . $t . '</a></p>'); |
} |
function drawMiddle() |
{ |
if (!$this->drawnMiddle) |
{ |
write('<br />'); |
write('</div>'); |
write('</div>'); |
write('<div class="content">'); |
write('<h2>' . $this->title . '</h2>'); |
$this->drawnMiddle = true; |
} |
} |
function drawFooter() |
{ |
if (!$this->drawnFooter) |
{ |
write('</div>'); |
write('</body>'); |
write('</html>'); |
$this->drawnFooter = true; |
} |
die(); |
} |
function drawError($text, $die = true) |
{ |
$this->drawHeader(); |
$this->drawMiddle(); |
write('<h4 style="color: red;">Error: ' . $text . '</h4>'); |
if ($die) |
{ |
$this->drawFooter(); |
die(); |
} |
} |
function drawBlogPostTree($id, $first = false) |
{ |
$post = $this->getBlogPost($id); |
if ($first) |
write('<h3><a href="post.php?id=' . $id . '">' . $post->title. '</a> <a href="post.php?id=' . $post->parent->ID . '">^</a></h3>'); |
else |
write('<a href="post.php?id=' . $id . '"><h3>' . $post->title. '</h3></a>'); |
write('<h5 style="color: #666666;">Posted On ' . date('l j F Y', $post->datePosted) . ' by ' . $post->user->name . ' (' . $post->user->username . ')</h5>'); |
write('<p>' . $post->content . '</p>'); |
write('<br />'); |
if ($this->isUserNormal($this->getLoggedInUser())) |
{ |
echo '<p class="bold"><a href="add-post.php?id=' . $id . '">Add Comment</a>'; |
if ($this->isUserAdmin($this->getLoggedInUser()) || $this->getLoggedInUser() == $post->author->ID) |
echo ' · <a href="del-post.php?id=' . $id . '">Delete Post</a>'; |
write('</p><br />'); |
} |
$ids = $this->findIDs('BlogPosts', 'WHERE ParentID=' . $id); |
for ($i = 0; $i < count($ids); $i++) |
{ |
write('<div class="indent">'); |
$this->drawBlogPostTree($ids[$i]); |
write('</div>'); |
} |
} |
function drawBlogCategoriesMenu() |
{ |
$cats = array(); |
$ids = $this->findIDs('BlogPosts', 'WHERE ParentID = -1'); |
for ($i = 0; $i < count($ids); $i++) |
{ |
$cat = $this->getBlogPost($ids[$i])->category; |
if (!in_array($cat, $cats)) |
{ |
array_push($cats, $cat); |
} |
} |
write('<h3>Categories</h3>'); |
for ($i = 0; $i < count($cats); $i++) |
{ |
$this->drawMenuItem($cats[$i], 'blog/index.php?cat=' . $cats[$i]); |
} |
} |
function replaceBBCode($str) |
{ |
$newstr = str_replace("\n", '</p><p>', $str); |
$newstr = str_replace(' ', ' ', $newstr); |
$newstr = str_replace(' :)', ' <img src="' . $this->url . 'data/smilies/face-smile.png" class="smiley" />', $newstr); |
$newstr = str_replace(' :p', ' <img src="' . $this->url . 'data/smilies/face-raspberry.png" class="smiley" />', $newstr); |
$newstr = str_replace(' :P', ' <img src="' . $this->url . 'data/smilies/face-raspberry.png" class="smiley" />',$newstr); |
$newstr = str_replace(' :|', ' <img src="' . $this->url . 'data/smilies/face-plain.png" class="smiley" />',$newstr); |
$newstr = str_replace(' :D', ' <img src="' . $this->url . 'data/smilies/face-laugh.png" class="smiley" />',$newstr); |
$newstr = str_replace(' =D', ' <img src="' . $this->url . 'data/smilies/face-laugh.png" class="smiley" />',$newstr); |
$newstr = str_replace(' :(', ' <img src="' . $this->url . 'data/smilies/face-sad.png" class="smiley" />',$newstr); |
$newstr = str_replace(' :0', ' <img src="' . $this->url . 'data/smilies/face-surprise.png" class="smiley" />',$newstr); |
$newstr = str_replace(' :o', ' <img src="' . $this->url . 'data/smilies/face-surprise.png" class="smiley" />',$newstr); |
$newstr = str_replace(' :O', ' <img src="' . $this->url . 'data/smilies/face-surprise.png" class="smiley" />',$newstr); |
$newstr = str_replace(' :/', ' <img src="' . $this->url . 'data/smilies/face-uncertain.png" class="smiley" />',$newstr); |
$newstr = str_replace(' ;)', ' <img src="' . $this->url . 'data/smilies/face-wink.png" class="smiley" />',$newstr); |
$bbcode = array( |
'/\[b\](.+?)\[\/b\]/is', |
'/\[i\](.+?)\[\/i\]/is', |
'/\[u\](.+?)\[\/u\]/is', |
'/\[url\](.+?)\[\/url\]/is', |
'/\[code\](.+?)\[\/code\]/is', |
'/\[img\](.+?)\[\/img\]/is' |
); |
$html = array( |
'<b>$1</b>', |
'<i>$1</i>', |
'<u>$1</u>', |
'<a href="$1">$1</a>', |
'<div class="code">$1</div>', |
'<img src="$1" />' |
); |
$newstr = preg_replace($bbcode, $html, $newstr); |
return $newstr; |
} |
function redirect($u) |
{ |
header('Location: ' . $u); |
die(); |
} |
function isLoggedIn() |
{ |
$cookie = $_COOKIE['Tim32_Login']; |
if (!empty($cookie)) |
{ |
$clist = explode('|~|', $cookie); |
$user = $this->getUserByUsername($clist[0]); |
if ($user) |
{ |
if ($user->password == $clist[1]) |
{ |
return true; |
} |
} |
} |
return false; |
} |
function isUserAdmin() |
{ |
if ($this->isLoggedIn()) |
{ |
if ($this->getLoggedInUser()->accessID <= 0) |
{ |
return true; |
} |
} |
return false; |
} |
function isUserGM() |
{ |
if ($this->isLoggedIn()) |
{ |
if ($this->getLoggedInUser()->accessID <= 1) |
{ |
return true; |
} |
} |
return false; |
} |
function isUserNormal() |
{ |
if ($this->isLoggedIn()) |
{ |
if ($this->getLoggedInUser()->accessID <= 2) |
{ |
return true; |
} |
} |
return false; |
} |
function checkLoggedIn() |
{ |
if (!$this->isLoggedIn()) |
{ |
$this->drawError('You need to be logged in.'); |
} |
} |
function query($query) |
{ |
$result = mysql_query($query); |
if (!$result) |
{ |
$this->drawError('MySQL Error: ' . mysql_error()); |
} |
return $result; |
} |
function findIDs($table, $query = '') |
{ |
$array = array(); |
$result = $this->query('SELECT ID FROM ' . $table . ' ' . $query); |
while ($row = mysql_fetch_array($result)) |
{ |
array_push($array, $row['ID']); |
} |
return $array; |
} |
function getUserByID($id) |
{ |
$result = $this->query('SELECT * FROM Users WHERE ID = ' . $id); |
while ($row = mysql_fetch_array($result)) |
{ |
$user = new User; |
$user->ID = $row['ID']; |
$user->accessID = $row['AccessID']; |
$user->username = $row['Username']; |
$user->password = $row['Password']; |
$user->emailAddress = $row['EmailAddress']; |
$user->name = $row['Name']; |
$user->challengeID = $row['ChallengeID']; |
return $user; |
} |
return false; |
} |
function getUserByUsername($username) |
{ |
$result = $this->query('SELECT * FROM Users WHERE Username = "' . $username . '"'); |
while ($row = mysql_fetch_array($result)) |
{ |
return $this->getUserByID($row['ID']); |
} |
return false; |
} |
function getLoggedInUser() |
{ |
if ($this->isLoggedIn()) |
{ |
$clist = explode('|~|', $_COOKIE['Tim32_Login']); |
return $this->getUserByUsername($clist[0]); |
} |
return false; |
} |
function getBlogPost($id) |
{ |
$result = $this->query('SELECT * FROM BlogPosts WHERE ID = ' . $id); |
while ($row = mysql_fetch_array($result)) |
{ |
$post = new BlogPost; |
$post->ID = $row['ID']; |
if ($row['ParentID'] == -1) |
{ |
$post->parent = -1; |
} |
else |
{ |
$post->parent = $this->getBlogPost($row['ParentID']); |
} |
$post->author = $this->getUserByID($row['AuthorID']); |
$post->user = $this->getUserByID($row['AuthorID']); // For some older pages |
$post->title = $row['Title']; |
$post->content = $this->replaceBBCode($row['Content']); |
$post->datePosted = strtotime($row['DatePosted']); |
$post->category = $row['Category']; |
$post->spam = $row['Spam']; |
return $post; |
} |
$this->drawError('Cannot find blog post, #' . $id); |
} |
function delBlogPost($id) |
{ |
$ids = $this->findIDs('BlogPosts', 'WHERE ParentID=' . $id); |
for ($i = 0; $i < count($ids); $i++) |
$this->delBlogPost($ids[$i]); |
$this->query('delete from BlogPosts where ID=' . $id); |
} |
function getGetID() |
{ |
$id = $_GET['id']; |
if (empty($id)) |
{ |
$id = 1; |
} |
return $id; |
} |
function getPostID() |
{ |
$id = $_POST['id']; |
if (empty($id)) |
{ |
$id = 1; |
} |
return $id; |
} |
} |
class User |
{ |
public $ID; |
public $accessID; |
public $username; |
public $password; |
public $emailAddress; |
public $name; |
public $challengeID; |
} |
class BlogPost |
{ |
public $ID; |
public $parent; |
public $author; |
public $title; |
public $content; |
public $datePosted; |
public $category; |
public $spam; |
} |
function write($str) |
{ |
echo $str; |
echo "\n"; |
} |
?> |
/install.sql |
---|
1,75 → 1,75 |
DROP DATABASE Tim32; |
CREATE DATABASE Tim32; |
USE Tim32; |
CREATE TABLE Users |
( |
ID INT NOT NULL AUTO_INCREMENT, |
AccessID INT, |
Username TEXT, |
Password TEXT, |
EmailAddress TEXT, |
Name TEXT, |
ChallengeID INT, |
PRIMARY KEY(ID) |
); |
CREATE TABLE BlogPosts |
( |
ID INT NOT NUll AUTO_INCREMENT, |
ParentID INT, |
AuthorID INT, |
Title TEXT, |
Content TEXT, |
DatePosted DATETIME, |
Category TEXT, |
Spam BOOLEAN, |
PRIMARY KEY(ID) |
); |
CREATE TABLE Projects |
( |
ID INT NOT NUll AUTO_INCREMENT, |
AuthorID INT, |
Title TEXT, |
Description TEXT, |
LogoURL TEXT, |
WebsiteURL TEXT, |
LatestVersion TEXT, |
PRIMARY KEY(ID) |
); |
CREATE TABLE ForumCategories |
( |
ID INT NOT NUll AUTO_INCREMENT, |
ParentID INT, |
Title TEXT, |
Description TEXT, |
PRIMARY KEY(ID) |
); |
CREATE TABLE ForumTopics |
( |
ID INT NOT NUll AUTO_INCREMENT, |
AuthorID INT, |
CategoryID INT, |
Title TEXT, |
DatePosted DATETIME, |
PRIMARY KEY(ID) |
); |
CREATE TABLE ForumPosts |
( |
ID INT NOT NUll AUTO_INCREMENT, |
AuthorID INT, |
TopicID INT, |
Title TEXT, |
Content TEXT, |
DatePosted DATETIME, |
Spam BOOLEAN, |
PRIMARY KEY(ID) |
); |
INSERT INTO Users VALUES (1, 0, "admin", SHA1("password"), "admins@tim32.org", "Tim32 Admin", 0); |
INSERT INTO BlogPosts VALUES(1, -1, 1, "Welcome to Tim32!", "Welcome to the new Tim32 website! It has had a complete design re-think to make it simpler and easier to use!", NOW(), "Tim32", FALSE); |
DROP DATABASE Tim32; |
CREATE DATABASE Tim32; |
USE Tim32; |
CREATE TABLE Users |
( |
ID INT NOT NULL AUTO_INCREMENT, |
AccessID INT, |
Username TEXT, |
Password TEXT, |
EmailAddress TEXT, |
Name TEXT, |
ChallengeID INT, |
PRIMARY KEY(ID) |
); |
CREATE TABLE BlogPosts |
( |
ID INT NOT NUll AUTO_INCREMENT, |
ParentID INT, |
AuthorID INT, |
Title TEXT, |
Content TEXT, |
DatePosted DATETIME, |
Category TEXT, |
Spam BOOLEAN, |
PRIMARY KEY(ID) |
); |
CREATE TABLE Projects |
( |
ID INT NOT NUll AUTO_INCREMENT, |
AuthorID INT, |
Title TEXT, |
Description TEXT, |
LogoURL TEXT, |
WebsiteURL TEXT, |
LatestVersion TEXT, |
PRIMARY KEY(ID) |
); |
CREATE TABLE ForumCategories |
( |
ID INT NOT NUll AUTO_INCREMENT, |
ParentID INT, |
Title TEXT, |
Description TEXT, |
PRIMARY KEY(ID) |
); |
CREATE TABLE ForumTopics |
( |
ID INT NOT NUll AUTO_INCREMENT, |
AuthorID INT, |
CategoryID INT, |
Title TEXT, |
DatePosted DATETIME, |
PRIMARY KEY(ID) |
); |
CREATE TABLE ForumPosts |
( |
ID INT NOT NUll AUTO_INCREMENT, |
AuthorID INT, |
TopicID INT, |
Title TEXT, |
Content TEXT, |
DatePosted DATETIME, |
Spam BOOLEAN, |
PRIMARY KEY(ID) |
); |
INSERT INTO Users VALUES (1, 0, "admin", SHA1("password"), "admins@tim32.org", "Tim32 Admin", 0); |
INSERT INTO BlogPosts VALUES(1, -1, 1, "Welcome to Tim32!", "Welcome to the new Tim32 website! It has had a complete design re-think to make it simpler and easier to use!", NOW(), "Tim32", FALSE); |
/data/sidebar-gradient.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/register-do.php |
---|
1,34 → 1,34 |
<?php |
require '_taios.php'; |
$page = new Taios_Page('Login'); |
$username = $_POST['username']; |
$password = $_POST['password']; |
$password2 = $_POST['password2']; |
$email = $_POST['email']; |
$name = $_POST['name']; |
if (empty($username)) |
{ |
$page->redirect('register.php?error=No Username Specified'); |
} |
if (empty($password)) |
{ |
$page->redirect('register.php?error=No Password Specified'); |
} |
if (empty($password2)) |
{ |
$page->redirect('register.php?error=No Repeat Password Specified'); |
} |
if ($password != $password2) |
{ |
$page->redirect('register.php?error=Passwords do not match'); |
} |
$page->query('INSERT INTO Users (AccessID, Username, Password, EmailAddress, Name, ChallengeID) VALUES (2, "' . $username . '", "' . sha1($password) . '", "' . $email . '", "' . $name . '", 0)'); |
$page->redirect('login.php'); |
?> |
<?php |
require '_taios.php'; |
$page = new Taios_Page('Login'); |
$username = $_POST['username']; |
$password = $_POST['password']; |
$password2 = $_POST['password2']; |
$email = $_POST['email']; |
$name = $_POST['name']; |
if (empty($username)) |
{ |
$page->redirect('register.php?error=No Username Specified'); |
} |
if (empty($password)) |
{ |
$page->redirect('register.php?error=No Password Specified'); |
} |
if (empty($password2)) |
{ |
$page->redirect('register.php?error=No Repeat Password Specified'); |
} |
if ($password != $password2) |
{ |
$page->redirect('register.php?error=Passwords do not match'); |
} |
$page->query('INSERT INTO Users (AccessID, Username, Password, EmailAddress, Name, ChallengeID) VALUES (2, "' . $username . '", "' . sha1($password) . '", "' . $email . '", "' . $name . '", 0)'); |
$page->redirect('login.php'); |
?> |
/register.php |
---|
1,56 → 1,56 |
<?php |
require '_taios.php'; |
$page = new Taios_Page('Register'); |
$page->drawHeader(); |
$page->drawMiddle(); |
?> |
<p class="bold">Here you can create an account with Tim32.</p> |
<br /> |
<?php |
if (isset($_GET['error'])) |
{ |
$page->drawError($_GET['error'], false); |
} |
?> |
<form action="register-do.php" method="POST"> |
<table> |
<tr> |
<td class="bold">Username: </td> |
<td><input type="text" name="username" /></td> |
</tr> |
<tr> |
<td class="bold">Password: </td> |
<td><input type="password" name="password" /></td> |
</tr> |
<tr> |
<td class="bold">Repeat Password: </td> |
<td><input type="password" name="password2" /></td> |
</tr> |
<tr> |
<td class="bold">Email Address</td>: </td> |
<td><input type="text" name="email" /></td> |
</tr> |
<tr> |
<td class="bold">Name</td>: </td> |
<td><input type="text" name="name" /></td> |
</tr> |
<tr> |
<td class="bold"></td> |
<td><input type="submit" value="Register" /></td> |
</tr> |
</table> |
</form> |
<?php |
$page->drawFooter(); |
?> |
<?php |
require '_taios.php'; |
$page = new Taios_Page('Register'); |
$page->drawHeader(); |
$page->drawMiddle(); |
?> |
<p class="bold">Here you can create an account with Tim32.</p> |
<br /> |
<?php |
if (isset($_GET['error'])) |
{ |
$page->drawError($_GET['error'], false); |
} |
?> |
<form action="register-do.php" method="POST"> |
<table> |
<tr> |
<td class="bold">Username: </td> |
<td><input type="text" name="username" /></td> |
</tr> |
<tr> |
<td class="bold">Password: </td> |
<td><input type="password" name="password" /></td> |
</tr> |
<tr> |
<td class="bold">Repeat Password: </td> |
<td><input type="password" name="password2" /></td> |
</tr> |
<tr> |
<td class="bold">Email Address</td>: </td> |
<td><input type="text" name="email" /></td> |
</tr> |
<tr> |
<td class="bold">Name</td>: </td> |
<td><input type="text" name="name" /></td> |
</tr> |
<tr> |
<td class="bold"></td> |
<td><input type="submit" value="Register" /></td> |
</tr> |
</table> |
</form> |
<?php |
$page->drawFooter(); |
?> |
/styles.css |
---|
1,140 → 1,140 |
body { |
background-color: #FFFFFF; |
color: #000000; |
font-family: Droid Sans, Tahoma, sans-serif; |
font-size: 11pt; |
} |
h1 { |
font-size: 28pt; |
margin: 6px; |
margin-top: 0px; |
color: #000089; |
border-bottom: 1px solid #000000; |
} |
h2 { |
font-size: 20pt; |
margin: 6px; |
margin-left: 8px; |
color: #00004B; |
} |
h3 { |
font-size: 16pt; |
margin: 6px; |
margin-left: 10px; |
color: #000055; |
} |
h4 { |
font-size: 12pt; |
margin: 6px; |
margin-left: 12px; |
color: #00005F; |
} |
h5 { |
font-size: 10pt; |
margin: 6px; |
margin-left: 14px; |
color: #000069; |
} |
p, table, span { |
font-size: 11pt; |
margin: 6px; |
margin-left: 16px; |
} |
a { |
text-decoration: none; |
color: #000050; |
} |
a:hover { |
text-decoration: underline; |
} |
input { |
border: 1px solid #000000; |
color: #000000; |
background-color: #B5D7FF; |
} |
table { |
border: 1px solid #222222; |
} |
td { |
padding: 3px; |
border: 1px solid #888888; |
} |
img { |
border: 2px solid #333333; |
} |
.smiley { |
border: 0px; |
vertical-align: middle; |
} |
.sidebar { |
left: 0px; |
top: 0px; |
position: fixed; |
padding: 0px; |
padding-left: 32px; |
border-right: 1px solid #000089; |
background-color: #FFFF73; |
background-image: url('data/sidebar-gradient.png'); |
background-repeat: repeat-x; |
background-position: center bottom; |
} |
.sidebar-header { |
left: 0px; |
width: 140px; |
padding: 6px; |
text-align: right; |
} |
.sidebar-menu { |
text-align: right; |
padding: 6px; |
} |
.sidebar-menu h3 { |
margin: 6px; |
} |
.sidebar-menu p { |
font-size: 12pt; |
margin: 4px; |
} |
.content { |
left: 200px; |
top: 0px; |
position: absolute; |
margin-right: 32px; |
} |
.bold { |
font-weight: bold; |
} |
.indent { |
margin-left: 14px; |
border-left: 1px solid #BBBBBB; |
} |
.code { |
border: 1px solid #333333; |
background-color: #DDDDDD; |
font-family: Droid Sans Mono, Monospace, Fixed; |
} |
body { |
background-color: #FFFFFF; |
color: #000000; |
font-family: Droid Sans, Tahoma, sans-serif; |
font-size: 11pt; |
} |
h1 { |
font-size: 28pt; |
margin: 6px; |
margin-top: 0px; |
color: #000089; |
border-bottom: 1px solid #000000; |
} |
h2 { |
font-size: 20pt; |
margin: 6px; |
margin-left: 8px; |
color: #00004B; |
} |
h3 { |
font-size: 16pt; |
margin: 6px; |
margin-left: 10px; |
color: #000055; |
} |
h4 { |
font-size: 12pt; |
margin: 6px; |
margin-left: 12px; |
color: #00005F; |
} |
h5 { |
font-size: 10pt; |
margin: 6px; |
margin-left: 14px; |
color: #000069; |
} |
p, table, span { |
font-size: 11pt; |
margin: 6px; |
margin-left: 16px; |
} |
a { |
text-decoration: none; |
color: #000050; |
} |
a:hover { |
text-decoration: underline; |
} |
input { |
border: 1px solid #000000; |
color: #000000; |
background-color: #B5D7FF; |
} |
table { |
border: 1px solid #222222; |
} |
td { |
padding: 3px; |
border: 1px solid #888888; |
} |
img { |
border: 2px solid #333333; |
} |
.smiley { |
border: 0px; |
vertical-align: middle; |
} |
.sidebar { |
left: 0px; |
top: 0px; |
position: fixed; |
padding: 0px; |
padding-left: 32px; |
border-right: 1px solid #000089; |
background-color: #FFFF73; |
background-image: url('data/sidebar-gradient.png'); |
background-repeat: repeat-x; |
background-position: center bottom; |
} |
.sidebar-header { |
left: 0px; |
width: 140px; |
padding: 6px; |
text-align: right; |
} |
.sidebar-menu { |
text-align: right; |
padding: 6px; |
} |
.sidebar-menu h3 { |
margin: 6px; |
} |
.sidebar-menu p { |
font-size: 12pt; |
margin: 4px; |
} |
.content { |
left: 200px; |
top: 0px; |
position: absolute; |
margin-right: 32px; |
} |
.bold { |
font-weight: bold; |
} |
.indent { |
margin-left: 14px; |
border-left: 1px solid #BBBBBB; |
} |
.code { |
border: 1px solid #333333; |
background-color: #DDDDDD; |
font-family: Droid Sans Mono, Monospace, Fixed; |
} |
/forums/index.php |
---|
1,14 → 1,14 |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Forums', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
write('<br /><p class="bold">This page is currently under construction.</p>'); |
$page->drawFooter(); |
?> |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Forums', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
write('<br /><p class="bold">This page is currently under construction.</p>'); |
$page->drawFooter(); |
?> |
/photos/index.php |
---|
1,14 → 1,14 |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Photos', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
write('<br /><p class="bold">This page is currently under construction.</p>'); |
$page->drawFooter(); |
?> |
<?php |
require '../_taios.php'; |
$page = new Taios_Page('Photos', '../'); |
$page->drawHeader(); |
$page->drawMiddle(); |
write('<br /><p class="bold">This page is currently under construction.</p>'); |
$page->drawFooter(); |
?> |