| Вот написал я код для админки...но вот проблема одна..когда я захожу на неё он сразу показывает чтобы я ввёл пароль в сразу всё для администрирование!!!что делать ??
Вот код admin.php
<?
error_reporting(0);
if (file_exists("passwd.dat") && $QUERY_STRING != ""):
require ("passwd.dat");
if (!isset($alogin) || md5($pass) != $Password[$alogin] || !isset($Password[$alogin])):
$logined = 0;
$error = "Неверный логин или пароль!<br>";
setcookie("alogin","",0);
setcookie("pass","",0);
else:
$logined = 1;
setcookie("alogin",$alogin);
setcookie("pass",$pass);
endif;
endif;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Администрирование</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head>
<style>
A:hover {COLOR: #FF0066}
a {text-decoration : none}
</style>
<body link="#000000" vlink="#000000" bgcolor="#ffffe6">
<table width=600 border=0 cellspacing=1 cellpadding=3 bgcolor=#CCCCCC>
<tr>
<td align=center class=p bgcolor=#E8E8FF>
<b>Администрирование</b>
</td>
</tr>
</table>
<?
if (!file_exists("passwd.dat") && $QUERY_STRING == "login"):
echo "</td></tr><tr><td><table border=0 cellpadding=0 cellspacing=0 width=600 height=4><tr><td height=4></td></tr></table><table width=600 border=0 cellspacing=1 cellpadding=3 bgcolor=#CCCCCC><tr><td align=center class=p bgcolor=#FFFFFF>Сейчас будет создан файл с паролем...</b></td></tr></table>";
if (isset($alogin) and $alogin != "" and isset($pass) and $pass != ""):
$file = fopen("passwd.dat","w");
fputs($file,"<?php\r\n\$Password['$alogin'] = \"".md5($pass)."\";\r\n?>");
fclose($file);
echo "</td></tr><tr><td><table border=0 cellpadding=0 cellspacing=0 width=600 height=4><tr><td height=4></td></tr></table><table width=600 border=0 cellspacing=1 cellpadding=3 bgcolor=#CCCCCC><tr><td align=center class=p bgcolor=#FFFFFF>Файл с паролем создан успешно!</b></td></tr></table>";
echo "</td></tr><tr><td><table border=0 cellpadding=0 cellspacing=0 width=600 height=4><tr><td height=4></td></tr></table><table width=600 border=0 cellspacing=1 cellpadding=3 bgcolor=#CCCCCC><tr><td align=center class=p bgcolor=#FFFFFF><b>Теперь можете смело входить в админ.центр! Удачи!</b></td></tr></table>";
else: echo "</td></tr><tr><td><table border=0 cellpadding=0 cellspacing=0 width=600 height=4><tr><td height=4></td></tr></table><table width=600 border=0 cellspacing=1 cellpadding=3 bgcolor=#CCCCCC><tr><td align=center class=p style=\"color:#FFFFFF\" bgcolor=#FF0000><b>Файл с паролем не создан! Недостаточно параметров!</b></td></tr></table>";
endif;
endif;
if ($logined):
include("config.inc.php");
function cut($string)
{
$string = ereg_replace('\\\"',""",$string);
$string = ereg_replace("\\\'",""",$string);
$string = str_replace(":",":",$string);
$string = str_replace("\r","",$string);
$string = str_replace("\n","<br>",$string);
$string = str_replace("%","%",$string);
$string = str_replace("^ +","",$string);
$string = str_replace(" +$","",$string);
$string = str_replace(" +"," ",$string);
return ($string);
}
else:
if($error!="") echo "</td></tr><tr><td><table border=0 cellpadding=0 cellspacing=0 width=600 height=4><tr><td height=4></td></tr></table><table width=600 border=0 cellspacing=1 cellpadding=3 bgcolor=#CCCCCC><tr><td align=center class=p style=\"color:#FFFFFF\" bgcolor=#FF0000><b>$error</b></td></tr></table>";
?>
<table width=600 border=0 cellspacing=1 cellpadding=3 bgcolor=#CCCCCC>
<form action=../../admin.php?login method=post>
<tr>
<td bgcolor=#E8E8FF align=center>
<b>Вход в админ.центр:</b>
</td>
</tr>
<tr>
<td bgcolor=#FFFFFF>
<table>
<tr>
<td width=210 align=right>
Логин:
</td>
<td class=p width=390 align=left>
<input type=text name=alogin size=30>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor=#FFFFFF>
<table>
<tr>
<td width=210 align=right>
Пароль:
</td>
<td width=390 align=left>
<input type=password name=pass size=30>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align=center bgcolor=#FFFFFF>
<input type=submit value="Войти" style="width:100px;cursor:hand;" onmouseover="this.style.backgroundColor='#E8E8FF';" onmouseout="this.style.backgroundColor='#FFFFFF';">
</td>
</tr>
</form>
</table>
<?php
if (!file_exists("passwd.dat"))
echo "</td></tr><tr><td><table border=0 cellpadding=0 cellspacing=0 width=600 height=4><tr><td height=4></td></tr></table><table width=600 border=0 cellspacing=1 cellpadding=3 bgcolor=#CCCCCC><tr><td align=center class=p bgcolor=#FFFFFF>Вы входите в админ.центр в первый раз!<br>Введите любой логин и пароль (они будут использоваться и в будущем).</td></tr></table>";
endif;
?>
<h2 align="center">Удаление фотографий</h2>
<?
$directory ="..";
$readfolder = opendir($directory);
while($file = readdir($readfolder))
{
if($file != ".." && $file != ".") $files[] = $file;
}
closedir($readfolder);
for($n=0;$n<count($files);$n++)
{
?>
<table border="1">
<tr>
<td>
<?
if (substr($files[$n],-4) == ".jpg") echo "<a href=delete.php?filename=$directory/"."$files[$n]>$files[$n]</a><br>";
?>
</td>
<td>X</td>
</tr>
</table>
<?
}
?>
<h2 align="center">Новости</h2>
<form action="../../msg.php" method="get">
<textarea name="msg" cols="" rows="" >
<? $fp = fopen ("../msg.dat", "r");
$buffer = fread($fp, 200);
fclose ($fp);
print $buffer;
?>
</textarea><br>
<input name="Изменить" type="submit">
</form>
<h2 align="center">Сообщение между админами</h2>
<font size="-1">В разработке.........</font>
</body>
</html> | |