my_channal_post.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. require_once "../path.php";
  3. require_once "../public/_pdo.php";
  4. require_once '../public/function.php';
  5. require_once '../hostsetting/function.php';
  6. $respond=array("status"=>0,"message"=>"");
  7. #先查询对此channal是否有权限修改
  8. PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
  9. $cooperation = 0;
  10. if(isset($_POST["id"])){
  11. $query = "SELECT owner FROM channal WHERE id=?";
  12. $fetch = PDO_FetchOne($query,array($_POST["id"]));
  13. if($fetch && $fetch==$_COOKIE["userid"]){
  14. #自己的channal
  15. $cooperation = 1;
  16. }
  17. else{
  18. $query = "SELECT count(*) FROM cooperation WHERE channal_id= ? and user_id=? ";
  19. $fetch = PDO_FetchOne($query,array($_POST["id"],$_COOKIE["userid"]));
  20. if($fetch>0){
  21. #有协作权限
  22. $cooperation = 1;
  23. }
  24. else{
  25. #无协作权限
  26. $cooperation = 0;
  27. }
  28. }
  29. }
  30. else{
  31. $respond["status"] = 1;
  32. $respond["message"] = 'error channal id';
  33. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  34. exit;
  35. }
  36. if($cooperation==0){
  37. $respond["status"] = 1;
  38. $respond["message"] = 'error 无修改权限';
  39. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  40. exit;
  41. }
  42. $query="UPDATE channal SET name = ? , summary = ?, status = ? , lang = ? , receive_time= ? , modify_time= ? where id = ? ";
  43. $sth = $PDO->prepare($query);
  44. $sth->execute(array($_POST["name"] , $_POST["summary"], $_POST["status"] , $_POST["lang"] , mTime() , mTime() , $_POST["id"]));
  45. $respond=array("status"=>0,"message"=>"");
  46. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  47. $error = PDO_ErrorInfo();
  48. $respond['status']=1;
  49. $respond['message']=$error[2];
  50. }
  51. else{
  52. // 设置 句子库和逐词译库可见性
  53. PDO_Connect("sqlite:"._FILE_DB_SENTENCE_);
  54. $query="UPDATE sentence SET language = ? , status = ? where channal = ? ";
  55. $sth = PDO_Execute($query,array($_POST["lang"],$_POST["status"],$_POST["id"]));
  56. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  57. $error = PDO_ErrorInfo();
  58. $respond['status']=1;
  59. $respond['message']=$error[2];
  60. }
  61. else{
  62. // 设置 逐词译库可见性
  63. PDO_Connect("sqlite:"._FILE_DB_USER_WBW_);
  64. $query="UPDATE wbw_block SET lang = ? , status = ? where channal = ? ";
  65. $sth = PDO_Execute($query,array($_POST["lang"],$_POST["status"],$_POST["id"]));
  66. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  67. $error = PDO_ErrorInfo();
  68. $respond['status']=1;
  69. $respond['message']=$error[2];
  70. }
  71. }
  72. }
  73. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  74. ?>