index.php
Language: PHP Hypertext Preprocessor
Last Modified: 2024-03-19 1:27:05 AM UTC
File Size: 1359 bytes
Last Modified: 2024-03-19 1:27:05 AM UTC
File Size: 1359 bytes
http://www.penguinstew.ca/index.php
<?php
if(!chdir($_SERVER['DOCUMENT_ROOT']))
{
print("ERROR: Can't set current directory to server root");
exit(1);
}
//Include model classes
require_once 'Model/IndexModel.php';
require_once 'Model/Posts/PostModel.php';
require_once 'Model/Posts/TopModel.php';
use \Model\IndexModel;
use \Model\Posts\TopModel;
use \Model\Posts\PostModel;
$page = $_GET["page"];
if(!isset($page))
{
$page = 1;
}
$model = new IndexModel();
$model->Top = new TopModel();
$model->Page = $page;
$pageSize = 4;
$pageSpread = 2;
$postCount = PostModel::GetPostCount();;
if($page > 1)
{
$model->PreviousPage = $page - 1;
}
$maxPages = ceil($postCount / $pageSize);
if($page < $maxPages)
{
$model->NextPage = $page + 1;
}
for($i = $page - $pageSpread ; $i < $page ; $i++)
{
if($i >= 1)
{
array_push($model->PreviousPages, $i);
}
}
for($i = $page + 1 ; $i <= $page + $pageSpread ; $i++)
{
if($i <= $maxPages)
{
array_push($model->NextPages, $i);
}
}
$model->Posts = PostModel::GetPostPage($page, $pageSize);
if($page == 1)
{
$title = "Penguin Stew - Home";
}
else
{
$title = "Penguin Stew - Page ". $page;
}
$leftmenu = true;
$contentPath = "View\indexView.php";
$scripts = "<script src=\"/scripts/TextSizeAdjust.js\"></script>\n";
include 'templates/master.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
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