term_post.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. require_once "../path.php";
  3. require_once "../public/_pdo.php";
  4. require_once '../public/function.php';
  5. $respond=array("status"=>0,"message"=>"");
  6. PDO_Connect("sqlite:"._FILE_DB_TERM_);
  7. if($_POST["id"]!=""){
  8. #更新
  9. $query="UPDATE term SET meaning= ? ,other_meaning = ? , tag= ? ,channal = ? , language = ? , note = ? , receive_time= ?, modify_time= ? where guid= ? ";
  10. $stmt = @PDO_Execute($query,array($_POST["mean"],
  11. $_POST["mean2"],
  12. $_POST["tag"],
  13. $_POST["channal"],
  14. $_POST["language"],
  15. $_POST["note"],
  16. mTime(),
  17. mTime(),
  18. $_POST["id"]
  19. ));
  20. if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
  21. $error = PDO_ErrorInfo();
  22. $respond['status']=1;
  23. $respond['message']=$error[2].$query;
  24. }
  25. else{
  26. $respond['status']=0;
  27. $respond['message']=$_POST["word"];
  28. }
  29. }
  30. else{
  31. #新建
  32. $parm[]=UUID::v4();
  33. $parm[]=$_POST["word"];
  34. $parm[]=pali2english($_POST["word"]);
  35. $parm[]=$_POST["mean"];
  36. $parm[]=$_POST["mean2"];
  37. $parm[]=$_POST["tag"];
  38. $parm[]=$_POST["channal"];
  39. $parm[]=$_POST["language"];
  40. $parm[]=$_POST["note"];
  41. $parm[]=$_COOKIE["userid"];
  42. $parm[]=0;
  43. $parm[]=mTime();
  44. $parm[]=mTime();
  45. $parm[]=mTime();
  46. $query="INSERT INTO term (id, guid, word, word_en, meaning, other_meaning, tag, channal, language,note,owner,hit,create_time,modify_time,receive_time )
  47. VALUES (NULL, ? , ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
  48. $stmt = @PDO_Execute($query,$parm);
  49. if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
  50. $error = PDO_ErrorInfo();
  51. $respond['status']=1;
  52. $respond['message']=$error[2].$query;
  53. }
  54. else{
  55. $respond['status']=0;
  56. $respond['message']=$_POST["word"];
  57. }
  58. }
  59. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  60. ?>