-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
55 lines (50 loc) · 1.37 KB
/
Copy pathindex.php
File metadata and controls
55 lines (50 loc) · 1.37 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
<?php
/**
* Insert the config file and check if the the user action is set or not. If not => set to "".
*
* config.php already contains Post.php
*
*/
require_once('./config.php');
$action = isset($_GET['action']) ? $_GET['action'] : "";
// Decide which action to perform
switch($action) {
case 'archive':
archive();
break;
case 'viewPost':
viewPost();
break;
default:
homepage();
}
/**
* Functions for user actions
*/
function homepage() {
$results = array();
$data = Post::getList(HOMPAGE_POST_NUM);
$results['posts'] = $data['results'];
$results['totalRows'] = $data['totalRows'];
$results['pageTitle'] = "BOTTLE CAP";
require_once(TEMPLATE_PATH . "/homepage.php");
}
function archive() {
$results = array();
$data = Post::getList();
$results['posts'] = $data['results'];
$results['totalRows'] = $data['totalRows'];
$results['pageTitle'] = "ARCHIVE | BOTTLE CAP";
require_once(TEMPLATE_PATH . "/archive.php");
}
function viewPost() {
if (!isset($_GET['postId']) || !$_GET['postId']) {
homepage();
return;
}
$results = array();
$results['post'] = Post::getById((int)$_GET['postId']);
$results['pageTitle'] = $results['post']->title . " | BOTTLE CAP";
require_once(TEMPLATE_PATH . "/viewPost.php");
}
?>