<?php 
require_once('session.php');
require_once('../fun/funsql.php');
require_once('../fun/funlogic.php');
require_once('../fun/funclass.php');
if (isset($_GET["rel"])){$rel=$_GET["rel"];}else{$rel="";}
$times=date("Y-m-d H:i:s");
$classstr=new classstr($dbz);
if ($rel==''){
  
}
//处理===========================================开始

if($rel=='plug_add'){
  $names=funstr($_POST["names"]);
  $users=funstr($_POST["users"]);
  $files=funstr($_POST["files"]);
  $sql=query("insert into ".$dbz."plug (names,users,files,times)values('$names','$users','$files','$times')"); 
  if ($sql){echo tanshow("","main.php?rel=plug");}else{echo mysql_error();}
}

if($rel=='plug_info'){
  $id=funstr($_POST["id"]);
  $names=funstr($_POST["names"]);
  $users=funstr($_POST["users"]);
  $files=funstr($_POST["files"]);
  $sql=query("update ".$dbz."plug set names='$names',users='$users',files='$files',times='$times' where id='$id'"); 
  if ($sql){echo tanshow("","main.php?rel=plug");}else{echo mysql_error();}
}

if($rel=='plug_del'){
  $id=funstr($_GET["id"]);
  $sql=query("delete from ".$dbz."plug where id='$id'");
  if ($sql){echo tanshow("","main.php?rel=plug");}else{echo mysql_error();}
  
}

if($rel=='page_del'){
  $id=funstr($_GET["id"]);
  $file=funstr($_GET["file"]);
  $sql=query("delete from ".$dbz."page where id='$id'");
  unlink("../".$file);
  if ($sql){echo tanshow("","main.php?rel=page");}else{echo mysql_error();}
  
}

if($rel=='page_ends'){
  $id=funstr($_GET["id"]);
  $num=funstr($_GET["num"]);
  $sql=query("update ".$dbz."page set ends=$num where id=$id");
  if ($sql){echo tanshow("","main.php?rel=page");}else{echo mysql_error();}
}

if($rel=='page_styles'){
  $id=funstr($_GET["id"]);
  $num=funstr($_GET["num"]);
  $sql=query("update ".$dbz."page set styles=$num where id=$id");
  if ($sql){echo tanshow("","main.php?rel=page");}else{echo mysql_error();}
}

if($rel=='page_tags'){
  $id=funstr($_GET["id"]);
  $num=funstr($_GET["num"]);
  $sql=query("update ".$dbz."page set tags=$num where id=$id");
  if ($sql){echo tanshow("","main.php?rel=page");}else{echo mysql_error();}
}

if($rel=='page_add'){
  $names=funstr($_POST["names"]);
  $files=funstr($_POST["files"]);
  $keywords=funstr($_POST["keywords"]);
  $dis=utf_substr(funstr($_POST["dis"]),199);
  $styles=@funstr($_POST["styles"]);
  $ends=@funstr($_POST["ends"]);
  $tags=@funstr($_POST["tags"]);
  $mg=funstr($_POST["mg"]);
  
  if($styles==''){$styles=0;}
  if($ends==''){$ends=0;}
  if($tags==''){$tags=0;}
  
  $sql=query("insert into ".$dbz."page(names,files,keywords,dis,styles,ends,tags,mg,times)values('$names','$files','$keywords','$dis','$styles','$ends','$tags','$mg','$times')");
  if ($sql){echo tanshow("","html.php?rel=page_html");}else{echo mysql_error();}
}

