term_post.php 2.3 KB

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