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.

DonationsStats.php 2.9KB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 = mysql_query("SELECT * FROM donations WHERE YEAR(dt) = " . $year);
  23. if (mysql_num_rows($sql_donations)) {
  24. while ($sql_row = mysql_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 be a free and open-source project to everyone.<br/>
  54. Donations will help ensure that developers have the needed enthusiasm and motivation to keep working hard 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.<br/>
  59. So far the KXStudio project has received <?php echo number_format($GLOBALS['total_ever'], 2); ?>&euro; in donations.<br/>
  60. 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/>
  61. Thank you very much for your generosity!
  62. </p>
  63. <div class="box box-description">
  64. <table style="text-align:center;">
  65. <tr>
  66. <td>&nbsp;Year&nbsp;</td>
  67. <td>&nbsp;Donation count&nbsp;</td>
  68. <td>&nbsp;Total received&nbsp;</td>
  69. <td>&nbsp;Average per donation&nbsp;</td>
  70. <td>&nbsp;Average per month&nbsp;</td>
  71. <td>&nbsp;Biggest single donation&nbsp;</td>
  72. </tr>
  73. <?php
  74. for ($year = strftime("%Y"); $year >= "2013"; $year -= 1) {
  75. print_donation_year($year);
  76. }
  77. ?>
  78. </table>
  79. </div>
  80. <p><br/></p>
  81. <?php
  82. include_once("includes/footer.php");
  83. ?>