source: trunk/admin/intro.php @ 2299

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

Bug fixed: as rvelices notified me by email, my header replacement script was
bugged (r2297 was repeating new and old header).

By the way, I've also removed the replacement keywords. We were using them
because it was a common usage with CVS but it is advised not to use them with
Subversion. Personnaly, it is a problem when I search differences between 2
Piwigo installations outside Subversion.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008      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 (!ini_get('allow_url_fopen'))
46  {
47    array_push(
48      $page['errors'],
49      l10n('Unable to check for upgrade since allow_url_fopen is disabled.')
50      );
51  }
52  else
53  {
54    $versions = array('current' => PHPWG_VERSION);
55    $lines = @file(PHPWG_URL.'/latest_version');
56
57    // if the current version is a BSF (development branch) build, we check
58    // the first line, for stable versions, we check the second line
59    if (preg_match('/^BSF/', $versions{'current'}))
60    {
61      $versions{'latest'} = trim($lines[0]);
62
63      // because integer are limited to 4,294,967,296 we need to split BSF
64      // versions in date.time
65      foreach ($versions as $key => $value)
66      {
67        $versions{$key} =
68          preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value);
69      }
70    }
71    else
72    {
73      $versions{'latest'} = trim($lines[1]);
74    }
75
76    if ('' == $versions{'latest'})
77    {
78      array_push(
79        $page['errors'],
80        l10n('Check for upgrade failed for unknown reasons.')
81        );
82    }
83    // concatenation needed to avoid automatic transformation by release
84    // script generator
85    else if ('%'.'PWGVERSION'.'%' == $versions{'current'})
86    {
87      array_push(
88        $page['infos'],
89        l10n('You are running on development sources, no check possible.')
90        );
91    }
92    else if (version_compare($versions{'current'}, $versions{'latest'}) < 0)
93    {
94      array_push(
95        $page['infos'],
96        l10n('A new version of PhpWebGallery is available.')
97        );
98    }
99    else
100    {
101      array_push(
102        $page['infos'],
103        l10n('You are running the latest version of PhpWebGallery.')
104        );
105    }
106  }
107}
108// Show phpinfo() output
109else if (isset($_GET['action']) and 'phpinfo' == $_GET['action'])
110{
111  phpinfo();
112  exit();
113}
114
115// +-----------------------------------------------------------------------+
116// |                             template init                             |
117// +-----------------------------------------------------------------------+
118
119$template->set_filenames(array('intro' => 'admin/intro.tpl'));
120
121$php_current_timestamp = date("Y-m-d H:i:s");
122list($mysql_version, $db_current_timestamp) = mysql_fetch_row(pwg_query('SELECT VERSION(), CURRENT_TIMESTAMP;'));
123
124$query = '
125SELECT COUNT(*)
126  FROM '.IMAGES_TABLE.'
127;';
128list($nb_elements) = mysql_fetch_row(pwg_query($query));
129
130$query = '
131SELECT COUNT(*)
132  FROM '.CATEGORIES_TABLE.'
133;';
134list($nb_categories) = mysql_fetch_row(pwg_query($query));
135
136$query = '
137SELECT COUNT(*)
138  FROM '.CATEGORIES_TABLE.'
139  WHERE dir IS NULL
140;';
141list($nb_virtual) = mysql_fetch_row(pwg_query($query));
142
143$query = '
144SELECT COUNT(*)
145  FROM '.CATEGORIES_TABLE.'
146  WHERE dir IS NOT NULL
147;';
148list($nb_physical) = mysql_fetch_row(pwg_query($query));
149
150$query = '
151SELECT COUNT(*)
152  FROM '.IMAGE_CATEGORY_TABLE.'
153;';
154list($nb_image_category) = mysql_fetch_row(pwg_query($query));
155
156$query = '
157SELECT COUNT(*)
158  FROM '.TAGS_TABLE.'
159;';
160list($nb_tags) = mysql_fetch_row(pwg_query($query));
161
162$query = '
163SELECT COUNT(*)
164  FROM '.IMAGE_TAG_TABLE.'
165;';
166list($nb_image_tag) = mysql_fetch_row(pwg_query($query));
167
168$query = '
169SELECT COUNT(*)
170  FROM '.USERS_TABLE.'
171;';
172list($nb_users) = mysql_fetch_row(pwg_query($query));
173
174$query = '
175SELECT COUNT(*)
176  FROM '.GROUPS_TABLE.'
177;';
178list($nb_groups) = mysql_fetch_row(pwg_query($query));
179
180$query = '
181SELECT COUNT(*)
182  FROM '.COMMENTS_TABLE.'
183;';
184list($nb_comments) = mysql_fetch_row(pwg_query($query));
185
186$template->assign(
187  array(
188    'PWG_VERSION' => PHPWG_VERSION,
189    'OS' => PHP_OS,
190    'PHP_VERSION' => phpversion(),
191    'MYSQL_VERSION' => $mysql_version,
192    'DB_ELEMENTS' => l10n_dec('%d element', '%d elements', $nb_elements),
193    'DB_CATEGORIES' =>
194      l10n_dec('cat_inclu_part1_S', 'cat_inclu_part1_P',
195        $nb_categories).
196      l10n_dec('cat_inclu_part2_S', 'cat_inclu_part2_P',
197        $nb_physical).
198      l10n_dec('cat_inclu_part3_S', 'cat_inclu_part3_P',
199        $nb_virtual),
200    'DB_IMAGE_CATEGORY' => l10n_dec('%d association', '%d associations', $nb_image_category),
201    'DB_TAGS' => l10n_dec('%d tag', '%d tags', $nb_tags),
202    'DB_IMAGE_TAG' => l10n_dec('%d association', '%d associations', $nb_image_tag),
203    'DB_USERS' => l10n_dec('%d user', '%d users', $nb_users),
204    'DB_GROUPS' => l10n_dec('%d group', '%d groups', $nb_groups),
205    'DB_COMMENTS' => l10n_dec('%d comment', '%d comments', $nb_comments),
206    'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
207    'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo',
208    'PHP_DATATIME' => $php_current_timestamp,
209    'DB_DATATIME' => $db_current_timestamp,
210    )
211  );
212
213if ($nb_elements > 0)
214{
215  $query = '
216SELECT MIN(date_available)
217  FROM '.IMAGES_TABLE.'
218;';
219  list($first_date) = mysql_fetch_row(pwg_query($query));
220
221  $template->assign(
222    'first_added',
223    array(
224      'DB_DATE' =>
225      sprintf(
226        l10n('first element added on %s'),
227        format_date($first_date, 'mysql_datetime')
228        )
229      )
230    );
231}
232
233// waiting elements
234$query = '
235SELECT COUNT(*)
236  FROM '.WAITING_TABLE.'
237  WHERE validated=\'false\'
238;';
239list($nb_waiting) = mysql_fetch_row(pwg_query($query));
240
241if ($nb_waiting > 0)
242{
243  $template->assign(
244    'waiting',
245    array(
246      'URL' => PHPWG_ROOT_PATH.'admin.php?page=upload',
247      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_waiting)
248      )
249    );
250}
251
252// unvalidated comments
253$query = '
254SELECT COUNT(*)
255  FROM '.COMMENTS_TABLE.'
256  WHERE validated=\'false\'
257;';
258list($nb_comments) = mysql_fetch_row(pwg_query($query));
259
260if ($nb_comments > 0)
261{
262  $template->assign(
263    'unvalidated',
264    array(
265      'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments',
266      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments)
267      )
268    );
269}
270
271// Add the PhpWebGallery Official menu
272  $template->assign( 'pwgmenu', pwg_URL() );
273
274// +-----------------------------------------------------------------------+
275// |                           sending html code                           |
276// +-----------------------------------------------------------------------+
277
278$template->assign_var_from_handle('ADMIN_CONTENT', 'intro');
279
280// Check integrity
281$c13y = new check_integrity();
282// add internal checks
283new c13y_internal();
284// check and display
285$c13y->check();
286$c13y->display();
287
288?>
Note: See TracBrowser for help on using the repository browser.