source: trunk/admin/intro.php @ 817

Last change on this file since 817 was 817, checked in by plg, 19 years ago
  • modification : major simplification of admin.php. Titles are managed by included page, localized items are managed directly in the template.
  • new : sub template admin/double_select is included in templates admin/cat_options, admin/user_perm and admin/group_perm. I haven't been able to use it in admin/picture_modify because it seems impossible to have two instance of the same sub-template without interfering.
  • modification : bug 99, in profile manager, no auto submit when changing language (useless and generate accessibility problem).
  • improvement : HTML semantically correct for administration menu, simpler syntax, less tags, correct tags (dl/dt/dd instead of div/div).
  • modification : number of waiting elements and unvalidated comments are displayed in admin/intro instead of administration menu (with a link to the dedicated pages).
  • deletion : no link to profile from admin/user_list anymore (no need).
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.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-2005 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2005-08-17 14:25:38 +0000 (Wed, 17 Aug 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 817 $
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}
32include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
33
34// +-----------------------------------------------------------------------+
35// |                                actions                                |
36// +-----------------------------------------------------------------------+
37
38// Check for upgrade : code inspired from punbb
39if (isset($_GET['action']) and 'check_upgrade' == $_GET['action'])
40{
41  if (!ini_get('allow_url_fopen'))
42  {
43    array_push(
44      $page['errors'],
45      l10n('Unable to check for upgrade since allow_url_fopen is disabled.')
46      );
47  }
48  else
49  {
50    $versions = array('current' => PHPWG_VERSION);
51    $lines = @file('http://www.phpwebgallery.net/latest_version');
52   
53    // if the current version is a BSF (development branch) build, we check
54    // the first line, for stable versions, we check the second line
55    if (preg_match('/^BSF/', $versions{'current'}))
56    {
57      $versions{'latest'} = trim($lines[0]);
58
59      // because integer are limited to 4,294,967,296 we need to split BSF
60      // versions in date.time
61      foreach ($versions as $key => $value)
62      {
63        $versions{$key} =
64          preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value);
65      }
66    }
67    else
68    {
69      $versions{'latest'} = trim($lines[1]);
70    }
71
72    if ('' == $versions{'latest'})
73    {
74      array_push(
75        $page['errors'],
76        l10n('Check for upgrade failed for unknown reasons.')
77        );
78    }
79    else if ('%PWGVERSION%' == $versions{'current'})
80    {
81      array_push(
82        $page['infos'],
83        l10n('You are running on development sources, no check possible.')
84        );
85    }
86    else if (version_compare($versions{'current'}, $versions{'latest'}) < 0)
87    {
88      array_push(
89        $page['infos'],
90        l10n('A new version of PhpWebGallery is available.')
91        );
92    }
93    else
94    {
95      array_push(
96        $page['infos'],
97        l10n('You are running the latest version of PhpWebGallery.')
98        );
99    }
100  }
101}
102// Show phpinfo() output
103else if (isset($_GET['action']) and 'phpinfo' == $_GET['action'])
104{
105  phpinfo();
106  exit();
107}
108
109// +-----------------------------------------------------------------------+
110// |                             template init                             |
111// +-----------------------------------------------------------------------+
112
113$template->set_filenames(array('intro' => 'admin/intro.tpl'));
114
115list($mysql_version) = mysql_fetch_row(pwg_query('SELECT VERSION();'));
116
117$query = '
118SELECT COUNT(*)
119  FROM '.IMAGES_TABLE.'
120;';
121list($nb_elements) = mysql_fetch_row(pwg_query($query));
122
123$query = '
124SELECT COUNT(*)
125  FROM '.CATEGORIES_TABLE.'
126;';
127list($nb_categories) = mysql_fetch_row(pwg_query($query));
128
129$query = '
130SELECT COUNT(*)
131  FROM '.CATEGORIES_TABLE.'
132  WHERE dir IS NULL
133;';
134list($nb_virtual) = mysql_fetch_row(pwg_query($query));
135
136$query = '
137SELECT COUNT(*)
138  FROM '.CATEGORIES_TABLE.'
139  WHERE dir IS NOT NULL
140;';
141list($nb_physical) = mysql_fetch_row(pwg_query($query));
142
143$query = '
144SELECT COUNT(*)
145  FROM '.USERS_TABLE.'
146;';
147list($nb_users) = mysql_fetch_row(pwg_query($query));
148
149$query = '
150SELECT COUNT(*)
151  FROM '.GROUPS_TABLE.'
152;';
153list($nb_groups) = mysql_fetch_row(pwg_query($query));
154
155$query = '
156SELECT COUNT(*)
157  FROM '.COMMENTS_TABLE.'
158;';
159list($nb_comments) = mysql_fetch_row(pwg_query($query));
160
161$query = '
162SELECT MIN(date_available)
163  FROM '.IMAGES_TABLE.'
164;';
165list($first_date) = mysql_fetch_row(pwg_query($query));
166
167$template->assign_vars(
168  array(
169    'PWG_VERSION' => PHPWG_VERSION,
170    'OS' => PHP_OS,
171    'PHP_VERSION' => phpversion(),
172    'MYSQL_VERSION' => $mysql_version,
173    'DB_ELEMENTS' => sprintf(l10n('%d elements'), $nb_elements),
174    'DB_CATEGORIES' =>
175      sprintf(
176        l10n('%d categories including %d physical and %d virtual'),
177        $nb_categories,
178        $nb_physical,
179        $nb_virtual
180        ),
181    'DB_USERS' => sprintf(l10n('%d users'), $nb_users),
182    'DB_GROUPS' => sprintf(l10n('%d groups'), $nb_groups),
183    'DB_COMMENTS' => sprintf(l10n('%d comments'), $nb_comments),
184    'DB_DATE' =>
185      sprintf(
186        l10n('first element added on %s'),
187        format_date($first_date, 'mysql_datetime')
188        ),
189    'U_CHECK_UPGRADE' =>
190      add_session_id(PHPWG_ROOT_PATH.'admin.php?action=check_upgrade'),
191    'U_PHPINFO' =>
192      add_session_id(PHPWG_ROOT_PATH.'admin.php?action=phpinfo')
193    )
194  );
195
196// waiting elements
197$query = '
198SELECT COUNT(*)
199  FROM '.WAITING_TABLE.'
200  WHERE validated=\'false\'
201;';
202list($nb_waiting) = mysql_fetch_row(pwg_query($query));
203
204if ($nb_waiting > 0)
205{
206  $template->assign_block_vars(
207    'waiting',
208    array(
209      'URL' => add_session_id(PHPWG_ROOT_PATH.'admin.php?page=waiting'),
210      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_waiting)
211      )
212    );
213}
214
215// unvalidated comments
216$query = '
217SELECT COUNT(*)
218  FROM '.COMMENTS_TABLE.'
219  WHERE validated=\'false\'
220;';
221list($nb_comments) = mysql_fetch_row(pwg_query($query));
222
223if ($nb_comments > 0)
224{
225  $template->assign_block_vars(
226    'unvalidated',
227    array(
228      'URL' => add_session_id(PHPWG_ROOT_PATH.'admin.php?page=comments'),
229      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments)
230      )
231    );
232}
233
234// +-----------------------------------------------------------------------+
235// |                           sending html code                           |
236// +-----------------------------------------------------------------------+
237
238$template->assign_var_from_handle('ADMIN_CONTENT', 'intro');
239
240?>
Note: See TracBrowser for help on using the repository browser.