elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Trabajando con las ramas de git (tercera parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  Cuenta descarga
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: 1 [2] Ir Abajo Respuesta Imprimir
Autor Tema: Cuenta descarga  (Leído 6,322 veces)
alone-in-the-chat


Desconectado Desconectado

Mensajes: 587


Ver Perfil
Re: Cuenta descarga
« Respuesta #10 en: 7 Octubre 2008, 21:32 pm »

Pues yo eh probado y funciona como un contador de visitas...

pero los enlaces que tu colocas son directos a los archivos:

href="manual/minicom.pdf"

de esa forma no se puede contar nada , por lo que lei lineas arriba a ese archivo debe llamarlo un php .

me tome la libertad de modificar un poco el codigo de Diabliyo (espero que no te moleste  :P ) , de forma que lo veas mas claro asi como esta funciona , claro ponle seguridad y demas  cosas de por si es bastante rudimentario.

index.php
Código
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Documento sin t&iacute;tulo</title>
  6. <style type="text/css">
  7. <!--
  8. .Estilo1 {color: #FFFFFF}
  9. -->
  10. </style>
  11. </head>
  12.  
  13. <body>
  14. <p class="Estilo1">.</p>
  15. <p class="Estilo1">.</p>
  16. <p class="Estilo1">.</p>
  17. <p class="Estilo1">.</p>
  18. <table width="520" border="10" align="center" cellpadding="1" cellspacing="1">
  19.  <tr>
  20.    <td colspan="4"><h1 align="center">Electrónica Pic</h1></td>
  21.  </tr>
  22.  <tr>
  23.    <td>Manual</td>
  24.    <td colspan="3"><div align="center">Formatos</div></td>
  25.  </tr>
  26.  <tr>
  27.    <td width="161"><div align="left">Minicom</div></td>
  28.    <td width="112"><div align="center"><a href="descargar.php?file=1" target="_blank">PDF</a></div></td>
  29.    <td width="112"><div align="center"><a href="descargar.php?file=2" target="_blank">XPS</a></div></td>
  30.    <td width="112"><div align="center"><a href="http://www.pic16f84a.org/component/docman/doc_download/38-minicom-v110.html">ZIP</a>(pdf)</div></td>
  31.  </tr>
  32.  <tr>
  33.    <td><div align="left">WinPic800</div></td>
  34.    <td><div align="center">PDF</div></td>
  35.    <td><div align="center">XPS</div></td>
  36.    <td><div align="center"><a href="http://www.pic16f84a.org/component/docman/doc_download/41-winpic800-v11.html">ZIP</a>(pdf)</div></td>
  37.  </tr>
  38. </table>
  39.  
  40. </body>
  41. </html>
  42.  

descargar.php
Código
  1. <?php
  2.  
  3.    error_reporting(E_ALL);
  4. if (isset($_GET['file']))
  5. {
  6. $fp= fopen( "micontador.txt", "r" );
  7. $big_buffer="";
  8. while( !feof($fp) )
  9. {
  10.     $buf= fgets($fp);
  11.     $x= explode( "|", $buf , 3 );
  12.     if( $x[0] == $_GET["file"] )
  13.     {
  14. $x= explode( "|", $buf );
  15. $big_buffer .= $x[0];
  16. $big_buffer .= "|";
  17. $big_buffer .= $x[1];
  18. $big_buffer .= "|";
  19. $x[2] = trim($x[2]);
  20. $big_buffer .= ($x[2]+1)."\n";
  21.  
  22. $download = $x[1];
  23. unset($x);
  24. }else{
  25.          $big_buffer .= trim($buf)."\n";
  26.     }
  27.     unset($buf);
  28. }
  29. //$big_buffer = trim($big_buffer);
  30. fclose($fp);
  31. unset($fp);
  32.  
  33. $fp_out= fopen( "micontador.txt", "w" );
  34. fwrite($fp_out, trim($big_buffer));
  35. fclose($fp_out);
  36. unset($fp_out);
  37. unset($big_buffer);
  38.  
  39. /* LANZAMOS EL ARCHIVO */
  40. header("Location: $download");
  41. }
  42. ?>


micontador.txt
Código
  1. 1|manuales/archivo.pdf|0
  2. 2|manuales/file.csv|0
  3.  


pruebalo si tienes alguna duda posteala porfa.

Saludos¡¡


En línea

Because maybe
You're gonna be the one that saves me
And after all
You're my wonderwall
d[n_n]b
Páginas: 1 [2] Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines