Просмотр полной версии : пароль на ст на страницу index.php черезраницу index.php через php скрипт кто знает ?
раньше ставил скрипт типо security.php
и на страницы которые хотел разместить пароль
указывал
include "security.php";
и все норм было пока хард не улител =)
может кто встречал такое ?
через админку хостинга не предлогать
security.php:
<?php
session_start();
$login = 'admin';
$password = 'admin';
if(empty($_SESSION['logined'])) {
if(isset($_POST['login'],$_POST['password']) && !is_array($_POST['login']) && !is_array($_POST['password']) && $_POST['login'] == $login && $_POST['password'] == $password)
$_SESSION['logined'] = 1;
else {
echo '
<form method = "POST">
<input type = "text" name = "login">
<input type = "password" name = "password">
<input type = "submit">
</form>
';
die;
}
} else if(isset($_SESSION['logined'],$_GET['exit'])) {
$_SESSION['logined'] = NULL;
unset($_SESSION['logined']);
}
?>
выходить - file.php?exit
FireFenix
07.06.2009, 10:23
лучше тогда в .htaccesss прописать авторизацию
security.php:
<?php
include("bd.php");
if (!isset($_SERVER['PHP_AUTH_USER']))
{
Header ("WWW-Authenticate: Basic realm=\"Admin Page\"");
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']);
}
$query = "SELECT pass FROM userlist WHERE user='".$_SERVER['PHP_AUTH_USER']."'";
$lst = @mysql_query($query);
if (!$lst)
{
Header ("WWW-Authenticate: Basic realm=\"Admin Page\"");
Header ("HTTP/1.0 401 Unauthorized");
exit();
}
if (mysql_num_rows($lst) == 0)
{
Header ("WWW-Authenticate: Basic realm=\"Admin Page\"");
Header ("HTTP/1.0 401 Unauthorized");
exit();
}
$pass = @mysql_fetch_array($lst);
if ($_SERVER['PHP_AUTH_PW']!= $pass['pass'])
{
Header ("WWW-Authenticate: Basic realm=\"Admin Page\"");
Header ("HTTP/1.0 401 Unauthorized");
exit();
}
}
?>
в bd.php
<?
$db = mysql_connect ("localhost","root","");
mysql_select_db("www",$db);
?>
в пхпмуадмине
# # Структура таблицы `userlist` # CREATE TABLE `userlist` ( `id` int(3) NOT NULL auto_increment, `user` varchar(50) NOT NULL default '', `pass` varchar(50) NOT NULL default '', PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=2 ; # # Дамп данных таблицы `userlist` # INSERT INTO `userlist` VALUES (1, 'adminr', 'admin');
Nelzone - это ты не у Алексея Попова случайно взял ? :-)
Ru}{eeZ - спасиб попробую.
Nelzone
я отказался от него по причина прописал все норм мне он пишет
Warning: Cannot modify header information - headers already sent by (output started at /home/content/a/n/d/andrey25/html/admin/index.php:8) in /home/content/a/n/d/andrey25/html/admin/security.php on line 6
Warning: Cannot modify header information - headers already sent by (output started at /home/content/a/n/d/andrey25/html/admin/index.php:8) in /home/content/a/n/d/andrey25/html/admin/security.php on line 7
6 и 7 lines
это
Header ("WWW-Authenticate: Basic realm=\"Admin Page\"");
Header ("HTTP/1.0 401 Unauthorized");
у тебя не было такова бага ?
wildshaman
07.06.2009, 13:17
Сохраняй в utf8 без BOM
to 9822
а чем тебя мой вариант не устраивает?
зачем лишние строчки кода когда .htaccess + авторизация делает тоже самое....
все норм я проверял..
вот кусочик админки из wr
http://rapidshare.com/files/241791822/memb.rar.html
Nelzone вспомнил в чем прикол =)) и на что злой на попова был, сам виноват =))
надо <?php include("security.php"); ?> ставить перед HTML кодом вспомнил когда писал движек, так этуже ошибку мне выдовал ;)
вдруг у кого проблеммы будуд такие.
Ru}{eeZ
сейчас мини движек пишу, там твой вариант поставлю ;)
у меня уже была создана таблица со всеми что Nelzone писал.
у нас хотсинг в USA какойто левый там баг с .htaccess
vBulletin® v3.8.14, Copyright ©2000-2026, vBulletin Solutions, Inc. Перевод: zCarot