if($rel=='page_info'){
  $id=funstr($_POST["id"]);
  $names=funstr($_POST["names"]);
  $files=funstr($_POST["files"]);
  $keywords=funstr($_POST["keywords"]);
  $dis=utf_substr(funstr($_POST["dis"]),199);
  $styles=@funstr($_POST["styles"]);
  $ends=@funstr($_POST["ends"]);
  $tags=@funstr($_POST["tags"]);
  $mg=funstr($_POST["mg"]);
  
  if($styles==''){$styles=0;}
  if($ends==''){$ends=0;}
  if($tags==''){$tags=0;}
  
  $sql=query("update ".$dbz."page set names='$names',files='$files',keywords='$keywords',dis='$dis',styles='$styles',ends='$ends',tags='$tags',mg='$mg',times='$times' where id=$id");
  if ($sql){echo tanshow("","html.php?rel=page_html&id=$id");}else{echo mysql_error();}
}

if($rel=='gao'){
  $str=$_POST["FCKeditor1"];
  //$str=str_replace("\\","",$str);
  createfile("../cache/sitegao.txt",$str);
  
  echo tanshow("","main.php?rel=gao");
}
if($rel=='config'){
  $title=funstr($_POST["title"]);
  $site=funstr($_POST["site"]);
  $keywords=funstr($_POST["keywords"]);
  $dis=funstr($_POST["dis"]);
  $styles=funstr($_POST["styles"]);
  $html=@funstr($_POST["html"]);
  $siteclose=@funstr($_POST["siteclose"]);
  $siteclosemg=funstr($_POST["siteclosemg"]);
  $ends=funstr($_POST["ends"]);
  $tongji=funstr($_POST["tongji"]);
  $sokey=funstr($_POST["sokey"]);
  $js=funstr($_POST["js"]);
  $rss=funstr($_POST["rss"]);
  $so=funstr($_POST["so"]);
  
  if($html==''){$html=0;}
  if($siteclose==''){$siteclose=0;}
  
  $str=$title.",,".$site.",,".$keywords.",,".$dis.",,".$styles.",,".$html.",,".$siteclose.",,".$siteclosemg.",,".$ends.",,".$tongji.",,".$sokey.",,".$js.",,".$rss.",,".$so;
  //$str=str_replace("/r","",$str);
  $str=str_replace("\\","",$str);
  
  createfile("../cache/config.txt",$str);
  echo tanshow("","main.php?rel=config");
}
//处理===========================================结束

//处理分类===========================================开始
if ($rel=='class_add'){
  $names=funstr($_POST["names"]);
  $keywords=funstr($_POST["keywords"]);
  $dis=funstr($_POST["dis"]);
  $styles=funstr($_POST["styles"]);
  $cid=funstr($_POST["cid"]);
  $lists=@funstr($_POST["lists"]);
  $toplists=@funstr($_POST["toplists"]);
  $indexvs=@funstr($_POST["indexvs"]);
  $orders=funstr($_POST["orders"]);
  
  if (strlen($names)<1){echo tanshow("分类名称不能为空!","");exit();}
  if (strlen($orders)<1){echo tanshow("分类排序不能为空,可以设置为0!","");exit();}
  
  $cids=split(",",$cid);
  if($lists==''){$lists=0;}
  if($toplists==''){$toplists=0;}
  if($indexvs==''){$indexvs=0;}

  $sql=query("insert into ".$dbz."class (names,keywords,dis,styles,cid,trees,lists,toplists,indexvs,orders,times,types)values('$names','$keywords','$dis','$styles','".$cids[0]."','".$cids[1]."','$lists','$toplists','$indexvs','$orders','$times',1)");
  if ($sql){
  $sql2=query("select * from ".$dbz."class order by id desc limit 0,1");
  if ($row=fetch($sql2)){query("update ".$dbz."class set trees='".$row["trees"].$row["id"].":' where id=".$row["id"]) or die(mysql_error());}
  echo tanshow("添加成功直接到添加页","class.php?rel=class_add");}else{echo mysql_error();}
}

if($rel=='class_all'){
  $i=funstr($_POST["i"]);
  $n=1;
  while($n<$i){
    $id_1="checkbox".$n;
    $id=@funstr($_POST[$id_1]);
	$orders_1="orders".$n;
	$orders=funstr($_POST[$orders_1]);
	if ($id<>''){
	  $sql=query("update ".$dbz."class set orders='$orders' where id=".$id)or die(mysql_error());
	}
	$n=$n+1;
  }
  echo tanshow("","class.php?rel=class");
}

