interface.php 4.34 KB
<?php
// 启动目录
define('BOOT_DIR_PATH', dirname(__FILE__).'/../../../../..');
define('ROOT_DIR_PATH', dirname(__FILE__).'/../../../BASE');
define('POST_PARAM_NAME', 'CALL');
define('POST_ROUTER', 'r');

require_once BOOT_DIR_PATH.'/util/JSON/JSON.class.php';
require_once BOOT_DIR_PATH.'/util/unicode/Unicode.class.php';
require_once BOOT_DIR_PATH.'/util/db/DbMysqli.class.php';
require_once ROOT_DIR_PATH.'/config/YSMCMain.const.php';
require_once ROOT_DIR_PATH.'/web/YSMWLoginAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWValidateRandomKeyAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWMessageAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWContactAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWRegisterAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWSystemSettingAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWHeadListAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWLogoutAction.class.php';
require_once ROOT_DIR_PATH.'/web/YSMWAppAction.class.php';

$router = explode('/',$_POST[POST_ROUTER]);
echo '输入格式为:';
print_r($router);
print_r(getCallParam());

echo '返回结果为:';

// 返回的结果
$result = '';


switch ($router[0])
{
    case 'login':
        login($router[1]);
        break;   
    case 'validate':
        validate($router[1]); 
        break;
    case 'message':
        message($router[1]);
        break;    
    case 'app':
        app($router[1]);
        break;        
    case 'register':
        register($router[1]);
        break;
    case 'contact':
        contact($router[1]);
        break;
    case 'systemSetting':
        systemSetting($router[1]);
        break;    
    case 'head':
        headList($router[1]);
        break;
    case 'logout':
        logout($router[1]);
        break;    
}

function login($r)
{
    $param = getCallParam();
    if(isset($param['request']))
    {
        $param = $param['request'];
    }
    else
    {
        $param = array();  
    }
    $loginAction = new YSMWLoginAction();
    echo $loginAction->login($param);
}

function validate($r)
{
    $param = getCallParam();
    $validateAction = new YSMWValidateRandomKeyAction();
    echo $validateAction->validateRandomKey($param);
}

function message($r)
{
    $param = getCallParam();
    $messageAction = new YSMWMessageAction();
    echo $messageAction->router($r, $param);
}

function app($r)
{
    $param = getCallParam();
    $appAction = new YSMWAppAction();
    echo $appAction->router($r, $param);
}

function register($r)
{
    $param = getCallParam();
    if(isset($param['request']))
    {
        $param = $param['request'];
    }
    else
    {
        $param = array();  
    }
    $registerAction = new YSMWRegisterAction();
    switch ($r)
    {
        case 'checkIDAndName':
            echo $registerAction->checkIDAndName($param);
            break;
        case 'checkPassword':
            echo $registerAction->checkPassword($param);
            break;
        case 'register':
            echo $registerAction->register($param);
            break;
    }
}

function contact($r)
{
    $param = getCallParam();
    $contactAction = new YSMWContactAction();
    echo $contactAction->router($r, $param);
}

function systemSetting($r)
{
    $param = getCallParam();
    $systemSettingAction = new YSMWSystemSettingAction();
    echo $systemSettingAction->router($r, $param);
}

function headList($r)
{
    $param = getCallParam();
    $headListAction = new YSMWHeadListAction();
    echo $headListAction->router($r, $param);
}

function logout($r)
{
    $param = getCallParam();
    $logout = new YSMWLogoutAction();
    echo $logout->router($r, $param);
}

/******************************************************/
function getCallParam()
{
    $param = array();
    
    if (isset($_POST[POST_PARAM_NAME]))
    {
        $paramValue = urldecode($_POST[POST_PARAM_NAME]);
        
          //去除格式
        $paramValue = str_replace('\n', '', $paramValue);
        $paramValue = str_replace('\r', '', $paramValue);
        $paramValue = str_replace('\t', '', $paramValue);
        $paramValue = str_replace('', '', $paramValue); 
        //echo Unicode::urlDecode($paramValue);
        //echo Json::decode(stripslashes(Unicode::urlDecode($paramValue)), true);
        $param = Json::decode(stripslashes(Unicode::urlDecode($paramValue)), true);
        echo "notice:";
    }
    return $param;
}
?>