source: trunk/admin/intro.php @ 861

Last change on this file since 861 was 861, checked in by plg, 15 years ago
  • bug fixed : no display of first added element date in admin/intro if no element in the gallery.
  • 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: 2005-09-03 21:20:24 +0000 (Sat, 03 Sep 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 861 $
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' =>
179      add_session_id(PHPWG_ROOT_PATH.'admin.php?action=check_upgrade'),
180    'U_PHPINFO' =>
181      add_session_id(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' => add_session_id(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' => add_session_id(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.