Valhalla Legends Forums Archive | Web Development | [PHP] Question

AuthorMessageTime
Sorc.PolgaraOk, I'll first give some background on the project I'm doing.

My University has basically blocked students from being able to DL .torrent files via the web.  So a simple way to bypass this is to put the .torrent file in somekind of archive/compressed file and downloading it with the help of someone else or having someone else just send the .torrent file over AIM, etc.

So what the project that I'm working on is a HTML webpage that uses PHP to:
1.  Download a specified .torrent file at a given URL to the server temporarily
2.  Archive the .torrent file into some type of compressed file.

Now briefly looking over the PHP Zlib Compression Functions and Bzip2 Compression Functions, I was wondering if anyone familiar with either of the two of the two compression functions knows if I can simply skip having to do step 1.

Thanks
March 27, 2006, 07:05 PM
topazHave you tried just telling the server to download the torrent, rewrite the extension, and send it on to you?March 28, 2006, 01:12 AM
Sorc.Polgara@Topaz yup, tried that.


I've figured out how to do what I need, w/o having to do step 1.
Code:
function compress( $srcFileName, $dstFileName )
{
$fp = fopen($srcFileName, "rb");
$data = '';

while (!feof($fp)) {
$data .= fread($fp, 8192);
}

fclose($fp);

if(!file_exists($dstFileName)){
$zp = gzopen( $dstFileName, "w9" );
gzwrite( $zp, $data );
gzclose( $zp );
}else{
return false;
}

return true;
}
March 28, 2006, 01:31 AM
SecretShopid recommend, downloading, compressing, and printing all in one swoop instead of trying to save the file.  I beleve gzip format can compress a stream.March 29, 2006, 11:34 PM
Joe[x86]I bet the filter has something to do with checking the magic bytes in the torrent file, and thats what causes the file to not download even if it's no longer a .torrent. Try changing the magic bytes and writing a small processing program to change it back to normal on the other end, asuming this isn't working out.March 30, 2006, 09:58 AM
SecretShop
I bet the filter has something to do with checking the magic bytes in the torrent file, and thats what causes the file to not download even if it's no longer a .torrent. Try changing the magic bytes and writing a small processing program to change it back to normal on the other end, asuming this isn't working out.

The reason to use compression over some other kind of change to the file would be that its not uncommon for browsers to understand gzip streams.  You could also use https protocol so the filter cannot read whats in the data you are sending, either way would work.
March 30, 2006, 07:33 PM
Joe[x86]School filters are built tough. I've never tried, but I bet if you used HTTPS it'd just MITM you and still block it.March 31, 2006, 09:21 AM
Sorc.PolgaraNo, they are only checking for .torrent.  I am able to put the .torrent file in a .gz and download the file.April 03, 2006, 07:27 PM
topaz
No, they are only checking for .torrent.  I am able to put the .torrent file in a .gz and download the file.

So uh, progress or what?
November 07, 2006, 01:19 AM
ErsanYou don't need to do all that, the traffic shaper is probably just checking for the mime type header and file extension, rewrite it.November 25, 2006, 09:38 PM
Arta[vL]My $0.02: An easier approach might be to base64 encode it. Less dependencies, simpler code and less resource-intensive.January 09, 2007, 06:57 PM
ErsanWon't do anything if it's checking mimetypes...

Also will increase the filesize by about 1.37 times the original, all in all a pretty bad idea.
March 26, 2007, 06:46 AM
betawarz
Won't do anything if it's checking mimetypes...

Also will increase the filesize by about 1.37 times the original, all in all a pretty bad idea.

oh my god? so, you're saying instead of having to download a 4 kb file, the file will end up being like.. 5.5 kb? say it aint so. on the flip side, yeah, just check the damn mime type.
March 30, 2007, 02:46 PM
ErsanWho the fuck said the file was 4kb...

100kb versus 137kb is alot in a high traffic situation, plus the unnecessary overhead in cpu time...  Besides the fact that it wouldn't solve the problem in any way whatsoever because Arta has no clue how mime encapsulation or traffic shapers work (and consequentially, web servers and browsers in general), it was a stupid idea.

'Checking' the mime type on his end doesn't do anything, it needs to be changed...
March 30, 2007, 02:48 PM
betawarz
Who the fuck said the file was 4kb...

100kb versus 137kb is alot in a high traffic situation, plus the unnecessary overhead in cpu time...  Besides the fact that it wouldn't solve the problem in any way whatsoever because Arta has no clue how mime encapsulation or traffic shapers work (and consequentially, web servers and browsers in general), it was a stupid idea.

'Checking' the mime type on his end doesn't do anything, it needs to be changed...

torrent files.. i've yet to see a torrent file be as big as 100 kb. even the most popular torrent on isohunt.com right now, lost, with tons of trackers, is only 30 kb. and obviously when i said check the mime type, i was referring to the idea that you'd probably change it after checking it, if need be.
March 30, 2007, 03:04 PM
ErsanIf you knew how torrent files work, you'd know that they can be as big as hundreds of megabytes depending on the piece size and size of files they have hashed...  Tracker addresses barely take up any space.March 30, 2007, 07:40 PM
cefx-I download my torrent files via lynx from a server in the states, then scp it to the machine I download from.
To get around traffic shaping, I use encryption.
March 30, 2007, 07:49 PM
Joe[x86]Dear shithead Ersan,

Arta was replying strictly to my post about magic bytes, in which case it would work.

Love, Joe.
April 09, 2007, 11:25 PM
ErsanHey joe, you dumbfuck, they haven't used magic bytes since 1996, and there's sure as fuck no magic bytes in torrent files, and no traffic shaper in the history of the world has ever shaped based on "magic bytes" as that's just completely fucking retarded - learn your shit before you make idiotic and irrelevant comments.  I'm pretty sure everyone who knows anything about the actual problem disregarded your dumbass post because of how stupid it was, and consequentially I fucking guarantee you arta wasn't responding to your idiocy.  Arta might be wrong but you take the dumbass award.  For the love of God take your self-righteous whiney jesus-boy shit elsewhere.

Thanks, Someone who isn't a complete and utter moron.
April 10, 2007, 03:17 PM