<?
		$listuser -> checklogin($_SESSION["member"]->uid);
		
		switch($act){
				case "add":
						$act = "add";
						break;
				case "addsav":
						$act = "addsav";
						break;
				case "edit":
						$act = "edit";
						break;
				case "editsav":
						$act = "editsav";
						break;
				case "delet":
						$act = "delet";
						break;
				case "deletok":
						$act = "deletok";
						break;
				case "to":
						$act = "to";
						break;
				default:
						$act = "show";
						break;
		}
		
		if($act== "show"){
			
				/*自定义数据*/$pagelistsize = 10;//每页显示条数
				$totallink = $db->query_num("select ulid from ".JIEQI_DB_PREFIX."_system_userlink where userid = ".$_SESSION["member"]->uid);
				$totalpage = ceil($totallink/$pagelistsize);
				$page = isset($page)?intval($page):"1";
				$page = ($page>$totalpage)?($totalpage):($page);
				$totalpage = ($totalpage==0)?1:intval($totalpage);
				$page = ($page<1)?(1):($page);
				$sqlstart = ($page-1)*$pagelistsize;
											
				$smartyObj->assign('userlink',$db->query_array("select ulid,ultitle,allvisit from ".JIEQI_DB_PREFIX."_system_userlink where userid = ".$_SESSION["member"]->uid." order by ulid desc limit ".$sqlstart.",".$pagelistsize));							
    		
    		$smartydate = array("pagetitle" => "我的链接",
													"totallink" => $totallink,
													"totalpage" => $totalpage,
													"page" => $page,
													"pagelistsize" => $pagelistsize,
													"data" => array(),
														);
														
				$tplpath = "user/link.tpl";
				
		}elseif($act == "add"){
					
				$url = array("act" => "addsav",
										"ulid" => "",
										"page" => "",
				);
				$smartydate = array("pagetitle" => "添加链接",
														"posturl" => URL_user_link($url),
														);
												
				$tplpath = "user/link_post.tpl";

		}elseif($act == "addsav"){
				
				$iserror = 0;
				
				if($linktitle == "" and $iserror == 0){
						$iserror = 1;
						$showwords = "添加失败！<br/>";
						$showwords .= "连接标题不能为空！<br/>";
						$url = array("act" => "add",
												"ulid" => "",
												"page" => "",
						);
						$tourl = URL_user_link($url);
				}
				if($linkurl == "" and $iserror == 0){
						$iserror = 1;
						$showwords = "添加失败！<br/>";
						$showwords .= "连接地址不能为空！<br/>";
						$url = array("act" => "add",
												"ulid" => "",
												"page" => "",
						);
						$tourl = URL_user_link($url);
				}else{
						$linkurl = str_replace("http://","",$linkurl);
				}
				if($iserror == 0){
						$db->query("INSERT INTO ".JIEQI_DB_PREFIX."_system_userlink (ultitle,ulurl,ulinfo,userid,username,score,weight,toptime,addtime,allvisit) VALUE('".$linktitle."','".$linkurl."','".$linkintro."',".$_SESSION["member"]->uid.",'".$_SESSION["member"]->name."',0,0,0,".time().",0)");
						$showwords = "添加成功！<br/>";
						$url = array("act" => "",
												"ulid" => "",
												"page" => "",
						);
						$tourl = URL_user_link($url);
				}
				
				$smartydate = array("pagetitle" => "添加链接",
														"pagecontent" => $showwords,
														"tourl" => $tourl,
														"redirecturl" => $tourl,
														);
														
				$tplpath = "public.tpl";
				
		}elseif($act == "edit"){
				
				$iserror = 0;
				
				$link = $db->query_object("select userid,ultitle,ulurl,ulinfo from ".JIEQI_DB_PREFIX."_system_userlink where ulid=".$ulid." and userid=".$_SESSION["member"]->uid);
				
				if(!$link){
						$iserror = 1;
						$showwords = "修改失败！<br/>";
						$showwords .= "不存在该条链接信息！<br/>";
						$url = array("act" => "",
												"ulid" => "",
												"page" => "",
						);
						$tourl = URL_user_link($url);
				}
				
				if($iserror == 0){
					
						$url = array("act" => "editsav",
												"ulid" => $ulid,
												"page" => "",
						);
						
						$smartydate = array("pagetitle" => "修改链接",
																"linktitle" => $link->ultitle,
																"linkurl" => $link->ulurl,
																"linkintro" => $link->ulinfo,
																"posturl" => URL_user_link($url),
																);
														
						$tplpath = "user/link_post.tpl";
						
				}else{
					
						$smartydate = array("pagetitle" => "添加链接",
														"pagecontent" => $showwords,
														"tourl" => $tourl,
														"redirecturl" => $tourl,
														);
														
						$tplpath = "public.tpl";
					
				}
				
				
		}elseif($act == "editsav"){
			
				$iserror = 0;
				
				$link = $db->query_object("select userid,ultitle,ulurl,ulinfo from ".JIEQI_DB_PREFIX."_system_userlink where ulid=".$ulid." and userid=".$_SESSION["member"]->uid);
				
				if(!$link){
						$iserror = 1;
						$showwords = "修改失败！<br/>";
						$showwords .= "不存在该条链接信息！<br/>";
						$url = array("act" => "",
												"ulid" => "",
												"page" => "",
						);
						$tourl = URL_user_link($url);
				}
				
				if($linktitle == "" and $iserror == 0){
						$iserror = 1;
						$showwords = "修改失败！<br/>";
						$showwords .= "连接标题不能为空！<br/>";
						$url = array("act" => "edit",
												"ulid" => $ulid,
												"page" => "",
						);
						$tourl = URL_user_link($url);
				}
				
				if($linkurl == "" and $iserror == 0){
						$iserror = 1;
						$showwords = "修改失败！<br/>";
						$showwords .= "连接地址不能为空！<br/>";
						$url = array("act" => "edit",
												"ulid" => $ulid,
												"page" => "",
						);
						$tourl = URL_user_link($url);
				}else{
						$linkurl = str_replace("http://","",$linkurl);
				}
				
				if($iserror == 0){
						$db->query("UPDATE ".JIEQI_DB_PREFIX."_system_userlink SET ultitle='".$linktitle."',ulurl='".$linkurl."',ulinfo='".$linkintro."' WHERE ulid=".$ulid." and userid=".$_SESSION["member"]->uid);
						$showwords = "修改成功！<br/>";
						$url = array("act" => "edit",
												"ulid" => $ulid,
												"page" => "",
						);
						$tourl = URL_user_link($url);
				}
				
				$smartydate = array("pagetitle" => "修改链接",
														"pagecontent" => $showwords,
														"tourl" => $tourl,
														"redirecturl" => $tourl,
														);
														
				$tplpath = "public.tpl";
				
		}elseif($act == "delet"){
				
				$iserror = 0;
				
				$link = $db->query_object("select userid,ultitle,ulurl,ulinfo from ".JIEQI_DB_PREFIX."_system_userlink where ulid=".$ulid." and userid=".$_SESSION["member"]->uid);
				
				if(!$link){
					
						$iserror = 1;
						$showwords = "删除失败！<br/>";
						$showwords .= "不存在该条链接信息！<br/>";
						$url = array("act" => "",
												"ulid" => "",
												"page" => "",
						);
						$tourl = URL_user_link($url);
						
				}else{
					
						$url = array("act" => "deletok",
												"ulid" => $ulid,
												"page" => "",
						);
						
						$urll = array("act" => "",
												"ulid" => "",
												"page" => "",
						);
						
						$tourl = "";
						
						$showwords = "删除确认<br/>";
						$showwords .= "您确定要删除该连接吗<br/>";
						$showwords .= "<a href=\"".URL_user_link($url)."\">确定</a> - <a href=\"".URL_user_link($urll)."\">取消</a><br/>";
						
				}
				
				$smartydate = array("pagetitle" => "删除链接",
												"pagecontent" => $showwords,
												"tourl" => $tourl,
												"redirecturl" => $tourl,
												);
												
				$tplpath = "public.tpl";
				
		}elseif($act == "deletok"){
				
				$iserror = 0;
				
				$link = $db->query_object("select userid,ultitle,ulurl,ulinfo from ".JIEQI_DB_PREFIX."_system_userlink where ulid=".$ulid." and userid=".$_SESSION["member"]->uid);
				
				if(!$link){
					
						$iserror = 1;
						$showwords = "删除失败！<br/>";
						$showwords .= "不存在该条链接信息！<br/>";
						$url = array("act" => "",
												"ulid" => "",
												"page" => "",
						);
						$tourl = URL_user_link($url);
						
				}else{
						
						$db->query("DELETE from ".JIEQI_DB_PREFIX."_system_userlink where ulid=".$ulid." and userid=".$_SESSION["member"]->uid);
						$url = array("act" => "",
												"ulid" => "",
												"page" => "",
						);
						$tourl = URL_user_link($url);
						$showwords = "删除成功<br/>";
						
				}
				
				$smartydate = array("pagetitle" => "删除链接",
												"pagecontent" => $showwords,
												"tourl" => $tourl,
												"redirecturl" => $tourl,
												);
												
				$tplpath = "public.tpl";
				
		}elseif($act == "to"){
				
				$iserror = 0;
				
				$link = $db->query_object("select userid,ultitle,ulurl,ulinfo from ".JIEQI_DB_PREFIX."_system_userlink where ulid=".$ulid." and userid=".$_SESSION["member"]->uid);
				
				if(!$link){
					
						$iserror = 1;
						$showwords = "跳转成功！<br/>";
						$showwords .= "不存在该条链接信息！<br/>";
						$url = array("act" => "",
												"ulid" => "",
												"page" => "",
						);
						$tourl = URL_user_link($url);
						
				}else{

						$tourl = "http://".$link->ulurl;
						$showwords = "请稍候，正在进入！<br/>";
						
				}
				
				$smartydate = array("pagetitle" => "删除链接",
												"pagecontent" => $showwords,
												"tourl" => $tourl,
												"redirecturl" => $tourl,
												);
												
				$tplpath = "public.tpl";
				
		}
?>