<?php
$admin_operate = '';
$where = $pageitem = array();
$group_default = $user_default = $catgory_default = $siteid_default = "";
$totalrecords = 0;
$starttime = $endtime = date("Y-m-d");
$user_menu = $date_menu = $site_menu = $group_menu = $bd_shoulu_menu = $outside_menu = $siteid_menu = $category_menu = "";
$user_menu_array = $date_menu_array = $site_menu_array = $group_menu_array = array();
$users = $db->select_date('user');
foreach($users as $user)
$user_menu_array[$user['id']] = $user['truename'];
$date_menu_array = array('today' => '今天',
'yesterday' => '昨天',
'last7day' => '近7天',
'thisweek' => '本周',
'lastweek' => '上周',
'last30day' => '最近30天',
'thismonth' => '本月',
'lastmonth' => '上月');
$outside_menu_array = array('0' => '站内','1' => '站外');
$bd_shoulu_menu_array = array('0' => '未收录','1' => '已收录');
$group_menu_array = $user_group;
if(isset($_GET['submit'])){
if(!empty($_GET['userid']) && $_GET['userid'] !== "" && $_GET['userid'] != 'all'){
$user = $db->select_one('user',array('id' => $_GET['userid']));
if(!$user)
alert_back('没有这个用户!!!!');
$where[] = "userid = '".$_GET['userid']."'";
$user_default = intval($user['id']);
$users = $db->select_date('user',array('group' => $user['group']));
if($users)
foreach($users as $t_user)
$user_options[$t_user['id']] = $t_user['truename'];
$group_default = $user['group'];
$pageitem[] = "userid=".$user['id'];
$pageitem[] = "group=".$user['group'];
$_GET['group'] = $user['group'];
}
elseif(!empty($_GET['group']) && $_GET['group'] != 'all'){
if(!in_array($_GET['group'],$user_group))
alert_back('靠,没有这个用户组!');
$users = $db->select_date('user',array('group' => $_GET['group']));
$userids = "";
if($users){
foreach($users as $t_user){
$user_options[$t_user['id']] = $t_user['truename'];
$userids[] = $t_user['id'];
}
$userids = implode(',',$userids);
}
$where[] = "userid IN (".$userids.")";
$group_default = $_GET['group'];
$pageitem[] = "group=".$_GET['group'];
}
if(!empty($_GET['siteid']) && $_GET['siteid'] !== "" && $_GET['siteid'] != 'all' && $_GET['siteid'] != 're'){
$site = $db->select_one('site',array('id' => $_GET['siteid']));
if(!$site)
alert_back('没有这个网站!!!!');
$where[] = "siteid = '".$_GET['siteid']."'";
$siteid_default = intval($site['id']);
$sites = $db->select_date('site',array('category' => $site['category']));
if($sites)
foreach($sites as $t_site)
$site_menu_array[$t_site['id']] = $t_site['domain'];
$pageitem[] = "siteid=".$site['id'];
$pageitem[] = "category=".$site['category'];
$_GET['category'] = $site['category'];
}
elseif(!empty($_GET['category']) && $_GET['category'] != 'all'){
if(!in_array($_GET['category'],$site_categorys))
alert_back('没有这个网站分类!!!');
$category_default = $_GET['category'];
$sites = $db->select_date('site',array('category' => $_GET['category']));
$siteids = '';
if($sites){
foreach($sites as $t_site){
$siteid_options[$t_site['id']] = $t_site['domain'];
$siteids[] = $t_site['id'];
$site_menu_array[$t_site['id']] = $t_site['domain'];
}
$siteids = implode(',',$siteids);
}
if($_GET['category'] == '地王集团')
$_GET['outside'] = 0;
$where[] = "siteid IN (".$siteids.")";
$pageitem[] = "category=".$_GET['category'];
}
if(isset($_GET['outside']) && $_GET['outside'] != 'all'){
$_GET['outside'] = intval($_GET['outside']);
if($_GET['outside'] !== ''){
$where[] = "outside = ".$_GET['outside'];
$pageitem[] = "outside=".$_GET['outside'];
}
}
if(isset($_GET['bd_shoulu']) && $_GET['bd_shoulu'] != 'all'){
$_GET['bd_shoulu'] = intval($_GET['bd_shoulu']);
if($_GET['bd_shoulu'] !== ''){
$where[] = "bd_shoulu = ".$_GET['bd_shoulu'];
$pageitem[] = "bd_shoulu=".$_GET['bd_shoulu'];
}
}
$date_menu_array = array('today' => '今天',
'yesterday' => '昨天',
'last7day' => '近7天',
'thisweek' => '本周',
'lastweek' => '上周',
'last30day' => '最近30天',
'thismonth' => '本月',
'lastmonth' => '上月');
if(!empty($_GET['quickdate'])){
switch($_GET['quickdate']){
case 'all' : $_GET['starttime'] = '';
$_GET['endtime'] = '';
break;
case 'today' : $_GET['starttime'] = date('Y-m-d');
$_GET['endtime'] = date('Y-m-d');
break;
case 'yesterday' : $_GET['starttime'] = date('Y-m-d',time() - 24 * 3600);
$_GET['endtime'] = date('Y-m-d',time() - 24 * 3600);
break;
case 'last7day' : $_GET['starttime'] = date('Y-m-d',time() - 7 * 24 * 3600);
$_GET['endtime'] = date('Y-m-d');
break;
case 'last30day' : $_GET['starttime'] = date('Y-m-d',time() - 30 * 24 * 3600);
$_GET['endtime'] = date('Y-m-d');
break;
case 'thisweek' : $week = intval(date('w'));
if($week == 0)
$_GET['starttime'] = date('Y-m-d');
else
$_GET['starttime'] = date('Y-m-d',time() - $week * 24 * 3600);
$_GET['endtime'] = date('Y-m-d');
break;
case 'lastweek' : $week = intval(date('w'));
$_GET['endtime'] = date('Y-m-d',time() - ($week + 1) * 24 * 3600);
$_GET['starttime'] = date('Y-m-d',time() - ($week + 8) * 24 * 3600);
break;
case 'thismonth' : $day = intval(date('j'));
$_GET['starttime'] = date('Y-m-d',time() - ($day - 1) * 24 * 3600);
$_GET['endtime'] = date('Y-m-d');
break;
case 'lastmonth' : $day = intval(date('j'));
$_GET['endtime'] = date('Y-m-d',time() - $day * 24 * 3600);
$endtime = @mktime(0,0,0,date('m',$_GET['endtime']),date('d',$_GET['endtime']),date('Y',$_GET['endtime']));
$days = date('t',$endtime);
$_GET['starttime'] = date('Y-m-d',time() - ($day + $days - 1) * 24 * 3600);
break;
default : break;
}
$pageitem[] = "quickdate=".$_GET['quickdate'];
}
if(!empty($_POST['starttime'])){
$_GET['starttime'] = $_POST['starttime'];
$_GET['quickdate'] = '';
}
if(!empty($_POST['endtime'])){
$_GET['endtime'] = $_POST['endtime'];
$_GET['quickdate'] = '';
}
if(!empty($_GET['starttime'])){
$starttime = $_GET['starttime'];
$starttime2 = explode('-',$starttime);
$starttime2 = mktime(0,0,0,$starttime2[1],$starttime2[2],$starttime2[0]);
$where[] = "time > ".$starttime2;
$pageitem[] = "starttime=".$_GET['starttime'];
}
if(!empty($_GET['endtime'])){
$endtime = $_GET['endtime'];
$endtime2 = explode('-',$endtime);
$endtime2 = mktime(23,59,59,$endtime2[1],$endtime2[2],$endtime2[0]);
$where[] = "time <= ".$endtime2;
$pageitem[] = "endtime=".$_GET['endtime'];
}
}
else{
}
$pageurlmore = '';
if(!empty($pageitem))
$pageurlmore = implode('&',$pageitem);
$pageurl = "?m=query&o=link&submit=1&".$pageurlmore;
$category_menu = @create_menu($pageurl,'category',$site_categorys,$_GET['category'],1,"&siteid=all");
$user_menu = @create_menu($pageurl,'userid',$user_menu_array,intval($_GET['userid']),2);
$date_menu = @create_menu($pageurl,'quickdate',$date_menu_array,$_GET['quickdate'],2);
$siteid_menu = @create_menu($pageurl,'siteid',$site_menu_array,intval($_GET['siteid']),2);
$group_menu = @create_menu($pageurl,'group',$group_menu_array,$_GET['group'],1,'&userid=all');
$bd_shoulu_menu = @create