Guest User

MoneySQL PHP Script

a guest
Dec 27th, 2016
754
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.92 KB | None | 0 0
  1. <?php
  2. ini_set('display_errors', 1);
  3.  
  4. // MoneySQL PHP script v6 (27-12-2016).
  5. // by Wruczek. MIT License.
  6. // http://dev.bukkit.org/bukkit-plugins/moneysql/
  7.  
  8. // CONFIGURATION - EDIT THIS
  9. $database_adress = "localhost";
  10. $database_name = "moneysql";
  11. $database_user = "Wruczek";
  12. $database_password = "password";
  13.  
  14. // Optional configuration
  15. $theme = 'united'; // Themes: Cerulean, Cosmo, Cyborg, Darkly, Flatly, Journal, Lumen, Paper, Readable, Sandstone, Simplex, Slate, Spacelab, Superhero, United, Yeti
  16. $how_many = 10;
  17. $title = "Top $how_many richest players on the server.";
  18. $page_title = $title;
  19. $show_uuid = true;
  20. $padding_top = "100px";
  21. // {balance} will be replaced with player balance.
  22. $money_format = "$ {balance}";
  23. // Head size in pixels.
  24. $head_size = 30;
  25.  
  26. // END OF CONFIGURATION
  27.  
  28. $con = mysqli_connect($database_adress, $database_user, $database_password, $database_name);
  29.  
  30. if (mysqli_connect_errno()) {
  31.    die("<h3 class='text-center'>Failed to connect to MySQL: " . mysqli_connect_error() . "</h3>");
  32. }
  33. ?>
  34.  
  35. <html>
  36. <head>
  37.     <meta charset="utf-8">
  38.     <meta content="Wruczek" name="author">
  39.     <title><?php echo $title; ?></title>
  40.  
  41.     <link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/<?php echo strtolower($theme) ?>/bootstrap.min.css" rel="stylesheet">
  42.  
  43.     <style>
  44.         body {
  45.             padding-top: <?php echo $padding_top ?>;
  46.         }
  47.     </style>
  48. </head>
  49. <body>
  50.  
  51. <div class="container">
  52.  
  53.     <h2 class="text-center"><?php echo $page_title; ?></h2>
  54.  
  55.     <table class="table table-striped table-hover">
  56.         <thead>
  57.         <tr>
  58.             <th>#</th>
  59.             <th>Head</th>
  60.             <th>Nickname</th>
  61.             <?php if ($show_uuid) { ?>
  62.                 <th>UUID</th>
  63.             <?php } ?>
  64.             <th>Balance</th>
  65.         </tr>
  66.         </thead>
  67.         <tbody>
  68.         <?php
  69.        $num = 0;
  70.  
  71.        $result = mysqli_query($con, "SELECT * FROM `moneysql` ORDER BY `money` DESC LIMIT $how_many");
  72.  
  73.        if (!$result) {
  74.            die("ERROR: Server not returned any data. " . mysqli_error($con));
  75.        }
  76.  
  77.        while ($row = mysqli_fetch_array($result)) {
  78.            $num++;
  79.            $uuid = $row['UUID'];
  80.            $nick = $row['last_known_name'];
  81.            $money = $row['money'];
  82.            $img = sprintf('<img src="https://minotar.net/helm/%s/%d.png">', $nick, $head_size);
  83.  
  84.             echo "<tr><td>$num</td><td>$img</td><td>$nick</td>";
  85.  
  86.             if ($show_uuid)
  87.                 echo "<td>$uuid</td>";
  88.  
  89.             echo "<td>" . str_replace("{balance}", $money, $money_format) . "</td></tr>";
  90.         }
  91.  
  92.         mysqli_close($con);
  93.         ?>
  94.         </tbody>
  95.     </table>
  96.  
  97.     <div class="footer">
  98.         &copy; <a href="https://wruczek.tech/">Wruczek</a> for <a href="http://dev.bukkit.org/bukkit-plugins/moneysql/" target="blank">MoneySQL</a> bukkit plugin.
  99.     </div>
  100. </div>
  101.  
  102. </body>
  103. </html>
Add Comment
Please, Sign In to add comment