لمحترفي الويبPHP - معمو — الصفحة ٢٠١

201 مخططات المصادقة في PHP البرنامج النصي file_authentication.php (تابع) <br>Password: <input type="password" name="addpass"> <br><input type="submit" name="add" value="Add User!"> </form> 43. 44. 45. 46. <? 47. } 48. 50. 51. 49. function add_user($adduser, $addpass) { global $password_file; if(!$fh= fopen($password_file, "a+")) { die("<P>Could Not Open Password File"); } 52. rewind ($fh); 53. while(feof($fh)) { 54. 55. 56. 57. 58. $line = fgets($fh, 4096); $user_pass = explode(":", $line); if($user_pass [0] == $adduser) { echo "<h2>Duplicate Login. Invalid!</h2>"; return 0; 59. } 60. } 61. 62. 63. 64. $add = $adduser ":" md5 ($addpass) "\n"; if(!fwrite($fh, $add)) { die("<P>Could Not Write To Password File"); } fclose($fh); echo "<h2>User Added!</h2>"; 65. } 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 77. /***** MAIN *****/ if(isset($checkpass)) { if (check_pass ($login, $password)) { echo " } else { <h2>Login Success!</h2>"; echo "<h2>Login Failed</h2><p>Bad username or password. Login and Password are case-sensitive. Try again:"; print_login_form($login); } } elseif(isset($add_form)) { print_add_form(); 76. } elseif(isset($add)) { · add_user($adduser, $addpass);
ص٢٠١

نص مستخرج آليًا من الصورة، وقد يقع فيه خطأ.