forked from aleksey200505/lightsquid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bigfiles.cgi
executable file
·101 lines (76 loc) · 2.23 KB
/
bigfiles.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/perl
#
# LightSquid Project (c) 2004-2005 Sergey Erokhin aka ESL
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# detail see in gnugpl.txt
print "Content-Type: text/html\n\n";
use File::Basename;
push (@INC,(fileparse($0))[1]);
use CGI;
require "lightsquid.cfg";
require "common.pl";
$co=new CGI;
$year =$co->param('year');
$month =$co->param('month');
$day =$co->param('day');
$filteruser =$co->param('user');
InitTPL("bigfiles",$co->param('tpl'));
$n=1;
$total=0;
$workperiod=" $day $MonthName[$month] $year";
open FF,"<$reportpath/$year$month$day/.bigfiles" || MyDie("cant' open .bigfile");
$N=0;
while (<FF>) {
($user,$time,$size,$link)=split;
if ($filteruser ne "") {
next unless ($filteruser eq $user);
};
$N++;
$total+=$size;
$printsize=FineDec($size);
$rowattr = ($N & 1)?$hTPLVARIABLE{oddattr}:$hTPLVARIABLE{evenattr};
$url_L=URLEncode("user_detail.cgi?year=$year&month=$month&day=$day&user=$user");
$url_B="$user";
$url_L =~ s/#/%23/;
$tmp=$hTPL{bigfile};
$tmp=~s/##BFILENUM##/$N/;
$tmp=~s/##BFILETIME##/$time/;
$tmp=~s/##BFILEUSER_L##/$url_L/;
$tmp=~s/##BFILEUSER_B##/$url_B/;
$tmp=~s/##BFILESIZE##/$printsize/;
$tmp=~s/##BFILELINK##/$link/;
$tmp=~s/##ROWATTR##/$rowattr/;
$tpl{bigfile} .= $tmp;
}
close FF;
$printsize=FineDec($total);
$tmp=$hTPL{bigfile};
$tmp=~s/##BFILENUM##/ /;
$tmp=~s/##BFILETIME##/ /;
$tmp=~s/##BFILEUSER_L##//;
$tmp=~s/##BFILEUSER_B##/TOTAL/;
$tmp=~s/##BFILESIZE##/$printsize/;
$tmp=~s/##BFILELINK##/ /;
$tmp=~s/##ROWATTR##/$hTPLVARIABLE{total}/;
$tpl{bigfile} .= $tmp;
ReplaceTPL(DATE,$workperiod);
ReplaceTPL(REPORTUSER,$filteruser);
ApplyTPL();
HideTPL("reportuser") if ($filteruser eq "");
PrintTPL();
__END__
2004-09-09 ADD : skip all files starting with .
2005-04-17 ADD : TemplateEngine
2005-07-01 ADD : TOTAL size
2005-08-30 ADD : Color flipper
2005-09-08 ADD : user now URL to day_detail for user
2005-10-01 ADD : _L,_B
2005-11-07 ADD : URL_Encode
2006-06-28 ADD : die -> MyDie
2006-06-28 ADD : &tpl= support
2006-09-13 ADD : &user= filter by USER