<?php error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); require 'common.php'; $imagem_content = null; if (array_key_exists('acao', $_POST) && $_POST['acao'] == "gravar") { $id_personagem = intval($_POST['id_personagem']); if ($id_personagem > 0) { $personagem = Personagem::pegar($id_personagem); $personagem->carregarDoPost(); $personagem->alterar(); } else { $personagem = new Personagem(); $personagem->carregarDoPost(); $personagem->inserir(); $url = 'ficha.php?personagem=' . $personagem->getId(); if (array_key_exists('pg', $_GET)) { $url .= "&pg={$_GET['pg']}"; } header("Location: {$url}"); exit; } if (array_key_exists('imagem_content', $_POST)) { $targ_w = $targ_h = 72; $jpeg_quality = 90; $img_r = imagecreatefromstring(base64_decode($_POST['imagem_content'])); $dst_r = ImageCreateTrueColor($targ_w, $targ_h); imagecopyresampled($dst_r, $img_r, 0, 0, $_POST['x'], $_POST['y'], $targ_w, $targ_h, $_POST['w'], $_POST['h']); $personagem->setImagem($dst_r); } elseif (array_key_exists('imagem_principal_url', $_POST) && $_POST['imagem_principal_url'] != '') { $imagem_content = file_get_contents($_POST['imagem_principal_url']);