TorrentFlux.com Welcome, Guest. Please login or register.
02-09-2010, 06:07:38
Home Help Search Login Register donate
TorrentFlux Home | TorrentFlux Hosting

+  TorrentFlux Forums
|-+  Code Hacks and Tools
| |-+  TorrentFlux 2.0 Hacks
| | |-+  Robust UnRAR/UnZip hack
« previous next »
Pages: [1] 2  All Go Down Print
Author Topic: Robust UnRAR/UnZip hack  (Read 16989 times)
lysip
Jr. Member
**
Offline Offline

Posts: 53




View Profile
« on: 01-27-2006, 21:29:13 »

As the Topic says, this hack will place a unrar or unzip icon next the the aproprate file to unrar/unzip the file to the current dir.  This is mostly useful if you dont want to have to download a million rar files or one big tar/zip file to your pc then extract it twice.

First of you must have php with cli built into it. try doing a php -v from a shell. if you see something you have php command interprater installed.

Second have unrar installed and in your path. *BSD users should use rarBSD*

Add these images to your images dir of torrentflux and add the files to the main dir of torrentflux.

In dir.php find this:
Code:
<script language="JavaScript">
function ConfirmDelete(file)
{
return confirm("<?php echo _ABOUTTODELETE ?>: " + file);
}
Directly under it add this:
Code:
<!-- R.D. -->
function UncompDetails(URL)
{
  window.open (URL,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=600,height=300');
}

Next find the second instance of this in dir.php:
Code:
echo "<td align=\"right\">";
Directly under it add this:
Code:
// R.D. - Display links for unzip/unrar
//**************************************************************************************************************

if(IsAdmin($cfg["user"]) || preg_match("/^" . $cfg["user"] . "/",$dir))
{
if ((strpos($entry, '.rar') !== FALSE AND strpos($entry, '.Part') === FALSE) OR (strpos($entry, '.part01.rar') !== FALSE ) OR (strpos($entry, '.part1.rar') !== FALSE )) {
echo "<a href=\"javascript:UncompDetails('uncomp.php?file=".urlencode($dir.$entry)."&dir=".urlencode($dir)."&type=rar')\"><img src=\"images/rar_enabled.gif\" width=16 height=16 title=\"Unrar\" border=0></a>";
}
if (strpos($dir.$entry, '.zip') !== FALSE) {
echo "<a href=\"javascript:UncompDetails('uncomp.php?file=".urlencode($dir.$entry)."&dir=".urlencode($dir)."&type=zip')\"><img src=\"images/zip.png\" width=16 height=16 title=\"Unzip\" border=0></a>";
}
}
//**************************************************************************************************************


For those who dont want to add unrar to there path: open uncompress.php and finding this:
Code:
$Command = "unrar x " . escapeshellarg($arg1) . " " . escapeshellarg($arg2);
And makeing it look like this:
Code:
$Command = "<path to unrar with / at end>unrar x " . escapeshellarg($arg1) . " " . escapeshellarg($arg2);

Best Wishes,
lysip

*EDIT* Forgot to say more about it... You can close the window while it is unrar'ing/zip'ing. If you do that you can tell weather or not its done by looking in the dir, and if there is a file called error.log its eather not done or finished with errors... all you have to do is open it up and check for the All Ok at the very end.
« Last Edit: 01-27-2006, 22:53:05 by lysip » Logged

CentOS 4.2 (kernel: 2.6.9-22.ELsmp)
TorrentFlux version - 2.1
Python version - 2.4.1
PHP Version - 4.3.9
Webserver software and version - Apache 2.0
Add-ons/Hacks - rememberme, multiup
kaix
Newbie
*
Offline Offline

Posts: 3



View Profile
« Reply #1 on: 01-27-2006, 22:46:49 »

Sweet, thanks!
Logged
ridewitme
Newbie
*
Offline Offline

Posts: 27


God of English





View Profile
« Reply #2 on: 01-28-2006, 00:30:41 »

Direct link to all the downloads of Unrar and variations:

http://www.rarlab.com/rar/

Direct link to RarBSD (for BSD users)

http://files4.rarlab.com/rar/rarbsd-3.5.1.tar.gz
Logged
IhatemyISP
Forum Code Monkey
Hero Member
*****
Offline Offline

TF Base: Linux 2.x
Posts: 841






View Profile WWW
« Reply #3 on: 01-28-2006, 01:31:40 »

Nicely done.

I see you're using the XMLOut hack I made...did you ever do anything with it?
Logged

Pentium III 667mhz | 155GB RAID 0 | 256MB RAM | Redhat 7.3 - 2.4.18-3 | Python 2.4.1 | PHP 5.1.4 (cgi-fcgi) | Lighttpd 1.4.11
lysip
Jr. Member
**
Offline Offline

Posts: 53




View Profile
« Reply #4 on: 01-28-2006, 11:46:12 »

no currently, but im eventually gona use it to create a firefox extension that will feed info back to you with out have to login and such. Thats gona be down the road, as ive never writtten a firefox extension before, i picture a sort of rss feed bar.
« Last Edit: 01-28-2006, 11:51:12 by lysip » Logged

CentOS 4.2 (kernel: 2.6.9-22.ELsmp)
TorrentFlux version - 2.1
Python version - 2.4.1
PHP Version - 4.3.9
Webserver software and version - Apache 2.0
Add-ons/Hacks - rememberme, multiup
staulkor
Newbie
*
Offline Offline

Posts: 11



View Profile
« Reply #5 on: 01-29-2006, 04:32:54 »

nice. you should make it so you can tell it a directory to create for each rar/zip you decompress...like a text box asking what should the filename be.
Logged
mb.Tab
Hero Member
*****
Offline Offline

TF Base: Linux 2.x
Posts: 574


Gotta love my Avatar !!





View Profile WWW
« Reply #6 on: 01-29-2006, 08:49:11 »

Thanks for the hack, its working nicely so far.....Smiley...

mb.Tab
Logged

pixluser
Newbie
*
Offline Offline

Posts: 34



View Profile
« Reply #7 on: 02-27-2006, 22:05:52 »

hi, i just got a pb,
when i click the icon,
a popup appear, with the login box, when i close those windows, and refresh the files page, it ask me to log in again,
and when i enter login in the popup, i've got another MAIN windows but no files extracted.

i've got the php cli

php -v work,
and  i use unrarbsd

(nothing particular in http-error and var/log/messages

SOLVED : i'm on freebsd, and i've modifyed the config.php path to my /usr/local/etc/tfconfig.php path (or something like that)
« Last Edit: 03-04-2006, 08:54:31 by pixluser » Logged
ghostcorps
Newbie
*
Offline Offline

TF Base: Linux 1.x
Posts: 32



View Profile
« Reply #8 on: 03-25-2006, 09:22:34 »

Hi

 Im on FreeBSD also, I already had unrar installed. So I  just dropped everything in and it all works except the "uncompressing file" window shows no progress, and indeed there is no new folder.

 Can you please suggest a possible reaosn for this??

Thanks

=^_^=
Logged

FreeBSD 6.0
---------------
apache-1.3.33_2
php4-4.4.0
mysql-server-4.1.20
python-2.4.3
torrentflux-2.1-b4rt-91
ridewitme
Newbie
*
Offline Offline

Posts: 27


God of English





View Profile
« Reply #9 on: 03-25-2006, 14:44:52 »

Check the error.log file, should indicate whether it's a missing file or permissions error. If you get 'no such file or directory' when you clearly specify the path to unrar, then you haven't installed it properly.




Andrew.
Logged
ghostcorps
Newbie
*
Offline Offline

TF Base: Linux 1.x
Posts: 32



View Profile
« Reply #10 on: 03-25-2006, 21:55:25 »

thanks ridewitme

 When you say the error.log, are you reffering to the log that should be 'in the dir' as mentioned at the end of lysips opening post? there are none Sad

 And find . | grep error.log  from /  just gives me my httpd-error.log.

 Perhaps im just being dumb, but when was I supposed to specify the path? My understanding was that it just unrared to the dir where the*.rar/zip is?


Thanks again

=^_^=
Logged

FreeBSD 6.0
---------------
apache-1.3.33_2
php4-4.4.0
mysql-server-4.1.20
python-2.4.3
torrentflux-2.1-b4rt-91
ridewitme
Newbie
*
Offline Offline

Posts: 27


God of English





View Profile
« Reply #11 on: 03-26-2006, 00:40:32 »

Yes, I am referring to the error.log that should create in the directory. You have to specify where unrar is installed to in uncompress.php.
Logged
ghostcorps
Newbie
*
Offline Offline

TF Base: Linux 1.x
Posts: 32



View Profile
« Reply #12 on: 03-26-2006, 02:55:23 »

Ah haa..

 thanks...  If it helps, i feel really dumb.

=^_^=
Logged

FreeBSD 6.0
---------------
apache-1.3.33_2
php4-4.4.0
mysql-server-4.1.20
python-2.4.3
torrentflux-2.1-b4rt-91
ridewitme
Newbie
*
Offline Offline

Posts: 27


God of English





View Profile
« Reply #13 on: 04-08-2006, 05:26:07 »

Possible version for 2.1 Final? Smiley
Logged
Paczesiowa
Full Member
***
Offline Offline

TF Base: Linux 2.x
Posts: 177



View Profile
« Reply #14 on: 04-08-2006, 19:22:58 »

it's working for TF 2.1
rar files are uncompressed with no problem
zip files are uncompressed but window says "uncompressing" forever and there is error.log with "(...) inflanting (...)" but who cares, there are no torrents with zipped files.
Logged

Pages: [1] 2  All Go Up Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by SMF 1.1.1 | SMF © 2006, Simple Machines LLC Powered by PHP