[814] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[2297] | 3 | // | Piwigo - a PHP based picture gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
| 5 | // | Copyright(C) 2008 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 | // +-----------------------------------------------------------------------+ |
---|
[814] | 23 | |
---|
| 24 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 25 | { |
---|
| 26 | die ("Hacking attempt!"); |
---|
| 27 | } |
---|
| 28 | |
---|
[1072] | 29 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
[2232] | 30 | include_once(PHPWG_ROOT_PATH.'admin/include/check_integrity.class.php'); |
---|
| 31 | include_once(PHPWG_ROOT_PATH.'admin/include/c13y_internal.class.php'); |
---|
[1072] | 32 | |
---|
[814] | 33 | // +-----------------------------------------------------------------------+ |
---|
[1072] | 34 | // | Check Access and exit when user status is not ok | |
---|
| 35 | // +-----------------------------------------------------------------------+ |
---|
| 36 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 37 | |
---|
| 38 | // +-----------------------------------------------------------------------+ |
---|
[814] | 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 (!ini_get('allow_url_fopen')) |
---|
| 46 | { |
---|
| 47 | array_push( |
---|
| 48 | $page['errors'], |
---|
| 49 | l10n('Unable to check for upgrade since allow_url_fopen is disabled.') |
---|
| 50 | ); |
---|
| 51 | } |
---|
| 52 | else |
---|
| 53 | { |
---|
| 54 | $versions = array('current' => PHPWG_VERSION); |
---|
[1726] | 55 | $lines = @file(PHPWG_URL.'/latest_version'); |
---|
[1538] | 56 | |
---|
[814] | 57 | // if the current version is a BSF (development branch) build, we check |
---|
| 58 | // the first line, for stable versions, we check the second line |
---|
| 59 | if (preg_match('/^BSF/', $versions{'current'})) |
---|
| 60 | { |
---|
| 61 | $versions{'latest'} = trim($lines[0]); |
---|
| 62 | |
---|
| 63 | // because integer are limited to 4,294,967,296 we need to split BSF |
---|
| 64 | // versions in date.time |
---|
| 65 | foreach ($versions as $key => $value) |
---|
| 66 | { |
---|
| 67 | $versions{$key} = |
---|
| 68 | preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value); |
---|
| 69 | } |
---|
| 70 | } |
---|
| 71 | else |
---|
| 72 | { |
---|
| 73 | $versions{'latest'} = trim($lines[1]); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | if ('' == $versions{'latest'}) |
---|
| 77 | { |
---|
| 78 | array_push( |
---|
| 79 | $page['errors'], |
---|
| 80 | l10n('Check for upgrade failed for unknown reasons.') |
---|
| 81 | ); |
---|
| 82 | } |
---|
[1226] | 83 | // concatenation needed to avoid automatic transformation by release |
---|
| 84 | // script generator |
---|
| 85 | else if ('%'.'PWGVERSION'.'%' == $versions{'current'}) |
---|
[814] | 86 | { |
---|
| 87 | array_push( |
---|
| 88 | $page['infos'], |
---|
| 89 | l10n('You are running on development sources, no check possible.') |
---|
| 90 | ); |
---|
| 91 | } |
---|
| 92 | else if (version_compare($versions{'current'}, $versions{'latest'}) < 0) |
---|
| 93 | { |
---|
| 94 | array_push( |
---|
| 95 | $page['infos'], |
---|
[2342] | 96 | l10n('A new version of Piwigo is available.') |
---|
[814] | 97 | ); |
---|
| 98 | } |
---|
| 99 | else |
---|
| 100 | { |
---|
| 101 | array_push( |
---|
| 102 | $page['infos'], |
---|
[2342] | 103 | l10n('You are running the latest version of Piwigo.') |
---|
[814] | 104 | ); |
---|
| 105 | } |
---|
| 106 | } |
---|
| 107 | } |
---|
| 108 | // Show phpinfo() output |
---|
| 109 | else if (isset($_GET['action']) and 'phpinfo' == $_GET['action']) |
---|
| 110 | { |
---|
| 111 | phpinfo(); |
---|
| 112 | exit(); |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | // +-----------------------------------------------------------------------+ |
---|
| 116 | // | template init | |
---|
| 117 | // +-----------------------------------------------------------------------+ |
---|
| 118 | |
---|
| 119 | $template->set_filenames(array('intro' => 'admin/intro.tpl')); |
---|
| 120 | |
---|
[1888] | 121 | $php_current_timestamp = date("Y-m-d H:i:s"); |
---|
| 122 | list($mysql_version, $db_current_timestamp) = mysql_fetch_row(pwg_query('SELECT VERSION(), CURRENT_TIMESTAMP;')); |
---|
[814] | 123 | |
---|
| 124 | $query = ' |
---|
| 125 | SELECT COUNT(*) |
---|
| 126 | FROM '.IMAGES_TABLE.' |
---|
| 127 | ;'; |
---|
| 128 | list($nb_elements) = mysql_fetch_row(pwg_query($query)); |
---|
| 129 | |
---|
| 130 | $query = ' |
---|
| 131 | SELECT COUNT(*) |
---|
| 132 | FROM '.CATEGORIES_TABLE.' |
---|
| 133 | ;'; |
---|
| 134 | list($nb_categories) = mysql_fetch_row(pwg_query($query)); |
---|
| 135 | |
---|
| 136 | $query = ' |
---|
| 137 | SELECT COUNT(*) |
---|
| 138 | FROM '.CATEGORIES_TABLE.' |
---|
| 139 | WHERE dir IS NULL |
---|
| 140 | ;'; |
---|
| 141 | list($nb_virtual) = mysql_fetch_row(pwg_query($query)); |
---|
| 142 | |
---|
| 143 | $query = ' |
---|
| 144 | SELECT COUNT(*) |
---|
| 145 | FROM '.CATEGORIES_TABLE.' |
---|
| 146 | WHERE dir IS NOT NULL |
---|
| 147 | ;'; |
---|
| 148 | list($nb_physical) = mysql_fetch_row(pwg_query($query)); |
---|
| 149 | |
---|
| 150 | $query = ' |
---|
| 151 | SELECT COUNT(*) |
---|
[1538] | 152 | FROM '.IMAGE_CATEGORY_TABLE.' |
---|
| 153 | ;'; |
---|
| 154 | list($nb_image_category) = mysql_fetch_row(pwg_query($query)); |
---|
| 155 | |
---|
| 156 | $query = ' |
---|
| 157 | SELECT COUNT(*) |
---|
| 158 | FROM '.TAGS_TABLE.' |
---|
| 159 | ;'; |
---|
| 160 | list($nb_tags) = mysql_fetch_row(pwg_query($query)); |
---|
| 161 | |
---|
| 162 | $query = ' |
---|
| 163 | SELECT COUNT(*) |
---|
| 164 | FROM '.IMAGE_TAG_TABLE.' |
---|
| 165 | ;'; |
---|
| 166 | list($nb_image_tag) = mysql_fetch_row(pwg_query($query)); |
---|
| 167 | |
---|
| 168 | $query = ' |
---|
| 169 | SELECT COUNT(*) |
---|
[814] | 170 | FROM '.USERS_TABLE.' |
---|
| 171 | ;'; |
---|
| 172 | list($nb_users) = mysql_fetch_row(pwg_query($query)); |
---|
| 173 | |
---|
| 174 | $query = ' |
---|
| 175 | SELECT COUNT(*) |
---|
| 176 | FROM '.GROUPS_TABLE.' |
---|
| 177 | ;'; |
---|
| 178 | list($nb_groups) = mysql_fetch_row(pwg_query($query)); |
---|
| 179 | |
---|
| 180 | $query = ' |
---|
| 181 | SELECT COUNT(*) |
---|
| 182 | FROM '.COMMENTS_TABLE.' |
---|
| 183 | ;'; |
---|
| 184 | list($nb_comments) = mysql_fetch_row(pwg_query($query)); |
---|
| 185 | |
---|
[2230] | 186 | $template->assign( |
---|
[814] | 187 | array( |
---|
| 188 | 'PWG_VERSION' => PHPWG_VERSION, |
---|
| 189 | 'OS' => PHP_OS, |
---|
| 190 | 'PHP_VERSION' => phpversion(), |
---|
| 191 | 'MYSQL_VERSION' => $mysql_version, |
---|
[1932] | 192 | 'DB_ELEMENTS' => l10n_dec('%d element', '%d elements', $nb_elements), |
---|
[814] | 193 | 'DB_CATEGORIES' => |
---|
[1932] | 194 | l10n_dec('cat_inclu_part1_S', 'cat_inclu_part1_P', |
---|
| 195 | $nb_categories). |
---|
| 196 | l10n_dec('cat_inclu_part2_S', 'cat_inclu_part2_P', |
---|
| 197 | $nb_physical). |
---|
| 198 | l10n_dec('cat_inclu_part3_S', 'cat_inclu_part3_P', |
---|
| 199 | $nb_virtual), |
---|
| 200 | 'DB_IMAGE_CATEGORY' => l10n_dec('%d association', '%d associations', $nb_image_category), |
---|
| 201 | 'DB_TAGS' => l10n_dec('%d tag', '%d tags', $nb_tags), |
---|
| 202 | 'DB_IMAGE_TAG' => l10n_dec('%d association', '%d associations', $nb_image_tag), |
---|
| 203 | 'DB_USERS' => l10n_dec('%d user', '%d users', $nb_users), |
---|
| 204 | 'DB_GROUPS' => l10n_dec('%d group', '%d groups', $nb_groups), |
---|
| 205 | 'DB_COMMENTS' => l10n_dec('%d comment', '%d comments', $nb_comments), |
---|
[1004] | 206 | 'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade', |
---|
[1884] | 207 | 'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo', |
---|
| 208 | 'PHP_DATATIME' => $php_current_timestamp, |
---|
| 209 | 'DB_DATATIME' => $db_current_timestamp, |
---|
[814] | 210 | ) |
---|
| 211 | ); |
---|
[817] | 212 | |
---|
[861] | 213 | if ($nb_elements > 0) |
---|
| 214 | { |
---|
| 215 | $query = ' |
---|
| 216 | SELECT MIN(date_available) |
---|
| 217 | FROM '.IMAGES_TABLE.' |
---|
| 218 | ;'; |
---|
| 219 | list($first_date) = mysql_fetch_row(pwg_query($query)); |
---|
| 220 | |
---|
[2230] | 221 | $template->assign( |
---|
[861] | 222 | 'first_added', |
---|
| 223 | array( |
---|
| 224 | 'DB_DATE' => |
---|
| 225 | sprintf( |
---|
| 226 | l10n('first element added on %s'), |
---|
| 227 | format_date($first_date, 'mysql_datetime') |
---|
| 228 | ) |
---|
| 229 | ) |
---|
| 230 | ); |
---|
| 231 | } |
---|
| 232 | |
---|
[817] | 233 | // waiting elements |
---|
| 234 | $query = ' |
---|
| 235 | SELECT COUNT(*) |
---|
| 236 | FROM '.WAITING_TABLE.' |
---|
| 237 | WHERE validated=\'false\' |
---|
| 238 | ;'; |
---|
| 239 | list($nb_waiting) = mysql_fetch_row(pwg_query($query)); |
---|
| 240 | |
---|
| 241 | if ($nb_waiting > 0) |
---|
| 242 | { |
---|
[2230] | 243 | $template->assign( |
---|
[817] | 244 | 'waiting', |
---|
| 245 | array( |
---|
[2033] | 246 | 'URL' => PHPWG_ROOT_PATH.'admin.php?page=upload', |
---|
[817] | 247 | 'INFO' => sprintf(l10n('%d waiting for validation'), $nb_waiting) |
---|
| 248 | ) |
---|
| 249 | ); |
---|
| 250 | } |
---|
| 251 | |
---|
| 252 | // unvalidated comments |
---|
| 253 | $query = ' |
---|
| 254 | SELECT COUNT(*) |
---|
| 255 | FROM '.COMMENTS_TABLE.' |
---|
| 256 | WHERE validated=\'false\' |
---|
| 257 | ;'; |
---|
| 258 | list($nb_comments) = mysql_fetch_row(pwg_query($query)); |
---|
| 259 | |
---|
| 260 | if ($nb_comments > 0) |
---|
| 261 | { |
---|
[2230] | 262 | $template->assign( |
---|
[817] | 263 | 'unvalidated', |
---|
| 264 | array( |
---|
[1004] | 265 | 'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments', |
---|
[817] | 266 | 'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments) |
---|
| 267 | ) |
---|
| 268 | ); |
---|
| 269 | } |
---|
| 270 | |
---|
[814] | 271 | // +-----------------------------------------------------------------------+ |
---|
| 272 | // | sending html code | |
---|
| 273 | // +-----------------------------------------------------------------------+ |
---|
| 274 | |
---|
| 275 | $template->assign_var_from_handle('ADMIN_CONTENT', 'intro'); |
---|
| 276 | |
---|
[2232] | 277 | // Check integrity |
---|
| 278 | $c13y = new check_integrity(); |
---|
| 279 | // add internal checks |
---|
| 280 | new c13y_internal(); |
---|
| 281 | // check and display |
---|
| 282 | $c13y->check(); |
---|
| 283 | $c13y->display(); |
---|
[2065] | 284 | |
---|
[1724] | 285 | ?> |
---|