Advertisement
Guest User

Untitled

a guest
Nov 7th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.74 KB | None | 0 0
  1. <?php
  2. if (!defined('IN_DISCUZ')) {
  3. exit('Access Denied');
  4. }
  5. require_once 'steamid.php';
  6. $psetting = $_G['cache']['plugin']['xnet_steam_credit_gf'];
  7. $plang = lang('xnet_steam_credit_gf:scriptlang');
  8. //读取配置语言
  9. if (!$_G['uid']) {
  10. showmessage($plang['alert_user_login'], NULL, array(), array('login' => 1));
  11. }
  12. $ctype = intval($psetting['ctype']);
  13. $jifen_title = $_G['setting']['extcredits'][$ctype]['title'];
  14. $bbs_scale = intval($psetting['bbs_scale']);
  15. $game_scale = intval($psetting['game_scale']);
  16. $allowtype = intval($psetting['btype']);
  17. //SteamAPI
  18. $steam_apikey = $psetting['steam_apikey'];
  19. $steam_apikey_check_steam = $psetting['steam_apikey_check_steam'];
  20. $steam_apicheck_type = $psetting['steam_apicheck_type'];
  21. //远程数据库设置
  22. $Use_remote_mysql = $psetting['remote_mysql'];
  23. $remote_host = $psetting['remote_host'];
  24. $remote_user = $psetting['remote_user'];
  25. $remote_pass = $psetting['remote_pass'];
  26. $remote_database = $psetting['remote_database'];
  27. //远程数据库
  28. //QQ通知变量
  29. $qq_robot_enable = $psetting['qq_robot_enable'];
  30. $qq_robot_send_user = $psetting['qq_robot_send_user'];
  31. $qq_robot_send_admin = $psetting['qq_robot_send_admin'];
  32. $qq_robot_admin_qq = $psetting['qq_robot_admin_qq'];
  33. $qq_robot_send_type = $psetting['qq_robot_send_type'];
  34. //QQ通知
  35. if ($TradeCoolDown <= 20) {
  36. $TradeCoolDown = 20;
  37. }
  38. //URL
  39. $notbind_url_goto = $psetting['notbind_url_goto'];
  40. if (!($steamid64 = DB::result_first("select steamID64 from " . DB::table('steam_users') . " where uid='" . $_G['uid'] . "'"))) {
  41. showmessage($plang['alert_user_nosteamid'], $url_forward = "{$notbind_url_goto}");
  42. }
  43. if (!($dzuid = DB::result_first("select uid from " . DB::table('steam_users') . " where uid='" . $_G['uid'] . "'"))) {
  44. showmessage($plang['alert_user_nosteamid'], $url_forward = "{$notbind_url_goto}");
  45. }
  46. $steamid32 = ConvertSteam64To32($steamid64);
  47. if ($steam_apikey_check_steam && $steam_apicheck_type == 3) {
  48. $NotInGame = SteamAPI_Fetch_PlayerNotInGame($steamid64);
  49. if (!$NotInGame) {
  50. $reson = SteamAPI_Fetch_Player_Reson($steamid64);
  51. showmessage($reson);
  52. }
  53. }
  54. if ($Use_remote_mysql) {
  55. //后台如果开启远程数据库
  56. //PHP连接其他MYSQL
  57. try {
  58. $connect = new PDO("mysql:host={$remote_host};dbname={$remote_database}", $remote_user, $remote_pass);
  59. } catch (PDOException $e) {
  60. showmessage($plang['alert_couldnot_connect_remote_mysql_server']);
  61. }
  62. }
  63. //不开启整段无视.
  64. //Remove SQL?
  65. if (!empty($_GET['formhash'])) {
  66. if ($_GET['formhash'] != FORMHASH) {
  67. showmessage('undefined_action');
  68. }
  69. $duiru = intval($_GET['duiru']);
  70. $duicount = intval($_GET['duicount']);
  71. //$file = fopen("creditslog.txt", "w+");
  72. $fangxiang = "兑换到游戏";
  73. $time = date('Y-m-d H:i:s', time());
  74. $CTDF_USERINFO["user"] = $discuz_user;
  75. if (empty($duiru) || empty($duicount)) {
  76. //检验数据
  77. showmessage($plang['alert_user_data_isnull']);
  78. }
  79. if (!$_G['uid']) {
  80. showmessage("请先登录!");
  81. }
  82. // if ($_G['uid'] != 480) showmessage("尚未开放!");
  83. if (!($steamid64 = DB::result_first("select steamID64 from " . DB::table('steam_users') . " where uid='" . $_G['uid'] . "'"))) {
  84. showmessage("没有绑定SteamID");
  85. }
  86. $OLDBBSCredits = C::t('common_member_count')->fetch($_G['uid']);
  87. $OLDBBSCreditsNumber = $OLDBBSCredits['extcredits' . $ctype];
  88. $OLDGameCredits = DB::result_first("select credits from `store_players` where authid = '{$steamid32}'");
  89. if ($duiru == '1') {
  90. //游戏币换论坛积分
  91. if ($steam_apikey_check_steam && $steam_apicheck_type == 1) {
  92. $NotInGame = SteamAPI_Fetch_PlayerNotInGame($steamid64);
  93. if (!$NotInGame) {
  94. $reson = SteamAPI_Fetch_Player_Reson($steamid64);
  95. showmessage($reson);
  96. }
  97. }
  98. if ($allowtype != 0 && $allowtype != 2) {
  99. showmessage($plang['alert_dhfx_disble']);
  100. }
  101. if (!$Use_remote_mysql) {
  102. if (!($gamecredits = DB::fetch_first("select * from `store_players` where authid = '{$steamid32}'"))) {
  103. showmessage($plang['alert_user_nosteamid'], $url_forward = "{$notbind_url_goto}");
  104. }
  105. }
  106. //远程 查询游戏积分
  107. if ($Use_remote_mysql) {
  108. $sql_gamecredits = "select * from `store_players` where authid = '{$steamid32}'";
  109. $sth = $connect->query($sql_gamecredits);
  110. if (!$sth) {
  111. showmessage($plang['alert_couldnot_connect_remote_mysql_server']);
  112. }
  113. while ($row = $sth->fetch()) {
  114. $gamecredits = $row['credits'];
  115. }
  116. } else {
  117. //查询本地积分
  118. $gamecredits = DB::result_first("select credits from `store_players` where authid = '{$steamid32}'");
  119. }
  120. $dayu500 = $gamecredits - $duicount;
  121. if ($allowtype != 2 && $dayu500 < 500) {
  122. showmessage("必须留 500 游戏积分!");
  123. }
  124. //远程 查询游戏积分
  125. $scount = ceil($duicount * $game_scale / $bbs_scale);
  126. if (intval($gamecredits) < $scount) {
  127. //积分不足
  128. showmessage($plang['alert_user_has_nofull']);
  129. }
  130. if (intval($gamecredits['credits']) == "") {
  131. //无帐号
  132. showmessage($plang['alert_nogame_credits'], $url_forward = "{$notbind_url_goto}");
  133. }
  134. if ($duicount < 1) {
  135. //积分不足
  136. showmessage($plang['alert_user_has_nofull']);
  137. }
  138. if (!is_numeric($duiru) || !is_int($duiru)) {
  139. showmessage($plang['alert_duicount_wrong']);
  140. }
  141. // Lengque
  142. if (!($timestamp = DB::result_first("select timestamp from " . DB::table('plugin_cooldown') . " where uid='" . $_G['uid'] . "'"))) {
  143. ##如果没有则写入
  144. $arr = array('uid' => $_G['uid'], 'timestamp' => TIMESTAMP);
  145. DB::query("insert into " . DB::table('plugin_cooldown') . "(`uid`, `timestamp`) VALUES ('{$arr['uid']}', '{$arr['timestamp']}')");
  146. } else {
  147. if ($timestamp = DB::result_first("select timestamp from " . DB::table('plugin_cooldown') . " where uid='" . $_G['uid'] . "'")) {
  148. if ($timestamp >= TIMESTAMP - $TradeCoolDown) {
  149. $countdown = $timestamp - (TIMESTAMP - $TradeCoolDown);
  150. showmessage("上一次操作是成功的! 请间隔 {$countdown} 秒后再操作!");
  151. } else {
  152. $Nowtimestamp = TIMESTAMP;
  153. DB::query("update " . DB::table('plugin_cooldown') . " set timestamp = '{$Nowtimestamp}' where uid='" . $_G['uid'] . "'");
  154. }
  155. }
  156. }
  157. // Lengque
  158. //扣游戏币,加论坛积分
  159. //PDO判断 扣除游戏积分增加论坛积分
  160. if (!$Use_remote_mysql) {
  161. //不使用远程数据库 则
  162. $duicount && updatemembercount($_G['uid'], array('extcredits' . $ctype => $duicount));
  163. DB::query("update `store_players` set credits = credits - {$scount} where authid = '{$steamid32}'");
  164. credit_log($_G['uid'], "dbb", 16, array('extcredits2' => $duicount), $customtitle1, "test");
  165. //LOG
  166. }
  167. //PDO
  168. if ($Use_remote_mysql) {
  169. //使用远程数据库 则
  170. $sql_gamecredits = "update `store_players` set credits = credits - {$scount} where authid = '{$steamid32}'";
  171. // $sth = $connect->query($sql_gamecredits);
  172. if (!$connect->exec($sql_gamecredits)) {
  173. showmessage($plang['alert_couldnot_connect_remote_mysql_server']);
  174. }
  175. $duicount && updatemembercount($_G['uid'], array('extcredits' . $ctype => $duicount));
  176. credit_log($_G['uid'], "dbb", 16, array('extcredits2' => $duicount), $customtitle1, "test");
  177. //LOG
  178. }
  179. //使用远程数据库 结束
  180. if ($duiru == '1') {
  181. // $OLDBBSCreditsNumber Credits:$OLDGameCredits
  182. $bbs_bypass = $OLDBBSCreditsNumber + $duicount;
  183. $game_bypass = $OLDGameCredits - $duicount;
  184. $NowBBSCredits = C::t('common_member_count')->fetch($_G['uid']);
  185. $NowBBSCreditsNumber = $NowBBSCredits['extcredits' . $ctype];
  186. $NowGameCredits = DB::result_first("select credits from `store_players` where authid = '{$steamid32}'");
  187. if ($Use_remote_mysql) {
  188. $sql_gamecredits = "select * from `store_players` where authid = '{$steamid32}'";
  189. $sth = $connect->query($sql_gamecredits);
  190. if (!$sth) {
  191. showmessage($plang['alert_couldnot_connect_remote_mysql_server']);
  192. }
  193. while ($row = $sth->fetch()) {
  194. $NowGameCredits = $row['credits'];
  195. }
  196. }
  197. if ($bbs_bypass == $NowBBSCreditsNumber) {
  198. $bbs_bypass = "验证积分PASS!";
  199. } else {
  200. $repuid = $_G['uid'];
  201. $bbs_bypass = "积分验证失败!!!";
  202. }
  203. if ($game_bypass == $NowGameCredits) {
  204. $game_bypass = "验证积分PASS!";
  205. } else {
  206. $repuid = $_G['uid'];
  207. $game_bypass = "积分验证失败!!!";
  208. //qqlite::sendqun(148942041, "UID$repuid $game_bypass");
  209. }
  210. //通知论坛积分增加
  211. if ($qq_robot_enable && $qq_robot_send_type == 1 || $qq_robot_send_type == 3) {
  212. $localtime = date('y-m-d H:i:s', time());
  213. //取现时间
  214. //消息定义
  215. $qqmessage = "[CSGO-CN] UID : " . $_G['uid'] . " 论坛id :" . $_G['username'] . " {$steamid64} 操作:游戏积分兑换 {$jifen_title} 数量:{$duicount} 操作时间:{$localtime} \n 原有信息:\n叶子:{$OLDBBSCreditsNumber} Credits:{$OLDGameCredits} \n现有信息:\n叶子:{$NowBBSCreditsNumber} [{$bbs_bypass}] Credits:{$NowGameCredits} [{$game_bypass}]";
  216. if ($qq_robot_send_user && ($qq_user = qqlite::getuser($_G['uid']))) {
  217. //如果QQ用户发送消息给对应号码
  218. $qq_hao = $qq_user['qq'];
  219. //$qqusername = $qq_user['username'];
  220. qqlite::sendqq($qq_hao, $qqmessage);
  221. //发送到对应QQ
  222. }
  223. //发送到admin
  224. if ($qq_robot_send_admin) {
  225. $adminqqs = preg_split('/\\r\\n/', $qq_robot_admin_qq);
  226. //后台 qq逐行读取
  227. foreach ($adminqqs as $admin_qq) {
  228. $admin_qq = str_replace(' ', '', $admin_qq);
  229. //过滤可能的空格
  230. qqlite::sendqq($admin_qq, $qqmessage);
  231. }
  232. }
  233. }
  234. //通知论坛积分增加
  235. }
  236. } elseif ($duiru == '2') {
  237. //积分换游戏币
  238. if ($allowtype != 0 && $allowtype != 1) {
  239. showmessage($plang['alert_dhfx_disble']);
  240. }
  241. if ($steam_apikey_check_steam && $steam_apicheck_type == 2) {
  242. $NotInGame = SteamAPI_Fetch_PlayerNotInGame($steamid64);
  243. if (!$NotInGame) {
  244. $reson = SteamAPI_Fetch_Player_Reson($steamid64);
  245. showmessage($reson);
  246. }
  247. }
  248. $bbscredits = C::t('common_member_count')->fetch($_G['uid']);
  249. $ccount = intval($bbscredits['extcredits' . $ctype]);
  250. $scount = ceil($duicount * $bbs_scale / $game_scale);
  251. //远程 查询游戏积分
  252. if ($Use_remote_mysql) {
  253. $sql_gamecredits = "select * from `store_players` where authid = '{$steamid32}'";
  254. $sth = $connect->query($sql_gamecredits);
  255. if (!$sth) {
  256. showmessage($plang['alert_couldnot_connect_remote_mysql_server']);
  257. }
  258. while ($row = $sth->fetch()) {
  259. $gamecredit2 = $row['credits'];
  260. }
  261. } else {
  262. //查询本地积分
  263. $gamecredit2 = DB::result_first("select credits from `store_players` where authid = '{$steamid32}'");
  264. }
  265. //远程 查询游戏积分
  266. if ($ccount < $scount) {
  267. //积分不足
  268. showmessage($plang['alert_user_has_nofull']);
  269. }
  270. if ($duicount < 1) {
  271. //积分不足
  272. showmessage($plang['alert_user_has_nofull']);
  273. }
  274. if ($gamecredit2 == "") {
  275. //如果游戏积分为空 未读取到
  276. showmessage($plang['alert_nogame_credits'], $url_forward = "{$notbind_url_goto}");
  277. }
  278. if (!is_numeric($duiru) || !is_int($duiru)) {
  279. showmessage($plang['alert_duicount_wrong']);
  280. }
  281. // Lengque
  282. if (!($timestamp = DB::result_first("select timestamp from " . DB::table('plugin_cooldown') . " where uid='" . $_G['uid'] . "'"))) {
  283. ##如果没有则写入
  284. $arr = array('uid' => $_G['uid'], 'timestamp' => TIMESTAMP);
  285. DB::query("insert into " . DB::table('plugin_cooldown') . "(`uid`, `timestamp`) VALUES ('{$arr['uid']}', '{$arr['timestamp']}')");
  286. } else {
  287. if ($timestamp = DB::result_first("select timestamp from " . DB::table('plugin_cooldown') . " where uid='" . $_G['uid'] . "'")) {
  288. if ($timestamp >= TIMESTAMP - $TradeCoolDown) {
  289. $countdown = $timestamp - (TIMESTAMP - $TradeCoolDown);
  290. showmessage("上一次操作是成功的! 请间隔 {$countdown} 秒后再操作!");
  291. } else {
  292. $Nowtimestamp = TIMESTAMP;
  293. DB::query("update " . DB::table('plugin_cooldown') . " set timestamp = '{$Nowtimestamp}' where uid='" . $_G['uid'] . "'");
  294. }
  295. }
  296. }
  297. // Lengque
  298. //验证积分
  299. //$zhengquejifen = $OLDBBSCreditsNumber-$duicount;
  300. // if()
  301. // $OLDBBSCreditsNumber = $bbscredits['extcredits' . $ctype];
  302. // $OLDGameCredits = DB::fetch_first("select * from `store_players` where authid = '$steamid32'");
  303. //
  304. //加游戏币,扣论坛积分
  305. if (!$Use_remote_mysql) {
  306. //不使用远程数据库 则
  307. $scount && updatemembercount($_G['uid'], array('extcredits' . $ctype => -$scount));
  308. DB::query("update `store_players` set credits = credits + {$duicount} where authid = '{$steamid32}'");
  309. credit_log($_G['uid'], "dgm", 16, array('extcredits2' => -$duicount), "test1", "test");
  310. //LOG
  311. }
  312. //PDO
  313. if ($Use_remote_mysql) {
  314. //使用远程数据库 则
  315. $sql_gamecredits = "update `store_players` set credits = credits + {$duicount} where authid = '{$steamid32}'";
  316. // $sth = $connect->query($sql_gamecredits);
  317. if (!$connect->exec($sql_gamecredits)) {
  318. showmessage($plang['alert_couldnot_connect_remote_mysql_server']);
  319. }
  320. $scount && updatemembercount($_G['uid'], array('extcredits' . $ctype => -$scount));
  321. credit_log($_G['uid'], "dgm", 16, array('extcredits2' => -$duicount), "test1", "test");
  322. //LOG
  323. }
  324. //使用远程数据库 结束
  325. } else {
  326. showmessage('undefined_action');
  327. }
  328. if ($duiru == '2') {
  329. // $OLDBBSCreditsNumber Credits:$OLDGameCredits
  330. $bbs_bypass = $OLDBBSCreditsNumber - $duicount;
  331. $game_bypass = $OLDGameCredits + $duicount;
  332. $NowBBSCredits = C::t('common_member_count')->fetch($_G['uid']);
  333. $NowBBSCreditsNumber = $NowBBSCredits['extcredits' . $ctype];
  334. $NowGameCredits = DB::result_first("select credits from `store_players` where authid = '{$steamid32}'");
  335. if ($Use_remote_mysql) {
  336. $sql_gamecredits = "select * from `store_players` where authid = '{$steamid32}'";
  337. $sth = $connect->query($sql_gamecredits);
  338. if (!$sth) {
  339. showmessage($plang['alert_couldnot_connect_remote_mysql_server']);
  340. }
  341. while ($row = $sth->fetch()) {
  342. $NowGameCredits = $row['credits'];
  343. }
  344. }
  345. if ($bbs_bypass == $NowBBSCreditsNumber) {
  346. $bbs_bypass = "验证积分PASS!";
  347. } else {
  348. $repuid = $_G['uid'];
  349. $bbs_bypass = "积分验证失败!!!";
  350. //qqlite::sendqun(148942041, "UID:$repuid $bbs_bypass");
  351. }
  352. if ($game_bypass == $NowGameCredits) {
  353. $game_bypass = "验证积分PASS!";
  354. } else {
  355. $repuid = $_G['uid'];
  356. $game_bypass = "积分验证失败!!!";
  357. // qqlite::sendqun(148942041, "UID$repuid $game_bypass");
  358. }
  359. if ($qq_robot_enable && $qq_robot_send_type == 2 || $qq_robot_send_type == 3) {
  360. $localtime = date('y-m-d H:i:s', time());
  361. //取现时间
  362. //消息定义
  363. $qqmessage = "[CSGO-CN] UID : " . $_G['uid'] . " 论坛id :" . $_G['username'] . " {$steamid64} 操作: {$jifen_title} 兑换 游戏积分 数量:{$duicount} 操作时间:{$localtime} \n 原有信息:\n叶子:{$OLDBBSCreditsNumber} Credits:{$OLDGameCredits} \n现有信息:\n叶子:{$NowBBSCreditsNumber} [{$bbs_bypass}] Credits:{$NowGameCredits} [{$game_bypass}]";
  364. if ($qq_robot_send_user && ($qq_user = qqlite::getuser($_G['uid']))) {
  365. //如果QQ用户发送消息给对应号码
  366. $qq_hao = $qq_user['qq'];
  367. //$qqusername = $qq_user['username'];
  368. qqlite::sendqq($qq_hao, $qqmessage);
  369. //发送到对应QQ
  370. }
  371. //发送到admin
  372. if ($qq_robot_send_admin) {
  373. $adminqqs = preg_split('/\\r\\n/', $qq_robot_admin_qq);
  374. //后台 qq逐行读取
  375. foreach ($adminqqs as $admin_qq) {
  376. $admin_qq = str_replace(' ', '', $admin_qq);
  377. //过滤可能的空格
  378. qqlite::sendqq($admin_qq, $qqmessage);
  379. }
  380. }
  381. }
  382. }
  383. //update credits
  384. //远程 查询游戏积分
  385. if ($Use_remote_mysql) {
  386. $sql_gamecredits = "select * from `store_players` where authid = '{$steamid32}'";
  387. $sth = $connect->query($sql_gamecredits);
  388. if (!$sth) {
  389. showmessage($plang['alert_couldnot_connect_remote_mysql_server']);
  390. }
  391. while ($row = $sth->fetch()) {
  392. $gamecredit = $row['credits'];
  393. }
  394. } else {
  395. //查询本地积分
  396. $gamecredit = DB::result_first("select credits from `store_players` where authid = '{$steamid32}'");
  397. }
  398. //远程 查询游戏积分
  399. $search = array($steamid32full);
  400. DB::query("update " . DB::table('common_member_count') . " set extcredits8 = " . intval($gamecredit) . " where uid='" . $_G['uid'] . "'");
  401. showmessage($plang['alert_user_duihuan_suc'], 'home.php?mod=spacecp&ac=plugin&op=credit&id=xnet_steam_credit_gf:steam');
  402. }
  403. //远程 查询游戏积分
  404. if ($Use_remote_mysql) {
  405. $sql_gamecredits = "select * from `store_players` where authid = '{$steamid32}'";
  406. $sth = $connect->query($sql_gamecredits);
  407. if (!$sth) {
  408. showmessage($plang['alert_couldnot_connect_remote_mysql_server']);
  409. }
  410. while ($row = $sth->fetch()) {
  411. $gamecount = $row['credits'];
  412. }
  413. } else {
  414. //查询本地积分
  415. $gamecount = DB::result_first("select credits from `store_players` where authid = '{$steamid32}'");
  416. }
  417. //远程 查询游戏积分
  418. $bbscredits = C::t('common_member_count')->fetch($_G['uid']);
  419. $jifencount = $bbscredits['extcredits' . $ctype];
  420. function ConvertSteam64To32($oriSteamID64)
  421. {
  422. $steamidcha = SteamID::Parse($oriSteamID64, SteamID::FORMAT_STEAMID64);
  423. $steamid32 = $steamidcha->Format(SteamID::FORMAT_STEAMID32);
  424. $steamid32 = str_replace("STEAM_1:", "", $steamid32);
  425. $steamid32 = str_replace("STEAM_0:", "", $steamid32);
  426. return $steamid32;
  427. /*
  428. if (empty($oriSteamID64)) {
  429. return '';
  430. }
  431. return st64to32($oriSteamID64);
  432. */
  433. }
  434. function st64to32($steam_cid)
  435. {
  436. $id = array('STEAM_0');
  437. $id[1] = substr($steam_cid, -1, 1) % 2 == 0 ? 0 : 1;
  438. $id[2] = bcsub($steam_cid, '76561197960265728');
  439. if (bccomp($id[2], '0') != 1) {
  440. return false;
  441. }
  442. $id[2] = bcsub($id[2], $id[1]);
  443. list($id[2], ) = explode('.', bcdiv($id[2], 2), 2);
  444. return $id[2];
  445. }
  446. function SteamAPI_Fetch_PlayerNotInGame($st64)
  447. {
  448. global $psetting;
  449. $daili = stream_context_create(array('http' => array('timeout' => 15, 'proxy' => 'tcp://127.0.0.1:1080', 'request_fulluri' => True)));
  450. $content = @file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={$psetting['steam_apikey']}&steamids={$st64}&format=json", false, $daili);
  451. //$content = @file_get_contents("https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$psetting[steam_apikey]&steamids=$st64&format=json");
  452. if ($content === false) {
  453. return false;
  454. }
  455. $profile = json_decode($content, true);
  456. if (empty($profile['response']['players'][0]['communityvisibilitystate'])) {
  457. return false;
  458. }
  459. $visibilitystateID = $profile['response']['players'][0]['communityvisibilitystate'];
  460. //如果资料私人拒绝!
  461. $IsClientInGame = $profile['response']['players'][0]['gameid'];
  462. $personastate = $profile['response']['players'][0]['personastate'];
  463. //在线
  464. $personastateflags = $profile['response']['players'][0]['personastateflags'];
  465. //在线类型
  466. if ($personastateflags === "") {
  467. return false;
  468. }
  469. if ($visibilitystateID == 3 && $IsClientInGame == "" && $personastate == 1 && $personastateflags === 0) {
  470. return true;
  471. }
  472. return false;
  473. }
  474. function SteamAPI_Fetch_Player_Reson($st64)
  475. {
  476. global $psetting, $plang;
  477. $daili = stream_context_create(array('http' => array('timeout' => 15, 'proxy' => 'tcp://127.0.0.1:1080', 'request_fulluri' => True)));
  478. $content = @file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={$psetting['steam_apikey']}&steamids={$st64}&format=json", false, $daili);
  479. // $content = @file_get_contents("https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$psetting[steam_apikey]&steamids=$st64&format=json");
  480. if ($content === false) {
  481. $resons = $plang['alert_couldnot_connect_steamapi_server'];
  482. return $resons;
  483. }
  484. $profile = json_decode($content, true);
  485. if (empty($profile['response']['players'][0]['communityvisibilitystate'])) {
  486. $resons = $plang['alert_couldnot_connect_steamapi_server'];
  487. return $resons;
  488. }
  489. $visibilitystateID = $profile['response']['players'][0]['communityvisibilitystate'];
  490. //如果资料私人拒绝!
  491. $IsClientInGame = $profile['response']['players'][0]['gameid'];
  492. $personastate = $profile['response']['players'][0]['personastate'];
  493. //在线
  494. $personastateflags = $profile['response']['players'][0]['personastateflags'];
  495. //在线类型
  496. if ($visibilitystateID != 3) {
  497. $resons = $plang['alert_steam_client_profiles_invisible'];
  498. return $resons;
  499. }
  500. if ($IsClientInGame != "") {
  501. $resons = $plang['alert_steam_client_ingame'];
  502. return $resons;
  503. }
  504. if ($personastateflags > 0) {
  505. $resons = $plang['alert_steam_client_mobile_online'];
  506. return $resons;
  507. }
  508. if ($personastate != 1) {
  509. $resons = $plang['alert_steam_client_offline'];
  510. return $resons;
  511. }
  512. return $resons;
  513. }
  514.  
  515.  
  516.  
  517. <?php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement