Last update at :2024-05-05,Edit by888u
With the popularity of large hard disk VPS, many friends have built something similar to a network disk. Among them, H5ai is the more popular. However, although h5ai is powerful, it is inconvenient to use. We also built one ourselves. The problem is that Chinese characters cannot be displayed normally. After struggling for a long time, I gave up. Another criticism of h5ai is that it is open. Anyone who knows your URL can access your files at will. There is no privacy at all. Sometimes it is more difficult if we want to put something indescribable. It is a necessity to add password access to h5ai and protect your files from being accessed by strangers.
In fact, it is not impossible to add password access to h5ai, and the method is also very simple, just use PHP's HTTP authentication, which can be completed with just a few lines of code. However, PHP's HTTP authentication mechanism only works when PHP is running as an Apache module, so this feature does not work with the CGI version.
For more specific information, you can refer to the relevant manuals of PHP. I will not introduce it here. Start directly with this tutorial.
First we need to find this file [_h5ai/public/index.php] and add the following code at the bottom:
functionmima(){
$user=array('138vps','vps138');
If(!($user[0]===$_SERVER['PHP_AUTH_USER'] && $user[1]===$_SERVER['PHP_AUTH_PW'])){
header('WWW-Authenticate: Basic realm="138vps"');
header('HTTP/1.0 401 Unauthorized');
die("please login");
} }
}
Then insert the following code on the first line, that is, below [
mima();
That’s it.
After adding the code, it probably looks like this
You can use the username [138vps] and password [vps138] to access. It is inaccessible without using the username and password.
Recommended site searches: cn domain name, domain name expiration query, foreign virtual host, website registration, purchase space, bgp cloud host in mainland China, registration query, free cn domain name registration, US server rental website, free Domain name registration,
发表评论