source: branches/2.0/admin/intro.php @ 3381

Last change on this file since 3381 was 3381, checked in by plg, 15 years ago

feature 1020 added: ability to subscribe to Piwigo Announcement Newsletter from
Piwigo itself. Admins can perform this action at the end of installation or on
administration panel index.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 8.7 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2009 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");
128list($mysql_version, $db_current_timestamp) = mysql_fetch_row(pwg_query('SELECT VERSION(), CURRENT_TIMESTAMP;'));
129
130$query = '
131SELECT COUNT(*)
132  FROM '.IMAGES_TABLE.'
133;';
134list($nb_elements) = mysql_fetch_row(pwg_query($query));
135
136$query = '
137SELECT COUNT(*)
138  FROM '.CATEGORIES_TABLE.'
139;';
140list($nb_categories) = mysql_fetch_row(pwg_query($query));
141
142$query = '
143SELECT COUNT(*)
144  FROM '.CATEGORIES_TABLE.'
145  WHERE dir IS NULL
146;';
147list($nb_virtual) = mysql_fetch_row(pwg_query($query));
148
149$query = '
150SELECT COUNT(*)
151  FROM '.CATEGORIES_TABLE.'
152  WHERE dir IS NOT NULL
153;';
154list($nb_physical) = mysql_fetch_row(pwg_query($query));
155
156$query = '
157SELECT COUNT(*)
158  FROM '.IMAGE_CATEGORY_TABLE.'
159;';
160list($nb_image_category) = mysql_fetch_row(pwg_query($query));
161
162$query = '
163SELECT COUNT(*)
164  FROM '.TAGS_TABLE.'
165;';
166list($nb_tags) = mysql_fetch_row(pwg_query($query));
167
168$query = '
169SELECT COUNT(*)
170  FROM '.IMAGE_TAG_TABLE.'
171;';
172list($nb_image_tag) = mysql_fetch_row(pwg_query($query));
173
174$query = '
175SELECT COUNT(*)
176  FROM '.USERS_TABLE.'
177;';
178list($nb_users) = mysql_fetch_row(pwg_query($query));
179
180$query = '
181SELECT COUNT(*)
182  FROM '.GROUPS_TABLE.'
183;';
184list($nb_groups) = mysql_fetch_row(pwg_query($query));
185
186$query = '
187SELECT COUNT(*)
188  FROM '.COMMENTS_TABLE.'
189;';
190list($nb_comments) = mysql_fetch_row(pwg_query($query));
191
192$template->assign(
193  array(
194    'PHPWG_URL' => PHPWG_URL,
195    'PWG_VERSION' => PHPWG_VERSION,
196    'OS' => PHP_OS,
197    'PHP_VERSION' => phpversion(),
198    'MYSQL_VERSION' => $mysql_version,
199    'DB_ELEMENTS' => l10n_dec('%d element', '%d elements', $nb_elements),
200    'DB_CATEGORIES' =>
201      l10n_dec('cat_inclu_part1_S', 'cat_inclu_part1_P',
202        $nb_categories).
203      l10n_dec('cat_inclu_part2_S', 'cat_inclu_part2_P',
204        $nb_physical).
205      l10n_dec('cat_inclu_part3_S', 'cat_inclu_part3_P',
206        $nb_virtual),
207    'DB_IMAGE_CATEGORY' => l10n_dec('%d association', '%d associations', $nb_image_category),
208    'DB_TAGS' => l10n_dec('%d tag', '%d tags', $nb_tags),
209    'DB_IMAGE_TAG' => l10n_dec('%d association', '%d associations', $nb_image_tag),
210    'DB_USERS' => l10n_dec('%d user', '%d users', $nb_users),
211    'DB_GROUPS' => l10n_dec('%d group', '%d groups', $nb_groups),
212    'DB_COMMENTS' => l10n_dec('%d comment', '%d comments', $nb_comments),
213    'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
214    'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo',
215    'PHP_DATATIME' => $php_current_timestamp,
216    'DB_DATATIME' => $db_current_timestamp,
217    )
218  );
219
220if ($nb_elements > 0)
221{
222  $query = '
223SELECT MIN(date_available)
224  FROM '.IMAGES_TABLE.'
225;';
226  list($first_date) = mysql_fetch_row(pwg_query($query));
227
228  $template->assign(
229    'first_added',
230    array(
231      'DB_DATE' =>
232      sprintf(
233        l10n('first element added on %s'),
234        format_date($first_date)
235        )
236      )
237    );
238}
239
240// waiting elements
241$query = '
242SELECT COUNT(*)
243  FROM '.WAITING_TABLE.'
244  WHERE validated=\'false\'
245;';
246list($nb_waiting) = mysql_fetch_row(pwg_query($query));
247
248if ($nb_waiting > 0)
249{
250  $template->assign(
251    'waiting',
252    array(
253      'URL' => PHPWG_ROOT_PATH.'admin.php?page=upload',
254      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_waiting)
255      )
256    );
257}
258
259// unvalidated comments
260$query = '
261SELECT COUNT(*)
262  FROM '.COMMENTS_TABLE.'
263  WHERE validated=\'false\'
264;';
265list($nb_comments) = mysql_fetch_row(pwg_query($query));
266
267if ($nb_comments > 0)
268{
269  $template->assign(
270    'unvalidated',
271    array(
272      'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments',
273      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments)
274      )
275    );
276}
277
278// +-----------------------------------------------------------------------+
279// |                           sending html code                           |
280// +-----------------------------------------------------------------------+
281
282$template->assign_var_from_handle('ADMIN_CONTENT', 'intro');
283
284// Check integrity
285$c13y = new check_integrity();
286// add internal checks
287new c13y_internal();
288// check and display
289$c13y->check();
290$c13y->display();
291
292?>
Note: See TracBrowser for help on using the repository browser.