vote.php 709 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. require_once 'session.php';
  3. require_once 'database.php';
  4. // Do not re-login
  5. if (!Session::is_valid())
  6. exit ();
  7. $db = new Database ();
  8. $db->connect ();
  9. // Vote a post
  10. if (isset ($_GET['post']))
  11. {
  12. if (isset ($_GET['up']))
  13. $db->upvote_post ($_GET['post'], Session::get_userid ());
  14. if (isset ($_GET['down']))
  15. $db->downvote_post ($_GET['post'], Session::get_userid ());
  16. exit ();
  17. }
  18. // Vote a comment
  19. if (isset ($_GET['comment']))
  20. {
  21. if (isset ($_GET['up']))
  22. $db->upvote_comment ($_GET['comment'], Session::get_userid ());
  23. if (isset ($_GET['down']))
  24. $db->downvote_comment ($_GET['comment'], Session::get_userid ());
  25. exit ();
  26. }