source: trunk/admin.php @ 1700

Last change on this file since 1700 was 1700, checked in by rub, 17 years ago

Feature Issue ID 0000496: Integrate MOD add_index on PWG with plugin.lang.php

Missing state 'active' to check direct access plugin page.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.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-2006 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2007-01-08 05:48:37 +0000 (Mon, 08 Jan 2007) $
10// | last modifier : $Author: rub $
11// | revision      : $Revision: 1700 $
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
28//----------------------------------------------------------- include
29define('PHPWG_ROOT_PATH','./');
30define('IN_ADMIN', true);
31include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
32
33include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
34include_once(PHPWG_ROOT_PATH.'admin/include/functions_plugins.inc.php');
35
36// +-----------------------------------------------------------------------+
37// | Check Access and exit when user status is not ok                      |
38// +-----------------------------------------------------------------------+
39check_status(ACCESS_ADMINISTRATOR);
40
41// +-----------------------------------------------------------------------+
42// |                    synchronize user informations                      |
43// +-----------------------------------------------------------------------+
44
45sync_users();
46
47// +-----------------------------------------------------------------------+
48// |  Check configuration and add notes on problem                         |
49// +-----------------------------------------------------------------------+
50
51check_conf();
52
53// +-----------------------------------------------------------------------+
54// |                            variables init                             |
55// +-----------------------------------------------------------------------+
56
57unset($page['page']);
58
59if 
60  (
61    isset($_GET['page'])
62    and preg_match('/^[a-z_]*$/', $_GET['page'])
63  )
64{
65  if
66    (
67      (!isset($_GET['page_type']) or $_GET['page_type'] == 'standard')
68      and is_file(PHPWG_ROOT_PATH.'admin/'.$_GET['page'].'.php')
69    )
70  {
71    $page['page']['type'] = 'standard';
72    $page['page']['name'] = $_GET['page'];
73  }
74  else if
75    (
76      (isset($_GET['page_type']) and $_GET['page_type'] == 'plugin')
77      and isset($_GET['plugin_id'])
78      and preg_match('/^[a-z_]*$/', $_GET['plugin_id'])
79      and is_file(PHPWG_PLUGINS_PATH.$_GET['plugin_id'].'/admin/'.$_GET['page'].'.php')
80    )
81  {
82    if (function_exists('mysql_real_escape_string'))
83    {
84      $page['page']['plugin_id'] = mysql_real_escape_string($_GET['plugin_id']);
85    }
86    else
87    {
88      $page['page']['plugin_id'] = mysql_escape_string($_GET['plugin_id']);
89    }
90
91    $check_db_plugin = get_db_plugins('active', $page['page']['plugin_id']);
92    if (!empty($check_db_plugin))
93    {
94      $page['page']['type'] = $_GET['page_type'];
95      $page['page']['name'] = $_GET['page'];
96    }
97    else
98    {
99      unset($page['page']);
100    }
101    unset($check_db_plugin);
102  }
103}
104
105if (!isset($page['page']))
106{
107  if (isset($_GET['page_type']) and $_GET['page_type'] == 'plugin')
108  {
109    $page['page']['type'] = 'standard';
110    $page['page']['name'] = 'plugins';
111  }
112  else
113  {
114    $page['page']['type'] = 'standard';
115    $page['page']['name'] = 'intro';
116  }
117}
118
119$page['errors'] = array();
120$page['infos']  = array();
121
122$link_start = PHPWG_ROOT_PATH.'admin.php?page=';
123$conf_link = $link_start.'configuration&amp;section=';
124$opt_link = $link_start.'cat_options&amp;section=';
125//----------------------------------------------------- template initialization
126$title = l10n('PhpWebGallery Administration'); // for include/page_header.php
127$page['page_banner'] = '<h1>'.l10n('PhpWebGallery Administration').'</h1>';
128$page['body_id'] = 'theAdminPage';
129include(PHPWG_ROOT_PATH.'include/page_header.php');
130
131$template->set_filenames(array('admin' => 'admin.tpl'));
132
133$template->assign_vars(
134  array(
135    'U_SITE_MANAGER'=> $link_start.'site_manager',
136    'U_HISTORY'=> $link_start.'stats',
137    'U_FAQ'=> $link_start.'help',
138    'U_SITES'=> $link_start.'remote_site',
139    'U_MAINTENANCE'=> $link_start.'maintenance',
140    'U_NOTIFICATION_BY_MAIL'=> $link_start.'notification_by_mail',
141    'U_ADVANCED_FEATURE'=> $link_start.'advanced_feature',
142    'U_CONFIG_GENERAL'=> $conf_link.'general',
143    'U_CONFIG_COMMENTS'=> $conf_link.'comments',
144    'U_CONFIG_DISPLAY'=> $conf_link.'default',
145    'U_CATEGORIES'=> $link_start.'cat_list',
146    'U_MOVE'=> $link_start.'cat_move',
147    'U_CAT_UPLOAD'=> $opt_link.'upload',
148    'U_CAT_COMMENTS'=> $opt_link.'comments',
149    'U_CAT_VISIBLE'=> $opt_link.'visible',
150    'U_CAT_STATUS'=> $opt_link.'status',
151    'U_CAT_OPTIONS'=> $link_start.'cat_options',
152    'U_CAT_UPDATE'=> $link_start.'site_update&amp;site=1',
153    'U_WAITING'=> $link_start.'waiting',
154    'U_COMMENTS'=> $link_start.'comments',
155    'U_RATING'=> $link_start.'rating',
156    'U_CADDIE'=> $link_start.'element_set&amp;cat=caddie',
157    'U_TAGS'=> $link_start.'tags',
158    'U_THUMBNAILS'=> $link_start.'thumbnail',
159    'U_USERS'=> $link_start.'user_list',
160    'U_GROUPS'=> $link_start.'group_list',
161    'U_RETURN'=> make_index_url(),
162    'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php',
163    'L_ADMIN' => $lang['admin'],
164    'L_ADMIN_HINT' => $lang['hint_admin']
165    )
166  );
167if ($conf['allow_web_services'])
168{
169  $template->assign_block_vars(
170    'web_services',
171    array(
172      'U_WS_CHECKER'=> $link_start.'ws_checker',
173      )
174    );
175}
176if ($conf['allow_random_representative'])
177{
178  $template->assign_block_vars(
179    'representative',
180    array(
181      'URL' => $opt_link.'representative'
182      )
183    );
184}
185
186// required before plugin page inclusion
187trigger_action('plugin_admin_menu');
188
189switch($page['page']['type'])
190{
191  case 'standard':
192  {
193    include(PHPWG_ROOT_PATH.'admin/'.$page['page']['name'].'.php');
194    break;
195  }
196  case 'plugin':
197  {
198    include(PHPWG_PLUGINS_PATH.$page['page']['plugin_id'].'/admin/'.$page['page']['name'].'.php');
199    break;
200  }
201  default:
202  {
203    die ("Hacking attempt!");
204    break;
205  }
206}
207
208
209//------------------------------------------------------------- content display
210$template->assign_block_vars('plugin_menu.menu_item',
211    array(
212      'NAME' => l10n('admin'),
213      'URL' => $link_start.'plugins'
214    )
215  );
216if ( isset($page['plugin_admin_menu']) )
217{
218  $plug_base_url = $link_start.'plugin&amp;section=';
219  foreach ($page['plugin_admin_menu'] as $menu)
220  {
221    $template->assign_block_vars('plugin_menu.menu_item',
222        array(
223          'NAME' => $menu['title'],
224          'URL' => $plug_base_url.$menu['uid']
225        )
226      );
227  }
228}
229
230// +-----------------------------------------------------------------------+
231// |                            errors & infos                             |
232// +-----------------------------------------------------------------------+
233
234if (count($page['errors']) != 0)
235{
236  foreach ($page['errors'] as $error)
237  {
238    $template->assign_block_vars('errors.error',array('ERROR'=>$error));
239  }
240}
241
242if (count($page['infos']) != 0)
243{
244  foreach ($page['infos'] as $info)
245  {
246    $template->assign_block_vars('infos.info',array('INFO'=>$info));
247  }
248}
249
250$template->parse('admin');
251include(PHPWG_ROOT_PATH.'include/page_tail.php');
252
253// +-----------------------------------------------------------------------+
254// |                     order permission refreshment                      |
255// +-----------------------------------------------------------------------+
256
257$query = '
258UPDATE '.USER_CACHE_TABLE.'
259  SET need_update = \'true\'
260;';
261pwg_query($query);
262?>
Note: See TracBrowser for help on using the repository browser.