Seite 1 von 2

Attachment Mod Version 2.3.9 komplette Dateigrösse auf index

Verfasst: 13.07.2004 21:20
von Berndte
Hallo,

habe oben genannten Mod erfolgreich und problemlos am laufen.

Ich fände es aber ganz nett, wenn ich irgendwo auf der index.php sowas wie "Der Uploadordner ist mit ***MB von ***MB gefüllt."

Es reicht schon aus, wenn dieser Satz unter "Diese Daten zeigen an, wer in den letzten 5 Minuten online war." ganz unten angezeigt wird.

Das muss doch eigentlich ganz einfach zu realisieren sein, da ja die Werte schon im ACP vorhanden sind.

Optional auch ein Balkendiagramm wie auch schon im Profil.

Gruss Bernd

Verfasst: 16.07.2004 17:28
von Berndte
und nochmal nach oben schubs.... hat denn echt keiner ne Idee???

Verfasst: 17.07.2004 00:20
von Elvis

Verfasst: 17.07.2004 09:44
von Berndte
hmm, auch nicht so direkt, was ich suche,

vielleicht hat ein modder mal Zeit sich dem anzunehmen, wäre auch ein gutes Feature find ich

Verfasst: 17.07.2004 11:11
von Leuchte
Nicht unbedingt das sauberste, sollte aber funktionieren:
functions.php
Suche

Code: Alles auswählen

//
// Get Userdata, $user can be username or user_id. If force_str is true, the username will be forced.
//
Füge davor ein

Code: Alles auswählen

function get_dir_size($dir, $size = 0) { 
    $handle = opendir($dir); 

    while ($file = readdir($handle)) { 
        if ($file == '.' || $file == '..') continue; 

        $full_path = $dir.$file; 

        if (is_dir($full_path)) { 
            $size = get_dir_size($full_path.'/', $size); 
        } else { 
            $size += round(filesize($full_path)  / 1048576 * 100) / 100; 
        } 
    } 

    closedir($handle); 

    return $size; 

}
index.php
Suche

Code: Alles auswählen

//
// Start output of page
//
Füge davor ein

Code: Alles auswählen

$path = "./UPLOADORDNER/"; // anpassen
$size = get_dir_size($path);
Suche

Code: Alles auswählen

'FORUM_LOCKED_IMG' => $images['forum_locked'],
Füge danach ein

Code: Alles auswählen

'L_DIR_SIZE' => $size,
templates/xxx/index_body.tpl
Suche

Code: Alles auswählen

<td align="left" valign="top"><span class="gensmall">{L_ONLINE_EXPLAIN}</span></td>
</tr>
Füge danach ein

Code: Alles auswählen

<tr>
	<td align="left" valign="top"><span class="gensmall">Der Uploadordner ist mit {L_DIR_SIZE} MB gefüllt</span></td>
</tr>

Verfasst: 17.07.2004 11:51
von Berndte
Danke dir... funktioniert einwandfrei!

ich habe die Anzeige mit in das Fenster eingebaut... auch kein Problem

Demo: www.opel4x4.de und dann ins Forum ;) und runterscrollen

Verfasst: 17.07.2004 13:02
von Berndte
wollte das soeben erweitern um auch die grösse des Avatarordners anzeigen zu lassen:

funktions.php

Code: Alles auswählen

function get_dir_size($dir, $avatarsize = 0) { 
    $handle = opendir($dir); 

    while ($file = readdir($handle)) { 
        if ($file == '.' || $file == '..') continue; 

        $full_path = $dir.$file; 

        if (is_dir($full_path)) { 
            $avatarsize = dir_size($full_path.'/', $avatarsize); 
        } else { 
            $avatarsize += round(filesize($full_path)  / 1048576 * 100) / 100; 
        } 
    } 

    closedir($handle); 

    return $avatarsize; 

}

function get_dir_size($dir, $uploadsize = 0) { 
    $handle = opendir($dir); 

    while ($file = readdir($handle)) { 
        if ($file == '.' || $file == '..') continue; 

        $full_path = $dir.$file; 

        if (is_dir($full_path)) { 
            $uploadsize = dir_size($full_path.'/', $uploadsize); 
        } else { 
            $uploadsize += round(filesize($full_path)  / 1048576 * 100) / 100; 
        } 
    } 

    closedir($handle); 

    return $uploadsize; 

}
index.php

Code: Alles auswählen

$uploadsize = get_dir_size("./files/");
$avatarsize = get_dir_size("./images/avatars/gallery/");
wo ist der Denkfehler? Bin ein absoluter PHP Neuling und verfahre nach lerning-by-doing

Verfasst: 17.07.2004 13:36
von Leuchte
Die Funktion darf nicht immer den selben Namen haben ;)
function get_dir_size
und
$avatarsize = get_dir_size($full_path.'/', $avatarsize);
Diese Werte jeweils anpassen.

Verfasst: 17.07.2004 14:13
von Berndte
Funktioniert!

Auch auf die Gefahr hin, dass ich nerve, kann man auch die Anzahl an Dateien im Ordner anzeigen lassen?

Verfasst: 17.07.2004 14:32
von Leuchte
includes/functions.php
Finde

Code: Alles auswählen

//
// Get Userdata, $user can be username or user_id. If force_str is true, the username will be forced.
//
Füge davor ein

Code: Alles auswählen

function count_files($dir) 
    { 
    if(is_dir($dir)) 
      { 
      $count_files[file] = 0; 

      chdir($dir); 
      $handle = opendir("."); 
      while($file = readdir($handle)) 
        { 
        if(is_dir($file) && $file != "." && $file != "..") 
          { 
           $count_files[file] += $y[file]; 
          }  
        if(is_file($file)) 
            { 
          $count_files[file]++; 
            } 
          } 

    if(stristr($dir,"../")) chdir($_SERVER["DOCUMENT_ROOT"].substr($_SERVER["PATH_INFO"],0,strrpos($_SERVER["PATH_INFO"],"/"))); 
      elseif($dir != ".") chdir("../"); 

      closedir($handle); 
      } 

    return $count_files; 
    }
index.php
Finde

Code: Alles auswählen

//
// Start output of page
//
Füge davor ein

Code: Alles auswählen

$count_files = count_files($path);
(Setzt die Änderung von vorhin voraus, da $path dort bereits bestimmt ist.)
Finde

Code: Alles auswählen

$template->assign_vars(array(
Füge danach ein

Code: Alles auswählen

'L_COUNT_FILES' => $count_files[file],
Im Template selbst (index_body.tpl) zeigt {L_COUNT_FILES} die Dateien an (bspw. Im Ordner befinden sich {L_COUNT_FILES} Dateien.)