source: trunk/admin/intro.php @ 1878

Last change on this file since 1878 was 1726, checked in by rub, 18 years ago

Very little/small corrections:

o bad parser word user on installation
o standardization of the method to open link in new tab/windows
o removed not used constant
o use/add link constants
o use new function pwg_URL
o add missing translation

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