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: 2005-08-15 22:01:00 +0000 (Mon, 15 Aug 2005) $ |
---|
10 | // | last modifier : $Author: plg $ |
---|
11 | // | revision : $Revision: 814 $ |
---|
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 | include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); |
---|
33 | |
---|
34 | // +-----------------------------------------------------------------------+ |
---|
35 | // | actions | |
---|
36 | // +-----------------------------------------------------------------------+ |
---|
37 | |
---|
38 | // Check for upgrade : code inspired from punbb |
---|
39 | if (isset($_GET['action']) and 'check_upgrade' == $_GET['action']) |
---|
40 | { |
---|
41 | if (!ini_get('allow_url_fopen')) |
---|
42 | { |
---|
43 | array_push( |
---|
44 | $page['errors'], |
---|
45 | l10n('Unable to check for upgrade since allow_url_fopen is disabled.') |
---|
46 | ); |
---|
47 | } |
---|
48 | else |
---|
49 | { |
---|
50 | $versions = array('current' => PHPWG_VERSION); |
---|
51 | $lines = @file('http://www.phpwebgallery.net/latest_version'); |
---|
52 | |
---|
53 | // if the current version is a BSF (development branch) build, we check |
---|
54 | // the first line, for stable versions, we check the second line |
---|
55 | if (preg_match('/^BSF/', $versions{'current'})) |
---|
56 | { |
---|
57 | $versions{'latest'} = trim($lines[0]); |
---|
58 | |
---|
59 | // because integer are limited to 4,294,967,296 we need to split BSF |
---|
60 | // versions in date.time |
---|
61 | foreach ($versions as $key => $value) |
---|
62 | { |
---|
63 | $versions{$key} = |
---|
64 | preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value); |
---|
65 | } |
---|
66 | } |
---|
67 | else |
---|
68 | { |
---|
69 | $versions{'latest'} = trim($lines[1]); |
---|
70 | } |
---|
71 | |
---|
72 | if ('' == $versions{'latest'}) |
---|
73 | { |
---|
74 | array_push( |
---|
75 | $page['errors'], |
---|
76 | l10n('Check for upgrade failed for unknown reasons.') |
---|
77 | ); |
---|
78 | } |
---|
79 | else if ('%PWGVERSION%' == $versions{'current'}) |
---|
80 | { |
---|
81 | array_push( |
---|
82 | $page['infos'], |
---|
83 | l10n('You are running on development sources, no check possible.') |
---|
84 | ); |
---|
85 | } |
---|
86 | else if (version_compare($versions{'current'}, $versions{'latest'}) < 0) |
---|
87 | { |
---|
88 | array_push( |
---|
89 | $page['infos'], |
---|
90 | l10n('A new version of PhpWebGallery is available.') |
---|
91 | ); |
---|
92 | } |
---|
93 | else |
---|
94 | { |
---|
95 | array_push( |
---|
96 | $page['infos'], |
---|
97 | l10n('You are running the latest version of PhpWebGallery.') |
---|
98 | ); |
---|
99 | } |
---|
100 | } |
---|
101 | } |
---|
102 | // Show phpinfo() output |
---|
103 | else if (isset($_GET['action']) and 'phpinfo' == $_GET['action']) |
---|
104 | { |
---|
105 | phpinfo(); |
---|
106 | exit(); |
---|
107 | } |
---|
108 | |
---|
109 | // +-----------------------------------------------------------------------+ |
---|
110 | // | template init | |
---|
111 | // +-----------------------------------------------------------------------+ |
---|
112 | |
---|
113 | $template->set_filenames(array('intro' => 'admin/intro.tpl')); |
---|
114 | |
---|
115 | list($mysql_version) = mysql_fetch_row(pwg_query('SELECT VERSION();')); |
---|
116 | |
---|
117 | $query = ' |
---|
118 | SELECT COUNT(*) |
---|
119 | FROM '.IMAGES_TABLE.' |
---|
120 | ;'; |
---|
121 | list($nb_elements) = mysql_fetch_row(pwg_query($query)); |
---|
122 | |
---|
123 | $query = ' |
---|
124 | SELECT COUNT(*) |
---|
125 | FROM '.CATEGORIES_TABLE.' |
---|
126 | ;'; |
---|
127 | list($nb_categories) = mysql_fetch_row(pwg_query($query)); |
---|
128 | |
---|
129 | $query = ' |
---|
130 | SELECT COUNT(*) |
---|
131 | FROM '.CATEGORIES_TABLE.' |
---|
132 | WHERE dir IS NULL |
---|
133 | ;'; |
---|
134 | list($nb_virtual) = mysql_fetch_row(pwg_query($query)); |
---|
135 | |
---|
136 | $query = ' |
---|
137 | SELECT COUNT(*) |
---|
138 | FROM '.CATEGORIES_TABLE.' |
---|
139 | WHERE dir IS NOT NULL |
---|
140 | ;'; |
---|
141 | list($nb_physical) = mysql_fetch_row(pwg_query($query)); |
---|
142 | |
---|
143 | $query = ' |
---|
144 | SELECT COUNT(*) |
---|
145 | FROM '.USERS_TABLE.' |
---|
146 | ;'; |
---|
147 | list($nb_users) = mysql_fetch_row(pwg_query($query)); |
---|
148 | |
---|
149 | $query = ' |
---|
150 | SELECT COUNT(*) |
---|
151 | FROM '.GROUPS_TABLE.' |
---|
152 | ;'; |
---|
153 | list($nb_groups) = mysql_fetch_row(pwg_query($query)); |
---|
154 | |
---|
155 | $query = ' |
---|
156 | SELECT COUNT(*) |
---|
157 | FROM '.COMMENTS_TABLE.' |
---|
158 | ;'; |
---|
159 | list($nb_comments) = mysql_fetch_row(pwg_query($query)); |
---|
160 | |
---|
161 | $query = ' |
---|
162 | SELECT MIN(date_available) |
---|
163 | FROM '.IMAGES_TABLE.' |
---|
164 | ;'; |
---|
165 | list($first_date) = mysql_fetch_row(pwg_query($query)); |
---|
166 | |
---|
167 | $template->assign_vars( |
---|
168 | array( |
---|
169 | 'PWG_VERSION' => PHPWG_VERSION, |
---|
170 | 'OS' => PHP_OS, |
---|
171 | 'PHP_VERSION' => phpversion(), |
---|
172 | 'MYSQL_VERSION' => $mysql_version, |
---|
173 | 'DB_ELEMENTS' => sprintf(l10n('%d elements'), $nb_elements), |
---|
174 | 'DB_CATEGORIES' => |
---|
175 | sprintf( |
---|
176 | l10n('%d categories including %d physical and %d virtual'), |
---|
177 | $nb_categories, |
---|
178 | $nb_physical, |
---|
179 | $nb_virtual |
---|
180 | ), |
---|
181 | 'DB_USERS' => sprintf(l10n('%d users'), $nb_users), |
---|
182 | 'DB_GROUPS' => sprintf(l10n('%d groups'), $nb_groups), |
---|
183 | 'DB_COMMENTS' => sprintf(l10n('%d comments'), $nb_comments), |
---|
184 | 'DB_DATE' => |
---|
185 | sprintf( |
---|
186 | l10n('first element added on %s'), |
---|
187 | format_date($first_date, 'mysql_datetime') |
---|
188 | ), |
---|
189 | 'U_CHECK_UPGRADE' => |
---|
190 | add_session_id(PHPWG_ROOT_PATH.'admin.php?action=check_upgrade'), |
---|
191 | 'U_PHPINFO' => |
---|
192 | add_session_id(PHPWG_ROOT_PATH.'admin.php?action=phpinfo') |
---|
193 | ) |
---|
194 | ); |
---|
195 | |
---|
196 | // +-----------------------------------------------------------------------+ |
---|
197 | // | sending html code | |
---|
198 | // +-----------------------------------------------------------------------+ |
---|
199 | |
---|
200 | $template->assign_var_from_handle('ADMIN_CONTENT', 'intro'); |
---|
201 | |
---|
202 | ?> |
---|