Revision history for SmaugDragon


Revision [18919]

Last edited on 2008-01-28 00:13:20 by SmaugDragon [Modified links pointing to docs server]

No Differences

Revision [14950]

Edited on 2006-07-23 01:15:23 by SmaugDragon [Modified links pointing to docs server]
Additions:
{{acls}}
Deletions:


Revision [14949]

Edited on 2006-07-22 11:43:08 by SmaugDragon [Modified links pointing to docs server]
Deletions:
{{filelist}}


Revision [14948]

Edited on 2006-07-22 11:42:53 by SmaugDragon [Modified links pointing to docs server]
Additions:



Revision [14947]

Edited on 2006-07-22 11:42:24 by SmaugDragon [Modified links pointing to docs server]
Additions:
{{filelist}}
Deletions:
{{FileList}}


Revision [14946]

Edited on 2006-07-22 11:40:53 by SmaugDragon [Modified links pointing to docs server]
Additions:
{{FileList}}
Deletions:


Revision [14945]

Edited on 2006-07-22 11:32:50 by SmaugDragon [Modified links pointing to docs server]
Additions:
{{lastedit}}
Deletions:
{{files}}


Revision [14944]

Edited on 2006-07-22 11:32:20 by SmaugDragon [Modified links pointing to docs server]
Additions:
CategoryUsers


Revision [14920]

