源代码如下:
<?php
function authenticate_user() {
header(\'WWW-Authenticate: Basic realm=\"Secret Stash\"\');
header(\"HTTP/1.0 401 Unauthorized\");
exit;
}
if (! isset($_SERVER[\'PHP_AUTH_USER\'])) {
authenticate_user();
} else {
mysql_pconnect(\"localhost\",\"authenticator\",\"secret\") or die(\"Can\'t connect to data server!\");
mysql_select_db(\"db\") or die(\"Can\'t select authentication data !\");
$query = \"SELECT username, pswd FROM user WHERE username=\'$_SERVER[PHP_AUTH_USER]\' AND pswd=MD5(\'$_SERVER[PHP_AUTH_PW]\')\";
$result = mysql_query($query);
// If nothing was found, reprompt the user for the login information.
if (mysql_num_rows($result) == 0) {
authenticate_user();
}
}
?>
继续阅读与本文标签相同的文章
下一篇 :
获得云计算支持的六大新兴技术
-
健乐教学机器人可开展的教学实训内容
2026-05-14栏目: 教程
-
5G套餐曝光遭“吐槽”,iphone11受追捧,导致苹果11销量比较高
2026-05-14栏目: 教程
-
为什么修电脑的叫自己不要杀毒和清理垃圾?
2026-05-14栏目: 教程
-
当水乡建筑遇上机器人,成就乌镇又一网红景点
2026-05-14栏目: 教程
-
惊险!手刹失灵,郴州一货车开启“无人驾驶”模式……
2026-05-14栏目: 教程
