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:
<script language="JavaScript">
function ConfirmDelete(file)
{
return confirm("<?php echo _ABOUTTODELETE ?>: " + file);
}
Directly under it add this:
<!-- 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:
echo "<td align=\"right\">";
Directly under it add this:
// 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:
$Command = "unrar x " . escapeshellarg($arg1) . " " . escapeshellarg($arg2);
And makeing it look like this:
$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.