Somebody have statistics code like this???

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • It will be build in time on version 2.0
      I remain at your disposal on the forum for any questions or help.

      A help is of course not a creation of a mod



      -------------------------------------------------------
      My personal game
      OUnivers - Close
      Xterium - Abandonned
    • Source Code

      1. {block name="title" prepend}{$LNG.lm_statistics}{/block}
      2. {block name="content"}
      3. <div id="page">
      4. <div id="content">
      5. <div id="ally_content" class="conteiner">
      6. <div class="gray_stripe">
      7. {$LNG.st_statistics} ({$LNG.st_updated}: {$stat_date}) {$LNG.st_next}: <span style="color:#FC0"><b id=brpstats></b></span>
      8. </div>
      9. <form name="stats" id="stats" method="post" action="">
      10. <table class="tablesorter ally_ranks">
      11. <tr>
      12. <td>
      13. <label for="who">{$LNG.st_show}</label> <select name="who" id="who" onchange="$('#stats').submit();">{html_options options=$Selectors.who selected=$who}</select>
      14. </td>
      15. <td>
      16. <label for="type">{$LNG.st_per}</label> <select name="type" id="type" onchange="$('#stats').submit();">{html_options options=$Selectors.type selected=$type}</select>
      17. </td>
      18. <td>
      19. <label for="range">{$LNG.st_in_the_positions}</label> <select name="range" id="range" onchange="$('#stats').submit();">{html_options options=$Selectors.range selected=$range}</select>
      20. </td>
      21. </tr>
      22. </table>
      23. </form>
      24. <table class="table519">
      25. {if $who == 1}
      26. {include file="shared.statistics.playerTable.tpl"}
      27. {elseif $who == 2}
      28. {include file="shared.statistics.allianceTable.tpl"}
      29. {/if}
      30. </table>
      31. <script type=text/javascript>
      32. v = new Date();
      33. var brpstats = document.getElementById('brpstats');
      34. function tstats(){
      35. n = new Date();
      36. ss = {$st_out};
      37. s = ss - Math.round( (n.getTime() - v.getTime()) / 1000.);
      38. m = 0;
      39. h = 0;
      40. d = 0;
      41. if ( s < 0 ) {
      42. var zeit = new Date();
      43. var ende = zeit.getTime();
      44. ende = ende + 100;
      45. function countdown() {
      46. var zeit2 = new Date();
      47. var jetzt = zeit2.getTime();
      48. if(jetzt >= ende) {
      49. brpstats.innerHTML = '<blink><b><font color=red>...</font></b></blink>';
      50. }
      51. }
      52. setInterval(countdown, 1000);
      53. } else
      54. {
      55. if ( s > 59 ) { m = Math.floor( s / 60 ); s = s - m * 60; }
      56. if ( m > 59 ) { h = Math.floor( m / 60 ); m = m - h * 60; }
      57. if ( h > 24 ) { d = Math.floor( h / 24 ); h = h - d * 24; }
      58. if ( s < 10 ) { s = '0' + s }
      59. if ( m < 10 ) { m = '0' + m }
      60. if ( h < 10 ) { h = '' + h }
      61. if ( s >= 0 ) { s = s + 's' }
      62. if ( m > 0 ) { m = m + 'm' } else m = '';
      63. if ( m == 0 && h > 0 ) { m = '0' + m + 'm'}
      64. if ( h > 0 ) { h = h + '??' } else h = '';
      65. if ( d > 0 ) { d = d + '??' } else d = '';
      66. brpstats.innerHTML = ' <b><font>' + d + ' ' + h + ' ' + m + ' ' + s + '</font></b>';
      67. }
      68. window.setTimeout('tstats();',999);
      69. }
      70. window.onload=tstats();
      71. </script>
      72. {/block}
      Display All
    • Source Code

      1. {block name="title" prepend}{$LNG.lm_statistics}{/block}
      2. {block name="content"}
      3. <div id="content">
      4. <div id="ally_content" class="conteiner">
      5. <table style="width:680px;">
      6. <div class="gray_stripe">
      7. <th colspan="4">Top 30 Votings</th>
      8. </div>
      9. <tr>
      10. <th colspan="4"><center><a href='./game.php?page=statistics' style="color:red">Back to Player Statistic</a></center></th>
      11. </tr>
      12. <tr>
      13. <td colspan="4">Best Voters for ZyperaxGalaxy<br>
      14. Top 3 will respectivly receive 150k, 100k & 50k DM at the end of the month</td>
      15. </tr>
      16. <tr style="height:23px;">
      17. <td style="width:80px"><strong style="color:orange;">Ranking</strong></td>
      18. <td style="width:250px"><strong style="color:orange;">Players</strong></td>
      19. <td><strong style="color:orange;">Amount of votes</strong></td>
      20. </tr>
      21. {foreach from=$voturile key=k item=v}
      22. <tr>
      23. <td style="height:40px;">{$v.rank}</td>
      24. <td><a href="#" onclick="return Dialog.Playercard({$v.id}" {if $v.id == $id_users} style="color:lime"{/if}>{$v.username}</a></td>
      25. <td>{$v.vcount}</td>
      26. </tr>
      27. {/foreach}
      28. </table>
      29. {/block}
      Display All
    • Source Code

      1. class ShowStatisticsPage extends AbstractPage
      2. {
      3. public static $requireModule = MODULE_STATISTICS;
      4. function __construct()
      5. {
      6. parent::__construct();
      7. }
      8. function show()
      9. {
      10. global $USER, $CONF, $LNG, $UNI;
      11. $who = HTTP::_GP('who', 1);
      12. $type = HTTP::_GP('type', 1);
      13. $range = HTTP::_GP('range', 1);
      14. $CurrentUserPoints = $GLOBALS['DATABASE']->uniquequery("SELECT *FROM ".STATPOINTS." where `id_owner` = ".$USER['id']." and `stat_type` = '1';");
      15. switch ($type)
      16. {
      17. case 2:
      18. $Order = "fleet_rank";
      19. $Points = "fleet_points";
      20. $Rank = "fleet_rank";
      21. $OldRank = "fleet_old_rank";
      22. break;
      23. case 3:
      24. $Order = "tech_rank";
      25. $Points = "tech_points";
      26. $Rank = "tech_rank";
      27. $OldRank = "tech_old_rank";
      28. break;
      29. case 4:
      30. $Order = "build_rank";
      31. $Points = "build_points";
      32. $Rank = "build_rank";
      33. $OldRank = "build_old_rank";
      34. break;
      35. case 5:
      36. $Order = "defs_rank";
      37. $Points = "defs_points";
      38. $Rank = "defs_rank";
      39. $OldRank = "defs_old_rank";
      40. break;
      41. case 6:
      42. $Order = "ach_rank";
      43. $Points = "ach_points";
      44. $Rank = "ach_rank";
      45. $OldRank = "ach_old_rank";
      46. break;
      47. default:
      48. $Order = "total_rank";
      49. $Points = "total_points";
      50. $Rank = "total_rank";
      51. $OldRank = "total_old_rank";
      52. break;
      53. }
      54. $RangeList = array();
      55. switch($who)
      56. {
      57. case 1:
      58. $MaxUsers = Config::get('users_amount');
      59. $range = min($range, $MaxUsers);
      60. $LastPage = max(1, ceil($MaxUsers / 100));
      61. for ($Page = 0; $Page < $LastPage; $Page++)
      62. {
      63. $PageValue = ($Page * 100) + 1;
      64. $PageRange = $PageValue + 99;
      65. $Selector['range'][$PageValue] = $PageValue."-".$PageRange;
      66. }
      67. $start = max(floor(($range - 1) / 100) * 100, 0);
      68. $stats_sql = 'SELECT DISTINCT s.*, u.id, u.race, u.username,u.urlaubs_modus, u.ally_id,u.bana,u.banaday,u.onlinetime,a.fraction,a.FraLevel, a.ally_name FROM '.STATPOINTS.' as s
      69. INNER JOIN '.USERS.' as u ON u.id = s.id_owner
      70. LEFT JOIN '.ALLIANCE.' as a ON a.id = s.id_ally
      71. WHERE s.`universe` = '.$UNI.' AND s.`stat_type` = 1 '.((Config::get('stat') == 2)?'AND u.`authlevel` < '.Config::get('stat_level').' ':'').'
      72. ORDER BY `'. $Order .'` ASC LIMIT '. $start .',100;';
      73. $query = $GLOBALS['DATABASE']->query($stats_sql);
      74. $RangeList = array();
      75. $fraction = $GLOBALS['DATABASE']->getFirstCell("SELECT fraction FROM ".ALLIANCE." WHERE id = ".$USER['ally_id'].";");
      76. $fra1 = '<img src="styles/images/alliance/fraction_'.$fraction.'.png" alt="1" width="19" height="18">';
      77. while ($StatRow = $GLOBALS['DATABASE']->fetch_array($query))
      78. {
      79. $isFriend = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM ".BUDDY." WHERE (sender = ".$USER['id']." AND owner = ".$StatRow['id']." ) OR (sender = ".$StatRow['id']." AND owner = ".$USER['id'].");");
      80. $isEnnemie = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM uni1_ennemies WHERE sender = ".$USER['id']." AND owner = ".$StatRow['id'].";");
      81. $Noob = CheckNoobProtec($CurrentUserPoints,$StatRow,$StatRow);
      82. if(empty($Noob['NoobPlayer']) && empty($Noob['StrongPlayer'])){
      83. $isNoob = 0;
      84. }else{
      85. if($Noob['NoobPlayer'] )
      86. $isNoob = 1;
      87. elseif($Noob['StrongPlayer'])
      88. $isNoob = 2;
      89. }
      90. $RangeList[] = array(
      91. 'id' => $StatRow['id'],
      92. 'name' => $StatRow['username'],
      93. 'race' => $StatRow['race'],
      94. 'points' => pretty_number($StatRow[$Points]),
      95. 'fraction2' => $fraction,
      96. 'allyid' => $StatRow['ally_id'],
      97. 'level' => $StatRow['FraLevel'],
      98. 'fraction' => $StatRow['fraction'] ? $fra1 : '',
      99. 'rank' => $StatRow[$Rank],
      100. 'allyname' => $StatRow['ally_name'],
      101. 'ranking' => $StatRow[$OldRank] - $StatRow[$Rank],
      102. 'isFriend' => $isFriend,
      103. 'isEnnemie' => $isEnnemie,
      104. 'isnoob' => $isNoob,
      105. 'isVac' => ($StatRow['urlaubs_modus'] == 1) ? 0 : 1,
      106. 'isInac' => ($StatRow['onlinetime'] < TIMESTAMP - 7 * 24 * 60 * 60) ? 0 : 1,
      107. );
      108. }
      109. $GLOBALS['DATABASE']->free_result($query);
      110. break;
      111. case 2:
      112. $MaxAllys = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM ".ALLIANCE." WHERE `ally_universe` = '".$UNI."';");
      113. $range = min($range, $MaxAllys);
      114. $LastPage = max(1, ceil($MaxAllys / 100));
      115. for ($Page = 0; $Page < $LastPage; $Page++)
      116. {
      117. $PageValue = ($Page * 100) + 1;
      118. $PageRange = $PageValue + 99;
      119. $Selector['range'][$PageValue] = $PageValue."-".$PageRange;
      120. }
      121. $start = max(floor(($range - 1) / 100) * 100, 0);
      122. $stats_sql = 'SELECT DISTINCT s.*, a.id, a.ally_members, a.ally_name FROM '.STATPOINTS.' as s
      123. INNER JOIN '.ALLIANCE.' as a ON a.id = s.id_owner
      124. WHERE `universe` = '.$UNI.' AND `stat_type` = 2
      125. ORDER BY `'. $Order .'` ASC LIMIT '. $start .',100;';
      126. $query = $GLOBALS['DATABASE']->query($stats_sql);
      127. while ($StatRow = $GLOBALS['DATABASE']->fetch_array($query))
      128. {
      129. $isWar = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM ".DIPLO." WHERE (owner_1 = ".$USER['ally_id']." AND owner_2 = ".$StatRow['id'].") OR (owner_1 = ".$StatRow['id']." AND owner_2 = ".$USER['ally_id'].") AND accept = '1' AND level = '5';");
      130. $isUnion = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM ".DIPLO." WHERE (owner_1 = ".$USER['ally_id']." AND owner_2 = ".$StatRow['id'].") OR (owner_1 = ".$StatRow['id']." AND owner_2 = ".$USER['ally_id'].") AND accept = '1' AND level = '2';");
      131. $RangeList[] = array(
      132. 'id' => $StatRow['id'],
      133. 'name' => $StatRow['ally_name'],
      134. 'members' => $StatRow['ally_members'],
      135. 'rank' => $StatRow[$Rank],
      136. 'mppoints' => pretty_number(floor($StatRow[$Points] / $StatRow['ally_members'])),
      137. 'points' => pretty_number($StatRow[$Points]),
      138. 'ranking' => $StatRow[$OldRank] - $StatRow[$Rank],
      139. 'isWar' => $isWar,
      140. 'isUnion' => $isUnion,
      141. );
      142. }
      143. $GLOBALS['DATABASE']->free_result($query);
      144. break;
      145. }
      146. $Selector['who'] = array(1 => $LNG['st_player'], 2 => $LNG['st_alliance']);
      147. $Selector['type'] = array(1 => $LNG['st_points'], 2 => $LNG['st_fleets'], 3 => $LNG['st_researh'], 4 => $LNG['st_buildings'], 5 => $LNG['st_defenses'], 6 => 'Achievements');
      148. $statkai = $GLOBALS['DATABASE']->uniquequery("SELECT nextTime FROM ".CRONJOBS." WHERE cronjobID = 2;");
      149. $this->tplObj->loadscript("jquery.countdown.js");
      150. $this->tplObj->assign_vars(array(
      151. 'Selectors' => $Selector,
      152. 'who' => $who,
      153. 'type' => $type,
      154. 'range' => floor(($range - 1) / 100) * 100 + 1,
      155. 'RangeList' => $RangeList,
      156. 'CUser_ally' => $USER['ally_id'],
      157. 'CUser_id' => $USER['id'],
      158. 'stat_date' => _date($LNG['php_tdformat'], Config::get('stat_last_update'), $USER['timezone']),
      159. 'st_out' => $statkai['nextTime'] - TIMESTAMP,
      160. ));
      161. $this->display('page.statistics.default.tpl');
      162. }
      163. }
      Display All
    • I presume this is old stats vs new stats, correct me if wrong.

      At my view this sould be pretty simple to do through class.statbuilder adding new column like tech_points_old after tech and store old points on database through Database->update command.


      then on class.ShowStatisticsPage you just do $smth['points'] - $smth['points_old'] [since statspage runs through cases and each case has it's vars defined]

      and to finish on shared.player.stats you add {if ($RangeInfo.points - $RangeInfo.old_points < 0}<font color="red">{$Rangeinfo.diff}</font>{else}<font color="lime">...{/if}

      Pretty simple.
      Looking for good VPS to host your game? Use DigitalOcean and get 10$ bonus credit!

      Stellaron - Grand Strategy OGame Universe, discover the secrets of Ancient Technology
      Upcoming expansion: Stellaron StarGate
    • Russoll wrote:

      sorrt this old 1.7.3....he/she asked for older script so i posted it
      I just replied without noticing you have added some content already.

      My bad :)
      Looking for good VPS to host your game? Use DigitalOcean and get 10$ bonus credit!

      Stellaron - Grand Strategy OGame Universe, discover the secrets of Ancient Technology
      Upcoming expansion: Stellaron StarGate
    • Qwa wrote:

      I presume this is old stats vs new stats, correct me if wrong.

      At my view this sould be pretty simple to do through class.statbuilder adding new column like tech_points_old after tech and store old points on database through Database->update command.


      then on class.ShowStatisticsPage you just do $smth['points'] - $smth['points_old'] [since statspage runs through cases and each case has it's vars defined]

      and to finish on shared.player.stats you add {if ($RangeInfo.points - $RangeInfo.old_points < 0}<font color="red">{$Rangeinfo.diff}</font>{else}<font color="lime">...{/if}

      Pretty simple.
      old stats vs new stats=yes
      I using xterium version ,you have the complete code?
      thanks
    • Qwa wrote:

      I presume this is old stats vs new stats, correct me if wrong.

      At my view this sould be pretty simple to do through class.statbuilder adding new column like tech_points_old after tech and store old points on database through Database->update command.


      then on class.ShowStatisticsPage you just do $smth['points'] - $smth['points_old'] [since statspage runs through cases and each case has it's vars defined]

      and to finish on shared.player.stats you add {if ($RangeInfo.points - $RangeInfo.old_points < 0}<font color="red">{$Rangeinfo.diff}</font>{else}<font color="lime">...{/if}

      Pretty simple.
      You just need to rewrite class statpage to store the current points into old column before the statistic update starts and you should be fine.
      Looking for good VPS to host your game? Use DigitalOcean and get 10$ bonus credit!

      Stellaron - Grand Strategy OGame Universe, discover the secrets of Ancient Technology
      Upcoming expansion: Stellaron StarGate