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