[814] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[2297] | 3 | // | Piwigo - a PHP based picture gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[5196] | 5 | // | Copyright(C) 2008-2010 Piwigo Team http://piwigo.org | |
---|
[2297] | 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 | { |
---|
[3133] | 45 | if (!fetchRemote(PHPWG_URL.'/download/latest_version', $result)) |
---|
[814] | 46 | { |
---|
[2880] | 47 | array_push($page['errors'], l10n('Unable to check for upgrade.')); |
---|
[814] | 48 | } |
---|
| 49 | else |
---|
| 50 | { |
---|
| 51 | $versions = array('current' => PHPWG_VERSION); |
---|
[2880] | 52 | $lines = @explode("\r\n", $result); |
---|
[1538] | 53 | |
---|
[814] | 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 |
---|
[4325] | 56 | if (preg_match('/^BSF/', $versions['current'])) |
---|
[814] | 57 | { |
---|
[4325] | 58 | $versions['latest'] = trim($lines[0]); |
---|
[814] | 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 | { |
---|
[4325] | 64 | $versions[$key] = |
---|
[814] | 65 | preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value); |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | else |
---|
| 69 | { |
---|
[4325] | 70 | $versions['latest'] = trim($lines[1]); |
---|
[814] | 71 | } |
---|
| 72 | |
---|
[4325] | 73 | if ('' == $versions['latest']) |
---|
[814] | 74 | { |
---|
| 75 | array_push( |
---|
| 76 | $page['errors'], |
---|
| 77 | l10n('Check for upgrade failed for unknown reasons.') |
---|
| 78 | ); |
---|
| 79 | } |
---|
[1226] | 80 | // concatenation needed to avoid automatic transformation by release |
---|
| 81 | // script generator |
---|
[4325] | 82 | else if ('%'.'PWGVERSION'.'%' == $versions['current']) |
---|
[814] | 83 | { |
---|
| 84 | array_push( |
---|
| 85 | $page['infos'], |
---|
| 86 | l10n('You are running on development sources, no check possible.') |
---|
| 87 | ); |
---|
| 88 | } |
---|
[4325] | 89 | else if (version_compare($versions['current'], $versions['latest']) < 0) |
---|
[814] | 90 | { |
---|
| 91 | array_push( |
---|
| 92 | $page['infos'], |
---|
[2342] | 93 | l10n('A new version of Piwigo is available.') |
---|
[814] | 94 | ); |
---|
| 95 | } |
---|
| 96 | else |
---|
| 97 | { |
---|
| 98 | array_push( |
---|
| 99 | $page['infos'], |
---|
[2342] | 100 | l10n('You are running the latest version of Piwigo.') |
---|
[814] | 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 | |
---|
[2529] | 116 | $template->set_filenames(array('intro' => 'intro.tpl')); |
---|
[814] | 117 | |
---|
[3382] | 118 | if ($conf['show_newsletter_subscription']) { |
---|
| 119 | $template->assign( |
---|
| 120 | array( |
---|
| 121 | 'EMAIL' => $user['email'], |
---|
| 122 | 'SUBSCRIBE_BASE_URL' => get_newsletter_subscribe_base_url($user['language']), |
---|
| 123 | ) |
---|
| 124 | ); |
---|
| 125 | } |
---|
| 126 | |
---|
[1888] | 127 | $php_current_timestamp = date("Y-m-d H:i:s"); |
---|
[4325] | 128 | $db_version = pwg_get_db_version(); |
---|
[6604] | 129 | list($db_current_date) = pwg_db_fetch_row(pwg_query('SELECT now();')); |
---|
[814] | 130 | |
---|
| 131 | $query = ' |
---|
| 132 | SELECT COUNT(*) |
---|
| 133 | FROM '.IMAGES_TABLE.' |
---|
| 134 | ;'; |
---|
[4325] | 135 | list($nb_elements) = pwg_db_fetch_row(pwg_query($query)); |
---|
[814] | 136 | |
---|
| 137 | $query = ' |
---|
| 138 | SELECT COUNT(*) |
---|
| 139 | FROM '.CATEGORIES_TABLE.' |
---|
| 140 | ;'; |
---|
[4325] | 141 | list($nb_categories) = pwg_db_fetch_row(pwg_query($query)); |
---|
[814] | 142 | |
---|
| 143 | $query = ' |
---|
| 144 | SELECT COUNT(*) |
---|
| 145 | FROM '.CATEGORIES_TABLE.' |
---|
| 146 | WHERE dir IS NULL |
---|
| 147 | ;'; |
---|
[4325] | 148 | list($nb_virtual) = pwg_db_fetch_row(pwg_query($query)); |
---|
[814] | 149 | |
---|
| 150 | $query = ' |
---|
| 151 | SELECT COUNT(*) |
---|
| 152 | FROM '.CATEGORIES_TABLE.' |
---|
| 153 | WHERE dir IS NOT NULL |
---|
| 154 | ;'; |
---|
[4325] | 155 | list($nb_physical) = pwg_db_fetch_row(pwg_query($query)); |
---|
[814] | 156 | |
---|
| 157 | $query = ' |
---|
| 158 | SELECT COUNT(*) |
---|
[1538] | 159 | FROM '.IMAGE_CATEGORY_TABLE.' |
---|
| 160 | ;'; |
---|
[4325] | 161 | list($nb_image_category) = pwg_db_fetch_row(pwg_query($query)); |
---|
[1538] | 162 | |
---|
| 163 | $query = ' |
---|
| 164 | SELECT COUNT(*) |
---|
| 165 | FROM '.TAGS_TABLE.' |
---|
| 166 | ;'; |
---|
[4325] | 167 | list($nb_tags) = pwg_db_fetch_row(pwg_query($query)); |
---|
[1538] | 168 | |
---|
| 169 | $query = ' |
---|
| 170 | SELECT COUNT(*) |
---|
| 171 | FROM '.IMAGE_TAG_TABLE.' |
---|
| 172 | ;'; |
---|
[4325] | 173 | list($nb_image_tag) = pwg_db_fetch_row(pwg_query($query)); |
---|
[1538] | 174 | |
---|
| 175 | $query = ' |
---|
| 176 | SELECT COUNT(*) |
---|
[814] | 177 | FROM '.USERS_TABLE.' |
---|
| 178 | ;'; |
---|
[4325] | 179 | list($nb_users) = pwg_db_fetch_row(pwg_query($query)); |
---|
[814] | 180 | |
---|
| 181 | $query = ' |
---|
| 182 | SELECT COUNT(*) |
---|
| 183 | FROM '.GROUPS_TABLE.' |
---|
| 184 | ;'; |
---|
[4325] | 185 | list($nb_groups) = pwg_db_fetch_row(pwg_query($query)); |
---|
[814] | 186 | |
---|
| 187 | $query = ' |
---|
| 188 | SELECT COUNT(*) |
---|
| 189 | FROM '.COMMENTS_TABLE.' |
---|
| 190 | ;'; |
---|
[4325] | 191 | list($nb_comments) = pwg_db_fetch_row(pwg_query($query)); |
---|
[814] | 192 | |
---|
[2230] | 193 | $template->assign( |
---|
[814] | 194 | array( |
---|
[3197] | 195 | 'PHPWG_URL' => PHPWG_URL, |
---|
[814] | 196 | 'PWG_VERSION' => PHPWG_VERSION, |
---|
| 197 | 'OS' => PHP_OS, |
---|
| 198 | 'PHP_VERSION' => phpversion(), |
---|
[4385] | 199 | 'DB_ENGINE' => $conf['dblayer'], |
---|
[4325] | 200 | 'DB_VERSION' => $db_version, |
---|
[5178] | 201 | 'DB_ELEMENTS' => l10n_dec('%d image', '%d images', $nb_elements), |
---|
[814] | 202 | 'DB_CATEGORIES' => |
---|
[6951] | 203 | l10n_dec('%d album including', '%d albums including', |
---|
[1932] | 204 | $nb_categories). |
---|
[5036] | 205 | l10n_dec('%d physical', '%d physical', |
---|
[1932] | 206 | $nb_physical). |
---|
[5036] | 207 | l10n_dec(' and %d virtual', ' and %d virtual', |
---|
[1932] | 208 | $nb_virtual), |
---|
| 209 | 'DB_IMAGE_CATEGORY' => l10n_dec('%d association', '%d associations', $nb_image_category), |
---|
| 210 | 'DB_TAGS' => l10n_dec('%d tag', '%d tags', $nb_tags), |
---|
| 211 | 'DB_IMAGE_TAG' => l10n_dec('%d association', '%d associations', $nb_image_tag), |
---|
| 212 | 'DB_USERS' => l10n_dec('%d user', '%d users', $nb_users), |
---|
| 213 | 'DB_GROUPS' => l10n_dec('%d group', '%d groups', $nb_groups), |
---|
| 214 | 'DB_COMMENTS' => l10n_dec('%d comment', '%d comments', $nb_comments), |
---|
[1004] | 215 | 'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade', |
---|
[1884] | 216 | 'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo', |
---|
| 217 | 'PHP_DATATIME' => $php_current_timestamp, |
---|
[6604] | 218 | 'DB_DATATIME' => $db_current_date, |
---|
[814] | 219 | ) |
---|
| 220 | ); |
---|
[817] | 221 | |
---|
[861] | 222 | if ($nb_elements > 0) |
---|
| 223 | { |
---|
| 224 | $query = ' |
---|
| 225 | SELECT MIN(date_available) |
---|
| 226 | FROM '.IMAGES_TABLE.' |
---|
| 227 | ;'; |
---|
[4325] | 228 | list($first_date) = pwg_db_fetch_row(pwg_query($query)); |
---|
[861] | 229 | |
---|
[2230] | 230 | $template->assign( |
---|
[861] | 231 | 'first_added', |
---|
| 232 | array( |
---|
| 233 | 'DB_DATE' => |
---|
| 234 | sprintf( |
---|
| 235 | l10n('first element added on %s'), |
---|
[3122] | 236 | format_date($first_date) |
---|
[861] | 237 | ) |
---|
| 238 | ) |
---|
| 239 | ); |
---|
| 240 | } |
---|
| 241 | |
---|
[817] | 242 | // waiting elements |
---|
| 243 | $query = ' |
---|
| 244 | SELECT COUNT(*) |
---|
| 245 | FROM '.WAITING_TABLE.' |
---|
| 246 | WHERE validated=\'false\' |
---|
| 247 | ;'; |
---|
[4325] | 248 | list($nb_waiting) = pwg_db_fetch_row(pwg_query($query)); |
---|
[817] | 249 | |
---|
| 250 | if ($nb_waiting > 0) |
---|
| 251 | { |
---|
[2230] | 252 | $template->assign( |
---|
[817] | 253 | 'waiting', |
---|
| 254 | array( |
---|
[2033] | 255 | 'URL' => PHPWG_ROOT_PATH.'admin.php?page=upload', |
---|
[817] | 256 | 'INFO' => sprintf(l10n('%d waiting for validation'), $nb_waiting) |
---|
| 257 | ) |
---|
| 258 | ); |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | // unvalidated comments |
---|
| 262 | $query = ' |
---|
| 263 | SELECT COUNT(*) |
---|
| 264 | FROM '.COMMENTS_TABLE.' |
---|
| 265 | WHERE validated=\'false\' |
---|
| 266 | ;'; |
---|
[4325] | 267 | list($nb_comments) = pwg_db_fetch_row(pwg_query($query)); |
---|
[817] | 268 | |
---|
| 269 | if ($nb_comments > 0) |
---|
| 270 | { |
---|
[2230] | 271 | $template->assign( |
---|
[817] | 272 | 'unvalidated', |
---|
| 273 | array( |
---|
[1004] | 274 | 'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments', |
---|
[817] | 275 | 'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments) |
---|
| 276 | ) |
---|
| 277 | ); |
---|
| 278 | } |
---|
| 279 | |
---|
[814] | 280 | // +-----------------------------------------------------------------------+ |
---|
| 281 | // | sending html code | |
---|
| 282 | // +-----------------------------------------------------------------------+ |
---|
| 283 | |
---|
| 284 | $template->assign_var_from_handle('ADMIN_CONTENT', 'intro'); |
---|
| 285 | |
---|
[2232] | 286 | // Check integrity |
---|
| 287 | $c13y = new check_integrity(); |
---|
| 288 | // add internal checks |
---|
| 289 | new c13y_internal(); |
---|
| 290 | // check and display |
---|
| 291 | $c13y->check(); |
---|
| 292 | $c13y->display(); |
---|
[2065] | 293 | |
---|
[1724] | 294 | ?> |
---|