Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.86 KB | None | 0 0
  1. <?php
  2. global $assetRepo;
  3. global $conn;
  4. global $clock;
  5.  
  6. $mon_name = json_decode(file_get_contents('https://raw.githubusercontent.com/cecpk/OSM-Rocketmap/master/static/data/pokemon.json'), true);
  7. $forms = json_decode(file_get_contents('https://raw.githubusercontent.com/darkelement1987/PoracleJS/patch-6/src/util/forms.json'), true);
  8. if(!isset($_GET['show100']) && !isset($_GET['pokemon']) && !isset($_GET['form'])){
  9. if(isset($_GET['mode'])){
  10. if($_GET['mode']!='raid' && $_GET['mode']!='pokemon' && $_GET['mode']!='0' && $_GET['mode']!='100'){
  11. $mode=' (Wild Pokemon)';
  12. $type='pokemon';
  13. $end='disappear_time';
  14. $query = 'SELECT pokemon_id, form, count, rank FROM ( SELECT pokemon_id, form, count, row_number() OVER ( ORDER BY COUNT DESC, pokemon_id ASC) AS rank FROM ( SELECT pokemon_id, form, COUNT(pokemon_id) AS COUNT FROM pokemon GROUP BY pokemon_id, form ) a ) b WHERE pokemon_id is not null ORDER BY rank asc, pokemon_id asc';
  15. } else {
  16. if($_GET['mode']=='pokemon'){
  17. $mode=' (Wild Pokemon)';
  18. $type='pokemon';
  19. $end='disappear_time';
  20. $query = 'SELECT pokemon_id, form, count, rank FROM ( SELECT pokemon_id, form, count, row_number() OVER ( ORDER BY COUNT DESC, pokemon_id ASC) AS rank FROM ( SELECT pokemon_id, form, COUNT(pokemon_id) AS COUNT FROM pokemon GROUP BY pokemon_id, form ) a ) b WHERE pokemon_id is not null ORDER BY rank asc, pokemon_id asc';
  21. }
  22. if($_GET['mode']=='raid'){
  23. $mode=' (In Raids)';
  24. $type='raid';
  25. $end='end';
  26. $query = 'SELECT pokemon_id, form, count, rank FROM ( SELECT pokemon_id, form, count, row_number() OVER ( ORDER BY COUNT DESC, pokemon_id ASC) AS rank FROM ( SELECT pokemon_id, form, COUNT(pokemon_id) AS COUNT FROM raid GROUP BY pokemon_id, form ) a ) b WHERE pokemon_id is not null ORDER BY rank asc, pokemon_id asc';
  27. }
  28. if($_GET['mode']=='0'){
  29. $mode=' (0%)';
  30. $type='pokemon';
  31. $end='individual_attack=0 AND individual_defense=0 AND individual_stamina=0 AND disappear_time';
  32. $query = 'select row_number() OVER ( ORDER BY COUNT DESC, pokemon_id ASC) AS rank, pokemon_id, form, count(*) as count from pokemon where individual_attack=0 and individual_defense=0 and individual_stamina=0 group by pokemon_id, form order by count desc, pokemon_id asc';
  33. }
  34. if($_GET['mode']=='100'){
  35. $mode=' (100%)';
  36. $type='pokemon';
  37. $end='individual_attack=15 AND individual_defense=15 AND individual_stamina=15 AND disappear_time';
  38. $query = 'select row_number() OVER ( ORDER BY COUNT DESC, pokemon_id ASC) AS rank, pokemon_id, form, count(*) as count from pokemon where individual_attack=15 and individual_defense=15 and individual_stamina=15 group by pokemon_id, form order by count desc, pokemon_id asc';
  39. }
  40. }
  41. } else {
  42. $mode=' (Wild Pokemon)';
  43. $type='pokemon';
  44. $end='disappear_time';
  45. $query = 'SELECT pokemon_id, form, count, rank FROM ( SELECT pokemon_id, form, count, row_number() OVER ( ORDER BY COUNT DESC, pokemon_id ASC) AS rank FROM ( SELECT pokemon_id, form, COUNT(pokemon_id) AS COUNT FROM pokemon GROUP BY pokemon_id, form ) a ) b WHERE pokemon_id is not null ORDER BY rank asc, pokemon_id asc';
  46. }
  47.  
  48. $result = $conn->query($query);?>
  49. <h3>Pokemon Seen Ranks<?=$mode?></h3>
  50. <p>
  51. [<a href="index.php?page=rank&mode=pokemon">Wild</a>][<a href="index.php?page=rank&mode=raid">Raids</a>][<a href="index.php?page=rank&mode=0">0%</a>][<a href="index.php?page=rank&mode=100">100%</a>]
  52. </p>
  53. <div class="table-responsive-sm">
  54. <table id="rankTable" class="table table-striped table-bordered w-auto">
  55. <thead>
  56. <tr>
  57. <th>#</th>
  58. <th>Pokemon</th>
  59. <th>Form</th>
  60. <th>Seen x</th>
  61. <th>Seen now</th>
  62. </tr>
  63. </thead>
  64. <tbody>
  65.  
  66. <?php if($result && $result->num_rows >= 1 ) {
  67. $seenquery = 'SELECT pokemon_id, form FROM ' . $type . ' WHERE ' . $end . ' > utc_timestamp();';
  68. $seenresult = $conn->query($seenquery);
  69. $seenmon = [];
  70. if($seenresult && $seenresult->num_rows >= 1 ) {
  71. while ($seenrow = $seenresult->fetch_object() ) {
  72. $seenmon[] = $seenrow->pokemon_id . '_' . $seenrow->form;
  73. }
  74. }
  75. while ($row = $result->fetch_object() ) {
  76. if (!in_array($row->pokemon_id . '_' . $row->form, $seenmon)) {$seen='No';} else {$seen='Yes';}
  77.  
  78. if($row->form > 0){
  79. if(!empty($forms[$row->pokemon_id][$row->form])){$formname = str_replace("_"," ",$forms[$row->pokemon_id][$row->form]);} else {$formname="Unknown form";}
  80. } else {
  81. $formname = '-';
  82. }
  83.  
  84. ?>
  85. <tr>
  86. <td><?=$row->rank?></td>
  87. <td><img src="<?=$assetRepo . 'pokemon_icon_' . str_pad($row->pokemon_id, 3, 0, STR_PAD_LEFT) . '_' . str_pad($row->form, 2, 0, STR_PAD_LEFT) . '.png'?>" height="32" width="32"> <a href="index.php?page=seen&pokemon=<?=$row->pokemon_id?>&form=<?=$row->form?>"><?=$mon_name[$row->pokemon_id]['name']?></a></td>
  88. <td><?=$formname?></td>
  89. <td><?=$row->count?></td>
  90. <td><?=$seen?></td>
  91. </tr>
  92. <?php
  93. }
  94. }
  95. ?>
  96. </tbody>
  97. </table>
  98. </div>
  99. <?php }
  100. if(isset($_GET['show100']) && isset($_GET['pokemon']) && isset($_GET['form'])){
  101. $query = "select pokemon_id, cp, individual_attack, individual_defense, individual_stamina, form, UNIX_TIMESTAMP(CONVERT_TZ(disappear_time, '+00:00', @@global.time_zone)) as disappear_time, UNIX_TIMESTAMP(CONVERT_TZ(last_modified, '+00:00', @@global.time_zone)) as last_modified from pokemon where individual_attack=15 and individual_defense=15 and individual_stamina=15 and pokemon_id=" . $_GET['pokemon'] . " and form=" . $_GET['form'] . " order by disappear_time desc";
  102. $result = $conn->query($query);
  103. $i=0;
  104. ?>
  105. <h3>Last seen 100% <?=$mon_name[$_GET['pokemon']]['name']?></h3>
  106. <div class="table-responsive-sm">
  107. <table id="rankTable" class="table table-striped table-bordered w-auto">
  108. <thead>
  109. <tr>
  110. <th>#</th>
  111. <th>Pokemon</th>
  112. <th>CP</th>
  113. <th>Last Seen</th>
  114. <th>Disappeared</th>
  115. </tr>
  116. </thead>
  117. <tbody>
  118. <?php while ($row = $result->fetch_object() ) {
  119. $i++;
  120. if($row->form > 0){
  121. if(!empty($forms[$row->pokemon_id][$row->form])){$formname = str_replace("_"," ",$forms[$row->pokemon_id][$row->form]);} else {$formname="Unknown form";}
  122. } else {
  123. $formname = '-';
  124. }?>
  125. <tr>
  126. <td><?=$i?></td>
  127. <td><?=$mon_name[$row->pokemon_id]['name']?></td>
  128. <td><?=$row->cp?></td>
  129. <td><span hidden><?=$row->last_modified?></span><?= date('l jS \of F Y ' . $clock, $row->last_modified) ?></td>
  130. <td><span hidden><?=$row->disappear_time?></span><?= date('l jS \of F Y ' . $clock, $row->disappear_time) ?></td>
  131. </tr>
  132. <?php }?>
  133.  
  134. </tbody>
  135. </table>
  136. </div>
  137.  
  138. <?php }?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement