Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/02/2015, 21:50
newnovato
 
Fecha de Ingreso: marzo-2009
Mensajes: 117
Antigüedad: 15 años, 1 mes
Puntos: 2
contador de descargas php

tengo un archivo llamado download.php con el siguiente codigo

<?php

if (!isset($_GET['file']) || empty($_GET['file'])) {
exit();
}
$root = 'musica/';
$file = basename($_GET['file']);
$path = $root.$file;
$type = '';

if (is_file($path)) {
$size = filesize($path);
if (function_exists('mime_content_type')) {
$type = mime_content_type($path);
} else if (function_exists('finfo_file')) {
$info = finfo_open(FILEINFO_MIME);
$type = finfo_file($info, $path);
finfo_close($info);
}
if ($type == '') {
$type = "application/force-download";
}
// Definir headers
header("Content-Type: $type");
header("Content-Disposition: attachment; filename=$file");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . $size);
// Descargar archivo
readfile($path);
} else {
die("El archivo no existe.");
}

?>

y un link en un archivo.html

<p><a href="download.php?file=cancion1.mp3">descargar cancion1</a>
<p><a href="download.php?file=cancion2.mp3">descargar cancion2</a>

como hago para saber cuantas veces se ha descargado cada cancion