source: trunk/admin/intro.php @ 1129

Last change on this file since 1129 was 1072, checked in by rub, 19 years ago

Step 2 improvement issue 0000301:

o Add and use Functions Check of status
o Restricted Access for user generic

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 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: 2006-03-09 22:46:28 +0000 (Thu, 09 Mar 2006) $
10// | last modifier : $Author: rub $
11// | revision      : $Revision: 1072 $
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('http://www.phpwebgallery.net/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    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
121list($mysql_version) = mysql_fetch_row(pwg_query('SELECT VERSION();'));
122
123$query = '
124SELECT COUNT(*)
125  FROM '.IMAGES_TABLE.'
126;';
127list($nb_elements) = mysql_fetch_row(pwg_query($query));
128
129$query = '
130SELECT COUNT(*)
131  FROM '.CATEGORIES_TABLE.'
132;';
133list($nb_categories) = mysql_fetch_row(pwg_query($query));
134
135$query = '
136SELECT COUNT(*)
137  FROM '.CATEGORIES_TABLE.'
138  WHERE dir IS NULL
139;';
140list($nb_virtual) = mysql_fetch_row(pwg_query($query));
141
142$query = '
143SELECT COUNT(*)
144  FROM '.CATEGORIES_TABLE.'
145  WHERE dir IS NOT NULL
146;';
147list($nb_physical) = mysql_fetch_row(pwg_query($query));
148
149$query = '
150SELECT COUNT(*)
151  FROM '.USERS_TABLE.'
152;';
153list($nb_users) = mysql_fetch_row(pwg_query($query));
154
155$query = '
156SELECT COUNT(*)
157  FROM '.GROUPS_TABLE.'
158;';
159list($nb_groups) = mysql_fetch_row(pwg_query($query));
160
161$query = '
162SELECT COUNT(*)
163  FROM '.COMMENTS_TABLE.'
164;';
165list($nb_comments) = 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    'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
185    'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo'
186    )
187  );
188
189if ($nb_elements > 0)
190{
191  $query = '
192SELECT MIN(date_available)
193  FROM '.IMAGES_TABLE.'
194;';
195  list($first_date) = mysql_fetch_row(pwg_query($query));
196
197  $template->assign_block_vars(
198    'first_added',
199    array(
200      'DB_DATE' =>
201      sprintf(
202        l10n('first element added on %s'),
203        format_date($first_date, 'mysql_datetime')
204        )
205      )
206    );
207}
208
209// waiting elements
210$query = '
211SELECT COUNT(*)
212  FROM '.WAITING_TABLE.'
213  WHERE validated=\'false\'
214;';
215list($nb_waiting) = mysql_fetch_row(pwg_query($query));
216
217if ($nb_waiting > 0)
218{
219  $template->assign_block_vars(
220    'waiting',
221    array(
222      'URL' => PHPWG_ROOT_PATH.'admin.php?page=waiting',
223      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_waiting)
224      )
225    );
226}
227
228// unvalidated comments
229$query = '
230SELECT COUNT(*)
231  FROM '.COMMENTS_TABLE.'
232  WHERE validated=\'false\'
233;';
234list($nb_comments) = mysql_fetch_row(pwg_query($query));
235
236if ($nb_comments > 0)
237{
238  $template->assign_block_vars(
239    'unvalidated',
240    array(
241      'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments',
242      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments)
243      )
244    );
245}
246
247// +-----------------------------------------------------------------------+
248// |                           sending html code                           |
249// +-----------------------------------------------------------------------+
250
251$template->assign_var_from_handle('ADMIN_CONTENT', 'intro');
252
253?>
Note: See TracBrowser for help on using the repository browser.