Hej.
Jeg bruger en gæstebog fra
www.hjemesideskolen.dk, til den
gæstebog følger et administrations panel med. Mit problem er: I
samme fil som administrations panelet er et login script. Men da
jeg allerede bruger et andet login script, skal dette fjernes.
Jeg har selv forsøgt, men får fejlmeddelelser.
Jeg har brug for at vide hvordan jeg fjerner login scriptet så
administrations panelet står ubeskyttet til bage. Her kommer
koden:
<?
// *** LOADING CONFIG FILE
include "var.inc.php";
// *** CHECKING ADMIN SESSION
session_start();
if ($_GET[logout]=="y"){
session_destroy();
header("location:".$_SERVER[PHP_SELF]);
}
if ( ($_POST[fuser]==$adm_user) and ($_POST[fpswd]==$adm_pswd) ){
$login=$adm_user."|".$adm_pswd;
session_register("login");
header("location:".$_SERVER[PHP_SELF]);
}
if ( (empty($_SESSION[login])) or
($_SESSION[login]<>$adm_user."|".$adm_pswd) ){
?>
<? $strTitle="Login til gæstebogsadministrationen";?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"
http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title><? echo $strTitle; ?></title>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<link href="gb.css" rel="stylesheet" type="text/css">
<link href="gb.css" rel="stylesheet" type="text/css"
media="print">
</head>
<body>
<div id="indhold">
<h1><? echo $strTitle; ?></h1>
<?
echo "<form action=\"".$_SERVER[PHP_SELF]."\"
method=\"post\">\n";
echo "<fieldset>\n";
echo "<legend>Indtast bruger-ID</legend>\n";
echo "<label for=\"t1\">Brugernavn:</label><input id=\"t1\"
type=\"text\" name=\"fuser\">\n";
echo "<label for=\"t2\">Password:</label><input id=\"t2\"
type=\"password\" name=\"fpswd\">\n";
echo "<label for=\"subm\"> </label><input id=\"subm\"
type=\"submit\" class=\"knapper\" value=\"Login\"
accesskey=\"s\">\n";
echo "</fieldset>";
echo "</form>";
echo "<p>Brugernavn: gaest</p>\n";
echo "<p>Password: lukmigind</p>\n";
?>
</div>
<div id="menu"><? include("menu_adm.inc"); ?></div>
</body>
</html>
<?
} else {
// *** (start) CONTENTS ***
// *** CHECKING FILE EXISTING
if (!file_exists($data)){
disperr("Filen "$data" blev ikke fundet!");
exit;
}
?>
<? $strTitle="Administrationsmodul til gæstebogen";?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"
http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title><? echo $strTitle; ?></title>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<link href="gb.css" rel="stylesheet" type="text/css">
<link href="gb-print.css" rel="stylesheet" type="text/css"
media="print">
<style type="text/css">
..indlag {
border: 1px solid #ccf;
padding: 5px;
margin-bottom: 10px;
}
fieldset {
width: auto;
}
..nobd {
border: none;
margin-bottom: 5px;
width: 300px;
}
</style>
</head>
<body>
<div id="indhold">
<h1><? echo $strTitle; ?></h1>
<?
// *** LOADING DATA
if($file=fopen($data,"r"))
{
while(!feof($file))
{
$contents_old.=fgets($file,255);
}
fclose($file);
}
$contents_old=conv_asc2html($contents_old,2);
$ar_row=explode("|line|",$contents_old);
if ( ($_POST[btedit]=="Ret indlæg") and
(!empty($_POST[line_ed])) ){
$ar_field=explode("|#|",$ar_row[$_POST[line_ed]]);
$ar_field[1]=$_POST[fname];
$ar_field[2]=$_POST[femail];
$ar_field[3]=$_POST[femail_show];
$ar_field[4]=$_POST[fsubject];
$ar_field[5]=$_POST[fcomment];
$ar_row[$_POST[line_ed]]=implode("|#|",$ar_field);
$contents_new=implode("|line|",$ar_row);
if ($file=fopen($data,"w")){
$contents_new=conv_asc2html($contents_new,1);
fputs($file,$contents_new);
fclose($file);
$contents_old=$contents_new;
$contents_old=conv_asc2html($contents_old,2);
$ar_row=explode("|line|",$contents_old);
//echo "\n<script type=<"text/javascript\">\n
alert(\"Posten er blevet ændret!\"); \n</script>\n";
}
}
if ( ($_POST[btdelete]=="Slet indlæg") and
($_POST[del_conf]=="y") and (!empty($_POST[line_ed])) ){
array_splice ($ar_row, $_POST[line_ed], 1);
$contents_new=implode("|line|",$ar_row);
if ($file=fopen($data,"w")){
$contents_new=conv_asc2html($contents_new,1);
fputs($file,$contents_new);
fclose($file);
$contents_old=$contents_new;
$contents_old=conv_asc2html($contents_old,2);
$ar_row=explode("|line|",$contents_old);
//echo "\n<script type\"text/javascript\">\n
alert(\"Posten er blevet slettet!\"); \n</script>\n";
}
}
$recperpage=12;
$row_first=1;
$row_last=count($ar_row)-1;
if (empty($_GET[row_start])){ $_GET[row_start]=$row_first; }
$row_end=$_GET[row_start]+$recperpage-1;
if ($row_end>$row_last){ $row_end=$row_last; }
if ($row_last>$recperpage){
echo "<p>Side: ";
for ($p=1; $p<=ceil($row_last / $recperpage); $p++){
if ($p>1){ $start=((($p-1)*$recperpage)+1);
} else { $start=1; }
if ($p==ceil($_GET[row_start]/$recperpage)){
$tdcol="#cccccc"; } else { $tdcol="#ffffff"; }
echo "[<a class=\"tlink\"
href=\"$PHP_SELF?row_start=$start\">$p</a>] ";
}
echo "</p>\n\n";
}
//echo
"first:$row_first|start:$row_start|end:$row_end|last:$row_last";
echo "<div>\n";
for ($r=$_GET[row_start]; $r<=$row_end; $r++){
$ar_field=explode("|#|",$ar_row[$r]);
$tanggal=$ar_field[0];
$name=$ar_field[1];
$email=$ar_field[2];
$email_show=$ar_field[3];
$subject=$ar_field[4];
$comment=$ar_field[5];
if ($_GET[line]==$r){
echo "<div id=\"d";
echo "$r\">\n";
echo "<form
action=\"".$_SERVER[PHP_SELF]."?row_start=".$_GET[row_start]."\"
method=\"post\">\n";
echo "<fieldset>\n";
echo "<legend>Ret indlæg</legend><br>\n";
echo " <input type=\"hidden\" name=\"row_start\"
value=\"$row_start\">";
echo " <input type=\"hidden\" name=\"line_ed\"
value=\"".$_GET[line]."\">";
echo "<label for=\"nr\">Nr:</label><input type=\"text\"
id=\"nr\" class=\" nobd\" value=\"$r\"
readonly=\"readonly\"><br>\n";
echo "<label for=\"dato\">Dato:</label><input id=\"dato\"
type=\"text\" class=\"nobd\" value=\"$tanggal\"
readonlu=\"readonly\"><br>\n";
echo "<label for=\"t1\">Navn:</label><input id=\"t1\"
name=\"fname\" value=\"$name\"><br>\n";
echo "<label for=\"t2\">E-mail:</label><input id=\"t2\"
name=\"femail\" value=\"$email\"><br>\n";
echo "<label for=\"shw\">Vis e-mail:</label><input
id=\"shw\" type=\"checkbox\" name=\"femail_show\" value=\"y\"";
if ($email_show=="y"){ echo " checked=\"checked\""; }
echo "><br>\n";
echo "<label for=\"t3\">Emne:</label><input id=\"t3\"
name=\"fsubject\" value=\"$subject\"><br>\n";
echo "<label for=\"t4\">Emne</label>";
echo "<textarea id=\"t4\" name=\"fcomment\" rows=2
cols=100>$comment</textarea><br>\n";
echo "<label for=\"subm\"> </label>";
echo "<input class=\"knapper\" type=\"submit\" id=\"subm\"
name=\"btedit\" value=\"Ret indlæg\">";
echo "<input class=\"knapper\" type=\"reset\">";
echo "<input class=\"knapper\" type=\"button\"
name=\"btback\" value=\"Tilbage\"
onclick=window.location=\"$PHP_SELF?row_start=$row_start\"><br>\n
";
echo "<label for\"sure\">Er du sikker?</label><input
id=\"sure\" type=\"checkbox\" name=\"del_conf\" value=\"y\">";
echo " <input class=\"knapper\" type=\"submit\"
name=\"btdelete\" value=\"Slet indlæg\"><br>\n";
echo "</fieldset>\n";
echo "</form>\n";
echo "</div>\n";
} else {
echo "<div class=\"indlag\">\n";
echo "<p class=\"mt mb\"><strong>Nr.</strong> $r <a
class=\"tlink\"
href=\"$PHP_SELF?line=".$r."&row_start=".$_GET[row_start]."#d
".$r."\">Ret</a><br>";
echo "<strong>Dato:</strong> $tanggal<br>";
echo "<strong>Navn:</strong>
$name<br><strong>E-mail:</strong> $email<br><strong>Vis
e-mail:</strong> $email_show<br><strong>Emne:</strong>
$subject<br>\n";
echo "<strong>Besked:</strong> $comment</p>\n";
echo "</div>\n";
}
}
echo "</div>\n";
?>
</div>
<div id="menu"><? include("menu_adm.inc"); ?></div>
</body>
</html>
<?
} // *** (end) CONTENTS ***
?>
--
Vil du lære at kode HTML, XHTML, CSS, SSI, ASP eller ASP.NET?
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! =>
http://www.html.dk/tutorials