Grazie, alcune considerazioni:
1 - alla pagina http://www.ellissinelcerchio.net/musica.html cliccando ad esempio sul link http://www.opkitchen.org/click.php4?...terferenze.ogg si passa attraverso il contatore (click.php4) installato su www.opkitchen.org. L'url che fa incrementare il contatore in questo caso è: http://www.ellissinelcerchio.net/dow...terferenze.ogg
2 - se inserisco e richiamo la funzione forceDownload nel file click.php4 devo a questo punto eliminare, sempre dal file click.php4, Header("Location: $url");
Questo è il codice originale di click.php4
Codice PHP:
<?php
/**
* tClick v 0.93 beta
* Copyright 2001 Stephen G. Walizer aka Technomancer all rights reserved.
* This software is licensed under the GNU GPL. See the file GPL or
* [url]http://www.gnu.org[/url] for details.
**/
Header("Location: $url");
// MySQL database information
$host = '60.150.149.40';
$username = 'username';
$password = 'password';
$database = 'db1';
$clicktable = 'clicktable';
$categorytable = 'categorytable';
$autoaddurl = 'N';
$con = mysql_connect($host, $username, $password);
$result = mysql_db_query($database, "SELECT clicks FROM $clicktable WHERE url='$url'");
if($row = mysql_fetch_array($result)) {
$value = $row['clicks'];
$value++;
$query = "UPDATE $clicktable SET clicks=$value WHERE url='$url'";
mysql_db_query($database, $query);
} else {
if($autoadd == 'Y') {
$query = "INSERT INTO $clicktable (id, url, clicks, deleted) VALUES (NULL, '$url', 1, 'N')";
mysql_db_query($database, $query);
}
}
mysql_close($con);
?>
Questo è il codice modificato con l'inserimento della funzione forceDownload:
Codice PHP:
<?php
/**
* tClick v 0.93 beta
* Copyright 2001 Stephen G. Walizer aka Technomancer all rights reserved.
* This software is licensed under the GNU GPL. See the file GPL or
* [url]http://www.gnu.org[/url] for details.
**/
function forceDownload( &$file ) {
/**
* Function forceDownload:
* download any type of file if it exists and is readable
* -------------------------------------
* @author Andrea Giammarchi
* @date 18/01/2005
* @compatibility PHP >= 4.3.0
*/
if( file_exists( $file ) == true && is_readable( $file ) == true ) {
$filename = &basename( $file );
if( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) {
$parsename = &explode( '.', $filename );
$last = count( $parsename ) - 1;
$filename = &implode( '%2E', array_slice( $parsename, 0, $last ) );
$filename .= '.'.$parsename[$last];
}
$content = &file_get_contents( $file );
header( 'Content-Type: application/octet-stream' );
header( 'Content-Disposition: attachment; filename='.$filename );
header( 'Content-Length:'.strlen( $content ) );
header( 'Content-Transfer-Encoding: binary' );
echo $content;
exit(0);
}
}
forceDownload($file);
// MySQL database information
$host = '60.150.149.40';
$username = 'username';
$password = 'password';
$database = 'db1';
$clicktable = 'clicktable';
$categorytable = 'categorytable';
$autoaddurl = 'N';
$con = mysql_connect($host, $username, $password);
$result = mysql_db_query($database, "SELECT clicks FROM $clicktable WHERE url='$url'");
if($row = mysql_fetch_array($result)) {
$value = $row['clicks'];
$value++;
$query = "UPDATE $clicktable SET clicks=$value WHERE url='$url'";
mysql_db_query($database, $query);
} else {
if($autoadd == 'Y') {
$query = "INSERT INTO $clicktable (id, url, clicks, deleted) VALUES (NULL, '$url', 1, 'N')";
mysql_db_query($database, $query);
}
}
mysql_close($con);
?>
3 - poichè "Location" non trasmette solo un header al browser, ma anche un redirect, se lo elimino come può funzionare il counter?
Grazie
ciao
luca