<?php

require "class/sistema.class.php";
require "seguranca.php";
try {
    protegePagina(null);
    switch ($_POST["acao"]) {
        case "cadastrar_video":
            $data = array("titulo" => $_POST["titulo"], "categoria" => $_POST["categoria"], "url" => $_POST["url"]);
            if (isset($_POST["tipo"])) {
                $data["tipo"] = $_POST["tipo"];
            }
            $sistema = new Sistema($data);
            $sistema->cadastrarVideo();
            break;
        case "cadastrar_video_upload":
            $data = array("titulo" => $_POST["titulo"], "categoria" => $_POST["categoria"], "arquivo" => $_FILES["arquivo"]);
            if (isset($_POST["tipo"])) {
                $data["tipo"] = $_POST["tipo"];
            }
            $sistema = new Sistema($data);
            $sistema->cadastrarVideoUpload();
            break;
        case "formulario_video":
            $sistema = new Sistema(array("id" => $_POST["id"]));
            $sistema->formularioVideo();
            break;
        case "formulario_video_upload":
            $sistema = new Sistema(array("id" => $_POST["id"]));
            $sistema->formularioVideoUpload();
            break;