Location: PHPKode > projects > H-tracker > downloadsub.php
<?
//
//  H-Tracker v0.2
//    http://h-tracker.org
//    Based on TorrentTrader (http://www.torrenttrader.org)
//
//
require_once("backend/functions.php");
require_once("phpzip.php");
dbconn();
//made by putyn @tbdev 

$updir = "$site_config[subs_dir]"; 

$action = (isset($_POST["action"]) ? $_POST["action"] : "" );
if ($action == "download"){
$id = isset($_POST["sid"]) ? 0 + $_POST["sid"] : 0; 
if ($id == 0)
show_error_msg("Err","Not a valid id");
else 
{
$res = mysql_query("SELECT id, name, filename FROM subtitles WHERE id={$id} ") or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_assoc($res);

$ext = (substr($arr["filename"] ,-3));
$fileName = str_replace(array(" ", ".","-") , "_" ,$arr["name"]).'.'.$ext;

$file = $updir."/".$arr["filename"]; 
$fileContent = file_get_contents($file);

$newFile = fopen("$updir/$fileName", "w");
@fwrite($newFile,$fileContent);
@fclose ($newFile); 

$file = array();
$zip = new PHPZip();
$file[] = "$updir/$fileName";
$fName = "$updir/".str_replace(array(" ", ".","-") , "_" ,$arr["name"]).".zip" ;
$zip->Zip($file, $fName);
$zip->forceDownload($fName);

@unlink($fName);
@unlink("$updir/$fileName");
mysql_query("UPDATE subtitles SET hits=hits+1 where id={$id}");

}
}else

show_error_msg("Err","No way");
?>
Return current item: H-tracker