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.

rate.php 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. <?PHP
  2. require_once('inc/account.php');
  3. require_once('inc/settings.php');
  4. require_once('inc/database.php');
  5. if (!isset($_SESSION['uid'])) {
  6. header('Location: '.BASE.'login');
  7. exit;
  8. }
  9. if (isset($_POST['quote']) && ctype_digit($_POST['quote'])) {
  10. if (isset($_POST['rateup'])) { $base = 1; } elseif (isset($_POST['ratedown'])) { $base = -1; } else { $base = 0; }
  11. $base *= (($_SESSION['standing'] + 10) / 10);
  12. $sql = 'SELECT rating_change FROM ratings WHERE user_id = '.$_SESSION['uid'].' AND quote_id = '.m($_POST['quote']);
  13. $res = mysql_query($sql);
  14. if (mysql_num_rows($res) == 0) {
  15. if ($_POST['quote'] != 62) {
  16. mysql_query('INSERT INTO ratings (user_id, quote_id, rating_change) VALUES ('.$_SESSION['uid'].', '.m($_POST['quote']).', '.$base.')');
  17. mysql_query('UPDATE quotes SET quote_rating = quote_rating + '.$base.', quote_rated = quote_rated + 1 WHERE quote_id = '.m($_POST['quote']));
  18. require('dostanding.php');
  19. }
  20. header('Location: '.$_POST['ref']);
  21. exit;
  22. } else {
  23. header('Location: '.$_POST['ref']);
  24. exit;
  25. }
  26. } else {
  27. die('Invalid quote');
  28. }
  29. ?>