[1] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | #========================================================================= |
---|
| 4 | # addaccount.cgi ver.1.00 |
---|
| 5 | # ladminðbvµœAAJEgð쬷éCGIB |
---|
| 6 | # ladmin ver.1.04ÅÌ®ìðmFB |
---|
| 7 | # |
---|
| 8 | # ** Ýèû@ ** |
---|
| 9 | # |
---|
| 10 | # - ºÌ$ladminÏÉladminÖÌpXðÝè·é±ÆB |
---|
| 11 | # - UNIXnOSÅgp·éêÍladminÆ€ÉüsR[hðÏ··é±ÆAÜœ |
---|
| 12 | # t@Cæªsðperl̳µ¢pXɷ鱯Bá> $ which perl |
---|
| 13 | # - T[o[vOâuEUÉæÁÄÍ $cgiuri ɱÌt@CÖÌ |
---|
| 14 | # ®SÈURIðZbgµÈ¯êÎÈçÈ¢êà éB |
---|
| 15 | # - perlÉpXªÊÁĢȢêÍ $perl ðperlÖ̳µ¢pXɷ鱯B |
---|
| 16 | # - ŒÍÊÌCGIƯ¶Å·BiÀs âcgi-bintH_ÈÇj |
---|
| 17 | # |
---|
| 18 | # ** »ÌŒ ** |
---|
| 19 | # addaccount.cgi ðuEUÅJÆTvHTMLi»ÌÜÜgŠÜ·jª |
---|
| 20 | # J«Ü·BÜœA±ÌcgiÍuEU©ççêéAccept-Languageª |
---|
| 21 | # jaÅnÜÁÄ¢êÎbZ[WÌêðú{êÉÏ·µÜ·B |
---|
| 22 | # (IEÈçC^[lbgIvVÌŸêÝèÅêÔãÉú{êðu) |
---|
| 23 | # »êÈOÌêÍpêÌÜÜo͵ܷB |
---|
| 24 | #------------------------------------------------------------------------- |
---|
| 25 | |
---|
| 26 | my($ladmin) = "../ladmin"; # ladminÌpX(š»çÏXªKv) |
---|
| 27 | |
---|
| 28 | my($cgiuri) = "./addaccount.cgi"; # ±Ìt@CÌURI |
---|
| 29 | my($perl) = "perl"; # perlÌR}hŒ |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | #--------------------------- Ýè±±ÜÅ -------------------------------- |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | use strict; |
---|
| 41 | use CGI; |
---|
| 42 | |
---|
| 43 | my($cgi)= new CGI; |
---|
| 44 | my(%langconv)=( |
---|
| 45 | 'Athena login-server administration tool.*' => '', |
---|
| 46 | 'logged on.*' => '', |
---|
| 47 | ); |
---|
| 48 | |
---|
| 49 | # ----- ú{ê«ÈçÏ·e[uðZbg ----- |
---|
| 50 | if($ENV{'HTTP_ACCEPT_LANGUAGE'}=~/^ja/){ |
---|
| 51 | my(%tmp)=( |
---|
| 52 | 'Account \[(.+)\] is successfully created.*' |
---|
| 53 | => 'AJEg "$1" ð쬵ܵœ.', |
---|
| 54 | 'Account \[(.+)\] creation failed\. same account exists.*' |
---|
| 55 | => 'AJEg "$1" Íùɶݵܷ.', |
---|
| 56 | 'Illeagal charactor found in UserID.*' |
---|
| 57 | => 'IDÌÉs³È¶ª èÜ·.', |
---|
| 58 | 'Illeagal charactor found in Password.*' |
---|
| 59 | => 'PasswordÌÉs³È¶ª èÜ·.', |
---|
| 60 | 'input UserID 4-24 bytes.' |
---|
| 61 | => 'IDÍŒp4`24¶Åü͵ğ³¢.', |
---|
| 62 | 'input Password 4-24 bytes.' |
---|
| 63 | => 'PasswordÍŒp4`24¶Åü͵ğ³¢.', |
---|
| 64 | 'Illeagal gender.*' |
---|
| 65 | => '«Êªš©µ¢Å·.', |
---|
| 66 | 'Cant connect to login server.*' |
---|
| 67 | => 'OCT[o[Éڱūܹñ.', |
---|
| 68 | 'login error.*' |
---|
| 69 | => 'OCT[o[ÖÌÇÒ ÀOCÉžsµÜµœ', |
---|
| 70 | "Can't execute ladmin.*" |
---|
| 71 | => 'ladminÌÀsÉžsµÜµœ', |
---|
| 72 | 'UserID "(.+)" is already used.*' |
---|
| 73 | => 'ID "$1" ÍùÉgp³êĢܷ.', |
---|
| 74 | 'You can use UserID \"(.+)\".*' |
---|
| 75 | => 'ID "$1" ÍgpÂ\Å·.', |
---|
| 76 | |
---|
| 77 | 'account making' =>'AJEgì¬', |
---|
| 78 | '\>UserID' =>'>hc', |
---|
| 79 | '\>Password' =>'>pX[h', |
---|
| 80 | '\>Gender' =>'>«Ê', |
---|
| 81 | '\>Male' =>'>j«', |
---|
| 82 | '\>Female' =>'>«', |
---|
| 83 | '\"Make Account\"' =>'"AJEgì¬"', |
---|
| 84 | '\"Check UserID\"' =>'"IDÌ`FbN"', |
---|
| 85 | ); |
---|
| 86 | map { $langconv{$_}=$tmp{$_}; } keys (%tmp); |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | # ----- ÇÁ ----- |
---|
| 90 | if( $cgi->param("addaccount") ){ |
---|
| 91 | my($userid)= $cgi->param("userid"); |
---|
| 92 | my($passwd)= $cgi->param("passwd"); |
---|
| 93 | my($gender)= lc(substr($cgi->param("gender"),0,1)); |
---|
| 94 | if(length($userid)<4 || length($userid)>24){ |
---|
| 95 | HttpError("input UserID 4-24 bytes."); |
---|
| 96 | } |
---|
| 97 | if(length($passwd)<4 || length($passwd)>24){ |
---|
| 98 | HttpError("input Password 4-24 bytes."); |
---|
| 99 | } |
---|
| 100 | if($userid=~/[^0-9A-Za-z\@\_\-\']/){ |
---|
| 101 | HttpError("Illeagal charactor found in UserID."); |
---|
| 102 | } |
---|
| 103 | if($passwd=~/[\x00-\x1f\x80-\xff\']/){ |
---|
| 104 | HttpError("Illeagal charactor found in Password."); |
---|
| 105 | } |
---|
| 106 | if($gender!~/[mf]/){ |
---|
| 107 | HttpError("Gender error."); |
---|
| 108 | } |
---|
| 109 | open PIPE,"$perl $ladmin --add $userid $gender $passwd |" |
---|
| 110 | or HttpError("Can't execute ladmin."); |
---|
| 111 | my(@msg)=<PIPE>; |
---|
| 112 | close PIPE; |
---|
| 113 | HttpMsg(@msg); |
---|
| 114 | } |
---|
| 115 | # ----- ¶Ý`FbN ----- |
---|
| 116 | elsif( $cgi->param("check") ){ |
---|
| 117 | my($userid)= $cgi->param("userid"); |
---|
| 118 | if(length($userid)<4 || length($userid)>24){ |
---|
| 119 | HttpError("input UserID 4-24 bytes."); |
---|
| 120 | } |
---|
| 121 | if($userid=~/[^0-9A-Za-z\@\_\-\']/){ |
---|
| 122 | HttpError("Illeagal charactor found in UserID."); |
---|
| 123 | } |
---|
| 124 | open PIPE,"$perl $ladmin --search --regex \\b$userid\\b |" |
---|
| 125 | or HttpError("Can't execute ladmin."); |
---|
| 126 | my(@msg)=<PIPE>; |
---|
| 127 | close PIPE; |
---|
| 128 | if(scalar(@msg)==6 && (split /[\s\0]+/,substr($msg[4],11,24))[0] eq $userid){ |
---|
| 129 | HttpMsg("NG : UserID \"$userid\" is already used."); |
---|
| 130 | }elsif(scalar(@msg)==5){ |
---|
| 131 | HttpMsg("OK : You can use UserID \"$userid\""); |
---|
| 132 | } |
---|
| 133 | HttpError("ladmin error ?\n---output---\n",@msg); |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | # ----- tH[ ----- |
---|
| 137 | else{ |
---|
| 138 | print LangConv( <<"EOM" ); |
---|
| 139 | Content-type: text/html\n |
---|
| 140 | <html> |
---|
| 141 | <head> |
---|
| 142 | <title>Athena account making cgi</title> |
---|
| 143 | </head> |
---|
| 144 | <body> |
---|
| 145 | <h1>Athena account making cgi</h1> |
---|
| 146 | <form action="$cgiuri" method="post"> |
---|
| 147 | <table border=2> |
---|
| 148 | <tr> |
---|
| 149 | <th>UserID</th> |
---|
| 150 | <td><input name="userid" size=24 maxlength=24></td> |
---|
| 151 | </tr> |
---|
| 152 | <tr> |
---|
| 153 | <th>Password</th> |
---|
| 154 | <td><input name="passwd" size=24 maxlength=24 type="password"></td> |
---|
| 155 | </tr> |
---|
| 156 | <tr> |
---|
| 157 | <th>Gender</th> |
---|
| 158 | <td> |
---|
| 159 | <input type="radio" name="gender" value="male">Male |
---|
| 160 | <input type="radio" name="gender" value="female">Female |
---|
| 161 | </td> |
---|
| 162 | </tr> |
---|
| 163 | <tr> |
---|
| 164 | <td colspan=2> |
---|
| 165 | <input type="submit" name="addaccount" value="Make Account"> |
---|
| 166 | <input type="submit" name="check" value="Check UserID"> |
---|
| 167 | </td> |
---|
| 168 | </tr> |
---|
| 169 | </table> |
---|
| 170 | </form> |
---|
| 171 | </body> |
---|
| 172 | </html> |
---|
| 173 | EOM |
---|
| 174 | exit; |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | sub LangConv { |
---|
| 178 | my(@lst)= @_; |
---|
| 179 | my($a,$b,@out)=(); |
---|
| 180 | foreach $a(@lst){ |
---|
| 181 | foreach $b(keys %langconv){ |
---|
| 182 | $a=~s/$b/$langconv{$b}/g; |
---|
| 183 | my($rep1)=$1; |
---|
| 184 | $a=~s/\$1/$rep1/g; |
---|
| 185 | } |
---|
| 186 | push @out,$a; |
---|
| 187 | } |
---|
| 188 | return @out; |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | sub HttpMsg { |
---|
| 192 | my($msg)=join("", LangConv(@_)); |
---|
| 193 | $msg=~s/\n/<br>\n/g; |
---|
| 194 | print LangConv("Content-type: text/html\n\n"),$msg; |
---|
| 195 | exit; |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | sub HttpError { |
---|
| 199 | my($msg)=join("", LangConv(@_)); |
---|
| 200 | $msg=~s/\n/<br>\n/g; |
---|
| 201 | print LangConv("Content-type: text/html\n\n"),$msg; |
---|
| 202 | exit; |
---|
| 203 | } |
---|
| 204 | |
---|