source: trunk/admin/intro.php @ 2232

Last change on this file since 2232 was 2232, checked in by rub, 16 years ago

0000809: Use more php classes implementation

Use class for c13y

  • 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// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | file          : $Id: intro.php 2232 2008-03-01 13:23:51Z rub $
8// | last update   : $Date: 2008-03-01 13:23:51 +0000 (Sat, 01 Mar 2008) $
9// | last modifier : $Author: rub $
10// | revision      : $Revision: 2232 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27if (!defined('PHPWG_ROOT_PATH'))
28{
29  die ("Hacking attempt!");
30}
31
32include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
33include_once(PHPWG_ROOT_PATH.'admin/include/check_integrity.class.php');
34include_once(PHPWG_ROOT_PATH.'admin/include/c13y_internal.class.php');
35
36// +-----------------------------------------------------------------------+
37// | Check Access and exit when user status is not ok                      |
38// +-----------------------------------------------------------------------+
39check_status(ACCESS_ADMINISTRATOR);
40
41// +-----------------------------------------------------------------------+
42// |                                actions                                |
43// +-----------------------------------------------------------------------+
44
45// Check for upgrade : code inspired from punbb
46if (isset($_GET['action']) and 'check_upgrade' == $_GET['action'])
47{
48  if (!ini_get('allow_url_fopen'))
49  {
50    array_push(
51      $page['errors'],
52      l10n('Unable to check for upgrade since allow_url_fopen is disabled.')
53      );
54  }
55  else
56  {
57    $versions = array('current' => PHPWG_VERSION);
58    $lines = @file(PHPWG_URL.'/latest_version');
59
60    // if the current version is a BSF (development branch) build, we check
61    // the first line, for stable versions, we check the second line
62    if (preg_match('/^BSF/', $versions{'current'}))
63    {
64      $versions{'latest'} = trim($lines[0]);
65
66      // because integer are limited to 4,294,967,296 we need to split BSF
67      // versions in date.time
68      foreach ($versions as $key => $value)
69      {
70        $versions{$key} =
71          preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value);
72      }
73    }
74    else
75    {
76      $versions{'latest'} = trim($lines[1]);
77    }
78
79    if ('' == $versions{'latest'})
80    {
81      array_push(
82        $page['errors'],
83        l10n('Check for upgrade failed for unknown reasons.')
84        );
85    }
86    // concatenation needed to avoid automatic transformation by release
87    // script generator
88    else if ('%'.'PWGVERSION'.'%' == $versions{'current'})
89    {
90      array_push(
91        $page['infos'],
92        l10n('You are running on development sources, no check possible.')
93        );
94    }
95    else if (version_compare($versions{'current'}, $versions{'latest'}) < 0)
96    {
97      array_push(
98        $page['infos'],
99        l10n('A new version of PhpWebGallery is available.')
100        );
101    }
102    else
103    {
104      array_push(
105        $page['infos'],
106        l10n('You are running the latest version of PhpWebGallery.')
107        );
108    }
109  }
110}
111// Show phpinfo() output
112else if (isset($_GET['action']) and 'phpinfo' == $_GET['action'])
113{
114  phpinfo();
115  exit();
116}
117
118// +-----------------------------------------------------------------------+
119// |                             template init                             |
120// +-----------------------------------------------------------------------+
121
122$template->set_filenames(array('intro' => 'admin/intro.tpl'));
123
124$php_current_timestamp = date("Y-m-d H:i:s");
125list($mysql_version, $db_current_timestamp) = mysql_fetch_row(pwg_query('SELECT VERSION(), CURRENT_TIMESTAMP;'));
126
127$query = '
128SELECT COUNT(*)
129  FROM '.IMAGES_TABLE.'
130;';
131list($nb_elements) = mysql_fetch_row(pwg_query($query));
132
133$query = '
134SELECT COUNT(*)
135  FROM '.CATEGORIES_TABLE.'
136;';
137list($nb_categories) = mysql_fetch_row(pwg_query($query));
138
139$query = '
140SELECT COUNT(*)
141  FROM '.CATEGORIES_TABLE.'
142  WHERE dir IS NULL
143;';
144list($nb_virtual) = mysql_fetch_row(pwg_query($query));
145
146$query = '
147SELECT COUNT(*)
148  FROM '.CATEGORIES_TABLE.'
149  WHERE dir IS NOT NULL
150;';
151list($nb_physical) = mysql_fetch_row(pwg_query($query));
152
153$query = '
154SELECT COUNT(*)
155  FROM '.IMAGE_CATEGORY_TABLE.'
156;';
157list($nb_image_category) = mysql_fetch_row(pwg_query($query));
158
159$query = '
160SELECT COUNT(*)
161  FROM '.TAGS_TABLE.'
162;';
163list($nb_tags) = mysql_fetch_row(pwg_query($query));
164
165$query = '
166SELECT COUNT(*)
167  FROM '.IMAGE_TAG_TABLE.'
168;';
169list($nb_image_tag) = mysql_fetch_row(pwg_query($query));
170
171$query = '
172SELECT COUNT(*)
173  FROM '.USERS_TABLE.'
174;';
175list($nb_users) = mysql_fetch_row(pwg_query($query));
176
177$query = '
178SELECT COUNT(*)
179  FROM '.GROUPS_TABLE.'
180;';
181list($nb_groups) = mysql_fetch_row(pwg_query($query));
182
183$query = '
184SELECT COUNT(*)
185  FROM '.COMMENTS_TABLE.'
186;';
187list($nb_comments) = mysql_fetch_row(pwg_query($query));
188
189$template->assign(
190  array(
191    'PWG_VERSION' => PHPWG_VERSION,
192    'OS' => PHP_OS,
193    'PHP_VERSION' => phpversion(),
194    'MYSQL_VERSION' => $mysql_version,
195    'DB_ELEMENTS' => l10n_dec('%d element', '%d elements', $nb_elements),
196    'DB_CATEGORIES' =>
197      l10n_dec('cat_inclu_part1_S', 'cat_inclu_part1_P',
198        $nb_categories).
199      l10n_dec('cat_inclu_part2_S', 'cat_inclu_part2_P',
200        $nb_physical).
201      l10n_dec('cat_inclu_part3_S', 'cat_inclu_part3_P',
202        $nb_virtual),
203    'DB_IMAGE_CATEGORY' => l10n_dec('%d association', '%d associations', $nb_image_category),
204    'DB_TAGS' => l10n_dec('%d tag', '%d tags', $nb_tags),
205    'DB_IMAGE_TAG' => l10n_dec('%d association', '%d associations', $nb_image_tag),
206    'DB_USERS' => l10n_dec('%d user', '%d users', $nb_users),
207    'DB_GROUPS' => l10n_dec('%d group', '%d groups', $nb_groups),
208    'DB_COMMENTS' => l10n_dec('%d comment', '%d comments', $nb_comments),
209    'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
210    'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo',
211    'PHP_DATATIME' => $php_current_timestamp,
212    'DB_DATATIME' => $db_current_timestamp,
213    )
214  );
215
216if ($nb_elements > 0)
217{
218  $query = '
219SELECT MIN(date_available)
220  FROM '.IMAGES_TABLE.'
221;';
222  list($first_date) = mysql_fetch_row(pwg_query($query));
223
224  $template->assign(
225    'first_added',
226    array(
227      'DB_DATE' =>
228      sprintf(
229        l10n('first element added on %s'),
230        format_date($first_date, 'mysql_datetime')
231        )
232      )
233    );
234}
235
236// waiting elements
237$query = '
238SELECT COUNT(*)
239  FROM '.WAITING_TABLE.'
240  WHERE validated=\'false\'
241;';
242list($nb_waiting) = mysql_fetch_row(pwg_query($query));
243
244if ($nb_waiting > 0)
245{
246  $template->assign(
247    'waiting',
248    array(
249      'URL' => PHPWG_ROOT_PATH.'admin.php?page=upload',
250      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_waiting)
251      )
252    );
253}
254
255// unvalidated comments
256$query = '
257SELECT COUNT(*)
258  FROM '.COMMENTS_TABLE.'
259  WHERE validated=\'false\'
260;';
261list($nb_comments) = mysql_fetch_row(pwg_query($query));
262
263if ($nb_comments > 0)
264{
265  $template->assign(
266    'unvalidated',
267    array(
268      'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments',
269      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments)
270      )
271    );
272}
273
274// Add the PhpWebGallery Official menu
275  $template->assign( 'pwgmenu', pwg_URL() );
276
277// +-----------------------------------------------------------------------+
278// |                           sending html code                           |
279// +-----------------------------------------------------------------------+
280
281$template->assign_var_from_handle('ADMIN_CONTENT', 'intro');
282
283// Check integrity
284$c13y = new check_integrity();
285// add internal checks
286new c13y_internal();
287// check and display
288$c13y->check();
289$c13y->display();
290
291?>
Note: See TracBrowser for help on using the repository browser.