<h1>Criar Post:</h1> </header> <?php $post = filter_input_array(INPUT_POST, FILTER_DEFAULT); if (isset($post) && $post['SendPostForm']) { $post['post_status'] = $post['SendPostForm'] == 'Cadastrar' ? '0' : '1'; $post['post_cover'] = $_FILES['post_cover']['tmp_name'] ? $_FILES['post_cover'] : null; unset($post['SendPostForm']); require '_models/AdminPost.class.php'; $cadastra = new AdminPost(); $cadastra->ExeCreate($post); if ($cadastra->getResult()) { if (!empty($_FILES['gallery_covers']['tmp_name'])) { $sendGallery = new AdminPost(); $sendGallery->gbSend($_FILES['gallery_covers'], $cadastra->getResult()); } header('Location: painel.php?exe=posts/update&create=true&postId=' . $cadastra->getResult()); } else { WSErro($cadastra->getError()[0], $cadastra->getError()[1]); } } ?> <form name="PostForm" action="" method="post" enctype="multipart/form-data"> <label class="label"> <span class="field">Enviar Capa:</span> <input type="file" name="post_cover" /> </label>
</header> <?php $post = filter_input_array(INPUT_POST, FILTER_DEFAULT); $postid = filter_input(INPUT_GET, 'postId', FILTER_VALIDATE_INT); if (isset($post) && $post['SendPostForm']) { $post['post_status'] = $post['SendPostForm'] == 'Atualizar' ? '0' : '1'; $post['post_cover'] = $_FILES['post_cover']['tmp_name'] ? $_FILES['post_cover'] : 'null'; unset($post['SendPostForm']); require_once '_models/AdminPost.class.php'; $cadastra = new AdminPost(); $cadastra->ExeUpdate($postid, $post); WSErro($cadastra->getError()[0], $cadastra->getError()[1]); if (!empty($_FILES['gallery_covers']['tmp_name'])) { $sendGallery = new AdminPost(); $sendGallery->gbSend($_FILES['gallery_covers'], $postid); } if (!empty($_FILES['files']['tmp_name'])) { $sendFiles = new AdminPost(); $sendFiles->flSend($_FILES['files'], $postid); } } else { $WsPosts = new WsPosts(); $WsPosts->setPost_id($postid); $WsPosts->Execute()->find(); if (!$WsPosts->Execute()->getResult()) { header('Location: painel.php?exe=posts/index&empty=true'); } else { $post = (array) $WsPosts->Execute()->getResult(); $post['post_date'] = date('d/m/Y H:i:s', strtotime($post['post_date'])); }