2
0

my_article_put.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /*
  3. 新建文章
  4. */
  5. require_once "../path.php";
  6. require_once "../public/_pdo.php";
  7. require_once '../public/function.php';
  8. require_once '../hostsetting/function.php';
  9. require_once "../ucenter/active.php";
  10. $respond=array("status"=>0,"message"=>"");
  11. if(!isset($_COOKIE["userid"])){
  12. #不登录不能新建
  13. $respond['status']=1;
  14. $respond['message']="no power create article";
  15. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  16. exit;
  17. }
  18. if(!isset($_POST["title"])){
  19. #无标题不能新建
  20. $respond['status']=1;
  21. $respond['message']="no title";
  22. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  23. exit;
  24. }
  25. PDO_Connect(_FILE_DB_USER_ARTICLE_);
  26. $query="INSERT INTO article ( id, title , subtitle , summary , content , tag , owner, setting , status , create_time , modify_time , receive_time ) VALUES ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ";
  27. $sth = $PDO->prepare($query);
  28. $uuid = UUID::v4();
  29. //写入日志
  30. add_edit_event(_ARTICLE_NEW_,$uuid);
  31. #新建文章默认私有
  32. $sth->execute(array($uuid , $_POST["title"] , "" ,"", "" , "" , $_COOKIE["userid"] , "{}" , 10 , mTime() , mTime() , mTime() ));
  33. $respond=array("status"=>0,"message"=>"");
  34. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  35. $error = PDO_ErrorInfo();
  36. $respond['status']=1;
  37. $respond['message']=$error[2];
  38. }
  39. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  40. ?>