<?php
require_once '../include/adminfunction.php';
checkadmin();

function updatesettext($text){
	if($text=="")
		return "";
    $text=str_replace("'",'"',$text);
    $text=str_replace("\r","",$text);
    $text=str_replace("\n","",$text);
    return $text;
}

$arrays = application("singerpagelist","../data/singerpagedate.php");
//dump($arrays);

if(!is_array($arrays)){
	$arrays = array();
}

$action=var_request("action","");
$tp=var_request("tp","");
$arri=var_request("i","");


$errmsg = "";
$pagetext="";
if($action=="update" || $action=="add"){
	$ctxtname = updatesettext(var_request("txtname",""));
	$cpagekeyword = updatesettext(var_request("pagekeyword",""));
	$cpagedescription = updatesettext(var_request("pagedescription",""));
	$cpagetitle = updatesettext(var_request("pagetitle",""));
	$cappno = var_request("appno","0");
	$cbutton = var_request("button","0");
	
	$arrayNow = array();
	$arrayNow['txtname'] = $ctxtname;
	$arrayNow['pagekeyword'] = $cpagekeyword;
	$arrayNow['pagedescription'] = $cpagedescription;
	$arrayNow['pagetitle'] = $cpagetitle;
		
	if($action=="add"){
		array_push($arrays,$arrayNow);
	}
	if($action=="update" && $cbutton=="修改"){
		$arrays[$cappno] = $arrayNow;
	}
	if($action=="update" && $cbutton=="删除"){
		array_splice($arrays,$cappno,1);
	}
	
	setapplication("singerpagelist",$arrays,"../data/singerpagedate.php");
	
	redirect_to("managesingerpage.php?add=ok");
	exit;
	
}


if($action=="sort"){
	if($tp=='up'){
		$temp = $arrays[$arri-1];
		$arrays[$arri-1] = $arrays[$arri];
		$arrays[$arri] = $temp;
		setapplication("singerpagelist",$arrays,"../data/singerpagedate.php");
		
		redirect_to("managesingerpage.php?add=ok");
		exit;
	}elseif($tp=='down'){
		$temp = $arrays[$arri+1];
		$arrays[$arri+1] = $arrays[$arri];
		$arrays[$arri] = $temp;
		setapplication("singerpagelist",$arrays,"../data/singerpagedate.php");
		
		redirect_to("managesingerpage.php?add=ok");
		exit;
	}
}

?>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>315爱购网</title>
	<link rel='stylesheet' href='images/order.css'>
    <style type="text/css">
<!--
.STYLE2 {color: #FF0000}
-->
    </style>
</head>

<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<center>
  <table width="96%" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td height="10" align=center></td>
  </tr>
</table>
<?php if(var_request("add","")=="ok"){?>
<table width="96%" border="0" cellpadding="3" cellspacing="1" bgcolor="#cccccc">
  <tr>
    <td height="30" colspan="2" align="center" bgcolor="#FFFFCC"><a href="managetypelist.php"><span class="STYLE2">修改成功！</span></a> </td>
  </tr>
</table>
<?php }?>

<?php 
if(is_array($arrays) && Count($arrays)>0){
	for($i=0;$i<Count($arrays);$i++){
?>
    <form name="form1" method="post" action="managesingerpage.php?action=update" style="margin:2px; color: #F00;">
    <table border="0" cellpadding="3" cellspacing="1" bgcolor="#cccccc"><tr bgcolor="#c8ddf4">
        <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">模块标记：</td>
        <td bgcolor="#ffffff"><input name="txtname" type="text" id="txtrootroad" value="<?php echo $arrays[$i]['txtname'] ?>" size="10"></td>
        <td bgcolor="#ffffff">
        标题：
          <input name="pagetitle" type="text" value="<?php echo $arrays[$i]['pagetitle'] ?>" size="20">
          关键字：
        <input name="pagekeyword" type="text" id="txtrootroad2" value="<?php echo $arrays[$i]['pagekeyword'] ?>" size="8"></td>
        <td bgcolor="#ffffff"><label>
          <input type="submit" name="button" id="button3" value="修改">
          <input type="submit" name="button" id="button" value="生成文件">
          
          <input type="button" name="button" id="button" value="编辑关联列表" onClick="location.href='ManageSingerPageEdit.php?pageid=<?php echo $i ?>';return false;">
          <input type="submit" name="button" id="button2" value="删除" onClick=" return confirm('确定删除么?')">
          <input type="hidden" name="appno" value="<?php echo $i ?>">
        </label></td>
    </tr>
      <tr bgcolor="#c8ddf4">
        <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">模块内容：</td>
        <td colspan="3" bgcolor="#F0F0F0"><textarea name="pagedescription" id="pagedescription" cols="100" rows="4"><?php echo $arrays[$i]['pagedescription'] ?></textarea>
          <br>
          调用代码 &lt;?php echo get_neirong_str(&quot;<?php echo $arrays[$i]['txtname'] ?>&quot;)?&gt;</td>
      </tr>
    </table>
    <br>
  </form>
<?php 
	}
}	
?>

<form name="form1" method="post" action="managesingerpage.php?action=add">
<table border="0" cellpadding="3" cellspacing="1" bgcolor="#cccccc"><tr bgcolor="#c8ddf4">
        <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">模块标记：</td>
        <td bgcolor="#ffffff"><input name="txtname" type="text" id="txtrootroad" value="page" size="10"></td>
        <td bgcolor="#ffffff">
       标题：
         <input name="pagetitle" type="text" value="" size="20">
         关键字：
       <input name="pagekeyword" type="text" id="txtrootroad2" value="" size="8">
       <br></td>
        <td bgcolor="#ffffff"><label>
      <input type="submit" name="button" id="button" value="添加">
    </label></td>
</tr>
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">模块内容：</td>
    <td colspan="3" bgcolor="#ffffff"><textarea name="pagedescription" cols="100" rows="4" id="pagedescription"></textarea></td>
    </tr>
</table>
</form>


<table width="96%" height="91" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="1" bgcolor="#b2b2b2"></td>
  </tr>
  <tr>
    <td height="90" align=center>
<br> 
<p><span style="color:#FF0000">本类别设置多功能模块。根据不同的模板，可以用于广告块、推荐列表等各种用途。</span></p>

      </td>
  </tr>
</table>
</center>
</body>
</html>
