-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
114 lines (111 loc) · 4.12 KB
/
index.php
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
<?php
global $BODY_ID;
$BODY_ID = "frontpage";
include_once("bootstrap.inc.php");
include_once("header.inc.php");
?>
<section id="bumper">
<div>
<article id="demand">
<h2>We want</h2>
<?php $count = SQLLib::SelectRow("SELECT count(*) AS c FROM posts WHERE intent='demand' AND closureReason is NULL AND (expiry IS NULL OR expiry > NOW())")->c; ?>
<p>Currently, <?=$count?> people are looking for somebody to help them with their projects!</p>
<a href="<?=ROOT_URL?>show-posts/?intent=demand">I can help!</a>
</article>
<article id="supply">
<h2>We offer</h2>
<?php $count = SQLLib::SelectRow("SELECT count(*) AS c FROM posts WHERE intent='supply' AND closureReason is NULL AND (expiry IS NULL OR expiry > NOW())")->c; ?>
<p>At the same time, <?=$count?> people are offering their skills to help out others!</p>
<a href="<?=ROOT_URL?>show-posts/?intent=supply">I need help!</a>
</article>
<article id="about">
<h2>We... wat?</h2>
<p>You don't know what this is about? No problem, we're all about sharing!</p>
<a href="<?=ROOT_URL?>about/">Tell me!</a>
</article>
</div>
</section>
<section id="content">
<div>
<div id='news'>
<?php
$posts = SQLLib::SelectRows("SELECT * FROM posts LEFT JOIN users ON users.sceneID = posts.userID WHERE closureReason is NULL ORDER BY postDate DESC LIMIT 5");
foreach($posts as $post)
{
?>
<article class='postlist'>
<div class='itemHeader area_<?=$post->area?> intent_<?=$post->intent?>'>
<h3><a href='<?=ROOT_URL?>post/<?=$post->id?>/<?=hashify($post->title)?>'><?=_html($post->title)?></a></h3>
<span class="author">Posted by <?=_html($post->displayName)?> <?=sprintf("<time datetime='%s'>%s</time>",$post->postDate,dateDiffReadable(time(),$post->postDate))?></span>
</div>
<div class='body'>
<?php
$c = $post->contents;
$c = shortify($c,500);
$c = parse_post($c);
echo $c;
?>
<a class='readmore' href='<?=ROOT_URL?>post/<?=$post->id?>/<?=hashify($post->title)?>'>Read more...</a>
</div>
</article>
<?php
}
?>
<div id='pagination'>
<a href="<?=ROOT_URL?>show-posts/">Read more posts »</a>
</div>
</div>
<div id='sidebar'>
<?php
if (@$_SESSION["userID"]) {
$unread = SQLLib::SelectRow( sprintf_esc("select count(*) as cnt from messages where userRecipient = %d and `read` = 0",$_SESSION["userID"]) )->cnt;
?>
<aside id="profile" class="box">
<h2>Hi, <?=_html($currentUser->displayName)?>!</h2>
<ul>
<?php if($currentUser->isAdmin){?>
<li><a href="<?=ROOT_URL?>admin/">Admin</a></li>
<?php }?>
<li><a href="<?=ROOT_URL?>profile/">Your settings</a></li>
<li><a href="<?=ROOT_URL?>show-posts/?mine=true">Your current posts</a></li>
<li><a href="<?=ROOT_URL?>messages/">Your messages<?=($unread?sprintf(" - <span class='unread'>%d new!</span>",$unread):"")?></a></li>
<li><a href="<?=ROOT_URL?>add-post/">Add a new post!</a></li>
<li><a href="<?=ROOT_URL?>logout/">Log out</a></li>
</ul>
</aside>
<?php } else { ?>
<aside id="login" class="box">
<h2>Log in!</h2>
<a href="<?=ROOT_URL?>login/">Log in via SceneID!</a>
</aside>
<?php } ?>
<aside id="categories" class="box">
<h2>Categories</h2>
<ul>
<?php
$posts = SQLLib::SelectRows("SELECT area, count(*) AS c FROM posts WHERE (expiry IS NULL OR expiry > NOW()) AND closureReason is NULL GROUP BY area ORDER BY area");
foreach($posts as $post)
{
$names = array(
'code' =>"Code",
'graphics'=>"Graphics",
'music' =>"Music",
'other' =>"Other",
);
?>
<li><a href='<?=ROOT_URL?>show-posts/?area[<?=_html($post->area)?>]=on'><?=_html($names[$post->area])?> <span><?=$post->c?></span></a></li>
<?php
}
?>
</ul>
</aside>
<aside class="box">
<h2>Showcase</h2>
<p>Want to see some testimonials on projects that turned to fruition because of Wanted? <a href="<?=ROOT_URL?>showcase/">Click here!</a></p>
</aside>
</div>
</div>
</section>
<?php
include_once("footer.inc.php");
?>