Verfasst: Di 27. Jun 2006, 15:19
das mit der Vorbelegung habe ich bisher noch nicht lösen können, das ist aber nicht das Problem...
Das Diskussionsforum zum Open Source Content Management System
https://forum.contenido.org/
Code: Alles auswählen
<?
$buttonstyle1 = "width:250px;height:20px;"; // Button 1
$buttonstyle2 = "width:100px;height:20px;margin-left:10px;"; // Button 2
$headcolor = "background-color:#eeeeee;padding:2px;"; // Tabellenkopf
$username="";
$adminname="";
function cut($text, $length) {
$dec = array("\"", "'", "\\", '\"', "\'", "<", ">");
$enc = array(""", "'", "\", """, "'", "<", ">");
$text = str_replace($enc, $dec, $text);
if (strlen($text) > $length) {
$text = substr($text, 0, ($length-3))."...";
}
$text = str_replace($dec, $enc, $text);
return $text;
}
$path="upload/CMS_VALUE[4]";
$username=$auth->auth['uname'];
$delpool="CMS_VALUE[5]";
$treffer_del = substr_count($delpool, $username);
if ($treffer_del==1) {
$deluser=$username;
}
$adminpool="CMS_VALUE[1]";
$treffer_admin = substr_count($adminpool, $username);
if ($treffer_admin==1) {
$adminname=$username;
}
if ($username==$adminname) {
$max_filesize_mb=CMS_VALUE[3];
} else {
$max_filesize_mb=CMS_VALUE[2];
}
$max_filesize=bcmul($max_filesize_mb,1000000);
function parseByteSize($size,$digits=2,$dir=false){
$kb=1024; $mb=1024*$kb; $gb=1024*$mb; $tb=1024*$gb;
if(($size==0)&&($dir)){return "Empty";}
else if($size<$kb){return $size." Bytes";}
else if($size<$mb){return round($size/$kb,$digits)." KB";}
else if($size<$gb){return round($size/$mb,$digits)." MB";}
else if($size<$tb){return round($size/$gb,$digits)." GB";}
else{return round($size/$tb,$digits)." TB";}
}
if ($step=="delete" && $username=="$adminname") {
unlink($path.$filename);
}
if (isset($_POST['uploadfile']))
{
if ($kdnr=="")
{
echo "<font color=red><b>Bitte geben Sie Ihre Kundennummer an.</b></font><br>";
}
else
{
$fileext = $_FILES['myfile']['type'];
$filename = $_FILES['myfile']['name'];
$filesize = $_FILES['myfile']['size'];
$filetemp = $_FILES['myfile']['tmp_name'];
if ($filesize > $max_filesize) {
$error = "<b>Die Datei ist mit $filesize Bytes größer als $max_filesize_mb MB.</b>";
}
if ($filename != "")
{
if ($error == "")
{
if (!file_exists($path.$kdnr."/"))
{
mkdir($path."$kdnr"."/",0777);
}
move_uploaded_file($filetemp, $path.$kdnr."/"."$filename");
chmod($path."$kdnr"."/"."$filename",0777);
echo "<font color=red><b>Die Datei wurde erfolgreich hochgeladen.</b></font><br>";
}
else
{
echo "$error";
}
}
else
{
echo "<font color=red><b>Bitte wählen Sie die hochzuladende Datei aus.</b></font><br>";
}
}
}
if (CMS_VALUE[8]==1 || ($username!="" && $username!="nobody")) {
echo "<div style=\"width:610px;\" id=\"upload\"><form name=\"uploadform\" method=\"post\" action=\"$PHP_SELF?idcat=$idcat\" enctype=\"multipart/form-data\">
<div><table>
<tr><td>Kundennummer:</td><td>Datei:</td></tr>
<tr><td><input type=\"text\" name=\"kdnr\" value=\"".$kdnr."\" style=\"width:110px;\" maxlength=5></td><td><input type=\"file\" name=\"myfile\" class=\"button\"><input type=\"submit\" name=\"uploadfile\" value=\"hochladen\" class=\"button\"></td></tr></table></div>
</form>
<div style=\"margin-bottom:5px;\"><strong>Bitte nur virengescannte Dateien hochladen!</strong></div>";
} else {
echo "<div>";
}
$show_list=CMS_VALUE[7];
if ($show_list==1 || $username==$adminname) {
$handle=opendir($path);
while ($file = readdir($handle)){
if ($file!='.' && $file!='..' && $file!='/') {
if (!@opendir($path.$file)==true) {
$file_list[] = $file;
}
}
}
closedir($handle);
@sort($file_list);
echo "<table align=\"left\" width=\"600px\" cellspacing=\"1\" border=\"1\" cellpadding=\"1\" style=\"border-collapse: collapse; background:#bbbbbb;\">
<tr style=\"$headcolor\">
<td style=\"$headcolor\">Dateiname</td>
<td style=\"$headcolor\">Größe</td>
<td style=\"$headcolor\">Aktion</td>";
if ($username==$deluser) echo "<td><span style=\"color:#ff0000;\">löschen</span></td>";
echo "</tr>";
for ($count=0;$file_list[$count]!="";$count++) {
echo "<tr style=\"background-color:#ffffff;\" onmouseover=\"this.style.backgroundColor = '#dddddd'\" onmouseout=\"this.style.backgroundColor = '#ffffff'\">
<td style=\"padding:2px;\"><font title='$file_list[$count]'>".cut($file_list[$count],CMS_VALUE[6])."</font></td>
<td style=\"padding:2px;\">".parseByteSize(@filesize($path.$file_list[$count]),2,false)."</td>
<td style=\"padding:2px;\"><a href='".$path."$file_list[$count]' target='_blank'><nobr>öffnen | speichern</nobr></a></td>";
if ($username==$deluser) {
echo "<td><a href='$PHP_SELF?idcat=$idcat&step=delete&filename=$file_list[$count]' target='_self'>löschen</a></td>";
}
echo "</tr>";
}
echo "</table></div><br clear=\"all\">";
} else {
echo "</div><br clear=\"all\">";
}
?>
Code: Alles auswählen
if (!file_exists($path.$kdnr."/"))
{
mkdir($path."$kdnr"."/",0777);
chmod($path."$kdnr"."/",0777);
}