File "fileman.cgi"

Full Path: /home/analogde/www/Design/fileman/fileman.cgi
File size: 3.11 KB
MIME-type: text/x-perl
Charset: utf-8

#!/usr/local/bin/perl
# ==================================================================
# File manager - enhanced web based file management system
#
#   Website  : http://gossamer-threads.com/
#   Support  : http://gossamer-threads.com/scripts/support/
#   Revision : $Id: fileman.cgi,v 1.10 2003/02/07 19:57:13 alex Exp $
# 
# Copyright (c) 2001 Gossamer Threads Inc.  All Rights Reserved.
# Redistribution in part or in whole strictly prohibited. Please
# see LICENSE file for full details.
# ==================================================================
    use lib 'http://www.analog-design.net/cgi-bin/private/lib';
    use strict;
    use vars qw/$CFG_PATH/;
    
    use GT::Base qw/:all/;
    use GT::CGI;
    use GT::FileMan;
    
    $| = 1;
    local $SIG{__DIE__}   = \&GT::FileMan::fatal;
   
    $CFG_PATH = 'http://www.analog-design.net/cgi-bin/private/ConfigData.pm';
    
    main();

sub main () {
#-------------------------------------------------------------------
#   Main process
#
        my $fm = GT::FileMan->new(
        cfg_path      => $CFG_PATH,
        commands      => {
            cmd_search      => 1,
            cmd_replace     => 1,
            cmd_command     => 1,
            cmd_upload      => 1,
            cmd_editor      => 1,
            cmd_passwd      => 1,
            cmd_makedir     => 1,
            cmd_preferences => 1,
            cmd_edit        => 1,
            cmd_download    => 1,
            cmd_copy        => 1,
            cmd_delete      => 1,
            cmd_move        => 1,
            cmd_chmod       => 1,
            cmd_tail        => 1,
            cmd_perl        => 1,
            cmd_diff        => 1,
            cmd_tar         => 1,
            cmd_admin       => 1,
            cmd_print       => 1,
        }
    );

# Set our tmp directory.
    $ENV{GT_TMPDIR} = $fm->{cfg}->{'priv_path'} . '/tmp';

# Check to see if we need to authenticate.
    if ($fm->{cfg}->{username} and $fm->{cfg}->{password}) {
        my $username  = $fm->{in}->cookie('username') || '';
        my $encrypted = $fm->{in}->cookie('password') || '';
        my $scheme    = $fm->{in}->cookie('scheme')   || 'fileman';
        if ($fm->{cgi}->{login}) {
            $username  = $fm->{cgi}->{username} || '';
            $encrypted = crypt($fm->{cgi}->{password}, $fm->{cfg}->{password});
        }
        if (!$username or ($username ne $fm->{cfg}->{username}) or ($encrypted ne $fm->{cfg}->{password})) {
            my $msg = $fm->{cgi}->{login} ? $GT::FileMan::Commands::LANGUAGE{ERR_LOGIN} : '';
            return $fm->page('login_form.html',{ msg => $msg , username => $fm->{cfg}->{username}, scheme => $scheme, html_url => $fm->{cfg}->{html_root_url} });
        }
    # Logged in ok, save username, password into cookie
        elsif ($fm->{cgi}->{login}) {
            print $fm->{in}->header (
                -cookie => [
                   $fm->{in}->cookie ( -name    => 'username', -value   => $username,  -expires => ''),
                   $fm->{in}->cookie ( -name    => 'password', -value   => $encrypted, -expires => ''),
                ]
            );
        }
    }
    $fm->process();

}