如果7月12日老版的个人网盘h5ai没有密码,后根据网友提供的代码加入验证密码后,总是自动删除用户名和密码,而进不了是什么问题呢?
加的两种验证代码分别如下:
1.修改: /var/www/html/files/_h5ai/public/index.php
在第二行加如下代码:
$authorization = false;
if($SERVER['PHP_AUTH_USER'] == "admin" && $SERVER['PHP_AUTH_PW'] == "更换你的密码"){
//echo "login";
$authorization = true;
// exit;
}
if(!$authorization){
header("WWW-Authenticate:Basic realm='Private'");
header('HTTP/1.0 401 Unauthorized');
print "You are unauthorized to enter this area.";
}
2.给网盘加个密码:
找到位于/var/www/html/files/_h5ai/public下的index.php文件,双击打开,在第一行"<?php"后换行输入"auth();"再次回车换行,注意这里的""均用做强调说明,
在文件的最后加入如下内容,并填入对应的用户名和密码,保存即可。
function auth (){
$valid_passwords = array ("你的用户名" => "你的密码");
$valid_users = array_keys($valid_passwords);
$user = $SERVER['PHP_AUTH_USER'];
$pass = $SERVER['PHP_AUTH_PW'];
$validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);
if (!$validated) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
die ("Not authorized");
}
}
未加之前的index.php是这样的 :
<?php
define('H5AI_VERSION', '0.30.0');
define('MIN_PHP_VERSION', '7.0.0');
if (!function_exists('version_compare') || version_compare(PHP_VERSION, MIN_PHP_VERSION, '<')) {
header('Content-type: text/plain;charset=utf-8');
exit('[ERR] h5ai requires PHP ' . MIN_PHP_VERSION . ' or later, but found PHP ' . PHP_VERSION);
}
if (substr(H5AI_VERSION, 0, 1) === '{') {
header('Content-type: text/plain;charset=utf-8');
exit('[ERR] h5ai sources must be preprocessed to work correctly');
}
require_once DIR . '/../private/php/class-bootstrap.php';
Bootstrap::run();
两种方法都试过了,都是一样,出现验证界面后,输入正确的用户名及密码后,马上清空用户名及密码,多次循环。代码和输入肯定没错。请大侠指教!