if($rel=='class_info'){
  $id=funstr($_POST["id"]);
  $names=funstr($_POST["names"]);
  $keywords=funstr($_POST["keywords"]);
  $dis=funstr($_POST["dis"]);
  $styles=funstr($_POST["styles"]);

  $lists=@funstr($_POST["lists"]);
  $toplists=@funstr($_POST["toplists"]);
  $indexvs=@funstr($_POST["indexvs"]);
  $orders=funstr($_POST["orders"]);
  
  if (strlen($names)<1){echo tanshow("分类名称不能为空!","");exit();}
  if (strlen($orders)<1){echo tanshow("分类排序不能为空,可以设置为0!","");exit();}
  if($lists==''){$lists=0;}
  if($toplists==''){$toplists=0;}
  if($indexvs==''){$indexvs=0;}
  
  $sql=query("update ".$dbz."class set names='$names',keywords='$keywords',dis='$dis',styles='$styles',lists='$lists',toplists='toplists',indexvs='$indexvs',orders='$orders' where id='$id'");
  if ($sql){echo tanshow("修改成功直接跳转到分类管理页","class.php?rel=class");}else{echo mysql_error();}
  
}

if($rel=='class_move'){
  $topclass=funstr($_POST["topclass"]);
  $endclass=funstr($_POST["endclass"]);
  $toparr=split(",",$topclass);
  $endarr=split(",",$endclass);
  if($toparr[0]==$endarr[0]){
    echo tanshow("移动分类与目标分类不能相同","class.php?rel=class_move");
  }
  else{
    $classstr->classarr();
    if($classstr->classlistbool($toparr[0])){
	  echo tanshow("移动分类不是最后一级分类,不能移动","class.php?rel=class_move");
	}
	else{
	  //分类下文章的trees和cid全部替换成目标分类
	  $sql=query("select* from ".$dbz."page where cid='$toparr[0]'");
	  while($row=fetch($sql)){
	    $update=query("update ".$dbz."page set trees='$endarr[1]',cid='$endarr[0]' where id=".$row["id"]);
	  }
	  $sql=query("delete from ".$dbz."class where id='$toparr[0]'");
	  if ($sql){echo tanshow("移动成功,返回分类移动页","class.php?rel=class_move");}else{echo mysql_error();}
	}
  }
}

if ($rel=='lists'){
  $id=funstr($_GET["id"]);
  $num=funstr($_GET["num"]);
  $sql=query("update ".$dbz."class set lists='$num' where id='$id'");
  if($sql){echo tanshow("","class.php?rel=class");}else{echo mysql_error();}
}
if ($rel=='toplists'){
  $id=funstr($_GET["id"]);
  $num=funstr($_GET["num"]);
  $sql=query("update ".$dbz."class set toplists='$num' where id='$id'");
  if($sql){echo tanshow("","class.php?rel=class");}else{echo mysql_error();}
}
if ($rel=='indexvs'){
  $id=funstr($_GET["id"]);
  $num=funstr($_GET["num"]);
  $sql=query("update ".$dbz."class set indexvs='$num' where id='$id'");
  if($sql){echo tanshow("","class.php?rel=class");}else{echo mysql_error();}
}
//处理分类===========================================结束
//处理文章===========================================开始
if($rel=='comments_replys'){
  $id=funstr($_POST["id"]);
  $replys=funstr($_POST["replys"]);
  $sql=query("update ".$dbz."comments set replys='".$replys."' where id=$id");
  if($sql){echo tanshow("","news.php?rel=comments");}else{echo mysql_error();}
}
if($rel=='comments_all'){
  $i=funstr($_POST["i"]);
  $n=1;
  while($n<=$i){
    $ns='checkbox'.$n;
	$id=@funstr($_POST[$ns]);
	if($id<>''){
	  $sql=query("delete from ".$dbz."comments where id=$id");
	}
    $n=$n+1;
  }
  echo tanshow("删除成功","news.php?rel=comments");
}

