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

+  TorrentFlux Forums
|-+  Code Hacks and Tools
| |-+  TorrentFlux 2.1 Hacks
| | |-+  Some Stats dir hack
« previous next »
Pages: [1] Go Down Print
Author Topic: Some Stats dir hack  (Read 2546 times)
deags
Full Member
***
Offline Offline

Posts: 121



View Profile
« on: 04-13-2006, 10:23:43 »

okay i am tryign to move most of the crap i had on my other tf to hte new on Smiley

i got alot of em off the old forums tho.... so i can't credit hte author as it is not in hte google cache Smiley

This is not my work!            i think it is coldfire's
if this is your work and you have a problem all you need ot do is aks me and i will delete this or credit you what ever you wishes are Smiley

in your languge add this to your languge file in my case language/lang-english.php

just add it anywhere basically Smiley

Code:
define('_TDDU','Directory Size:');

in dir.php find

Code:
                }
            }
        }
    }
    closedir($handle);
    echo "</table>";
}

and replace with

Code:
                }
            }
        }
    }
    closedir($handle);
$cmd = "du -ch ".$dirName." | grep \"total\"";
$du = shell_exec($cmd);
echo "</table>";
echo "<table cellpadding=0 width=740>";
$du2 = substr($du, 0, -7);
echo "<tr bgcolor=#ececec>";
echo "<td align=\"center\">"._TDDU." ".$du2."B</td></tr>";
    echo "</table>";
}

now after

