<?
	require_once("admin__check.php");

	// 设置搜索条件和排序方式
	$a=$a==""?"status":trim($a);
	$b=$b=="desc"?"desc":"asc";
	$c=str_replace("\\","",str_replace("\"","'",$c));
	$condition=$c==""?"1":$c;
	$condition.=" and status>0 ";

	// 获取当前页数并设定每页记录条数	
	$p=floor(trim($p));
	$p=$p<=0?1:$p;
	$q=floor(trim($q));
	$q=$q<=0?20:$q;

	// 获取总记录条数
	$sql="select count(id) from ".TBL_PAGE." where $condition ";
	$totals=mysql_fetch_array(mysql_query($sql));
	$total=$totals[0];

	// 获取当前页记录集
	$sql="select * from ".TBL_PAGE." where $condition order by $a $b limit ".(($p-1)*$q).",$q ";
	$result=mysql_query($sql);
	while($row=mysql_fetch_array($result)){
		$lists[]=$row;
	}
?>

<fieldset>页面管理 - 列表</fieldset>

<div id="toolbar">
	<button class="b2" onclick="operate(this,'<?=basename(__FILE__,".php");?>_do.php&status=2','change',0)">进行投放</button>
	&nbsp;
	<button class="b2" onclick="operate(this,'<?=basename(__FILE__,".php");?>_do.php&status=1','change',0)">取消投放</button>
	&nbsp;&nbsp;
	<button class="b1" onclick="operate(this,'<?=basename(__FILE__,".php");?>_do.php','del',0)">删除选中记录</button>
</div>

<table cellspacing='0' cellpadding='3' border='0'>
	<tr>
		<th width="7%"	title="<?=$title="id";?>"			class="<?=$a==$title?$b:""?>" onclick="sort(this.title)">ID</th>
		<th width="7%"	title="<?=$title="uid";?>"		class="<?=$a==$title?$b:""?>" onclick="sort(this.title)">UID</th>
		<th width="43%"	title="<?=$title="title";?>"	class="<?=$a==$title?$b:""?>" onclick="sort(this.title)">标题</th>
		<th width="20%"	title="<?=$title="dt";?>"			class="<?=$a==$title?$b:""?>" onclick="sort(this.title)">时间</th>
		<th width="10%"	title="<?=$title="click";?>"	class="<?=$a==$title?$b:""?>" onclick="sort(this.title)">点击</th>
		<th width="10%"	title="<?=$title="status";?>"	class="<?=$a==$title?$b:""?>" onclick="sort(this.title)">状态</th>
		<th width="3%"><input type="checkbox" id="cb_0" onclick="select_all();" title="全部选中"></th>
	</tr>
	<?
		$status=array(
			-1=>"已经删除",
			0=>"用户不允许投放",
			1=>"未通过审核",
			2=>"已通过审核",
		);
		if(count($lists)>0){
			$i=0;
			foreach($lists as $l){
				$i++;
				$bgcolor=$bgcolor=="#FFFFFF"?"#F8F8F8":"#FFFFFF";
				$str.="<tr align='center' bgcolor='$bgcolor'>";			
				$str.="<td>".$l['id']."</td>";		
				$str.="<td>".$l['uid']."</td>";
				$str.="<td align='left'><a href='".$l["uri"]."' target='preview'>".$l['title']."</a></td>";
				$str.="<td>".$l['dt']."</td>";
				$str.="<td>".$l['click']."</td>";
				$str.="<td><img src='images/status_".$l['status'].".gif' border='0' title='".$status[$l["status"]]."'></td>";
				$str.="<td><input type='checkbox' id=cb_".$i." value=".$l["id"]." ".(strstr($l["uri"],"#")=="#eachgain"?"title='默认采集页面'":"")."></td>";
				$str.="</tr>";			
			}
		}
		else{
			$str="<tr><td colspan='7' style='height:80px;padding-left:20px;color:#666666;'>提示：没有符合条件的任何信息。</td></tr>";
		}
		echo $str;
	?>
	<tr>
		<th colspan="7" align="center" style="display:<?=$role=="admin"?"block":"none";?>;">
			<input id="tatol" type="hidden" value="<?=$i;?>">
			<textarea id="keyword" style="width:600px;height:21px;overflow:hidden;" onkeydown="if(event.keyCode==13){document.all.search.click();}" title="格式：id>1 and email like '%@126.com'"><?=$c;?></textarea>&nbsp;<button id="search" onclick="sort('<?=$a;?>')">查询</button>
		</th>
	</tr>
	<tr>
		<td colspan="7" class="page"><?show_page($total);?></td>
	</tr>
</table>