Whatpulse team parser
Auteur: ikki007 - 04 juni 2007 - 17:16 - Gekeurd door: Stijn - Hits: 3712 - Aantal punten: (0 stemmen)
Whatpulse is een project. (whatpulse.org)
Hierbij zijn er ook team, dit scriptje haalt de team info op en leest het mooi uit.
Je team moet webAPI wel hebben ingeschakeld.
http://whatpulse.org/webapi/
Ik heb het team_parse script van whatpulse gebruikt bij het maken van dit script.
Ik heb er ongeveer een uur aan gewerkt.
|
Code: |
<html>
<head>
<title>WhatPulse stats - Powered by Ikki007</title>
<style type="text/css">
<!--
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 85%;
color: #000;
}
h1,h2,h3 {
padding: 10px;
background-color: #F0F0F0;
border-bottom: 1px solid #DDD;
}
a {
text-decoration: none;
color: #000
}
#div {
position:absolute;
padding: 10px;
background-color: #F0F0F0;
border-bottom: 1px solid #DDD;
top: 200;
left: 450;
width: 300;
}
#team {
position:absolute;
padding: 10px;
background-color: #F0F0F0;
border-bottom: 1px solid #DDD;
top: 238;
left: 450;
width: 300;
}
.div {
position:absolute;
padding: 10px;
background-color: #F0F0F0;
border-bottom: 1px solid #DDD;
visibility:hidden;
top: 238;
left: 450;
width: 300;
}
-->
</style>
<script language="Javascript">
<!--
function toggleDiv(id,flagit) {
if (flagit=="1"){
if (document.layers) document.layers[''+id+''].visibility = "show"
else if (document.all) document.all[''+id+''].style.visibility = "visible"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
if (document.getElementById) document.getElementById('team').style.visibility = "hidden"
}
else
if (flagit=="0"){
if (document.layers) document.layers[''+id+''].visibility = "hide"
else if (document.all) document.all[''+id+''].style.visibility = "hidden"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
if (document.getElementById) document.getElementById('team').style.visibility = "visible"
}
}
//-->
</script>
</head>
<body>
<?php
$teamid = 11200; // Vul hier de ID van je team in
error_reporting(E_ALL ^ E_NOTICE);
function readTeamStats($teamid, $team_stats, $members)
{
$statistics_tags = array("TeamName", "TeamDescription", "TeamMembers", "TeamClicks",
"TeamKeys", "TeamRank", "TeamDateFormed", "TeamFounder");
$member_tags = array("MemberName", "MemberUserID", "MemberKeys", "MemberClicks",
"MemberLastpulse", "MemberManager", "MemberCountry");
$data = implode("", file("http://whatpulse.org/api/teams/".$teamid.".xml"));
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $values, $index);
xml_parser_free($parser);
for ($x = 0; $x < sizeof($statistics_tags); $x++)
{
$team_stats[$statistics_tags[$x]] = $values[$index[$statistics_tags[$x]][0]]['value'];
}
for ($x = 0; $x < sizeof($index['Member']); $x++)
{
for ($y = 0; $y < sizeof($member_tags); $y++)
{
if ($values[$index[$member_tags[$y]][$x]]['level'] == 5)
{
$members[$x][$member_tags[$y]] = $values[$index[$member_tags[$y]][$x]]['value'];
}
}
}
}
$team_stats = array();
$members = array();
readTeamStats($teamid, &$team_stats, &$members);
print '<h1>'.$team_stats['TeamName'].' WhatPulse stats</h1><br />';
for($i = 0; $i < sizeof($members); $i++) {
$a = $i+1;
$pct = round($members[$i]['MemberKeys']*100/$team_stats['TeamKeys'], 2);
$a = ($a == 1 ? $a.' - <a href="http://whatpulse.org/stats/users/'.$members[$i]['MemberUserID'].'/" onMouseOver="toggleDiv(\'div'.$i.'\',1)" onMouseOut="toggleDiv(\'div'.$i.'\',0)" target="_blank">'.$members[$i]['MemberName'].'</a> ('.number_format($members[$i]['MemberKeys'],"0",",",".").') ('.$pct.'%)<br />' : $a.' - <a href="http://whatpulse.org/stats/users/'.$members[$i]['MemberUserID'].'/" onMouseOver="toggleDiv(\'div'.$i.'\',1)" onMouseOut="toggleDiv(\'div'.$i.'\',0)" target="_blank">'.$members[$i]['MemberName'].'</a> (-'.number_format(($members[0]['MemberKeys']-$members[$i]['MemberKeys']),"0",",",".").') ('.$pct.'%)<br />');
print $a;
print '
<div id="div'.$i.'" class="div">
ID: '.$members[$i]['MemberUserID'].'<br />
<br />
Nickname: '.$members[$i]['MemberName'].'<br />
<br />
Keys: '.number_format($members[$i]['MemberKeys'],"0",",",".").'<br />
Clicks: '.number_format($members[$i]['MemberClicks'],"0",",",".").'<br />
<br />
Country: '.$members[$i]['MemberCountry'].'<br />
</div>';
}
print '
<div id="team">
Team: '.$team_stats['TeamName'].'<br />
<br />
Members: '.$team_stats['TeamMembers'].'<br />
<br />
Keys: '.number_format($team_stats['TeamKeys'],"0",",",".").'<br />
Clicks: '.number_format($team_stats['TeamClicks'],"0",",",".").'<br />
<br />
Rank: '.$team_stats['TeamRank'].'<br />
</div>
';
?>
<div id="div">Hover someones name</div>
</body>
</html>
<html> <head> <title>WhatPulse stats - Powered by Ikki007</title> <style type="text/css"> <!-- body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 85%; color: #000; } h1,h2,h3 { padding: 10px; background-color: #F0F0F0; border-bottom: 1px solid #DDD; } a { text-decoration: none; color: #000 } #div { position:absolute; padding: 10px; background-color: #F0F0F0; border-bottom: 1px solid #DDD; top: 200; left: 450; width: 300; } #team { position:absolute; padding: 10px; background-color: #F0F0F0; border-bottom: 1px solid #DDD; top: 238; left: 450; width: 300; } .div { position:absolute; padding: 10px; background-color: #F0F0F0; border-bottom: 1px solid #DDD; visibility:hidden; top: 238; left: 450; width: 300; } --> </style> <script language="Javascript"> <!-- function toggleDiv(id,flagit) { if (flagit=="1"){ if (document.layers) document.layers[''+id+''].visibility = "show" else if (document.all) document.all[''+id+''].style.visibility = "visible" else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible" if (document.getElementById) document.getElementById('team').style.visibility = "hidden" } else if (flagit=="0"){ if (document.layers) document.layers[''+id+''].visibility = "hide" else if (document.all) document.all[''+id+''].style.visibility = "hidden" else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden" if (document.getElementById) document.getElementById('team').style.visibility = "visible" } } //--> </script> </head> <body> <?php $teamid = 11200; // Vul hier de ID van je team in function readTeamStats($teamid, $team_stats, $members) { $statistics_tags = array("TeamName", "TeamDescription", "TeamMembers", "TeamClicks", "TeamKeys", "TeamRank", "TeamDateFormed", "TeamFounder"); $member_tags = array("MemberName", "MemberUserID", "MemberKeys", "MemberClicks", "MemberLastpulse", "MemberManager", "MemberCountry"); $data = implode("", file("http://whatpulse.org/api/teams/".$teamid.".xml")); for ($x = 0; $x < sizeof($statistics_tags); $x++) { $team_stats[$statistics_tags[$x]] = $values[$index[$statistics_tags[$x]][0]]['value']; } for ($x = 0; $x < sizeof($index['Member']); $x++) { for ($y = 0; $y < sizeof($member_tags); $y++) { if ($values[$index[$member_tags[$y]][$x]]['level'] == 5) { $members[$x][$member_tags[$y]] = $values[$index[$member_tags[$y]][$x]]['value']; } } } } readTeamStats($teamid, &$team_stats, &$members); print '<h1>'.$team_stats['TeamName'].' WhatPulse stats</h1><br />'; for($i = 0; $i < sizeof($members); $i++) { $a = $i+1; $pct = round($members[$i]['MemberKeys']*100/$team_stats['TeamKeys'], 2); $a = ($a == 1 ? $a.' - <a href="http://whatpulse.org/stats/users/'.$members[$i]['MemberUserID'].'/" onMouseOver="toggleDiv(\'div '.$i.'\ ',1)" onMouseOut="toggleDiv(\'div '.$i.'\ ',0)" target="_blank">'.$members[$i]['MemberName'].'</a> ('.number_format($members[$i]['MemberKeys'],"0",",",".").') ('.$pct.'%)<br />' : $a.' - <a href="http://whatpulse.org/stats/users/'.$members[$i]['MemberUserID'].'/" onMouseOver="toggleDiv(\'div '.$i.'\ ',1)" onMouseOut="toggleDiv(\'div '.$i.'\ ',0)" target="_blank">'.$members[$i]['MemberName'].'</a> (-'.number_format(($members[0]['MemberKeys']-$members[$i]['MemberKeys']),"0",",",".").') ('.$pct.'%)<br />'); <div id="div'.$i.'" class="div"> ID: '.$members[$i]['MemberUserID'].'<br /> <br /> Nickname: '.$members[$i]['MemberName'].'<br /> <br /> Keys: '.number_format($members[$i]['MemberKeys'],"0",",",".").'<br /> Clicks: '.number_format($members[$i]['MemberClicks'],"0",",",".").'<br /> <br /> Country: '.$members[$i]['MemberCountry'].'<br /> </div>'; } <div id="team"> Team: '.$team_stats['TeamName'].'<br /> <br /> Members: '.$team_stats['TeamMembers'].'<br /> <br /> Keys: '.number_format($team_stats['TeamKeys'],"0",",",".").'<br /> Clicks: '.number_format($team_stats['TeamClicks'],"0",",",".").'<br /> <br /> Rank: '.$team_stats['TeamRank'].'<br /> </div> '; ?> <div id="div">Hover someones name</div> </body> </html>
Download code (.txt)
|
|
Stemmen |
Niet ingelogd. |
|