Added Steam/SGS cURL version
This commit is contained in:
parent
1cc4bbd392
commit
9a40fa0b45
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/*
|
||||
* SteamGroupStatus (cURL)
|
||||
* Copyright (C) 2012 Maximilian "MadMakz" Lotz
|
||||
*
|
||||
* http://madmakz.com/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 3 as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
$gruppe = "cgx24"; // Groupname at the end of http://steamcommunity.com/groups/
|
||||
echo stgrp_status($gruppe);
|
||||
|
||||
function stgrp_status($group = false){
|
||||
if(!$group){ return "<div class=\"blockrow\"><b>No group set.</b></div>"; }
|
||||
|
||||
$error_reporting = error_reporting();
|
||||
error_reporting(0);
|
||||
$url = file_get_contents_curl('http://steamcommunity.com/groups/'.$group, "SteamGroupStatus Query Script");
|
||||
if($url["header"]["http_code"] != "200"){
|
||||
error_reporting($error_reporting);
|
||||
return "<div class=\"blockrow\"><b>Steamcommunity appears to be down.</b></div>";
|
||||
}
|
||||
error_reporting($error_reporting);
|
||||
|
||||
$return = "<div class=\"blockrow\">\n";
|
||||
|
||||
preg_match("#<h1>(.+)</h1>#sU", $url["data"], $aMatches);
|
||||
$return .= "<a class=\"clanname\" href='http://steamcommunity.com/groups/$group' target='_blank'>".$aMatches[1]."</a>\n";
|
||||
$return .= "<br>\n";
|
||||
|
||||
preg_match("#<span class=\"count \">(.+)</span>#sU", $url["data"], $aMembers);
|
||||
$return .= "<span class=\"resultsb\">".$aMembers[1]." Members</span>\n";
|
||||
$return .= "<br>\n";
|
||||
|
||||
preg_match_all("#<div class=\"count \">(.+)</div>#sU", $url["data"], $aActive);
|
||||
$return .= "<span class=\"membersInGame\"><font color=#8bc53f>".$aActive[1][0]." In-Game</font></span>\n";
|
||||
$return .= "<br>";
|
||||
$return .= "<span class=\"membersOnline\"><font color=#62a7e3>".$aActive[1][1]." Online</font></span>\n";
|
||||
|
||||
$return .= "</div>";
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
function file_get_contents_curl($url, $agent = "My Agent"){
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
|
||||
$data = curl_exec($ch);
|
||||
$header = curl_getinfo($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
return array("data" => $data, "header" => $header);
|
||||
}
|
||||
?>
|
Reference in New Issue