source: trunk/admin/intro.php @ 12640

Last change on this file since 12640 was 11839, checked in by rvelices, 13 years ago

feature 2384: improve average rating calculation (final)

  • Property svn:eol-style set to LF
File size: 9.3 KB
RevLine 
[814]1<?php
2// +-----------------------------------------------------------------------+
[8728]3// | Piwigo - a PHP based photo gallery                                    |
[2297]4// +-----------------------------------------------------------------------+
[8728]5// | Copyright(C) 2008-2011 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  {
[2880]48    array_push($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    {
76      array_push(
77        $page['errors'],
78        l10n('Check for upgrade failed for unknown reasons.')
79        );
80    }
[1226]81    // concatenation needed to avoid automatic transformation by release
82    // script generator
[4325]83    else if ('%'.'PWGVERSION'.'%' == $versions['current'])
[814]84    {
85      array_push(
86        $page['infos'],
87        l10n('You are running on development sources, no check possible.')
88        );
89    }
[4325]90    else if (version_compare($versions['current'], $versions['latest']) < 0)
[814]91    {
92      array_push(
93        $page['infos'],
[2342]94        l10n('A new version of Piwigo is available.')
[814]95        );
96    }
97    else
98    {
99      array_push(
100        $page['infos'],
[2342]101        l10n('You are running the latest version of Piwigo.')
[814]102        );
103    }
104  }
105}
106// Show phpinfo() output
107else if (isset($_GET['action']) and 'phpinfo' == $_GET['action'])
108{
109  phpinfo();
110  exit();
111}
112
113// +-----------------------------------------------------------------------+
114// |                             template init                             |
115// +-----------------------------------------------------------------------+
116
[2529]117$template->set_filenames(array('intro' => 'intro.tpl'));
[814]118
[3382]119if ($conf['show_newsletter_subscription']) {
120  $template->assign(
121    array(
122      'EMAIL' => $user['email'],
123      'SUBSCRIBE_BASE_URL' => get_newsletter_subscribe_base_url($user['language']),
124      )
125    );
126}
127
[1888]128$php_current_timestamp = date("Y-m-d H:i:s");
[4325]129$db_version = pwg_get_db_version();
[6604]130list($db_current_date) = pwg_db_fetch_row(pwg_query('SELECT now();'));
[814]131
132$query = '
133SELECT COUNT(*)
134  FROM '.IMAGES_TABLE.'
135;';
[4325]136list($nb_elements) = pwg_db_fetch_row(pwg_query($query));
[814]137
138$query = '
139SELECT COUNT(*)
140  FROM '.CATEGORIES_TABLE.'
141;';
[4325]142list($nb_categories) = pwg_db_fetch_row(pwg_query($query));
[814]143
144$query = '
145SELECT COUNT(*)
146  FROM '.CATEGORIES_TABLE.'
147  WHERE dir IS NULL
148;';
[4325]149list($nb_virtual) = pwg_db_fetch_row(pwg_query($query));
[814]150
151$query = '
152SELECT COUNT(*)
153  FROM '.CATEGORIES_TABLE.'
154  WHERE dir IS NOT NULL
155;';
[4325]156list($nb_physical) = pwg_db_fetch_row(pwg_query($query));
[814]157
158$query = '
159SELECT COUNT(*)
[1538]160  FROM '.IMAGE_CATEGORY_TABLE.'
161;';
[4325]162list($nb_image_category) = pwg_db_fetch_row(pwg_query($query));
[1538]163
164$query = '
165SELECT COUNT(*)
166  FROM '.TAGS_TABLE.'
167;';
[4325]168list($nb_tags) = pwg_db_fetch_row(pwg_query($query));
[1538]169
170$query = '
171SELECT COUNT(*)
172  FROM '.IMAGE_TAG_TABLE.'
173;';
[4325]174list($nb_image_tag) = pwg_db_fetch_row(pwg_query($query));
[1538]175
176$query = '
177SELECT COUNT(*)
[814]178  FROM '.USERS_TABLE.'
179;';
[4325]180list($nb_users) = pwg_db_fetch_row(pwg_query($query));
[814]181
182$query = '
183SELECT COUNT(*)
184  FROM '.GROUPS_TABLE.'
185;';
[4325]186list($nb_groups) = pwg_db_fetch_row(pwg_query($query));
[814]187
188$query = '
189SELECT COUNT(*)
190  FROM '.COMMENTS_TABLE.'
191;';
[4325]192list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
[814]193
[11839]194$query = '
195SELECT COUNT(*)
196  FROM '.RATE_TABLE.'
197;';
198list($nb_rates) = pwg_db_fetch_row(pwg_query($query));
199
[2230]200$template->assign(
[814]201  array(
[3197]202    'PHPWG_URL' => PHPWG_URL,
[814]203    'PWG_VERSION' => PHPWG_VERSION,
204    'OS' => PHP_OS,
205    'PHP_VERSION' => phpversion(),
[4385]206    'DB_ENGINE' => $conf['dblayer'],
[4325]207    'DB_VERSION' => $db_version,
[8665]208    'DB_ELEMENTS' => l10n_dec('%d photo', '%d photos', $nb_elements),
[814]209    'DB_CATEGORIES' =>
[6951]210      l10n_dec('%d album including', '%d albums including',
[1932]211        $nb_categories).
[5036]212      l10n_dec('%d physical', '%d physical',
[1932]213        $nb_physical).
[5036]214      l10n_dec(' and %d virtual', ' and %d virtual',
[1932]215        $nb_virtual),
216    'DB_IMAGE_CATEGORY' => l10n_dec('%d association', '%d associations', $nb_image_category),
217    'DB_TAGS' => l10n_dec('%d tag', '%d tags', $nb_tags),
218    'DB_IMAGE_TAG' => l10n_dec('%d association', '%d associations', $nb_image_tag),
219    'DB_USERS' => l10n_dec('%d user', '%d users', $nb_users),
220    'DB_GROUPS' => l10n_dec('%d group', '%d groups', $nb_groups),
221    'DB_COMMENTS' => l10n_dec('%d comment', '%d comments', $nb_comments),
[11839]222                'DB_RATES' => sprintf('%d rates', $nb_rates),
[1004]223    'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
[1884]224    'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo',
225    'PHP_DATATIME' => $php_current_timestamp,
[6604]226    'DB_DATATIME' => $db_current_date,
[814]227    )
228  );
[817]229
[861]230if ($nb_elements > 0)
231{
232  $query = '
233SELECT MIN(date_available)
234  FROM '.IMAGES_TABLE.'
235;';
[4325]236  list($first_date) = pwg_db_fetch_row(pwg_query($query));
[861]237
[2230]238  $template->assign(
[861]239    'first_added',
240    array(
241      'DB_DATE' =>
242      sprintf(
[8682]243        l10n('first photo added on %s'),
[3122]244        format_date($first_date)
[861]245        )
246      )
247    );
248}
249
[817]250// unvalidated comments
251$query = '
252SELECT COUNT(*)
253  FROM '.COMMENTS_TABLE.'
254  WHERE validated=\'false\'
255;';
[4325]256list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
[817]257
258if ($nb_comments > 0)
259{
[2230]260  $template->assign(
[817]261    'unvalidated',
262    array(
[1004]263      'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments',
[817]264      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments)
265      )
266    );
267}
268
[10684]269// graphics library
270switch (pwg_image::get_library())
271{
272  case 'imagick':
273    $library = 'ImageMagick';
274    $img = new Imagick();
275    $version = $img->getVersion();
276    if (preg_match('/ImageMagick \d+\.\d+\.\d+-?\d*/', $version['versionString'], $match))
277    {
278      $library = $match[0];
279    }
280    $template->assign('GRAPHICS_LIBRARY', $library);
281    break;
282
283  case 'ext_imagick':
284    $library = 'External ImageMagick';
285    exec($conf['ext_imagick_dir'].'convert -version', $returnarray);
286    if (preg_match('/Version: ImageMagick (\d+\.\d+\.\d+-?\d*)/', $returnarray[0], $match))
287    {
288      $library .= ' ' . $match[1];
289    }
290    $template->assign('GRAPHICS_LIBRARY', $library);
291    break;
292
293  case 'gd':
294    $gd_info = gd_info();
295    $template->assign('GRAPHICS_LIBRARY', 'GD '.@$gd_info['GD Version']);
296    break;
297}
298
[814]299// +-----------------------------------------------------------------------+
300// |                           sending html code                           |
301// +-----------------------------------------------------------------------+
302
303$template->assign_var_from_handle('ADMIN_CONTENT', 'intro');
304
[2232]305// Check integrity
306$c13y = new check_integrity();
307// add internal checks
308new c13y_internal();
309// check and display
310$c13y->check();
311$c13y->display();
[2065]312
[1724]313?>
Note: See TracBrowser for help on using the repository browser.