punbb/admin_loader.php
author Dan
Wed, 11 Jul 2007 21:01:48 -0400
changeset 0 f9ffdbd96607
child 2 a8a21e1c7afa
permissions -rw-r--r--
Initial population
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     1
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     2
/***********************************************************************
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     3
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     4
  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     5
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     6
  This file is part of PunBB.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     7
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     8
  PunBB is free software; you can redistribute it and/or modify it
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     9
  under the terms of the GNU General Public License as published
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    10
  by the Free Software Foundation; either version 2 of the License,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    11
  or (at your option) any later version.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    12
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    13
  PunBB is distributed in the hope that it will be useful, but
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    14
  WITHOUT ANY WARRANTY; without even the implied warranty of
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    16
  GNU General Public License for more details.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    17
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    18
  You should have received a copy of the GNU General Public License
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    19
  along with this program; if not, write to the Free Software
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    20
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    21
  MA  02111-1307  USA
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    22
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    23
************************************************************************/
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    24
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    25
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    26
// Tell header.php to use the admin template
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    27
define('PUN_ADMIN_CONSOLE', 1);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    28
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    29
define('PUN_ROOT', './');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    30
require PUN_ROOT.'include/common.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    31
require PUN_ROOT.'include/common_admin.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    32
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    33
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    34
if ($pun_user['g_id'] > PUN_MOD)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    35
	message($lang_common['No permission']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    36
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    37
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    38
// The plugin to load should be supplied via GET
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    39
$plugin = isset($_GET['plugin']) ? $_GET['plugin'] : '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    40
if (!@preg_match('/^AM?P_(\w*?)\.php$/i', $plugin))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    41
	message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    42
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    43
// AP_ == Admins only, AMP_ == admins and moderators
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    44
$prefix = substr($plugin, 0, strpos($plugin, '_'));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    45
if ($pun_user['g_id'] == PUN_MOD && $prefix == 'AP')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    46
	message($lang_common['No permission']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    47
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    48
// Make sure the file actually exists
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    49
if (!file_exists(PUN_ROOT.'plugins/'.$plugin))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    50
	message('There is no plugin called \''.$plugin.'\' in the plugin directory.');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    51
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    52
// Construct REQUEST_URI if it isn't set
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    53
if (!isset($_SERVER['REQUEST_URI']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    54
	$_SERVER['REQUEST_URI'] = (isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : '').'?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    55
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    56
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / '.$plugin;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    57
require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    58
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    59
// Attempt to load the plugin. We don't use @ here to supress error messages,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    60
// because if we did and a parse error occurred in the plugin, we would only
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    61
// get the "blank page of death".
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    62
include PUN_ROOT.'plugins/'.$plugin;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    63
if (!defined('PUN_PLUGIN_LOADED'))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    64
	message('Loading of the plugin \''.$plugin.'\' failed.');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    65
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    66
// Output the clearer div
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    67
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    68
	<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    69
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    70
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    71
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    72
require PUN_ROOT.'footer.php';