nightpatrol

WEBSPY PHP

Aug 7th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.97 KB | None | 0 0
  1. ---|| ALL OF THE PHP IN WEBSPY index.php ||---
  2.  
  3.  
  4. }
  5. $_SESSION['loggedin'] = 1;
  6. include "config.php";
  7. error_reporting(0);
  8. header('Content-Type: text/html; charset=utf-8');
  9.  
  10. $cachefolder = getcwd() . "/../history";
  11.  
  12. if (!file_exists($cachefolder)) {
  13. $old_umask = umask(0);
  14. mkdir($cachefolder, 0775);
  15. umask($old_umask);
  16. }
  17.  
  18. if (isset($_GET["download"])) {
  19. $file = $_GET["file"];
  20. if (file_exists($file) && is_readable($file)) {
  21. if (preg_match('/\.jpg$/',$file)) {
  22. header('Content-Description: File Transfer');
  23. header('Content-Type: application/octet-stream');
  24. header('Content-Disposition: attachment; filename="'.basename($file).'"');
  25. header('Content-Length: ' . filesize($file));
  26. readfile($file);
  27. }
  28. }
  29. }
  30.  
  31. if ($_GET["metadata"] == "true") {
  32. if ($_GET["PrivateKey"] == $PrivateKey) {
  33. $file = fopen("../history/metadata_us1.json", "w");
  34. fwrite($file, $_POST["metadata"]);
  35. echo "Error.MetadataWriteSuccessful";
  36. exit;
  37. } else {
  38. echo "Error.PrivateKeyMismatch";
  39. exit;
  40. }
  41. }
  42.  
  43. if ($_GET["upload"] == "true") {
  44. if ($_GET["PrivateKey"] == $PrivateKey) {
  45. if (is_uploaded_file($_FILES['file']['tmp_name']))
  46. {
  47. $folder_name = $cachefolder . "/" . str_replace(".jpg", "", $_FILES['file']['name']);
  48. if (!file_exists($folder_name)) {
  49. mkdir($folder_name);
  50. }
  51. /* Move uploaded files */
  52. if (move_uploaded_file($_FILES['file']['tmp_name'], $folder_name . "/" . date("Y-n-j_G-i-s") . ".jpg")) {
  53. echo "Error.UploadDone";
  54. } else {
  55. echo "Error.UploadFailed";
  56. }
  57. } else {
  58. echo $_FILES['file']['error'];
  59. echo "Error.UploadFailed";
  60. }
  61. } else {
  62. return "Error.PrivateKeyMismatch";
  63. }
  64. exit;
  65. } elseif ($_GET["delete"] == "true") {
  66. echo $_GET["file"];
  67. if ($_GET["PrivateKey"] == $PrivateKey) {
  68. if (isset($_GET["file"])) {
  69. if (unlink($cachefolder . "/" . $_GET["file"])) {
  70. echo "Error.DeleteSuccessful";
  71. } else {
  72. echo "Error.DeleteNotSuccessful";
  73. }
  74. } else {
  75. echo "Error.FileNotSpecified";
  76. }
  77. } else {
  78. echo "Error.PrivateKeyMismatch";
  79. }
  80. exit;
  81. } else {
  82. $generate = 1;
  83. header("Access-Control-Allow-Origin: \"http://old.linhy.cz\"");
  84. }
  85. ?>
  86.  
  87. <?php
  88. if ($generate == 1) {
  89. $steamid = "";
  90.  
  91. /* Reading metadata from file */
  92. $file = fopen("../history/metadata_us1.json", "r");
  93. $metadata_json = fread($file, filesize("../history/metadata_us1.json"));
  94. $metadata_json = json_decode($metadata_json, true);
  95. foreach ($metadata_json['players'] as $item) {
  96. $metadata[$item['steamid']]['name'] = $item['name'];
  97. $metadata[$item['steamid']]['timestamp'] = $item['timestamp'];
  98. $metadata[$item['steamid']]['serverid'] = $item['serverid'];
  99. }
  100. /* End reading metadata from file */
  101.  
  102. foreach ($metadata as $file => $temp) {
  103. $steamid .= $file . ",";
  104. }
  105.  
  106.  
  107. /* Global player stats */
  108. $url = 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . $SteamAPI_Key . '&steamids=' . $steamid;
  109.  
  110. $cURL = curl_init();
  111. curl_setopt($cURL, CURLOPT_URL, $url);
  112. curl_setopt($cURL, CURLOPT_HTTPGET, true);
  113. curl_setopt($cURL, CURLOPT_RETURNTRANSFER, TRUE);
  114. curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
  115. 'Content-Type: application/json',
  116. 'Accept: application/json'
  117. ));
  118. $result = curl_exec($cURL);
  119. $json = json_decode($result, true);
  120.  
  121. foreach($json['response']['players'] as $item) {
  122. $globalstats[$item['steamid']] .= '"profileurl":"' . $item['profileurl'] . '",';
  123. $globalstats[$item['steamid']] .= '"avatar":"' . $item['avatarmedium'] . '",';
  124.  
  125. if($item['personastate'] == 0) {
  126. $personastate = '"personastate":"Offline",';
  127. } elseif($item['personastate'] == 1) {
  128. $personastate = '"personastate":"Online",';
  129. } elseif($item['personastate'] == 2) {
  130. $personastate = '"personastate":"Busy",';
  131. } elseif($item['personastate'] == 3) {
  132. $personastate = '"personastate":"Away",';
  133. } elseif($item['personastate'] == 4) {
  134. $personastate = '"personastate":"Snooze",';
  135. } elseif($item['personastate'] == 5) {
  136. $personastate = '"personastate":"Looking to trade",';
  137. } elseif($item['personastate'] == 6) {
  138. $personastate = '"personastate":"Looking to play",';
  139. }
  140.  
  141. if ($item['communityvisibilitystate'] == 3) {
  142. $globalstats[$item['steamid']] .= '"communitystate":"Public",';
  143. } else {
  144. $globalstats[$item['steamid']] .= '"communitystate":"Private",';
  145. }
  146.  
  147. $globalstats[$item['steamid']] .= '"lastlogoff":"' . $item['lastlogoff'] . '",';
  148.  
  149. if (isset($item['gameextrainfo'])) {
  150. $personastate = '"personastate": "Playing ' . $item['gameextrainfo'] . '",';
  151. }
  152.  
  153. $globalstats[$item['steamid']] .= $personastate;
  154.  
  155. if (isset($item['gameserverip'])) {
  156. $globalstats[$item['steamid']] .= '"gameserverip":"' . $item['gameserverip'] . '",';
  157. }
  158.  
  159. }
  160. /* Global player stats end */
  161.  
  162. /* Player bans */
  163. $url = 'http://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?key=' . $SteamAPI_Key . '&steamids=' . $steamid;
  164.  
  165. $cURL = curl_init();
  166. curl_setopt($cURL, CURLOPT_URL, $url);
  167. curl_setopt($cURL, CURLOPT_HTTPGET, true);
  168. curl_setopt($cURL, CURLOPT_RETURNTRANSFER, TRUE);
  169. curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
  170. 'Content-Type: application/json',
  171. 'Accept: application/json'
  172. ));
  173. $result = curl_exec($cURL);
  174. $json = json_decode($result, true);
  175.  
  176. foreach($json['players'] as $item) {
  177. $com_ban = ($item['CommunityBanned']) ? 'true' : 'false';
  178. $globalstats[$item['SteamId']] .= '"CommunityBanned":"' . $com_ban . "\",";
  179. $vac_ban = ($item['VACBanned']) ? 'true' : 'false';
  180. $globalstats[$item['SteamId']] .= '"VACBanned":"' . $vac_ban . "\",";
  181. $globalstats[$item['SteamId']] .= '"NumberOfVACBans":"' . $item['NumberOfVACBans'] . "\",";
  182. $globalstats[$item['SteamId']] .= '"DaysSinceLastBan":"' . $item['DaysSinceLastBan'] . "\",";
  183. $globalstats[$item['SteamId']] .= '"NumberOfGameBans":"' . $item['NumberOfGameBans'] . "\",";
  184. $globalstats[$item['SteamId']] .= '"EconomyBan":"' . $item['EconomyBan'] . "\",";
  185. }
  186. /* Player bans end */
  187.  
  188. $check = 0;
  189. foreach ($metadata as $file => $temp) {
  190. $check = 1;
  191. $file .= ".jpg";
  192. echo "<div class=\"imgdiv\"><img class=\"spyimage\" src=\"" . getfile($file) . "\"><span class=\"playerinfo\"><span class=\"player_name_raw\">" . $metadata[str_replace(".jpg", "", $file)]['name'] . "</span><br>SteamID64: <span class=\"steamid_raw\">" . str_replace(".jpg", "", $file) . "</span><br><a class=\"more_info_button\" href=\"#\">More info</a></span><span class=\"hidden_data\" style=\"display: none\">" . getInfo(str_replace(".jpg", "", $file)) . "</span></div>";
  193. }
  194.  
  195. if ($check == 0) {
  196. echo "<center><span class=\"no_players\">No players are online, or there was a problem initializing.</span></center>";
  197. }
  198. }
  199.  
  200. function getFile($file) {
  201. global $cachefolder;
  202. $files = scandir($cachefolder . "/" . str_replace(".jpg", "", $file));
  203. $file_count = count($files);
  204. return "../history/" . str_replace(".jpg", "", $file) . "/" . $files[$file_count - 1];
  205. }
  206.  
  207.  
  208. function getInfo($steamid) {
  209. global $SteamAPI_Key;
  210. global $globalstats;
  211. global $metadata;
  212.  
  213. $return = "{" . $globalstats[$steamid];
  214.  
  215.  
  216. /* Unturned Playtime */
  217. $url = 'http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=' . $SteamAPI_Key . '&steamid=' . $steamid . "&format=json";
  218.  
  219. $cURL = curl_init();
  220. curl_setopt($cURL, CURLOPT_URL, $url);
  221. curl_setopt($cURL, CURLOPT_HTTPGET, true);
  222. curl_setopt($cURL, CURLOPT_RETURNTRANSFER, TRUE);
  223. curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
  224. 'Content-Type: application/json',
  225. 'Accept: application/json'
  226. ));
  227. $result = curl_exec($cURL);
  228. $json = json_decode($result, true);
  229.  
  230. foreach($json['response']['games'] as $item) {
  231. if ($item['appid'] == 304930) {
  232. if (isset($item['playtime_2weeks'])) {
  233. $return .= '"playtime_2weeks":"' . $item['playtime_2weeks'] / 60 . ' hours",';
  234. }
  235. $return .= '"playtime_total":"' . $item['playtime_forever'] / 60 . ' hours",';
  236. }
  237. }
  238.  
  239. $return .= '"screenshot_time":"' . $metadata[$steamid]['timestamp'] . '",';
  240. $return .= '"serverid":"' . $metadata[$steamid]['serverid'] . '"';
  241.  
  242. return $return . "}";
  243.  
  244. }
  245. ?>
  246. <script type="text/javascript">
  247. $(".more_info_button").click(function(e) {
  248. e.preventDefault();
  249. var img_url = $(e.target).parent().siblings(".spyimage").attr("src");
  250. $(".big_image").attr("src", img_url);
  251. $(".player_name").html($(e.target).siblings(".player_name_raw").html());
  252. $(".file_download").attr("href", "?download&file=" + img_url);
  253. $(".more_info_overlay").css("display", "block");
  254. $(".big_image").css("margin-top", ($(".more_info_overlay_black").outerHeight() - $(".big_image").outerHeight()) / 2 + "px");
  255.  
  256. var data = $(e.target).parent().siblings(".hidden_data").html();
  257. var json = jQuery.parseJSON(data);
  258. $(".player_name_url").attr("href", json.profileurl);
  259. if (json.gameserverip === undefined) {
  260. $(".status").html(json.personastate);
  261. } else {
  262. $(".status").html(json.personastate + ' <a href="steam://connect/' + json.gameserverip + '" id="game_url">Connect</a>');
  263. }
  264.  
  265. $(".debug").html("Debugging information: " + data);
  266.  
  267. });
  268.  
  269. $(".more_info_overlay").click(function(e) {
  270. if ($(e.target).is('.more_info_overlay')) {
  271. e.preventDefault();
  272. $(".more_info_overlay").css("display", "none");
  273. }
  274. });
  275.  
  276. $(".close_overlay").click(function(e) {
  277. if ($(e.target).is('.close_overlay')) {
  278. e.preventDefault();
  279. $(".more_info_overlay").css("display", "none");
  280. }
  281. });
  282.  
  283. $(document).keydown(function(e) {
  284. if ($(".more_info_overlay").css("display") == "block" && e.which == 27) {
  285. $(".more_info_overlay").css("display", "none");
  286. };
  287. });
  288. </script>
Advertisement
Add Comment
Please, Sign In to add comment