my_channal_post.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /*
  3. 修改channel
  4. */
  5. require_once "../config.php";
  6. require_once "../public/_pdo.php";
  7. require_once '../public/function.php';
  8. require_once '../channal/function.php';
  9. require_once '../redis/function.php';
  10. require_once '../hostsetting/function.php';
  11. $respond=array("status"=>0,"message"=>"");
  12. #先查询对此channal是否有权限修改
  13. PDO_Connect(_FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
  14. $cooperation = 0;
  15. if(isset($_POST["id"])){
  16. $redis = redis_connect();
  17. $channel = new Channal($redis);
  18. $channelPower = $channel->getPower($_POST["id"]);
  19. }
  20. else{
  21. $respond["status"] = 1;
  22. $respond["message"] = 'error channal id';
  23. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  24. exit;
  25. }
  26. if($channelPower<30){
  27. $respond["status"] = 1;
  28. $respond["message"] = 'error 无修改权限';
  29. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  30. exit;
  31. }
  32. if(!isset($_POST["type"])){
  33. $respond["status"] = 1;
  34. $respond["message"] = 'Error: no [type] ';
  35. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  36. exit;
  37. }
  38. $channelOldInfo = $channel->getChannal($_POST["id"]);
  39. $query="UPDATE "._TABLE_CHANNEL_." SET editor_id=?, name = ? , summary = ?, type = ?, status = ? , lang = ? , updated_at = now() , modify_time= ? where uid = ? ";
  40. $sth = $PDO->prepare($query);
  41. $sth->execute(array($_COOKIE["user_id"],$_POST["name"] , $_POST["summary"], $_POST["type"], $_POST["status"] , $_POST["lang"] , mTime() , $_POST["id"]));
  42. $respond=array("status"=>0,"message"=>"");
  43. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  44. $error = PDO_ErrorInfo();
  45. $respond['status']=1;
  46. $respond['message']=$error[2];
  47. }
  48. else{
  49. if($redis){
  50. if($channelOldInfo["status"]!=$_POST["status"]){
  51. $redis->del("power://channel/".$_POST["id"]);
  52. }
  53. }
  54. // 设置 句子库和逐词译库可见性
  55. PDO_Connect(_FILE_DB_SENTENCE_);
  56. $query="UPDATE "._TABLE_SENTENCE_." SET language = ? , status = ? where channel_uid = ? ";
  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. PDO_Connect(_FILE_DB_USER_WBW_);
  65. $query="UPDATE "._TABLE_USER_WBW_BLOCK_." SET lang = ? , status = ? where channel_uid = ? ";
  66. $sth = PDO_Execute($query,array($_POST["lang"],$_POST["status"],$_POST["id"]));
  67. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  68. $error = PDO_ErrorInfo();
  69. $respond['status']=1;
  70. $respond['message']=$error[2];
  71. }
  72. }
  73. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  74. ?>