source: branches/branch-1_5/admin/intro.php @ 1003

Last change on this file since 1003 was 1003, checked in by nikrou, 18 years ago

Improve security of sessions:

  • use only cookies to store session id on client side
  • use default php session system with database handler to store sessions on server side
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.2 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 12:52:55 +0000 (Sun, 15 Jan 2006) $
10// | last modifier : $Author: nikrou $
11// | revision      : $Revision: 1003 $
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' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
181    'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo'
182    )
183  );
184
185if ($nb_elements > 0)
186{
187  $query = '
188SELECT MIN(date_available)
189  FROM '.IMAGES_TABLE.'
190;';
191  list($first_date) = mysql_fetch_row(pwg_query($query));
192
193  $template->assign_block_vars(
194    'first_added',
195    array(
196      'DB_DATE' =>
197      sprintf(
198        l10n('first element added on %s'),
199        format_date($first_date, 'mysql_datetime')
200        )
201      )
202    );
203}
204
205// waiting elements
206$query = '
207SELECT COUNT(*)
208  FROM '.WAITING_TABLE.'
209  WHERE validated=\'false\'
210;';
211list($nb_waiting) = mysql_fetch_row(pwg_query($query));
212
213if ($nb_waiting > 0)
214{
215  $template->assign_block_vars(
216    'waiting',
217    array(
218      'URL' => PHPWG_ROOT_PATH.'admin.php?page=waiting',
219      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_waiting)
220      )
221    );
222}
223
224// unvalidated comments
225$query = '
226SELECT COUNT(*)
227  FROM '.COMMENTS_TABLE.'
228  WHERE validated=\'false\'
229;';
230list($nb_comments) = mysql_fetch_row(pwg_query($query));
231
232if ($nb_comments > 0)
233{
234  $template->assign_block_vars(
235    'unvalidated',
236    array(
237      'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments',
238      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments)
239      )
240    );
241}
242
243// +-----------------------------------------------------------------------+
244// |                           sending html code                           |
245// +-----------------------------------------------------------------------+
246
247$template->assign_var_from_handle('ADMIN_CONTENT', 'intro');
248
249?>
Note: See TracBrowser for help on using the repository browser.