if ($rel=='comments_del'){
  $id=funstr($_GET["id"]);
  $page=funstr($_GET["page"]);
  $sql=query("delete from ".$dbz."comments where id='$id'");
  if ($sql){echo tanshow("","news.php?rel=comments&page=$page");}else{echo mysql_error();}
}

if($rel=='comments_audits'){
  $id=funstr($_GET["id"]);
  $num=funstr($_GET["num"]);
  $page=funstr($_GET["page"]);
  $sql=query("update ".$dbz."comments set audits=$num where id=$id");
  if ($sql){echo tanshow("","news.php?rel=comments&page=$page");}else{echo mysql_error();}
}

if ($rel=='news_config'){
  $index=funstr($_POST["index"]);
  $class=funstr($_POST["class"]);
  $list=funstr($_POST["list"]);
  $update=funstr($_POST["update"]);
  $hot=funstr($_POST["hot"]);
  $vip=funstr($_POST["vip"]);
  $size=funstr($_POST["size"]);
  $ping=@funstr($_POST["ping"]);
  $style=@funstr($_POST["style"]);
  $time=@funstr($_POST["time"]);
  if($ping==''){$ping=0;}
  if($style==''){$style=0;}
  if($time==''){$time=0;}
  $str=$index.",,".$class.",,".$list.",,".$update.",,".$hot.",,".$vip.",,".$size.",,".$ping.",,".$style.",,".$time;
  
  createfile("../cache/newsconfig.txt",$str);
  echo tanshow("","news.php?rel=news_config");
  
}
if ($rel=='news_source_add'){
  $mg=funstr($_POST["mg"]);
  $types=funstr($_POST["types"]);
  if (strlen($mg)<1){echo tanshow("内容不能为空!","");exit();}
  $sql=query("insert into ".$dbz."news_source(mg,types)values('$mg','$types')");
  if ($sql){echo tanshow("","news.php?rel=news_add");}else{echo mysql_error();}
}
if ($rel=='news_source_del'){
  $id=funstr($_GET["id"]);
  $sql=query("delete from ".$dbz."news_source where id='$id'");
  if ($sql){echo tanshow("","news.php?rel=news_add");}else{echo mysql_error();}
}
if ($rel=='news_del'){
  $id=funstr($_GET["id"]);
  $page=funstr($_GET["page"]);
  $sql=query("delete from ".$dbz."news where id='$id'");
  @unlink("../news/".$id.".htm");
  if ($sql){echo tanshow("","news.php?rel=news&page=$page");}else{echo mysql_error();}
}

if ($rel=='news_all'){
  $i=funstr($_POST["i"]);
  $n=1;
  while($n<=$i){
    $ns='checkbox'.$n;
	$id=@funstr($_POST[$ns]);
	if($id<>''){
	  $sql=query("delete from ".$dbz."news where id=$id");
	 @unlink("../news/".$id.".htm");
	}
    $n=$n+1;
  }
  echo tanshow("删除成功","news.php?rel=news");
}

