Willkommen |
|
myGully |
|
Links |
|
Forum |
|
|
|
|
09.11.09, 05:39
|
#1
|
Anfänger
Registriert seit: Nov 2008
Beiträge: 23
Bedankt: 99
|
Brauche dringend Hilfe bei Gästebuch (PHP)
hi leute,
bräuchte mal ganz, ganz dringend eure hilfe. sitze bereits die ganze nacht und komme einfach nicht auf den fehler.
hab 2 probleme:
1. hab ein feld für den admin-login. wenn ich dieses anklicke, erscheint ganz kurz
BENUTZER + PASSWORT zum eintragen, ist aber gleich wieder weg. warum????
code vom "eintrag-erstellen":
PHP-Code:
<table style="border:1px solid #000000;border-collapse:collapse;background-color:<? echo $bg1; ?>;font-family:arial;font-size:12px;"> <tr> <th style="background-color:<? echo $th_bg; ?>;color:<? echo $th_txt; ?>;">Neue Nachricht erstellen </th> </tr> <tr> <td style="text-align:left;padding:0px 10px 0px 10px;"> <form action="<? echo $_PHP['SELF']; ?>" method="post"> <? $userip = $_SERVER['REMOTE_ADDR']; echo '<input type="hidden" name="ip" value="' . $userip . '">'; ?><br> <? $date = date('M j, Y'); echo '<input type="hidden" name="date" value="' . $date . '">'; ?><br> Name:<br> <input type="text" name="name" size="40"><br> Email:<br> <input type="text" name="email" size="40"><br> Webseite:<br> <input type="text" name="website" value="http://" size="40"><br> Nachricht:<br> <textarea name="comment" rows="10" cols="30"></textarea><br> Security Code:<br> <img src="txt2png.php?" name="img" id="img" alt="Security Code" title="Security Code"><br> Code eingeben:<br> <input id="security_code" name="security_code" type="text"> <input type="submit" name="add_msg" value="Send"> <input type="reset" value="Clear"> </form> </td> </tr> <tr> <td align="center"> <br> <a href="" onclick="newcode(); return false;">Neuen Code erstellen</a><br> <br> </td> </tr> </table>
2. bei neuen einträgen muß man einen captcha-code eingeben. obwohl ich immer das richtige eingebe, steht immer "falscher code".
code vom admin-feld:
PHP-Code:
<table style="width:600px;padding:0px;border-collapse:collapse;font-size:12px;font-family:arial;text-align:right;"> <tr> <td style="text-align:right;padding:10px 10px 0px 0px;"> <? if (!isset($_SESSION['show_admin']) && !isset($_SESSION['guestbook_admin'])) { ?> <a href="<? echo $_PHP['SELF'] . '?show_admin' ?>"><img src="images/edit.gif" width="20" height="10" border="0"></a> <? } else if (!isset($_SESSION['guestbook_admin']) && isset($_SESSION['show_admin'])) { ?> <table style="width:100%;"> <tr> <td style="font-family:arial;font-size:12px;height:12px;text-align:right"> <form action="<? echo $_PHP['SELF']; ?>" method="post"> Name: <input type="text" name="name" size="10"><br> Pass: <input type="password" name="pass" size="10"><br> <input type="submit" name="admin_login" value="Anmelden"> </form> </td> </tr> </table> <? } else { ?> <table style="width:100%;"> <tr> <td style="font-family:arial;font-size:12px;height:12px;text-align:right"> Angemeldet als <? echo $_SESSION['guestbook_admin'] . ' - [ <a href="' . $_PHP['SELF'] . '?logout">Abmelden</a> ]'; ?> </td> </tr> </table> <? } ?> </td> </tr> </table>
hab das skript damals gekauft, kann den inhaber aber leider nicht mehr ausfindig machen.
das gästebuch ist wirklich einfach aufgebaut und ich möchte das daher nicht unbedingt wechseln....
bitte, bitte, bitte um eure hilfe....
|
|
|
09.11.09, 10:49
|
#2
|
Newbie
Registriert seit: Nov 2009
Beiträge: 78
Bedankt: 8
|
Hmm ändere mal alle " $_PHP['SELF'] " in " $_SERVER['PHP_SELF'] " ... Auf deine Weise macht man das eigl. nicht mehr .
Prüf mal ob das schreiben in die Sessions auch klappt...
Code:
echo '<pre>'.print_r( $_SESSION, true).'</pre>';
Hmm das ist aber nicht der ganze Quelltext oder? Wenn ich recht habe, poste mal den ganzen.
|
|
|
09.11.09, 17:47
|
#3
|
Anfänger
Registriert seit: Nov 2008
Beiträge: 23
Bedankt: 99
|
hi elend,
danke für deine rasche hilfe.
nun, wie bereits erwähnt, habe ich das skript damals gekauft - ist daher schon etwas älter. da das gästebuch aber sehr einfach aufgebaut ist, möchte ich dieses wieder verwenden.
die änderung habe ich gemacht - hat nur leider nichts geändert
was meinst du genau mit "Prüf mal ob das schreiben in die Sessions auch klappt..." - wo soll ich das reinkopieren?
ja, du hast recht. hier wäre die GANZE guestbook.php:
PHP-Code:
<? include('no/config.inc.php'); //============================================================================================= //====================================== Do Not Edit ========================================= //============================================================================================= ?> <style type="text/css"> body { background-color: <? echo $bg; ?>;; color: <? echo $text; ?>; } a { font-family: arial; font-size: 12px; font-weight: normal; text-decoration: underline; color: <? echo $link; ?>; } a:hover { font-family: arial; font-size: 12px; font-weight: none; text-decoration: underline; color: <? echo $hover; ?>; } .Stil1 { font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 10px; } a:link { text-decoration: none; } a:visited { text-decoration: none; } a:active { text-decoration: none; } </style> <? $file = 'entries/entries.txt'; $entries = fopen($s*****_path . $file, 'r'); $num_lines = count(file($s*****_path . $file)); if (isset($_REQUEST['show_admin'])) { if (!isset($_SESSION['guestbook_admin'])) { $_SESSION['show_admin'] = true; echo '<meta http-equiv="refresh" content="0;url=' . $_SERVER['HTTP_REFERER'] . '">'; } } else if (isset($_REQUEST['logout'])) { if (isset($_SESSION['guestbook_admin'])) { session_unset(guestbook_admin); echo '<meta http-equiv="refresh" content="0;url=' . $_SERVER['HTTP_REFERER'] . '">'; } } else if (isset($_REQUEST['admin_login'])) { if (isset($_REQUEST['name']) && isset($_REQUEST['pass'])) { if ($_REQUEST['name'] == $admin && $_REQUEST['pass'] == $password) { $_SESSION['guestbook_admin'] = $admin; echo '<meta http-equiv="refresh" content="0;url=' . $_SERVER['HTTP_REFERER'] . '">'; } else { session_unset(guestbook_admin); echo '<meta http-equiv="refresh" content="0;url=' . $_SERVER['HTTP_REFERER'] . '">'; } } } else if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') { if (isset($_SESSION['guestbook_admin']) && isset($_REQUEST['entry'])) { $key = $_REQUEST['entry']; $fc=file($s*****_path . $file); $f=fopen($s*****_path . $file,"w"); foreach($fc as $line) { if (!strstr($line,$key)) fputs($f,$line); } fclose($f); } echo '<meta http-equiv="refresh" content="0;url=' . $_SERVER['HTTP_REFERER'] . '">'; exit(); } else if (isset($_REQUEST['add_msg']) && $_REQUEST['add_msg'] == NULL) { $_SESSION['referrer'] = $_SERVER['HTTP_REFERER']; ?> <s***** language="javas*****" type="text/javas*****"> function rand(n) { return (Math.floor(Math.random()*n+1)); } function newcode() { var sec; sec = document.getElementById("img"); if (sec) sec.setAttribute("src",sec.src+rand(9)); } // --> </s*****> <div> <center> <table style="border:1px solid #000000;border-collapse:collapse;background-color:<? echo $bg1; ?>;font-family:arial;font-size:12px;"> <tr> <th style="background-color:<? echo $th_bg; ?>;color:<? echo $th_txt; ?>;">Neue Nachricht erstellen </th> </tr> <tr> <td style="text-align:left;padding:0px 10px 0px 10px;"> <form action="<? echo $_PHP['SELF']; ?>" method="post"> <? $userip = $_SERVER['REMOTE_ADDR']; echo '<input type="hidden" name="ip" value="' . $userip . '">'; ?><br> <? $date = date('M j, Y'); echo '<input type="hidden" name="date" value="' . $date . '">'; ?><br> Name:<br> <input type="text" name="name" size="40"><br> Email:<br> <input type="text" name="email" size="40"><br> Webseite:<br> <input type="text" name="website" value="http://" size="40"><br> Nachricht:<br> <textarea name="comment" rows="10" cols="30"></textarea><br> Security Code:<br> <img src="txt2png.php?" name="img" id="img" alt="Security Code" title="Security Code"><br> Code eingeben:<br> <input id="security_code" name="security_code" type="text"> <input type="submit" name="add_msg" value="Send"> <input type="reset" value="Clear"> </form> </td> </tr> <tr> <td align="center"> <br> <a href="" onclick="newcode(); return false;">Neuen Code erstellen</a><br> <br> </td> </tr> </table> </center> </div> <? echo '</body>'; echo '</html>'; exit(); } else if (isset($_REQUEST['add_msg']) && ($_REQUEST['add_msg'] == 'Send' || $_REQUEST['add_msg'] == 'new')) { $id = time(); $date = stripslashes($_REQUEST['date']); $name = stripslashes(str_replace("\n", " ", $_REQUEST['name'])); $email = stripslashes(str_replace("\n", " ", $_REQUEST['email'])); $website = stripslashes(str_replace("\n", " ", $_REQUEST['website'])); $ip = stripslashes($_REQUEST['ip']); $comment = stripslashes(str_replace("\n", "<br>", $_REQUEST['comment'])); if ($_REQUEST['add_msg'] == 'new') { $error = ''; } else if (!isset($_REQUEST['security_code']) || !isset($_SESSION['security_code']) || $_REQUEST['security_code'] != $_SESSION['security_code']) { $error = '<b><font color="#F000000">Error: </font></b>Falscher Security Code!'; } else if (!isset($_REQUEST['name']) || $name == '') { $error = '<b><font color="#F000000">Error: </font>M</b>Bitte den Namen angeben.'; } else if (!isset($_REQUEST['email']) || $email == '') { $error = '<b><font color="#F000000">Error: </font></b>Bitte die E-Mail angeben.'; } else if (!isset($_REQUEST['date']) || $date == '') { $error = '<b><font color="#F000000">Error: </font></b>Kein Datum gesetzt.'; } else if (!isset($_REQUEST['ip']) || $ip == '') { $error = '<b><font color="#F000000">Error: </font></b>Keine IP gesetzt.'; } else if (!isset($_REQUEST['comment']) || $comment == '') { $error = '<b><font color="#F000000">Error: </font></b>Bitte Kommentar angeben.'; } else { $error = '<b><font color="#0000000">Success: </font></b>Die Nachricht wurde gesendet.'; $new_line = "$id|$date|$name|$email|$website|$ip|$comment\n"; $old_lines = file($s*****_path . $file); array_unshift($old_lines,$new_line); $new_content = join('',$old_lines); $fp = fopen($s*****_path . $file,'w'); $write = fwrite($fp, $new_content); fclose($fp); echo '<meta http-equiv="refresh" content="2;url=' . $_SESSION['referrer'] . '">'; } } ?> <div> <center> <table style="width:600px;padding:0px;border-collapse:collapse;font-size:12px;font-family:arial;"> <tr> <td width="207" style="padding:0px 0px 10px 10px;text-align:left;width:200px;"> <? $pages = ceil($num_lines / $limit); if ($_GET['pg'] >= 1 && $pages != 0) { if ($_GET['pg'] == 1) { echo '[ '; } else { echo '[ <a href="' . $_PHP['SELF'] . '?pg=' . ($_GET['pg'] - 1) . '">...</a> | '; } } $p = 1; while ($p <= $pages) { if (isset($_GET['pg'] )) { if ($_GET['pg'] == $p ) { if ($p == $pages) { echo '<b>' . $p . '</b>'; } else { echo '<b>' . $p . '</b> | '; } } else if ($_GET['pg'] <= 2) { if ($p <= 5) { if ($p < 5) { if ($pages <= 5 && $_GET['pg'] >= 1) { if ($p == $pages) { echo '<a href="' . $_PHP['SELF'] . '?pg=' . $p . '">' . $p . '</a>'; } else { echo '<a href="' . $_PHP['SELF'] . '?pg=' . $p . '">' . $p . '</a> | '; } } else if ($pages > 5 && $_GET['pg'] >= 1) { echo '<a href="' . $_PHP['SELF'] . '?pg=' . $p . '">' . $p . '</a> | '; } } else { echo '<a href="' . $_PHP['SELF'] . '?pg=' . $p . '">' . $p . '</a>'; } } } else if ($_GET['pg'] == $pages) { if ($p >= $_GET['pg'] - 4) { echo '<a href="' . $_PHP['SELF'] . '?pg=' . $p . '">' . $p . '</a> | '; } } else if ($_GET['pg'] + 1 == $pages) { if ($p == $_GET['pg'] + 1) { echo '<a href="' . $_PHP['SELF'] . '?pg=' . $p . '">' . $p . '</a>'; } else if ($p >= $_GET['pg'] - 3 && $p <= $_GET['pg'] + 3) { echo '<a href="' . $_PHP['SELF'] . '?pg=' . $p . '">' . $p . '</a> | '; } } else if (($p <= $_GET['pg'] + 2) && ($p >= $_GET['pg'] - 2)) { if ($p == $pages) { echo '<a href="' . $_PHP['SELF'] . '?pg=' . $p . '">' . $p . '</a>'; } else if ($p == $_GET['pg'] + 2) { echo '<a href="' . $_PHP['SELF'] . '?pg=' . $p . '">' . $p . '</a>'; } else { echo '<a href="' . $_PHP['SELF'] . '?pg=' . $p . '">' . $p . '</a> | '; } } } else { if ($p <= 5) { if ($p == 1 && $pages > 1) { echo '[ <b>' . $p . '</b> | '; } else if ($p == 1 && $pages == 1) { echo '[ <b>' . $p . '</b>'; } else if ($p < 5 && $pages > 1) { if ($p == $pages) { echo '<a href="' . $_PHP['SELF'] . '?pg=' . $p . '">' . $p . '</a>'; } else { echo '<a href="' . $_PHP['SELF'] . '?pg=' . $p . '">' . $p . '</a> | '; } } else { echo '<a href="' . $_PHP['SELF'] . '?pg=' . $p . '">' . $p . '</a>'; } } } $p++; } if (($_GET['pg'] <= $pages || !isset($_GET['pg'])) && $pages != 0) { if ($pages < 2) { echo ' ]'; } else if (!isset($_GET['pg'])) { echo ' | <a href="' . $_PHP['SELF'] . '?pg=2">...</a> ]'; } else if ($_GET['pg'] == $pages) { echo ' ]'; } else { echo ' | <a href="' . $_PHP['SELF'] . '?pg=' . ($_GET['pg'] + 1) . '">...</a> ]'; } } ?> </td> <td width="119" style="padding:0px 0px 10px 0px;text-align:center;"><? echo $error; ?></td> <td width="258" valign="bottom" nowrap style="padding:0px 10px 10px 10px;text-align:right;width:260px;">[ <a href="<? echo $_PHP['SELF']; ?>?add_msg">Nachricht erstellen</a> ]</td> </tr> </table> </center> </div> <div> <center> <table style="border:1px solid black;width:600px;padding:0px;border-collapse:collapse;font-size:12px;font-family:arial;"> <tr> <th style="background-color:<? echo $th_bg; ?>;color:<? echo $th_txt; ?>;height:20px">Absender</th> <th style="background-color:<? echo $th_bg; ?>;color:<? echo $th_txt; ?>;height:20px">Eintrag</th> </tr> <? if(isset($_GET['pg'])){ $start = $limit * ($_GET['pg'] - 1); } else { $start = 0; } if ($entries) { $i = 0; $j = 0; while (!feof($entries)) { if ($bg == $bg1) { $bg = $bg2; } else { $bg = $bg1; } $line[] = fgets($entries, 4096); $array = explode('|', $line[$i]); if ($i < $num_lines && $i >= $start && $j < $limit) { ?> <tr style="background-color:<? echo $bg; ?>;"> <td style="background-color:<? echo $bg3; ?>;height:20px;border-top:1px solid #000000;border-bottom:1px solid #000000;padding:0px 10px 0px 10px;text-align:left;vertical-align:middle"> <? echo '<b>Gesendet</b> ' . $array[1]; ?> </td> <td style="background-color:<? echo $bg3; ?>;height:20px;border-top:1px solid #000000;border-bottom:1px solid #000000;padding:0px 10px 0px 10px;text-align:right;vertical-align:middle"> <? if (isset($_SESSION['guestbook_admin'])) { echo '<b>IP:</b> ' . $array[5] . ' | '; } ?> <? if (isset($_SESSION['guestbook_admin'])) { echo '<b>Email:</b> <a href="mailto:' . $array[3] . '">' . $array[3] . '</a> | '; } ?> <? if (isset($_SESSION['guestbook_admin'])) { echo '<a href="' . $_PHP['SELF'] . '?action=delete&entry=' . $array[0] . '" onclick="return confirm(\'Are you sure you want to delete this message?\')">Entfernen</a>'; } ?> </td> </tr> <tr style="background-color:<? echo $bg; ?>;"> <td style="border-right:1px solid #000000;width:150px;padding:10px;text-align:left;vertical-align:top"> <? echo '<b>Name:</b> ' . $array[2] . '<br>'; ?> <? if ($array[4] != NULL) { echo '<b>Website:</b> <a href="' . $array[4] . '" target="_blank">Visit</a><br>'; } ?> </td> <td style="padding:10px;text-align:left;vertical-align:top"> <? echo $array[6] . '<br>'; ?> </td> </tr> <? $j++; } $i++; } fclose($entries); } ?> </table> <table style="width:600px;padding:0px;border-collapse:collapse;font-size:12px;font-family:arial;text-align:right;"> <tr> <td style="text-align:right;padding:10px 10px 0px 0px;"> <? if (!isset($_SESSION['show_admin']) && !isset($_SESSION['guestbook_admin'])) { ?> <a href="<? echo $_PHP['SELF'] . '?show_admin' ?>"><img src="images/edit.gif" width="20" height="10" border="0"></a> <? } else if (!isset($_SESSION['guestbook_admin']) && isset($_SESSION['show_admin'])) { ?> <table style="width:100%;"> <tr> <td style="font-family:arial;font-size:12px;height:12px;text-align:right"> <form action="<? echo $_PHP['SELF']; ?>" method="post"> Name: <input type="text" name="name" size="10"><br> Pass: <input type="password" name="pass" size="10"><br> <input type="submit" name="admin_login" value="Anmelden"> </form> </td> </tr> </table> <? } else { ?> <table style="width:100%;"> <tr> <td style="font-family:arial;font-size:12px;height:12px;text-align:right"> Angemeldet als <? echo $_SESSION['guestbook_admin'] . ' - [ <a href="' . $_PHP['SELF'] . '?logout">Abmelden</a> ]'; ?> </td> </tr> </table> <? } ?> </td> </tr> </table> </center> </div>
|
|
|
09.11.09, 18:40
|
#4
|
Newbie
Registriert seit: Nov 2009
Beiträge: 78
Bedankt: 8
|
Entferne mal das:
Code:
|| $_REQUEST['security_code'] != $_SESSION['security_code'])
aus dem Quelltext und versuchs nochmal
|
|
|
09.11.09, 18:50
|
#5
|
Anfänger
Registriert seit: Nov 2008
Beiträge: 23
Bedankt: 99
|
jetzt steht:
Parse error: syntax error, unexpected '{' in /var/www/web401/html/guestbook/guestbook.php on line 163
|
|
|
Forumregeln
|
Du kannst keine neue Themen eröffnen
Du kannst keine Antworten verfassen
Du kannst keine Anhänge posten
Du kannst nicht deine Beiträge editieren
HTML-Code ist Aus.
|
|
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:42 Uhr.
().
|