성공적으로 로그인하면 월급 데이터를 인쇄해야하는 경우 사용자가 로그인해야하는 임무 (파일에 대한 사용자 이름/비밀번호 확인)가 필요합니다. IN-accounting.data라는 다른 파일에 저장됩니다. ive는 부분적으로 작동하는 사용자 로그를 얻지 만, 이제는 회계 장부에있는 모든 것에 대해 인쇄 할 것이므로 "봉급 지불"부분을 인쇄하는 데 어려움을 겪고 있습니다. 나는 단지 데이터를 인쇄하는 방법을 알아 내는데 도움이 될 수 있습니다. 사용자가 제안 사항에 로그인 했습니까? 이러한 파일과 코드 모든 사회 보장 번호 (SSN), 전화 번호, 주소, 사람들은 할당 이 perl 사용자 로그인 후 월급 데이터 인쇄
가 11-6-12는 제안 된 변경 사항을 반영하기 위해 업데이트, 지금 실행
을 제공 데이터 만있어, 가짜 4cb9c8a8048fd02294477fcb1a41191a : 500 : 25 : 알렉산더 월요일 :/홈/급여/빈/PA 방식은 원래는
#!/usr/bin/perl
use warnings;
use strict;
use Digest::MD5 'md5_hex';
open (PSWD, '<', 'password.passwd');
#getting username and password
#converting username to lowercase if username is entered in CAPS
print "Please enter your username: ";
chomp(my $userN = <STDIN>);
my $username = lc($userN);
############################################
print "Please enter your password: ";
chomp(my $password = <STDIN>);
my $passwd=md5_hex($password);
###############################################
my $matchCount = 0;#used later to make sure username and password match file
#reading password.passwd and assigning values
while (my $lines = <PSWD>){
my($user,$pswd,$userID,$groupID,$info,$home,$shell) = split ':', $lines;
#checking username entered vs that in the passwd file
if ($username eq $user){
print "Checking username... MATCH\n";
$username=$info;
#keeps track if username matches or not
$matchCount+=1;
#checking password entered vs that in the passwd file
if ($passwd eq $pswd){
print "Checking password... MATCH\n";
my ($first,$last)=split(" ", $info);
accounting($first,$last);
}
else{
print "Password does not match!\n";
}
last;
}
}
# if matchcount did not change, username did not match killing the program
if ($matchCount == 0){
die ("\"$username\" does not match any users in our database!\n");
}
sub accounting{
my $first_name=shift;
my $last_name=shift;
open(my $fh, '<', 'IN-accounting.data') or die "cannot open accounting file $!";
while (my $lines = <$fh>){
chomp $lines;
my @fields = split(/\|/, $lines);
push @data2, \@fields;
my($Lname,$Fname,$ssn,$address)=($fields[0],$fields[1],$fields[2],$fields[3]);
my($city,$state,$zip,$payDate)=($fields[4],$fields[5],$fields[6],$fields[7]);
my($hours,$rate,$taxes,$deductions,$notes)= ($fields[8],$fields[9],$fields[10],$fields[11],$fields[12]);
next if $Lname ne $last_name and $Fname ne $first_name;
my ($Gpay)= eval($hours)*eval($rate);#gross pay
my ($Tpay)=$Gpay-($taxes+$deductions);#total pay
my $Essn=substr($ssn,+-4);#edited ssn
print "$Fname $Lname\n";
print "$address\n";
print "$city $state $zip\n";
print "SSN: xxx-xx-$Essn\n";
print"\n";
print "Pay Date: $payDate";
print"\n";
print"You had $hours hours at \$$rate/hour\n";
print"Gross Pay: $Gpay\n";
print"Taxes:\$-$taxes\n";
print"Deductions:\$-$deductions\n";
print"Total Pay: $Tpay\n";
print"\n";
print"Notes:$notes\n\n";
}
print"press enter to quit: ";
my $quit=<>;
if ($quit){ exit;}
}
password.passwd
amon9640에 원 yroll iart1373 : 4cb9c8a8048fd02294477fcb1a41191a : 501 : 25 : 이니 Arterbury :/홈/급여/빈/급여 wher0210 : 4cb9c8a8048fd02294477fcb1a41191a : 502 : 25 : 워델 허먼 :/홈/급여/빈/급여
회계 파일
월요일 | Alexander | 815-19-9640 | 4662 Dewy 세분 | Owltown | 오레곤 | 97434-8480 | 1/18/1998 | 19 | 21.68 | 60.28 | 2.24 | 급여 전문가가 계정을 감사하고 있습니다. 곧.
Arterbury | 037-30-1373 | 987 Rocky Island Byway | 크리스마스 시티 | 뉴 멕시코 | 88023-3889 | 4/1/1993 | 9 | 7.02 | 17.75 | 12.71 | 감사가 완료되었습니다. 결함이 발견되었습니다.
Herman | Wardell | 114-29-0210 | 5555 Cinder Forest Wynd | White Eyes Town | 워싱턴 | 98707-5628 | 10/0/2003 | 37 | 3.07 | 41.90 | 20.89 | 감사가 완료되었습니다. 결함이 발견되었습니다.
누가이 스크립트를 사용합니까? 는 회계 파일과 같은 시스템의 사용자 인 경우, 그들은 이미 스크립트 파일 또는 다른 스크립트가 실행되지 않을 수 모두에 액세스 할 수 있습니다. ([암호화 해시 기능은 암호 해시 함수 수 없다] http://throwingfire.com/storing-passwords-securely/# : 그들은 단지 파일을 읽거나 스크립트 – JRideout
MD5에서 확인 암호를 삭제할 수 있습니다 암호를 사용하는 무시 무시한 해시입니다 notpasswordhashes) – JRideout
아마에 로그인하는 사용자의 애플리케이션 로직 및 서식 출력 기록에서 데이터의 로딩 및 분석을 분리하는 것이 좋습니다 것입니다. 또한 일종의 관계형 데이터베이스에 데이터를 배치하는 것이 개선 될 수 있습니다. 이러한 유형의 데이터 만 위해 작성됩니다. – JRideout