<?php
require("../../class/connect.php");
include("../../class/db_sql.php");
include("../../class/config.php");
include("../../class/functions.php");
include "../".LoadLang("pub/fun.php");
$link=db_connect();
$empire=new mysqlquery();
$logininid=getcvar('loginuserid');
$loginin=getcvar('loginusername');
$loginrnd=getcvar('loginrnd');
$loginlevel=getcvar('loginlevel');
$editor=1;
is_login($logininid,$loginin,$loginrnd);
//验证权限
CheckLevel($logininid,$loginin,$classid,"ad");
$page=(int)$_GET['page'];
$start=(int)$_GET['start'];
$line=10;//每页显示条数
$page_line=23;//每页显示链接数
$offset=$start+$page*$line;//总偏移量
$query="select * from {$dbtbpre}enewsad";
//过期广告
$time=$_GET['time'];
if(empty($time))
{$time=$_POST['time'];}
$where=" where";
if($time)
{
	$date=date("Y-m-d");
	$query.=" where endtime<'$date'";
	$where=" and";
	$search="&time=$time";
}
//搜索
$sear=$_GET['sear'];
if(empty($sear))
{$sear=$_POST['sear'];}
if($sear)
{
	$keyboard=$_GET['keyboard'];
	if(empty($keyboard))
	{$keyboard=$_POST['keyboard'];}
	$keyboard=addslashes(stripSlashes($keyboard));
	$show=$_GET['show'];
	if(empty($show))
	{$show=$_POST['show'];}
	$classid=$_GET['classid'];
	if(empty($classid))
	{$classid=$_POST['classid'];}
	$t=$_GET['t'];
	if(empty($t))
	{$t=$_POST['t'];}
	if($show==1)
	{$where.=" title like '%$keyboard%'";}
	elseif($show==2)
	{$where.=" adsay like '%$keyboard%'";}
	else
	{$where.=" (title like '%$keyboard%' or adsay like '%$keyboard%')";}
	$classid=(int)$classid;
	if($classid)
	{$where.=" and classid='$classid'";}
	if($t!=9)
	{$where.=" and t='$t'";}
	$search.="&classid=$classid&show=$show&t=$t&sear=1&keyboard=$keyboard";
	$query.=$where;
}
$num=$empire->num($query);//取得总条数
$query=$query." order by adid desc limit $offset,$line";
$sql=$empire->query($query);
$returnpage=page1($num,$line,$page_line,$start,$page,$search);
$ty[1]="普通显示";
$ty[2]="";
$ty[3]="可移动透明对话框";
$ty[4]="满屏浮动显示";
$ty[5]="上下浮动显示 - 右";
$ty[6]="上下浮动显示 - 左";
$ty[7]="全屏幕渐隐消失";
$ty[8]="打开新窗口";
$ty[9]="弹出窗口";
$ty[10]="普通网页对话框";
$ty[11]="对联式广告";
$myt[1]="文字广告";
$myt[2]="html广告";
$myt[3]="弹出广告";
$myt[0]="图片与flash广告";
//广告类别
$csql=$empire->query("select classid,classname from {$dbtbpre}enewsadclass");
while($cr=$empire->fetch($csql))
{
	$options.="<option value=".$cr[classid].">".$cr[classname]."</option>";
}
//风格
$loginadminstyleid=(int)getcvar('loginadminstyleid');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
<title>管理广告</title>
</head>

<body>
<table width="98%%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr>
    <td height="25">位置：<a href="ListAd.php">管理广告</a>&nbsp;&nbsp;(<a href=AddAd.php?enews=AddAd>增加广告</a>)&nbsp;&nbsp;(<a href=ListAd.php?time=1>管理过期广告</a>)</td>
  </tr>
</table>
<form name="form1" method="post" action="ListAd.php">
  <table width="98%%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
    <input type=hidden name=time value=<?=$time?>>
    <tr> 
      <td height="25" bgcolor="#FFFFFF">关键字：
        <input name="keyboard" type="text" id="keyboard" value="<?=$keyboard?>">
        <input name="show" type="radio" value="0" checked>
        不限 
        <input name="show" type="radio" value="1">
        广告名称 
        <input name="show" type="radio" value="2">
        备注 
        <select name="classid" id="classid">
          <option value="0">不限类别</option>
		  <?=$options?>
        </select>
        <select name="t" id="t">
          <option value="9">不限广告类型</option>
          <option value="0">图片与flash广告</option>
          <option value="1">文字广告</option>
          <option value="2">html广告</option>
          <option value="3">弹出广告</option>
        </select>
        <input type="submit" name="Submit" value="搜索">
        <input name="sear" type="hidden" id="sear" value="1"></td>
    </tr>
    <tr> 
      <td height="25" bgcolor="#FFFFFF">说明：调用方式：&lt;script src=广告js地址&gt;&lt;/script&gt;或用标签调用</td>
    </tr>
  </table>
</form>
<?
  while($r=$empire->fetch($sql))
  {
  ?>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  <tr class="header"> 
    <td width="12%" height="25">广告名称：</td>
    <td width="35%" height="25"> 
      <?=$r[title]?>
      </td>
    <td width="15%" height="25">点击： 
      <?=$r[onclick]?>
      </td>
    <td width="38%" height="25">管理：[<a href="../view/js.php?js=<?=$public_r['adfile']?><?=$r[adid]?>&p=acmsd" target="_blank">预览</a>]　[<a href="AddAd.php?enews=EditAd&adid=<?=$r[adid]?>&time=<?=$time?>">修改</a>]　[<a href="../enews.php?enews=DelAd&adid=<?=$r[adid]?>&time=<?=$time?>" onclick="return confirm('确认要删除？');">删除</a>]</td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td height="38">广告类型：</td>
    <td height="38"> 
      <?=$myt[$r[t]]?>&nbsp;(<?=$ty[$r[adtype]]?>)
    </td>
    <td rowspan="2">备注:</td>
    <td height="25" rowspan="2"> <textarea name="textarea" cols="42" rows="5"><?=$r[adsay]?></textarea></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td height="25">过期时间：</td>
    <td height="25"> 
      <?=$r[starttime]?>
      &nbsp;-&nbsp; 
      <?=$r[endtime]?>
    </td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td height="25">广告JS地址：</td>
    <td height="25" colspan="3"> <input name="textfield" type="text" value="<?=$public_r[newsurl]?>d/js/acmsd/<?=$public_r['adfile']?><?=$r[adid]?>.js" size="70">
      (ID:<b><?=$r[adid]?></b>)</td>
  </tr>
</table>
<?
  }
  ?>
<br>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr>
    <td>分页：<?=$returnpage?></td>
  </tr>
</table>
</body>
</html>
<?
db_close();
$empire=null;
?>
