source: trunk/admin/intro.php @ 3197

Last change on this file since 3197 was 3197, checked in by plg, 16 years ago

merge r3196 from branch 2.0 to trunk

bug 926 fixed: change links to piwigo.org so that they go to existing URLs.

new: if the current language is french, the links go to fr.piwigo.org instead.

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