sent_pr_merge.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. #更新一个句子
  3. require_once "../config.php";
  4. require_once "../public/function.php";
  5. require_once "../usent/function.php";
  6. require_once "../ucenter/active.php";
  7. require_once "../share/function.php";
  8. require_once "../redis/function.php";
  9. require_once "../channal/function.php";
  10. $db_pr = new SentPr();
  11. $db_sent = new Sent_DB();
  12. $channel = new Channal();
  13. $updateDate=array();
  14. $insertData=array();
  15. $insertHistoray=array();
  16. $respond["error"]=0;
  17. $respond["message"]="";
  18. $prData = $db_pr->getPrDataById($_POST["id"]);
  19. if($prData){
  20. $channelPower = $channel->getPower($prData["channel"]);
  21. if($channelPower>=20){
  22. $dest = $db_sent->getSent($prData["book"],$prData["paragraph"],$prData["begin"],$prData["end"],$prData["channel"]);
  23. $newData = $prData;
  24. if($dest){
  25. #更新
  26. $newData["id"]=$dest["uid"];
  27. $newData["modify_time"]=mTime();
  28. $newData["landmark"]="";
  29. $updateDate[] = $newData;
  30. $insertHistoray[] = $newData;
  31. }
  32. else{
  33. #插入
  34. $newData["id"]=UUID::v4();;
  35. $newData["modify_time"]=mTime();
  36. $newData["landmark"]="";
  37. $insertData[] = $newData;
  38. $insertHistoray[] = $newData;
  39. }
  40. if($db_sent->update($updateDate)){
  41. $respond['update'] = count($updateDate);
  42. $respond['data'] = $newData;
  43. }
  44. else{
  45. $respond['message'] = $db_sent->getError();
  46. $respond['status'] = 1;
  47. }
  48. if($db_sent->insert($insertData)){
  49. $respond['insert'] = count($insertData);
  50. }else{
  51. $respond['message'] = $db_sent->getError();
  52. $respond['status'] = 1;
  53. }
  54. if($db_sent->historay($insertHistoray)){
  55. $respond['historay'] = count($insertHistoray);
  56. }else{
  57. $respond['message'] = $db_sent->getError();
  58. $respond['status'] = 1;
  59. }
  60. }
  61. else{
  62. $output["error"]=1;
  63. $output["message"]="没有写入权限";
  64. }
  65. }
  66. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  67. ?>