-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
196 lines (189 loc) · 6.54 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
$_zp_script_timer['start'] = microtime();
// force UTF-8 Ø
require_once(dirname(__FILE__).'/zp-core/global-definitions.php');
define('OFFSET_PATH', 0);
require_once(ZENFOLDER . "/template-functions.php");
checkInstall();
//$_zp_script_timer['require'] = microtime();
//rss feeds
if(isset($_GET['rss']) || isset($_GET['rss-news']) || isset($_GET['rss-comments'])) {
require_once(dirname(__FILE__). '/'.ZENFOLDER.'/functions-rss.php');
rssHitcounter();
startRSSCache();
//gallery RSS
if(isset($_GET['rss'])) {
if (!getOption('RSS_album_image')) {
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
include(ZENFOLDER. '/404.php');
exit();
}
require_once(ZENFOLDER .'/'.PLUGIN_FOLDER . "/image_album_statistics.php");
include(dirname(__FILE__). "/".ZENFOLDER.'/rss/rss.php');
}
//Zenpage News RSS
if(isset($_GET['rss-news'])) {
if (!getOption('RSS_articles')) {
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
include(ZENFOLDER. '/404.php');
exit();
}
include(dirname(__FILE__). "/".ZENFOLDER.'/rss/rss-news.php');
}
//Comments RSS
if(isset($_GET['rss-comments'])) {
if (!getOption('RSS_comments')) {
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
include(ZENFOLDER. '/404.php');
exit();
}
include(dirname(__FILE__). "/".ZENFOLDER.'/rss/rss-comments.php');
}
endRSSCache();
exit();
}
//$_zp_script_timer['rss'] = microtime();
/**
* Invoke the controller to handle requests
*/
require_once(dirname(__FILE__). "/".ZENFOLDER.'/controller.php');
$_zp_obj = '';
//$_zp_script_timer['controller'] = microtime();
// Display an arbitrary theme-included PHP page
if (isset($_GET['p'])) {
handleSearchParms('page', $_zp_current_album, $_zp_current_image);
$theme = setupTheme();
$page = str_replace(array('/','\\','.'), '', sanitize($_GET['p']));
if (isset($_GET['z'])) { // system page
if ($subfolder = sanitize($_GET['z'])) {
$subfolder .= '/';
}
$_zp_gallery_page = basename($_zp_obj = ZENFOLDER.'/'.$subfolder.$page.'.php');
} else {
$_zp_obj = THEMEFOLDER."/$theme/$page.php";
$_zp_gallery_page = basename($_zp_obj);
}
// Display an Image page.
} else if (in_context(ZP_IMAGE)) {
handleSearchParms('image', $_zp_current_album, $_zp_current_image);
$theme = setupTheme();
$_zp_gallery_page = basename($_zp_obj = THEMEFOLDER."/$theme/image.php");
// Display an Album page.
} else if (in_context(ZP_ALBUM)) {
if ($_zp_current_album->isDynamic()) {
$search = $_zp_current_album->getSearchEngine();
zp_setCookie("zenphoto_search_params", $search->getSearchParams(), SEARCH_DURATION);
} else {
handleSearchParms('album', $_zp_current_album);
}
$theme = setupTheme();
$_zp_gallery_page = basename($_zp_obj = THEMEFOLDER."/$theme/album.php");
// Display the Index page.
} else if (in_context(ZP_INDEX)) {
handleSearchParms('index');
$theme = setupTheme();
$_zp_gallery_page = basename($_zp_obj = THEMEFOLDER."/$theme/index.php");
}
//$_zp_script_timer['page'] = microtime();
if (!isset($theme)) {
$theme = setupTheme();
}
//$_zp_script_timer['theme setup'] = microtime();
$custom = SERVERPATH.'/'.THEMEFOLDER.'/'.internalToFilesystem($theme).'/functions.php';
if (file_exists($custom)) {
require_once($custom);
} else {
$custom = false;
}
if (DEBUG_PLUGINS) {
debugLog('Loading the "theme" plugins.');
}
$_zp_loaded_plugins = array();
foreach (getEnabledPlugins() as $extension=>$loadtype) {
if ($loadtype&THEME_PLUGIN) {
if (DEBUG_PLUGINS) {
list($usec, $sec) = explode(" ", microtime());
$start = (float)$usec + (float)$sec;
}
require_once(getPlugin($extension.'.php'));
if (DEBUG_PLUGINS) {
list($usec, $sec) = explode(" ", microtime());
$end = (float)$usec + (float)$sec;
debugLog(sprintf(' '.$extension.'('.($priority & PLUGIN_PRIORITY).')=>%.4fs',$end-$start));
}
// $_zp_script_timer['load '.$extension] = microtime();
}
$_zp_loaded_plugins[] = $extension;
}
if ($zp_request) {
$_zp_obj = zp_apply_filter('load_theme_script',$_zp_obj);
}
//$_zp_script_timer['theme scripts'] = microtime();
if ($zp_request && file_exists(SERVERPATH . "/" . internalToFilesystem($_zp_obj))) {
$hint = $show = false;
if (checkAccess($hint, $show)) { // ok to view
// re-initialize video dimensions if needed
if (isImageVideo() & isset($_zp_flash_player)) {
$_zp_current_image->updateDimensions();
}
setThemeColumns();
} else {
if (is_object($_zp_HTML_cache)) { // don't cache the logon page or you can never see the real one
$_zp_HTML_cache->abortHTMLCache();
}
$_zp_gallery_page = 'password.php';
$_zp_obj = SERVERPATH.'/'.THEMEFOLDER.'/'.$theme.'/password.php';
if (!file_exists(internalToFilesystem($_zp_obj))) {
$_zp_obj = SERVERPATH.'/'.ZENFOLDER.'/password.php';
}
}
// Include the appropriate page for the requested object, and a 200 OK header.
header ('Content-Type: text/html; charset=' . LOCAL_CHARSET);
header("HTTP/1.0 200 OK");
header("Status: 200 OK");
header('Last-Modified: ' . $_zp_last_modified);
zp_apply_filter('theme_headers');
include(internalToFilesystem($_zp_obj));
} else {
// If the requested object does not exist, issue a 404 and redirect to the theme's
// 404.php page, or a 404.php in the zp-core folder.
if (is_object($_zp_HTML_cache)) {
$_zp_HTML_cache->abortHTMLCache();
}
list($album, $image) = rewrite_get_album_image('album','image');
debug404($album, $image, $theme);
$_zp_gallery_page = '404.php';
$errpage = THEMEFOLDER.'/'.internalToFilesystem($theme).'/404.php';
header ('Content-Type: text/html; charset=' . LOCAL_CHARSET);
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
zp_apply_filter('theme_headers');
if (file_exists(SERVERPATH . "/" . $errpage)) {
if ($custom) require_once($custom);
include($errpage);
} else {
include(ZENFOLDER. '/404.php');
}
}
//$_zp_script_timer['theme script load'] = microtime();
exposeZenPhotoInformations($_zp_obj, $_zp_loaded_plugins, $theme);
//$_zp_script_timer['expose information'] = microtime();
db_close(); // close the database as we are done
echo "\n";
list($usec, $sec) = explode(' ', array_shift($_zp_script_timer));
$first = $last = (float)$usec + (float)$sec;
$_zp_script_timer['end'] = microtime();
foreach ($_zp_script_timer as $step=>$time) {
list($usec, $sec) = explode(" ", $time);
$cur = (float)$usec + (float)$sec;
printf("<!-- ".gettext('Zenphoto script processing %1$s:%2$.4f seconds')." -->\n",$step,$cur-$last);
$last = $cur;
}
if (count($_zp_script_timer)>1) printf("<!-- ".gettext('Zenphoto script processing total:%.4f seconds')." -->\n",$last-$first);
if (is_object($_zp_HTML_cache)) {
$_zp_HTML_cache->endHTMLCache();
}
?>