source: trunk/admin/intro.php @ 1004

Last change on this file since 1004 was 1004, 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.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: 2006-01-15 13:45:42 +0000 (Sun, 15 Jan 2006) $
10// | last modifier : $Author: nikrou $
11// | revision      : $Revision: 1004 $
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$template->assign_vars(
162  array(
163    'PWG_VERSION' => PHPWG_VERSION,
164    'OS' => PHP_OS,
165    'PHP_VERSION' => phpversion(),
166    'MYSQL_VERSION' => $mysql_version,
167    'DB_ELEMENTS' => sprintf(l10n('%d elements'), $nb_elements),
168    'DB_CATEGORIES' =>
169      sprintf(
170        l10n('%d categories including %d physical and %d virtual'),
171        $nb_categories,
172        $nb_physical,
173        $nb_virtual
174        ),
175    'DB_USERS' => sprintf(l10n('%d users'), $nb_users),
176    'DB_GROUPS' => sprintf(l10n('%d groups'), $nb_groups),
177    'DB_COMMENTS' => sprintf(l10n('%d comments'), $nb_comments),
178    'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
179    'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo'
180    )
181  );
182
183if ($nb_elements > 0)
184{
185  $query = '
186SELECT MIN(date_available)
187  FROM '.IMAGES_TABLE.'
188;';
189  list($first_date) = mysql_fetch_row(pwg_query($query));
190
191  $template->assign_block_vars(
192    'first_added',
193    array(
194      'DB_DATE' =>
195      sprintf(
196        l10n('first element added on %s'),
197        format_date($first_date, 'mysql_datetime')
198        )
199      )
200    );
201}
202
203// waiting elements
204$query = '
205SELECT COUNT(*)
206  FROM '.WAITING_TABLE.'
207  WHERE validated=\'false\'
208;';
209list($nb_waiting) = mysql_fetch_row(pwg_query($query));
210
211if ($nb_waiting > 0)
212{
213  $template->assign_block_vars(
214    'waiting',
215    array(
216      'URL' => PHPWG_ROOT_PATH.'admin.php?page=waiting',
217      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_waiting)
218      )
219    );
220}
221
222// unvalidated comments
223$query = '
224SELECT COUNT(*)
225  FROM '.COMMENTS_TABLE.'
226  WHERE validated=\'false\'
227;';
228list($nb_comments) = mysql_fetch_row(pwg_query($query));
229
230if ($nb_comments > 0)
231{
232  $template->assign_block_vars(
233    'unvalidated',
234    array(
235      'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments',
236      'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments)
237      )
238    );
239}
240
241// +-----------------------------------------------------------------------+
242// |                           sending html code                           |
243// +-----------------------------------------------------------------------+
244
245$template->assign_var_from_handle('ADMIN_CONTENT', 'intro');
246
247?>
Note: See TracBrowser for help on using the repository browser.