<?php
 /**
 *      [QKSHOP] (C) QIKEWEB Inc.
 *      This is NOT a freeware, use is subject to license terms
 */

define("IN_QKWEB",true);
require("includes/init.php");
$ACTION_NAME = "";
$opf = ROOT_PATH."includes/action/".MODEL_NAME."Action.class.php";
if(!file_exists($opf)){
	$url = $_SERVER["PATH_INFO"];
	$preg = "/^".str_replace("/","\/",$baseUrl)."/e";
	$seoUrl = preg_replace($preg,"",$url);
	$seoUrl = preg_replace("/'/","",$url);
	$wheres='';if(defined('SITE_ID')){$wheres .= " and (siteId='".SITE_ID."' or siteId=0)";}
	$sql = "select url from qk_seo_url where seoUrl='$seoUrl' $wheres";
	$url = $db->getOne($sql);
	if(!$url){
		header("HTTP/1.1 404 Not Found");
		Msg::show("未找到该模块");
	}else{
		unset($_GET);
		$_SERVER['PATH_INFO'] = $url;
		Dispatcher::dispatch();
	}
}
if(!defined('MODEL_NAME')){Msg::show("未找到模块(文件不存在)");}
$opf = ROOT_PATH."includes/action/".MODEL_NAME."Action.class.php";
require_once($opf);
$modelName = ucfirst(strtolower(MODEL_NAME)."Action");
try{
	if(!class_exists($modelName)){
		header("HTTP/1.1 404 Not Found");
		Msg::show("未找到模块(类不存在)");
	}
	$model = new $modelName;
}catch(Exception $e){
	exit($e->getMessage());
}
$actionName = strtolower(ACTION_NAME);
if(method_exists($model,$actionName)){
	$model->$actionName();
}else{
	Msg::show("该动作不存在");
	//Dispatcher::dispatch();
}



?>