<?
		$listuser -> checklogin($_SESSION["member"]->uid);
		
		switch($type){
				case "send":
						$type = "send";
						break;
				case "sendok":
						$type = "sendok";
						break;
				case "sendbox":
						$type = "sendbox";
						break;
				case "recvbox":
						$type = "recvbox";
						break;
				case "read":
						$type = "read";
						break;
				case "check":
						$type = "check";
						break;
				case "delet":
						$type = "delet";
						break;
				case "deletok":
						$type = "deletok";
						break;
				default:
						$type = "show";
						break;
		}
		
		if($type == "show"){
			
				$smartydate = array("pagetitle" => "首页",
											"pagecontent" => "",
											);
									
				$tplpath = "user/message.tpl";
				
		}elseif($type == "send"){
			
				$smartydate = array("pagetitle" => "首页",
											"pagecontent" => "",
											);
									
				$tplpath = "user/message_send.tpl";
				
		}elseif($type == "sendok"){
			
				$iserror = 0;
				$uid = isset($uid)?intval($uid):0;
				
				$isuser = $db->query_num("select uid from ".JIEQI_DB_PREFIX."_system_users where uid=".$uid);
				if(!$isuser){
						$iserror = 1;
						$pagecontent = "<b>发送失败！</b><br/>";
						$pagecontent .= "不存在的收件人！<br/>";
						$url = array("act" => "",
												"type" => "send",
												"page" => "",
												);
						$tourl = URL_user_message($url);
				}
				if($iserror==0){
						$db->query("INSERT INTO ".JIEQI_DB_PREFIX."_system_message (siteid,postdate,fromid,fromname,toid,toname,title,content,messagetype,isread,fromdel,todel,enablebbcode,enablehtml,enablesmilies,attachsig,attachment) VALUE(0,'".time()."',".$_SESSION["member"]->uid.",'".$_SESSION["member"]->name."',".$uid.",'".$listuser->getuserdate("name",$uid)."','".$title."','".$content."',0,0,0,0,1,0,1,0,0)");
						$pagecontent = "发送成功！<br/>";
						$url = array("act" => "",
												"type" => "sendbox",
												"page" => "",
												);
						$tourl = URL_user_message($url);	
				}
				
				$smartydate = array("pagetitle" => "信息发送报告",
														"pagecontent" => $pagecontent,
														"tourl" => $tourl,
														"redirecturl" => $tourl,
														);
														
				$tplpath = "public.tpl";
				
		}elseif($type == "sendbox"){
				
				/*自定义数据*/$pagelistsize = 10;//每页显示条数
				$totalmessage = $db->query_num("select messageid from ".JIEQI_DB_PREFIX."_system_message where fromid = ".$_SESSION["member"]->uid);
				$totalpage = ceil($totalmessage/$pagelistsize);
				$page = isset($page)?intval($page):"1";
				$totalpage = ($totalpage==0)?1:intval($totalpage);
				$page = ($page>$totalpage)?($totalpage):($page);
				$page = ($page<1)?(1):($page);
				$sqlstart = ($page-1)*$pagelistsize;
											
				$smartyObj->assign('getmessage',$db->query_array("select * from ".JIEQI_DB_PREFIX."_system_message where fromid = ".$_SESSION["member"]->uid." order by messageid desc limit ".$sqlstart.",".$pagelistsize));
				
				$smartydate = array("pagetitle" => "发件箱",
													"totalmessage" => $totalmessage,
													"pagelistsize" => $pagelistsize,
													"totalpage" => $totalpage,
													"page" => $page,
													"data" => array("act"=>"",
																					"type" => "sendbox",
																					),
														);
				$tplpath = "user/message_sendbox.tpl";
				
		}elseif($type == "recvbox"){
			
				/*自定义数据*/$pagelistsize = 10;//每页显示条数
				
				if($act == "unread"){
						$totalmessage = $db->query_num("select messageid from ".JIEQI_DB_PREFIX."_system_message where isread=0 and toid = ".$_SESSION["member"]->uid);
				}else{
						$totalmessage = $db->query_num("select messageid from ".JIEQI_DB_PREFIX."_system_message where toid = ".$_SESSION["member"]->uid);
				}	
				
				$totalpage = ceil($totalmessage/$pagelistsize);
				$page = isset($page)?intval($page):"1";
				$totalpage = ($totalpage==0)?1:intval($totalpage);
				$page = ($page>$totalpage)?($totalpage):($page);
				$page = ($page<1)?(1):($page);
				$sqlstart = ($page-1)*$pagelistsize;
											
				if($act == "unread"){
						$smartyObj->assign('getmessage',$db->query_array("select messageid,postdate,fromid,fromname,title,isread from ".JIEQI_DB_PREFIX."_system_message where isread=0 and toid = ".$_SESSION["member"]->uid." order by messageid desc limit ".$sqlstart.",".$pagelistsize));
				}else{
						$smartyObj->assign('getmessage',$db->query_array("select messageid,postdate,fromid,fromname,title,isread from ".JIEQI_DB_PREFIX."_system_message where toid = ".$_SESSION["member"]->uid." order by messageid desc limit ".$sqlstart.",".$pagelistsize));
				}
				
				$smartydate = array("pagetitle" => "发件箱",
													"totalmessage" => $totalmessage,
													"pagelistsize" => $pagelistsize,
													"totalpage" => $totalpage,
													"page" => $page,
													"data" => array("act"=>"",
																					"type" => "recvbox",
																					),
														);
				$tplpath = "user/message_recvbox.tpl";
		}elseif($type == "read"){
					
					$iserror = 0;
					$act = isset($act)?intval($act):0;
    			
					$message = $db->query_object("select * from ".JIEQI_DB_PREFIX."_system_message where messageid=".$act." and toid = ".$_SESSION["member"]->uid);
				
					if(!$message){
							$iserror = 1;
							$pagecontent = "<b>查看消息失败！</b><br/>";
							$pagecontent .= "不存在该条信息！<br/>";
							$url = array("act" => "",
													"type" => "recvbox",
													"page" => "",
													);
							$tourl = URL_user_message($url);
					}
					
					if($iserror == 0){
							$smartyObj->assign('showmessage',$message);
							$db->query("UPDATE ".JIEQI_DB_PREFIX."_system_message SET isread=1 where messageid=".$act);
							
							$smartydate = array("pagetitle" => "查看信息",);
							$tplpath = "user/message_read.tpl";
					}else{
							$smartydate = array("pagetitle" => "Warning",
																	"pagecontent" => $pagecontent,
																	"tourl" => $tourl,
																	"redirecturl" => $tourl,
																	);
														
							$tplpath = "public.tpl";
					}
		}elseif($type == "check"){
					
					$iserror = 0;
					$act = isset($act)?intval($act):0;
					
					$message = $db->query_object("select * from ".JIEQI_DB_PREFIX."_system_message where messageid=".$act." and fromid = ".$_SESSION["member"]->uid);
					
					if(!$message){
							$iserror = 1;
							$pagecontent = "<b>查看消息失败！</b><br/>";
							$pagecontent .= "不存在该条信息！<br/>";
							$url = array("act" => "",
													"type" => "sendbox",
													"page" => "",
													);
							$tourl = URL_user_message($url);
					}
					
					if($iserror == 0){
							$smartyObj->assign('showmessage',$message);
							
							$smartydate = array("pagetitle" => "查看信息",);
							$tplpath = "user/message_check.tpl";
					}else{
							$smartydate = array("pagetitle" => "Warning",
																	"pagecontent" => $pagecontent,
																	"tourl" => $tourl,
																	"redirecturl" => $tourl,
																	);
														
							$tplpath = "public.tpl";
					}
		}elseif($type == "delet"){
			
				$iserror = 0;
				
				$message = $db->query_object("select * from ".JIEQI_DB_PREFIX."_system_message where messageid=".$act." and toid = ".$_SESSION["member"]->uid);
				
				if(!$message){
						$iserror = 1;
						$pagecontent = "<b>查看消息失败！</b><br/>";
						$pagecontent .= "不存在该条信息！<br/>";
						$url = array("act" => "",
												"type" => "recvbox",
												"page" => "",
												);
						$tourl = URL_user_message($url);
				}else{
					
						$url = array("type" => "deletok",
												"act" => $act,
												"page" => "",
						);
						
						$urll = array("type" => "recvbox",
												"act" => "",
												"page" => "",
						);
						
						$tourl = "";
						
						$showwords = "删除确认<br/>";
						$showwords .= "您确定要删除该信息吗<br/>";
						$showwords .= "<a href=\"".URL_user_message($url)."\">确定</a> - <a href=\"".URL_user_message($urll)."\">取消</a><br/>";
						
				}
				
				$smartydate = array("pagetitle" => "删除信息",
												"pagecontent" => $showwords,
												"tourl" => $tourl,
												"redirecturl" => $tourl,
												);
												
				$tplpath = "public.tpl";
				
		}elseif($type == "deletok"){
				
				$iserror = 0;
				
				$message = $db->query_object("select * from ".JIEQI_DB_PREFIX."_system_message where messageid=".$act." and toid = ".$_SESSION["member"]->uid);
				
				if(!$message){
						$iserror = 1;
						$pagecontent = "<b>查看消息失败！</b><br/>";
						$pagecontent .= "不存在该条信息！<br/>";
						$url = array("type" => "recvbox",
												"act" => "",
												"page" => "",
												);
						$tourl = URL_user_message($url);
				}else{
						
						$db->query("DELETE from ".JIEQI_DB_PREFIX."_system_message where messageid=".$act." and toid = ".$_SESSION["member"]->uid);
						$url = array("type" => "recvbox",
												"act" => "",
												"page" => "",
						);
						$tourl = URL_user_message($url);
						$showwords = "删除成功<br/>";
						
				}
				
				$smartydate = array("pagetitle" => "删除链接",
												"pagecontent" => $showwords,
												"tourl" => $tourl,
												"redirecturl" => $tourl,
												);
												
				$tplpath = "public.tpl";
				
		}
?>