if($rel=='news_audits'){
  $id=funstr($_GET["id"]);
  $num=funstr($_GET["num"]);
  $page=funstr($_GET["page"]);
  $sql=query("update ".$dbz."news set audits=$num where id=$id");
  if ($sql){echo tanshow("","news.php?rel=news&page=$page");}else{echo mysql_error();}
}
if($rel=='news_vips'){
  $id=funstr($_GET["id"]);
  $num=funstr($_GET["num"]);
  $page=funstr($_GET["page"]);
  $sql=query("update ".$dbz."news set vips=$num where id=$id");
  if ($sql){echo tanshow("","news.php?rel=news&page=$page");}else{echo mysql_error();}
}
if($rel=='news_headlines'){
  $id=funstr($_GET["id"]);
  $num=funstr($_GET["num"]);
  $page=funstr($_GET["page"]);
  $sql=query("update ".$dbz."news set headlines=$num where id=$id");
  if ($sql){echo tanshow("","news.php?rel=news&page=$page");}else{echo mysql_error();}
}
if($rel=='news_slides'){
  $id=funstr($_GET["id"]);
  $num=funstr($_GET["num"]);
  $page=funstr($_GET["page"]);
  $sql=query("update ".$dbz."news set slides=$num where id=$id");
  if ($sql){echo tanshow("","news.php?rel=news&page=$page");}else{echo mysql_error();}
}
if($rel=='news_tops'){
  $id=funstr($_GET["id"]);
  $num=funstr($_GET["num"]);
  $page=funstr($_GET["page"]);
  $sql=query("update ".$dbz."news set tops=$num where id=$id");
  if ($sql){echo tanshow("","news.php?rel=news&page=$page");}else{echo mysql_error();}
}

if ($rel=='news_add'){
  $titles=funstr($_POST["titles"]);
  $keywords=funstr($_POST["keywords"]);
  $dis=funstr($_POST["dis"]);
  $users=@funstr($_POST["users"]);
  $sources=@funstr($_POST["sources"]);
  $vips=@funstr($_POST["vips"]);
  $slides=@funstr($_POST["slides"]);
  $headlines=@funstr($_POST["headlines"]);
  $imgs=funstr($_POST["imgs"]);
  $cid=@funstr($_POST["cid"]);
  $mg=funstr($_POST["FCKeditor1"]);
  $clearhtml=@funstr($_POST["clearhtml"]);
  //$tags=funstr($_POST["tags"]);
  $tops=@funstr($_POST["tops"]);
  
  if(strlen($titles)<1){echo tanshow("标题不能为空","");exit();}
  if(strlen($mg)<1){echo tanshow("内容不能为空","");exit();}
  
  if($vips==''){$vips='0';}
  if($slides==''){$slides='0';}
  if($headlines==''){$headlines='0';}
  if($tops==''){$tops='0';}
  if($clearhtml==''){$clearhtml='0';}else{$mg=html_clears($mg);}
  if($dis==''){$dis=utf_substr(html_clears($mg),190);}
  $cids=explode(",",$cid);
  
  if(count($cids)==1){echo tanshow("尚未添加分类,直接转向到分类添加页!","class.php?rel=class_add");exit();}
  
  $sql=query("insert into ".$dbz."news(titles,keywords,dis,users,sources,cid,trees,vips,slides,headlines,imgs,mg,tops,times,audits)values('$titles','$keywords','$dis','$users','$sources','$cids[0]','$cids[1]','$vips','$slides','$headlines','$imgs','$mg','$tops','$times','1')");
  if ($sql){echo tanshow("","html.php?rel=news_html");}else{echo mysql_error();}
}

if ($rel=='news_info'){
  $id=funstr($_POST["id"]);
  $titles=@funstr($_POST["titles"]);
  $keywords=@funstr($_POST["keywords"]);
  $dis=@funstr($_POST["dis"]);
  $users=@funstr($_POST["users"]);
  $sources=@funstr($_POST["sources"]);
  $vips=@funstr($_POST["vips"]);
  $slides=@funstr($_POST["slides"]);
  $headlines=@funstr($_POST["headlines"]);
  $imgs=@funstr($_POST["imgs"]);
  $cid=funstr($_POST["cid"]);
  $mg=funstr($_POST["FCKeditor1"]);
  $clearhtml=@funstr($_POST["clearhtml"]);
  //$tags=@funstr($_POST["tags"]);
  $tops=@funstr($_POST["tops"]);
  $page=funstr($_POST["page"]);
  
  if(strlen($titles)<1){echo tanshow("标题不能为空","");exit();}
  if(strlen($mg)<1){echo tanshow("内容不能为空","");exit();}
  
  if($vips==''){$vips='0';}
  if($slides==''){$slides='0';}
  if($headlines==''){$headlines='0';}
  if($tops==''){$tops='0';}
  if($clearhtml==''){$clearhtml='0';}else{$mg=html_clears($mg);}
  if($dis==''){$dis=utf_substr(html_clears($mg),190);}
  $cids=split(",",$cid);
  
  $sql=query("update ".$dbz."news set titles='$titles',keywords='$keywords',dis='$dis',users='$users',sources='$sources',cid='$cids[0]',trees='$cids[1]',vips='$vips',slides='$slides',headlines='$headlines',imgs='$imgs',mg='$mg',tops='$tops',times='$times',audits='1' where id=$id");
  if ($sql){echo tanshow("","html.php?rel=news_html&id=$id&page=$page");}else{echo mysql_error();}
}

