<?php
/**
 * @version        Somao_Search X1.0 9:23 2012-1-1 Somao $
 * @package        Somao_Search.Site
 * @copyright      Copyright (c) 2009 - 2012, Somao, Inc.
 * @license        http://www.somao123.com/
 * @link           http://www.somao.cc/
**/
require "global.php";
CheckPurview('union_code',$authoritys,$rank);
$action=$_REQUEST["action"];
$id=$_REQUEST["id"];
if($action=="save"){
	$cid=$_POST['cid'];
	$names=$_POST['names'];
	$type=$_POST['type'];
	$info=$_POST['info'];
	$body=$_POST['body'];
	
	if($cid!=""){
		$array=array('names'=>$names,'type'=>$type,'info'=>$info,'body'=>$body);
	    $db->update("ve123_webunion_code",$array,"cid='$cid'");
	    jsalert("修改成功");
	    header("location:union_code.php");
	}else{
		$array=array('names'=>$names,'type'=>$type,'info'=>$info,'body'=>$body);
	    $db->insert("ve123_webunion_code",$array); 
		jsalert("添加成功"); 
		header("location:union_code.php");
	} 
     
}
if($action=="del"){
	 $db->query("DELETE FROM ve123_webunion_code WHERE cid=$id");
	 jsalert ("成功删除指定的记录!");
	 exit(); 
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<meta http-equiv="x-ua-compatible" content="ie=7" />
<link href="css/admincp.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
  <div class="floattop">
    <div class="itemtitle"><h3>代码列表</h3>
      <ul class="tab1">
        <li <?php if($action=="" or $action=="search"){echo 'class="current"';}?>><a href="union_code.php"><span>代码列表</span></a></li>
        <li <?php if($action=="add"){echo 'class="current"';}?>><a href="?action=add"><span>添加代码</span></a></li>
      </ul>
     </div>
   </div>
 <div class="floattopempty"></div>
<?php
if($action==""){
?>
<form id="listform" name="listform" method="post" action="?action=dolistform" onsubmit="return checkform();">
<table class="tb tb2 ">
  <tr class="header">
    <th style="text-align: center">ID</th>
    <th>代码类型</th>
    <th>代码名称</th>
    <th>操作</th>
  </tr>
  <?php
  $query=$db->query("select * from ve123_webunion_code order by cid desc ");
  while($link=$db->fetch_array($query)){
  ?>
  <tr>
    <td height="30" align="center"><?php echo $link["cid"];?></td>
    <td height="30"><?php echo $link["type"];?></td>
    <td height="30"><?php echo $link["names"];?></td>
    <td><a href="?action=add&cid=<?php echo $link["cid"];?>">修改</a> <a href="?action=del&cid=<?php echo $link["cid"];?>">删除</a></td>
  </tr>
  <?php
  }
  ?>
  </table>
<?php }
elseif($action=="add") {
$cids=$_GET['cid'];
$row=$db->get_one("select * from ve123_webunion_code where cid='".$cids."' ");
?>
<form method="post" action="">
<input type="hidden" name="action" value="save" />
<input type="hidden" name="cid" value="<?php echo $row["cid"];?>" />
<table class="tb tb2">
  <tr>
    <tr><th  class="partition"  colspan="5">详细信息</th></tr>
      <tr>
        <td align="right" width="90"><h4>代码名称</h4></td>
        <td align="left"><input type="text" name="names"  style="width:260px;" value="<?php echo $row["names"];?>"/></td>
      </tr>
      <tr>
        <td align="right" width="90"><h4>代码类型</h4></td>
        <td align="left">
        <input type="radio" name="type" value="搜索框" <?php if($row["type"]=="搜索框") echo 'checked="checked"';?> /> 搜索框
        <input type="radio" name="type" value="文字链接" <?php if($row["type"]=="文字链接") echo 'checked="checked"';?> /> 文字链接
        <input type="radio" name="type" value="自定义" <?php if($row["type"]=="自定义") echo 'checked="checked"';?> />自定义</td>
      </tr>
      <tr>
        <td align="right" width="90"><h4>代码描述</h4></td>
        <td align="left"><textarea name="info" cols="80" rows="5"><?php echo $row["info"];?></textarea></td>
      </tr>
      <tr>
        <td align="right" width="90"><h4>代码内容</h4></td>
        <td align="left"><textarea name="body" cols="80" rows="25"><?php echo $row["body"];?></textarea>
        <script type="text/javascript">//<![CDATA[
window.CKEDITOR_BASEPATH='/include/ckeditor/';
//]]></script>
<script type="text/javascript" src="/include/ckeditor/ckeditor.js?t=B8DJ5M3"></script>
<script type="text/javascript">//<![CDATA[
CKEDITOR.replace('body', {"extraPlugins":"dedepage,multipic,addon","toolbar":[["Source","-","Templates"],["Cut","Copy","Paste","PasteText","PasteFromWord","-","Print"],["Undo","Redo","-","Find","Replace","-","SelectAll","RemoveFormat"],["ShowBlocks"],["Image","Flash","Addon"],["Maximize"],"\/",["Bold","Italic","Underline","Strike","-"],["NumberedList","BulletedList","-","Outdent","Indent","Blockquote"],["JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock"],["Table","HorizontalRule","Smiley","SpecialChar"],["Link","Unlink","Anchor"],"\/",["Styles","Format","Font","FontSize"],["TextColor","BGColor","MyPage","MultiPic"]],"height":350,"skin":"kama"});
//]]></script></td>
      </tr>
      <tr>
        <td align="right" width="90"><h4>代码说明</h4></td>
        <td align="left">1、添加搜索框注意：<br />
        &nbsp;&nbsp;&nbsp; form的action属性必须是"域名+/s/?" 关键字字段名称为wd<br />
        &nbsp;&nbsp;&nbsp; 在form标签之中必须添加 &lt;input type=&quot;hidden&quot; name=&quot;urlid&quot; value=&quot;$urlid&quot; /&gt;<br /> 
        <br />
       2、添加链接演示：<br />
         &nbsp;&nbsp;&nbsp;  &lt;a href=&quot;域名+/s/?wd=关键字&amp;urlid=$urlid&quot; target=&quot;_blank&quot;&gt;关键字&lt;/a&gt; </td>
      </tr>
       <tr>
        <td align="right" width="90"></td>
        <td align="left"><input type="submit"  value="提交" /> <input type="reset"  value="重填" /></td>
      </tr>
    </table>
</form>
<?php } ?>
</div>
</body>
</html>