<?php
session_start();
require_once('common.php');
require_once('../libs/cons.php');
require_once 'qlogin.class.php';
$qid = $_GET['qid'];
if(!$qid){
$dba = mysql_query("select count(*) from ".C('DB_PREFIX')."qqs where (skeyzt>0 or sidzt>0)");
$a = mysql_fetch_array($dba);
$title='协助打码';
include_once 'common.head.php';
?>
        <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-lg-10">
            <h2>协助打码</h2>
            <ol class="breadcrumb">
                <li>主页
                </li>
                <li> <strong>其他功能</strong>
                </li>
            </ol>
        </div>
        <div class="col-lg-2"></div>
    </div>
    <style type="text/css">
        .table-bordered > thead > tr > th, .table-bordered > thead > tr > td {
    line-height: 30px;
}
    </style>
    <script src="//cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
    <script src="//cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
		<div class="wrapper wrapper-content animated fadeInRight">
        <div class="col-xs-12 col-md-8">
            <div class="panel panel-success">
                <div class="panel-heading">
                    <h3 class="panel-title">协助打码</h3>
                </div>
				<div class="panel-body" align="left">
					<p>总共<?=$a[0]?>个需要打码的QQ</p>
				</div>
            </div>
        </div>
        <div class="col-xs-12 col-md-8" style="float: none;">
            <div>
                <div class='tab-content'>
                    <div class='tab-pane active' id='tab'>
                        <table class="table table-bordered">
							<tbody>
                                <tr>
                                    <td width="10%" align="center"><span style="color:silver;"><b>QQ</b></span>
                                    </td>
                                    <td width="20%" align="center"><span style="color:silver;"><b>SID/SKEY状态</b></span>
                                    </td>
                                    <td width="10%" align="center"><span style="color:silver;"><b>操作</b></span>
                                    </td>
                                </tr>
                                <?php
				$kb = mysql_query("select * from ".C('DB_PREFIX')."qqs where (skeyzt>0 or sidzt>0)");
				while($rw=mysql_fetch_array($kb)){
				?>
				<tr>
				<td><?=$rw['qq']?></td>
				<td><?=get_zt_($rw['sidzt'])?>/<?=get_zt_($rw['skeyzt'])?></td>
				<td><a href="?qid=<?=$rw['qid']?>&type=xz&tp=ok"><button type="button" class="btn btn-default" >协助打码</button></a></td>
				<tr>
				<?php } ?>
                                
                                      </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
</div>
<?php }else{ 
if(!$qid || !$qqrow=$db->get_row("select * from ".C('DB_PREFIX')."qqs where qid='$qid' limit 1")){
	showmsg("QQ不存在",true,"/mgmt/xzdm.php");
}
if($qqrow['sidzt'] or $qqrow['skeyzt']){
$uin = $qqrow['qq'];
$_pwd = decrypt($qqrow['pwd'],$syskey);
$vcode = $_POST['code'];
$sig = $_POST['sig'];
if($_GET['tp']=='ok'){
	$data = new Qqlogin($uin,$_pwd,$vcode,$sig);
	$qqs=json_decode($data->json,true);
	if($qqs['code']==-1){
		$code=1;
		$sig=$qqs['sig'];
	}elseif($qqs['code']==-3){
		$msg=$qqs['msg'];
		$yes = 1;
	}else{
		if($qqs['skey'] && $qqs['sid'] && $qqs['p_skey'] && $qqs['p_skey2']){
			$sid = $qqs['sid'];
			$skey = $qqs['skey'];
			$p_skey = $qqs['p_skey'];
			$p_skey2 = $qqs['p_skey2'];
			$set="p_skey='{$p_skey}',skey='{$skey}',p_skey2='{$p_skey2}',p_skey='{$p_skey}',sid='{$sid}',skeyzt=0,sidzt=0";
			$db->query("update ".C('DB_PREFIX')."qqs set {$set} where qq='$uin'");
			$db->query("update ".C('DB_PREFIX')."users set rmb=rmb+1 where uid='{$userrow[uid]}'");
			$msg="为QQ".$uin."打码成功！因此您获得了1余额的奖励！";
			$yes = 1;
		}
}
}
}else{
	showmsg("QQ状态不存在异常",true,"/mgmt/xzdm.php");
	
	}
$title='协助QQ'.$qqrow[qq].'打码';
include_once 'common.head.php';
?>
  <div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
      <h2>协助QQ<?=$qqrow['qq']?>打码</h2>
      <ol class="breadcrumb">
        <li> 主页
        </li>
        <li> QQ列表
        </li>
      </ol>
    </div>
    <div class="col-lg-2"></div>
  </div>
  <div class="wrapper wrapper-content animated fadeInRight">
  
  
	<div class="col-md-8">
      <div class="ibox-title">
        <h5>添加 / 更新</h5>
      </div>
      <div class="ibox-content">

		  		<form action="?qid=<?=$qqrow[qid]?>&tp=ok" method="post" class="form-horizontal">
		<input type="hidden" name="do" value="add">
          
		  <div class="input-group code" <div <?php if(!$code){ ?> style="display:none;" <?php } ?>>
          <div class="list-group-item">
            <div class="input-group" id="codes">
              <div class="input-group-addon">验证码</div>
              <input type="text" class="form-control" name="code" id="code" placeholder="输入验证码">
              <br>
			  <input type="hidden" name="sig" value="<?=$sig?>">
              <span id="codeimg"><img onclick="getpic.php?uin=<?=$uin?>&sig=<?=$sig?>" src="getpic.php?uin=<?=$uin?>&sig=<?=$sig?>"></span>
            </div>
			</div>
          </div>
          
		
		<?php if($msg){ ?>
<div class="list-group-item">
			  <div class="input-group">
                <div class="input-group-addon">结果</div>
				<label class="form-control red" for="field-2" id="load"><?=$msg?></label>
              </div>
            </div>
				<?php } ?>
				<div class="list-group-item">
		  <?php if(!$yes){ ?>
				<input type="submit" name="submit" value="确认更新" class="btn btn-primary btn-block">
				<?php }else{ ?>
				<a href="/mgmt/xzdm.php" class="btn btn-primary btn-block" >返回协助打码<a>
				<?php } ?>
				</div>
		
		</form>
		</div>
      </div>
    </div>
	
	
		  
		 
					
	


<?php } ?>

<?php 
require_once 'common.foot.php';
?>