//处理文章===========================================结束
//处理连接===========================================开始
if($rel=='link_all'){
  $i=funstr($_POST["i"]);
  $n=1;
  while($n<=$i){
    $ns1='checkbox'.$n;
	$ns2='orders'.$n;
	$id=@funstr($_POST[$ns1]);
	$id2=@funstr($_POST[$ns2]);
	
	if($id<>''){
	  $sql=query("update ".$dbz."link set orders='$id2' where id=$id");
	}
    $n=$n+1;
  }
  echo tanshow("批量修改排序成功","link.php");
  
}
if ($rel=='link_del'){
  $id=funstr($_GET["id"]);
  $page=funstr($_GET["page"]);
  $sql=query("delete from ".$dbz."link where id='$id'");
  if ($sql){echo tanshow("","link.php?page=$page");}else{echo mysql_error();}
}
if($rel=='link_audits'){
  $id=funstr($_GET["id"]);
  $num=funstr($_GET["num"]);
  $page=funstr($_GET["page"]);
  $sql=query("update ".$dbz."link set audits=$num where id=$id");
  if ($sql){echo tanshow("","link.php?page=$page");}else{echo mysql_error();}
}
if($rel=='link_add'){
  $names=funstr($_POST["names"]);
  $urls=funstr($_POST["urls"]);
  $imgs=funstr($_POST["imgs"]);
  $qqs=funstr($_POST["qqs"]);
  $orders=funstr($_POST["orders"]);
  $dis=funstr($_POST["dis"]);
  
  $sql=query("insert into ".$dbz."link(names,urls,imgs,qqs,orders,dis,audits,times)values('$names','$urls','$imgs','$qqs','$orders','$dis',1,'$times')");
  if ($sql){echo tanshow("","link.php?rel=link_add");}else{echo mysql_error();}
}

if($rel=='link_info'){
  $id=funstr($_POST["id"]);
  $page=funstr($_POST["page"]);
  $names=funstr($_POST["names"]);
  $urls=funstr($_POST["urls"]);
  $imgs=funstr($_POST["imgs"]);
  $qqs=funstr($_POST["qqs"]);
  $orders=funstr($_POST["orders"]);
  $dis=funstr($_POST["dis"]);
  
  $sql=query("update ".$dbz."link set names='$names',urls='$urls',imgs='$imgs',qqs='$qqs',orders='$orders',dis='$dis',times='$times' where id=$id");
  if ($sql){echo tanshow("","link.php?&page=$page");}else{echo mysql_error();}
}


//处理连接===========================================结束
//处理广告===========================================开始
if ($rel=='ad_del'){
  $id=funstr($_GET["id"]);
  $sql=query("delete from ".$dbz."ad where id='$id'");
  if ($sql){echo tanshow("","ad.php?rel=ad_add");}else{echo mysql_error();}
}
if($rel=='ad_add'){
  $names=funstr($_POST["names"]);
  $tags=funstr($_POST["tags"]);
  $codes=funstr($_POST["codes"]);
  $sqls=query("select * from ".$dbz."ad where tags='$tags'");
  if(!$row=fetch($sqls)){
    $sql=query("insert into ".$dbz."ad (names,tags,codes,times)values('$names','$tags','$codes','$times')");
    if ($sql){echo tanshow("","ad.php");}else{echo mysql_error();}
  }
  else{
    echo tanshow("标签不能重复","ad.php?rel=ad_add");
  }
}

