my_channal_post.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. require_once "../path.php";
  3. require_once "../public/_pdo.php";
  4. require_once '../public/function.php';
  5. require_once '../channal/function.php';
  6. require_once '../redis/function.php';
  7. require_once '../hostsetting/function.php';
  8. $respond=array("status"=>0,"message"=>"");
  9. #先查询对此channal是否有权限修改
  10. PDO_Connect(_FILE_DB_CHANNAL_);
  11. $cooperation = 0;
  12. if(isset($_POST["id"])){
  13. $redis = redis_connect();
  14. $channel = new Channal($redis);
  15. $channelPower = $channel->getPower($_POST["id"]);
  16. }
  17. else{
  18. $respond["status"] = 1;
  19. $respond["message"] = 'error channal id';
  20. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  21. exit;
  22. }
  23. if($channelPower<30){
  24. $respond["status"] = 1;
  25. $respond["message"] = 'error 无修改权限';
  26. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  27. exit;
  28. }
  29. $channelOldInfo = $channel->getChannal($_POST["id"]);
  30. $query="UPDATE channal SET name = ? , summary = ?, status = ? , lang = ? , receive_time= ? , modify_time= ? where id = ? ";
  31. $sth = $PDO->prepare($query);
  32. $sth->execute(array($_POST["name"] , $_POST["summary"], $_POST["status"] , $_POST["lang"] , mTime() , mTime() , $_POST["id"]));
  33. $respond=array("status"=>0,"message"=>"");
  34. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  35. $error = PDO_ErrorInfo();
  36. $respond['status']=1;
  37. $respond['message']=$error[2];
  38. }
  39. else{
  40. if($redis){
  41. if($channelOldInfo["status"]!=$_POST["status"]){
  42. $redis->del("power://channel/".$_POST["id"]);
  43. }
  44. }
  45. // 设置 句子库和逐词译库可见性
  46. PDO_Connect(_FILE_DB_SENTENCE_);
  47. $query="UPDATE sentence SET language = ? , status = ? where channal = ? ";
  48. $sth = PDO_Execute($query,array($_POST["lang"],$_POST["status"],$_POST["id"]));
  49. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  50. $error = PDO_ErrorInfo();
  51. $respond['status']=1;
  52. $respond['message']=$error[2];
  53. }
  54. // 设置 逐词译库可见性
  55. PDO_Connect(_FILE_DB_USER_WBW_);
  56. $query="UPDATE wbw_block SET lang = ? , status = ? where channal = ? ";
  57. $sth = PDO_Execute($query,array($_POST["lang"],$_POST["status"],$_POST["id"]));
  58. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  59. $error = PDO_ErrorInfo();
  60. $respond['status']=1;
  61. $respond['message']=$error[2];
  62. }
  63. }
  64. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  65. ?>