| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- require_once "../path.php";
- require_once "../public/_pdo.php";
- require_once '../public/function.php';
- require_once '../hostsetting/function.php';
- $respond=array("status"=>0,"message"=>"");
- #先查询对此channal是否有权限修改
- PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
- $cooperation = 0;
- if(isset($_POST["id"])){
- $query = "SELECT owner FROM channal WHERE id=?";
- $fetch = PDO_FetchOne($query,array($_POST["id"]));
- if($fetch && $fetch==$_COOKIE["userid"]){
- #自己的channal
- $cooperation = 1;
- }
- else{
- $query = "SELECT count(*) FROM cooperation WHERE channal_id= ? and user_id=? ";
- $fetch = PDO_FetchOne($query,array($_POST["id"],$_COOKIE["userid"]));
- if($fetch>0){
- #有协作权限
- $cooperation = 1;
- }
- else{
- #无协作权限
- $cooperation = 0;
- }
- }
- }
- else{
- $respond["status"] = 1;
- $respond["message"] = 'error channal id';
- echo json_encode($respond, JSON_UNESCAPED_UNICODE);
- exit;
- }
- if($cooperation==0){
- $respond["status"] = 1;
- $respond["message"] = 'error 无修改权限';
- echo json_encode($respond, JSON_UNESCAPED_UNICODE);
- exit;
- }
- $query="UPDATE channal SET name = ? , summary = ?, status = ? , lang = ? , receive_time= ? , modify_time= ? where id = ? ";
- $sth = $PDO->prepare($query);
- $sth->execute(array($_POST["name"] , $_POST["summary"], $_POST["status"] , $_POST["lang"] , mTime() , mTime() , $_POST["id"]));
- $respond=array("status"=>0,"message"=>"");
- if (!$sth || ($sth && $sth->errorCode() != 0)) {
- $error = PDO_ErrorInfo();
- $respond['status']=1;
- $respond['message']=$error[2];
- }
- echo json_encode($respond, JSON_UNESCAPED_UNICODE);
- ?>
|