Storage Program

  • Uploaded by: Frank
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Storage Program as PDF for free.

More details

  • Words: 992
  • Pages: 7
#!/usr/bin/perl #Programmed by FLJR90 "FrankQC" system("clear"); &program_start; sub program_start { print "If adding someone, press enter twice.\n\n"; print "u/ "; chomp($registered_user_username = <>); print "p/ "; chomp($registered_user_password = <>); if(($registered_user_username eq "admin") && ($registered_user_password eq "admin")) { &client_approved; } elsif(($registered_user_username eq "admin") || ($registered_user_password != "admin")) { &wrong_password; } elsif(($registered_user_username eq "exit") && ($registered_user_password eq "exit")) { exit; }else{ &ask_registration; } } sub ask_registration { system("clear"); print "Answer the following with \"yes\" or \"no\".\n"; print "\n"; print "Add User?> "; chomp($register_question = <>); if($register_question eq "yes") { &client_register_yes; } elsif($register_question eq "no") { &client_register_no; }else{ print "Input \"$register_question\" does not exist.\n";

&ask_registration; }

} sub client_register_yes{

print "Name > "; chomp($new_name = <>); print "E-Mail > "; chomp($new_email = <>); &client_register_confirmation; } sub client_register_no { print "Are you sure?>

"; chomp($you_sure = <>);

if($you_sure eq "yes") {

¬_registered; }

}

elsif($you_sure eq "no") { &ask_registration; }else{ print "Unknown command...\n"; &ask_registration; }

sub client_register_confirmation { print print print print print print

"\nYou have specified the following...\n"; "----------\n"; "Name: $new_name\n"; "E-Mail: $new_email\n"; "----------\n"; "Is this right?> "; chomp($you_sure = <>); if($you_sure eq "yes") { &log_file; } elsif($you_sure eq "no") { system("clear"); &client_register_yes; }else{ print "Input \"$you_sure\" does not

exist."; }

system("clear"); &client_register_confirmation;

} sub thank_you { system("clear"); print "$new_name has been added.\n"; &program_start;

}

sub client_approved { system("clear"); print "Logged in as $registered_user_username.\n"; print color 'bold blue'; print "For a list of commands, type: /?\n"; print color 'reset'; &choose_operations; } sub choose_operations { use Term::ANSIColor; print ">

}

"; chomp($operation_selection = <>);

if($operation_selection eq "/showusers") { &show_clients; elsif($operation_selection eq "/showusers?") {

were added.\n";

print color 'bold blue'; print "/showuser tells you, in a list, which users print color 'reset'; &choose_operations;

}

}

rid of older text.\n"; }

}

the program.\n";

elsif($operation_selection eq "/clear") { system("clear"); &choose_operations; elsif($operation_selection eq "/clear?") { print color 'bold blue'; print "/clear clears up the terminal screen. Gets print color 'reset'; &choose_operations; elsif($operation_selection eq "/exit") { system("clear"); system("exit"); elsif($operation_selection eq "/exit?") { print color 'bold blue'; print "/exit logs the user out of the program. Exits print color 'reset'; &choose_operations;

}

}

elsif($operation_selection eq "/editusers") { print color 'bold blue'; system("nano clients.txt"); print color 'reset'; &choose_operations;

elsif($operation_selection eq "/editusers?") { print color 'bold blue'; print "/editusers loads a GNU/Nano screen to edit currently added users.\n"; print color 'reset'; &choose_operations; } elsif($operation_selection eq "/?") { print color 'bold blue'; print "\nNote: For more command info, put a \"?\" after it (no spaces).\n\n"; print "/showusers /editusers /clear /exit /proginfo\n"; print "/time /db.backup /db.revert /logoff\n"; print "/db.del.main /db.del.bkp /db.nuke\n"; print "/db.main.check /db.bkp.check /ls\n\n"; print color 'reset'; &choose_operations; } elsif($operation_selection eq "/??") { print color 'bold blue'; print "/? shows the list of commands currently available.\n"; print color 'reset';

&choose_operations; }

Francois.\n"; }

}

}

}

}

clients.txt\n";

elsif($operation_selection eq "/proginfo") { print color 'bold blue'; print "Programmed in Perl 5. Programmed by print color 'reset'; &choose_operations; elsif($operation_selection eq "/proginfo?") { print color 'bold blue'; print "Shows program information.\n"; print color 'reset'; &choose_operations; elsif($operation_selection eq "/time") { system("date"); &choose_operations; elsif($operation_selection eq "/time?") { print color 'bold blue'; print "/time will tell you your system time.\n"; print color 'reset'; &choose_operations; elsif($operation_selection eq "/db.backup") { system("cp clients.txt clients.txt.backup"); &choose_operations; elsif($operation_selection eq "/db.backup?") { print color 'bold blue'; print "/db.backup will create a backup of print color 'reset'; &choose_operations;

}

}

