Advertisement
Guest User

Untitled

a guest
May 4th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. public function action_register()
  2. {
  3. if (Common::isEmpty($_POST)) {
  4. Common::redir("painel-do-usuario/post/novo");
  5. }
  6.  
  7. $referenceColumns = array(
  8. "id" => (int) Session::get("userId")
  9. );
  10.  
  11. $qr = $this->user->get($referenceColumns);
  12.  
  13. if ($qr) {
  14. $image = $_POST["screenshot"];
  15.  
  16. $filename = uniqid(time()) . ".png";
  17.  
  18. $image = str_replace('data:image/png;base64,', '', $image);
  19. $decoded = base64_decode($image);
  20.  
  21. file_put_contents(str_replace("/", DIRECTORY_SEPARATOR, STATIC_PATH . "image/posts/" . $qr["dir"] . "/" . $filename), $decoded);
  22.  
  23. $referenceColumns = array(
  24. "title" => filter_input(INPUT_POST, "formatTitle", FILTER_SANITIZE_STRING)
  25. );
  26.  
  27. $qr = $this->format->get($referenceColumns);
  28.  
  29. if ($qr) {
  30. $addedUpColumns = array(
  31. "id_user" => Session::get("userId"),
  32. "id_format" => $qr["id"],
  33. "title" => filter_input(INPUT_POST, "title", FILTER_SANITIZE_STRING),
  34. "path" => $filename
  35. );
  36.  
  37. $qr = $this->image->create($addedUpColumns);
  38.  
  39. if ($qr) {
  40. Common::redir("painel-do-usuario/post/listar");
  41. }
  42. }
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement