source: trunk/admin/intro.php @ 25933

Last change on this file since 25933 was 25085, checked in by plg, 11 years ago

feature 2920: reuse "nb pending comments" calculation in admin/intro.

add missing CSS code in r25084

  • Property svn:eol-style set to LF
File size: 8.8 KB
RevLine 
[814]1<?php
2// +-----------------------------------------------------------------------+
[8728]3// | Piwigo - a PHP based photo gallery                                    |
[2297]4// +-----------------------------------------------------------------------+
[19703]5// | Copyright(C) 2008-2013 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
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die ("Hacking attempt!");
27}
28
[1072]29include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
[2232]30include_once(PHPWG_ROOT_PATH.'admin/include/check_integrity.class.php');
31include_once(PHPWG_ROOT_PATH.'admin/include/c13y_internal.class.php');
[10684]32include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');
[1072]33
[814]34// +-----------------------------------------------------------------------+
[1072]35// | Check Access and exit when user status is not ok                      |
36// +-----------------------------------------------------------------------+
37check_status(ACCESS_ADMINISTRATOR);
38
39// +-----------------------------------------------------------------------+
[814]40// |                                actions                                |
41// +-----------------------------------------------------------------------+
42
43// Check for upgrade : code inspired from punbb
44if (isset($_GET['action']) and 'check_upgrade' == $_GET['action'])
45{
[3133]46  if (!fetchRemote(PHPWG_URL.'/download/latest_version', $result))
[814]47  {
[25018]48    $page['errors'][] = l10n('Unable to check for upgrade.');
[814]49  }
50  else
51  {
52    $versions = array('current' => PHPWG_VERSION);
[2880]53    $lines = @explode("\r\n", $result);
[1538]54
[814]55    // if the current version is a BSF (development branch) build, we check
56    // the first line, for stable versions, we check the second line
[4325]57    if (preg_match('/^BSF/', $versions['current']))
[814]58    {
[4325]59      $versions['latest'] = trim($lines[0]);
[814]60
61      // because integer are limited to 4,294,967,296 we need to split BSF
62      // versions in date.time
63      foreach ($versions as $key => $value)
64      {
[4325]65        $versions[$key] =
[814]66          preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value);
67      }
68    }
69    else
70    {
[4325]71      $versions['latest'] = trim($lines[1]);
[814]72    }
73
[4325]74    if ('' == $versions['latest'])
[814]75    {
[25018]76      $page['errors'][] = l10n('Check for upgrade failed for unknown reasons.');
[814]77    }
[1226]78    // concatenation needed to avoid automatic transformation by release
79    // script generator
[4325]80    else if ('%'.'PWGVERSION'.'%' == $versions['current'])
[814]81    {
[25018]82      $page['infos'][] = l10n('You are running on development sources, no check possible.');
[814]83    }
[4325]84    else if (version_compare($versions['current'], $versions['latest']) < 0)
[814]85    {
[25018]86      $page['infos'][] = l10n('A new version of Piwigo is available.');
[814]87    }
88    else
89    {
[25018]90      $page['infos'][] = l10n('You are running the latest version of Piwigo.');
[814]91    }
92  }
93}
94// Show phpinfo() output
95else if (isset($_GET['action']) and 'phpinfo' == $_GET['action'])
96{
97  phpinfo();
98  exit();
99}
100
101// +-----------------------------------------------------------------------+
102// |                             template init                             |
103// +-----------------------------------------------------------------------+
104
[2529]105$template->set_filenames(array('intro' => 'intro.tpl'));
[814]106
[3382]107if ($conf['show_newsletter_subscription']) {
108  $template->assign(
109    array(
110      'EMAIL' => $user['email'],
111      'SUBSCRIBE_BASE_URL' => get_newsletter_subscribe_base_url($user['language']),
112      )
113    );
114}
115
[1888]116$php_current_timestamp = date("Y-m-d H:i:s");
[4325]117$db_version = pwg_get_db_version();
[6604]118list($db_current_date) = pwg_db_fetch_row(pwg_query('SELECT now();'));
[814]119
120$query = '
121SELECT COUNT(*)
122  FROM '.IMAGES_TABLE.'
123;';
[4325]124list($nb_elements) = pwg_db_fetch_row(pwg_query($query));
[814]125
126$query = '
127SELECT COUNT(*)
128  FROM '.CATEGORIES_TABLE.'
129;';
[4325]130list($nb_categories) = pwg_db_fetch_row(pwg_query($query));
[814]131
132$query = '
133SELECT COUNT(*)
134  FROM '.CATEGORIES_TABLE.'
135  WHERE dir IS NULL
136;';
[4325]137list($nb_virtual) = pwg_db_fetch_row(pwg_query($query));
[814]138
139$query = '
140SELECT COUNT(*)
141  FROM '.CATEGORIES_TABLE.'
142  WHERE dir IS NOT NULL
143;';
[4325]144list($nb_physical) = pwg_db_fetch_row(pwg_query($query));
[814]145
146$query = '
147SELECT COUNT(*)
[1538]148  FROM '.IMAGE_CATEGORY_TABLE.'
149;';
[4325]150list($nb_image_category) = pwg_db_fetch_row(pwg_query($query));
[1538]151
152$query = '
153SELECT COUNT(*)
154  FROM '.TAGS_TABLE.'
155;';
[4325]156list($nb_tags) = pwg_db_fetch_row(pwg_query($query));
[1538]157
158$query = '
159SELECT COUNT(*)
160  FROM '.IMAGE_TAG_TABLE.'
161;';
[4325]162list($nb_image_tag) = pwg_db_fetch_row(pwg_query($query));
[1538]163
164$query = '
165SELECT COUNT(*)
[814]166  FROM '.USERS_TABLE.'
167;';
[4325]168list($nb_users) = pwg_db_fetch_row(pwg_query($query));
[814]169
170$query = '
171SELECT COUNT(*)
172  FROM '.GROUPS_TABLE.'
173;';
[4325]174list($nb_groups) = pwg_db_fetch_row(pwg_query($query));
[814]175
176$query = '
177SELECT COUNT(*)
[11839]178  FROM '.RATE_TABLE.'
179;';
180list($nb_rates) = pwg_db_fetch_row(pwg_query($query));
181
[2230]182$template->assign(
[814]183  array(
[3197]184    'PHPWG_URL' => PHPWG_URL,
[814]185    'PWG_VERSION' => PHPWG_VERSION,
186    'OS' => PHP_OS,
187    'PHP_VERSION' => phpversion(),
[20462]188    'DB_ENGINE' => 'MySQL',
[4325]189    'DB_VERSION' => $db_version,
[8665]190    'DB_ELEMENTS' => l10n_dec('%d photo', '%d photos', $nb_elements),
[814]191    'DB_CATEGORIES' =>
[25018]192      l10n_dec('%d album including', '%d albums including', $nb_categories).
193      l10n_dec('%d physical', '%d physicals', $nb_physical).
194      l10n_dec(' and %d virtual', ' and %d virtuals', $nb_virtual),
[1932]195    'DB_IMAGE_CATEGORY' => l10n_dec('%d association', '%d associations', $nb_image_category),
196    'DB_TAGS' => l10n_dec('%d tag', '%d tags', $nb_tags),
197    'DB_IMAGE_TAG' => l10n_dec('%d association', '%d associations', $nb_image_tag),
198    'DB_USERS' => l10n_dec('%d user', '%d users', $nb_users),
199    'DB_GROUPS' => l10n_dec('%d group', '%d groups', $nb_groups),
[25005]200    'DB_RATES' => ($nb_rates == 0) ? l10n('no rate') : l10n('%d rates', $nb_rates),
[1004]201    'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
[1884]202    'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo',
203    'PHP_DATATIME' => $php_current_timestamp,
[6604]204    'DB_DATATIME' => $db_current_date,
[814]205    )
206  );
[12887]207 
208if ($conf['activate_comments'])
209{
210  $query = '
211SELECT COUNT(*)
212  FROM '.COMMENTS_TABLE.'
213;';
214  list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
215  $template->assign('DB_COMMENTS', l10n_dec('%d comment', '%d comments', $nb_comments));
216}
217
[861]218if ($nb_elements > 0)
219{
220  $query = '
221SELECT MIN(date_available)
222  FROM '.IMAGES_TABLE.'
223;';
[4325]224  list($first_date) = pwg_db_fetch_row(pwg_query($query));
[861]225
[2230]226  $template->assign(
[861]227    'first_added',
228    array(
229      'DB_DATE' =>
[25005]230      l10n('first photo added on %s', format_date($first_date))
[861]231      )
232    );
233}
234
[10684]235// graphics library
236switch (pwg_image::get_library())
237{
238  case 'imagick':
239    $library = 'ImageMagick';
240    $img = new Imagick();
241    $version = $img->getVersion();
242    if (preg_match('/ImageMagick \d+\.\d+\.\d+-?\d*/', $version['versionString'], $match))
243    {
244      $library = $match[0];
245    }
246    $template->assign('GRAPHICS_LIBRARY', $library);
247    break;
248
249  case 'ext_imagick':
250    $library = 'External ImageMagick';
251    exec($conf['ext_imagick_dir'].'convert -version', $returnarray);
252    if (preg_match('/Version: ImageMagick (\d+\.\d+\.\d+-?\d*)/', $returnarray[0], $match))
253    {
254      $library .= ' ' . $match[1];
255    }
256    $template->assign('GRAPHICS_LIBRARY', $library);
257    break;
258
259  case 'gd':
260    $gd_info = gd_info();
261    $template->assign('GRAPHICS_LIBRARY', 'GD '.@$gd_info['GD Version']);
262    break;
263}
264
[814]265// +-----------------------------------------------------------------------+
266// |                           sending html code                           |
267// +-----------------------------------------------------------------------+
268
269$template->assign_var_from_handle('ADMIN_CONTENT', 'intro');
270
[2232]271// Check integrity
272$c13y = new check_integrity();
273// add internal checks
274new c13y_internal();
275// check and display
276$c13y->check();
277$c13y->display();
[2065]278
[1724]279?>
Note: See TracBrowser for help on using the repository browser.