Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

publish_post.php 1007B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. require_once('../includes/config.php');
  3. //check to see that the form has been submitted
  4. $id = 0;
  5. if(isset($_POST) && $logged_in)
  6. {
  7. $id = rawurldecode($_POST['id']);
  8. $post = $db->select('blog', "id=? LIMIT 1", array($id));
  9. if ($post)
  10. {
  11. $success = true;
  12. $publish = $post['publish'];
  13. if ($success && !$user->admin && $post_select['author_id'] != $user->id)
  14. {
  15. $error = "You are not allowed to publish this post.";
  16. if (!$publish)
  17. {
  18. $error = "You are not allowed to unpublish this post.";
  19. }
  20. $success = false;
  21. }
  22. if ($success)
  23. {
  24. $data = array(
  25. "publish" => $publish,
  26. "date_published" => date("Y-m-d H:i:s",time())
  27. );
  28. $post_id = $db->update($data, 'blog', 'id=?', array($id));
  29. unset($_POST);
  30. echo "true";
  31. }
  32. else
  33. {
  34. echo $error;
  35. }
  36. }
  37. else
  38. {
  39. echo "That blog post does not exist.";
  40. }
  41. }
  42. else
  43. {
  44. echo "You need to be logged in to delete this post.";
  45. }
  46. ?>