my_group_put.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. #新增群组或项目
  3. require_once "../path.php";
  4. require_once "../public/_pdo.php";
  5. require_once '../public/function.php';
  6. $respond=array("status"=>0,"message"=>"");
  7. if(isset($_COOKIE["userid"])){
  8. PDO_Connect("sqlite:"._FILE_DB_GROUP_);
  9. $query="INSERT INTO group_info ( id, parent , name , description , status , creator ,create_time )
  10. VALUES ( ?, ? , ? , ? , ? , ? ,? ) ";
  11. $sth = $PDO->prepare($query);
  12. $newid = UUID::v4();
  13. $sth->execute(array( $newid,$_POST["parent"], $_POST["name"], "" ,1 ,$_COOKIE["userid"] , mTime() ));
  14. $respond=array("status"=>0,"message"=>"");
  15. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  16. $error = PDO_ErrorInfo();
  17. $respond['status']=1;
  18. $respond['message']=$error[2];
  19. }
  20. $query="INSERT INTO group_member ( user_id , group_id , power , group_name , level , status )
  21. VALUES ( ? , ? , ? , ? , ? ,? ) ";
  22. $sth = $PDO->prepare($query);
  23. if($_POST["parent"]==0){
  24. $level = 0;
  25. $power = 0;
  26. }
  27. else{
  28. $level = 1;
  29. $power = 1;
  30. }
  31. $sth->execute(array($_COOKIE["userid"] ,$newid, $power , $_POST["name"], $level ,1 ));
  32. $respond=array("status"=>0,"message"=>"");
  33. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  34. $error = PDO_ErrorInfo();
  35. $respond['status']=1;
  36. $respond['message']=$error[2];
  37. }
  38. }
  39. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  40. ?>