user_activity.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. require_once 'session.php';
  3. require_once 'database.php';
  4. require_once 'date.php';
  5. require_once 'twig.php';
  6. // Must be logged in
  7. if (!Session::is_valid ())
  8. {
  9. header ('Location: ./login');
  10. exit ();
  11. }
  12. $db = new Database ();
  13. $db->connect ();
  14. // Show posts
  15. if (isset ($_GET['posts']))
  16. {
  17. $posts = $db->get_user_posts (Session::get_userid ());
  18. echo $twig->render (
  19. 'user_posts.twig',
  20. array ('posts' => $posts));
  21. }
  22. // Show comments
  23. elseif (isset ($_GET['comments']))
  24. {
  25. $comments = $db->get_user_comments (Session::get_userid ());
  26. echo $twig->render (
  27. 'user_comments.twig',
  28. array ('comments' => $comments));
  29. }
  30. // Show replies
  31. elseif (isset ($_GET['replies']))
  32. {
  33. $replies = $db->get_user_replies (Session::get_userid ());
  34. // We need to set the replies as "read"
  35. $db->set_replies_as_read (Session::get_userid ());
  36. echo $twig->render (
  37. 'user_replies.twig',
  38. array ('replies' => $replies));
  39. }
  40. // Wrong argument
  41. else
  42. {
  43. header ('Location: ./user');
  44. exit ();
  45. }