Turbina |
Download |
Size |
Type |
#!/usr/bin/perl
#
# Copyright (c) 2005, Korinlov Matwey
#
# $Id: arch_list.cgi,v 1.11 2006/01/01 11:58:28 matwey Exp $
#
use strict;
use Digest::MD5 qw(md5 md5_hex md5_base64);
use File::Copy;
my %FILETYPES;
$FILETYPES{'\.tgz$'} ='GnuZipped source tarboll';
$FILETYPES{'\.tar\.gz$'} ='GnuZipped source tarboll';
$FILETYPES{'\.tar\.bz2$'} ='BZipped source tarboll';
$FILETYPES{'\.zip$'} ='FlateZipped source tarboll';
$FILETYPES{'86\.rpm$'} ='RPM binary package';
$FILETYPES{'src\.rpm$'} ='SRPM package';
$FILETYPES{'\.deb$'} ='Debian package';
$FILETYPES{'\.tex$'} ='TeX/LaTeX document';
$FILETYPES{'\.ps$'} ='PostScript document';
$FILETYPES{'\.pdf$'} ='Adobe PDF document';
my $SCRIPT_ROOT='/srv/www/mass/download';
sub get_filetype($){
my $filename=shift;
foreach my $math (keys %FILETYPES){
if($filename=~/$math/){
return $FILETYPES{$math};
}
}
}
sub urldecode($){
my $ret=shift;
$ret=~s/\+/ /g;
$ret=~s/%([0-9a-hA-H]{2})/pack('C',hex($1))/ge;
return $ret;
}
sub check_cache($){
my ($query)=@_;
my $cache_name='al_'.md5_hex($query).'.cache';
( -s '/var/tmp/'.$cache_name ) and return 1;
return 0;
}
sub print_cache($){
my ($query)=@_;
my $cache_name='al_'.md5_hex($query).'.cache';
open(CF,'/var/tmp/'.$cache_name);
while(){
print;
}
close(CF);
return 0;
}
sub write_cache($$){
my ($query,$content)=@_;
my $cache_name='al_'.md5_hex($query).'.cache';
open(CF,'>/var/tmp/'.$cache_name);
print CF $content;
close(CF);
return 0;
}
sub check_param($$$){
my ($bool,$name,$c)=@_;
if( ! $bool ){
print STDERR "'$name' param fail\n";
$$c++;
}
}
sub read_comments($){
my ($real_root)=@_;
my %ret;
open(C,$real_root.'/.al_comments');
while(){
chomp;
$_=~/(.*?):(.*)/;
my $filename=$1;
my $comment=$2;
$filename=~s/^\s+//;
$filename=~s/\s+$//;
$ret{$filename}=$comment;
}
close(C);
return %ret;
}
sub build_list($$$$$){
my ($filename_mask,$output_format,$rows_num,$virtual_root,$real_root)=@_;
my @ret;
opendir(RD,$SCRIPT_ROOT.'/'.$real_root) or die;
my @files=readdir(RD);
@files=sort{$b cmp $a}(@files);
closedir(RD);
my %comment=read_comments($SCRIPT_ROOT.'/'.$real_root);
foreach(@files){
if($_=~/$filename_mask/){
my $s=(stat($SCRIPT_ROOT.'/'.$real_root.'/'.$_))[7];
my $t=get_filetype($_);
my $c=$comment{$_};
eval('push(@ret,"'.$output_format.'")');
}
}
($rows_num > 0) and @ret=splice(@ret,0,$rows_num);
return join("\n",@ret);
}
my %query_params;
foreach( split(/&/,$ENV{'QUERY_STRING'}) ){
my ($k,$v)=split(/=/,$_);
$query_params{$k}=urldecode($v);
}
#
my $filename_mask = $query_params{'m'};
my $output_format = $query_params{'f'};
my $rows_num = $query_params{'n'};
my $virtual_root = $query_params{'v'};
my $real_root = $query_params{'r'};
#
print "Content-Type: text/html\n\n";
#
my $params_err=0;
check_param(($filename_mask),'m',\$params_err);
check_param(($output_format),'f',\$params_err);
check_param(($virtual_root),'v',\$params_err);
check_param(($real_root),'r',\$params_err);
$params_err and exit;
#
#
$real_root=~s/((\.){2,}\/)//g;
$output_format=~s/"/\\"/g;
#
#
check_cache($ENV{'QUERY_STRING'}) or write_cache($ENV{'QUERY_STRING'},build_list($filename_mask,$output_format,$rows_num,$virtual_root,$real_root));
print_cache($ENV{'QUERY_STRING'});
#
|
Download |
Size |
Type |
#!/usr/bin/perl
#
# Copyright (c) 2005, Korinlov Matwey
#
# $Id: arch_list.cgi,v 1.11 2006/01/01 11:58:28 matwey Exp $
#
use strict;
use Digest::MD5 qw(md5 md5_hex md5_base64);
use File::Copy;
my %FILETYPES;
$FILETYPES{'\.tgz$'} ='GnuZipped source tarboll';
$FILETYPES{'\.tar\.gz$'} ='GnuZipped source tarboll';
$FILETYPES{'\.tar\.bz2$'} ='BZipped source tarboll';
$FILETYPES{'\.zip$'} ='FlateZipped source tarboll';
$FILETYPES{'86\.rpm$'} ='RPM binary package';
$FILETYPES{'src\.rpm$'} ='SRPM package';
$FILETYPES{'\.deb$'} ='Debian package';
$FILETYPES{'\.tex$'} ='TeX/LaTeX document';
$FILETYPES{'\.ps$'} ='PostScript document';
$FILETYPES{'\.pdf$'} ='Adobe PDF document';
my $SCRIPT_ROOT='/srv/www/mass/download';
sub get_filetype($){
my $filename=shift;
foreach my $math (keys %FILETYPES){
if($filename=~/$math/){
return $FILETYPES{$math};
}
}
}
sub urldecode($){
my $ret=shift;
$ret=~s/\+/ /g;
$ret=~s/%([0-9a-hA-H]{2})/pack('C',hex($1))/ge;
return $ret;
}
sub check_cache($){
my ($query)=@_;
my $cache_name='al_'.md5_hex($query).'.cache';
( -s '/var/tmp/'.$cache_name ) and return 1;
return 0;
}
sub print_cache($){
my ($query)=@_;
my $cache_name='al_'.md5_hex($query).'.cache';
open(CF,'/var/tmp/'.$cache_name);
while(){
print;
}
close(CF);
return 0;
}
sub write_cache($$){
my ($query,$content)=@_;
my $cache_name='al_'.md5_hex($query).'.cache';
open(CF,'>/var/tmp/'.$cache_name);
print CF $content;
close(CF);
return 0;
}
sub check_param($$$){
my ($bool,$name,$c)=@_;
if( ! $bool ){
print STDERR "'$name' param fail\n";
$$c++;
}
}
sub read_comments($){
my ($real_root)=@_;
my %ret;
open(C,$real_root.'/.al_comments');
while(){
chomp;
$_=~/(.*?):(.*)/;
my $filename=$1;
my $comment=$2;
$filename=~s/^\s+//;
$filename=~s/\s+$//;
$ret{$filename}=$comment;
}
close(C);
return %ret;
}
sub build_list($$$$$){
my ($filename_mask,$output_format,$rows_num,$virtual_root,$real_root)=@_;
my @ret;
opendir(RD,$SCRIPT_ROOT.'/'.$real_root) or die;
my @files=readdir(RD);
@files=sort{$b cmp $a}(@files);
closedir(RD);
my %comment=read_comments($SCRIPT_ROOT.'/'.$real_root);
foreach(@files){
if($_=~/$filename_mask/){
my $s=(stat($SCRIPT_ROOT.'/'.$real_root.'/'.$_))[7];
my $t=get_filetype($_);
my $c=$comment{$_};
eval('push(@ret,"'.$output_format.'")');
}
}
($rows_num > 0) and @ret=splice(@ret,0,$rows_num);
return join("\n",@ret);
}
my %query_params;
foreach( split(/&/,$ENV{'QUERY_STRING'}) ){
my ($k,$v)=split(/=/,$_);
$query_params{$k}=urldecode($v);
}
#
my $filename_mask = $query_params{'m'};
my $output_format = $query_params{'f'};
my $rows_num = $query_params{'n'};
my $virtual_root = $query_params{'v'};
my $real_root = $query_params{'r'};
#
print "Content-Type: text/html\n\n";
#
my $params_err=0;
check_param(($filename_mask),'m',\$params_err);
check_param(($output_format),'f',\$params_err);
check_param(($virtual_root),'v',\$params_err);
check_param(($real_root),'r',\$params_err);
$params_err and exit;
#
#
$real_root=~s/((\.){2,}\/)//g;
$output_format=~s/"/\\"/g;
#
#
check_cache($ENV{'QUERY_STRING'}) or write_cache($ENV{'QUERY_STRING'},build_list($filename_mask,$output_format,$rows_num,$virtual_root,$real_root));
print_cache($ENV{'QUERY_STRING'});
#
|
Rs485 |
Download |
Size |
Type |
#!/usr/bin/perl
#
# Copyright (c) 2005, Korinlov Matwey
#
# $Id: arch_list.cgi,v 1.11 2006/01/01 11:58:28 matwey Exp $
#
use strict;
use Digest::MD5 qw(md5 md5_hex md5_base64);
use File::Copy;
my %FILETYPES;
$FILETYPES{'\.tgz$'} ='GnuZipped source tarboll';
$FILETYPES{'\.tar\.gz$'} ='GnuZipped source tarboll';
$FILETYPES{'\.tar\.bz2$'} ='BZipped source tarboll';
$FILETYPES{'\.zip$'} ='FlateZipped source tarboll';
$FILETYPES{'86\.rpm$'} ='RPM binary package';
$FILETYPES{'src\.rpm$'} ='SRPM package';
$FILETYPES{'\.deb$'} ='Debian package';
$FILETYPES{'\.tex$'} ='TeX/LaTeX document';
$FILETYPES{'\.ps$'} ='PostScript document';
$FILETYPES{'\.pdf$'} ='Adobe PDF document';
my $SCRIPT_ROOT='/srv/www/mass/download';
sub get_filetype($){
my $filename=shift;
foreach my $math (keys %FILETYPES){
if($filename=~/$math/){
return $FILETYPES{$math};
}
}
}
sub urldecode($){
my $ret=shift;
$ret=~s/\+/ /g;
$ret=~s/%([0-9a-hA-H]{2})/pack('C',hex($1))/ge;
return $ret;
}
sub check_cache($){
my ($query)=@_;
my $cache_name='al_'.md5_hex($query).'.cache';
( -s '/var/tmp/'.$cache_name ) and return 1;
return 0;
}
sub print_cache($){
my ($query)=@_;
my $cache_name='al_'.md5_hex($query).'.cache';
open(CF,'/var/tmp/'.$cache_name);
while(){
print;
}
close(CF);
return 0;
}
sub write_cache($$){
my ($query,$content)=@_;
my $cache_name='al_'.md5_hex($query).'.cache';
open(CF,'>/var/tmp/'.$cache_name);
print CF $content;
close(CF);
return 0;
}
sub check_param($$$){
my ($bool,$name,$c)=@_;
if( ! $bool ){
print STDERR "'$name' param fail\n";
$$c++;
}
}
sub read_comments($){
my ($real_root)=@_;
my %ret;
open(C,$real_root.'/.al_comments');
while(){
chomp;
$_=~/(.*?):(.*)/;
my $filename=$1;
my $comment=$2;
$filename=~s/^\s+//;
$filename=~s/\s+$//;
$ret{$filename}=$comment;
}
close(C);
return %ret;
}
sub build_list($$$$$){
my ($filename_mask,$output_format,$rows_num,$virtual_root,$real_root)=@_;
my @ret;
opendir(RD,$SCRIPT_ROOT.'/'.$real_root) or die;
my @files=readdir(RD);
@files=sort{$b cmp $a}(@files);
closedir(RD);
my %comment=read_comments($SCRIPT_ROOT.'/'.$real_root);
foreach(@files){
if($_=~/$filename_mask/){
my $s=(stat($SCRIPT_ROOT.'/'.$real_root.'/'.$_))[7];
my $t=get_filetype($_);
my $c=$comment{$_};
eval('push(@ret,"'.$output_format.'")');
}
}
($rows_num > 0) and @ret=splice(@ret,0,$rows_num);
return join("\n",@ret);
}
my %query_params;
foreach( split(/&/,$ENV{'QUERY_STRING'}) ){
my ($k,$v)=split(/=/,$_);
$query_params{$k}=urldecode($v);
}
#
my $filename_mask = $query_params{'m'};
my $output_format = $query_params{'f'};
my $rows_num = $query_params{'n'};
my $virtual_root = $query_params{'v'};
my $real_root = $query_params{'r'};
#
print "Content-Type: text/html\n\n";
#
my $params_err=0;
check_param(($filename_mask),'m',\$params_err);
check_param(($output_format),'f',\$params_err);
check_param(($virtual_root),'v',\$params_err);
check_param(($real_root),'r',\$params_err);
$params_err and exit;
#
#
$real_root=~s/((\.){2,}\/)//g;
$output_format=~s/"/\\"/g;
#
#
check_cache($ENV{'QUERY_STRING'}) or write_cache($ENV{'QUERY_STRING'},build_list($filename_mask,$output_format,$rows_num,$virtual_root,$real_root));
print_cache($ENV{'QUERY_STRING'});
#
|
Download |
Size |
Type |
#!/usr/bin/perl
#
# Copyright (c) 2005, Korinlov Matwey
#
# $Id: arch_list.cgi,v 1.11 2006/01/01 11:58:28 matwey Exp $
#
use strict;
use Digest::MD5 qw(md5 md5_hex md5_base64);
use File::Copy;
my %FILETYPES;
$FILETYPES{'\.tgz$'} ='GnuZipped source tarboll';
$FILETYPES{'\.tar\.gz$'} ='GnuZipped source tarboll';
$FILETYPES{'\.tar\.bz2$'} ='BZipped source tarboll';
$FILETYPES{'\.zip$'} ='FlateZipped source tarboll';
$FILETYPES{'86\.rpm$'} ='RPM binary package';
$FILETYPES{'src\.rpm$'} ='SRPM package';
$FILETYPES{'\.deb$'} ='Debian package';
$FILETYPES{'\.tex$'} ='TeX/LaTeX document';
$FILETYPES{'\.ps$'} ='PostScript document';
$FILETYPES{'\.pdf$'} ='Adobe PDF document';
my $SCRIPT_ROOT='/srv/www/mass/download';
sub get_filetype($){
my $filename=shift;
foreach my $math (keys %FILETYPES){
if($filename=~/$math/){
return $FILETYPES{$math};
}
}
}
sub urldecode($){
my $ret=shift;
$ret=~s/\+/ /g;
$ret=~s/%([0-9a-hA-H]{2})/pack('C',hex($1))/ge;
return $ret;
}
sub check_cache($){
my ($query)=@_;
my $cache_name='al_'.md5_hex($query).'.cache';
( -s '/var/tmp/'.$cache_name ) and return 1;
return 0;
}
sub print_cache($){
my ($query)=@_;
my $cache_name='al_'.md5_hex($query).'.cache';
open(CF,'/var/tmp/'.$cache_name);
while(){
print;
}
close(CF);
return 0;
}
sub write_cache($$){
my ($query,$content)=@_;
my $cache_name='al_'.md5_hex($query).'.cache';
open(CF,'>/var/tmp/'.$cache_name);
print CF $content;
close(CF);
return 0;
}
sub check_param($$$){
my ($bool,$name,$c)=@_;
if( ! $bool ){
print STDERR "'$name' param fail\n";
$$c++;
}
}
sub read_comments($){
my ($real_root)=@_;
my %ret;
open(C,$real_root.'/.al_comments');
while(){
chomp;
$_=~/(.*?):(.*)/;
my $filename=$1;
my $comment=$2;
$filename=~s/^\s+//;
$filename=~s/\s+$//;
$ret{$filename}=$comment;
}
close(C);
return %ret;
}
sub build_list($$$$$){
my ($filename_mask,$output_format,$rows_num,$virtual_root,$real_root)=@_;
my @ret;
opendir(RD,$SCRIPT_ROOT.'/'.$real_root) or die;
my @files=readdir(RD);
@files=sort{$b cmp $a}(@files);
closedir(RD);
my %comment=read_comments($SCRIPT_ROOT.'/'.$real_root);
foreach(@files){
if($_=~/$filename_mask/){
my $s=(stat($SCRIPT_ROOT.'/'.$real_root.'/'.$_))[7];
my $t=get_filetype($_);
my $c=$comment{$_};
eval('push(@ret,"'.$output_format.'")');
}
}
($rows_num > 0) and @ret=splice(@ret,0,$rows_num);
return join("\n",@ret);
}
my %query_params;
foreach( split(/&/,$ENV{'QUERY_STRING'}) ){
my ($k,$v)=split(/=/,$_);
$query_params{$k}=urldecode($v);
}
#
my $filename_mask = $query_params{'m'};
my $output_format = $query_params{'f'};
my $rows_num = $query_params{'n'};
my $virtual_root = $query_params{'v'};
my $real_root = $query_params{'r'};
#
print "Content-Type: text/html\n\n";
#
my $params_err=0;
check_param(($filename_mask),'m',\$params_err);
check_param(($output_format),'f',\$params_err);
check_param(($virtual_root),'v',\$params_err);
check_param(($real_root),'r',\$params_err);
$params_err and exit;
#
#
$real_root=~s/((\.){2,}\/)//g;
$output_format=~s/"/\\"/g;
#
#
check_cache($ENV{'QUERY_STRING'}) or write_cache($ENV{'QUERY_STRING'},build_list($filename_mask,$output_format,$rows_num,$virtual_root,$real_root));
print_cache($ENV{'QUERY_STRING'});
#
|