elsif($operation_selection eq "/db.revert") { system("cp clients.txt.backup clients.txt"); &choose_operations;

elsif($operation_selection eq "/db.revert?") { print color 'bold blue'; print "/db.revert will put the database backup as the new database (used if mistake in main database).\n"; print color 'reset'; &choose_operations; } elsif($operation_selection eq "/logoff") { system("clear"); print "Logged off as $registered_user_username.\n"; &program_start; } elsif($operation_selection eq "/logoff?") { print color 'bold blue'; print "/logoff will log you off as admin and bring you back to the login screen.\n"; print color 'reset'; &choose_operations;

} elsif($operation_selection eq "/db.del.main") { &delete_database_main; }

elsif($operation_selection eq "/db.del.main?") { print color 'bold blue'; print "/db.del will delete clients.txt (main database). Password required.\n"; print color 'reset'; &choose_operations; } elsif($operation_selection eq "/db.del.bkp") { &delete_database_backup; } elsif($operation_selection eq "/db.del.bkp?") { print color 'bold blue'; print "/db.del.bkp will delete the backup databases. Password required.\n"; print color 'reset'; &choose_operations; } elsif($operation_selection eq "/db.nuke") { &db_nuke; } elsif($operation_selection eq "/db.main.check") { &db_main_check; } elsif($operation_selection eq "/db.main.check?") { print color 'bold blue'; print "/db.main.check will tell you if the contact list file exists in the directory.\n"; print color 'reset'; &db_main_check; } elsif($operation_selection eq "/db.bkp.check") { &db_backup_check; } elsif($operation_selection eq "/db.bkp.check?") { print color 'bold blue'; print "/db.bkp.check will tell you if the backup file exists.\n"; print color 'reset'; &choose_operations; } elsif($operation_selection eq "/ls") { &list_directory; } elsif($operation_selection eq "/ls?") { print color 'bold blue'; print "/ls will show files in directory.\n"; print color 'reset'; &choose_operations; } elsif($operation_selection eq "/db.nuke?") { print color 'bold blue'; print "/db.nuke will delete all the databases.\n"; print color 'reset'; &choose_operations;

}else{

print "Your input of \"$operation_selection\" does not exist. For help: /?\n\n"; &choose_operations; } } sub list_directory {

}

system("ls"); &choose_operations;

sub db_backup_check { $checkbackup = "clients.txt.backup"; if(-e $checkbackup) { print "Backup exists\n"; &choose_operations; }else{ print "Backup does not exist.\n"; &choose_operations; } } sub db_main_check { $checkmain = "clients.txt"; if(-e $checkmain) { print "Main Database file exists.\n"; &choose_operations; }else{ print "Main Database does not exist.\n"; &choose_operations; } } sub db_nuke { print "Password>

"; chomp($db_nuke = <>);

if($db_nuke eq "deletenow"){ system("rm clients.txt; rm clients.txt~; rm clients.txt.backup; rm clients.txt.backup~"); &choose_operations; }else{ print "Wrong password.\n"; &choose_operations; } sub delete_database_backup {

}

print "Password>

"; chomp($db_bkp_del = <>);

if($db_bkp_del eq "deletenow"){ system("rm clients.txt.backup; rm clients.txt.backup~"); &choose_operations; }else{ print "Wrong password.\n"; &choose_operations; } } sub delete_database_main { print "Password>

"; chomp($db_main_del = <>);

if($db_main_del eq "deletenow") { system("rm clients.txt; rm clients.txt~"); &choose_operations; }else{ print "Wrong password.\n"; &choose_operations; } } sub not_registered { print "User exited.\n\n"; exit; } sub log_file { open (MYFILE, '>>clients.txt'); print MYFILE "Name: [$new_name]; E-Mail: [$new_email];"; print MYFILE "\n"; close (MYFILE); &thank_you; } sub show_clients { open (MYFILE, 'clients.txt'); while (<MYFILE>) { chomp; print "$_\n"; } close (MYFILE); &choose_operations; } sub wrong_password { system("clear"); print "Wrong password\n\n"; &program_start; }

Related Documents

Storage Program
May 2020 18
Storage
May 2020 23
Storage
November 2019 47
Hydrogen Storage
June 2020 18
Vaccine Storage
May 2020 23
Emc Storage
October 2019 25

More Documents from ""

Ct-g2175 Panasonic Diagrama
December 2019 36
May 2020 12
Irc Bot V.2.1
June 2020 15
980908_02rev
May 2020 12
Irc Bot V.2.0
May 2020 16