From e762c01b34ade503c5fa74cc2cd506bb4bb67a42 Mon Sep 17 00:00:00 2001 From: "Janus B. Kristensen" Date: Sun, 17 Jun 2007 13:43:18 +0000 Subject: [PATCH] The .torrent-generator allowing projects to dynamically generator .torrent-data for their files. svn path=/trunk/boinc/; revision=12950 --- html/bt/torrent_cache.php | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 html/bt/torrent_cache.php diff --git a/html/bt/torrent_cache.php b/html/bt/torrent_cache.php new file mode 100755 index 0000000000..7201d90171 --- /dev/null +++ b/html/bt/torrent_cache.php @@ -0,0 +1,57 @@ +isValid($file)) throw new IllegalArgumentException("File was not accepted by the server for tracking."); + +// Everything's fine let's lookup the .torrent in the cache if needed: +$cache_args = "file=".$file."&modtime=".$fileModTime; +$cacheddata=get_cached_data(TORRENT_CACHE_TTL,$cache_args); +if ($cacheddata){ //If we have got the data in cache + $torrent = unserialize($cacheddata); // use the cached data +} else { //if not do queries etc to generate new data + for ($i=0; $iensureSHA1Loaded(); + db_init(); + $torrent->register(); + set_cache_data(serialize($torrent),$cache_args); //save data in cache +}; + +header("Content-type: application/x-bittorrent"); +header("Content-Disposition: attachment; filename=\"".basename($file).".torrent\""); + +echo $torrent->toEncoded(); +?> \ No newline at end of file