-
Notifications
You must be signed in to change notification settings - Fork 0
/
topics.php
33 lines (29 loc) · 1.04 KB
/
topics.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
<?php require('core/init.php');?>
<?php
$topic=new Topic;
$template=new Template("templates/topics.php");
$category=isset($_GET['category']) ? $_GET['category'] : null;
$user_id=isset($_GET['user']) ? $_GET['user'] : null;
if(isset($_GET['category'])&&!empty($_GET['category']))
{
$template->topics=$topic->getTopicsByCategory($category);
$template->title='Posts in "'.$topic->getCategoryName($category)->name.'"';
}else if(isset($_GET['user'])&&!empty($_GET['user']))
{$template->topics=$topic->getPostsByUserId($user_id);
$template->title='Posts by "'.$topic->userName($user_id)->username.'"';
}
else
$template->topics=$topic->getAllTopics();
$template->totUsers=totUsers();
$template->totTopics=topicsCount("all");
$template->totCategories=totCategories();
if(isLoggedIn())
{
$template->user_id=$_SESSION['user_id'];
$template->username=$_SESSION['username'];
$template->email=$_SESSION['email'];
$template->avatar=$_SESSION['avatar'];
$template->last_activity=$_SESSION['last_activity'];
}else redirect("home.php");
echo $template;
?>