Location: PHPKode > projects > SiteX > redirect.php
<?PHP

include("includes/globals.php.inc");
include("includes/functions.php");
include("lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("lang/".$sxSetup['Language'].".php");
include("themes/$THEME_FOLDER/config.php.inc");

if($linkid){
	
	$query = "SELECT * FROM $DB_Links WHERE id='$linkid'";
	$result = mysql_query($query, $Link) or queryError("9", mysql_error());
	$ROW = mysql_fetch_object($result);
	
	$hits = $ROW->hits+1;
	$query2 = "UPDATE $DB_Links SET hits='$hits' WHERE id='$linkid'";
	$result2 = mysql_query($query2, $Link) or queryError("10", mysql_error());
	
	header("Location: $ROW->url");
	die();
}
elseif($fileid){
	
	$query = "SELECT * FROM $DB_Files WHERE id='$fileid'";
	$result = mysql_query($query, $Link) or queryError("9", mysql_error());
	$ROW = mysql_fetch_object($result);
	
	$hits = $ROW->hits+1;
	$query2 = "UPDATE $DB_Files SET hits='$hits' WHERE id='$fileid'";
	$result2 = mysql_query($query2, $Link) or queryError("10", mysql_error());
	
	//header("Location: content/files/$ROW->filename");
	
	$filename = $sxContentDir['Files']."/".$ROW->filename;

	// required for IE, otherwise Content-disposition is ignored
	if(ini_get('zlib.output_compression'))
		ini_set('zlib.output_compression', 'Off');
	
	// addition by Jorg Weske
	$file_extension = strtolower(substr(strrchr($filename,"."),1));
	
	switch($file_extension)
	{
	  case "pdf": $ctype="application/pdf"; break;
	  case "exe": $ctype="application/octet-stream"; break;
	  case "zip": $ctype="application/zip"; break;
	  case "doc": $ctype="application/msword"; break;
	  case "xls": $ctype="application/vnd.ms-excel"; break;
	  case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
	  case "gif": $ctype="image/gif"; break;
	  case "png": $ctype="image/png"; break;
	  case "jpeg":
	  case "jpg": $ctype="image/jpg"; break;
	  default: $ctype="application/force-download";
	}
	header("Pragma: public"); // required
	header("Expires: 0");
	header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
	header("Cache-Control: private",false); // required for certain browsers 
	header("Content-Type: $ctype");
	// change, added quotes to allow spaces in filenames, by Rajkumar Singh
	header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
	header("Content-Transfer-Encoding: binary");
	header("Content-Length: ".filesize($filename));
	readfile("$filename");
	
	die();
}
else
{
	header("Location:".$sxThemeConfig['Homepage']);
	die();
}

?>
Return current item: SiteX