find das Skript an sich sehr fein, nur bring ich es einfach nicht zum laufen. Es wird soweit alles korrekt angezeigt, nur kann ich bei meinem Gästebuch nach wie vor Einträge schreiben, ohne den Zahlencode einzugeben, obwohl dieser wunderschön angezeit würde. Das zehrt schon an den Nerven ... bin für jede Info dankbar !!!
index.php
- Code: Alles auswählen
<?php
session_start();
include ("config.inc.php");
include ("functions/vars.inc.php");
include ("functions/main.inc.php");
if ($HTTP_GET_VARS['action'] == "save") Save();
?>
<html>
<head>
<title>Team96 Gaestebuch</title>
<link rel="stylesheet" href="style.css">
</head>
<body bgcolor="<?php echo $BG_COLOR_0 ?>" text="<?php echo $TEXT_COLOR ?>" link="<?php echo $LINK ?>" vlink="<?php echo $VLINK ?>" alink="<?php echo $ALINK ?>">
<div align="right"></div>
<table width="450" border="0" cellspacing="1" cellpadding="1" align="center" bgcolor="<?php echo $BG_COLOR_1 ?>">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="<?php echo $BG_COLOR_2 ?>" width="450">
<tr>
<td height="20" background="images/header.gif" width="5"> </td>
<td height="20" background="images/header.gif" width="370"><b><font size="<?php echo $HEADERTEXT_SIZE ?>" color="<?php echo $HEADERTEXT_COLOR ?>">Gästebuch</font></b></td>
<td height="20" background="images/header.gif" width="70">
<div align="right"><b>
<?php Actions() ?>
</b></div>
</td>
<td height="20" background="images/header.gif" width="5"> </td>
</tr>
<tr>
<td width="5" height="5"> </td>
<td width="370" height="5"> </td>
<td width="70" height="5">
<div align="right"></div>
</td>
<td width="5" height="5"> </td>
</tr>
<?php if (!$HTTP_GET_VARS['action']) Show(); ?>
<?php if ($HTTP_GET_VARS['action'] == "add") { ?>
<tr>
<td width="5"> </td>
<td colspan="2" height="30">
<form name="form1" method="post" action="<? echo $HTTP_SERVER_VARS['PHP_SELF'] ?>?action=save">
<table width="400" border="0" cellspacing="0" cellpadding="0" align="center">
<?php if ($HTTP_GET_VARS['error'] == 1) { ?>
<tr>
<td colspan="2"><b><font color="<?php echo $ERRORTEXT_COLOR ?>">error
- some fields are empty</font></b></td>
</tr>
<tr>
<td width="200"> </td>
<td width="300"> </td>
</tr>
<?php } ?>
<tr>
<td width="200">name: *</td>
<td width="300">
<input type="text" name="name" size="40" value="<?php echo $HTTP_GET_VARS['name'] ?>" maxlength="20">
</td>
</tr>
<tr>
<td width="200">e-mail:</td>
<td width="300">
<input type="text" name="email" size="40" value="<?php echo $HTTP_GET_VARS['email'] ?>" maxlength="50">
</td>
</tr>
<tr>
<td width="200">homepage:</td>
<td width="300">
<?php
if ($HTTP_GET_VARS['homepage']) $value = $HTTP_GET_VARS['homepage'];
else $value = "http://";
?>
<input type="text" name="homepage" size="40" value="<?php echo $value ?>" maxlength="50">
</td>
</tr>
<tr>
<td width="200">comment: *</td>
<td width="300">
<textarea name="comment" cols="49" rows="10"><?php echo $HTTP_GET_VARS['comment'] ?></textarea>
</td>
</tr>
<tr>
<td width="200" height="20"> </td>
<td width="300" height="20"><font size="1">* = Pflichtfelder</font></td>
</tr>
<tr>
<td width="200">Code eingeben:</td>
<td><img src="captcha/captcha.php" border="0" title="Sicherheitscode"></td>
<tr></tr>
<td></td>
<td><input type="text" name="sicherheitscode" size="20" maxlength="10"></td>
</tr>
<tr><td><br></td></tr>
<tr>
<td width="200"> </td>
<td width="300">
<input type="submit" name="Submit" value="Abschicken">
</td>
</tr>
</table>
</form>
</td>
<td width="5" height="30"> </td>
</tr>
<tr>
<td width="5" height="10"> </td>
<td colspan="2" height="10"> </td>
<td width="5" height="10"> </td>
</tr>
<?php } ?>
</table>
</td>
</tr>
</table>
<p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"></font> </p>
</body>
</html>
main.inc.php
- Code: Alles auswählen
<?php
function encrypt($string, $key) {
$result1 = '';
for($i=0; $i<strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result1.=$char;
return base64_encode($result);
}
$sicherheits_eingabe = encrypt($_POST["sicherheitscode"], "8h384ls94");
$sicherheits_eingabe = str_replace("=", "", $sicherheits_eingabe);
if($sicherheits_eingabe == $_SESSION['captcha_spam']){
unset($_SESSION['captcha_spam']);
}
}
$db_test = @mysql_connect($HOST,$ID,$PW);
if (!$db_test)
{
echo "Es konnte keine Verbindung zur Datenbank aufgebaut werden!<br>";
echo "Bitte versuchen Sie es später noch einmal!";
exit();
}
// datebase connect
function Connect_DB()
{
include ("config.inc.php");
$conn_id = mysql_connect($HOST,$ID,$PW);
mysql_select_db($DB,$conn_id);
return $conn_id;
}
// datebase disconnect
function Disconnect_DB($conn_id)
{
mysql_close($conn_id);
}
// save entry
function Save()
{
global $HTTP_GET_VARS,$HTTP_POST_VARS,$HTTP_SERVER_VARS;
if (!$HTTP_POST_VARS['name']): $error = 1;
elseif (!$HTTP_POST_VARS['comment']): $error = 1;
else: $error = 0;
endif;
if ($error == 0)
{
include ("config.inc.php");
$conn_id = Connect_DB();
$date = date("d.m.Y - H:i:s");
mysql_query("insert into $TABLE_NAME (name,email,homepage,comment,date) VALUES ('{$HTTP_POST_VARS['name']}','{$HTTP_POST_VARS['email']}','{$HTTP_POST_VARS['homepage']}','{$HTTP_POST_VARS['comment']}','$date')");
Disconnect_DB($conn_id);
header("Location: index.php");
}
else header("Location: {$HTTP_SERVER_VARS['PHP_SELF']}?action=add&name={$HTTP_POST_VARS['name']}&email={$HTTP_POST_VARS['email']}&homepage={$HTTP_POST_VARS['homepage']}&comment={$HTTP_POST_VARS['comment']}&error=$error");
}
// actions
function Actions()
{
global $HTTP_GET_VARS,$HTTP_SERVER_VARS;
if(!$HTTP_GET_VARS['action']) echo "<a class='header' href='{$HTTP_SERVER_VARS['PHP_SELF']}?action=add'>neuer_Eintrag</a>";
else echo "<a class='header' href='{$HTTP_SERVER_VARS['PHP_SELF']}'>lesen</a>";
}
// show entries
function Show()
{
global $HTTP_GET_VARS,$HTTP_POST_VARS,$HTTP_SERVER_VARS,$num;
include ("config.inc.php");
$conn_id = Connect_DB();
$result = mysql_query("select nr from $TABLE_NAME");
$num = mysql_numrows($result);
echo "<tr>";
echo "<td width='5' height='10'> </td>";
echo "<td width='440'height='10' colspan='2'><div align='center'>$num Einträge</div></td>";
echo "<td width='5' height='10'> </td>";
echo "</tr>";
echo "<tr>";
echo "<td width='5' height='10'> </td>";
echo "<td width='440' height='10' colspan='2'> </td>";
echo "<td width='5' height='10'> </td>";
echo "</tr>";
$result = mysql_query("select nr,name,email,homepage,comment,date from $TABLE_NAME order by nr desc LIMIT {$HTTP_GET_VARS['start']}, $DS_ANZAHL");
while ($row = mysql_fetch_object($result))
{
$nr = $row->nr;
$name = $row->name;
$email = $row->email;
$homepage = $row->homepage;
$comment = $row->comment;
$date = $row->date;
$comment = htmlspecialchars($comment);
$comment = preg_replace ("/([^\s]{45,})/e", "''.wordwrap('\\1', 45, ' ', 1).''", $comment);
$comment = nl2br($comment);
$comment = preg_replace("/((http(s?):\/\/)|(www\.))([\w\.\-,&%+\/]+)/i","<a class=\"normal\"href=\"http$3://$4$5\" target=\"_blank\">$2$4$5</a>", $comment);
$comment = preg_replace("/([\w-_\.]+@[\w-_\.]+\.\w+)/i","<a class=\"normal\" href=\"mailto:$1\">$1</a>", $comment);
$comment = str_replace(":)","<img border=\"0\" alt=\"\"src=\"smilies/1.gif\" /> ",$comment);
$comment = str_replace(":-)","<img border=\"0\" alt=\"\"src=\"smilies/1.gif\" /> ",$comment);
$comment = str_replace(":(","<img border=\"0\" alt=\"\"src=\"smilies/2.gif\" /> ",$comment);
$comment = str_replace(":-(","<img border=\"0\" alt=\"\"src=\"smilies/2.gif\" /> ",$comment);
$comment = str_replace(":D","<img border=\"0\" alt=\"\"src=\"smilies/3.gif\" /> ",$comment);
$comment = str_replace(":-D","<img border=\"0\" alt=\"\"src=\"smilies/3.gif\" /> ",$comment);
$comment = str_replace(":P","<img border=\"0\" alt=\"\"src=\"smilies/4.gif\" /> ",$comment);
$comment = str_replace(":-P","<img border=\"0\" alt=\"\"src=\"smilies/4.gif\" /> ",$comment);
$comment = str_replace(":O","<img border=\"0\" alt=\"\"src=\"smilies/5.gif\" /> ",$comment);
$comment = str_replace(":-O","<img border=\"0\" alt=\"\"src=\"smilies/5.gif\" /> ",$comment);
$comment = str_replace(";)","<img border=\"0\" alt=\"\"src=\"smilies/6.gif\" /> ",$comment);
$comment = str_replace(";-)","<img border=\"0\" alt=\"\"src=\"smilies/6.gif\" /> ",$comment);
$comment = str_replace("8)","<img border=\"0\" alt=\"\"src=\"smilies/7.gif\" /> ",$comment);
$comment = str_replace("8-)","<img border=\"0\" alt=\"\"src=\"smilies/7.gif\" /> ",$comment);
$comment = str_replace(":[","<img border=\"0\" alt=\"\"src=\"smilies/8.gif\" /> ",$comment);
$comment = str_replace(":-[","<img border=\"0\" alt=\"\"src=\"smilies/8.gif\" /> ",$comment);
$comment = str_replace(":o","<img border=\"0\" alt=\"\"src=\"smilies/9.gif\" /> ",$comment);
$comment = str_replace(":-o","<img border=\"0\" alt=\"\"src=\"smilies/9.gif\" /> ",$comment);
if ($homepage == "http://") $homepage = "";
if (!$homepage AND !$email): $homemail = "<div align='right'><a href='admin/delete.php?nr=$nr'><img src='images/delete.gif' border='0' alt='delete entry'></a> </div>";
elseif ($homepage AND !$email): $homemail = "<div align='right'><a href='$homepage' target = '_blank'><img src='images/home.gif' border='0' alt='$homepage'></a> <a href='admin/delete.php?nr=$nr'><img src='images/delete.gif' border='0' alt='delete entry'></a> </div>";
elseif (!$homepage AND $email): $homemail = "<div align='right'><a href='mailto:$email'><img src='images/email.gif' border='0' alt='$email'></a> <a href='admin/delete.php?nr=$nr'><img src='images/delete.gif' border='0' alt='delete entry'></a> </div>";
else: $homemail = "<div align='right'><a href='$homepage' target = '_blank'><img src='images/home.gif' border='0' alt='$homepage'></a> <a href='mailto:$email'><img src='images/email.gif' border='0' alt='$email'></a> <a href='admin/delete.php?nr=$nr'><img src='images/delete.gif' border='0' alt='delete entry'></a> </div>";
endif;
echo "<tr>";
echo "<td bgcolor='$BG_COLOR_3' width='5' height='20'> </td>";
echo "<td bgcolor='$BG_COLOR_3' width='370' height='20'><b>$name</b> schrieb am $date</td>";
echo "<td bgcolor='$BG_COLOR_3' width='70' height='20'>$homemail</td>";
echo "<td bgcolor='$BG_COLOR_3' width='5' height='20'> </td>";
echo "</tr>";
echo "<tr>";
echo "<td width='5' height='5'> </td>";
echo "<td width='370' height='5'> </td>";
echo "<td width='70' height='5'> </td>";
echo "<td width='5' height='5'> </td>";
echo "</tr>";
echo "<tr>";
echo "<td width='5'> </td>";
echo "<td width='440' colspan='2'>$comment</td>";
echo "<td width='5'> </td>";
echo "</tr>";
echo "<tr>";
echo "<td width='5' height='15'> </td>";
echo "<td width='370' height='15'> </td>";
echo "<td width='70' height='15'> </td>";
echo "<td width='5' height='15'> </td>";
echo "</tr>";
}
Disconnect_DB($conn_id);
echo "<tr>";
echo "<td width='5'> </td>";
echo "<td width='440' colspan='2' height='30'>page: ";
if ($num > $DS_ANZAHL)
{
$seiten = $num / $DS_ANZAHL;
$seiten = ceil($seiten);
$i = ($HTTP_GET_VARS['start'] / $DS_ANZAHL) -1;
if ($i < 1)
{
$i = 1;
$HTTP_GET_VARS['next_start'] = 0;
}
else $HTTP_GET_VARS['next_start'] = $HTTP_GET_VARS['start'] - (2 * $DS_ANZAHL);
if (($seiten - $i) >= 5) $seiten1 = $i + 4 ;
else $seiten1 = $seiten;
if ($i >= 2) echo "<a class='normal' href='{$HTTP_SERVER_VARS['PHP_SELF']}?start=0'>first</a> ... ";
for ($i; $i<= $seiten1; $i++)
{
if ($HTTP_GET_VARS['next_start'] == $HTTP_GET_VARS['start']) echo "<b><a class='normal' href='{$HTTP_SERVER_VARS['PHP_SELF']}?start={$HTTP_GET_VARS['next_start']}'>[ $i ]</a></b> ";
else echo "<a class='normal' href='{$HTTP_SERVER_VARS['PHP_SELF']}?start={$HTTP_GET_VARS['next_start']}'>$i</a> ";
$HTTP_GET_VARS['next_start'] = $HTTP_GET_VARS['next_start'] + $DS_ANZAHL;
}
$endstart = ($seiten - 1) * $DS_ANZAHL;
if (($i-1) < $seiten) echo " ... <a class='normal' href='{$HTTP_SERVER_VARS['PHP_SELF']}?start=$endstart'>last</a>";
}
else echo "<b><a class='normal' href='{$HTTP_SERVER_VARS['PHP_SELF']}?start=0'>[ 1 ]</a></b>";
echo "<td width='5'> </td>";
echo "</td>";
echo "</tr>";
}
?>
vars.inc.php
- Code: Alles auswählen
<?php
if (!isset($HTTP_GET_VARS['action'])) $HTTP_GET_VARS['action'] = "";
if (!isset($HTTP_GET_VARS['error'])) $HTTP_GET_VARS['error'] = "";
if (!isset($HTTP_GET_VARS['name'])) $HTTP_GET_VARS['name'] = "";
if (!isset($HTTP_GET_VARS['email'])) $HTTP_GET_VARS['email'] = "";
if (!isset($HTTP_GET_VARS['homepage'])) $HTTP_GET_VARS['homepage'] = "";
if (!isset($HTTP_GET_VARS['comment'])) $HTTP_GET_VARS['comment'] = "";
if (!isset($HTTP_GET_VARS['start'])) $HTTP_GET_VARS['start'] = "0";
if (!isset($HTTP_GET_VARS['next_start'])) $HTTP_GET_VARS['next_start'] = "0";
?>
