#!F:/perl/bin/perl
use CGI;
use strict 'refs';
use lib '..';
use CGI qw(:standard);
use CGI::Carp qw/fatalsToBrowser/;
use File::Copy;
#---War mal für n Anmeldeformular
$nick = 'user';
$pass = 'user';
$ip= remote_addr;
$user{'nick'}=$nick;
$user{'pass'}=$pass;
$user{'ip'}=$ip;
#---Einstelungen---
$pfad="./../../temp/"; #lokaler pfad, wohin die datei hochgeladen wird mit / am Ende
$url="http://pcw.homeip.net/temp/"; #url zum verzeichnis, auf das $pfad zeigt mit / am ende
$script='http://pcw.homeip.net/pcw/cgi-bin/filecontrol2.cgi'; #url von sich selbst (wie $_SERVER[PHP_SELF])
$default_name = $ip;
$the_cookie = cookie(-name=>'pcwuser',
-value=>\%user,
-expires=>"+1h");
#-----------Creating a New query----------------------
#-----------Print HTML-Header-------------------------
print header(-cookie=>$the_cookie);
print '<html xmlns="http://www.w3.org/1999/xhtml" lang="de-DE">
<head>
<title>HTTP-Kontrollzentrum</title>
<link rev="made" href="mailto:pcw@pcw.homeip.net" />
<meta name="keywords" content="Upload" />
<meta name="copyright" content="pcw" />
<style media="screen" type="text/css"><!--
a:link{font-family:Tahoma,Arial;color:#ADF3FB;text-decoration:none}
a:visited{font-family:Tahoma,Arial;color:#ADF3FB;text-decoration:none}
a:hover{font-family:Tahoma,Arial;color:#ADF3FB;text-decoration:none}
a:active{font-family:Tahoma,Arial;color:#ADF3FB;text-decoration:none}
th{font-family:Tahoma,Arial;font-Size:14px;color:#ADF3FB;}
td{font-family:Tahoma,Arial;font-Size:11px;color:#ADF3FB;}
td.h{font-family:Tahoma,Arial;font-Size:14px;color:#ADF3FB;}
table {border-width:1px;
border-style:solid;
border-color:#c0dcdc;
padding:1cm;
text-align:justify; }
--></style>
</head>
<body bgcolor="#000c34" text="#619AB8">','<font face="Tahoma">';
print small(strong("Version "),$CGI::VERSION);
print "<center>",h2("HTTP-Kontrollzentrum"),
strong("Dieses Feature arbeitet erst ab Netscape 2.0, IE 4.0 oder neueren Versionen."),
p;
# Start a multipart form.
print start_multipart_form(),
"<table><tr><th colspan=\"2\">$url</th></tr><tr><td class=\"h\">Dateiname: </td>\n<td>",
textfield('savefile',$default_name,30),reset,"</td>\n</tr><tr>\n<td class=\"h\">Datei: </td>\n<td>",
filefield('filename','',30),"</td>\n</tr><tr>\n",
# "<td>Name:</td>\n",
# "<td><input name=\"nick\" value=\"\" size=\"15\"></td></tr>\n",
# "<tr><td>Passwort:</td>\n",
# "<td><input type=\"password\" name=\"pass\" value=\"\" size=\"15\"></td></tr>\n<tr>\n",
"<td colspan=\"2\" align=\"center\">",submit('submit','Hochladen'),"</td>\n</tr>\n</table>\n",
endform;
# Process the form if there is a file name entered
if (my $file = param('filename'))
{
my $tmpfile=tmpFileName($file);
$savefile = param('savefile');
$savefile=~ s/\//-/gs;
$savefile = "$pfad$savefile";
#wenn der dateiname schon existiert, wird nue numerm in klammern angehängt ;)
if(-e $savefile)
{
$n=0;
$ind=rindex($savefile,'.');
$savfile=substr($savefile,0,$ind);
$end=substr($savefile,$ind+1,length($savefile)-$ind);
while (-e "$savfile($n).$end")
{
$n++;
}
$savefile="$savfile($n).$end";
}
#Jetzt werden bestimmte dateiendungen duch ".script" ersetzt, damit keiner nen cgi oder so hochläd ;)
$savefile=~s/(((\.php)|(\.phps)|(\.phtml)|(\.pl)|(\.cgi))+)/\.script/gs;
chmod 0777, $savefile;
copy($tmpfile,$savefile);
}
#Löschfunktion
if (my $del = param('del'))
{
$delfile="$pfad$del";
if(-e $delfile)
{
unlink($delfile);print "Datei ($del) gelöscht!\n";
}
else
{
print "Error: Kann $del nicht löschen. Datei existiert nicht!\n";
}
}
#Umbenennen
if (my $newname = param('newname'))
{
# $newname=~s/(((\.php)|(\.phps)|(\.phtml)|(\.pl)|(\.cgi))+)/\.script/gs;
$new="$pfad$newname";
$rename=param('rename');
$re="$pfad$rename";
if(-e $re)
{
if(rename($re,$new))
{
print "$rename wurde erfolgreich umbenannt in $newname!\n";
}
else
{
print hr,"$!\n";
}
}
else
{
print "Error: Kann $re nicht umbenennen. Datei existiert nicht!\n";
}
}
&ShowFiles;
print "</center>\n",end_html;
#Funktion zum anzeigend er vorhandenen Files
sub ShowFiles
{
@file=<$pfad*>;
if(@file){
print "<table><tr><th>Dateien online:</th><th>Bytes</th><th>Löschen</th><th>Umbenennen</th>\n";
foreach(@file)
{
if(-f $_){
$size= -s $_;
$_=~ s/$pfad//gs;
if($_ ne lc("Thumbs.db"))
{
print "</tr><tr><td class=\"h\"><a href=\"$url$_\" target=\"_blank\">$_</a></td><td align=\"right\">$size</td><td><form method=\"post\" action=\"$script\" enctype=\"multipart/form-data\"><input type=\"hidden\" name=\"del\" value=\"$_\"><input type=\"hidden\" name=\"nick\" value=\"$user{'nick'}\"><input type=\"hidden\" name=\"pass\" value=\"$user{'pass'}\"><input type=\"submit\" name=\"submit\" value=\"Löschen\"></form></td><td><form method=\"post\" action=\"$script\" enctype=\"multipart/form-data\"><input type=\"hidden\" name=\"rename\" value=\"$_\"><input type=\"hidden\" name=\"nick\" value=\"$user{'nick'}\"><input type=\"hidden\" name=\"pass\" value=\"$user{'pass'}\"><input type=\"text\" size=\"15\" name=\"newname\" value=\"$_\"><input type=\"submit\" name=\"submit\" value=\"Umbenennen\"></form></td>\n";
}
}
}
print "</tr></table>\n";}
print hr;
}