![Policia](http://static.forosdelweb.com/fdwtheme/images/smilies/cop.png)
![Policia](http://static.forosdelweb.com/fdwtheme/images/smilies/cop.png)
les agradeceria si me dicen como es la vuelta...
![Afirmando](http://static.forosdelweb.com/fdwtheme/images/smilies/afirmar.gif)
![Afirmando](http://static.forosdelweb.com/fdwtheme/images/smilies/afirmar.gif)
![Afirmando](http://static.forosdelweb.com/fdwtheme/images/smilies/afirmar.gif)
![Afirmando](http://static.forosdelweb.com/fdwtheme/images/smilies/afirmar.gif)
![Policia](http://static.forosdelweb.com/fdwtheme/images/smilies/cop.png)
![Policia](http://static.forosdelweb.com/fdwtheme/images/smilies/cop.png)
![Policia](http://static.forosdelweb.com/fdwtheme/images/smilies/cop.png)
![Policia](http://static.forosdelweb.com/fdwtheme/images/smilies/cop.png)
![Afirmando](http://static.forosdelweb.com/fdwtheme/images/smilies/afirmar.gif)
![Afirmando](http://static.forosdelweb.com/fdwtheme/images/smilies/afirmar.gif)
![Afirmando](http://static.forosdelweb.com/fdwtheme/images/smilies/afirmar.gif)
![borracho](http://static.forosdelweb.com/fdwtheme/images/smilies/borracho.png)
| ||||
![]() BUENO la idea es EVITAR ![]() ![]() les agradeceria si me dicen como es la vuelta... ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
__________________ Estampados Villavicencio |
| ||||
![]() la idea es bloquear la descarga para usuarios no registrados
__________________ Estampados Villavicencio |
| |||
un index de validacion Pues yo tengo una funcion de validacion para entrar a mis paginas restringidas, y en las carpetas donde solo tengo recursos pero que no deseo permitir que accedan personas non gratas tecleando la ruta directa a la carpeta lo que hago es poner un index.php en donde solo pongo la funcion de validacion. Asi cuando alguien intente apuntar hacia mi carpeta, lo que hace la funcion es mandarlo para fuera. Obviamente si el usuario se sabe tambien el nombre del archivo que quiere descagar, ya es otra cuestión. Todo depende que tanto necesites. Generalmente en esos casos lo que se hace es sacar esos recursos del área de acción del navegador, es decir, por debajo del RootDocument. Saludos! |
| ||||
Yo un dia me encontre esta funcion y me ha servido perfecto: Código PHP: Código PHP: |
| ||||
esa funcion que hace exactamente... cualquiera puede ver el link pero solo se lo pueden bajar los registrados o algo asi? porque estaba buscando yo algo asi para meter en mis foros, que cualquiera pueda ver el link de descarga, pero solo lo puedan descargar los registrados.. que a los otros les tire a una pagina de error, o les muestre un alert o algo asi..
__________________ ALOZORRO v5.0 (ahora en .es) |
| ||||
esa funcion lo unico q hace es bajar un archivo, pero es cuestion de: session_start(); $file_to_dl = "/directorio/archivo.ext"; if (isset($_SESSION['variable_session'])){ download( $file_to_dl ); }else{ echo 'te tenes q loguear flaco'; } |
| ||||
hola intente hacer la funcion pero me falla algo . cree una carpeta y puse el script y el archivo , probe un .doc y me pidio un conversor . puse un txt y me mostro esto dentro del txt que descargo. <br /> <b>Notice</b>: Undefined variable: fpath in <b>c:\php\www\seguimientos2\prueba_donwload\prueba .php</b> on line <b>67</b><br /> <br /> <b>Warning</b>: fread(): supplied argument is not a valid stream resource in <b>c:\php\www\\prueba_donwload\prueba.php</b> on line <b>69</b><br /> <br /> <b>Warning</b>: fclose(): supplied argument is not a valid stream resource in <b>c:\php\www\\prueba_donwload\prueba.php</b> on line <b>72</b><br /> alguna idea de algo. gracias cluster por el link. un saludo
__________________ "Cuando se adelanta un oponente, enfréntalo y salúdalo; si intenta retroceder, déjalo seguir su camino" |
| ||||
una cosa.. pero esta funcion no vale para cualquier link que le pases? quiero decir.. si le meto www.google.com me daría el mismo mensaje al intentar abrirla si el usuario no esta registrado?
__________________ ALOZORRO v5.0 (ahora en .es) |
| ||||
hola no comprendo tu punto , ya que solo pruebo con la funcion para descarga un .doc que tengo en el server, aun no estoy considerando ninguna validacion de usuario. yo solo hago esto . <?php function download( $file, $fname="" ) { if( empty( $fname ) ) { $fname = explode( "/", $file ); $fname = $fname[count($fname)-1]; } if( !file_exists( $file ) ) { header("HTTP/1.1 404 Not Found"); return; } $fsize = filesize($file); $bufsize = 20000; if(isset($_SERVER['HTTP_RANGE'])) { // Partial Download if(preg_match("/^bytes=(\\d+)-(\\d*)$/", $_SERVER['HTTP_RANGE'], $matches)) { //parsing Range header $from = $matches[1]; $to = $matches[2]; if(empty($to)) { $to = $fsize - 1; // -1 because end byte is included //(From HTTP protocol: // 'The last-byte-pos value gives the byte-offset of the last byte in the range; that is, the byte positions specified are inclusive') } $content_size = $to - $from + 1; header("HTTP/1.1 206 Partial Content"); header("Content-Range: $from-$to/$fsize"); header("Content-Length: $content_size"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=$fname"); header("Content-Transfer-Encoding: binary"); header("Cache-Control: private"); if($fh = fopen($fpath, "rb")) { fseek($fh, $from); $cur_pos = ftell($fh); while($cur_pos !== FALSE && ftell($fh) + $bufsize < $to+1) { $buffer = fread($fh, $bufsize); print $buffer; $cur_pos = ftell($fh); } $buffer = fread($fh, $to+1 - $cur_pos); print $buffer; fclose($fh); } else { header("HTTP/1.1 500 Internal Server Error"); return; } } else { header("HTTP/1.1 500 Internal Server Error"); return; } } else { // Usual download header("HTTP/1.1 200 OK"); header("Content-Length: $fsize"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=$fname"); header("Content-Transfer-Encoding: binary"); header("Cache-Control: private"); $fh = fopen($fpath, "rb"); while($buf = fread($fh, $bufsize)) print $buf; fclose($fh); } } //"../prueba_donwload/tu.txt" $file_to_dl = "../prueba_donwload/tu.txt"; download( $file_to_dl ); exit(); ?>
__________________ "Cuando se adelanta un oponente, enfréntalo y salúdalo; si intenta retroceder, déjalo seguir su camino" |
| ||||
encontre esta codigo que hace lo que busco y me funcion super bien. <?PHP $id = "llamado.doc"; $enlace = "../prueba_donwload/".$id; header ("Content-Disposition: attachment; filename=".$id." "); header ("Content-Type: application/octet-stream"); header ("Content-Length: ".filesize($enlace)); readfile($enlace); ?> un saludo.
__________________ "Cuando se adelanta un oponente, enfréntalo y salúdalo; si intenta retroceder, déjalo seguir su camino" |
| ||||
Re: Proteger Links De Descarga ok. si que bien los codigos. los estoy probando y sirven . gracias a los que aportaron.
__________________ Estampados Villavicencio |