Subversion Repositories taios

Compare Revisions

Ignore whitespace Rev 1 → Rev 28

/blog/post.php
0,0 → 1,41
<?php
 
require '../_taios.php';
 
$page = new Taios_Page('Blog Posts', '../');
 
if (!isset($_GET['id']))
$page->redirect("index.php");
 
$page->drawHeader();
write('<h3>Blog</h3>');
$page->drawMenuItem('Computing', 'index.php?cat=Computing');
$page->drawMiddle();
 
if ($page->isUserGM($page->getLoggedInUser()))
{
write('<p class="bold"><a href="add-post.php">Add Post</a></p>');
write('<br />');
}
 
drawPost($_GET['id']);
 
function drawPost($id)
{
$post = $page->getBlogPost($id);
write('<h3>' . $post->title. '</h3>');
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>');
 
$ids = $page->findIDs('BlogPosts', 'WHERE ParentID = ' . $id);
for ($i = 0; $i < count($ids); $i++)
{
write('<p class="extract">');
drawPost($i);
}
 
}
 
$page->drawFooter();
 
?>
/blog/index.php
1,30 → 1,30
<?php
 
require '../_taios.php';
 
$page = new Taios_Page('Blog Posts', '../');
$page->drawHeader();
write('<h3>Blog</h3>');
$page->drawMenuItem('Computing', 'index.php?cat=Computing');
$page->drawMiddle();
 
if ($page->isUserGM($page->getLoggedInUser()))
{
write('<p class="bold"><a href="add-post.php">Add Post</a></p>');
write('<br />');
}
 
$ids = $page->findIDs('BlogPosts');
for ($i = 0; $i < count($ids); $i++)
{
$id = $ids[$i];
$post = $page->getBlogPost($id);
write('<h3>' . $post->title. '</h3>');
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>');
}
 
$page->drawFooter();
 
?>
<?php
 
require '../_taios.php';
 
$page = new Taios_Page('Blog Posts', '../');
$page->drawHeader();
write('<h3>Blog</h3>');
$page->drawMenuItem('Computing', 'index.php?cat=Computing');
$page->drawMiddle();
 
if ($page->isUserGM($page->getLoggedInUser()))
{
write('<p class="bold"><a href="add-post.php">Add Post</a></p>');
write('<br />');
}
 
$ids = $page->findIDs('BlogPosts', 'WHERE ParentID = -1');
for ($i = 0; $i < count($ids); $i++)
{
$id = $ids[$i];
$post = $page->getBlogPost($id);
write('<a href="post.php?id=' . $i . '"><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>');
}
 
 
$page->drawFooter();
 
?>
/styles.css
1,111 → 1,115
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;
}
 
.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;
width: 720px;
margin-right: 32px;
}
 
.bold {
font-weight: bold;
}
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;
}
 
.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;
width: 720px;
margin-right: 32px;
}
 
.bold {
font-weight: bold;
}
 
p.indent {
margin-left: 5em;
}
/_taios.php
1,5 → 1,7
<?php
 
require '_config.php';
 
class Taios_Page
{
function __construct($title, $url = "")
11,7 → 13,7
$this->drawnMiddle = false;
$this->drawnFooter = false;
$this->db = mysql_connect('localhost', 'root', 'puppylinux');
$this->db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD);
if (!$this->db)
{
$this->drawError('Failed to connect to database: ' . mysql_error());
49,7 → 51,7
write('<br />');
if ($this->isLoggedIn())
{
$this->drawMenuItem('Manage Account', 'admim/?id=' . $this->getLoggedInUser()->ID);
$this->drawMenuItem('Manage Account', 'admin/account.php?id=' . $this->getLoggedInUser()->ID);
$this->drawMenuItem('Logout', 'logout-do.php');
}
else
93,7 → 95,7
$this->drawnFooter = true;
}
die();
// die();
}
function drawError($text, $die = true)
174,6 → 176,14
return false;
}
function checkLoggedIn()
{
if (!$this->isLoggedIn())
{
$this->drawError('You need to be logged in.');
}
}
function query($query)
{
$result = mysql_query($query);
247,17 → 257,49
{
$post = new BlogPost;
$post->ID = $row['ID'];
if ($row['ParentID'] == -1)
{
$post->parent = -1;
}
else
{
$post->parent = $this->getBlogPost($row['ParentID']);
}
$post->user = $this->getUserByID($row['AuthorID']);
$post->title = $row['Title'];
$post->content = $row['Content'];
$post->datePosted = strtotime($row['DatePosted']);
$post->category = $row['Category'];
$post->spam = $row['Spam'];
return $post;
}
$this->drawError('Cannot find blog post, #' . $id);
return false;
}
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
274,11 → 316,13
class BlogPost
{
public $ID;
public $parent;
public $author;
public $title;
public $content;
public $datePosted;
public $category;
public $spam;
}
 
function write($str)
/admin/account.php
0,0 → 1,57
<?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 />
 
<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>
 
<?php
}
else
{
if (!$user)
{
drawError('No such user, #' . $userID);
}
else
{
drawError('You do not have permission to access this page.');
}
}
 
$page->drawFooter();
 
?>
/admin/index.php
0,0 → 1,26
<?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-blog-comments.php">Manage All Blog Comments</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();
 
?>
/install.sql
18,13 → 18,58
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, "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");
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);
/index.php
22,7 → 22,7
 
<?php
 
$ids = $page->findIDs('BlogPosts');
$ids = $page->findIDs('BlogPosts', 'WHERE ParentID = -1');
for ($i = 0; $i < 5 && $i < count($ids); $i++)
{
$id = $ids[$i];