A unf. social network done poorly.
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.

62 lines
1.8KB

  1. <?php /* creates entry for status */
  2. ini_set('display_errors', '1');
  3. require_once($_SERVER['DOCUMENT_ROOT'] . '/socialtune/includes/session.php');
  4. require_once($_SERVER['DOCUMENT_ROOT'] . '/socialtune/includes/config.php');
  5. require_once($_SERVER['DOCUMENT_ROOT'] . '/socialtune/includes/user-data.php');
  6. /* Which are we using today? */
  7. $isRemoval = (!empty($_POST['removal'])) ? $_POST['removal'] : false;
  8. $post_id = (!empty($_POST['post_id'])) ? $_POST['post_id'] : false;
  9. //$post_id = (!empty($_POST['post_id'])) ? $_POST['post_id'] : false;
  10. $poster_id = $user_id;
  11. $message = (!empty($_POST['message'])) ? $_POST['message'] : false;
  12. $connection = mysqli_connect($dbHost, $dbUser, $dbPass, $dbName);
  13. if($isRemoval){
  14. $post_id = (!empty($_POST['post_id'])) ? $_POST['post_id'] : false;
  15. $isRemoval = mysqli_real_escape_string($connection, $isRemoval);
  16. $post_id = mysqli_real_escape_string($connection, $post_id);
  17. if($post_id){
  18. $delete_status_now = "DELETE FROM status
  19. WHERE id='$post_id' AND poster_id='$user_id'";
  20. if(!mysqli_query($connection, $delete_status_now)){
  21. die("Error.");
  22. }
  23. echo "deleted status.";
  24. }else{
  25. echo 'Something went wrong. -- removal.';
  26. }
  27. }else{
  28. /* Status Creation */
  29. $poster_id = mysqli_real_escape_string($connection, $poster_id);
  30. $message = mysqli_real_escape_string($connection, $message);
  31. var_dump($poster_id);
  32. if($poster_id && $message){
  33. $add_status = "INSERT INTO status(poster_id, message)
  34. VALUES
  35. ('$poster_id','$message')";
  36. if(!mysqli_query($connection, $add_status)){
  37. die("err....wat");
  38. }
  39. Header("Location: dashboard.php");
  40. }else{
  41. echo "Error: Either you're not logged in, or forgot to enter text.";
  42. Header("Location: dashboard.php?ps=1");
  43. }
  44. }
  45. Header("Location: dashboard.php");
  46. ?>