public void start() { try { /////// tools.ask_no_clinet_echo(); tools.reset_color(); tools.set_cursor_loc_org(); tools.clearscreen(); bool check_ok = false; while (tcc.Connected) { tools.set_cursor_loc_org(); tools.printfile(@"/etc/wellcome.ansi"); tools.print("歡迎來到 erspicu_brox 的 bbs ", 14, 0); tools.print("(或以guest參觀,new註冊帳號)", 17, 0); tools.print("請輸入登入帳號 : ", 16, 0); tools.print_inputbox(12, ConsoleColor.Red, ConsoleColor.White); string loginid = tools.get_input_line(10); tools.reset_color(); if (loginid == "new") { registration(); check_ok = true; } else if (loginid == "guest") { clinet_profile = new clinet_datastruct(); clinet_profile.id = "guest"; clinet_profile.passwd = ""; clinet_profile.nickman = "我是訪客"; clinet_profile.mail = ""; check_ok = true; } else { check_ok = login_check(loginid); } //最後進入主選單 if (check_ok == true) { Console.WriteLine(clinet_profile.id + " (" + tcc.GetHashCode().ToString() + ") " + "登入"); system_main_menu(); } } Console.WriteLine("Clinet已登出."); } catch { Console.WriteLine("Clinet(" + tcc.GetHashCode().ToString() + ") 已關閉連結"); } }
public bool login_check(string id) { //檢查此帳號是否存在 if (!File.Exists(Directory.GetCurrentDirectory() + "/UserID/" + id + "/.PassWord")) { tools.print("此帳號不存在,按任意鍵繼續..", 20, 0); tools.pause(); tools.set_cursor_loc(20, 0); tools.clear_cursor2LineEnd(); return false; } //輸入密碼 tools.print("請輸入密碼 : ", 18, 0); tools.print_inputbox(12, ConsoleColor.DarkBlue, ConsoleColor.White); string passwd = tools.get_input_password(10, '*'); tools.reset_color(); string sha1 = File.OpenText(Directory.GetCurrentDirectory() + "/UserID/" + id + "/.PassWord").ReadToEnd(); while (sha1 != tools.get_sha1(passwd)) { tools.print("密碼錯誤,按任意鍵繼續...", 20, 0); tools.pause(); tools.set_cursor_loc(20, 0); tools.clear_cursor2LineEnd(); tools.print("請輸入密碼 : ", 18, 0); tools.print_inputbox(12, ConsoleColor.DarkBlue, ConsoleColor.White); passwd = tools.get_input_password(10, '*'); tools.reset_color(); } tools.print("帳號密碼確認無誤,按任意鍵繼續...", 20, 0); tools.pause(); clinet_profile = new clinet_datastruct(); clinet_profile.id = id; return true; }
public void registration() { tools.clearscreen(); bool check_ok = false; string newid = ""; while (check_ok == false) { tools.print("請輸入註冊帳號 : ", 2, 5); tools.print_inputbox(10, ConsoleColor.Red, ConsoleColor.White); newid = tools.get_input_line(12); //判斷是否已被註冊過 if (Directory.Exists(Directory.GetCurrentDirectory() + "/UserID/" + newid + "/")) { tools.reset_color(); tools.print("本ID已被註冊過,請改換註冊ID", 3, 5); check_ok = false; } else { tools.set_cursor_loc(3, 5); tools.clear_cursorLine(); check_ok = true; tools.reset_color(); tools.print("OK!", 2, 0); Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/UserID/" + newid + "/"); } } // tools.print("請輸入註冊密碼 : ", 4, 5); tools.print_inputbox(10, ConsoleColor.Red, ConsoleColor.White); string passwd = tools.get_input_password(10, '*'); tools.reset_color(); tools.print("OK!", 4, 0); tools.print("請輸入暱稱 : ", 6, 5); tools.print_inputbox(10, ConsoleColor.Red, ConsoleColor.White); string nickname = tools.get_input_line(10); tools.reset_color(); tools.print("OK!", 6, 0); tools.print("請輸電子信箱 : ", 8, 5); tools.print_inputbox(22, ConsoleColor.Red, ConsoleColor.White); string mailurl = tools.get_input_line(20); tools.reset_color(); tools.print("OK!", 8, 0); clinet_profile = new clinet_datastruct(); clinet_profile.id = newid; clinet_profile.nickman = nickname; clinet_profile.passwd = passwd; clinet_profile.mail = mailurl; //建立帳號 File.WriteAllText(Directory.GetCurrentDirectory() + "/UserID/" + newid + "/" + ".PassWord", tools.get_sha1(passwd)); tools.print("恭喜!註冊完畢.按任意鍵繼續..", 10, 5); tools.pause(); }