<?php
require(dirname(__FILE__) .'/check.php');
$skin->CheckIframe();

$infoSysArr = Cache::PhpFile('infoSys');
$userSysArr = Cache::PhpFile('userSys');


/* **** 版权所有 ****

 程序开发：网钛科技
 网钛CMS官网：http://otcms.com
 网钛IDC官网：http://idccms.com
 ＱＱ：877873666
 微信：QQ877873666
 邮箱：877873666@qq.com

 **** 版权所有 **** */


//打开用户表，并检测用户是否登录
$MB->Open('','login');

$skin->WebTop();


echo('
<script language="javascript" type="text/javascript" src="js/inc/list.js?v='. OT_VERSION .'"></script>
<script language="javascript" type="text/javascript" src="js/inc/trim.js?v='. OT_VERSION .'"></script>
');



switch ($mudi){
	case 'manage':
		$MB->IsSecMenuRight('alertBack',51,$dataType);
		manage();
		break;

	default:
		die('err');
}

$skin->WebBottom();

$MB->Close();
$DB->Close();





// 静态页管理
function manage(){
	global $DB,$MB,$skin,$mudi,$dataType,$dataTypeCN,$pageCount,$recordCount,$systemArr,$userSysArr,$infoSysArr;

	$dataTypeCN		= '限制阅读记录';
	$dataMode		= OT::GetStr('dataMode');
	$dataModeStr	= OT::GetStr('dataModeStr');

	$refType		= OT::GetRegExpStr('refType','sql');
	$refUsername	= OT::GetRegExpStr('refUsername','sql');
	$refDataName	= OT::GetRegExpStr('refDataName','sql');
	$refDataID		= OT::GetInt('refDataID');
	$refNote		= OT::GetRegExpStr('refNote','sql');
	$refDate1		= OT::GetStr('refDate1');
		if (! strtotime($refDate1)){ $refDate1=''; }
	$refDate2		= OT::GetStr('refDate2');
		if (! strtotime($refDate2)){ $refDate2=''; }

	$SQLstr='select * from '. OT_dbPref .'infoPayData where 1=1';

	if ($refType != ''){ $SQLstr .= " and IPD_type=". $DB->ForStr($refType); }
	if ($refUsername != ''){ $SQLstr .= " and IPD_username like '%". $DB->ForStr($refUsername,false) ."%'"; }
	if ($refDataName != ''){ $SQLstr .= " and IPD_dataName like '%". $DB->ForStr($refDataName,false) ."%'"; }
	if ($refDataID > 0){ $SQLstr .= " and IPD_dataID=". $refDataID; }else{ $refDataID = ''; }
	if ($refNote != ''){ $SQLstr .= " and IPD_note like '%". $DB->ForStr($refNote,false) ."%'"; }
	if ($refDate1 != ''){ $SQLstr .= ' and IPD_time>='. $DB->ForTime($refDate1); }
	if ($refDate2 != ''){ $SQLstr .= ' and IPD_time<='. $DB->ForTime(TimeDate::Add('d',1,$refDate2)); }

	echo(AdmArea::TopBackBtn('info.php?mudi=manage&dataType=news&dataTypeCN=%E6%96%87%E7%AB%A0', '返回 文章管理'));

	$skin->TableTop('share_refer.gif','',$dataTypeCN .'查询');
		echo('
		<form id="refForm" name="refForm" method="get" action="">
		<input type="hidden" name="mudi" value="'. $mudi .'" />
		<input type="hidden" name="dataMode" value="'. $dataMode .'" />
		<input type="hidden" name="dataModeStr" value="'. $dataModeStr .'" />
		<input type="hidden" name="dataType" value="'. $dataType .'" />
		<input type="hidden" name="dataTypeCN" value="'. $dataTypeCN .'" />

		<table align="center" style="width:95%;" border="0" cellSpacing="0" cellPadding="0" summary="" class="padd5td">
		<tr>
			<td>
				类型：<select id="refType" name="refType">
					<option value=""></option>
					<option value="score" '. Is::Selected($refType,'score') .'>会员积分</option>
					<option value="quick" '. Is::Selected($refType,'quick') .'>直接支付</option>
					<option value="pwd" '. Is::Selected($refType,'pwd') .'>密码查看</option>
				</select>
			</td>
			<td>
				&ensp;&ensp;会员名：<input type="text" name="refUsername" size="20" style="width:120px;" value="'. $refUsername .'" />
			</td>
			<td>
				文章标题：<input type="text" name="refDataName" size="20" style="width:175px;" value="'. $refDataName .'" />&ensp;&ensp;
				ID：<input type="text" name="refDataID" size="6" value="'. $refDataID .'" />
			</td>
		</tr>
		<tr>
			<td>
				备注：<input type="text" name="refNote" size="20" value="'. $refNote .'" />
			</td>
			<td>

			</td>
			<td>
				发布日期：<input type="text" name="refDate1" size="10" style="width:100px;" value="'. $refDate1 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />&ensp;
				至&ensp;<input type="text" name="refDate2" size="10" style="width:100px;" value="'. $refDate2 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />
			</td>
		</tr>
		<tr>
			<td align="center" style="padding:5px;padding-top:20px" colspan="3">
				<input type="image" src="'. AdmTpl::ImgSrc('button_refer') .'" />
				&ensp;&ensp;&ensp;&ensp;
				<img src="'. AdmTpl::ImgSrc('button_reset') .'" onclick=\'document.location.href="?mudi='. $mudi .'&dataMode='. $dataMode .'&dataModeStr='. $dataModeStr .'&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'"\' style="cursor:pointer;" alt="" />
			</td>
		</tr>
		</table>
		</form>
		');
	$skin->TableBottom();

	echo('
	<br />

	<form id="listForm" name="listForm" method="post" action="infoPayData_deal.php?mudi=moreDel" onsubmit="return CheckListForm()">
	<script language="javascript" type="text/javascript">document.write (\'<input type="hidden" name="backURL" value="\'+ document.location.href +\'" />\')</script>
	<input type="hidden" name="dataType" value="'. $dataType .'" />
	<input type="hidden" name="dataTypeCN" value="'. $dataTypeCN .'" />
	');

	$skin->TableTop2('share_list.gif','',$dataTypeCN .'列表');
	$skin->TableItemTitle('4%,5%,8%,12%,29%,25%,10%,6%','<input type="checkbox" id="selAll" name="selAll" onclick="CheckBoxAll()" />,序号,类型,用户名,文章标题,备注,发生时间,删除');

	$pageSize	= $MB->mMbRow['MB_itemNum'];		//每页条数
	$page		= OT::GetInt('page');
	$showRow=$DB->GetLimit($SQLstr .' order by IPD_ID DESC',$pageSize,$page);
	if (! $showRow){
		$skin->TableNoData('暂无内容');
	}else{
		$recordCount=$DB->GetRowCount();
		$pageCount=ceil($recordCount/$pageSize);
		if ($page < 1 || $page > $pageCount){$page=1;}

		echo('
		<tbody class="tabBody padd3td">
		');
		$number=1+($page-1)*$pageSize;
		$rowCount = count($showRow);
		for ($i=0; $i<$rowCount; $i++){
			if ($i % 2 == 1){ $bgcolor='class="tabColorTr"'; }else{ $bgcolor=''; }
	
			echo('
			<tr '. $bgcolor .' id="data'. $showRow[$i]['IPD_ID'] .'">
				<td align="center" class="selCheckbox"><input type="checkbox" name="selDataID[]" value="'. $showRow[$i]['IPD_ID'] .'" /></td>
				<td align="center">'. $number .'</td>
				<td align="center">'. TypeCN($showRow[$i]['IPD_type2']) .'</td>
				<td align="center">'. $showRow[$i]['IPD_username'] . AdmArea::UserInfoImg($showRow[$i]['IPD_userID']) .'</td>
				<td align="center">['. $showRow[$i]['IPD_dataID'] .']'. $showRow[$i]['IPD_dataName'] .'&ensp;<a href="../news/?'. $showRow[$i]['IPD_dataID'] .'.html&rnd=user'. $showRow[$i]['IPD_userID'] .'" target="_blank" class="font2_2">[预览]</a></td>
				<td align="center">'. $showRow[$i]['IPD_note'] .'</td>
				<td align="center">'. $showRow[$i]['IPD_time'] .'</td>
				<td align="center">
					<img src="images/img_del.gif" style="cursor:pointer" onclick=\'if(confirm("你确定要删除['. $showRow[$i]['IPD_username'] .']“'. $showRow[$i]['IPD_dataName'] .'”？")==true){DataDeal.location.href="infoPayData_deal.php?mudi=del&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&theme=&dataID='. $showRow[$i]['IPD_ID'] .'"}\' alt="删除" title="删除" />
				</td>
			</tr>
			');
			$number ++;
		}
		echo('
		</tbody>
		<tr class="tabColorB padd5">
			<td align="left" colspan="20">
				<input type="button" value="全选" class="tabBottomBtn allSel" onclick="AllSelBox()" />
				<input type="button" value="反选" class="tabBottomBtn revSel" onclick="RevSelBox()" />
				&ensp;
				<input type="submit" value="批量删除" class="tabBottomBtn del" />
			</td>
		</tr>
		');
	}
	unset($showRow);

	echo('</form>');

	$skin->TableBottom2($pageCount, $pageSize, $recordCount);
}


function TypeCN($str){
	switch ($str){
		case 'score':	return '会员积分';
		case 'quick':	return '直接支付';
		case 'pwd':		return '密码查看';
		case 'ad':		return '广告奖励';
		default:		return $str;
	}

}

?>