1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based picture gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | if (!defined('PHPWG_ROOT_PATH')) |
---|
25 | { |
---|
26 | die ("Hacking attempt!"); |
---|
27 | } |
---|
28 | |
---|
29 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
30 | include_once(PHPWG_ROOT_PATH.'admin/include/check_integrity.class.php'); |
---|
31 | include_once(PHPWG_ROOT_PATH.'admin/include/c13y_internal.class.php'); |
---|
32 | |
---|
33 | // +-----------------------------------------------------------------------+ |
---|
34 | // | Check Access and exit when user status is not ok | |
---|
35 | // +-----------------------------------------------------------------------+ |
---|
36 | check_status(ACCESS_ADMINISTRATOR); |
---|
37 | |
---|
38 | // +-----------------------------------------------------------------------+ |
---|
39 | // | actions | |
---|
40 | // +-----------------------------------------------------------------------+ |
---|
41 | |
---|
42 | // Check for upgrade : code inspired from punbb |
---|
43 | if (isset($_GET['action']) and 'check_upgrade' == $_GET['action']) |
---|
44 | { |
---|
45 | if (!fetchRemote(PHPWG_URL.'/download/latest_version', $result)) |
---|
46 | { |
---|
47 | array_push($page['errors'], l10n('Unable to check for upgrade.')); |
---|
48 | } |
---|
49 | else |
---|
50 | { |
---|
51 | $versions = array('current' => PHPWG_VERSION); |
---|
52 | $lines = @explode("\r\n", $result); |
---|
53 | |
---|
54 | // if the current version is a BSF (development branch) build, we check |
---|
55 | // the first line, for stable versions, we check the second line |
---|
56 | if (preg_match('/^BSF/', $versions{'current'})) |
---|
57 | { |
---|
58 | $versions{'latest'} = trim($lines[0]); |
---|
59 | |
---|
60 | // because integer are limited to 4,294,967,296 we need to split BSF |
---|
61 | // versions in date.time |
---|
62 | foreach ($versions as $key => $value) |
---|
63 | { |
---|
64 | $versions{$key} = |
---|
65 | preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value); |
---|
66 | } |
---|
67 | } |
---|
68 | else |
---|
69 | { |
---|
70 | $versions{'latest'} = trim($lines[1]); |
---|
71 | } |
---|
72 | |
---|
73 | if ('' == $versions{'latest'}) |
---|
74 | { |
---|
75 | array_push( |
---|
76 | $page['errors'], |
---|
77 | l10n('Check for upgrade failed for unknown reasons.') |
---|
78 | ); |
---|
79 | } |
---|
80 | // concatenation needed to avoid automatic transformation by release |
---|
81 | // script generator |
---|
82 | else if ('%'.'PWGVERSION'.'%' == $versions{'current'}) |
---|
83 | { |
---|
84 | array_push( |
---|
85 | $page['infos'], |
---|
86 | l10n('You are running on development sources, no check possible.') |
---|
87 | ); |
---|
88 | } |
---|
89 | else if (version_compare($versions{'current'}, $versions{'latest'}) < 0) |
---|
90 | { |
---|
91 | array_push( |
---|
92 | $page['infos'], |
---|
93 | l10n('A new version of Piwigo is available.') |
---|
94 | ); |
---|
95 | } |
---|
96 | else |
---|
97 | { |
---|
98 | array_push( |
---|
99 | $page['infos'], |
---|
100 | l10n('You are running the latest version of Piwigo.') |
---|
101 | ); |
---|
102 | } |
---|
103 | } |
---|
104 | } |
---|
105 | // Show phpinfo() output |
---|
106 | else if (isset($_GET['action']) and 'phpinfo' == $_GET['action']) |
---|
107 | { |
---|
108 | phpinfo(); |
---|
109 | exit(); |
---|
110 | } |
---|
111 | |
---|
112 | // +-----------------------------------------------------------------------+ |
---|
113 | // | template init | |
---|
114 | // +-----------------------------------------------------------------------+ |
---|
115 | |
---|
116 | $template->set_filenames(array('intro' => 'intro.tpl')); |
---|
117 | |
---|
118 | $php_current_timestamp = date("Y-m-d H:i:s"); |
---|
119 | list($mysql_version, $db_current_timestamp) = mysql_fetch_row(pwg_query('SELECT VERSION(), CURRENT_TIMESTAMP;')); |
---|
120 | |
---|
121 | $query = ' |
---|
122 | SELECT COUNT(*) |
---|
123 | FROM '.IMAGES_TABLE.' |
---|
124 | ;'; |
---|
125 | list($nb_elements) = mysql_fetch_row(pwg_query($query)); |
---|
126 | |
---|
127 | $query = ' |
---|
128 | SELECT COUNT(*) |
---|
129 | FROM '.CATEGORIES_TABLE.' |
---|
130 | ;'; |
---|
131 | list($nb_categories) = mysql_fetch_row(pwg_query($query)); |
---|
132 | |
---|
133 | $query = ' |
---|
134 | SELECT COUNT(*) |
---|
135 | FROM '.CATEGORIES_TABLE.' |
---|
136 | WHERE dir IS NULL |
---|
137 | ;'; |
---|
138 | list($nb_virtual) = mysql_fetch_row(pwg_query($query)); |
---|
139 | |
---|
140 | $query = ' |
---|
141 | SELECT COUNT(*) |
---|
142 | FROM '.CATEGORIES_TABLE.' |
---|
143 | WHERE dir IS NOT NULL |
---|
144 | ;'; |
---|
145 | list($nb_physical) = mysql_fetch_row(pwg_query($query)); |
---|
146 | |
---|
147 | $query = ' |
---|
148 | SELECT COUNT(*) |
---|
149 | FROM '.IMAGE_CATEGORY_TABLE.' |
---|
150 | ;'; |
---|
151 | list($nb_image_category) = mysql_fetch_row(pwg_query($query)); |
---|
152 | |
---|
153 | $query = ' |
---|
154 | SELECT COUNT(*) |
---|
155 | FROM '.TAGS_TABLE.' |
---|
156 | ;'; |
---|
157 | list($nb_tags) = mysql_fetch_row(pwg_query($query)); |
---|
158 | |
---|
159 | $query = ' |
---|
160 | SELECT COUNT(*) |
---|
161 | FROM '.IMAGE_TAG_TABLE.' |
---|
162 | ;'; |
---|
163 | list($nb_image_tag) = mysql_fetch_row(pwg_query($query)); |
---|
164 | |
---|
165 | $query = ' |
---|
166 | SELECT COUNT(*) |
---|
167 | FROM '.USERS_TABLE.' |
---|
168 | ;'; |
---|
169 | list($nb_users) = mysql_fetch_row(pwg_query($query)); |
---|
170 | |
---|
171 | $query = ' |
---|
172 | SELECT COUNT(*) |
---|
173 | FROM '.GROUPS_TABLE.' |
---|
174 | ;'; |
---|
175 | list($nb_groups) = mysql_fetch_row(pwg_query($query)); |
---|
176 | |
---|
177 | $query = ' |
---|
178 | SELECT COUNT(*) |
---|
179 | FROM '.COMMENTS_TABLE.' |
---|
180 | ;'; |
---|
181 | list($nb_comments) = mysql_fetch_row(pwg_query($query)); |
---|
182 | |
---|
183 | $template->assign( |
---|
184 | array( |
---|
185 | 'PWG_VERSION' => PHPWG_VERSION, |
---|
186 | 'OS' => PHP_OS, |
---|
187 | 'PHP_VERSION' => phpversion(), |
---|
188 | 'MYSQL_VERSION' => $mysql_version, |
---|
189 | 'DB_ELEMENTS' => l10n_dec('%d element', '%d elements', $nb_elements), |
---|
190 | 'DB_CATEGORIES' => |
---|
191 | l10n_dec('cat_inclu_part1_S', 'cat_inclu_part1_P', |
---|
192 | $nb_categories). |
---|
193 | l10n_dec('cat_inclu_part2_S', 'cat_inclu_part2_P', |
---|
194 | $nb_physical). |
---|
195 | l10n_dec('cat_inclu_part3_S', 'cat_inclu_part3_P', |
---|
196 | $nb_virtual), |
---|
197 | 'DB_IMAGE_CATEGORY' => l10n_dec('%d association', '%d associations', $nb_image_category), |
---|
198 | 'DB_TAGS' => l10n_dec('%d tag', '%d tags', $nb_tags), |
---|
199 | 'DB_IMAGE_TAG' => l10n_dec('%d association', '%d associations', $nb_image_tag), |
---|
200 | 'DB_USERS' => l10n_dec('%d user', '%d users', $nb_users), |
---|
201 | 'DB_GROUPS' => l10n_dec('%d group', '%d groups', $nb_groups), |
---|
202 | 'DB_COMMENTS' => l10n_dec('%d comment', '%d comments', $nb_comments), |
---|
203 | 'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade', |
---|
204 | 'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo', |
---|
205 | 'PHP_DATATIME' => $php_current_timestamp, |
---|
206 | 'DB_DATATIME' => $db_current_timestamp, |
---|
207 | ) |
---|
208 | ); |
---|
209 | |
---|
210 | if ($nb_elements > 0) |
---|
211 | { |
---|
212 | $query = ' |
---|
213 | SELECT MIN(date_available) |
---|
214 | FROM '.IMAGES_TABLE.' |
---|
215 | ;'; |
---|
216 | list($first_date) = mysql_fetch_row(pwg_query($query)); |
---|
217 | |
---|
218 | $template->assign( |
---|
219 | 'first_added', |
---|
220 | array( |
---|
221 | 'DB_DATE' => |
---|
222 | sprintf( |
---|
223 | l10n('first element added on %s'), |
---|
224 | format_date($first_date) |
---|
225 | ) |
---|
226 | ) |
---|
227 | ); |
---|
228 | } |
---|
229 | |
---|
230 | // waiting elements |
---|
231 | $query = ' |
---|
232 | SELECT COUNT(*) |
---|
233 | FROM '.WAITING_TABLE.' |
---|
234 | WHERE validated=\'false\' |
---|
235 | ;'; |
---|
236 | list($nb_waiting) = mysql_fetch_row(pwg_query($query)); |
---|
237 | |
---|
238 | if ($nb_waiting > 0) |
---|
239 | { |
---|
240 | $template->assign( |
---|
241 | 'waiting', |
---|
242 | array( |
---|
243 | 'URL' => PHPWG_ROOT_PATH.'admin.php?page=upload', |
---|
244 | 'INFO' => sprintf(l10n('%d waiting for validation'), $nb_waiting) |
---|
245 | ) |
---|
246 | ); |
---|
247 | } |
---|
248 | |
---|
249 | // unvalidated comments |
---|
250 | $query = ' |
---|
251 | SELECT COUNT(*) |
---|
252 | FROM '.COMMENTS_TABLE.' |
---|
253 | WHERE validated=\'false\' |
---|
254 | ;'; |
---|
255 | list($nb_comments) = mysql_fetch_row(pwg_query($query)); |
---|
256 | |
---|
257 | if ($nb_comments > 0) |
---|
258 | { |
---|
259 | $template->assign( |
---|
260 | 'unvalidated', |
---|
261 | array( |
---|
262 | 'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments', |
---|
263 | 'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments) |
---|
264 | ) |
---|
265 | ); |
---|
266 | } |
---|
267 | |
---|
268 | // +-----------------------------------------------------------------------+ |
---|
269 | // | sending html code | |
---|
270 | // +-----------------------------------------------------------------------+ |
---|
271 | |
---|
272 | $template->assign_var_from_handle('ADMIN_CONTENT', 'intro'); |
---|
273 | |
---|
274 | // Check integrity |
---|
275 | $c13y = new check_integrity(); |
---|
276 | // add internal checks |
---|
277 | new c13y_internal(); |
---|
278 | // check and display |
---|
279 | $c13y->check(); |
---|
280 | $c13y->display(); |
---|
281 | |
---|
282 | ?> |
---|