my_group_put.php 1.3 KB

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