<?php
 /**
 *      [XCECP] (C) COLNET Inc.
 *      This is NOT a freeware, use is subject to license terms
 */
if(!defined("IN_QKWEB")){exit("Access Denied");}
class Msg{
	public static function show($msg,$exit=true){
		$pageInfo['title']='提示信息';
		if(is_array($msg)){
			$showmsg = $msg['msg'];
			$url = $msg['url'];
			$timer = $msg['timer'];
			
			if($msg['httpStatusCode']){
				if($msg['httpStatusCode']==404){
					header("HTTP/1.1 404 Not Found");
				}else if($msg['httpStatusCode']==403){
					header("HTTP/1.1 403 Forbidden");
				}
			}
			if($msg['title']){ $pageInfo['title']=$msg['title']; }
		}else{
			$showmsg = $msg;
		}
		if(!isset($timer) || $timer=='' || !is_numeric($timer)){$timer=1000;}
		assign("msg",$showmsg);
		if(isset($url))assign("url",$url);
		if(isset($timer))assign("timer",$timer);
		if(getgpc("inajax")==1){
			$ret = array('success'=>false,'message'=>$msg);
			echo json_encode($ret);
			exit;
		}
		if(isset($GLOBALS['smarty'])){
			global $smarty;
			$dir = $smarty->getTemplateDir();//print_r($dir);
			if(file_exists($dir[0]."msg.html")){
				if(ob_get_length()){
					$tmp = ob_get_clean();
				}
				assign("pageInfo",$pageInfo);
				display("msg");
				ob_end_flush();
			}else{
				echo $showmsg;
			}
		}else{
			echo $showmsg;
		}
		if($exit){
			exit();
		}
	}
}
?>