if($rel=='ad_info'){
  $id=funstr($_POST["id"]);
  $names=funstr($_POST["names"]);
  $tags=funstr($_POST["tags"]);
  $codes=funstr($_POST["codes"]);
  
  $sql=query("update ".$dbz."ad set names='$names',tags='$tags',codes='$codes',times='$times' where id=$id");
  if ($sql){echo tanshow("","ad.php");}else{echo mysql_error();}
}

//处理广告===========================================结束
//处理会员===========================================开始
if($rel=='user_admin'){
  $id=funstr($_POST["id"]);
  $username=funstr($_POST["username"]);
  $password=funstr($_POST["password"]);
  $password2=funstr($_POST["password2"]);
  
  if($password<>$password2){
    echo tanshow("两次输入密码不同.","");
  }
  else{
    $password=md5($password);
    $sql=query("update ".$dbz."user set passwords='$password',usernames='$username' where id=$id");
	if ($sql){echo tanshow("修改成功","user.php?rel=user_admin");}else{echo mysql_error();}
  }
}
if($rel=='user_config'){
  $yunxu=@funstr($_POST["yunxu"]);
  $regfens=funstr($_POST["regfens"]);
  $vipfens=funstr($_POST["vipfens"]);
  $newsfens=funstr($_POST["newsfens"]);
  
  
  if($yunxu==''){$yunxu=0;}else{$yunxu=1;}
  
  $str=$yunxu.',,'.$regfens.',,'.$vipfens.',,'.$newsfens;
  createfile('../cache/userconfig.txt',$str);
  echo tanshow("","user.php?rel=user_config");
}

//处理会员===========================================结束
//处理搜索关键字===========================================开始
if($rel=='so_hots'){
  $id=funstr($_GET["id"]);
  $num=funstr($_GET["num"]);
  $page=funstr($_GET["page"]);
  $sql=query("update ".$dbz."so set hots=$num where id=$id");
  if ($sql){echo tanshow("","main.php?rel=so&page=$page");}else{echo mysql_error();}
}
if ($rel=='so_del'){
  $id=funstr($_GET["id"]);
  $page=funstr($_GET["page"]);
  $sql=query("delete from ".$dbz."so where id='$id'");
  if ($sql){echo tanshow("","main.php?rel=so&page=$page");}else{echo mysql_error();}
}
if($rel=='so_add'){
  $keywords=funstr($_POST["keywords"]);
  $hots=@funstr($_POST["hots"]);
  if($hots==''){$hots=0;}
  if($keywords==''){echo tanshow("关键字不能为空","");}
  else{
    $sqls=query("select * from ".$dbz."so where keywords='$keywords'");
	if($rows=fetch($sqls)){
	  echo tanshow("关键字已经存在","");
	}
	else{
	  $sql=query("insert into ".$dbz."so(keywords,hots,times)values('$keywords','$hots','$times')");
	  if ($sql){echo tanshow("","main.php?rel=so_add");}else{echo mysql_error();}
	}
  }
}
if($rel=='so_info'){
  $id=funstr($_POST["id"]);
  $page=funstr($_POST["page"]);
  $keywords=funstr($_POST["keywords"]);
  $hots=@funstr($_POST["hots"]);
  if($hots==''){$hots=0;}
  if($keywords==''){echo tanshow("关键字不能为空","");}
  else{
	$sql=query("update ".$dbz."so set keywords='$keywords',hots='$hots',times='$times' where id=$id");
	if ($sql){echo tanshow("","main.php?rel=so&page=$page");}else{echo mysql_error();}
  }
}

//处理搜索关键字===========================================结束
mysql_close();
?>