source: branches/2.1/admin/intro.php @ 10485

Last change on this file since 10485 was 6605, checked in by nikrou, 14 years ago

Bug 1744 fixed : Incorrect use of timezone with SQLite
Fixed anti-flood system.

Merge from trunk

  • Property svn:eol-style set to LF
File size: 8.7 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2010 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');
32
33// +-----------------------------------------------------------------------+
34// | Check Access and exit when user status is not ok                      |
35// +-----------------------------------------------------------------------+
36check_status(ACCESS_ADMINISTRATOR);
37
38// +-----------------------------------------------------------------------+
39// |                                actions                                |
40// +-----------------------------------------------------------------------+
41
42// Check for upgrade : code inspired from punbb
43if (isset($_GET['action']) and 'check_upgrade' == $_GET['action'])
44{
45  if (!fetchRemote(PHPWG_URL.'/download/latest_version', $result))
46  {
47    array_push($page['errors'], l10n('Unable to check for upgrade.'));
48  }
49  else
50  {
51    $versions = array('current' => PHPWG_VERSION);
52    $lines = @explode("\r\n", $result);
53
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
56    if (preg_match('/^BSF/', $versions['current']))
57    {
58      $versions['latest'] = trim($lines[0]);
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      {
64        $versions[$key] =
65          preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value);
66      }
67    }
68    else
69    {
70      $versions['latest'] = trim($lines[1]);
71    }
72
73    if ('' == $versions['latest'])
74    {
75      array_push(
76        $page['errors'],
77        l10n('Check for upgrade failed for unknown reasons.')
78        );
79    }
80    // concatenation needed to avoid automatic transformation by release
81    // script generator
82    else if ('%'.'PWGVERSION'.'%' == $versions['current'])
83    {
84      array_push(
85        $page['infos'],
86        l10n('You are running on development sources, no check possible.')
87        );
88    }
89    else if (version_compare($versions['current'], $versions['latest']) < 0)
90    {
91      array_push(
92        $page['infos'],
93        l10n('A new version of Piwigo is available.')
94        );
95    }
96    else
97    {
98      array_push(
99        $page['infos'],
100        l10n('You are running the latest version of Piwigo.')
101        );
102    }
103  }
104}
105// Show phpinfo() output
106else if (isset($_GET['action']) and 'phpinfo' == $_GET['action'])
107{
108  phpinfo();
109  exit();
110}
111
112// +-----------------------------------------------------------------------+
113// |                             template init                             |
114// +-----------------------------------------------------------------------+
115
116$template->set_filenames(array('intro' => 'intro.tpl'));
117
118if ($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
127$php_current_timestamp = date("Y-m-d H:i:s");
128$db_version = pwg_get_db_version();
129list($db_current_date) = pwg_db_fetch_row(pwg_query('SELECT now();'));
130
131$query = '
132SELECT COUNT(*)
133  FROM '.IMAGES_TABLE.'
134;';
135list($nb_elements) = pwg_db_fetch_row(pwg_query($query));
136
137$query = '
138SELECT COUNT(*)
139  FROM '.CATEGORIES_TABLE.'
140;';
141list($nb_categories) = pwg_db_fetch_row(pwg_query($query));
142
143$query = '
144SELECT COUNT(*)
145  FROM '.CATEGORIES_TABLE.'
146  WHERE dir IS NULL
147;';
148list($nb_virtual) = pwg_db_fetch_row(pwg_query($query));
149
150$query = '
151SELECT COUNT(*)
152  FROM '.CATEGORIES_TABLE.'
153  WHERE dir IS NOT NULL
154;';
155list($nb_physical) = pwg_db_fetch_row(pwg_query($query));
156
157$query = '
158SELECT COUNT(*)
159  FROM '.IMAGE_CATEGORY_TABLE.'
160;';
161list($nb_image_category) = pwg_db_fetch_row(pwg_query($query));
162
163$query = '
164SELECT COUNT(*)
165  FROM '.TAGS_TABLE.'
166;';
167list($nb_tags) = pwg_db_fetch_row(pwg_query($query));
168
169$query = '
170SELECT COUNT(*)
171  FROM '.IMAGE_TAG_TABLE.'
172;';
173list($nb_image_tag) = pwg_db_fetch_row(pwg_query($query));
174
175$query = '
176SELECT COUNT(*)
177  FROM '.USERS_TABLE.'
178;';
179list($nb_users) = pwg_db_fetch_row(pwg_query($query));
180
181$query = '
182SELECT COUNT(*)
183  FROM '.GROUPS_TABLE.'
184;';
185list($nb_groups) = pwg_db_fetch_row(pwg_query($query));
186
187$query = '
188SELECT COUNT(*)
189  FROM '.COMMENTS_TABLE.'
190;';
191list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
192
193$template->assign(
194  array(
195    'PHPWG_URL' => PHPWG_URL,
196    'PWG_VERSION' => PHPWG_VERSION,
197    'OS' => PHP_OS,
198    'PHP_VERSION' => phpversion(),
199    'DB_ENGINE' => $conf['dblayer'],
200    'DB_VERSION' => $db_version,
201    'DB_ELEMENTS' => l10n_dec('%d image', '%d images', $nb_elements),
202    'DB_CATEGORIES' =>
203      l10n_dec('%d category including', '%d categories including',
204        $nb_categories).
205      l10n_dec('%d physical', '%d physical',
206        $nb_physical).
207      l10n_dec(' and %d virtual', ' and %d virtual',
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),
215    'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
216    'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo',
217    'PHP_DATATIME' => $php_current_timestamp,
218    'DB_DATATIME' => $db_current_date,
219    )
220  );
221
222if ($nb_elements > 0)
223{
224  $query = '
225SELECT MIN(date_available)
226  FROM '.IMAGES_TABLE.'
227;';
228  list($first_date) = pwg_db_fetch_row(pwg_query($query));
229
230  $template->assign(
231    'first_added',
232    array(
233      'DB_DATE' =>
234      sprintf(
235        l10n('first element added on %s'),
236        format_date($first_date)
237        )
238      )
239    );
240}
241
242// waiting elements
243$query = '
244SELECT COUNT(*)
245  FROM '.WAITING_TABLE.'
246  WHERE validated=\'false\'
247;';
248list($nb_waiting) = pwg_db_fetch_row(pwg_query($query));
249
250if ($nb_waiting > 0)
251{
252  $template->assign(
253    'waiting',
254    array(
255      'URL' => PHPWG_ROOT_PATH.'admin.php?page=upload',
256      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_waiting)
257      )
258    );
259}
260
261// unvalidated comments
262$query = '
263SELECT COUNT(*)
264  FROM '.COMMENTS_TABLE.'
265  WHERE validated=\'false\'
266;';
267list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
268
269if ($nb_comments > 0)
270{
271  $template->assign(
272    'unvalidated',
273    array(
274      'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments',
275      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments)
276      )
277    );
278}
279
280// +-----------------------------------------------------------------------+
281// |                           sending html code                           |
282// +-----------------------------------------------------------------------+
283
284$template->assign_var_from_handle('ADMIN_CONTENT', 'intro');
285
286// Check integrity
287$c13y = new check_integrity();
288// add internal checks
289new c13y_internal();
290// check and display
291$c13y->check();
292$c13y->display();
293
294?>
Note: See TracBrowser for help on using the repository browser.