At work...

Bohica said:
do you want anything other than the names? (like size, mod date, etc?)
would be nice...


Putrid said:
well,,, fine then...

pearl would be ok, it would do the job.


I will just go over here and sit in my corner then and eat my lunch.
so you're not going to make me one now? :(
 
sry... just got back from lunch ;o

here's a really simple one, for now. i'll keep working on it, though. add ip's to the %auth hash to give them access.


Code:
#!/usr/bin/perl -w
use strict;
use Fcntl ':mode';
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

$| = 1;

my %auth = ('127.0.0.1'     => 1,
            '24.221.85.168' => 1);


my $root = $ENV{'DOCUMENT_ROOT'};
my $script = $ENV{'SCRIPT_NAME'};


if(not $auth{$ENV{'REMOTE_ADDR'}}) {
    print "Content-type: text/html\n\n";
    print "Forbidden from $ENV{'REMOTE_ADDR'}";
    exit;
}

my $dir = param('d');
if(not defined($dir)) {
    die "Undefined directory.";
}

my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
    $atime,$mtime,$ctime,$blksize,$blocks)
    = stat($dir);

if( -d "$root/$dir") {
    chdir($root.$dir);
    my @files = `ls -1a`;

    print "Content-type: text/html\n\n";
    print "<pre>";
    my $cnt = 0;
    foreach (@files) {
        print " <a href=\"$script"."?d=$dir/$_\">$_</a>";
    }
    print "</pre>";
} else {
    print "Location: $dir\n\n";
}
 
ok, I have your script done and it has pretty pics to go beside the file names to let you know which type of file it is...

it does directories listing and subdirectories from the directory you put it in...


pm me with your email addy and I will zip it all up and send it to you :)




:bouncy:
 
I know Putrid apparently already satisfied you, but here :p

(http://warpedlight.com/list.txt)
Code:
#!/usr/bin/perl -w
use strict;
use File::stat;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

$| = 1;
my $hsent = 0;

my %auth = ('127.0.0.1'     => 1,
	    '24.221.85.168' => 1);

my $root = $ENV{'DOCUMENT_ROOT'}; $root .= "/";
my $script = $ENV{'SCRIPT_NAME'};

if(not $auth{$ENV{'REMOTE_ADDR'}}) {
    &print_head();
    print "Forbidden.";
    exit;
}

my $dir = param('d');
$dir =~ s/\.\.//ig;

if(not defined($dir)) {
    die "Undefined directory.";
}

if( -d "$root/$dir") {
    opendir(DIR, "$root/$dir");
    my @files = readdir(DIR);
    closedir(DIR);

    &print_head();
    print "<pre>";
    printf "<strong>Perms      Size(B)   UID\\GID     Lastmod                  Filename</strong>\n";
    print "<hr align=\"left\" width=\"530\" size=\"1\" noshade color=\"black\">\n\n";
    foreach (@files) {	
	my $f = stat("$root$dir/$_");
	my ($link,$linkdir) = ($_,$dir);
	printf "%04o", $f->mode & 07777;
	if($_ eq "..") { $_ = ""; $linkdir =~ s/^\/*(.*)\/[^\/]*$/\/$1/ig; }
	printf "%16d     %d\\%d     %s     <a href=\"$script?d=$linkdir/$_\">$link</a>\n", $f->size, $f->uid, $f->gid, scalar gmtime $f->mtime;
    }
    print "</pre>";
    &print_tail();
} else {
    print "Location: $dir\n\n";
}

sub print_tail() {
    print <<EOHTML;


<hr align="left" width="530" size="1" noshade color="black">

$ENV{'SERVER_SOFTWARE'} server at <a href="http://$ENV{'SERVER_NAME'}:$ENV{'SERVER_PORT'}">$ENV{'SERVER_NAME'}</a>:$ENV{'SERVER_PORT'}
</body></html>
EOHTML
;

}

sub print_head($dir) {
    print "Content-type: text/html\n\n" and ($hsent = 1) unless ($hsent == 1);
    print <<EOHTML;
<html><head><title>Listing: $dir</title>
       >
BODY {
  background-color: #A7B6C0;
  font-size: 8pt;
}
PRE {
    font-family: Lucida Console, Fixedsys;
}
</style>
</head>      >
EOHTML
;
}
 
Last edited:
Bohica said:
I know Putrid apparently already satisfied you, but...


mine is cooler with prudy pictures and everything



but it's in PHP so I hope it works on his server :)




:bouncy:
 
i figured pictures would just complicate things (making sure they're in the right place, etc.) :shrug:
 
dunna got a host for pics...


work for an isp but if I host from work will get in big big troubles :(


boss monitors bandwidth, blah




:bouncy:
 
Bohica said:
i figured pictures would just complicate things (making sure they're in the right place, etc.) :shrug:

just made a function with an array of the types of extenstions then when my script reads the files and puts them into the table on the page they just get put in front of the file or directory with the appropriate graphic for the extension type for that table row ...


:bouncy:
 
I'm also caught up at work.
I'm so bored, I'm day dreaming.
Surfing doesn't help, I've surfed everything.

Just finished a cool project where we can take an e-mail, strip the file attachment using a unix script, and process the file. We're using this to load SoundScan Top 200 CD charts into our system.
 
yay.png


You rock Putrid! :D

thanks all... ;)
 
Back
Top