Subversion Repositories taios

Compare Revisions

Ignore whitespace Rev 169 → Rev 1

/admin/all-blog-posts.php
File deleted
/admin/all-accounts.php
File deleted
/admin/index.php
File deleted
/admin/account-do.php
File deleted
/admin/account.php
File deleted
/projects/index.php
File deleted
/404.php
File deleted
/wiki/index.php
File deleted
/forums/index.php
File deleted
/photos/index.php
File deleted
/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');
 
?>
/blog/add-post.php
File deleted
/blog/post.php
File deleted
/blog/del-post.php
File deleted
/blog/edit-post.php
File deleted
/blog/index.php
1,40 → 1,30
<?php
 
require '../_taios.php';
 
$page = new Taios_Page('Blog Posts', '../');
$page->drawHeader();
$page->drawBlogCategoriesMenu();
$page->drawMiddle();
 
if ($page->isUserGM($page->getLoggedInUser()))
{
write('<p class="bold"><a href="add-post.php?id=-1">Add Post</a></p>');
write('<br />');
}
 
$query = 'WHERE ParentID = -1';
 
if (isset($_GET['cat']))
{
$query = $query . ' AND Category = "' . $_GET['cat'] . '"';
write('<p>Only showing blog posts from the ' . $_GET['cat'] . ' category. <a href="index.php">Reset Filtering</a></p><br />');
}
 
$query = $query . " ORDER BY DatePosted DESC";
 
$ids = $page->findIDs('BlogPosts', $query);
for ($i = 0; $i < count($ids); $i++)
{
$id = $ids[$i];
$post = $page->getBlogPost($id);
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 />');
}
 
$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');
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();
 
?>
/_taios.php
1,7 → 1,5
<?php
 
require '_config.php';
 
