scores.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. $page = 3;
  3. require("inc_header.php");
  4. // ======================================================
  5. // LATEST GAMES
  6. // ======================================================
  7. $table = "";
  8. $query = "SELECT `title`, `difficulty`, songinstance.id as siid, song.id as sid, `username`, `score`, `date`
  9. FROM `highscore`, `songinstance`, `song`
  10. WHERE highscore.songinstance = songinstance.id AND songinstance.song = song.id
  11. ORDER BY `date` DESC";
  12. $result_temp = mysqli_query($connection, $query);
  13. while($result = mysqli_fetch_assoc($result_temp))
  14. {
  15. $table .= "<tr>";
  16. $table .= "<td><a href='" . returnurl('song.php?id=' . $result['sid']) . "'>" . $result['title'] . "</a></td>";
  17. $table .= "<td><a href='" . returnurl('songinstance.php?id=' . $result['siid']) . "'>" . $result['difficulty'] . "</a></td>";
  18. $table .= "<td>" . $result['username'] . "</td>";
  19. $table .= "<td>" . $result['score'] . "</td>";
  20. $table .= "<td>" . $result['date'] . "</td>";
  21. $table .= "</tr>";
  22. }
  23. // ======================================================
  24. // DATA POINTS FOR SCORES GRAPH
  25. // ======================================================
  26. $scores_array = array();
  27. $scores_names_array = array();
  28. $query = "SELECT `date`, `score`, `username`
  29. FROM highscore
  30. ORDER BY `date` DESC
  31. LIMIT 0,28";
  32. $result_temp = mysqli_query($connection, $query);
  33. while($result = mysqli_fetch_assoc($result_temp))
  34. {
  35. $scores_array[] = "{y: '" . $result['date'] . "', sc: " . $result['score'] . "}";
  36. $scores_names_array[] = "'" . $result['username'] . "'";
  37. }
  38. $scores_array = array_reverse($scores_array);
  39. $scores_names_array = array_reverse($scores_names_array);
  40. // ======================================================
  41. // SELECT HIGHEST SCORE OF TODAY
  42. // ======================================================
  43. $query = "SELECT `username`, `score`
  44. FROM highscore
  45. ORDER BY `score` DESC
  46. LIMIT 1";
  47. $result_temp = mysqli_query($connection, $query);
  48. $result = mysqli_fetch_assoc($result_temp);
  49. $highest_score = $result['score'];
  50. $best_player = $result['username'];
  51. if($highest_score==null)
  52. {
  53. $highest_score=0;
  54. $best_player="BORF";
  55. }
  56. ?>
  57. <!-- Content Wrapper. Contains page content -->
  58. <div class="content-wrapper">
  59. <!-- Content Header (Page header) -->
  60. <section class="content-header">
  61. <h1>
  62. Scores
  63. <small>All score activity in one quick overview</small>
  64. </h1>
  65. <ol class="breadcrumb">
  66. <li class="active"><a href="#"><i class="ion ion-ribbon-b"></i> Scores</a></li>
  67. </ol>
  68. </section>
  69. <section class="content">
  70. <div class="row">
  71. <div class="col-lg-9">
  72. <!-- games played graph -->
  73. <div class="box box-solid bg-purple">
  74. <div class="box-header">
  75. <i class="ion ion-ribbon-b"></i>
  76. <h3 class="box-title">Scores</h3>
  77. </div>
  78. <div class="box-body border-radius-none">
  79. <div class="chart" id="scores-chart" style="height: 165px;"></div>
  80. </div><!-- /.box-body -->
  81. </div><!-- /.box -->
  82. </div>
  83. <div class="col-lg-3 col-md-6 col-xs-12">
  84. <!-- small box -->
  85. <div class="small-box bg-aqua">
  86. <div class="inner">
  87. <h3><?php echo $best_player; ?></h3>
  88. <p>Best Player</p>
  89. </div>
  90. <div class="icon">
  91. <i class="ion ion-ios-game-controller-a"></i>
  92. </div>
  93. </div>
  94. </div><!-- ./col -->
  95. <div class="col-lg-3 col-sm-6 col-xs-12">
  96. <!-- small box -->
  97. <div class="small-box bg-yellow">
  98. <div class="inner">
  99. <h3><?php echo $highest_score; ?><sup style="font-size: 20px"> points</sup></h3>
  100. <p>Highscore</p>
  101. </div>
  102. <div class="icon">
  103. <i class="ion ion-ribbon-b"></i>
  104. </div>
  105. </div>
  106. </div><!-- ./col -->
  107. </div>
  108. <div class="row">
  109. <div class="col-lg-12">
  110. <!-- TABLE: LATEST SONGS -->
  111. <div class="box">
  112. <div class="box-header with-border">
  113. <i class="ion ion-ribbon-b"></i>
  114. <h3 class="box-title">Scores</h3>
  115. </div><!-- /.box-header -->
  116. <div class="box-body">
  117. <table id="scores-table" class="table table-bordered">
  118. <thead>
  119. <tr>
  120. <th>Song Name</th>
  121. <th>Difficulty</th>
  122. <th>Name</th>
  123. <th>Score</th>
  124. <th>Time</th>
  125. </tr>
  126. </thead>
  127. <tbody>
  128. <?php
  129. echo $table;
  130. ?>
  131. </tbody>
  132. </table>
  133. </div><!-- /.box-body -->
  134. </div><!-- /.box -->
  135. </div><!-- /.col -->
  136. </div><!-- /.row -->
  137. </section><!-- /.content -->
  138. </div><!-- /.content-wrapper -->
  139. <!-- Morris.js charts -->
  140. <script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
  141. <script src="plugins/morris/morris.min.js" type="text/javascript"></script>
  142. <!-- DATA TABES SCRIPT -->
  143. <script src="plugins/datatables/jquery.dataTables.min.js" type="text/javascript"></script>
  144. <script src="plugins/datatables/dataTables.bootstrap.min.js" type="text/javascript"></script>
  145. <!-- Page specific javascript -->
  146. <script type="text/javascript">
  147. var scores_data = [ <?php
  148. foreach ($scores_array as $value)
  149. {
  150. echo $value . ",\n";
  151. }
  152. ?> ];
  153. var scores_names_data = [ <?php
  154. foreach ($scores_names_array as $value)
  155. {
  156. echo $value . ",\n";
  157. }
  158. ?> ];
  159. </script>
  160. <script src="dist/js/pages/scores.js" type="text/javascript"></script>
  161. <?php
  162. require("inc_footer.php");
  163. ?>