KXStudio Website https://kx.studio/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.9KB

  1. <?php
  2. $PAGE_TITLE = "KXStudio : Donations";
  3. $PAGE_TYPE = "DONATIONS";
  4. $PAGE_SOURCE_1 = ARRAY("/Donations");
  5. $PAGE_SOURCE_2 = ARRAY("Donations");
  6. include_once("includes/header.php");
  7. require "donate/config.php";
  8. require "donate/connect.php";
  9. $GLOBALS['biggest_donation_date'] = "Unknown";
  10. $GLOBALS['biggest_donation_value'] = 0.0;
  11. $GLOBALS['total_ever'] = 0.0;
  12. function print_donation_year($year) {
  13. global $db_link;
  14. if ($db_link === FALSE) {
  15. echo '<tr><td colspan="6">DB connection failed</td></tr>';
  16. return;
  17. }
  18. $amount = 0.0;
  19. $max_month = 0.0;
  20. $total_year = 0.0;
  21. $donation_count = 0.0;
  22. $sql_donations = mysqli_query($db_link, "SELECT * FROM donations WHERE YEAR(dt) = " . $year);
  23. if (mysqli_num_rows($sql_donations)) {
  24. while ($sql_row = mysqli_fetch_assoc($sql_donations)) {
  25. $amount = $sql_row["amount"];
  26. $donation_count += 1.0;
  27. if ($amount > $max_month) {
  28. $max_month = $amount;
  29. if ($amount > $GLOBALS['biggest_donation_value']) {
  30. $GLOBALS['biggest_donation_date'] = date("Y-m-d", strtotime($sql_row["dt"]));
  31. $GLOBALS['biggest_donation_value'] = $amount;
  32. }
  33. }
  34. $total_year += $amount;
  35. }
  36. }
  37. $GLOBALS['total_ever'] += $total_year;
  38. echo '<tr>';
  39. echo ' <td>' . $year . '</td>';
  40. echo ' <td>' . $donation_count . '</td>';
  41. echo ' <td>' . number_format($total_year, 2) . '&euro;</td>';
  42. if ($donation_count > 0.0) {
  43. echo ' <td>' . number_format($total_year/$donation_count, 2) . '&euro;</td>';
  44. } else {
  45. echo ' <td>0&euro;</td>';
  46. }
  47. echo ' <td>' . number_format($total_year/12.0, 2) . '&euro;</td>';
  48. echo ' <td>' . number_format($max_month, 2) . '&euro;</td>';
  49. echo '</tr>';
  50. }
  51. ?>
  52. <p>
  53. KXStudio is and always will be a free and open-source project to everyone.<br/>
  54. Donations help ensure that developers have the needed enthusiasm and motivation to keep working on the project.<br/>
  55. Just because we're open-source doesn't mean we're allergic to money. ;)
  56. </p>
  57. <p>
  58. This page contain statistics regarding donations made to the KXStudio project over time.
  59. </p>
  60. <div class="box box-description">
  61. <table style="text-align:center;">
  62. <tr>
  63. <td>&nbsp;Year&nbsp;</td>
  64. <td>&nbsp;Donation count&nbsp;</td>
  65. <td>&nbsp;Total received&nbsp;</td>
  66. <td>&nbsp;Average per donation&nbsp;</td>
  67. <td>&nbsp;Average per month&nbsp;</td>
  68. <td>&nbsp;Biggest single donation&nbsp;</td>
  69. </tr>
  70. <?php
  71. for ($year = strftime("%Y"); $year >= "2013"; $year -= 1) {
  72. print_donation_year($year);
  73. }
  74. ?>
  75. </table>
  76. </div>
  77. <p>
  78. So far the KXStudio project has received <?php echo number_format($GLOBALS['total_ever'], 2); ?>&euro; in donations.<br/>
  79. The biggest donation ever made was on <?php echo $GLOBALS['biggest_donation_date']; ?>, with a value of <?php echo number_format($GLOBALS['biggest_donation_value'], 2); ?>&euro;.<br/>
  80. Thank you very much for your generosity!
  81. </p>
  82. <p><br/></p>
  83. <?php
  84. include_once("includes/footer.php");
  85. ?>