my_article_post.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. require_once "../article/function.php";
  8. require_once "../redis/function.php";
  9. require_once "../db/custom_book.php";
  10. add_edit_event(_ARTICLE_EDIT_,$_POST["id"]);
  11. $respond=array("status"=>0,"message"=>"");
  12. # 检查是否有修改权限
  13. $redis = redis_connect();
  14. $article = new Article($redis);
  15. $power = $article->getPower($_POST["id"]);
  16. if($power<20){
  17. $respond["status"]=1;
  18. $respond["message"]="No Power For Edit";
  19. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  20. exit;
  21. }
  22. $_content = $_POST["content"];
  23. /*
  24. if(isset($_POST["import"]) && $_POST["import"]=='on'){
  25. #导入自定义书
  26. $custom_book = new CustomBook($redis);
  27. $_lang = explode("_",$_POST["lang"]);
  28. if(count($_lang)===3){
  29. $lang = $_lang[2];
  30. }
  31. else if(count($_lang)===1){
  32. $lang = $_lang[0];
  33. }
  34. else{
  35. $respond["status"]=1;
  36. $respond["message"]="无法识别的语言".$_POST["lang"];
  37. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  38. exit;
  39. }
  40. $respond = $custom_book->new($_POST["title"],$_content,$lang);
  41. if($respond["status"]==0){
  42. $_content = $respond["content"];
  43. }
  44. else{
  45. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  46. exit;
  47. }
  48. }
  49. */
  50. PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
  51. $query="UPDATE "._TABLE_ARTICLE_." SET title = ? , subtitle = ? , summary = ?, lang = ? , content = ? , setting = ? , status = ? , updated_at=now() , modify_time= ? where uid = ? ";
  52. $sth = $PDO->prepare($query);
  53. $sth->execute(array($_POST["title"] , $_POST["subtitle"] ,$_POST["summary"] ,$_POST["lang"], $_content , "{}" , $_POST["status"] , mTime() , $_POST["id"]));
  54. $respond=array("status"=>0,"message"=>"");
  55. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  56. $error = PDO_ErrorInfo();
  57. $respond['status']=1;
  58. $respond['message']=$error[2];
  59. }
  60. else{
  61. if($redis){
  62. $redis->del("article://".$_POST["id"]);
  63. $redis->del("power://article/".$_POST["id"]);
  64. }
  65. }
  66. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  67. ?>