<?php
/**
* 插件处理文件
* @author moufer<moufer@163.com>
* @package PHPDP
* @copyright phpdp.com
* @version $Id plugin.php 1 2008-5-10 21:02 $
*/
define('SCRIPTNAV', 'plugin');
require_once './include/common.inc.php';

$action = $action ? $action : 'index';

if(empty($module) || !preg_match("/^[a-z0-9_\-]+$/i", $module)) {
    redirect('未加载有效的插件.', null);
} elseif(!$pluginmodule = $_plugins[$module]) {
    redirect('不存在的插件.', null);
} elseif(!$actioninfo = $pluginmodule['actionlist'][$action]) {
    redirect('未定义的操作。', null);
} elseif($actioninfo['needlogin'] && !$user->isLogin) {
    $forward = $php_reuri ? $host_url.$php_reuri : $_config['siteurl'];
    location($_config['siteurl'].'member/'.'login.php?forward='.rawurlencode($forward), false);
} elseif($actioninfo['admin'] && (!defined('IN_ADMIN') || $admin)) {
    redirect('没有权限。', null);
}

$pluginmodule['directory'] .= (substr($pluginmodule['directory'], -1) != '/') ? '/' : '';
$filename = MUDDER_PLUGINDIR.$pluginmodule['directory'].'action_'.$action.'.php';

if(!@file_exists($filename)) {
    redirect('插件文件不存在.', null);
} else {
    include $filename;
}
?>
