2003-01-08 17:31:16 +00:00
|
|
|
|
<?php
|
2003-09-07 13:46:51 +00:00
|
|
|
|
// -------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// $Id$
|
|
|
|
|
//
|
|
|
|
|
// FILENAME : mcp.php
|
|
|
|
|
// STARTED : Mon May 5, 2003
|
|
|
|
|
// COPYRIGHT : <20> 2001, 2003 phpBB Group
|
|
|
|
|
// WWW : http://www.phpbb.com/
|
|
|
|
|
// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
|
|
|
|
|
//
|
|
|
|
|
// -------------------------------------------------------------
|
2003-01-08 17:31:16 +00:00
|
|
|
|
|
|
|
|
|
define('IN_PHPBB', true);
|
|
|
|
|
$phpbb_root_path = './';
|
2003-09-07 13:46:51 +00:00
|
|
|
|
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
2003-01-08 17:31:16 +00:00
|
|
|
|
include($phpbb_root_path . 'common.'.$phpEx);
|
|
|
|
|
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
|
|
|
|
|
|
2003-09-14 22:21:57 +00:00
|
|
|
|
// ---------
|
|
|
|
|
// FUNCTIONS
|
2003-02-06 03:30:32 +00:00
|
|
|
|
//
|
2003-09-14 22:21:57 +00:00
|
|
|
|
class module
|
2003-02-06 03:30:32 +00:00
|
|
|
|
{
|
2003-11-27 23:26:19 +00:00
|
|
|
|
var $id = 0;
|
|
|
|
|
var $type;
|
|
|
|
|
var $name;
|
|
|
|
|
var $mode;
|
2004-07-08 22:57:05 +00:00
|
|
|
|
var $url;
|
2003-11-27 23:26:19 +00:00
|
|
|
|
|
|
|
|
|
// Private methods, should not be overwritten
|
2004-07-08 22:57:05 +00:00
|
|
|
|
function create($module_type, $module_url, $post_id, $topic_id, $forum_id, $selected_mod = false, $selected_submod = false)
|
2003-09-14 22:21:57 +00:00
|
|
|
|
{
|
2004-07-08 22:57:05 +00:00
|
|
|
|
global $template, $auth, $db, $user, $config;
|
|
|
|
|
global $phpbb_root_path, $phpEx;
|
|
|
|
|
|
|
|
|
|
if ($post_id)
|
|
|
|
|
{
|
|
|
|
|
if (!$topic_id || !$forum_id)
|
|
|
|
|
{
|
|
|
|
|
$sql = 'SELECT topic_id, forum_id
|
|
|
|
|
FROM ' . POSTS_TABLE . "
|
|
|
|
|
WHERE post_id = $post_id";
|
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
$row = $db->sql_fetchrow($result);
|
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
|
|
|
|
$topic_id = (int) $row['topic_id'];
|
|
|
|
|
$forum_id = (int) $row['forum_id'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($topic_id && !$forum_id)
|
|
|
|
|
{
|
|
|
|
|
$sql = 'SELECT forum_id
|
|
|
|
|
FROM ' . TOPICS_TABLE . "
|
|
|
|
|
WHERE topic_id = $topic_id";
|
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
$row = $db->sql_fetchrow($result);
|
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
|
|
|
|
$forum_id = (int) $row['forum_id'];
|
|
|
|
|
}
|
2003-04-09 21:47:58 +00:00
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
$sql = 'SELECT module_id, module_title, module_filename, module_subs, module_acl
|
2003-09-14 22:21:57 +00:00
|
|
|
|
FROM ' . MODULES_TABLE . "
|
|
|
|
|
WHERE module_type = '{$module_type}'
|
|
|
|
|
AND module_enabled = 1
|
|
|
|
|
ORDER BY module_order ASC";
|
|
|
|
|
$result = $db->sql_query($sql);
|
2003-04-09 21:47:58 +00:00
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
$i = 0;
|
2003-04-09 21:47:58 +00:00
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
2003-04-03 00:10:10 +00:00
|
|
|
|
{
|
2003-11-27 23:26:19 +00:00
|
|
|
|
// Authorisation is required for the basic module
|
2003-09-14 22:21:57 +00:00
|
|
|
|
if ($row['module_acl'])
|
2003-04-09 21:47:58 +00:00
|
|
|
|
{
|
2004-05-26 18:13:53 +00:00
|
|
|
|
$is_auth = false;
|
|
|
|
|
eval('$is_auth = (' . preg_replace(array('#acl_([a-z_]+)#e', '#cfg_([a-z_]+)#e'), array('(int) $auth->acl_get("\\1")', '(int) $config["\\1"]'), trim($row['module_acl'])) . ');');
|
2003-11-27 23:26:19 +00:00
|
|
|
|
|
|
|
|
|
// The user is not authorised to use this module, skip it
|
2003-09-14 22:21:57 +00:00
|
|
|
|
if (!$is_auth)
|
2003-04-09 21:47:58 +00:00
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
$selected = ($row['module_filename'] == $selected_mod || $row['module_id'] == $selected_mod || (!$selected_mod && !$i)) ? true : false;
|
|
|
|
|
|
|
|
|
|
// Get the localised lang string if available, or make up our own otherwise
|
2004-07-08 22:57:05 +00:00
|
|
|
|
$module_lang = strtoupper($module_type) . '_' . $row['module_title'];
|
2003-11-27 23:26:19 +00:00
|
|
|
|
$template->assign_block_vars($module_type . '_section', array(
|
2004-07-08 22:57:05 +00:00
|
|
|
|
'L_TITLE' => (isset($user->lang[$module_lang])) ? $user->lang[$module_lang] : ucfirst(str_replace('_', ' ', strtolower($row['module_title']))),
|
2003-11-27 23:26:19 +00:00
|
|
|
|
'S_SELECTED' => $selected,
|
|
|
|
|
'U_TITLE' => $module_url . '&i=' . $row['module_id'])
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ($selected)
|
2003-04-09 21:47:58 +00:00
|
|
|
|
{
|
2003-11-27 23:26:19 +00:00
|
|
|
|
$module_id = $row['module_id'];
|
2003-09-14 22:21:57 +00:00
|
|
|
|
$module_name = $row['module_filename'];
|
2003-04-09 21:47:58 +00:00
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
if ($row['module_subs'])
|
|
|
|
|
{
|
|
|
|
|
$j = 0;
|
|
|
|
|
$submodules_ary = explode("\n", $row['module_subs']);
|
|
|
|
|
foreach ($submodules_ary as $submodule)
|
|
|
|
|
{
|
|
|
|
|
$submodule = explode(',', trim($submodule));
|
|
|
|
|
$submodule_title = array_shift($submodule);
|
|
|
|
|
|
|
|
|
|
$is_auth = true;
|
|
|
|
|
foreach ($submodule as $auth_option)
|
|
|
|
|
{
|
|
|
|
|
if (!$auth->acl_get($auth_option))
|
|
|
|
|
{
|
|
|
|
|
$is_auth = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-08 22:57:05 +00:00
|
|
|
|
if (!$is_auth || empty($submodule_title))
|
2003-11-27 23:26:19 +00:00
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-08 22:57:05 +00:00
|
|
|
|
// Only show those rows we are able to access
|
|
|
|
|
if (($submodule_title == 'post_details' && !$post_id) ||
|
|
|
|
|
($submodule_title == 'topic_view' && !$topic_id) ||
|
|
|
|
|
($submodule_title == 'forum_view' && !$forum_id))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$suffix = ($post_id) ? "&p=$post_id" : '';
|
|
|
|
|
$suffix .= ($topic_id) ? "&t=$topic_id" : '';
|
|
|
|
|
$suffix .= ($forum_id) ? "&f=$forum_id" : '';
|
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
$selected = ($submodule_title == $selected_submod || (!$selected_submod && !$j)) ? true : false;
|
|
|
|
|
|
|
|
|
|
// Get the localised lang string if available, or make up our own otherwise
|
2004-07-08 22:57:05 +00:00
|
|
|
|
$module_lang = strtoupper($module_type . '_' . $module_name . '_' . $submodule_title);
|
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
$template->assign_block_vars("{$module_type}_section.{$module_type}_subsection", array(
|
2004-07-08 22:57:05 +00:00
|
|
|
|
'L_TITLE' => (isset($user->lang[$module_lang])) ? $user->lang[$module_lang] : ucfirst(str_replace('_', ' ', strtolower($module_lang))),
|
2003-11-27 23:26:19 +00:00
|
|
|
|
'S_SELECTED' => $selected,
|
2004-07-08 22:57:05 +00:00
|
|
|
|
'U_TITLE' => $module_url . '&i=' . $module_id . '&mode=' . $submodule_title . $suffix)
|
2003-11-27 23:26:19 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ($selected)
|
|
|
|
|
{
|
|
|
|
|
$this->mode = $submodule_title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$j++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-04-09 21:47:58 +00:00
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
$i++;
|
2003-04-10 00:56:23 +00:00
|
|
|
|
}
|
|
|
|
|
$db->sql_freeresult($result);
|
2003-09-14 22:21:57 +00:00
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
if (!$module_id)
|
2003-04-09 21:47:58 +00:00
|
|
|
|
{
|
2003-09-14 22:21:57 +00:00
|
|
|
|
trigger_error('MODULE_NOT_EXIST');
|
2003-04-09 21:47:58 +00:00
|
|
|
|
}
|
2003-02-23 08:19:54 +00:00
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
$this->type = $module_type;
|
|
|
|
|
$this->id = $module_id;
|
|
|
|
|
$this->name = $module_name;
|
2004-07-08 22:57:05 +00:00
|
|
|
|
$this->url = "{$phpbb_root_path}mcp.$phpEx?sid={$user->session_id}";
|
|
|
|
|
$this->url .= ($post_id) ? "&p=$post_id" : '';
|
|
|
|
|
$this->url .= ($topic_id) ? "&t=$topic_id" : '';
|
|
|
|
|
$this->url .= ($forum_id) ? "&f=$forum_id" : '';
|
2003-09-14 22:21:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
function load($type = false, $name = false, $mode = false, $run = true)
|
2003-09-14 22:21:57 +00:00
|
|
|
|
{
|
2004-07-08 22:57:05 +00:00
|
|
|
|
global $phpbb_root_path, $phpEx;
|
2003-09-14 22:21:57 +00:00
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
if ($type)
|
2003-02-23 08:19:54 +00:00
|
|
|
|
{
|
2003-11-27 23:26:19 +00:00
|
|
|
|
$this->type = $type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($name)
|
|
|
|
|
{
|
|
|
|
|
$this->name = $name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!class_exists($this->type . '_' . $this->name))
|
|
|
|
|
{
|
2004-07-08 22:57:05 +00:00
|
|
|
|
require_once($phpbb_root_path . "includes/{$this->type}/{$this->type}_{$this->name}.$phpEx");
|
2003-11-27 23:26:19 +00:00
|
|
|
|
|
|
|
|
|
if ($run)
|
|
|
|
|
{
|
2004-07-08 22:57:05 +00:00
|
|
|
|
if (!isset($this->mode))
|
2003-03-19 01:44:44 +00:00
|
|
|
|
{
|
2004-07-08 22:57:05 +00:00
|
|
|
|
$this->mode = $mode;
|
2003-03-19 01:44:44 +00:00
|
|
|
|
}
|
2003-11-27 23:26:19 +00:00
|
|
|
|
|
2004-07-08 22:57:05 +00:00
|
|
|
|
eval("\$this->module = new {$this->type}_{$this->name}(\$this->id, \$this->mode, \$this->url);");
|
2003-11-27 23:26:19 +00:00
|
|
|
|
if (method_exists($this->module, 'init'))
|
|
|
|
|
{
|
|
|
|
|
$this->module->init();
|
|
|
|
|
}
|
2003-02-23 08:19:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-09-14 22:21:57 +00:00
|
|
|
|
}
|
2003-02-21 01:54:30 +00:00
|
|
|
|
|
2003-09-14 22:21:57 +00:00
|
|
|
|
// Displays the appropriate template with the given title
|
|
|
|
|
function display($page_title, $tpl_name)
|
|
|
|
|
{
|
|
|
|
|
global $template;
|
2003-02-23 08:19:54 +00:00
|
|
|
|
|
2003-09-14 22:21:57 +00:00
|
|
|
|
page_header($page_title);
|
2003-01-08 17:31:16 +00:00
|
|
|
|
|
2003-09-14 22:21:57 +00:00
|
|
|
|
$template->set_filenames(array(
|
|
|
|
|
'body' => $tpl_name)
|
|
|
|
|
);
|
2003-01-08 17:31:16 +00:00
|
|
|
|
|
2003-09-14 22:21:57 +00:00
|
|
|
|
page_footer();
|
|
|
|
|
}
|
2003-01-08 17:31:16 +00:00
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
|
|
|
|
|
// Public methods to be overwritten by modules
|
|
|
|
|
function module()
|
2003-09-14 22:21:57 +00:00
|
|
|
|
{
|
2003-11-27 23:26:19 +00:00
|
|
|
|
// Module name
|
|
|
|
|
// Module filename
|
|
|
|
|
// Module description
|
|
|
|
|
// Module version
|
|
|
|
|
// Module compatibility
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2003-02-17 06:24:42 +00:00
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
function init()
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2003-04-03 00:10:10 +00:00
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
function install()
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function uninstall()
|
|
|
|
|
{
|
|
|
|
|
return false;
|
2003-09-14 22:21:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-11-27 23:26:19 +00:00
|
|
|
|
//
|
2003-09-14 22:21:57 +00:00
|
|
|
|
// FUNCTIONS
|
|
|
|
|
// ---------
|
2003-04-09 21:47:58 +00:00
|
|
|
|
|
2004-07-08 22:57:05 +00:00
|
|
|
|
|
2003-09-14 22:21:57 +00:00
|
|
|
|
// Start session management
|
|
|
|
|
$user->start();
|
|
|
|
|
$auth->acl($user->data);
|
2004-02-28 21:16:15 +00:00
|
|
|
|
$user->setup('mcp');
|
2003-04-09 21:47:58 +00:00
|
|
|
|
|
2003-11-27 23:26:19 +00:00
|
|
|
|
$mcp = new module();
|
|
|
|
|
|
2003-09-14 22:21:57 +00:00
|
|
|
|
// Basic parameter data
|
2004-07-08 22:57:05 +00:00
|
|
|
|
$mode = request_var('mode', '');
|
|
|
|
|
$mode2 = (isset($_REQUEST['quick'])) ? request_var('mode2', '') : '';
|
|
|
|
|
$module = request_var('i', '');
|
|
|
|
|
|
|
|
|
|
if ($mode2)
|
2003-09-14 22:21:57 +00:00
|
|
|
|
{
|
2004-07-08 22:57:05 +00:00
|
|
|
|
$mode = $mode2;
|
|
|
|
|
$action = '';
|
|
|
|
|
unset($mode2);
|
2003-04-09 21:47:58 +00:00
|
|
|
|
}
|
2004-07-08 22:57:05 +00:00
|
|
|
|
|
|
|
|
|
// Only Moderators can go beyond this point
|
|
|
|
|
if ($user->data['user_id'] == ANONYMOUS || !$auth->acl_get('m_'))
|
2003-09-14 22:21:57 +00:00
|
|
|
|
{
|
2004-07-08 22:57:05 +00:00
|
|
|
|
if ($user->data['user_id'] != ANONYMOUS)
|
|
|
|
|
{
|
|
|
|
|
redirect("index.$phpEx$SID");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
login_box("{$phpbb_root_path}mcp.$phpEx$SID&mode=$mode&i=$module", '', $user->lang['LOGIN_EXPLAIN_MCP']);
|
2003-09-14 22:21:57 +00:00
|
|
|
|
}
|
2004-07-08 22:57:05 +00:00
|
|
|
|
|
|
|
|
|
$quickmod = (isset($_REQUEST['quickmod'])) ? true : false;
|
|
|
|
|
$action = request_var('action', '');
|
|
|
|
|
|
|
|
|
|
if (is_array($action))
|
2003-09-14 22:21:57 +00:00
|
|
|
|
{
|
2004-07-08 22:57:05 +00:00
|
|
|
|
list($action, ) = each($action);
|
2003-09-14 22:21:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-08 22:57:05 +00:00
|
|
|
|
if ($action == 'merge_select')
|
|
|
|
|
{
|
|
|
|
|
$mode = 'forum_view';
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-09 12:31:33 +00:00
|
|
|
|
if (in_array($mode, array('split', 'split_all', 'split_beyond', 'merge', 'merge_posts')))
|
|
|
|
|
{
|
|
|
|
|
$_REQUEST['action'] = $action = $mode;
|
|
|
|
|
$mode = 'topic_view';
|
|
|
|
|
$quickmod = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-08 22:57:05 +00:00
|
|
|
|
if (!$quickmod)
|
|
|
|
|
{
|
|
|
|
|
$post_id = request_var('p', 0);
|
|
|
|
|
$topic_id = request_var('t', 0);
|
|
|
|
|
$forum_id = request_var('f', 0);
|
|
|
|
|
|
|
|
|
|
// Instantiate module system and generate list of available modules
|
|
|
|
|
$mcp->create('mcp', "mcp.$phpEx$SID", $post_id, $topic_id, $forum_id, $module, $mode);
|
2003-11-27 23:26:19 +00:00
|
|
|
|
|
2004-07-08 22:57:05 +00:00
|
|
|
|
// Load and execute the relevant module
|
|
|
|
|
$mcp->load('mcp', 'main', $mode);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch ($mode)
|
|
|
|
|
{
|
|
|
|
|
case 'lock':
|
|
|
|
|
case 'unlock':
|
|
|
|
|
case 'lock_post':
|
|
|
|
|
case 'unlock_post':
|
|
|
|
|
$mcp->load('mcp', 'main', $mode);
|
|
|
|
|
break;
|
|
|
|
|
case 'make_sticky':
|
|
|
|
|
case 'make_announce':
|
|
|
|
|
case 'make_global':
|
|
|
|
|
case 'make_normal':
|
|
|
|
|
$mcp->load('mcp', 'main', $mode);
|
|
|
|
|
break;
|
|
|
|
|
case 'move':
|
|
|
|
|
$mcp->load('mcp', 'main', $mode);
|
|
|
|
|
break;
|
|
|
|
|
case 'delete_topic':
|
|
|
|
|
$mcp->load('mcp', 'main', $mode);
|
|
|
|
|
break;
|
|
|
|
|
case 'delete_post':
|
|
|
|
|
$mcp->load('mcp', 'main', $mode);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
trigger_error("$mode not allowed as quickmod");
|
|
|
|
|
}
|
2003-09-14 22:21:57 +00:00
|
|
|
|
|
2003-01-08 17:31:16 +00:00
|
|
|
|
?>
|