-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsource.php
More file actions
52 lines (52 loc) · 2.02 KB
/
source.php
File metadata and controls
52 lines (52 loc) · 2.02 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
<?php
include('include/autoloader.php');
// recieve the source id and slug variables
$id = intval(make_safe(xss_clean($_GET['id'])));
$slug = make_safe(xss_clean($_GET['slug']));
$source = $general->source($id); // the source method found in include/general.class.php
// check if the source exists, if not redirect to error page
if ($source == 0) {
header('Location:'.$general_setting['siteurl'].'/not-found');
}
// fetching the result
foreach ($source AS $key=>$value) {
$smarty->assign('source_'.$key,$value);
}
// fetch the url to get the page id
$ur = explode('?',curPageURL());
if (count($ur) != 0) {
if (isset($ur[1])) {
parse_str($ur[1],$query);
}
}
$page = 1; // first page number
$size = $theme_setting['source_news_number']; // number of news per category page you can change it from theme setting
if (isset($query['page'])){ $page = (int) $query['page']; }
// count news number that related to this source
$sqls = "SELECT * FROM news WHERE published='1' AND source_id='$id'";
$query = $mysqli->query($sqls);
$total_records = $query->num_rows;
$smarty->assign('total_records',$total_records);
if ($total_records > 0) {
// define the pagination class. found at : include/pagination.php
$pagination = new Pagination();
$pagination->setLink("./source/$id/$slug?page=%s");
$pagination->setPage($page);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);
$get = "SELECT * FROM news WHERE published='1' AND source_id='$id' ORDER BY id DESC ".$pagination->getLimitSql();
$q = $mysqli->query($get);
while ($row = $q->fetch_assoc()) {
$news[] = $row;
}
$smarty->assign('news',$news);
$pagi = $pagination->create_links();
$smarty->assign('pagi',$pagi);
}
// assign the SEO variables (title,keywords,description).
$smarty->assign('seo_title',$source['title']);
$smarty->assign('seo_keywords',$general_setting['seo_keywords']);
$smarty->assign('seo_description',$general_setting['seo_description']);
// display the source HTML
$smarty->display('source.html');
?>