source: trunk/admin/intro.php @ 19009

Last change on this file since 19009 was 14977, checked in by mistic100, 13 years ago

change languages keys to differentiate if "%d physical" is plural or singular, same for "and %d virtual"
+ missing ja_JP php open tag

  • Property svn:eol-style set to LF
File size: 9.5 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2012 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// +-----------------------------------------------------------------------+
23
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die ("Hacking attempt!");
27}
28
29include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
30include_once(PHPWG_ROOT_PATH.'admin/include/check_integrity.class.php');
31include_once(PHPWG_ROOT_PATH.'admin/include/c13y_internal.class.php');
32include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');
33
34// +-----------------------------------------------------------------------+
35// | Check Access and exit when user status is not ok                      |
36// +-----------------------------------------------------------------------+
37check_status(ACCESS_ADMINISTRATOR);
38
39// +-----------------------------------------------------------------------+
40// |                                actions                                |
41// +-----------------------------------------------------------------------+
42
43// Check for upgrade : code inspired from punbb
44if (isset($_GET['action']) and 'check_upgrade' == $_GET['action'])
45{
46  if (!fetchRemote(PHPWG_URL.'/download/latest_version', $result))
47  {
48    array_push($page['errors'], l10n('Unable to check for upgrade.'));
49  }
50  else
51  {
52    $versions = array('current' => PHPWG_VERSION);
53    $lines = @explode("\r\n", $result);
54
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
57    if (preg_match('/^BSF/', $versions['current']))
58    {
59      $versions['latest'] = trim($lines[0]);
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      {
65        $versions[$key] =
66          preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value);
67      }
68    }
69    else
70    {
71      $versions['latest'] = trim($lines[1]);
72    }
73
74    if ('' == $versions['latest'])
75    {
76      array_push(
77        $page['errors'],
78        l10n('Check for upgrade failed for unknown reasons.')
79        );
80    }
81    // concatenation needed to avoid automatic transformation by release
82    // script generator
83    else if ('%'.'PWGVERSION'.'%' == $versions['current'])
84    {
85      array_push(
86        $page['infos'],
87        l10n('You are running on development sources, no check possible.')
88        );
89    }
90    else if (version_compare($versions['current'], $versions['latest']) < 0)
91    {
92      array_push(
93        $page['infos'],
94        l10n('A new version of Piwigo is available.')
95        );
96    }
97    else
98    {
99      array_push(
100        $page['infos'],
101        l10n('You are running the latest version of Piwigo.')
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
117$template->set_filenames(array('intro' => 'intro.tpl'));
118
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
128$php_current_timestamp = date("Y-m-d H:i:s");
129$db_version = pwg_get_db_version();
130list($db_current_date) = pwg_db_fetch_row(pwg_query('SELECT now();'));
131
132$query = '
133SELECT COUNT(*)
134  FROM '.IMAGES_TABLE.'
135;';
136list($nb_elements) = pwg_db_fetch_row(pwg_query($query));
137
138$query = '
139SELECT COUNT(*)
140  FROM '.CATEGORIES_TABLE.'
141;';
142list($nb_categories) = pwg_db_fetch_row(pwg_query($query));
143
144$query = '
145SELECT COUNT(*)
146  FROM '.CATEGORIES_TABLE.'
147  WHERE dir IS NULL
148;';
149list($nb_virtual) = pwg_db_fetch_row(pwg_query($query));
150
151$query = '
152SELECT COUNT(*)
153  FROM '.CATEGORIES_TABLE.'
154  WHERE dir IS NOT NULL
155;';
156list($nb_physical) = pwg_db_fetch_row(pwg_query($query));
157
158$query = '
159SELECT COUNT(*)
160  FROM '.IMAGE_CATEGORY_TABLE.'
161;';
162list($nb_image_category) = pwg_db_fetch_row(pwg_query($query));
163
164$query = '
165SELECT COUNT(*)
166  FROM '.TAGS_TABLE.'
167;';
168list($nb_tags) = pwg_db_fetch_row(pwg_query($query));
169
170$query = '
171SELECT COUNT(*)
172  FROM '.IMAGE_TAG_TABLE.'
173;';
174list($nb_image_tag) = pwg_db_fetch_row(pwg_query($query));
175
176$query = '
177SELECT COUNT(*)
178  FROM '.USERS_TABLE.'
179;';
180list($nb_users) = pwg_db_fetch_row(pwg_query($query));
181
182$query = '
183SELECT COUNT(*)
184  FROM '.GROUPS_TABLE.'
185;';
186list($nb_groups) = pwg_db_fetch_row(pwg_query($query));
187
188$query = '
189SELECT COUNT(*)
190  FROM '.RATE_TABLE.'
191;';
192list($nb_rates) = pwg_db_fetch_row(pwg_query($query));
193
194$template->assign(
195  array(
196    'PHPWG_URL' => PHPWG_URL,
197    'PWG_VERSION' => PHPWG_VERSION,
198    'OS' => PHP_OS,
199    'PHP_VERSION' => phpversion(),
200    'DB_ENGINE' => $conf['dblayer'],
201    'DB_VERSION' => $db_version,
202    'DB_ELEMENTS' => l10n_dec('%d photo', '%d photos', $nb_elements),
203    'DB_CATEGORIES' =>
204      l10n_dec('%d album including', '%d albums including',
205        $nb_categories).
206      l10n_dec('%d physical', '%d physicals',
207        $nb_physical).
208      l10n_dec(' and %d virtual', ' and %d virtuals',
209        $nb_virtual),
210    'DB_IMAGE_CATEGORY' => l10n_dec('%d association', '%d associations', $nb_image_category),
211    'DB_TAGS' => l10n_dec('%d tag', '%d tags', $nb_tags),
212    'DB_IMAGE_TAG' => l10n_dec('%d association', '%d associations', $nb_image_tag),
213    'DB_USERS' => l10n_dec('%d user', '%d users', $nb_users),
214    'DB_GROUPS' => l10n_dec('%d group', '%d groups', $nb_groups),
215    'DB_RATES' => ($nb_rates == 0) ? l10n('no rate') : sprintf(l10n('%d rates'), $nb_rates),
216    'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
217    'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo',
218    'PHP_DATATIME' => $php_current_timestamp,
219    'DB_DATATIME' => $db_current_date,
220    )
221  );
222 
223if ($conf['activate_comments'])
224{
225  $query = '
226SELECT COUNT(*)
227  FROM '.COMMENTS_TABLE.'
228;';
229  list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
230  $template->assign('DB_COMMENTS', l10n_dec('%d comment', '%d comments', $nb_comments));
231 
232  // unvalidated comments
233  $query = '
234SELECT COUNT(*)
235  FROM '.COMMENTS_TABLE.'
236  WHERE validated=\'false\'
237;';
238  list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
239
240  if ($nb_comments > 0)
241  {
242    $template->assign(
243      'unvalidated',
244      array(
245        'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments',
246        'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments)
247        )
248      );
249  }
250}
251
252if ($nb_elements > 0)
253{
254  $query = '
255SELECT MIN(date_available)
256  FROM '.IMAGES_TABLE.'
257;';
258  list($first_date) = pwg_db_fetch_row(pwg_query($query));
259
260  $template->assign(
261    'first_added',
262    array(
263      'DB_DATE' =>
264      sprintf(
265        l10n('first photo added on %s'),
266        format_date($first_date)
267        )
268      )
269    );
270}
271
272// graphics library
273switch (pwg_image::get_library())
274{
275  case 'imagick':
276    $library = 'ImageMagick';
277    $img = new Imagick();
278    $version = $img->getVersion();
279    if (preg_match('/ImageMagick \d+\.\d+\.\d+-?\d*/', $version['versionString'], $match))
280    {
281      $library = $match[0];
282    }
283    $template->assign('GRAPHICS_LIBRARY', $library);
284    break;
285
286  case 'ext_imagick':
287    $library = 'External ImageMagick';
288    exec($conf['ext_imagick_dir'].'convert -version', $returnarray);
289    if (preg_match('/Version: ImageMagick (\d+\.\d+\.\d+-?\d*)/', $returnarray[0], $match))
290    {
291      $library .= ' ' . $match[1];
292    }
293    $template->assign('GRAPHICS_LIBRARY', $library);
294    break;
295
296  case 'gd':
297    $gd_info = gd_info();
298    $template->assign('GRAPHICS_LIBRARY', 'GD '.@$gd_info['GD Version']);
299    break;
300}
301
302// +-----------------------------------------------------------------------+
303// |                           sending html code                           |
304// +-----------------------------------------------------------------------+
305
306$template->assign_var_from_handle('ADMIN_CONTENT', 'intro');
307
308// Check integrity
309$c13y = new check_integrity();
310// add internal checks
311new c13y_internal();
312// check and display
313$c13y->check();
314$c13y->display();
315
316?>
Note: See TracBrowser for help on using the repository browser.