This repository was archived by the owner on Jan 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.php
More file actions
143 lines (132 loc) · 3.93 KB
/
template.php
File metadata and controls
143 lines (132 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
include 'session.php';
class ThreadType
{
const Normal = 0;
const Sticky = 1;
const Poll = 2;
}
function template_head($title, $author)
{
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<title><?=$title;?></title>
<meta name="description" content="<?=$title;?>">
<meta name="author" content="<?=$author;?>">
<link rel="stylesheet" href="styles.css?v=<?=md5_file('styles.css');?>">
</head>
<body>
<?php
}
function template_forum_header()
{
session_init();
?>
<header>
<ul>
<li><a href="index.php" id="logo">forum238</a></li>
<li><a href="search.php" id="search">Search</a></li>
<?php
if($_SESSION['uid'] == 0)
{
echo " <li><a href=\"login.php\">Login</a></li>\n";
echo " <li><a href=\"register.php\">Register</a></li>\n";
}
else
{
echo " <li><a href=\"profile.php?user=".$_SESSION['uid']."\">".$_SESSION['username']."</a></li>\n";
echo " <li><a href=\"?logout\">Logout</a></li>\n";
}
?>
</ul>
</header>
<section id="content">
<?php
}
function template_footer()
{
?>
</section>
<footer>2013 - Jason Gassel, Josh Galan, Matthew McKeller</footer>
</body>
</html>
<?php
}
function template_thread_title($title, $type=0, $tag=NULL)
{
// Build thread title
if($type & ThreadType::Poll)
$title = 'Poll: '.$title;
if($type & ThreadType::Sticky && $tag != NULL && $tag != '')
$title = '['.$tag.'] '.$title;
return $title;
}
function template_thread_info($db, $tid, $uid, $title, $type, $question=NULL, $tag=NULL)
{
$displayTitle = template_thread_title($title, $type, $tag);
$userResult = $db->query('SELECT username, avatar FROM user WHERE uid='.$uid);
$user = $userResult->fetch_array();
$latestPostResult = $db->query('SELECT uid, date, time FROM post WHERE tid='.$tid.' ORDER BY pid DESC LIMIT 0, 1');
$latestPost = $latestPostResult->fetch_array();
$userResult = $db->query('SELECT username, avatar FROM user WHERE uid='.$latestPost['uid']);
$latestUser = $userResult->fetch_array();
if($user && $latestPost)
{
?>
<article class="threadInfo">
<a href="viewthread.php?thread=<?= $tid; ?>" class="infoTitle"><?= $displayTitle; ?></a>
<br />
Created By:
<a href="profile.php?user=<?= $uid; ?>" class="infoUsername">
<img src="<?= $user['avatar']; ?>" alt="<?= $user['username'] ?>'s avatar" class="miniAvatar" />
<?= $user['username'] ?>
</a>
<div class="infoLatestPost">
Last Reply:
<a href="profile.php?user=<?= $latestPost['uid']; ?>" class="infoUsername">
<img src="<?= $latestUser['avatar']; ?>" alt="<?= $latestUser['username'] ?>'s avatar" class="miniAvatar" />
<?= $latestUser['username'] ?>
</a>
on <?= $latestPost['date']; ?> <?= $latestPost['time'] ?>
</div>
</article>
<?php
}
}
function template_post($db, $tid, $pid, $uid, $date, $time, $text)
{
$text = str_replace("\n", '<br />', $text);
$userResult = $db->query('SELECT username, avatar FROM user WHERE uid='.$uid);
$user = $userResult->fetch_array();
if($user)
{
?>
<article class="post">
<div class="userInfo">
<a href="profile.php?user=<?= $uid ?>"><img src="<?= $user['avatar']; ?>" alt="<?= $user['username'] ?>'s avatar" class="avatar" /></a>
<br />
<a href="profile.php?user=<?= $uid ?>" class="username"><?= $user['username']; ?></a>
</div>
<div class="text">
<div class="datetime"><?= $date.' '.$time; ?></div>
<?= $text; ?>
</div>
<br />
<div class="controls">
<?php
if($uid == $_SESSION['uid'])
echo '<a href="viewthread.php?thread='.$tid."&delete=".$pid."\">Delete</a>\n";
?>
<a href="createpost.php?thread=<?= $tid; ?>">Reply</a>
</div>
</article>
<?php
}
}
?>