<?php
// 情谊 QQ955854
namespace app\common\steam\controller;//跟目录路径一样
use think\Db;
use think\Controller;
class Index extends Controller
{
public function getReturn($code = 1, $data = "成功", $json = null)//系统需,要不要动
{
return array("code" => $code, "data" => $data, "json" => $json);
}
public function Cookie($atad)//监控心跳
{
$url="https://store.steampowered.com/account/store_transactions/";
$ret= curl_get($url,'',$atad['ck']);
$money = $this->cut_z($ret,'href="https://store.steampowered.com/account/store_transactions/">¥ ','</a>');
if($money){
$code = 1;
$data = "余额:".$money;
}else{
$code = -1;
$data = "CK已过期!";
}
return $this->getReturn(1,$data,array("time"=>time(),"cookie"=>$Cookie));
}
public function cehsald($atad)//监控回调
{
$row = Db::name("pay_gfg")->where("pid", $atad['pid'])->where("mid",$atad['mid'])->find();
$header = array(
'Content-Type: application/x-www-form-urlencoded',
'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
'Referer: https://store.steampowered.com/checkout?cart='.$cart.'µtxn=-1',
'Cookie: '.$row['ck']
);
$url="https://store.steampowered.com/checkout/transactionstatus/?count=3&transid=".$atad['pay_id'];
$ret = curl_get($url,$header,$row['ck']);
$json = json_decode($ret,TRUE);
$data = $json['purchasereceipt']['purchasestatus'];//支付结果
if($data == 1){
return $this->getReturn(1, '交易成功', $atad);
}else{
return $this->getReturn(-1, '交易失败'.$ret.$data, $atad);
}
}
public function fukyem($data)//支付页面
{
$sz = Db::name("pay_sz")->find();
$atad= Db::name("pay_gfg")->where("pid", $data['pid'])->where("mid", $data['mid'])->find();
$user = Db::name("pay_user")->where("id", $data['pid'])->find();
$data['timeOut'] = $user['bug_close'];//订单有效期
if($data['type']=='alipay'){//支付宝
if($atad['ms']==0){//H5
return redirect($data['mid_url']);
//return response($data['mid_url']);
}else{//扫码
$data['src'] = url('enQrcode').'?url='.$data['mid_url'];//二维码
// 模板变量赋值
$data['luji'] = iphtml('pay');//模板路径
$this->assign('data',$data);
return $this->fetch(ippublic('pay').'/index.html');
}
}else{//微信
if($atad['ms']==0){//H5
return response($data['mid_url']);
}else{//扫码
$data['src'] = url('enQrcode').'?url='.$data['mid_url'];//二维码
// 模板变量赋值
$data['luji'] = iphtml('pay');//模板路径
$this->assign('data',$data);
return $this->fetch(ippublic('pay').'/index.html');
}
}
}
public function exec($api,$atad,$money,$type)
{
if($money<30){
$this->success('1015',null,'订单创建失败(错误信息:单笔金额不可小于30元)');
}
if($type == 'alipay'){
$PaymentMethod = 'alipay';
}else{
$PaymentMethod = 'wechat';
}
$money = $money*100;
$ck = $atad['ck'];
$sessionID = $this->cut_z($atad['ck'],'sessionid=',';');
$header = array(
'Content-Type: application/x-www-form-urlencoded',
'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
'Referer: https://store.steampowered.com/steamaccount/addfunds',
'Cookie: '.$ck
);
$url = "https://store.steampowered.com/steamaccount/addfundssubmit";
$data = 'action=add_to_cart¤cy=CNY&amount='.$money.'&sessionID='.$sessionID.'&mtreturnurl=';
$ret = $this->get_curl_header($url,$data,$ck,$header);
preg_match_all('/(Location):(\s+|")([^"\s]+)/s', $ret['header'], $m);
preg_match_all('/[1-9][0-9]{4,}/', $m[0][0], $matches);
$cart = $matches[0][0];
$header = array(
'Content-Type: application/x-www-form-urlencoded',
'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
'Referer: https://store.steampowered.com/checkout?cart='.$cart.'µtxn=-1',
'Cookie: '.$ck
);
$url = "https://store.steampowered.com/checkout/inittransaction/";
$data = 'gidShoppingCart='.$cart.'&gidReplayOfTransID=-1&PaymentMethod='.$PaymentMethod.'&abortPendingTransactions=0&bHasCardInfo=0&CardNumber=&CardExpirationYear=&CardExpirationMonth=&FirstName=&LastName=&Address=&AddressTwo=&Country=CN&City=&State=&PostalCode=&Phone=&ShippingFirstName=&ShippingLastName=&ShippingAddress=&ShippingAddressTwo=&ShippingCountry=CN&ShippingCity=&ShippingState=&ShippingPostalCode=&ShippingPhone=&bIsGift=0&GifteeAccountID=0&GifteeEmail=&GifteeName=&GiftMessage=&Sentiment=&Signature=&ScheduledSendOnDate=0&BankAccount=&BankCode=&BankIBAN=&BankBIC=&TPBankID=&BankAccountID=&bSaveBillingAddress=1&gidPaymentID=&bUseRemainingSteamAccount=0&bPreAuthOnly=0&sessionid='.$sessionID;
$ret = curl_post($url,$data,$header,$ck);
$json=json_decode($ret,TRUE);
$transid = $json['transid'];
$header = array(
'Content-Type: application/x-www-form-urlencoded',
'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
'Referer: https://store.steampowered.com/checkout?cart='.$cart.'µtxn=-1',
'Cookie: '.$ck
);
$url = 'http://222.178.203.72:19005/whst/63/=rsnqdzrsdZlonvdqdczbnl//checkout/getfinalprice/?count=1&transid='.$transid.'&purchasetype=selfµtxnid=-1&cart='.$cart.'&gidReplayOfTransID=-1';
$ret = curl_get($url,$header,$ck);
$json=json_decode($ret,TRUE);
if($json['success'] == 8){
return $this->getReturn(-1, '支付订单拉起频繁!');
}
$header = array(
'Content-Type: application/x-www-form-urlencoded',
'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
'Referer: https://store.steampowered.com/checkout?cart='.$cart.'µtxn=-1',
'Cookie: '.$ck
);
$url = 'http://222.178.203.72:19005/whst/63/=rsnqdzrsdZlonvdqdczbnl//checkout/transactionstatus/?count=1&transid='.$transid;
$ret = curl_get($url,$header,$ck);
$json=json_decode($ret,TRUE);
$header = array(
'Content-Type: application/x-www-form-urlencoded',
'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
'Referer: https://store.steampowered.com/checkout?cart='.$cart.'µtxn=-1',
'Cookie: '.$ck
);
$url = 'http://222.178.203.72:19005/whst/63/=rsnqdzrsdZlonvdqdczbnl//checkout/externallink/?transid='.$transid;
$ret = curl_get($url,$header,$ck);
$json=json_decode($ret,TRUE);
$ret = html_entity_decode($ret);
$pattern = '/<input\s+type="hidden"\s+name="([^"]*)"\s+value="([^"]*)"/i';
preg_match_all($pattern, $ret, $matches);
$params = array_combine($matches[1], $matches[2]);
$queryString = http_build_query($params);
$header = array(
'Content-Type: application/x-www-form-urlencoded',
'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Versio