my_collect_put.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. require_once "../config.php";
  3. require_once "../public/_pdo.php";
  4. require_once '../public/function.php';
  5. require_once '../hostsetting/function.php';
  6. require_once "../ucenter/active.php";
  7. $respond=array("status"=>0,"message"=>"");
  8. if(!isset($_COOKIE["userid"])){
  9. #不登录不能新建
  10. $respond['status']=1;
  11. $respond['message']="no power create article";
  12. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  13. exit;
  14. }
  15. if(!isset($_POST["title"])){
  16. #无标题不能新建
  17. $respond['status']=1;
  18. $respond['message']="no title";
  19. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  20. exit;
  21. }
  22. $uuid = UUID::v4();
  23. add_edit_event(_COLLECTION_NEW_,$uuid);
  24. PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
  25. $query="INSERT INTO "._TABLE_COLLECTION_." (
  26. uid ,
  27. title ,
  28. subtitle ,
  29. summary ,
  30. article_list ,
  31. owner,
  32. owner_id,
  33. editor_id,
  34. lang ,
  35. status ,
  36. create_time ,
  37. modify_time
  38. ) VALUES ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ";
  39. $sth = $PDO->prepare($query);
  40. $sth->execute(array($uuid , $_POST["title"] , "" ,"", "[]" , $_COOKIE["user_uid"] , $_COOKIE["user_id"], $_COOKIE["user_id"], "" , $_POST["status"] , mTime() , mTime() ));
  41. $respond=array("status"=>0,"message"=>"");
  42. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  43. $error = PDO_ErrorInfo();
  44. $respond['status']=1;
  45. $respond['message']=$error[2];
  46. }
  47. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  48. ?>