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);
    }
} else {
    $WsPosts = new WsPosts();
    $WsPosts->setPost_id($postid);
    $WsPosts->find();
    if (!$WsPosts->getResult()) {
        header('Location: painel.php?exe=post/index&empty=true');
    } else {
        $post = (array) $WsPosts->getResult();
        $post['post_date'] = date('d/m/Y H:i:s', strtotime($post['post_date']));
    }
}
if (!empty($_SESSION['errCapa'])) {
    WSErro($_SESSION['errCapa'], E_USER_WARNING);
    unset($_SESSION['errCapa']);
}
$checkCreate = filter_input(INPUT_GET, 'create', FILTER_VALIDATE_BOOLEAN);
if ($checkCreate && empty($cadastra)) {
    WSErro("O post <b>{$post['post_title']}</b> foi cadastrado com sucesso no sistema!", WS_ACCEPT);
}
 private function UpdateImage()
 {
     if (is_array($this->Data['post_cover'])) {
         $WsPosts = new WsPosts();
         $WsPosts->setPost_id($this->Post);
         $WsPosts->find();
         $this->deletaImagem('../uploads/' . $WsPosts->getResult()->post_cover);
         $upload = new Upload();
         $upload->Image($this->Data['post_cover'], $this->Data['post_name']);
     }
     if (isset($upload) && $upload->getResult()) {
         $this->Data['post_cover'] = $upload->getResult();
         $this->Update();
     } else {
         unset($this->Data['post_cover']);
         if (!empty($upload) && $upload->getError()) {
             WSErro("<b>ERRO AO ENVIAR CAPA: </b>" . $upload->getError(), E_USER_WARNING);
         }
         $this->Update();
     }
 }