english 
Thread Options  Search this Thread  
Post: #1
30-11-2006 16:44 PM (This post was last modified: 30-11-2006 18:07 PM by xam)
SquadG


Joined: 29-11-2006
Posts: 25
Country: Canada
Male SquadG is Offline now
404 Solution for Not Found ...
Try this code, now it work on my new server :

CODE:
<?php

require_once("include/bittorrent.php");

dbconn();
maxsysop ();
parked();
@ini_set('zlib.output_compression', 'On');
@set_time_limit(0);

if (@ini_get('output_handler') == 'ob_gzhandler' AND @ob_get_length() !== true)
{	// if output_handler = ob_gzhandler, turn it off and remove the header sent by PHP
	@ob_end_clean();
	header('Content-Encoding:');
}

$_SERVER["PATH_INFO"]= "/" . $_GET["name"] . ".torrent";

if (!preg_match(':^/(\d{1,10})/(.+)\.torrent$:', $_SERVER["PATH_INFO"], $matches)) {

	httperr();
	}

$id = 0 + $matches[1];
//$id = 0 + 76;
if (!$id)
	httperr();

$res = sql_query("SELECT name FROM torrents WHERE id = ".sqlesc($id)) or sqlerr(__FILE__, __LINE__);
$row = mysql_fetch_assoc($res);

$fn = "$torrent_dir/$id.torrent";

if (!$row || !is_file($fn) || !is_readable($fn))
	httperr();

sql_query("UPDATE torrents SET hits = hits + 1 WHERE id = ".sqlesc($id)) or sqlerr(__FILE__, __LINE__);

require_once "include/benc.php";

if (strlen($CURUSER['passkey']) != 32) {
	$CURUSER['passkey'] = md5($CURUSER['username'].get_date_time().$CURUSER['passhash']);
	sql_query("UPDATE users SET passkey=".sqlesc($CURUSER[passkey])." WHERE id=".sqlesc($CURUSER[id]));
}

$dict = bdec_file($fn, (1024*1024));
$dict['value']['announce']['value'] = "$BASEURL/announce.php?passkey=$CURUSER[passkey]";
$dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']).":".$dict['value']['announce']['value'];
$dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']);

header ("Expires: Tue, 1 Jan 1980 00:00:00 GMT");
header ("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header ("Cache-Control: no-store, no-cache, must-revalidate");
header ("Cache-Control: post-check=0, pre-check=0", false);
header ("Pragma: no-cache");
header ("X-Powered-By: ".VERSION." (c) ".date("Y")." ".$SITENAME."");
header ("Accept-Ranges: bytes");
header ("Connection: close");
header ("Content-Transfer-Encoding: binary");
header ("Content-disposition: attachment; filename=$name.torrent");
header ("Content-Type: application/x-bittorrent");
ob_implicit_flush(true);

print(benc($dict));
?>


Work very good

PS: Sorry for my english, i'm from Quebec

Post: #2
30-11-2006 23:25 PM
Aazir


Joined: 29-11-2006
Posts: 461
Country: Canada
Male Aazir is Offline now
404 Solution for Not Found ...
moi aussi je suis du québec


Post: #3
30-11-2006 23:32 PM
SquadG


Joined: 29-11-2006
Posts: 25
Country: Canada
Male SquadG is Offline now
404 Solution for Not Found ...
Sa fais plaisir de voir un québéquois too Si ta un prob avec le 404 utilise ce script

Post: #4
30-11-2006 23:33 PM (This post was last modified: 30-11-2006 23:35 PM by svetlioOo)
svetlioOo


Joined: 11-11-2006
Posts: 127
Country: Bulgaria
Male svetlioOo is Offline now
404 Solution for Not Found ...
Write on English !!! This is not multi-language forum.. I am not good at English too but I write on it...

Post: #5
30-11-2006 23:49 PM
Aazir


Joined: 29-11-2006
Posts: 461
Country: Canada
Male Aazir is Offline now
404 Solution for Not Found ...
jai pas de probleme

linstallation a marcher #1

Post: #6
01-12-2006 03:20 AM
SquadG


Joined: 29-11-2006
Posts: 25
Country: Canada
Male SquadG is Offline now
404 Solution for Not Found ...
Qui est ton hoster?

Post: #7
01-12-2006 05:21 AM
Aazir


Joined: 29-11-2006
Posts: 461
Country: Canada
Male Aazir is Offline now
404 Solution for Not Found ...
moi meme

jai un serveur tres stable en linix Gentoo

clic sur ma signature

Post: #8
01-12-2006 05:57 AM (This post was last modified: 01-12-2006 05:58 AM by SquadG)
SquadG


Joined: 29-11-2006
Posts: 25
Country: Canada
Male SquadG is Offline now
404 Solution for Not Found ...
Sympa comme tracker ^^ Je m'abonne voir

PS: Ta une traduction fini ? Moi elle est là à disons 30%, check là : http://www.hdfrench.com

Post: #9
01-12-2006 09:51 AM
xam
Team Leader


Joined: 01-02-2006
Posts: 11,515
Country: Belgium
Awards:  
Male xam is Offline now
404 Solution for Not Found ...
write 1 more post and say bye bye.

Quick Reply
Decrease Size
Increase Size
Insert bold text Insert italic text Insert underlined text Align text to the left Align text to the centerr Align text to the right Justify text Insert quoted text Code Insert formatted PHP code Insert formatted SQL code
Colors
Insert hyperlink Insert image Insert email address
Smilies
Insert hidden text



Forum Jump: