Example #1
0
        redirect("{$CFG->wwwroot}/blocks/webgd_community/view.php?community={$idCommunity}&option=7", 'Video não encontrado', 10);
        echo $OUTPUT->footer();
        die;
    } else {
        echo $OUTPUT->heading('<span class="titulo_list">' . '<a href="' . $url . '" >' . $OUTPUT->heading($community->name, 2, 'titulo_comunidade') . '</a></span><br/>');
        echo "<div class='subTitle'>Editar Vídeo</div><br/>";
    }
} else {
    echo $OUTPUT->heading('<span class="titulo_list">' . '<a href="' . $url . '" >' . $OUTPUT->heading($community->name, 2, 'titulo_comunidade') . '</a></span><br/>');
    echo "<div class='subTitle'>Cadastar Vídeo</div><br/>";
}
$mform = new CadastrarArquivoForm(null, array('community' => $idCommunity, 'file' => $idFile));
if ($data = $mform->get_data()) {
    if ($idFile) {
        $msg = get_string('msgErro', 'block_webgd_community');
        if ($arquivo = $webgdCommunityDao->searchMovieById($idFile)) {
            $arquivo->name = $data->nome;
            if ($id = $DB->update_record(TableResouces::$TABLE_PAGE_COMMUNITY_MEDIA, $arquivo)) {
                $msg = 'Video editado com sucesso';
            }
        }
    } else {
        $name = $mform->get_new_filename('attachment');
        $random = rand();
        $name = $random . '_' . $name;
        $path = "{$CFG->dataroot}/webgd_community/{$name}";
        $msg = get_string('msgErro', 'block_webgd_community');
        if ($mform->save_file('attachment', $path, true)) {
            try {
                $transaction = $DB->start_delegated_transaction();
                $post = new stdClass();
Example #2
0
<?php

require_once dirname(__FILE__) . '/../../../../config.php';
require_once $CFG->dirroot . '/blocks/webgd_community/lib/class/dao/WebgdCommunityDao.php';
require_login(1);
$idFile = optional_param('file', 0, PARAM_INTEGER);
$webgdDao = new WebgdCommunityDao();
$fileBd = $webgdDao->searchMovieById($idFile);
$path = $fileBd->path;
$aux = explode('.', $path);
$extensao = $aux[sizeof($aux) - 1];
$size = filesize($path);
$fm = @fopen($path, 'rb');
if (!$fm) {
    // You can also redirect here
    header("HTTP/1.0 404 Not Found");
    die;
}
$begin = 0;
$end = $size;
if (isset($_SERVER['HTTP_RANGE'])) {
    if (preg_match('/bytes=\\h*(\\d+)-(\\d*)[\\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches)) {
        $begin = intval($matches[0]);
        if (!empty($matches[1])) {
            $end = intval($matches[1]);
        }
    }
}
if ($begin > 0 || $end < $size) {
    header('HTTP/1.0 206 Partial Content');
} else {
Example #3
0
<?php

require_once dirname(__FILE__) . '/../../../../config.php';
require_once $CFG->dirroot . '/blocks/webgd_community/commons/TableResouces.php';
require_once $CFG->dirroot . '/blocks/webgd_community/lib/class/dao/WebgdCommunityDao.php';
global $USER;
require_login(1);
$PAGE->set_url('/course/index.php');
$PAGE->set_context(context_system::instance());
$PAGE->set_pagelayout('standard');
echo $OUTPUT->header('themeselector');
echo $OUTPUT->heading('Deletar Video');
$idFile = optional_param('file', 0, PARAM_INTEGER);
$idCommunity = optional_param('community', 0, PARAM_INTEGER);
$webgdCommunityDao = new WebgdCommunityDao();
$msg = 'Video não encontrado';
if ($webgdCommunityDao->searchMovieCommunityById($idCommunity, $idFile)) {
    $file = $webgdCommunityDao->searchMovieById($idFile);
    if ($webgdCommunityDao->deleteMovieByIdUser($file->id, $USER->id, $file->post)) {
        $msg = 'Video excluido com sucesso';
        unlink($file->path);
    }
}
redirect("{$CFG->wwwroot}/blocks/webgd_community/view.php?community={$idCommunity}", $msg, 10);
echo $OUTPUT->footer();