#!/keropinet/lang/perl/bin
# WebHome Free v1.0
# Manager
# Made by CyberScript
# website: http://www.cyberscript.net
# email: webmaster@cyberscript.net
# (C) Copyright 1999, All rights reserved.
# DO NOT EDIT THIS SCRIPT
##########################################
use Fcntl;
use AnyDBM_File;
require "cgi-lib.pl";
&ReadParse(\%in,\%cgi_cfn);
print "Content-type: text/html\n\n";
if (!$in{'username'} || !$in{'password'}) { &login_html; exit; }
&get_values;
&check_login;
&actions;
&manager_html;
sub login_html {
print qq~
keropiNET user login
keropiNET login utenti
© Copyright 1999 WebHome Free v1.0
Made by CyberScript, get your own free version !
~;
}
sub manager_html {
print qq~
keropiNET file manager
File manager utenti
Hello $user_info[2], your website URL is $config{'root_url'}/$in{'username'}/
~;
@dir = sort {lc($a) cmp lc($b)} @dir;
foreach $line (@dir) {
if (-f "$config{'root_dir'}/$in{'username'}/$line") {
@stat=stat("$config{'root_dir'}/$in{'username'}/$line");
if ($stat[7] > 1000) { $stat[7] *= .001; $stat[7] = int($stat[7]); $stat[7] .= " KB"; }
else { $stat[7] = int($stat[7]); $stat[7] .= " Bytes"; }
$stat[9] = localtime($stat[9]);
$list .= qq~
$line
$stat[7]
$stat[9]
~;
}
}
if ($list) {
print qq~
~;
}
print qq~
© Copyright 1999 WebHome Free v1.0
Made by CyberScript, get your own free version !
~;
}
sub check_login {
if (!$users{$in{'username'}}) { &error_html("Username not presente nel database"); }
if ($user_info[0] ne $in{'password'}) { &error_html("Password non corretta"); }
}
sub error_html {
($error)=@_;
print qq~
keropiNET login/manager error
keropiNET login/manager error
© Copyright 1999 WebHome Free v1.0
Made by CyberScript, get your own free version !
~;
exit;
}
sub get_values {
# Configure
open (CONFIG,"config.txt");
while () { if ($_ =~ /\n/) { chop $_; } @config=split(/=/,$_,2); $config{$config[0]}=$config[1]; if ($config[0] eq "bad_types") { @bad_types=split(/,/,$config[1]); } }
close (CONFIG);
# Open user database if not already open
if (!$users{"$in{'username'}"}) {
$flags = O_CREAT | O_RDWR;
$db = "$config{'data_dir'}/users";
tie(%users, 'AnyDBM_File', $db , $flags, 0666) || &error_html("Impossibile aprire database utente");
}
# Directory list
opendir (DIR,"$config{'root_dir'}/$in{'username'}");
@dir = readdir(DIR);
closedir (DIR);
# Disk usage, Available and Directory list
$usage=0;
foreach $line (@dir) { if (-f "$config{'root_dir'}/$in{'username'}/$line") { @stat=stat("$config{'root_dir'}/$in{'username'}/$line"); $usage += $stat[7]; } }
$usage = int($usage * .001);
$available = $config{'space_limit'} - $usage;
# User info
@user_info=split(/\|/,$users{$in{'username'}});
}
sub actions {
# Delete a file
if ($in{'delete'}) {
if ($in{'file_input'} =~ /^[a-zA-Z0-9\.\-\_]*$/) { unlink ("$config{'root_dir'}/$in{'username'}/$in{'file'}"); &get_values; }
else { &error_html("Invaild file name"); }
}
# Rename a file
if ($in{'rename'}) {
if ($in{'file_input'} =~ /^[a-zA-Z0-9\.\-\_]*$/) {
foreach $line (@bad_types) { if ($in{'file_input'} =~ /$line/i) { &error_html("Invalid file type"); } }
rename ("$config{'root_dir'}/$in{'username'}/$in{'file'}","$config{'root_dir'}/$in{'username'}/$in{'file_input'}");
} else { &error_html("Invaild file name"); }
&get_values;
}
# Upload file(s)
if ($in{'upload'}) {
for ($i=1; $i<=5; $i++) {
if ($in{"file$i"}) {
if ($cgi_cfn{"file$i"} =~ /(.*)\/(.*)/) { $cgi_cfn{"file$i"}=$2; }
if ($cgi_cfn{"file$i"} =~ /(.*)\\(.*)/) { $cgi_cfn{"file$i"}=$2; }
foreach $line (@bad_types) { if ($cgi_cfn{"file$i"} =~ /$line/) { &error_html("Invaild file type: $line"); } }
$limit=$available;
if (-f "$config{'root_dir'}/$in{'username'}/$cgi_cfn{\"file$i\"}") {
@stat=stat("$config{'root_dir'}/$in{'username'}/$cgi_cfn{\"file$i\"}");
$limit += ($stat[7] * .001);
}
if (($limit - (length($in{"file$i"}) * .001)) < 0) { &error_html("Spazio web esaurito"); }
open (FILE,">$config{'root_dir'}/$in{'username'}/$cgi_cfn{\"file$i\"}") || &error_html("Impossibile creare $cgi_cfn{\"file$i\"}: $!");
binmode (FILE);
print FILE $in{"file$i"};
close (FILE);
}
}
&get_values;
}
}