my_channal_post.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  52. ?>