<?php 
function class_cs($c_str,$back,$z_str,$wapid){
$sql="SELECT {$c_str},{$back} FROM class WHERE {$c_str}='{$z_str}' AND siteid='{$wapid}'";
	$result = mysql_query($sql);
	if($result && mysql_num_rows($result)>0){
	list($str1,$str2) = mysql_fetch_row($result);
	    $t = $str2;
	   }else{
	    $t = '参数错误,程序错误的传递了不存在的参数，找不到制定栏目的额数据，请检查地址是否正确或者联系程序提供商';
	   }
	 return $t;  
	 }
echo head("修改顶部");
   if($admin != 1 && $admin !=2){
     die('您好，你无权进入此页面！');
	 }
   if($_GET['action']  == 'mod'){
   if($_GET['cid'] == NULL || $_GET['cid'] == 0){
   $sql = "UPDATE config SET index_top='{$_POST['t']}' WHERE user='{$wapid}'";
   }else{
   $sql = "UPDATE class SET top='{$_POST['t']}' WHERE cid='{$_GET['cid']}' AND siteid='{$wapid}'";
   }
   $result = mysql_query($sql);
   if($result && mysql_affected_rows()>0){
   echo "修改成功";
   }else{
    echo "修改失败";
   }
   mysql_free_result($result);
   $sql="SELECT cid,siteid,gro FROM class WHERE cid='{$_GET['cid']}' AND siteid='{$wapid}'";
   $result=mysql_query($sql);
   list($cid,$siteid,$gro) = mysql_fetch_row($qcon);
   echo '<div class="content">
   <a href="../indexadmin_web.php?cid='.$_GET['cid'].'">排版页面</a></div>';
	}else{ 
    if($_GET['cid'] == NULL || $_GET['cid'] == 0){
	                      $t = $index_top;
	                                                     }else{
    
	                      $t = class_cs('cid','top',$_GET['cid'],$wapid);
	}
    echo "<div class=\"system_title\" style=\"line-height:40px;background:#efefef;border:1px solid #ccc;\">顶部内容排版[支持UBB]</div>
    <form method=\"post\" action=\"mod.php?mod=mod_t_web&action=mod&cid=".$_GET['cid']."\">
    <textarea name=\"t\" style=\"width:100%;height:300px;\">".$t."</textarea><br>
    <input type=\"submit\" value=\"确认修改\">
    </form>";
    
	 echo "<div class=\"mylink\"><a href=\"../indexadmin_web.php?cid=".$_GET['cid']."\">返回页面综合排版</a></div>";

    }
	echo footer(1);
?>