source: trunk/admin.php @ 1700

Last change on this file since 1700 was 1700, checked in by rub, 18 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
RevLine 
[217]1<?php
[354]2// +-----------------------------------------------------------------------+
[593]3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
[1058]5// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
[354]6// +-----------------------------------------------------------------------+
[593]7// | branch        : BSF (Best So Far)
[354]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// +-----------------------------------------------------------------------+
[217]27
[345]28//----------------------------------------------------------- include
[364]29define('PHPWG_ROOT_PATH','./');
[393]30define('IN_ADMIN', true);
[364]31include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
[808]32
[1072]33include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
[1655]34include_once(PHPWG_ROOT_PATH.'admin/include/functions_plugins.inc.php');
[1072]35
[808]36// +-----------------------------------------------------------------------+
[1072]37// | Check Access and exit when user status is not ok                      |
38// +-----------------------------------------------------------------------+
39check_status(ACCESS_ADMINISTRATOR);
40
41// +-----------------------------------------------------------------------+
[808]42// |                    synchronize user informations                      |
43// +-----------------------------------------------------------------------+
44
45sync_users();
46
[817]47// +-----------------------------------------------------------------------+
[1682]48// |  Check configuration and add notes on problem                         |
49// +-----------------------------------------------------------------------+
50
51check_conf();
52
53// +-----------------------------------------------------------------------+
[817]54// |                            variables init                             |
55// +-----------------------------------------------------------------------+
[708]56
[1699]57unset($page['page']);
58
59if 
60  (
61    isset($_GET['page'])
[817]62    and preg_match('/^[a-z_]*$/', $_GET['page'])
[1699]63  )
[217]64{
[1699]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
[1700]91    $check_db_plugin = get_db_plugins('active', $page['page']['plugin_id']);
[1699]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  }
[217]103}
[1699]104
105if (!isset($page['page']))
[217]106{
[1699]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  }
[217]117}
[393]118
[1655]119$page['errors'] = array();
120$page['infos']  = array();
121
[393]122$link_start = PHPWG_ROOT_PATH.'admin.php?page=';
[602]123$conf_link = $link_start.'configuration&amp;section=';
[614]124$opt_link = $link_start.'cat_options&amp;section=';
[393]125//----------------------------------------------------- template initialization
[862]126$title = l10n('PhpWebGallery Administration'); // for include/page_header.php
[1071]127$page['page_banner'] = '<h1>'.l10n('PhpWebGallery Administration').'</h1>';
[850]128$page['body_id'] = 'theAdminPage';
[393]129include(PHPWG_ROOT_PATH.'include/page_header.php');
130
[817]131$template->set_filenames(array('admin' => 'admin.tpl'));
[614]132
[817]133$template->assign_vars(
134  array(
[1029]135    'U_SITE_MANAGER'=> $link_start.'site_manager',
[1004]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',
[1091]140    'U_NOTIFICATION_BY_MAIL'=> $link_start.'notification_by_mail',
[1656]141    'U_ADVANCED_FEATURE'=> $link_start.'advanced_feature',
[1004]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',
[1058]152    'U_CAT_UPDATE'=> $link_start.'site_update&amp;site=1',
[1004]153    'U_WAITING'=> $link_start.'waiting',
154    'U_COMMENTS'=> $link_start.'comments',
[1042]155    'U_RATING'=> $link_start.'rating',
[1004]156    'U_CADDIE'=> $link_start.'element_set&amp;cat=caddie',
[1119]157    'U_TAGS'=> $link_start.'tags',
[1004]158    'U_THUMBNAILS'=> $link_start.'thumbnail',
159    'U_USERS'=> $link_start.'user_list',
160    'U_GROUPS'=> $link_start.'group_list',
[1082]161    'U_RETURN'=> make_index_url(),
[1004]162    'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php',
[948]163    'L_ADMIN' => $lang['admin'],
164    'L_ADMIN_HINT' => $lang['hint_admin']
[817]165    )
166  );
[1665]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}
[809]176if ($conf['allow_random_representative'])
177{
178  $template->assign_block_vars(
179    'representative',
180    array(
[1004]181      'URL' => $opt_link.'representative'
[809]182      )
183    );
184}
[1058]185
[1655]186// required before plugin page inclusion
187trigger_action('plugin_admin_menu');
[792]188
[1699]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}
[817]207
[1699]208
[1655]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
[792]230// +-----------------------------------------------------------------------+
231// |                            errors & infos                             |
232// +-----------------------------------------------------------------------+
[817]233
[792]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}
[817]241
[792]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
[688]250$template->parse('admin');
[393]251include(PHPWG_ROOT_PATH.'include/page_tail.php');
[817]252
[657]253// +-----------------------------------------------------------------------+
254// |                     order permission refreshment                      |
255// +-----------------------------------------------------------------------+
[817]256
[657]257$query = '
[808]258UPDATE '.USER_CACHE_TABLE.'
[657]259  SET need_update = \'true\'
260;';
261pwg_query($query);
[362]262?>
Note: See TracBrowser for help on using the repository browser.