Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 163 lines (132 sloc) 4.317 kB
b4000e5 新功能增加,bug修正。
Geng Shuang authored
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5 use MIME::Base64;
6
a4726eb 为ezDailys.pl添加可选参数。
Geng Shuang authored
7 my $SPECUSER = @ARGV ? shift : '';
2379b81 版本库更名。
Geng Shuang authored
8 my $USERFILE = '/home/gengs/develops/ezWork/accounts';
9 my $USERSELS = '/home/gengs/develops/ezWork/useroptions';
b4000e5 新功能增加,bug修正。
Geng Shuang authored
10
11 my %FIELDSDEF = (
12 TASK => 'txtTask',
13 PROJ => 'selProject',
14 PROT => 'selProTask',
15 ACTV => 'selActType1',
16 SACT => 'selActType2',
17 PROM => 'selModule1',
18 );
19
20 open my $UF, "< $USERFILE";
21 my @userlist = <$UF>;
22 close $UF;
23
24 open my $SF, "< $USERSELS";
25 my @usersels = <$SF>;
26 close $SF;
27
28 foreach my $l (@userlist) {
29 my $line = $l;
30 chomp $line;
31 if ($line =~ /^(.*?):(.*?):(.*)$/) {
32 my $user_name = $1;
a4726eb 为ezDailys.pl添加可选参数。
Geng Shuang authored
33 if (!$SPECUSER || ($SPECUSER eq $user_name)) {
34 my $user_pass = decode_base64($2);
35 my $user_info = decode_base64($3);
b4000e5 新功能增加,bug修正。
Geng Shuang authored
36
a4726eb 为ezDailys.pl添加可选参数。
Geng Shuang authored
37 print "Reporting for $user_name\n";
b4000e5 新功能增加,bug修正。
Geng Shuang authored
38
5a05a8d 修正密码中包含非标准的字母和字符时认证错误问题。
Geng Shuang authored
39 my $chk_pass_ol = `perl /home/gengs/develops/ezWork/getuseroptions.pl '$user_name' '$user_pass'`;
b4000e5 新功能增加,bug修正。
Geng Shuang authored
40
a4726eb 为ezDailys.pl添加可选参数。
Geng Shuang authored
41 if ($chk_pass_ol =~ /!ERROR! Invalid username or password!!/) {
42 print "!!WARNING!! Account [$user_name] can not be verified.\n";
b4000e5 新功能增加,bug修正。
Geng Shuang authored
43 }
44 else {
a4726eb 为ezDailys.pl添加可选参数。
Geng Shuang authored
45 if (my $err = check_user_settings($user_name)) {
46 print "!!WARNING!! Account [$user_name] has wrong setting in field [$err].\n";
47 }
48 else {
2379b81 版本库更名。
Geng Shuang authored
49 my $reportstr = "perl /home/gengs/develops/ezWork/ezDaily.pl '$user_name' '$user_pass' ";
a4726eb 为ezDailys.pl添加可选参数。
Geng Shuang authored
50 foreach my $key ('TASK','PROJ','PROT','ACTV','SACT','PROM') {
51 $reportstr .= "'".get_field_info($user_name, $FIELDSDEF{$key})."' ";
52 }
53 print $reportstr."\n";
54 `$reportstr`;
b4000e5 新功能增加,bug修正。
Geng Shuang authored
55 }
56 }
57 }
58 }
59 }
60
61 sub check_user_settings {
62 my $account = shift;
63
64 foreach my $key (keys %FIELDSDEF) {
65 if ($key eq 'TASK') {
66 return $FIELDSDEF{$key} unless get_field_info($account, $FIELDSDEF{$key});
67 }
68 else {
69 return $FIELDSDEF{$key} if check_field_set($account, $FIELDSDEF{$key});
70 }
71 }
72
73 return 0;
74 }
75
76 sub check_field_set {
77 my $account = shift;
78 my $field = shift;
79
80 my $value = get_field_info($account, $field);
81 my $searchstr = "account=$account;";
82 if ($field eq 'selProject') {
83 }
84 elsif ($field eq 'selActType2') {
85 $searchstr .= "selProject=".get_field_info($account, 'selProject').";".
86 "selActType1=".get_field_info($account, 'selActType1').";";
87 }
88 else {
89 $searchstr .= "selProject=".get_field_info($account, 'selProject').";";
90 }
91
92 my $check = get_field_def($searchstr, $field);
93
94 return 0 if $check =~ /\($value\)/;
95 return 0 if !$check && !$value;
96
97 return 1;
98 }
99
100 sub get_field_def {
101 my $search = shift;
102 my $field = shift;
103
104 my $account = $search;
105 $account =~ s/account=(.*?);.*/$1/;
106 $search =~ s/.*?=.*?;//;
107
108 my $sels = join '', @usersels;
109 unless ($sels =~ s/.*###$account###(.*?)###$account###.*/$1/s) {
a4726eb 为ezDailys.pl添加可选参数。
Geng Shuang authored
110 print "Cannot found $account in $USERSELS\n";
b4000e5 新功能增加,bug修正。
Geng Shuang authored
111 }
112
113 my $level = 0;
114 while ($search =~ /(.*?)=(.*?);/g) {
115 my $sfield = $1;
116 my $svalue = $2;
117 $sels =~ s/.*^\*{$level}$svalue.*?\n(.*?)^\*{$level}[^*]+.*/$1/gsm;
118 $level++;
119 }
120
121 $sels =~ s/.*\*{$level}$field\n*(.*?)\*{$level}$field.*/$1/s;
122 my $retval = '';
123 while ($sels =~ /^\*{$level}([^*]+)$/gm) {
124 my $str = $1;
125
126 $str =~ /(.*?)=(.*)/;
127 $retval .= " ($1) $2\n";
128 }
129
130 my $uservalue = get_field_info($account, $field);
131 if ($uservalue) {
132 $retval =~ s/^(\s+)(?=\($uservalue\))/ * /sm;
133 }
134
135 return $retval;
136 }
137
138 sub get_field_info {
139 my $account = shift;
140 my $field = @_ ? shift : '';
141
142 my @lines = grep(/^$account:/, @userlist);
143 return "Account [$account] cannot found!" unless @lines;
144 my $line = shift @lines;
145
146 chomp $line;
147
148 my $retstr = '';
4305d66 修正查询field字段value的bug。(ezDailys.pl)
Geng Shuang authored
149 if ($field && $line =~ m/[:;]$field<(.*?)(?:;|$)/) {
b4000e5 新功能增加,bug修正。
Geng Shuang authored
150 $retstr .= decode_base64($1);
151 }
152 elsif ($field) {
153 $retstr .= '';
154 }
155 else {
156 foreach my $key (keys %FIELDSDEF) {
157 $retstr .= $FIELDSDEF{$key}.'='.get_field_info($account, $FIELDSDEF{$key})."\n";
158 }
159 }
160
161 return $retstr;
162 }
Something went wrong with that request. Please try again.