Пример #1
0
include 'functions/cURLFunctions.php';
include 'functions/config.php';
session_start();
if (!isset($_SESSION['login_user'])) {
    header("location: login");
}
if (isset($_POST['videoinputsection']) && isset($_POST['videoinputtitle']) && isset($_POST['videoinputdesc']) && isset($_POST['selectedyearvideo'])) {
    global $uploadDir;
    $video = createVideo($_POST['videoinputtitle'], $_POST['videoinputdesc'], "0", $_POST['videoinputsection'], $_POST['selectedyearvideo']);
    if (empty($_FILES['videoinputfile']) && $_FILES['videoinputfile']['name'] != "") {
        foreach ($video as $value) {
            $fileExt = end(explode(".", $_FILES["videoinputfile"]["name"]));
            $fileName = $value["ID"] . "." . $fileExt;
            move_uploaded_file($_FILES["videoinputfile"]["tmp_name"], $uploadDir . $fileName);
            chmod($uploadDir . $fileName, 0644);
        }
    }
    header("location: index?year=" . $_POST['selectedyearvideo'] . "&section=" . $_POST['videoinputsection']);
}
if (isset($_POST['updatevideoinputtitle']) && isset($_POST['updatevideoinputdesc']) && isset($_POST['updatevideoid']) && isset($_POST['updatevideoyear']) && isset($_POST['updatevideosection'])) {
    global $uploadDir;
    updateVideo($_POST['updatevideoinputtitle'], $_POST['updatevideoinputdesc'], "0", $_POST['updatevideosection'], $_POST['updatevideoyear'], $_POST['updatevideoid']);
    if (empty($_FILES['videoinputfile']) && $_FILES['updatevideoinputfile']['name'] != "") {
        echo "test1";
        $fileExt = end(explode(".", $_FILES["updatevideoinputfile"]["name"]));
        $fileName = $_POST['updatevideoid'] . "." . $fileExt;
        move_uploaded_file($_FILES["updatevideoinputfile"]["tmp_name"], $uploadDir . $fileName);
        chmod($uploadDir . $fileName, 0644);
    }
    header("location: index?year=" . $_POST['updatevideoyear'] . "&section=" . $_POST['updatevideosection']);
}
Пример #2
0
function buscarVideos($IDcurso, $IDtema, $dir)
{
    global $extensionesValidas;
    $cont = 0;
    $ubicacion = str_replace(_DOCUMENTROOT . _DIRCURSOS, '', $dir);
    if ($handle = opendir($dir)) {
        while (false !== ($filename = readdir($handle))) {
            if ($filename != "." && $filename != "..") {
                // Si existe la carpeta de INBOX, leer su contenido:
                if (is_dir($dir . "/" . $filename)) {
                    logAction($dir . "/" . $filename . " no se procesará, ya que no es un archivo");
                    //echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Las carpetas dentro de un tema no se procesarán <br />";
                } else {
                    // Comprobar si el archivo tiene una extensión válida:
                    $extension = pathinfo($dir . "/" . $filename, PATHINFO_EXTENSION);
                    if (in_array($extension, $extensionesValidas)) {
                        $cont++;
                        // Limpiar el nombre de la carpeta de caracteres extraños y espacios
                        $filenameNEW = clean($filename);
                        rename($dir . "/" . $filename, $dir . "/" . $filenameNEW);
                        // Guardar el vídeo:
                        //	echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(".$IDcurso." - ".$IDtema.") Encontrado vídeo ".$filename."<br />";
                        logAction("Encontrado vídeo " . $dir . "/" . $filename . ". Renombrado a " . $filenameNEW);
                        $IDvideo = getIDvideo($IDcurso, $IDtema, $filename, $ubicacion . "/" . $filenameNEW);
                        $img = getPortada($filenameNEW, $dir);
                        if ($img != '') {
                            updateVideo($IDvideo, $ubicacion . "/img/" . $img);
                        }
                        //	echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$ubicacion."/".$filenameNEW."<br />";
                        //	echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$ubicacion."/img/".$img."<br />";
                    } else {
                        logAction($dir . "/" . $filename . " no tiene una extensión válida");
                    }
                }
            }
        }
        if ($cont == 0) {
            logAction($dir . " no contiene vídeos");
            //	echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;No existen vídeos para ".$dir."<br />";
        }
    } else {
        logAction("Error al leer " . $dir);
        //	echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Error al leer de ".$dir."<br />";
    }
}