-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
45 lines (34 loc) · 1.13 KB
/
index.php
File metadata and controls
45 lines (34 loc) · 1.13 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
<?php
require_once('templates/common.tpl.php');
require_once('database/common.tpl.db.php');
require_once('database/connection.db.php');
require_once('templates/items.tpl.php');
require_once('templates/pagination.tpl.php');
require_once('class/pagination.class.php');
$session = new Session();
$db = getDatabaseConnection();
$numberItems = getNumberOfItems($db);
if($numberItems == -1){
exit();
}
$pagination = new Pagination($numberItems);
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
$pagination->setCurrentPage(intval($_GET['page']));
}else{
$pagination->setCurrentPage(1);
}
if(isset($_GET['category']) && $_GET['category'] != 'All'){
$category = $_GET['category'];
$items = Item::getItemsByCategory($db, $category, $pagination->getOffset(), $pagination->getLimit());
drawHeader($session,true);
drawItems($items);
drawFooter();
exit();
}else {
$items = Item::getItemsStartingOn($db, $pagination->getOffset(), $pagination->getLimit());
drawHeader($session,true);
drawItems($items);
drawPagination($pagination);
drawFooter();
}
?>