source: branches/branch-1_6/admin/intro.php @ 1459

Last change on this file since 1459 was 1227, checked in by plg, 19 years ago

merge -r990:991 from branch 1.5 to branch 1.6 (bug 196 fixed)

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