my_channal_put.php 1.0 KB

123456789101112131415161718192021222324
  1. <?php
  2. #新建channel
  3. require_once "../config.php";
  4. require_once "../public/_pdo.php";
  5. require_once '../public/function.php';
  6. require_once '../hostsetting/function.php';
  7. require_once __DIR__."/../public/snowflakeid.php";
  8. $snowflake = new SnowFlakeId();
  9. $respond=array("status"=>0,"message"=>"");
  10. if(isset($_COOKIE["userid"])){
  11. PDO_Connect(_FILE_DB_CHANNAL_,_DB_USERNAME_,_DB_PASSWORD_);
  12. $query="INSERT INTO "._TABLE_CHANNEL_." ( id, uid, owner_uid , editor_id, name , summary , status , lang, create_time , modify_time ) VALUES ( ?, ? , ? , ? , ? , ? , ? , ? , ? , ? ) ";
  13. $sth = $PDO->prepare($query);
  14. $sth->execute(array($snowflake->id() , UUID::v4() , $_COOKIE["user_uid"] , $_COOKIE["user_id"] , $_POST["name"] , "" , $_POST["status"] ,$_POST["lang"] , mTime() , mTime() ));
  15. $respond=array("status"=>0,"message"=>"");
  16. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  17. $error = PDO_ErrorInfo();
  18. $respond['status']=1;
  19. $respond['message']=$error[2];
  20. }
  21. }
  22. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  23. ?>