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.

rateajax.php 1.0KB

1234567891011121314151617181920212223242526272829
  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($_GET['quote']) && ctype_digit($_GET['quote'])) {
  10. if (isset($_GET['rateup'])) { $base = 1; } elseif (isset($_GET['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($_GET['quote']);
  13. $res = mysql_query($sql);
  14. if (mysql_num_rows($res) == 0) {
  15. if ($_GET['quote'] != 62) {
  16. mysql_query('INSERT INTO ratings (user_id, quote_id, rating_change) VALUES ('.$_SESSION['uid'].', '.m($_GET['quote']).', '.$base.')');
  17. mysql_query('UPDATE quotes SET quote_rating = quote_rating + '.$base.', quote_rated = quote_rated + 1 WHERE quote_id = '.m($_GET['quote']));
  18. require('dostanding.php');
  19. }
  20. }
  21. doRate($_GET['quote'], false);
  22. } else {
  23. die('Invalid quote');
  24. }
  25. ?>