Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL ^ E_WARNING);
- header("Content-Type: image/png");
- function saveUserData($user) {
- $dom = new DOMDocument();
- $html = file_get_contents('http://folding.extremeoverclocking.com/user_summary.php?s=&u='.$user);
- $dom->loadHTML($html);
- $h1s = $dom->getElementsByTagName('h1');
- $tables = $dom->getElementsByTagName('table');
- $trs = $tables->item(6)->getElementsByTagName('tr');
- $tds = $trs->item(1)->getElementsByTagName('td');
- $json = array(
- "userName"=>$h1s->item(0)->textContent,
- "userTeamRank"=>$tds->item(0)->textContent,
- "userOverallRank"=>$tds->item(1)->textContent,
- "userPoints"=>$tds->item(6)->textContent,
- "userPPD"=>$tds->item(3)->textContent,
- );
- $json['date'] = date("Y-m-d G:i:s");
- $usersInfo = fopen("scripts/users.json","r");
- $usersInfo = fread($usersInfo,filesize("scripts/users.json"));
- $usersInfoArr = json_decode($usersInfo);
- $json = json_encode($json);
- $json = json_decode($json);
- $usersInfoArr->{$user} = $json;
- $usersInfoArr = json_encode($usersInfoArr);
- $usersInfo = fopen("scripts/users.json","w");
- fwrite($usersInfo,$usersInfoArr);
- fclose($usersInfo);
- return json_decode($usersInfoArr);
- }
- function saveTeamData($team) {
- $dom = new DOMDocument();
- $html = file_get_contents('http://folding.extremeoverclocking.com/team_summary.php?s=&t='.$team);
- $dom->loadHTML($html);
- $h1s = $dom->getElementsByTagName('h1');
- $tables = $dom->getElementsByTagName('table');
- $trs = $tables->item(6)->getElementsByTagName('tr');
- $tds = $trs->item(1)->getElementsByTagName('td');
- $json = array(
- "teamName"=>$h1s->item(0)->textContent,
- "teamRank"=>$tds->item(0)->textContent,
- "teamPoints"=>$tds->item(9)->textContent,
- "teamPPD"=>$tds->item(3)->textContent,
- "teamToday"=>$tds->item(7)->textContent,
- );
- $json['date'] = date("Y-m-d G:i:s");
- $teamInfo = fopen("scripts/teams.json","r");
- $teamInfo = fread($teamInfo,filesize("scripts/teams.json"));
- $teamInfoArr = json_decode($teamInfo);
- $json = json_encode($json);
- $json = json_decode($json);
- $teamInfoArr->{$team} = $json;
- $teamInfoArr = json_encode($teamInfoArr);
- $teamInfo = fopen("scripts/teams.json","w");
- fwrite($teamInfo,$teamInfoArr);
- fclose($teamInfo);
- return json_decode($teamInfoArr);
- }
- if(isset($_GET['u']) && isset($_GET['t'])) {
- $userInfoFile = fopen('scripts/users.json','r');
- $userInfo = fread($userInfoFile,filesize('scripts/users.json'));
- fclose($userInfoFile);
- $userInfo = json_decode($userInfo);
- if(isset($userInfo->{$_GET['u']})) {
- $user = $userInfo->{$_GET['u']};
- } else {
- $userInfo = saveUserData($_GET['u']);
- $user = $userInfo->{$_GET['u']};
- }
- $lastDate = $user->date;
- $now = date("Y-m-d G:i:s");
- $hours = (strtotime($now) - strtotime($lastDate)) / 3600;
- if($hours >= 1) {
- saveUserData($_GET['u']);
- }
- $user = $userInfo->{$_GET['u']};
- $teamInfoFile = fopen('scripts/teams.json','r');
- $teamInfo = fread($teamInfoFile,filesize('scripts/teams.json'));
- fclose($teamInfoFile);
- $teamInfo = json_decode($teamInfo);
- if(isset($teamInfo->{$_GET['t']})) {
- $team = $teamInfo->{$_GET['t']};
- } else {
- $teamInfo = saveTeamData($_GET['t']);
- $team = $teamInfo->{$_GET['t']};
- }
- $lastDate = $team->date;
- $now = date("Y-m-d G:i:s");
- $hours = (strtotime($now) - strtotime($lastDate)) / 3600;
- if($hours >= 1) {
- saveTeamData($_GET['t']);
- }
- if(isset($_GET['b']) && file_exists("images/sigimages/".$_GET['b'].".png")) {
- $template = imagecreatefrompng("images/sigimages/".$_GET['b'].'.png');
- } else {
- $template = imagecreatefrompng('images/sigimages/luna1.png');
- }
- $white = imagecolorallocate($template, 255, 255, 255);
- $yellow = imagecolorallocate($template, 255, 255, 0);
- $font = 'images/fonts/UbuntuMono-R.ttf';
- if(strlen($user->userName) > 14) {
- $username = substr($user->userName,0,14)."...";
- } else {
- $username = $user->userName;
- }
- if(strlen($team->teamName) > 13) {
- $teamname = substr($team->teamName,0,13)."...";
- } else {
- $teamname = $team->teamName;
- }
- imagettftext($template,10,0,69,25,$white,$font,'User:');
- imagettftext($template,10,0,105,25,$yellow,$font,$username);
- imagettftext($template,10,0,15,37,$white,$font,'Rank on Team:');
- imagettftext($template,10,0,105,37,$yellow,$font,$user->userTeamRank);
- imagettftext($template,10,0,15,49,$white,$font,'Overall Rank:');
- imagettftext($template,10,0,105,49,$yellow,$font,$user->userOverallRank);
- imagettftext($template,10,0,22,61,$white,$font,'User Points:');
- imagettftext($template,10,0,105,61,$yellow,$font,$user->userPoints);
- imagettftext($template,10,0,42,73,$white,$font,'User PPD:');
- imagettftext($template,10,0,105,73,$yellow,$font,$user->userPPD);
- imagettftext($template,10,0,219,25,$white,$font,'Team Name:');
- imagettftext($template,10,0,289,25,$yellow,$font,$teamname);
- imagettftext($template,10,0,199,37,$white,$font,'Rank of Team:');
- imagettftext($template,10,0,289,37,$yellow,$font,$team->teamRank);
- imagettftext($template,10,0,206,49,$white,$font,'Team Points:');
- imagettftext($template,10,0,289,49,$yellow,$font,$team->teamPoints);
- imagettftext($template,10,0,226,61,$white,$font,'Team PPD:');
- imagettftext($template,10,0,289,61,$yellow,$font,$team->teamPPD);
- imagettftext($template,10,0,199,73,$white,$font,'Points Today:');
- imagettftext($template,10,0,289,73,$yellow,$font,$team->teamToday);
- imagepng($template);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement