public function js(array $datos = array()) { $validaciones = array("p3" => "errores_requerido && errores_identificador", "p4" => "errores_requerido && errores_texto"); if (!\core\Validaciones::errores_validacion_request($validaciones, $datos)) { $datos["ruta"] = PATH_APP . "ficheros/" . $datos["values"]["p3"] . "/"; $datos["fichero"] = urldecode($datos["values"]["p4"]); $extension = substr($datos["fichero"], strpos($datos["fichero"], ".")); // echo("Path_Fichero: ".$ruta.$fichero); // echo("Tamaño: " .filesize($ruta.$fichero)); // exit(__METHOD__.$extension.\modelos\ficheros::get_mime_type($extension)); $fila["fichero"] = $datos["values"]["p3"] . "/" . $datos["fichero"]; $fila["remote_addr"] = $_SERVER["REMOTE_ADDR"]; $fila["request_time"] = gmdate("Y-m-d H:i:s", $_SERVER["REQUEST_TIME"]); if (!\modelos\descargas::tabla("descargas")->insert($fila)) { exit(\modelos\descargas::get_error()); } header("Content-type: " . \modelos\ficheros::get_mime_type($extension)); // header('Content-Disposition: attachment; filename="'.$fichero.'"'); // header("Content-Transfer-Encoding: binary"); header("Content-Length: " . filesize($datos["ruta"] . $datos["fichero"])); // $http_body = \core\Vista::generar(__FUNCTION__, $datos); // echo $http_body; $file_path = $datos["ruta"] . $datos["fichero"]; include $file_path; } else { header("Location: " . \core\URL::generar()); } }
/** * * @return array $ficheros["carpeta"]=array("file1", "file2", ...) */ public static function get_ficheros($carpeta) { $directorio = PATH_APPLICATION . "recursos/ficheros"; if ($_REQUEST["p3"] == 'krasnale') { $directorio = PATH_APPLICATION . "recursos/imagenes"; } $ficheros = array(); $subdirectorio = $directorio . "/{$carpeta}"; if ($dh = opendir($subdirectorio)) { while (($file = readdir($dh)) !== false) { // echo "filename:" . $file . "<br>"; if (is_file($subdirectorio . "/{$file}")) { // array_push($ficheros, $file); $ficheros[$file] = \modelos\descargas::get_contador_descargas("{$carpeta}/{$file}"); } } closedir($dh); } return $ficheros; }