Quote database webapp
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.

index.php 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?PHP
  2. require_once('inc/database.php');
  3. require_once('inc/header.php');
  4. ?>
  5. <div class="oneThird right stats">
  6. <h2>Statistics</h2>
  7. <?PHP
  8. $sql = 'SELECT COUNT(*), AVG(quote_rating) FROM quotes';
  9. $res = mysql_query($sql) or print(mysql_error());
  10. $row = mysql_fetch_array($res); $quotes = $row[0];
  11. echo '<p>We have <em>'.$row[0].'</em> quotes, with an average rating of <em>';
  12. echo round($row[1],2).'</em>. These quotes were contributed by some of our ';
  13. $sql = 'SELECT COUNT(*) FROM users';
  14. $res = mysql_query($sql) or print(mysql_error());
  15. $row = mysql_fetch_array($res); $users = $row[0];
  16. echo '<em>'.$row[0].'</em> users, who have made a total of <em>';
  17. $sql = 'SELECT COUNT(*) FROM ratings';
  18. $res = mysql_query($sql) or print(mysql_error());
  19. $row = mysql_fetch_array($res);
  20. echo $row[0].'</em> individual ratings, an average of <em>';
  21. echo round($row[0]/$users,1).'</em> quotes rated per user.</p>';
  22. if (isset($_SESSION['uid'])) {
  23. echo '<h2>Your stats</h2>';
  24. echo '<p>';
  25. $sql = 'SELECT COUNT(*), AVG(quote_rating) FROM quotes WHERE user_id = '.$_SESSION['uid'];
  26. $res = mysql_query($sql) or print(mysql_error());
  27. $row = mysql_fetch_array($res);
  28. echo 'You have submitted <em>'.$row[0].'</em> quote';
  29. echo ($row[0] != 1 ? 's' : '').' that have an average rating of <em>';
  30. echo round($row[1],2).'</em>.';
  31. $sql = 'SELECT COUNT(*) FROM ratings WHERE user_id = '.$_SESSION['uid'];
  32. $res = mysql_query($sql) or print(mysql_error());
  33. $row = mysql_fetch_array($res);
  34. echo ' You have rated <em>'.$row[0].'</em> quote';
  35. if ($row[0] != 1) { echo 's'; }
  36. echo '.';
  37. if ($row[0] < $quotes) {
  38. echo ' Why not rate <a href="'.BASE.'unrated">some more</a>?.';
  39. } else {
  40. echo ' Wow, that\'s all of them. Why not <a href="'.BASE.'submit">add a new quote</a>?';
  41. }
  42. }
  43. ?>
  44. </div>
  45. <div>
  46. <h2>Welcome</h2>
  47. <p>Welcome to the quote db. You might think that this is just another bash
  48. clone, and you'd be partly right. But the quote db has some key differences.
  49. First off, we don't have any moderators. Every person starts with the same
  50. access to the site. When you submit a quote, it appears instantly on the
  51. <a href="<?PHP echo BASE; ?>latest">latest quotes</a> page, where other users
  52. can rate it as good, bad or neutral.
  53. </p>
  54. <p>
  55. If the quotes you submit get a poor rating, this will reflect on you and your
  56. <em>standing</em> will decrease. Your standing is displayed on the right of
  57. the menu bar when you're logged in, and operates on a scale of -10 to +10.
  58. If your standing drops too low, your ability to add quotes will be suspended.
  59. Conversely, if your quotes are met with a standing ovation (and good ratings),
  60. your standing will increase. This, in turn, affects how much your opinion is
  61. taken into account when you rate quotes. The higher standing you have, the
  62. more of an impact your ratings will have.
  63. </p>
  64. <p>
  65. The Quote DB now supports OpenID. Simply enter your
  66. OpenID identifier on the <a href="<?PHP echo BASE; ?>login">login</a>
  67. page.
  68. </p>
  69. <p>
  70. <strong>New!</strong> The Quote DB now fully supports Unicode (UTF-8) quotes
  71. </p>
  72. </div>
  73. <?PHP
  74. require_once('inc/footer.php');
  75. ?>