login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Statistieken > Whatpulse team parser

Whatpulse team parser

Auteur: ikki007 - 04 juni 2007 - 17:16 - Gekeurd door: Stijn - Hits: 3702 - 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:
  1. <html>
  2. <head>
  3. <title>WhatPulse stats - Powered by Ikki007</title>
  4. <style type="text/css">
  5. <!--
  6. body {
  7. font-family: Verdana, Arial, Helvetica, sans-serif;
  8. font-size: 85%;
  9. color: #000;
  10. }
  11.  
  12. h1,h2,h3 {
  13. padding: 10px;
  14. background-color: #F0F0F0;
  15. border-bottom: 1px solid #DDD;
  16. }
  17.  
  18. a {
  19. text-decoration: none;
  20. color: #000
  21. }
  22.  
  23. #div {
  24. position:absolute;
  25. padding: 10px;
  26. background-color: #F0F0F0;
  27. border-bottom: 1px solid #DDD;
  28. top: 200;
  29. left: 450;
  30. width: 300;
  31. }
  32.  
  33. #team {
  34. position:absolute;
  35. padding: 10px;
  36. background-color: #F0F0F0;
  37. border-bottom: 1px solid #DDD;
  38. top: 238;
  39. left: 450;
  40. width: 300;
  41. }
  42.  
  43. .div {
  44. position:absolute;
  45. padding: 10px;
  46. background-color: #F0F0F0;
  47. border-bottom: 1px solid #DDD;
  48. visibility:hidden;
  49. top: 238;
  50. left: 450;
  51. width: 300;
  52. }
  53. -->
  54. </style>
  55. <script language="Javascript">
  56. <!--
  57. function toggleDiv(id,flagit) {
  58. if (flagit=="1"){
  59. if (document.layers) document.layers[''+id+''].visibility = "show"
  60. else if (document.all) document.all[''+id+''].style.visibility = "visible"
  61. else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
  62. if (document.getElementById) document.getElementById('team').style.visibility = "hidden"
  63. }
  64. else
  65. if (flagit=="0"){
  66. if (document.layers) document.layers[''+id+''].visibility = "hide"
  67. else if (document.all) document.all[''+id+''].style.visibility = "hidden"
  68. else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
  69. if (document.getElementById) document.getElementById('team').style.visibility = "visible"
  70. }
  71. }
  72. //-->
  73. </script>
  74. </head>
  75. <body>
  76. <?php
  77. $teamid = 11200; // Vul hier de ID van je team in
  78.  
  79. error_reporting(E_ALL ^ E_NOTICE);
  80.  
  81. function readTeamStats($teamid, $team_stats, $members)
  82. {
  83.  
  84. $statistics_tags = array("TeamName", "TeamDescription", "TeamMembers", "TeamClicks",
  85. "TeamKeys", "TeamRank", "TeamDateFormed", "TeamFounder");
  86.  
  87. $member_tags = array("MemberName", "MemberUserID", "MemberKeys", "MemberClicks",
  88. "MemberLastpulse", "MemberManager", "MemberCountry");
  89.  
  90. $data = implode("", file("http://whatpulse.org/api/teams/".$teamid.".xml"));
  91. $parser = xml_parser_create();
  92. xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
  93. xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
  94. xml_parse_into_struct($parser, $data, $values, $index);
  95. xml_parser_free($parser);
  96.  
  97. for ($x = 0; $x < sizeof($statistics_tags); $x++)
  98. {
  99. $team_stats[$statistics_tags[$x]] = $values[$index[$statistics_tags[$x]][0]]['value'];
  100. }
  101.  
  102. for ($x = 0; $x < sizeof($index['Member']); $x++)
  103. {
  104. for ($y = 0; $y < sizeof($member_tags); $y++)
  105. {
  106. if ($values[$index[$member_tags[$y]][$x]]['level'] == 5)
  107. {
  108. $members[$x][$member_tags[$y]] = $values[$index[$member_tags[$y]][$x]]['value'];
  109. }
  110. }
  111. }
  112. }
  113.  
  114. $team_stats = array();
  115. $members = array();
  116.  
  117. readTeamStats($teamid, &$team_stats, &$members);
  118.  
  119. print '<h1>'.$team_stats['TeamName'].' WhatPulse stats</h1><br />';
  120.  
  121. for($i = 0; $i < sizeof($members); $i++) {
  122.  
  123. $a = $i+1;
  124.  
  125. $pct = round($members[$i]['MemberKeys']*100/$team_stats['TeamKeys'], 2);
  126.  
  127. $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 />');
  128.  
  129. print $a;
  130.  
  131.  
  132. <div id="div'.$i.'" class="div">
  133. ID: '.$members[$i]['MemberUserID'].'<br />
  134. <br />
  135. Nickname: '.$members[$i]['MemberName'].'<br />
  136. <br />
  137. Keys: '.number_format($members[$i]['MemberKeys'],"0",",",".").'<br />
  138. Clicks: '.number_format($members[$i]['MemberClicks'],"0",",",".").'<br />
  139. <br />
  140. Country: '.$members[$i]['MemberCountry'].'<br />
  141. </div>';
  142.  
  143.  
  144. }
  145.  
  146. <div id="team">
  147. Team: '.$team_stats['TeamName'].'<br />
  148. <br />
  149. Members: '.$team_stats['TeamMembers'].'<br />
  150. <br />
  151. Keys: '.number_format($team_stats['TeamKeys'],"0",",",".").'<br />
  152. Clicks: '.number_format($team_stats['TeamClicks'],"0",",",".").'<br />
  153. <br />
  154. Rank: '.$team_stats['TeamRank'].'<br />
  155. </div>
  156.  
  157. ';
  158. ?>
  159. <div id="div">Hover someones name</div>
  160. </body>
  161. </html>
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (4)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.035s