• Welcome to Valhalla Legends Archive.
 

[PHP] Question

Started by Sorc.Polgara, March 27, 2006, 07:05 PM

Previous topic - Next topic

Sorc.Polgara

Ok, 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

topaz

Have you tried just telling the server to download the torrent, rewrite the extension, and send it on to you?
RLY...?

Sorc.Polgara

@Topaz yup, tried that.


I've figured out how to do what I need, w/o having to do step 1.

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;
}

SecretShop

id recommend, downloading, compressing, and printing all in one swoop instead of trying to save the file.  I beleve gzip format can compress a stream.

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.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

SecretShop

Quote from: J on March 30, 2006, 09:58 AM
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.

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.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Sorc.Polgara

No, they are only checking for .torrent.  I am able to put the .torrent file in a .gz and download the file.

topaz

Quote from: Sorc.Polgara on April 03, 2006, 07:27 PM
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?
RLY...?

Ersan

#9
You don't need to do all that, the traffic shaper is probably just checking for the mime type header and file extension, rewrite it.

Arta

My $0.02: An easier approach might be to base64 encode it. Less dependencies, simpler code and less resource-intensive.

Ersan

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.

warz

Quote from: Ersan on March 26, 2007, 06:46 AM
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.

Ersan

#13
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...

warz

#14
Quote from: Ersan on March 30, 2007, 02:48 PM
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.