-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
127 lines (107 loc) · 3.67 KB
/
index.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/*
LightBlog, a PHP/SQLite blogging platform
Copyright (C) 2008-2016 The LightBlog Team.
index.php
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// This constant will allows us to include files that can't be viewed
// directly.
define('INLB', true);
// We definitely need this, it will setup everything we need.
require('Sources/Core.php');
// Which theme are you using?
$themeName = get_bloginfo('theme');
// This could be fatal!
if(!file_exists('themes/'. basename($themeName). '/main.php'))
{
trigger_error('The theme "'. utf_htmlspecialchars($themeName). '" does not exist', E_USER_ERROR);
}
// If it isn't a post or page we're showing, then make a list of posts.
if(!isset($_GET['post']) && !isset($_GET['page']))
{
// Require the proper loop class
require(ABSPATH .'/Sources/Class.PostLoop.php');
// Pagination variables
$file = basename($_SERVER['SCRIPT_FILENAME']);
if(isset($_GET['p']))
{
$page = (int)$_GET['p'];
}
else
{
$page = 1;
}
// Display the right post view
if(isset($_GET['archive']))
{
$GLOBALS['postquery']['type'] = 'archive';
$GLOBALS['postquery']['date'] = (int)$_GET['archive'];
}
elseif(isset($_GET['category']))
{
$GLOBALS['postquery']['type'] = 'category';
$GLOBALS['postquery']['catid'] = (int)$_GET['category'];
}
else
{
$GLOBALS['postquery']['type'] = 'latest';
}
// Include main theme file
include('themes/'. $themeName. '/main.php');
}
// Looks like it is a post or page
else
{
if(isset($_GET['post']))
{
function formCallback($response)
{
if(!empty($response))
{
if($response['result'] == 'error' || $response['result'] == 'success')
{
if(isset($response['response']))
{
return $response['response'];
}
}
else
{
return 'No response from form processor.';
}
}
return;
}
// Require the proper loop class
require(ABSPATH .'/Sources/Class.PostLoop.php');
require(ABSPATH .'/Sources/Class.CommentLoop.php');
require(ABSPATH .'/Sources/Process.php');
$_SESSION['cmessage'] = formCallback(processForm($_POST));
// Get post ID
$GLOBALS['pid'] = (int)$_GET['post'];
$GLOBALS['postquery']['type'] = 'post';
// Display appropriate theme file
include('themes/'.$themeName.'/post.php');
}
elseif(isset($_GET['page']))
{
// Require the proper loop class
require(ABSPATH .'/Sources/Class.PageLoop.php');
// Get page ID
$GLOBALS['pid'] = (int)$_GET['page'];
$GLOBALS['postquery']['type'] = 'page';
// Display appropriate theme file
include('themes/'.$themeName.'/page.php');
}
}
?>