source: branches/1.5/admin/intro.php @ 8154

Last change on this file since 8154 was 1005, checked in by nikrou, 19 years ago

Revert to revision 1002

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.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-2005 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2006-01-15 13:49:29 +0000 (Sun, 15 Jan 2006) $
10// | last modifier : $Author: nikrou $
11// | revision      : $Revision: 1005 $
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    // concatenation needed to avoid automatic transformation by release
80    // script generator
81    else if ('%'.'PWGVERSION'.'%' == $versions{'current'})
82    {
83      array_push(
84        $page['infos'],
85        l10n('You are running on development sources, no check possible.')
86        );
87    }
88    else if (version_compare($versions{'current'}, $versions{'latest'}) < 0)
89    {
90      array_push(
91        $page['infos'],
92        l10n('A new version of PhpWebGallery is available.')
93        );
94    }
95    else
96    {
97      array_push(
98        $page['infos'],
99        l10n('You are running the latest version of PhpWebGallery.')
100        );
101    }
102  }
103}
104// Show phpinfo() output
105else if (isset($_GET['action']) and 'phpinfo' == $_GET['action'])
106{
107  phpinfo();
108  exit();
109}
110
111// +-----------------------------------------------------------------------+
112// |                             template init                             |
113// +-----------------------------------------------------------------------+
114
115$template->set_filenames(array('intro' => 'admin/intro.tpl'));
116
117list($mysql_version) = mysql_fetch_row(pwg_query('SELECT VERSION();'));
118
119$query = '
120SELECT COUNT(*)
121  FROM '.IMAGES_TABLE.'
122;';
123list($nb_elements) = mysql_fetch_row(pwg_query($query));
124
125$query = '
126SELECT COUNT(*)
127  FROM '.CATEGORIES_TABLE.'
128;';
129list($nb_categories) = mysql_fetch_row(pwg_query($query));
130
131$query = '
132SELECT COUNT(*)
133  FROM '.CATEGORIES_TABLE.'
134  WHERE dir IS NULL
135;';
136list($nb_virtual) = mysql_fetch_row(pwg_query($query));
137
138$query = '
139SELECT COUNT(*)
140  FROM '.CATEGORIES_TABLE.'
141  WHERE dir IS NOT NULL
142;';
143list($nb_physical) = mysql_fetch_row(pwg_query($query));
144
145$query = '
146SELECT COUNT(*)
147  FROM '.USERS_TABLE.'
148;';
149list($nb_users) = mysql_fetch_row(pwg_query($query));
150
151$query = '
152SELECT COUNT(*)
153  FROM '.GROUPS_TABLE.'
154;';
155list($nb_groups) = mysql_fetch_row(pwg_query($query));
156
157$query = '
158SELECT COUNT(*)
159  FROM '.COMMENTS_TABLE.'
160;';
161list($nb_comments) = mysql_fetch_row(pwg_query($query));
162
163$template->assign_vars(
164  array(
165    'PWG_VERSION' => PHPWG_VERSION,
166    'OS' => PHP_OS,
167    'PHP_VERSION' => phpversion(),
168    'MYSQL_VERSION' => $mysql_version,
169    'DB_ELEMENTS' => sprintf(l10n('%d elements'), $nb_elements),
170    'DB_CATEGORIES' =>
171      sprintf(
172        l10n('%d categories including %d physical and %d virtual'),
173        $nb_categories,
174        $nb_physical,
175        $nb_virtual
176        ),
177    'DB_USERS' => sprintf(l10n('%d users'), $nb_users),
178    'DB_GROUPS' => sprintf(l10n('%d groups'), $nb_groups),
179    'DB_COMMENTS' => sprintf(l10n('%d comments'), $nb_comments),
180    'U_CHECK_UPGRADE' =>
181      add_session_id(PHPWG_ROOT_PATH.'admin.php?action=check_upgrade'),
182    'U_PHPINFO' =>
183      add_session_id(PHPWG_ROOT_PATH.'admin.php?action=phpinfo')
184    )
185  );
186
187if ($nb_elements > 0)
188{
189  $query = '
190SELECT MIN(date_available)
191  FROM '.IMAGES_TABLE.'
192;';
193  list($first_date) = mysql_fetch_row(pwg_query($query));
194
195  $template->assign_block_vars(
196    'first_added',
197    array(
198      'DB_DATE' =>
199      sprintf(
200        l10n('first element added on %s'),
201        format_date($first_date, 'mysql_datetime')
202        )
203      )
204    );
205}
206
207// waiting elements
208$query = '
209SELECT COUNT(*)
210  FROM '.WAITING_TABLE.'
211  WHERE validated=\'false\'
212;';
213list($nb_waiting) = mysql_fetch_row(pwg_query($query));
214
215if ($nb_waiting > 0)
216{
217  $template->assign_block_vars(
218    'waiting',
219    array(
220      'URL' => add_session_id(PHPWG_ROOT_PATH.'admin.php?page=waiting'),
221      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_waiting)
222      )
223    );
224}
225
226// unvalidated comments
227$query = '
228SELECT COUNT(*)
229  FROM '.COMMENTS_TABLE.'
230  WHERE validated=\'false\'
231;';
232list($nb_comments) = mysql_fetch_row(pwg_query($query));
233
234if ($nb_comments > 0)
235{
236  $template->assign_block_vars(
237    'unvalidated',
238    array(
239      'URL' => add_session_id(PHPWG_ROOT_PATH.'admin.php?page=comments'),
240      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments)
241      )
242    );
243}
244
245// +-----------------------------------------------------------------------+
246// |                           sending html code                           |
247// +-----------------------------------------------------------------------+
248
249$template->assign_var_from_handle('ADMIN_CONTENT', 'intro');
250
251?>
Note: See TracBrowser for help on using the repository browser.