#!/usr/bin/perl
use strict;
#use lib './';
#************************************************************************************
#Build 1011A0001
#************************************************************************************
use CGI::Carp qw(fatalsToBrowser);
(our $script=$0) =~s!^.*[/\\]!!;
use Manager;
use Digest::MD5;
use Data::Dumper;
use CGI::Cookie;
use utf8;
use URI::Escape;
use Encode qw(encode);
use Encode;
#************************************************************************************
#Icon Artwork By Silvestre Herrera
#
#Check out his other icon artwork here: http://www.silvestre.com.ar
#
#Icons released under the terms of the GNU General Public License version 2 and/or 3
#
#************************************************************************************
my %SUB = (
download => \&download,
upload=> \&upload2,
uploadfl => \&uploadfl,
uploadja => \&uploadja,
uploadok => \&uploadok,
uplja => \&uplja,
userarea => \&userarea,
findfile => \&findfile,
about => \&about,
view => \&view,
chmod => \&chmod_f,
logout=> \&logout,
delete=> \&delete,
mkdir => \&mkdir,
rename=> \&rename,
copy => \©_f,
pack => \&pack,
unpack=> \&unpack,
move => \&move,
edit => \&edit,
tree => \&tree,
notes => \¬es,
batch_download => \&batch_download,
hotlink=> \&hotlink,
flu=> \&flu,
);
my $fm = new Manager(config=>'Configuration.pl', SCRIPT=>$script);
$fm->parseCGI;
my $dir=$fm->{CGI}->{dir};
about() if $fm->{CGI}->{action} eq 'about';
$fm->hotLink() if $fm->{CGI}->{file} && $fm->{CGI}->{link} && $fm->{CGI}->{a};
forgott() if $fm->{CGI}->{action} eq 'forgott';
restore() if $fm->{CGI}->{action} eq 'restore';
flu() if $fm->{CGI}->{action} eq 'flu';
uplja() if $fm->{CGI}->{action} eq 'uplja';
$SUB{upload} = \&upload if $fm->{uploadPrBarOn};
$SUB{upload} = \&uploadX if $fm->{xUploadOn};
my $sid = $fm->getCookie($fm->{cookieName});
$sid=~s/;$//;
if ($fm->{CGI}->{action} eq 'logout'){
$fm->currentUserBySid();
$fm->logger("Logged Out");
$fm->logout;
exit;
}
if($fm->{CGI}->{log_in}){
$fm->getMessages( $fm->{CGI}->{language} || $fm->{currentUser}->{language} || 'en');
$fm->login(password=>$fm->{CGI}->{password},login=>$fm->{CGI}->{login});
$fm->logger("Logged In");
#clear all old sessions
$fm->clearSessions;
print "Location: $fm->{SCRIPT}\n\n";
}
elsif($sid){ print L "[sid] $sid\n";#close L;
$fm->currentUserBySid();
}
unless($fm->currentUser){$fm->login;}
my $user = $fm->currentUser();
$fm->logout(3) if $user->{disabled};
$fm->logout(3) unless $fm->validTime();
$fm->getMessages( $fm->{CGI}->{language} || $fm->{currentUser}->{language} || 'en');
$fm->{CGI}->{opt} ||= 'name';
$SUB{$fm->{CGI}->{action}}->() if defined $SUB{$fm->{CGI}->{action}};
my ($dsort,$sort)=$fm->getFileList();
#my $Rights = ($fm->{isShared} && !$fm->currentUser->{isAdmin})? $user->{SHARED}->{$fm->{isShared}}->{RIGHTS}:$user->{RIGHTS};
my $Rights = ($fm->{isShared} && !$fm->currentUser->{isAdmin})? $user->{SHARED}->{$fm->{isShared}}->{RIGHTS}:$user->{RIGHTS};
my %opt_;
my %arrow;
if($fm->{CGI}->{r}){$arrow{$fm->{CGI}->{opt}} = " {htmlDataFolder}/arrow_up.gif\" align=\"top\" alt=\"\"> ";}
else{
$arrow{$fm->{CGI}->{opt}} = " {htmlDataFolder}/arrow_down.gif\" align=\"top\" alt=\"\"> ";
$opt_{$fm->{CGI}->{opt}}="&r=1";
}
my $overQuota = $fm->currentfreeSpace? undef:1;
print "Content-type: text/html; charset=utf-8\n\n";
print qq~
$fm->{Filemanagertitle}
{timeOut};
print qq~>
~;
my $qs = "";
my $colspan = $fm->{fileDescriptionOn}?7:6;
(my $tdir=$dir)=~s/^\(shared\)//;
my @path = split('/',$tdir);
$tdir="";
my $i=0;
for (@path){
$tdir &&= $tdir.'/';
$tdir .= $_;
$_= "$_ ";
}
$tdir = join ('/',@path);
print qq~
{MESSAGES}->{file_position}>
{MESSAGES}->{edit_position}>
{MESSAGES}->{tools_position}>
{MESSAGES}->{help_position}>
~;
my $disabled = 'disabled' if $fm->{CGI}->{gzfile};
my $col1 = $fm->{fileDescriptionOn}? '37%':'48%';
my $col2 = $fm->{fileDescriptionOn}? '6%':'10%';
my $col3 = $fm->{fileDescriptionOn}? '12%':'22%';
print qq~
";
print "";
print "";
print footer();
print "