Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
писал не я, но почти то что тебе нужно:
PHP:<?php if (!isset($_SERVER['PHP_AUTH_USER'])) { Header ("WWW-Authenticate: Basic realm=\"Enter Login/Password\""); Header ("HTTP/1.0 401 Unauthorized"); exit(); } else { if (!get_magic_quotes_gpc()) { $_SERVER['PHP_AUTH_USER'] = mysql_escape_string($_SERVER['PHP_AUTH_USER']); $_SERVER['PHP_AUTH_PW'] = mysql_escape_string($_SERVER['PHP_AUTH_PW']); } @$p = $_SERVER['PHP_AUTH_USER']; $lst = mysql_query("SELECT password FROM users WHERE username='$p' and is_moder='1'") or die(mysql_error()); if (!$lst) { Header ("WWW-Authenticate: Basic realm=\"Введите Логин и Пароль\""); Header ("HTTP/1.0 401 Unauthorized"); exit(); } if (mysql_num_rows($lst) == 0) { Header ("WWW-Authenticate: Basic realm=\"Введите Логин и Пароль\""); Header ("HTTP/1.0 401 Unauthorized"); exit(); } $pass = @mysql_fetch_array($lst); if ($_SERVER['PHP_AUTH_PW']!= $pass['password']) { Header ("WWW-Authenticate: Basic realm=\"Введите Логин и Пароль\""); Header ("HTTP/1.0 401 Unauthorized"); exit(); } } ?>
И накроется эта авторизация медным тазом, если PHP установлен как *CGI
[SIZE=1][COLOR=#0000c0][SIZE=2][COLOR=#000000]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<LINK href="design/style.css" rel=stylesheet type=text/css>
<title>Заголовок</title>
</head>
<body>
<div align="center">
<center>
<table border="0" width="70%" cellspacing="3" cellpadding="3" height="100%">
<tr>
<td width="100%">
<div align="center">
<center>
<table border="0" width="360" height="200" cellspacing="1" cellpadding="0">
<tr>
<td width="20" bgcolor="#FF0000" valign="top"> </td>
<td width="340" bgcolor="#85C329" valign="top">
<table border="0" width="100%" cellspacing="5" cellpadding="5">
<tr>
<td width="5%"><img border="0" src="design/main.gif" width="61" height="61"></td>
<td width="95%">
<h1>Вход</h1>
</td>
</tr>
<tr>
<td width="100%" colspan="2"> </td>
</tr>
<tr>
<td width="100%" colspan="2">Введите пароль:</td>
</tr>
<tr>
<td width="100%" colspan="2" bgcolor="#ABD966">
ФОРМА
</center></center>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<center>
</table>
</center>
</div>
</body>
</html>
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=1][COLOR=#0000c0][SIZE=1][COLOR=#0000c0]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=1][/SIZE]
<?php
$fp = fopen(dirname(__FILE__).'/passwords.txt','r');
$list = array();
while($str = fgets($fp)) $list[] = trim($str);
$form = '';
$pass = trim($_REQUEST[pass]);
if (!$pass) {
$form .= "<br><br><form>Пароль:";
$form .= "<input type=password name=pass>";
$form .= "<input type=submit value=Go></form>";
}
if ($pass && in_array($pass, $list)) {
header("Location: http://site.com/secretfolder/");
die();
} else if ($pass) {
$form .= "<br><font color=red><b>Неверный пароль</b></font>";
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<LINK href="design/style.css" rel=stylesheet type=text/css>
<title>Заголовок</title>
</head>
<body>
<div align="center">
<center>
<table border="0" width="70%" cellspacing="3" cellpadding="3" height="100%">
<tr>
<td width="100%">
<div align="center">
<center>
<table border="0" width="360" height="200" cellspacing="1" cellpadding="0">
<tr>
<td width="20" bgcolor="#FF0000" valign="top"> </td>
<td width="340" bgcolor="#85C329" valign="top">
<table border="0" width="100%" cellspacing="5" cellpadding="5">
<tr>
<td width="5%"><img border="0" src="design/main.gif" width="61" height="61"></td>
<td width="95%">
<h1>Вход</h1>
</td>
</tr>
<tr>
<td width="100%" colspan="2"> </td>
</tr>
<tr>
<td width="100%" colspan="2">Введите пароль:</td>
</tr>
<tr>
<td width="100%" colspan="2" bgcolor="#ABD966">
<?php echo $form;?>
</center></center>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<center>
</table>
</center>
</div>
</body>
</html>
<?php
$fp = fopen(dirname(__FILE__).'/passwords.txt','r');
$list = array();
while($str = fgets($fp)) $list[] = trim($str);
$form = '';
$pass = trim($_REQUEST[pass]);
if (!$pass) {
$form .= "<br><br><form>Пароль:";
$form .= "<input type=password name=pass>";
$form .= "<input type=submit value=Go></form>";
}
if ($pass && in_array($pass, $list)) {
header("Location: http://site.com/secretfolder/");
die();
} elseif ($pass) {
$form .= "<br><font color=red><b>Неверный пароль</b></font>";
}
else($pass == 0) {}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<LINK href="design/style.css" rel=stylesheet type=text/css>
<title>Заголовок</title>
</head>
<body>
<div align="center">
<center>
<table border="0" width="70%" cellspacing="3" cellpadding="3" height="100%">
<tr>
<td width="100%">
<div align="center">
<center>
<table border="0" width="360" height="200" cellspacing="1" cellpadding="0">
<tr>
<td width="20" bgcolor="#FF0000" valign="top"> </td>
<td width="340" bgcolor="#85C329" valign="top">
<table border="0" width="100%" cellspacing="5" cellpadding="5">
<tr>
<td width="5%"><img border="0" src="design/main.gif" width="61" height="61"></td>
<td width="95%">
<h1>Вход</h1>
</td>
</tr>
<tr>
<td width="100%" colspan="2"> </td>
</tr>
<tr>
<td width="100%" colspan="2">Введите пароль:</td>
</tr>
<tr>
<td width="100%" colspan="2" bgcolor="#ABD966">
<?php echo $form;?>
</center></center>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<center>
</table>
</center>
</div>
</body>
</html>
<?php
$fp = fopen(dirname(__FILE__).'/passwords.txt','r');
$list = array();
while($str = fgets($fp)) $list[] = trim($str);
$form = '';
$pass = trim($_REQUEST[pass]);
if (!$pass) {
$form .= "<br><br><form>Пароль:";
$form .= "<input type=password name=pass>";
$form .= "<input type=submit value=Go></form>";
}
if ($pass && in_array($pass, $list)) {
header("Location: http://site.com/secretfolder/");
die();
} elseif ($pass) {
$form .= "<br><font color=red><b>Неверный пароль</b></font>";
}
elseif($pass == 0) { }
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<LINK href="design/style.css" rel=stylesheet type=text/css>
<title>Заголовок</title>
</head>
<body>
<div align="center">
<center>
<table border="0" width="70%" cellspacing="3" cellpadding="3" height="100%">
<tr>
<td width="100%">
<div align="center">
<center>
<table border="0" width="360" height="200" cellspacing="1" cellpadding="0">
<tr>
<td width="20" bgcolor="#FF0000" valign="top"> </td>
<td width="340" bgcolor="#85C329" valign="top">
<table border="0" width="100%" cellspacing="5" cellpadding="5">
<tr>
<td width="5%"><img border="0" src="design/main.gif" width="61" height="61"></td>
<td width="95%">
<h1>Вход</h1>
</td>
</tr>
<tr>
<td width="100%" colspan="2"> </td>
</tr>
<tr>
<td width="100%" colspan="2">Введите пароль:</td>
</tr>
<tr>
<td width="100%" colspan="2" bgcolor="#ABD966">
<?php echo $form;?>
</center></center>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<center>
</table>
</center>
</div>
</body>
</html>