my_group_put.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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("" . _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. } else {
  27. $level = 1;
  28. $power = 1;
  29. }
  30. $sth->execute(array($_COOKIE["userid"], $newid, $power, $_POST["name"], $level, 1));
  31. $respond = array("status" => 0, "message" => "");
  32. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  33. $error = PDO_ErrorInfo();
  34. $respond['status'] = 1;
  35. $respond['message'] = $error[2];
  36. }
  37. }
  38. echo json_encode($respond, JSON_UNESCAPED_UNICODE);