source: trunk/admin/intro.php @ 1884

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

Add DateTime on administration introduction page (Useful to help user on the forum, ...)
Move history configuration in a other tab.
Use translation on picture hint (Kb).
Show hint oh the menu text (not only on counter)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.3 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-03-09 22:52:22 +0000 (Fri, 09 Mar 2007) $
10// | last modifier : $Author: rub $
11// | revision      : $Revision: 1884 $
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$php_current_timestamp = date("Y-m-d H:i:s");
188list($db_current_timestamp) = mysql_fetch_row(pwg_query('SELECT CURRENT_TIMESTAMP;'));
189
190$template->assign_vars(
191  array(
192    'PWG_VERSION' => PHPWG_VERSION,
193    'OS' => PHP_OS,
194    'PHP_VERSION' => phpversion(),
195    'MYSQL_VERSION' => $mysql_version,
196    'DB_ELEMENTS' => sprintf(l10n('%d elements'), $nb_elements),
197    'DB_CATEGORIES' =>
198      sprintf(
199        l10n('%d categories including %d physical and %d virtual'),
200        $nb_categories,
201        $nb_physical,
202        $nb_virtual
203        ),
204    'DB_IMAGE_CATEGORY' =>sprintf(l10n('%d associations'), $nb_image_category),
205    'DB_TAGS' => sprintf(l10n('%d tags'), $nb_tags),
206    'DB_IMAGE_TAG' => sprintf(l10n('%d associations'), $nb_image_tag),
207    'DB_USERS' => sprintf(l10n('%d users'), $nb_users),
208    'DB_GROUPS' => sprintf(l10n('%d groups'), $nb_groups),
209    'DB_COMMENTS' => sprintf(l10n('%d comments'), $nb_comments),
210    'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
211    'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo',
212    'PHP_DATATIME' => $php_current_timestamp,
213    'DB_DATATIME' => $db_current_timestamp,
214    )
215  );
216
217if ($nb_elements > 0)
218{
219  $query = '
220SELECT MIN(date_available)
221  FROM '.IMAGES_TABLE.'
222;';
223  list($first_date) = mysql_fetch_row(pwg_query($query));
224
225  $template->assign_block_vars(
226    'first_added',
227    array(
228      'DB_DATE' =>
229      sprintf(
230        l10n('first element added on %s'),
231        format_date($first_date, 'mysql_datetime')
232        )
233      )
234    );
235}
236
237// waiting elements
238$query = '
239SELECT COUNT(*)
240  FROM '.WAITING_TABLE.'
241  WHERE validated=\'false\'
242;';
243list($nb_waiting) = mysql_fetch_row(pwg_query($query));
244
245if ($nb_waiting > 0)
246{
247  $template->assign_block_vars(
248    'waiting',
249    array(
250      'URL' => PHPWG_ROOT_PATH.'admin.php?page=waiting',
251      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_waiting)
252      )
253    );
254}
255
256// unvalidated comments
257$query = '
258SELECT COUNT(*)
259  FROM '.COMMENTS_TABLE.'
260  WHERE validated=\'false\'
261;';
262list($nb_comments) = mysql_fetch_row(pwg_query($query));
263
264if ($nb_comments > 0)
265{
266  $template->assign_block_vars(
267    'unvalidated',
268    array(
269      'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments',
270      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments)
271      )
272    );
273}
274
275// Add the PhpWebGallery Official menu
276  $template->assign_block_vars( 'pwgmenu', pwg_URL() );
277 
278// +-----------------------------------------------------------------------+
279// |                           sending html code                           |
280// +-----------------------------------------------------------------------+
281
282$template->assign_var_from_handle('ADMIN_CONTENT', 'intro');
283
284?>
Note: See TracBrowser for help on using the repository browser.