term_post.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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("" . _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. } else {
  36. $respond['status'] = 0;
  37. $respond['message'] = $_POST["word"];
  38. }
  39. } else {
  40. #新建
  41. $parm[] = UUID::v4();
  42. $parm[] = $_POST["word"];
  43. $parm[] = pali2english($_POST["word"]);
  44. $parm[] = $_POST["mean"];
  45. $parm[] = $_POST["mean2"];
  46. $parm[] = $_POST["tag"];
  47. $parm[] = $_POST["channal"];
  48. $parm[] = $_POST["language"];
  49. $parm[] = $_POST["note"];
  50. $parm[] = $_COOKIE["userid"];
  51. $parm[] = 0;
  52. $parm[] = mTime();
  53. $parm[] = mTime();
  54. $parm[] = mTime();
  55. $query = "INSERT INTO term (id, guid, word, word_en, meaning, other_meaning, tag, channal, language,note,owner,hit,create_time,modify_time,receive_time )
  56. VALUES (NULL, ? , ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
  57. $stmt = @PDO_Execute($query, $parm);
  58. if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
  59. $error = PDO_ErrorInfo();
  60. $respond['status'] = 1;
  61. $respond['message'] = $error[2] . $query;
  62. } else {
  63. $respond['status'] = 0;
  64. $respond['message'] = $_POST["word"];
  65. }
  66. }
  67. echo json_encode($respond, JSON_UNESCAPED_UNICODE);