class Taios_Page
{
function __construct($title, $url = "")
13,7 → 11,7
$this->drawnMiddle = false;
$this->drawnFooter = false;
$this->db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD);
$this->db = mysql_connect('localhost', 'root', 'puppylinux');
if (!$this->db)
{
$this->drawError('Failed to connect to database: ' . mysql_error());
51,7 → 49,7
write('<br />');
if ($this->isLoggedIn())
{
$this->drawMenuItem('Administration', 'admin/');
$this->drawMenuItem('Manage Account', 'admim/?id=' . $this->getLoggedInUser()->ID);
$this->drawMenuItem('Logout', 'logout-do.php');
}
else
67,7 → 65,7
function drawMenuItem($t, $u)
{
write('<p><a href="' . $this->url . $u . '">' . $t . '</a></p>');
write('<p><a href="' . $this->url . $u . '"</a>' . $t . '</a></p>');
}
function drawMiddle()
112,97 → 110,9
}
}
function drawBlogPostTree($id, $first = false)
function redirect($url)
{
$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 ' &middot <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(' ', '&nbsp;&nbsp;', $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);
header('Location: ' . $url);
die();
}
264,14 → 174,6
return false;
}
function checkLoggedIn()
{
if (!$this->isLoggedIn())
{
$this->drawError('You need to be logged in.');
}
}
function query($query)
{
$result = mysql_query($query);
345,21 → 247,11
{
$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->user = $this->getUserByID($row['AuthorID']);
$post->title = $row['Title'];
$post->content = $this->replaceBBCode($row['Content']);
$post->content = $row['Content'];
$post->datePosted = strtotime($row['DatePosted']);
$post->category = $row['Category'];
$post->spam = $row['Spam'];
return $post;
}
366,38 → 258,6
$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
414,13 → 274,11
class BlogPost
{
public $ID;
public $parent;
public $author;
public $title;
public $content;
public $datePosted;
public $category;
public $spam;
}
 
function write($str)
/install.sql
1,75 → 1,30
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,
AuthorID INT,
Title TEXT,
Content TEXT,
DatePosted DATETIME,
Category TEXT,
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");
/data/smilies/face-raspberry.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/data/smilies/face-raspberry.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: data/smilies/face-smile.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: data/smilies/face-smile.png
===================================================================
--- data/smilies/face-smile.png (revision 169)
+++ data/smilies/face-smile.png (nonexistent)
/data/smilies/face-smile.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: data/smilies/face-surprise.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: data/smilies/face-surprise.png
===================================================================
--- data/smilies/face-surprise.png (revision 169)
+++ data/smilies/face-surprise.png (nonexistent)
/data/smilies/face-surprise.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: data/smilies/face-laugh.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: data/smilies/face-laugh.png
===================================================================
--- data/smilies/face-laugh.png (revision 169)
+++ data/smilies/face-laugh.png (nonexistent)
/data/smilies/face-laugh.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: data/smilies/face-plain.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: data/smilies/face-plain.png
===================================================================
--- data/smilies/face-plain.png (revision 169)
+++ data/smilies/face-plain.png (nonexistent)
/data/smilies/face-plain.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: data/smilies/face-sad.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: data/smilies/face-sad.png
===================================================================
--- data/smilies/face-sad.png (revision 169)
+++ data/smilies/face-sad.png (nonexistent)
/data/smilies/face-sad.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: data/smilies/face-uncertain.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: data/smilies/face-uncertain.png
===================================================================
--- data/smilies/face-uncertain.png (revision 169)
+++ data/smilies/face-uncertain.png (nonexistent)
/data/smilies/face-uncertain.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: data/smilies/face-wink.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: data/smilies/face-wink.png
===================================================================
--- data/smilies/face-wink.png (revision 169)
+++ data/smilies/face-wink.png (nonexistent)
/data/smilies/face-wink.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: data/sidebar-gradient.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: register-do.php
===================================================================
--- register-do.php (revision 169)
+++ register-do.php (revision 1)
@@ -1,34 +1,34 @@
-
-
-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');
-
-?>
+
+
+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');
+
+?>
Index: register.php
===================================================================
--- register.php (revision 169)
+++ register.php (revision 1)
@@ -1,56 +1,56 @@
-
-
-require '_taios.php';
-
-$page = new Taios_Page('Register');
-$page->drawHeader();
-$page->drawMiddle();
-
-?>
-
-

Here you can create an account with Tim32.

-
-
-
-
-if (isset($_GET['error']))
-{
- $page->drawError($_GET['error'], false);
-}
-
-?>
-
-
-: :
-
-Username:
-
-
-
-Password:
-
-
-
-Repeat Password:
-
-
-
-Email Address
-
-
-
-Name
-
-
-
-
-
-
-
-
-
-
-
-$page->drawFooter();
-
-?>
+
+
+require '_taios.php';
+
+$page = new Taios_Page('Register');
+$page->drawHeader();
+$page->drawMiddle();
+
+?>
+
+

Here you can create an account with Tim32.

+
+
+
+
+if (isset($_GET['error']))
+{
+ $page->drawError($_GET['error'], false);
+}
+
+?>
+
+
+: :
+
+Username:
+
+
+
+Password:
+
+
+
+Repeat Password:
+
+
+
+Email Address
+
+
+
+Name
+
+
+
+
+
+
+
+
+
+
+
+$page->drawFooter();
+
+?>
Index: styles.css
===================================================================
--- styles.css (revision 169)
+++ styles.css (revision 1)
@@ -63,24 +63,6 @@
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;
@@ -120,6 +102,7 @@
left: 200px;
top: 0px;
position: absolute;
+ width: 720px;
margin-right: 32px;
}
@@ -126,15 +109,3 @@
.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;
-}
-
/index.php
1,39 → 1,45
<?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');
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 />');
}
 
if ($page->isLoggedIn())
{
write('<h3>Actions</h3>');
write('<h4><a href="admin/account.php?id=' . $page->getLoggedInUser()->ID . '">Manage Account</a></h4>');
}
 
$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();
 
?>