<?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); $q = optional_param('q', 0, PARAM_INTEGER); $webgdCommunityDao = new WebgdCommunityDao(); if ($q) { $fileBd = $webgdCommunityDao->searchQuestionByCommunityById($idFile); $path = $fileBd->attachmentquestion; } else { $fileBd = $webgdCommunityDao->searchAnswerById($idFile); $path = $fileBd->video; } $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]);