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.

103 lines
2.7KB

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