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.

account.php 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?PHP
  2. require_once('inc/database.php');
  3. session_name('qdb');
  4. session_start();
  5. if (!isset($_SESSION['uid']) && isset($_COOKIE['quotedbperm'])) {
  6. $sql = 'SELECT user_id, user_standing, user_name FROM users WHERE user_hash = \''.m($_COOKIE['quotedbperm']).'\'';
  7. $res = mysql_query($sql);
  8. if (mysql_num_rows($res) == 1) {
  9. $row = mysql_fetch_array($res);
  10. $_SESSION['uid'] = $row['user_id'];
  11. $_SESSION['uname'] = $row['user_name'];
  12. $_SESSION['standing'] = $row['user_standing'];
  13. }
  14. }
  15. if (isset($_SESSION['standing'])) {
  16. $sql = 'SELECT user_standing FROM users WHERE user_id = '.$_SESSION['uid'];
  17. $res = mysql_query($sql);
  18. $row = mysql_fetch_array($res);
  19. $_SESSION['standing'] = $row[0];
  20. }
  21. function doRate($id, $div = true) {
  22. $sql = 'SELECT rating_change FROM ratings WHERE user_id = '.$_SESSION['uid'].' AND quote_id = '.$id;
  23. $res = mysql_query($sql);
  24. if (mysql_num_rows($res) == 0) {
  25. if ($div) {
  26. echo '<div class="rate" id="rate'.$id.'">';
  27. }
  28. echo '<form action="'.BASE.'rate" method="post">';
  29. echo ' <input type="hidden" name="ref" value="'.$_SERVER['REQUEST_URI'].'">';
  30. echo ' <input type="hidden" name="quote" value="'.$id.'">';
  31. echo ' <input type="image" name="rateup" src="'.BASE.'res/plus.png" value="up" alt="Good" title="This is a good quote" onClick="return doRate(\'rateup\', '.$id.');">';
  32. echo ' <input type="image" name="rateneutral" src="'.BASE.'res/neutral.png" value="neutral" alt="Neutral" title="This is an average quote" onClick="return doRate(\'rateneutral\', '.$id.');">';
  33. echo ' <input type="image" name="ratedown" src="'.BASE.'res/minus.png" value="down" alt="Bad" title="This is a bad quote" onClick="return doRate(\'ratedown\', '.$id.');">';
  34. echo '</form>';
  35. if ($div) {
  36. echo '</div>';
  37. }
  38. } else {
  39. $row = mysql_fetch_array($res);
  40. if ($div) {
  41. echo '<div class="rate">';
  42. }
  43. if ($row['rating_change'] > 0) {
  44. echo 'You rated this quote as good.';
  45. } elseif ($row['rating_change'] == 0) {
  46. echo 'You rated this quote as average.';
  47. } else {
  48. echo 'You rated this quote as bad.';
  49. }
  50. if ($div) {
  51. echo '</div>';
  52. }
  53. }
  54. }
  55. ?>