PHP and MySQL Web Development - P68

PHP and MySQL Web Development - P68: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | Using Basic Authentication with Apache s .htaccess Files 307 The line require valid-user specifies that any valid user is to be allowed access. Listing .htpass The Password File Stores Usernames and Each User s Encrypted Password user1 0nRp9M80GS7zM user2 user3 yjQMCPWjXFTzU user4 LOmlMEi hAme2 Each line in the .htpass file contains a username a colon and that user s encrypted password. The exact contents of your .htpass file will create it you use a small program called htpasswd that comes in the Apache distribution. The htpasswd program is used in one of the following ways htpasswd -cmdps passwordfile username or htpasswd -b cmdps passwordfile username password The only switch that you need to use is -c. Using -c tells htpasswd to create the file. You must use this for the first user you add. Be careful not to use it for other users because if the file exists htpasswd will delete it and create a new one. The optional m d p or s switches can be used if you want to specify which encryption algorithm including no encryption you would like to use. The b switch tells the program to expect the password as a parameter rather than prompting for is useful if you want to call htpasswd noninteractively as part of a batch process but should not be used if you are calling htpasswd from the command line. The following commands created the file shown in Listing htpasswd -bc home book .htpass user1 pass1 htpasswd -b home book .htpass user2 pass2 htpasswd -b home book .htpass user4 pass3 htpasswd -b home book .htpass user4 pass4 This sort of authentication is easy to set up but there are a few problems with using a .htaccess file this way. Users and passwords are stored in a text file. Each time a browser requests a file that is protected by the .htaccess file the server must parse the .htaccess file and then parse the password file attempting to match the username and password. Rather than using an .htaccess file we could specify the same

Không thể tạo bản xem trước, hãy bấm tải xuống
1    36    1    21-03-2023
98    17    1    21-03-2023
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.