<?php

	@set_time_limit(0);
	@ignore_user_abort(true);

	require '../siteinfo.php';
	require '../Source/function/global.php';

	if (empty($_GET['server']) || $_GET['server']<1 || $_GET['server']>8 || @$_GET['job']!=$websitejob){
		die ('Parameter error!');
	}

	$localhost = mysql_connect ($sqlhost,$sqluser,$sqlpass)or die ('连接数据库失败，请联系网站管理员！');
	mysql_select_db ($sqldata,$localhost);
	mysql_query ('SELECT COUNT(id) FROM fw'.$_GET['server']);
	$result = mysql_query ('SELECT * FROM fw'.$_GET['server']);

	while ($row=mysql_fetch_array($result)){
		$sql = mysql_fetch_array (mysql_query ("SELECT * FROM `qqlist` WHERE `qq`='$row[qq]'"));
		if ($sql['qy'] == 'true' and $sql['Agreement'] == '3G'){
			$data = newsid ($row['qq'],$row['pw']);

			if(strpos ($data,'操作异常')){
				mysql_query("UPDATE `qqlist` SET `newsid`='no' WHERE `qid`='$sql[qid]'");
				echo "<h5>$row[qq]---更新失败</h5>";
			}else if (strpos ($data,'成功')){
				$out = explode ('sid=',$data);
				$sid = substr ($out[1],0,24);
				mysql_query ("UPDATE `qqlist` SET sid='$sid',newsid='yes' WHERE qid='$sql[qid]'");
				mysql_query ("UPDATE `fw{$_GET['server']}` SET `sid`='$sid' WHERE `qid`='$sql[qid]'");
				echo "<h5>$row[qq]---更新成功</h5>";
			}

			//usleep (300000);

		}else{
			echo "<h5>$row[qq]---暂停更新</h5>";
		}
	}

