<?php
error_reporting(0);
require_once( dirname( __FILE__ ) . '/Config.php' );
$Action = $_REQUEST['Action'];
$UserKey = $_REQUEST['key'];
$cookie_jar = dirname(__FILE__) . '/BuddyAuth.txt';
//cookie临时文件
echo '
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
<meta name="description" content="Buddy Auth Portal">
<meta name="author" content="Meiam">
<link rel="icon" href="favicon.ico">

<title>Buddy Auth Portal</title>

<!-- Bootstrap core CSS -->
<link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="css/starter-template.css" rel="stylesheet">

<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<!--<script src="../../assets/js/ie-emulation-modes-warning.js"></script>-->

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>

<body>

<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Buddy Auth Portal</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="http://www.demonbuddy.cn/forum-40-1.html">兄弟下载</a></li>
<li><a href="http://www.demonbuddy.cn/thread-2265-1-1.html">兄弟销售</a></li>
<li><a href="http://www.demonbuddy.cn/thread-4812-1-1.html">门童神器</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>

<div class="container">
<div class="starter-template">
<div class="col-lg-12">
';
echo " <form role="search" method="post" action="index.php?Action=Query">rntttt<div class="input-group">rnttttt<input name="key" type="text" class="form-control" placeholder="请输入你的正版序列号" value="{$UserKey}" >rnttttt<span class="input-group-btn">rntttttt<button class="btn btn-success" type="submit">查询</button>rnttttt</span>rntttt</div><!-- /input-group -->rn </form>t ";
echo "t<hr>rnt<form role="search" action="index.php?Action=Kill" method="post">rnt<div class="panel panel-default">rnt<div class="panel-heading">CURRENT SESSIONS</div>rntrn <table class="table table-striped">rn <thead>rn <tr>rn <th class="info" style="text-align: center">Control</th>rn <th class="info" style="text-align: center">Type</th>rn <th class="info" style="text-align: center">Started</th>rn <th class="info" style="text-align: center">Running Time</th>rn <th class="info" style="text-align: center">Key Used</th>rn </tr>rn </thead>rn <tbody>rn <tr>rntt<input name="key" type="hidden" value="{$UserKey}" />rntt";
if ($Action == 'Query') {
$LoginPost = "UserName={$User}&Password={$Pass}&RememberMe=false";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.buddyauth.com/Account/LogOn?ReturnUrl=%2fUser%2fSessions');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $LoginPost);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
$LoginData = curl_exec($ch);
//file_put_contents('LoginData.txt', $LoginData);
curl_close($ch);
$Postkey = "key={$UserKey}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.buddyauth.com/User/Sessions');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $Postkey);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
$Sessions = curl_exec($ch);
//file_put_contents('Sessions.txt', $Sessions);
curl_close($ch);
$pat = '/<tr>(.+?)</tr>/is';
preg_match_all($pat, $Sessions, $m);
$b = array_filter($m[1]);
for ($i = 2; $i < count($b) - 2; $i++) {
echo $b[$i];
}
}
if ($Action == 'Kill') {
$PostKillData = file_get_contents('php://input');
//$PostKill = "key=$key&selectedSessions%5B0%5D.Id=1021065821&selectedSessions%5B0%5D.IsChecked=true&selectedSessions%5B0%5D.IsChecked=false";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.buddyauth.com/User/Sessions');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $PostKillData);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
$PostKill = curl_exec($ch);
//file_put_contents('PostKill.txt', $PostKill);
curl_close($ch);
$PostKillBack = "key={$UserKey}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.buddyauth.com/User/Sessions');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $PostKillBack);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
$KillBack = curl_exec($ch);
//file_put_contents('KillBack.txt', $KillBack);
curl_close($ch);
$pat = '/<tr>(.+?)</tr>/is';
preg_match_all($pat, $KillBack, $m);
$b = array_filter($m[1]);
for ($i = 2; $i < count($b) - 2; $i++) {
echo $b[$i];
}
}
echo ' </tr>
</tbody>

</table>
</table>
</div>
<button class="btn btn-danger" type="submit">Kill Selected</button>
<hr class="featurette-divider">
<footer>
<p>&copy; 2015 CODE BY <a href="http://www.592.la">MEIAM</a> </p>
</footer>
</div>
</div>

</div><!-- /.container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
<script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<!-- <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>-->
</body>
</html>';