Edited on 2006-07-20 14:32:11 by SmaugDragon [Modified links pointing to docs server]
Additions:
See my Action script FileView
{{files}}
Deletions:
fileview.php action:
The only variable is "location" set to the location of the directory you want to show files from.
save as ##actions/fileview.php##
examples:
""{{fileview location="uploads/*.*"}} will show all files in uploads directory ""
"" {{fileview location="uploads/*.zip}} will show only zip files in uploads directory ""
"" {{fileview location="uploads/pic???.jpg}} will show only jpg files with names like pic000.jpg pic001.jpg etc ""
Additionally you can set $md5checksum on or off in the fileview.php file to have md5checksums generated on the fly [off by default].
(Not recomended for large directories or files tested on FreeBSD, Apache Server. I don't know what windows would do ##leave comment##)
Please comment if you find this action helpful It is my first "published" code and I would love to hear back from the community
KNOWN BUG: file names with spaces ie. "This windows file.zip" will not link correctly.
%%(php)
<style type="text/css">
table {border:1px solid #000; border-collapse:collapse; font-family:arial,courier,sans-serif; font-size:90%; }
td,th{border:0px solid #000; border-collapse:collapse; padding:5px; }
thead th{text-align:center; background:#9cf; }
tbody th{text-align:center; background:#69c; }
tbody td{text-align:right; background:#DDDDDD; }
#ic{width: 0px;}
#nm{width: 80px; text-align: left; nowrap;}
#sz{width: 80px; text-align: right; nowrap;}
#mf{width: 80px; text-align: right; nowrap;}
#cd{width:120px; text-align:right; font-family:courier; nowrap;}
</style>
<?php
if (!$location) { $location = "uploads/*.*"; } /* if location is not specified show all files in uploads */
$md5checksum_on = 0; /* calculate md5 checksums (1 = yes | 0 = no) */
/* Taken from WikkaWakka actions files.php */
if (! function_exists('bytesToHumanReadableUsage')) {
function bytesToHumanReadableUsage($bytes, $precision = 2, $names = '')
{
if (!is_numeric($bytes) || $bytes < 0) {
return false;
}
for ($level = 0; $bytes >= 1024; $level++) { $bytes /= 1024; }
switch ($level)
{
case 0: $suffix = (isset($names[0])) ? $names[0] : 'Bytes'; break;
case 1: $suffix = (isset($names[1])) ? $names[1] : 'KB'; break;
case 2: $suffix = (isset($names[2])) ? $names[2] : 'MB'; break;
case 3: $suffix = (isset($names[3])) ? $names[3] : 'GB'; break;
case 4: $suffix = (isset($names[4])) ? $names[4] : 'TB'; break;
default: $suffix = (isset($names[$level])) ? $names[$level] : ''; break;
}
if (empty($suffix)) { trigger_error('Unable to find suffix for case ' . $level);
return false;
} return round($bytes, $precision) . ' ' . $suffix;
}
}
/* End of borrowed Code */
echo "<table summary=\"This table lists the files ".$location."\">\n";
echo "<tr><th scope=\"col\"> </th><th scope=\"col\">File</th><th scope=\"col\">Size</th><th scope=\"col\">Modified</th>";
if ($md5checksum_on == 1) echo "<th scope=\"col\">md5 Checksum</th></tr>\n"; else echo "</tr>\n";
foreach (glob($location) as $filename) {
echo "<td id=\"ic\"></td>";
echo "<td id=\"nm\"><a href=".$filename.">$filename</a>";
echo "<td id=\"sz\">".bytesToHumanReadableUsage(filesize($filename))."</td>";
echo "<td id=\"mf\">".date ("m/d/Y", filemtime($filename))."</td>";
if ($md5checksum_on == 1) echo "<td id=\"cd\">".md5_file($filename)."</td>";
echo "</tr>\n";
}
echo "</table>";
?>
%%
----CategoryUserContributions


Revision [14919]

Edited on 2006-07-20 13:09:27 by SmaugDragon [Modified links pointing to docs server]
Deletions:
FileView


Revision [14917]

Edited on 2006-07-20 13:09:06 by SmaugDragon [Modified links pointing to docs server]
Additions:
FileView


Revision [14916]

Edited on 2006-07-20 13:06:12 by SmaugDragon [Modified links pointing to docs server]
Additions:
(Not recomended for large directories or files tested on FreeBSD, Apache Server. I don't know what windows would do ##leave comment##)
Deletions:
(Not recomended for large directories or files)


Revision [14915]

Edited on 2006-07-20 13:03:56 by SmaugDragon [Modified links pointing to docs server]
Additions:
$md5checksum_on = 0; /* calculate md5 checksums (1 = yes | 0 = no) */
Deletions:
$md5checksum_on = 1; /* calculate md5 checksums (1 = yes | 0 = no) */


Revision [14914]

Edited on 2006-07-20 13:01:19 by SmaugDragon [Modified links pointing to docs server]
Additions:
%%(php)
Deletions:
%%(php;1;fileview.php;)


Revision [14913]

Edited on 2006-07-20 13:00:52 by SmaugDragon [Modified links pointing to docs server]
Additions:
%%(php;1;fileview.php;)
Deletions:
%%(php;fileview.php)


Revision [14912]

Edited on 2006-07-20 12:59:56 by SmaugDragon [Modified links pointing to docs server]
Additions:
%%(php;fileview.php)
Deletions:
%%(php;1;fileview.php)


Revision [14911]

Edited on 2006-07-20 12:59:16 by SmaugDragon [Modified links pointing to docs server]
Additions:
----CategoryUserContributions


Revision [14910]

Edited on 2006-07-20 12:58:16 by SmaugDragon [Modified links pointing to docs server]
Additions:
fileview.php action:
The only variable is "location" set to the location of the directory you want to show files from.
save as ##actions/fileview.php##
%%(php;1;fileview.php)
Deletions:
My fileview action script the only variable is "location" set to the location of the directory you want to show files from.
%%(php;1)


Revision [14908]

Edited on 2006-07-20 12:53:47 by SmaugDragon [Modified links pointing to docs server]
Additions:
Please comment if you find this action helpful It is my first "published" code and I would love to hear back from the community
KNOWN BUG: file names with spaces ie. "This windows file.zip" will not link correctly.


Revision [14907]

Edited on 2006-07-20 12:50:50 by SmaugDragon [Modified links pointing to docs server]
Additions:
%%(php;1)
Deletions:
%% (php)


Revision [14906]

Edited on 2006-07-20 12:50:20 by SmaugDragon [Modified links pointing to docs server]
Additions:
%% (php)


Revision [14905]

Edited on 2006-07-20 12:49:27 by SmaugDragon [Modified links pointing to docs server]
Additions:
""{{fileview location="uploads/*.*"}} will show all files in uploads directory ""
"" {{fileview location="uploads/*.zip}} will show only zip files in uploads directory ""
"" {{fileview location="uploads/pic???.jpg}} will show only jpg files with names like pic000.jpg pic001.jpg etc ""
Deletions:
%% {{fileview location="uploads/*.*"}} will show all files in uploads directory %%
%% {{fileview location="uploads/*.zip}} will show only zip files in uploads directory %%
%% {{fileview location="uploads/pic???.jpg}} will show only jpg files with names like pic000.jpg pic001.jpg etc %%


Revision [14904]

Edited on 2006-07-20 12:48:47 by SmaugDragon [Modified links pointing to docs server]
Additions:
%%
<style type="text/css">
table {border:1px solid #000; border-collapse:collapse; font-family:arial,courier,sans-serif; font-size:90%; }
td,th{border:0px solid #000; border-collapse:collapse; padding:5px; }
thead th{text-align:center; background:#9cf; }
tbody th{text-align:center; background:#69c; }
tbody td{text-align:right; background:#DDDDDD; }
#ic{width: 0px;}
#nm{width: 80px; text-align: left; nowrap;}
#sz{width: 80px; text-align: right; nowrap;}
#mf{width: 80px; text-align: right; nowrap;}
#cd{width:120px; text-align:right; font-family:courier; nowrap;}
</style>
<?php
if (!$location) { $location = "uploads/*.*"; } /* if location is not specified show all files in uploads */
$md5checksum_on = 1; /* calculate md5 checksums (1 = yes | 0 = no) */
/* Taken from WikkaWakka actions files.php */
if (! function_exists('bytesToHumanReadableUsage')) {
function bytesToHumanReadableUsage($bytes, $precision = 2, $names = '')
{
if (!is_numeric($bytes) || $bytes < 0) {
return false;
}
for ($level = 0; $bytes >= 1024; $level++) { $bytes /= 1024; }
switch ($level)
{
case 0: $suffix = (isset($names[0])) ? $names[0] : 'Bytes'; break;
case 1: $suffix = (isset($names[1])) ? $names[1] : 'KB'; break;
case 2: $suffix = (isset($names[2])) ? $names[2] : 'MB'; break;
case 3: $suffix = (isset($names[3])) ? $names[3] : 'GB'; break;
case 4: $suffix = (isset($names[4])) ? $names[4] : 'TB'; break;
default: $suffix = (isset($names[$level])) ? $names[$level] : ''; break;
}
if (empty($suffix)) { trigger_error('Unable to find suffix for case ' . $level);
return false;
} return round($bytes, $precision) . ' ' . $suffix;
}
}
/* End of borrowed Code */
echo "<table summary=\"This table lists the files ".$location."\">\n";
echo "<tr><th scope=\"col\"> </th><th scope=\"col\">File</th><th scope=\"col\">Size</th><th scope=\"col\">Modified</th>";
if ($md5checksum_on == 1) echo "<th scope=\"col\">md5 Checksum</th></tr>\n"; else echo "</tr>\n";
foreach (glob($location) as $filename) {
echo "<td id=\"ic\"></td>";
echo "<td id=\"nm\"><a href=".$filename.">$filename</a>";
echo "<td id=\"sz\">".bytesToHumanReadableUsage(filesize($filename))."</td>";
echo "<td id=\"mf\">".date ("m/d/Y", filemtime($filename))."</td>";
if ($md5checksum_on == 1) echo "<td id=\"cd\">".md5_file($filename)."</td>";
echo "</tr>\n";
}
echo "</table>";
?>
%%
Deletions:
{{ fileview location="uploads/*.*"}}


Revision [14903]

The oldest known version of this page was created on 2006-07-20 12:48:05 by SmaugDragon [Modified links pointing to docs server]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki