<?php

/*
'**************************************************************************************************
' 程序名称: CCTVAI开源音乐管理系统
' 官方网站: http://www.cctvai.com
' 联系 Q Q: 1542367792
' QQ交流群：136687984
' 版本：(终结版)
' 备注：未经书面授权，不得向任何第三方提供本软件系统！
' 功能，模板，插件，扩展，定制请联系QQ：1542367792
'**************************************************************************************************
*/
error_reporting(0);
include "../../include/cctvai.conn.php";
include "../function_common.php";
admincheck(9);
/*if(Smallfivesolution() == $_SERVER['SERVER_NAME']) {
} else {
    echo Smallfivesq();
    exit();
}*/
set_time_limit(0);
@ini_set('memory_limit', '-1');
$action=SafeRequest("action", "get");
if($action=="dj") {
	echo "<style type='text/css'><!--body,td,th {background-color: #FFFFFF;font-size: 9pt;}a {font-size: 9pt;}a:link {text-decoration: none;color:#3F628C;}a:visited {text-decoration: none;color:#3F628C;}a:hover {text-decoration: none;color:#3F628C;}a:active {text-decoration: none;color:#3F628C;}--></style>";
	global $db;
	$shits=SafeRequest("start_hits", "post");
	$ehits=SafeRequest("end_hits", "post");
	$classid=SafeRequest("ClassIDs", "post");
	$CD_Type=SafeRequest("CD_Type", "post");
	if($CD_Type==""){$CD_Type=SafeRequest("CD_Type", "get");}
	$sday=SafeRequest("sday", "auto");
	$count=SafeRequest("count", "auto");
	if(!IsNum($count))
		$count=30;
	if($classid=="") {
		$classid=SafeRequest("classid", "get");
	}
	$page=SafeRequest("pages", "get");
	if(!IsNum($page))
		$page=1;
	if(!IsNum($shits))
		$shits=1;
	if(!IsNum($ehits))
		$ehits=1000;
	if($page!=1) {
		$shits=SafeRequest("start_hits", "get");
		$ehits=SafeRequest("end_hits", "get");
		$classid=SafeRequest("classid", "get");
	}

	if($classid==0) {
		if(IsNul($sday)) {
			$sql="select * from " . tname('dj') . " where DATEDIFF(DATE(CD_AddTime),'" . date('Y-m-d') . "')>=-$sday order by CD_ID desc";
		} else {
			$sql="select * from " . tname('dj') . " order by CD_ID desc";
		}

	} else {
		if(IsNul($sday)) {
			$sql="select * from " . tname('dj') . " where CD_ClassID=" . $classid . " and DATEDIFF(DATE(CD_AddTime),'" . date('Y-m-d') . "')>=-$sday order by CD_ID desc";
		} else {
			$sql="select * from " . tname('dj') . " where CD_ClassID=" . $classid . " order by CD_ID desc";
		}
	}

	$Arr=getpagerow($sql, $count); //sql,每页显示条数
	$result=$db->query($Arr[2]);
	if($result) {
		echo ("<div style='width:100%; background: #FAFBF7; border-top:1px solid #ddd; border-bottom:1px solid #ddd;color:#668E1B; font-size:10pt; height:30px; line-height:30px;font-weight:bold; margin:0 auto;'>&nbsp;正在随机更改歌曲【".$CD_Type."】第<font style='color:red; font-size:15px; font-style:italic'>" . $page . "</font>页，共<font style='color:red; font-size:15px; font-style:italic'>" . $Arr[3] . "</font>页</div><br/>");
		while($row=$db->fetch_array($result)) {
			$CD_Hits=mt_rand($shits, $ehits);
			$sql2="update " . tname('dj') . " set $CD_Type=" . $CD_Hits . " where CD_ID=" . $row['CD_ID'] . "";
			$db->query($sql2);
			echo "&nbsp;歌曲：<font style=font-size:12px;><a href=" . LinkUrl("dj", $row['CD_ClassID'], 1, $row['CD_ID']) . " target=_blank><font color=red>" . $row['CD_Name'] . "</font></a>&nbsp;&nbsp;的【".$CD_Type."】更改为 <font color=red>" . $CD_Hits . "</font> 了</font><br/>";
		}
		if($page>=$Arr[3]) {
			die("<br/>&nbsp;<font style=font-size:10pt;><b>恭喜您，所有的随机歌曲数据更改完毕！</b></font><script language='javascript'>alert('恭喜您，所有的随机歌曲数据更改完毕！');</script>");
		} else {
			die("<br/>&nbsp;<font style=font-size:10pt;><b>为了节约系统资源，将暂停 " . cd_stoptime . " 秒后继续随机更改数据，请不要关闭或刷新...</font></b><script language='javascript'>setTimeout('ReadGo();'," . (cd_stoptime*1000) . ");function ReadGo(){location.href='?action=dj&pages=" . ($page+1) . "&classid=" . $classid . "&CD_Type=".$CD_Type."&start_hits=" . $shits . "&end_hits=" . $ehits . "&sday=" . $sday . "&count=" . $count . "';}</script>");
		}
	}
} elseif($action=="video") {
	echo "<style type='text/css'><!--body,td,th {background-color: #FFFFFF;font-size: 9pt;}a {font-size: 9pt;}a:link {text-decoration: none;color:#3F628C;}a:visited {text-decoration: none;color:#3F628C;}a:hover {text-decoration: none;color:#3F628C;}a:active {text-decoration: none;color:#3F628C;}--></style>";
	global $db;
	$shits=SafeRequest("start_hits", "post");
	$ehits=SafeRequest("end_hits", "post");
	$classid=SafeRequest("ClassIDs", "post");
	$CD_Type=SafeRequest("CD_Type", "post");
	if($CD_Type==""){$CD_Type=SafeRequest("CD_Type", "get");}
	$sday=SafeRequest("sday", "auto");
	$count=SafeRequest("count", "auto");
	if(!IsNum($count))
		$count=30;
	if($classid=="") {
		$classid=SafeRequest("classid", "get");
	}
	$page=SafeRequest("pages", "get");
	if(!IsNum($page))
		$page=1;
	if(!IsNum($shits))
		$shits=1;
	if(!IsNum($ehits))
		$ehits=1000;
	if($page!=1) {
		$shits=SafeRequest("start_hits", "get");
		$ehits=SafeRequest("end_hits", "get");
		$classid=SafeRequest("classid", "get");
	}

	if($classid==0) {
		if(IsNul($sday)) {
			$sql="select * from " . tname('video') . " where DATEDIFF(DATE(CD_AddTime),'" . date('Y-m-d') . "')>=-$sday order by CD_ID desc";
		} else {
			$sql="select * from " . tname('video') . " order by CD_ID desc";
		}

	} else {
		if(IsNul($sday)) {
			$sql="select * from " . tname('video') . " where CD_ClassID=" . $classid . " and DATEDIFF(DATE(CD_AddTime),'" . date('Y-m-d') . "')>=-$sday order by CD_ID desc";
		} else {
			$sql="select * from " . tname('video') . " where CD_ClassID=" . $classid . " order by CD_ID desc";
		}
	}

	$Arr=getpagerow($sql, $count); //sql,每页显示条数
	$result=$db->query($Arr[2]);
	if($result) {
		echo ("<div style='width:100%; background: #FAFBF7; border-top:1px solid #ddd; border-bottom:1px solid #ddd;color:#668E1B; font-size:10pt; height:30px; line-height:30px;font-weight:bold; margin:0 auto;'>&nbsp;正在随机更改视频【".$CD_Type."】第<font style='color:red; font-size:15px; font-style:italic'>" . $page . "</font>页，共<font style='color:red; font-size:15px; font-style:italic'>" . $Arr[3] . "</font>页</div><br/>");
		while($row=$db->fetch_array($result)) {
			$CD_Hits=mt_rand($shits, $ehits);
			$sql2="update " . tname('video') . " set $CD_Type=" . $CD_Hits . " where CD_ID=" . $row['CD_ID'] . "";
			$db->query($sql2);
			echo "&nbsp;视频：<font style=font-size:12px;><a href=" . LinkUrl("video", $row['CD_ClassID'], 1, $row['CD_ID']) . " target=_blank><font color=red>" . $row['CD_Name'] . "</font></a>&nbsp;&nbsp;的【".$CD_Type."】更改为 <font color=red>" . $CD_Hits . "</font> 了</font><br/>";
		}
		if($page>=$Arr[3]) {
			die("<br/>&nbsp;<font style=font-size:10pt;><b>恭喜您，所有的随机视频数据更改完毕！</b></font><script language='javascript'>alert('恭喜您，所有的随机视频数据更改完毕！');</script>");
		} else {
			die("<br/>&nbsp;<font style=font-size:10pt;><b>为了节约系统资源，将暂停 " . cd_stoptime . " 秒后继续随机更改人气，请不要关闭或刷新...</font></b><script language='javascript'>setTimeout('ReadGo();'," . (cd_stoptime*1000) . ");function ReadGo(){location.href='?action=video&pages=" . ($page+1) . "&classid=" . $classid . "&CD_Type=".$CD_Type."&start_hits=" . $shits . "&end_hits=" . $ehits . "&sday=" . $sday . "&count=" . $count . "';}</script>");
		}
	}
} elseif($action=="singer") {
	echo "<style type='text/css'><!--body,td,th {background-color: #FFFFFF;font-size: 9pt;}a {font-size: 9pt;}a:link {text-decoration: none;color:#3F628C;}a:visited {text-decoration: none;color:#3F628C;}a:hover {text-decoration: none;color:#3F628C;}a:active {text-decoration: none;color:#3F628C;}--></style>";
	global $db;
	$shits=SafeRequest("start_hits", "post");
	$ehits=SafeRequest("end_hits", "post");
	$classid=SafeRequest("ClassIDs", "post");
	$sday=SafeRequest("sday", "auto");
	$count=SafeRequest("count", "auto");
	if(!IsNum($count))
		$count=30;
	if($classid=="") {
		$classid=SafeRequest("classid", "get");
	}
	$page=SafeRequest("pages", "get");
	if(!IsNum($page))
		$page=1;
	if(!IsNum($shits))
		$shits=1;
	if(!IsNum($ehits))
		$ehits=1000;
	if($page!=1) {
		$shits=SafeRequest("start_hits", "get");
		$ehits=SafeRequest("end_hits", "get");
		$classid=SafeRequest("classid", "get");
	}

	if($classid==0) {
		if(IsNul($sday)) {
			$sql="select * from " . tname('singer') . " where DATEDIFF(DATE(CD_AddTime),'" . date('Y-m-d') . "')>=-$sday order by CD_ID desc";
		} else {
			$sql="select * from " . tname('singer') . " order by CD_ID desc";
		}

	} else {
		if(IsNul($sday)) {
			$sql="select * from " . tname('singer') . " where CD_ClassID=" . $classid . " and DATEDIFF(DATE(CD_AddTime),'" . date('Y-m-d') . "')>=-$sday order by CD_ID desc";
		} else {
			$sql="select * from " . tname('singer') . " where CD_ClassID=" . $classid . " order by CD_ID desc";
		}
	}

	$Arr=getpagerow($sql, $count); //sql,每页显示条数
	$result=$db->query($Arr[2]);
	if($result) {
		echo ("<div style='width:100%; background: #FAFBF7; border-top:1px solid #ddd; border-bottom:1px solid #ddd;color:#668E1B; font-size:10pt; height:30px; line-height:30px;font-weight:bold; margin:0 auto;'>&nbsp;正在随机更改歌手人气第<font style='color:red; font-size:15px; font-style:italic'>" . $page . "</font>页，共<font style='color:red; font-size:15px; font-style:italic'>" . $Arr[3] . "</font>页</div><br/>");
		while($row=$db->fetch_array($result)) {
			$CD_Hits=mt_rand($shits, $ehits);
			$sql2="update " . tname('singer') . " set CD_Hits=" . $CD_Hits . " where CD_ID=" . $row['CD_ID'] . "";
			$db->query($sql2);
			echo "&nbsp;歌手：<font style=font-size:12px;><a href=" . LinkUrl("singer", $row['CD_ClassID'], 1, $row['CD_ID']) . " target=_blank><font color=red>" . $row['CD_Name'] . "</font></a>&nbsp;&nbsp;的人气更改为 <font color=red>" . $CD_Hits . "</font> 了</font><br/>";
		}
		if($page>=$Arr[3]) {
			die("<br/>&nbsp;<font style=font-size:10pt;><b>恭喜您，所有的随机歌手人气更改完毕！</b></font><script language='javascript'>alert('恭喜您，所有的随机歌手人气更改完毕！');</script>");
		} else {
			die("<br/>&nbsp;<font style=font-size:10pt;><b>为了节约系统资源，将暂停 " . cd_stoptime . " 秒后继续随机更改人气，请不要关闭或刷新...</font></b><script language='javascript'>setTimeout('ReadGo();'," . (cd_stoptime*1000) . ");function ReadGo(){location.href='?action=singer&pages=" . ($page+1) . "&classid=" . $classid . "&start_hits=" . $shits . "&end_hits=" . $ehits . "&sday=" . $sday . "&count=" . $count . "';}</script>");
		}
	}
} elseif($action=="malbum") {
	echo "<style type='text/css'><!--body,td,th {background-color: #FFFFFF;font-size: 9pt;}a {font-size: 9pt;}a:link {text-decoration: none;color:#3F628C;}a:visited {text-decoration: none;color:#3F628C;}a:hover {text-decoration: none;color:#3F628C;}a:active {text-decoration: none;color:#3F628C;}--></style>";
	global $db;
	$shits=SafeRequest("start_hits", "post");
	$ehits=SafeRequest("end_hits", "post");
	$classid=SafeRequest("ClassIDs", "post");
	$sday=SafeRequest("sday", "auto");
	$count=SafeRequest("count", "auto");
	if(!IsNum($count))
		$count=30;
	if($classid=="") {
		$classid=SafeRequest("classid", "get");
	}
	$page=SafeRequest("pages", "get");
	if(!IsNum($page))
		$page=1;
	if(!IsNum($shits))
		$shits=1;
	if(!IsNum($ehits))
		$ehits=1000;
	if($page!=1) {
		$shits=SafeRequest("start_hits", "get");
		$ehits=SafeRequest("end_hits", "get");
		$classid=SafeRequest("classid", "get");
	}

	if($classid==0) {
		if(IsNul($sday)) {
			$sql="select * from " . tname('malbum') . " where DATEDIFF(DATE(CD_AddTime),'" . date('Y-m-d') . "')>=-$sday order by CD_ID desc";
		} else {
			$sql="select * from " . tname('malbum') . " order by CD_ID desc";
		}

	} else {
		if(IsNul($sday)) {
			$sql="select * from " . tname('malbum') . " where CD_ClassID=" . $classid . " and DATEDIFF(DATE(CD_AddTime),'" . date('Y-m-d') . "')>=-$sday order by CD_ID desc";
		} else {
			$sql="select * from " . tname('malbum') . " where CD_ClassID=" . $classid . " order by CD_ID desc";
		}
	}

	$Arr=getpagerow($sql, $count); //sql,每页显示条数
	$result=$db->query($Arr[2]);
	if($result) {
		echo ("<div style='width:100%; background: #FAFBF7; border-top:1px solid #ddd; border-bottom:1px solid #ddd;color:#668E1B; font-size:10pt; height:30px; line-height:30px;font-weight:bold; margin:0 auto;'>&nbsp;正在随机更改音乐专辑人气第<font style='color:red; font-size:15px; font-style:italic'>" . $page . "</font>页，共<font style='color:red; font-size:15px; font-style:italic'>" . $Arr[3] . "</font>页</div><br/>");
		while($row=$db->fetch_array($result)) {
			$CD_Hits=mt_rand($shits, $ehits);
			$sql2="update " . tname('malbum') . " set CD_Hits=" . $CD_Hits . " where CD_ID=" . $row['CD_ID'] . "";
			$db->query($sql2);
			echo "&nbsp;音乐专辑：<font style=font-size:12px;><a href=" . LinkUrl("malbum", $row['CD_ClassID'], 1, $row['CD_ID']) . " target=_blank><font color=red>" . $row['CD_Name'] . "</font></a>&nbsp;&nbsp;的人气更改为 <font color=red>" . $CD_Hits . "</font> 了</font><br/>";
		}
		if($page>=$Arr[3]) {
			die("<br/>&nbsp;<font style=font-size:10pt;><b>恭喜您，所有的随机音乐专辑人气更改完毕！</b></font><script language='javascript'>alert('恭喜您，所有的随机音乐专辑人气更改完毕！');</script>");
		} else {
			die("<br/>&nbsp;<font style=font-size:10pt;><b>为了节约系统资源，将暂停 " . cd_stoptime . " 秒后继续随机更改人气，请不要关闭或刷新...</font></b><script language='javascript'>setTimeout('ReadGo();'," . (cd_stoptime*1000) . ");function ReadGo(){location.href='?action=malbum&pages=" . ($page+1) . "&classid=" . $classid . "&start_hits=" . $shits . "&end_hits=" . $ehits . "&sday=" . $sday . "&count=" . $count . "';}</script>");
		}
	}
} elseif($action=="valbum") {
	echo "<style type='text/css'><!--body,td,th {background-color: #FFFFFF;font-size: 9pt;}a {font-size: 9pt;}a:link {text-decoration: none;color:#3F628C;}a:visited {text-decoration: none;color:#3F628C;}a:hover {text-decoration: none;color:#3F628C;}a:active {text-decoration: none;color:#3F628C;}--></style>";
	global $db;
	$shits=SafeRequest("start_hits", "post");
	$ehits=SafeRequest("end_hits", "post");
	$classid=SafeRequest("ClassIDs", "post");
	$sday=SafeRequest("sday", "auto");
	$count=SafeRequest("count", "auto");
	if(!IsNum($count))
		$count=30;
	if($classid=="") {
		$classid=SafeRequest("classid", "get");
	}
	$page=SafeRequest("pages", "get");
	if(!IsNum($page))
		$page=1;
	if(!IsNum($shits))
		$shits=1;
	if(!IsNum($ehits))
		$ehits=1000;
	if($page!=1) {
		$shits=SafeRequest("start_hits", "get");
		$ehits=SafeRequest("end_hits", "get");
		$classid=SafeRequest("classid", "get");
	}

	if($classid==0) {
		if(IsNul($sday)) {
			$sql="select * from " . tname('valbum') . " where DATEDIFF(DATE(CD_AddTime),'" . date('Y-m-d') . "')>=-$sday order by CD_ID desc";
		} else {
			$sql="select * from " . tname('valbum') . " order by CD_ID desc";
		}

	} else {
		if(IsNul($sday)) {
			$sql="select * from " . tname('valbum') . " where CD_ClassID=" . $classid . " and DATEDIFF(DATE(CD_AddTime),'" . date('Y-m-d') . "')>=-$sday order by CD_ID desc";
		} else {
			$sql="select * from " . tname('valbum') . " where CD_ClassID=" . $classid . " order by CD_ID desc";
		}
	}

	$Arr=getpagerow($sql, $count); //sql,每页显示条数
	$result=$db->query($Arr[2]);
	if($result) {
		echo ("<div style='width:100%; background: #FAFBF7; border-top:1px solid #ddd; border-bottom:1px solid #ddd;color:#668E1B; font-size:10pt; height:30px; line-height:30px;font-weight:bold; margin:0 auto;'>&nbsp;正在随机更改视频专辑人气第<font style='color:red; font-size:15px; font-style:italic'>" . $page . "</font>页，共<font style='color:red; font-size:15px; font-style:italic'>" . $Arr[3] . "</font>页</div><br/>");
		while($row=$db->fetch_array($result)) {
			$CD_Hits=mt_rand($shits, $ehits);
			$sql2="update " . tname('valbum') . " set CD_Hits=" . $CD_Hits . " where CD_ID=" . $row['CD_ID'] . "";
			$db->query($sql2);
			echo "&nbsp;视频专辑：<font style=font-size:12px;><a href=" . LinkUrl("valbum", $row['CD_ClassID'], 1, $row['CD_ID']) . " target=_blank><font color=red>" . $row['CD_Name'] . "</font></a>&nbsp;&nbsp;的人气更改为 <font color=red>" . $CD_Hits . "</font> 了</font><br/>";
		}
		if($page>=$Arr[3]) {
			die("<br/>&nbsp;<font style=font-size:10pt;><b>恭喜您，所有的随机视频专辑人气更改完毕！</b></font><script language='javascript'>alert('恭喜您，所有的随机视频专辑人气更改完毕！');</script>");
		} else {
			die("<br/>&nbsp;<font style=font-size:10pt;><b>为了节约系统资源，将暂停 " . cd_stoptime . " 秒后继续随机更改人气，请不要关闭或刷新...</font></b><script language='javascript'>setTimeout('ReadGo();'," . (cd_stoptime*1000) . ");function ReadGo(){location.href='?action=valbum&pages=" . ($page+1) . "&classid=" . $classid . "&start_hits=" . $shits . "&end_hits=" . $ehits . "&sday=" . $sday . "&count=" . $count . "';}</script>");
		}
	}
} elseif($action=="news") {
	echo "<style type='text/css'><!--body,td,th {background-color: #FFFFFF;font-size: 9pt;}a {font-size: 9pt;}a:link {text-decoration: none;color:#3F628C;}a:visited {text-decoration: none;color:#3F628C;}a:hover {text-decoration: none;color:#3F628C;}a:active {text-decoration: none;color:#3F628C;}--></style>";
	global $db;
	$shits=SafeRequest("start_hits", "post");
	$ehits=SafeRequest("end_hits", "post");
	$classid=SafeRequest("ClassIDs", "post");
	$sday=SafeRequest("sday", "auto");
	$count=SafeRequest("count", "auto");
	if(!IsNum($count))
		$count=30;
	if($classid=="") {
		$classid=SafeRequest("classid", "get");
	}
	$page=SafeRequest("pages", "get");
	if(!IsNum($page))
		$page=1;
	if(!IsNum($shits))
		$shits=1;
	if(!IsNum($ehits))
		$ehits=1000;
	if($page!=1) {
		$shits=SafeRequest("start_hits", "get");
		$ehits=SafeRequest("end_hits", "get");
		$classid=SafeRequest("classid", "get");
	}

	if($classid==0) {
		if(IsNul($sday)) {
			$sql="select * from " . tname('news') . " where DATEDIFF(DATE(CD_AddTime),'" . date('Y-m-d') . "')>=-$sday order by CD_ID desc";
		} else {
			$sql="select * from " . tname('news') . " order by CD_ID desc";
		}

	} else {
		if(IsNul($sday)) {
			$sql="select * from " . tname('news') . " where CD_ClassID=" . $classid . " and DATEDIFF(DATE(CD_AddTime),'" . date('Y-m-d') . "')>=-$sday order by CD_ID desc";
		} else {
			$sql="select * from " . tname('news') . " where CD_ClassID=" . $classid . " order by CD_ID desc";
		}
	}

	$Arr=getpagerow($sql, $count); //sql,每页显示条数
	$result=$db->query($Arr[2]);
	if($result) {
		echo ("<div style='width:100%; background: #FAFBF7; border-top:1px solid #ddd; border-bottom:1px solid #ddd;color:#668E1B; font-size:10pt; height:30px; line-height:30px;font-weight:bold; margin:0 auto;'>&nbsp;正在随机更改文章人气第<font style='color:red; font-size:15px; font-style:italic'>" . $page . "</font>页，共<font style='color:red; font-size:15px; font-style:italic'>" . $Arr[3] . "</font>页</div><br/>");
		while($row=$db->fetch_array($result)) {
			$CD_Hits=mt_rand($shits, $ehits);
			$sql2="update " . tname('news') . " set CD_Hits=" . $CD_Hits . " where CD_ID=" . $row['CD_ID'] . "";
			$db->query($sql2);
			echo "&nbsp;文章：<font style=font-size:12px;><a href=" . LinkUrl("news", $row['CD_ClassID'], 1, $row['CD_ID']) . " target=_blank><font color=red>" . $row['CD_Name'] . "</font></a>&nbsp;&nbsp;的人气更改为 <font color=red>" . $CD_Hits . "</font> 了</font><br/>";
		}
		if($page>=$Arr[3]) {
			die("<br/>&nbsp;<font style=font-size:10pt;><b>恭喜您，所有的随机文章人气更改完毕！</b></font><script language='javascript'>alert('恭喜您，所有的随机文章人气更改完毕！');</script>");
		} else {
			die("<br/>&nbsp;<font style=font-size:10pt;><b>为了节约系统资源，将暂停 " . cd_stoptime . " 秒后继续随机更改人气，请不要关闭或刷新...</font></b><script language='javascript'>setTimeout('ReadGo();'," . (cd_stoptime*1000) . ");function ReadGo(){location.href='?action=news&pages=" . ($page+1) . "&classid=" . $classid . "&start_hits=" . $shits . "&end_hits=" . $ehits . "&sday=" . $sday . "&count=" . $count . "';}</script>");
		}
	}
} elseif($action=="user") {
	echo "<style type='text/css'><!--body,td,th {background-color: #FFFFFF;font-size: 9pt;}a {font-size: 9pt;}a:link {text-decoration: none;color:#3F628C;}a:visited {text-decoration: none;color:#3F628C;}a:hover {text-decoration: none;color:#3F628C;}a:active {text-decoration: none;color:#3F628C;}--></style>";
	global $db;
	$shits=SafeRequest("start_hits", "post");
	$ehits=SafeRequest("end_hits", "post");
	$classid=SafeRequest("ClassIDs", "post");
	$sday=SafeRequest("sday", "auto");
	$count=SafeRequest("count", "auto");
	if(!IsNum($count))
		$count=30;
	if($classid=="") {
		$classid=SafeRequest("classid", "get");
	}
	$page=SafeRequest("pages", "get");
	if(!IsNum($page))
		$page=1;
	if(!IsNum($shits))
		$shits=1;
	if(!IsNum($ehits))
		$ehits=1000;
	if($page!=1) {
		$shits=SafeRequest("start_hits", "get");
		$ehits=SafeRequest("end_hits", "get");
		$classid=SafeRequest("classid", "get");
	}

	if($classid==0) {
		$sql="select * from " . tname('user') . " order by cd_id desc";
	}elseif($classid==1) {
		$sql="select * from " . tname('user') . " where cd_vipgrade=1 order by cd_id desc";
	}elseif($classid==2) {
		$sql="select * from " . tname('user') . " where cd_vipgrade=2 order by cd_id desc";
	}elseif($classid==3) {
		$sql="select * from " . tname('user') . " where cd_checkmusic=1 order by cd_id desc";
	}elseif($classid==4) {
		$sql="select * from " . tname('user') . " where cd_checkmm=1 order by cd_id desc";
	}elseif($classid==5) {
		$sql="select * from " . tname('user') . " where cd_isbest=1 order by cd_id desc";
	}else{
		$sql="select * from " . tname('user') . " order by cd_id desc";
	}
	//exit($sql);
	$Arr=getpagerow($sql, $count); //sql,每页显示条数
	$result=$db->query($Arr[2]);
	if($result) {
		echo ("<div style='width:100%; background: #FAFBF7; border-top:1px solid #ddd; border-bottom:1px solid #ddd;color:#668E1B; font-size:10pt; height:30px; line-height:30px;font-weight:bold; margin:0 auto;'>&nbsp;正在随机更改会员人气第<font style='color:red; font-size:15px; font-style:italic'>" . $page . "</font>页，共<font style='color:red; font-size:15px; font-style:italic'>" . $Arr[3] . "</font>页</div><br/>");
		while($row=$db->fetch_array($result)) {
			$CD_Hits=mt_rand($shits, $ehits);
			$sql2="update " . tname('user') . " set cd_hits=" . $CD_Hits . " where cd_id=" . $row['cd_id'] . "";
			$db->query($sql2);
			echo "&nbsp;会员：<font style=font-size:12px;><a href=" . linkweburl($row['cd_id'],$row['cd_name']) . " target=_blank><font color=red>" . $row['cd_name'] . "/" . $row['cd_nicheng'] . "</font></a>&nbsp;&nbsp;的人气更改为 <font color=red>" . $CD_Hits . "</font> 了</font><br/>";
		}
		if($page>=$Arr[3]) {
			die("<br/>&nbsp;<font style=font-size:10pt;><b>恭喜您，所有的随机会员人气更改完毕！</b></font><script language='javascript'>alert('恭喜您，所有的随机会员人气更改完毕！');</script>");
		} else {
			die("<br/>&nbsp;<font style=font-size:10pt;><b>为了节约系统资源，将暂停 " . cd_stoptime . " 秒后继续随机更改人气，请不要关闭或刷新...</font></b><script language='javascript'>setTimeout('ReadGo();'," . (cd_stoptime*1000) . ");function ReadGo(){location.href='?action=user&pages=" . ($page+1) . "&classid=" . $classid . "&start_hits=" . $shits . "&end_hits=" . $ehits . "&sday=" . $sday . "&count=" . $count . "';}</script>");
		}
	}
} else {
?>
<!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=gb2312" /> 
  <meta name="renderer" content="webkit" /> 
  <title>x5Music 管理后台</title> 
  <link rel="stylesheet" href="../css/add.css" type="text/css" media="screen" /> 
  <style type="text/css">
.table2{width: 100%;max-width: 100%;border-collapse: collapse;border-spacing: 0;}
.table2 td{font-size: 12px;border-top: 1px solid #ddd;padding: 8px;vertical-align: top;}
.table2 tr:hover{text-decoration: none;background-color: #e6f2fb;}
.table2 th{border-bottom: 2px solid #ddd;vertical-align: bottom;padding: 2px;text-align: left;}
.table3{width: 100%;max-width: 100%;border-collapse: collapse;border-spacing: 0;}
.table3 tr:hover{text-decoration: none;background-color: #e6f2fb;}
.table3 td{font-size: 12px;line-height:25px;border-top: 1px solid #ddd;padding: 5px;vertical-align: top;border-right: solid 1px #ddd;}
.table3 th{border-bottom: 2px solid #ddd;vertical-align: bottom;padding: 2px;text-align: left;}
</style> 
 </head> 
 <body> 
  <div class="contents"> 
   <div class="panel"> 
    <div class="panel-head"> 
     <strong>数据批量随机&nbsp;注：批量随机将覆盖原有数据</strong> 
    </div> 
    <table class="table3"> 
     <tbody> 
     <form method="post" name="SpanSel" action="?action=dj" target="Html_Bottom"> 
      <tr> 
       <td width="60" align="left" class="p10">音乐</td> 
       <td align="left">
&nbsp;随机范围：<input class="input input_hd length_1" type="text" size="4" name="start_hits" value="1">&nbsp;至&nbsp;<input class="input input_hd length_1" type="text" size="4" name="end_hits" value="1000">
           	    &nbsp; 选择栏目：
                <select name="ClassIDs">
                  <option value="0">所有栏目</option>
                  <?php
		$sqlclass="select * from ".tname('class')." where CD_SystemID=1 ";
		$results=$db->query($sqlclass);
		if($results){
			$classstr="";
			while ($row3=$db->fetch_array($results)){
				$classstr.="<option value=".$row3['CD_ID'].">".$row3['CD_Name']."</option>";
				}
			}
									?>
                  <?php echo $classstr?>
                </select>
                &nbsp;指定天数:
                <select name="sday">
                	<option value="">不限</option>
                    <?php
                    	for($i=1;$i<16;$i++){
							echo "<option value=\"".$i."\">".$i."天内</option>\r\n";
							}
					?>
                </select>
                &nbsp; 
                &nbsp;字段:
                <select name="CD_Type">
                	<option value="CD_Hits">CD_Hits=>总人气</option>
					<option value="CD_DayHits">CD_DayHits=>今日人气</option>
					<option value="CD_WeekHits">CD_WeekHits=>本周人气</option>
					<option value="CD_MonthHits">CD_MonthHits=>本月</option>
					<option value="CD_DownHits">CD_DownHits=>下载人气</option>
					<option value="CD_FavHits">CD_FavHits=>收藏人气</option>
					<option value="CD_uHits">CD_uHits=>顶人气</option>
					<option value="CD_dHits">CD_dHits=>踩人气</option>
                </select>
                &nbsp; 
				每页&nbsp;<input name="count" class="input input_hd length_1" type="text" size="4" value="50">&nbsp;条
                &nbsp; 
       &nbsp;<input name="submit" type="submit" class="btn mr20" value="开始随机设置人气" />
	   </td> 
      </tr> 
	 </form>
     <form method="post" name="SpanSel" action="?action=video" target="Html_Bottom"> 
      <tr> 
       <td width="60" align="left" class="p10">视频</td> 
       <td align="left">
&nbsp;随机范围：<input class="input input_hd length_1" type="text" size="4" name="start_hits" value="1">&nbsp;至&nbsp;<input class="input input_hd length_1" type="text" size="4" name="end_hits" value="1000">
           	    &nbsp; 选择栏目：
                <select name="ClassIDs">
                  <option value="0">所有栏目</option>
                  <?php
		$sqlclass="select * from ".tname('videoclass')." where CD_SystemID=1 ";
		$results=$db->query($sqlclass);
		if($results){
			$classstr="";
			while ($row3=$db->fetch_array($results)){
				$classstr.="<option value=".$row3['CD_ID'].">".$row3['CD_Name']."</option>";
				}
			}
									?>
                  <?php echo $classstr?>
                </select>
                &nbsp;指定天数:
                <select name="sday">
                	<option value="">不限</option>
                    <?php
                    	for($i=1;$i<16;$i++){
							echo "<option value=\"".$i."\">".$i."天内</option>\r\n";
							}
					?>
                </select>
                &nbsp; 
                &nbsp;字段:
                <select name="CD_Type">
                	<option value="CD_Hits">CD_Hits=>总人气</option>
					<option value="CD_DayHits">CD_DayHits=>今日人气</option>
					<option value="CD_WeekHits">CD_WeekHits=>本周人气</option>
					<option value="CD_MonthHits">CD_MonthHits=>本月</option>
					<option value="CD_DownHits">CD_DownHits=>下载人气</option>
					<option value="CD_FavHits">CD_FavHits=>收藏人气</option>
					<option value="CD_uHits">CD_uHits=>顶人气</option>
					<option value="CD_dHits">CD_dHits=>踩人气</option>
                </select>
                &nbsp; 
				每页&nbsp;<input name="count" class="input input_hd length_1" type="text" size="4" value="50">&nbsp;条
                &nbsp; 
       &nbsp;<input name="submit" type="submit" class="btn mr20" value="开始随机设置人气" />
	   </td> 
      </tr> 
	 </form>
     <form method="post" name="SpanSel" action="?action=singer" target="Html_Bottom"> 
      <tr> 
       <td width="60" align="left" class="p10">歌手</td> 
       <td align="left">
&nbsp;随机人气范围：<input class="input input_hd length_1" type="text" size="4" name="start_hits" value="1">&nbsp;至&nbsp;<input class="input input_hd length_1" type="text" size="4" name="end_hits" value="1000">
           	    &nbsp; 选择栏目：
                <select name="ClassIDs">
                  <option value="0">所有栏目</option>
                  <?php
		$sqlclass="select * from ".tname('singerclass')." where CD_SystemID=1 ";
		$results=$db->query($sqlclass);
		if($results){
			$classstr="";
			while ($row3=$db->fetch_array($results)){
				$classstr.="<option value=".$row3['CD_ID'].">".$row3['CD_Name']."</option>";
				}
			}
									?>
                  <?php echo $classstr?>
                </select>
                &nbsp;指定天数:
                <select name="sday">
                	<option value="">不限</option>
                    <?php
                    	for($i=1;$i<16;$i++){
							echo "<option value=\"".$i."\">".$i."天内</option>\r\n";
							}
					?>
                </select>
                &nbsp; 每页&nbsp;<input name="count" class="input input_hd length_1" type="text" size="4" value="50">&nbsp;条
                &nbsp; 
       &nbsp;<input name="submit" type="submit" class="btn mr20" value="开始随机设置人气" />
	   </td> 
      </tr> 
	 </form>
     <form method="post" name="SpanSel" action="?action=malbum" target="Html_Bottom"> 
      <tr> 
       <td width="60" align="left" class="p10">音乐专辑</td> 
       <td align="left">
&nbsp;随机人气范围：<input class="input input_hd length_1" type="text" size="4" name="start_hits" value="1">&nbsp;至&nbsp;<input class="input input_hd length_1" type="text" size="4" name="end_hits" value="1000">
           	    &nbsp; 选择栏目：
                <select name="ClassIDs">
                  <option value="0">所有栏目</option>
                  <?php
		$sqlclass="select * from ".tname('malbumclass')." where CD_SystemID=1 ";
		$results=$db->query($sqlclass);
		if($results){
			$classstr="";
			while ($row3=$db->fetch_array($results)){
				$classstr.="<option value=".$row3['CD_ID'].">".$row3['CD_Name']."</option>";
				}
			}
									?>
                  <?php echo $classstr?>
                </select>
                &nbsp;指定天数:
                <select name="sday">
                	<option value="">不限</option>
                    <?php
                    	for($i=1;$i<16;$i++){
							echo "<option value=\"".$i."\">".$i."天内</option>\r\n";
							}
					?>
                </select>
                &nbsp; 每页&nbsp;<input name="count" class="input input_hd length_1" type="text" size="4" value="50">&nbsp;条
                &nbsp; 
       &nbsp;<input name="submit" type="submit" class="btn mr20" value="开始随机设置人气" />
	   </td> 
      </tr> 
	 </form>
     <form method="post" name="SpanSel" action="?action=valbum" target="Html_Bottom"> 
      <tr> 
       <td width="60" align="left" class="p10">视频专辑</td> 
       <td align="left">
&nbsp;随机人气范围：<input class="input input_hd length_1" type="text" size="4" name="start_hits" value="1">&nbsp;至&nbsp;<input class="input input_hd length_1" type="text" size="4" name="end_hits" value="1000">
           	    &nbsp; 选择栏目：
                <select name="ClassIDs">
                  <option value="0">所有栏目</option>
                  <?php
		$sqlclass="select * from ".tname('valbumclass')." where CD_SystemID=1 ";
		$results=$db->query($sqlclass);
		if($results){
			$classstr="";
			while ($row3=$db->fetch_array($results)){
				$classstr.="<option value=".$row3['CD_ID'].">".$row3['CD_Name']."</option>";
				}
			}
									?>
                  <?php echo $classstr?>
                </select>
                &nbsp;指定天数:
                <select name="sday">
                	<option value="">不限</option>
                    <?php
                    	for($i=1;$i<16;$i++){
							echo "<option value=\"".$i."\">".$i."天内</option>\r\n";
							}
					?>
                </select>
                &nbsp; 每页&nbsp;<input name="count" class="input input_hd length_1" type="text" size="4" value="50">&nbsp;条
                &nbsp; 
       &nbsp;<input name="submit" type="submit" class="btn mr20" value="开始随机设置人气" />
	   </td> 
      </tr> 
	 </form>
     <form method="post" name="SpanSel" action="?action=news" target="Html_Bottom"> 
      <tr> 
       <td width="60" align="left" class="p10">文章</td> 
       <td align="left">
&nbsp;随机人气范围：<input class="input input_hd length_1" type="text" size="4" name="start_hits" value="1">&nbsp;至&nbsp;<input class="input input_hd length_1" type="text" size="4" name="end_hits" value="1000">
           	    &nbsp; 选择栏目：
                <select name="ClassIDs">
                  <option value="0">所有栏目</option>
                  <?php
		$sqlclass="select * from ".tname('newsclass')."";
		$results=$db->query($sqlclass);
		if($results){
			$classstr="";
			while ($row3=$db->fetch_array($results)){
				$classstr.="<option value=".$row3['CD_ID'].">".$row3['CD_Name']."</option>";
				}
			}
									?>
                  <?php echo $classstr?>
                </select>
                &nbsp;指定天数:
                <select name="sday">
                	<option value="">不限</option>
                    <?php
                    	for($i=1;$i<16;$i++){
							echo "<option value=\"".$i."\">".$i."天内</option>\r\n";
							}
					?>
                </select>
                &nbsp; 每页&nbsp;<input name="count" class="input input_hd length_1" type="text" size="4" value="50">&nbsp;条
                &nbsp; 
       &nbsp;<input name="submit" type="submit" class="btn mr20" value="开始随机设置人气" />
	   </td> 
      </tr> 
	 </form>
     <form method="post" name="SpanSel" action="?action=user" target="Html_Bottom"> 
      <tr> 
       <td width="60" align="left" class="p10">会员</td> 
       <td align="left">
&nbsp;随机人气范围：<input class="input input_hd length_1" type="text" size="4" name="start_hits" value="1">&nbsp;至&nbsp;<input class="input input_hd length_1" type="text" size="4" name="end_hits" value="1000">
           	    &nbsp; 选择类型：
                <select name="ClassIDs">
                  <option value="0">所有会员</option>
				  <option value="1">月付VIP</option>
				  <option value="2">年付VIP</option>
				  <option value="3">音乐认证</option>
				  <option value="4">美女认证</option>
				  <option value="5">推荐会员</option>
                </select>
                &nbsp; 每页&nbsp;<input name="count" class="input input_hd length_1" type="text" size="4" value="50">&nbsp;条
                &nbsp; 
       &nbsp;<input name="submit" type="submit" class="btn mr20" value="开始随机设置人气" />
	   </td> 
      </tr> 
	 </form>
     </tbody>  
    </table> 
   </div> 
  </div> 
  <div class="contents"> 
   <div class="panel"> 
    <div class="panel-head"> 
     <strong>进行状态：<span style="color:#ff0000;">在没看到提示完成的情况下不要刷新或关闭此页面</span></strong> 
    </div> 
    <div id="mdv" style="width:100%;height:200px;"> 
     <iframe name="Html_Bottom" frameborder="0" id="Html_Bottom" width="100%" height="100%"></iframe> 
    </div> 
   </div> 
  </div>  
 </body>
</html>
<?php
}
?>