Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2.  
  3. $link = $_POST["link"];
  4.  
  5. if (empty($link)) {
  6. $payload->info = "Please fill in the link.";
  7. $payload->message = "400: Bad Request";
  8.  
  9. $response = new Response($payload, 400, "Bad Request");
  10. $response->execute();
  11. exit();
  12. }
  13.  
  14. if (filter_var($link, FILTER_VALIDATE_URL) === FALSE) {
  15. $payload->info = "Your link is not valid.";
  16. $payload->message = "400: Bad Request";
  17.  
  18. $response = new Response($payload, 400, "Bad Request");
  19. $response->execute();
  20. exit();
  21. }
  22.  
  23. $id = bin2hex(random_bytes(4));
  24.  
  25. $database->query("INSERT INTO shortcuts VALUES ('$oauth', '$id', 0, '$link')");
  26.  
  27. $payload->info = "Shortcut has been created!<br><br> Your link is: https://wildbuck.co/shortcuts/$id";
  28. $payload->id = $id;
  29. $payload->message = "200: OK";
  30.  
  31. $response = new Response($payload, 200, "OK");
  32. $response->execute();
  33. exit();
  34.  
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement