-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
81 lines (67 loc) · 1.95 KB
/
index.php
File metadata and controls
81 lines (67 loc) · 1.95 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
<?php
define("INCLUDED", true); //This is for returning a die message if INCLUDED is not defined on any of the template
$AJAX_PAGE = false;
//################ Required Resources ################
$REQUIRED_RESOURCES = array();
//################ Required Files ################
require_once("init.php");
//################ PAGE ACCESS ################
$cms->BannedAccess(true);
eval($cms->SetPageAccess(ACCESS_ALL));
//################ General Variables ################
$page_name[] = array("News"=>"index.php");
//################ Page Functions ################
function FetchNews($start=0, $limit=5)
{
global $DB;
$query = new Query();
$query->Select("`news`")->Columns("*")->Order("`sticky` DESC, `date` DESC")->Limit($start, $limit)->Build();
$return = MySQLiFetch($DB->query($query, DBNAME));
return $return;
}
function FetchTotalNews()
{
global $DB;
$query = new Query();
$query->Select("`news`")->Columns(array("COUNT(*)"=>"numrows"))->Build();
$return = MySQLiFetch($DB->query($query, DBNAME), "onerow: 1");
return $return['numrows'];
}
function FetchNewsById($nid)
{
global $DB;
$query = new Query();
$query->Select("`news`")->Columns("*")->Where("`id` = '%s'", $nid)->Build();
$return = MySQLiFetch($DB->query($query, DBNAME), "onerow: 1");
return $return;
}
function FetchComments($limit)
{
global $DB;
$query = new Query();
$query->Select("`news_comments`")->Columns("*")->Where("`newsid` = '%s'", $_GET['id'])->Order("`date` ASC")->Limit($limit)->Build();
$return = MySQLiFetch($DB->query($query, DBNAME));
return $return;
}
//################ Template's Output ################
if(isset($_GET['id']))
{
$news = FetchNewsById($_GET['id']);
$comments = FetchComments("5");
if($news)
{
$page_name[] = array($news['title']=>$_SERVER['REQUEST_URI']);
eval($templates->Output('news_id'));
}
else
{
//TODO If no news found
}
}
else
{
$news = FetchNews();
$numnews = FetchTotalNews();
eval($templates->Output('news_home'));
}
?>