Code:
            if (@is_dir($dirName.$entry))
            {
                echo "<tr bgcolor=\"".$bg."\"><td><a href=\"dir.php?dir=".urlencode($dir.$entry)."\"><img src=\"images/folder2.gif\" width=\"16\" height=\"16\" title=\"".$entry."\" border=\"0\" align=\"absmiddle\">".$entry."</a></td>";
add this

Code:
$dudir = shell_exec ("/usr/bin/du -sk -h ".correctFileName ($dirName.$entry));
$dusize = explode ("\t", $dudir);
$arStat = @lstat($dirName.$entry);
$timeStamp = $arStat[10];
echo "<td align=\"right\">".$dusize[0]."B</td>";

echo "<td width=140>".date("m-d-Y h:i a", $timeStamp)."</td>";
echo "<td align=\"right\">";

now delete this(should be underneath)

Code:
                echo "<td>&nbsp;</td>";
                echo "<td>&nbsp;</td>";
                echo "<td align=\"right\">";

now find
Code:
                echo "<td>".date("m-d-Y g:i a", $timeStamp)."</td>";
and replace with

Code:
                echo "<td width=140>".date("m-d-Y h:i a", $timeStamp)."</td>";

in functions.php

add this

Code:
//*************************************************************************
// correctFileName()
// Adds backslashes above special characters to obtain attainable directory
// names for disk usage
function correctFileName ($inName)
{
       $replaceItems = array("'", ",", "#", "%", "!", "+", ":", "/", " ", "@", "$", "&", "?", "\"", "(", ")");
       $replacedItems = array("\'", "\,", "\#", "\%", "\!", "\+", "\:", "\/", "\ ", "\@", "\$", "\&", "\?", "\\\"", "\(", "\)");
       $cleanName = str_replace($replaceItems, $replacedItems, $inName);
       return $cleanName;
}

if you canot work out where i just put mine below

Code:
//*********************************************************
// avddelete()
function avddelete($file)
{
    chmod($file,0777);
    if (@is_dir($file))
    {
        $handle = @opendir($file);
        while($filename = readdir($handle))
        {
            if ($filename != "." && $filename != "..")
            {
                avddelete($file."/".$filename);
            }
        }
        closedir($handle);
        @rmdir($file);
    }
    else
    {
        @unlink($file);
    }
}


that is all that needs to be done.... i think Wink
« Last Edit: 04-19-2006, 08:06:00 by deags » Logged
gringo
Full Member
***
Offline Offline

TF Base: Linux 1.x
Posts: 111





View Profile WWW
« Reply #1 on: 04-13-2006, 12:34:12 »

What exactly does this do?  Show the space used in each directory?
Logged

P4 2.8 | CentOS-4.2 | 1024MB RAM | 10 mb/s Connect

Apache 2.0.52 | PHP 4.3.9 | MySQL 4.1.12 | Python 2.3.4

TF 2.1b4rt with cosmetic changes.
deags
Full Member
***
Offline Offline

Posts: 121



View Profile
« Reply #2 on: 04-13-2006, 19:15:32 »

show directory info such as size and time created.... like the files have Smiley

« Last Edit: 04-13-2006, 19:19:53 by deags » Logged
ssj4gogeta
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 18





View Profile WWW
« Reply #3 on: 04-14-2006, 05:50:16 »

Here is the cache version of the original code by coldfire http://72.14.203.104/search?q=cache:9Ue1UpgjnaIJ:www.torrentflux.com/forum/index.php%3Fshowtopic%3D870+&hl=en&gl=uk&ct=clnk&cd=1 also included on that page is my mod to use the total dir usage of the dir you are viewing. I will addapt it to 2.1 if anyone wants it or someone else can do it.
Logged
gringo
Full Member
***
Offline Offline

TF Base: Linux 1.x
Posts: 111





View Profile WWW
« Reply #4 on: 04-14-2006, 08:54:03 »

oh, ok,  thanks!  looks like a nice hack, i'll probably install it soon.
Logged

P4 2.8 | CentOS-4.2 | 1024MB RAM | 10 mb/s Connect

Apache 2.0.52 | PHP 4.3.9 | MySQL 4.1.12 | Python 2.3.4

TF 2.1b4rt with cosmetic changes.
gringo
Full Member
***
Offline Offline

TF Base: Linux 1.x
Posts: 111





View Profile WWW
« Reply #5 on: 04-14-2006, 22:47:08 »

OK, I installed this and it made my directory view look funny, so I started from the original dir.php and did it again...but with the same results =/

I attached a screenshot of my borked dir.php.

Any suggestions?
Logged

P4 2.8 | CentOS-4.2 | 1024MB RAM | 10 mb/s Connect

Apache 2.0.52 | PHP 4.3.9 | MySQL 4.1.12 | Python 2.3.4

TF 2.1b4rt with cosmetic changes.
deags
Full Member
***
Offline Offline

Posts: 121



View Profile
« Reply #6 on: 04-14-2006, 23:29:24 »

ah yeh one sec i see the prob Smiley


here is what i for got to tell you to do....
Quote from: deags
now delete this(should be underneath)

Code:
                echo "<td>&nbsp;</td>";
                echo "<td>&nbsp;</td>";
                echo "<td align=\"right\">";
« Last Edit: 04-14-2006, 23:33:26 by deags » Logged
gringo
Full Member
***
Offline Offline

TF Base: Linux 1.x
Posts: 111





View Profile WWW
« Reply #7 on: 04-14-2006, 23:43:03 »

doh!  can't believe I didn't catch that.  Thanks for the great hack!
Logged

P4 2.8 | CentOS-4.2 | 1024MB RAM | 10 mb/s Connect

Apache 2.0.52 | PHP 4.3.9 | MySQL 4.1.12 | Python 2.3.4

TF 2.1b4rt with cosmetic changes.
lysip
Jr. Member
**
Offline Offline

Posts: 53




View Profile
« Reply #8 on: 04-15-2006, 02:16:39 »

Very nice i wonder why this isnt incorperated into tflux atm, excessive disk usage i sapose, considering every time you view a dir it has to enter a bunch of directorys, but anyway.
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
mb.Tab
Hero Member
*****
Offline Offline

TF Base: Linux 2.x
Posts: 574


Gotta love my Avatar !!





View Profile WWW
« Reply #9 on: 04-18-2006, 13:07:40 »

Thanks for this....working great here Smiley

mb.Tab
Logged

coldfire
Jr. Member
**
Offline Offline

Posts: 64






View Profile
« Reply #10 on: 04-19-2006, 00:12:33 »

Great, you've found my old hack, and thanks ss4gogeta for finding the google cache Smiley
Logged

Gentoo 2005-r1, TF 2.1 final + Specific Save Path, Multi-Upload and Page Refresh Countdown Timer hacks, 120GB dedicated to TF
Pages: [1] 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