<?php require('layout/header.php'); ?>
<script type="text/javascript">
function insert(was) {
document.disc.discussion.value += was + " ";
document.disc.discussion.focus();
}
</script>
<script type="text/javascript">
function showSuccessMessage() {
showNotification({
type : "success",
message: "<?php echo $lang['succes_discussion']; ?>"
});
}
function showErrorMessage() {
showNotification({
type : "error",
message: "<?php echo $lang['couldnot_discussion']; ?>"
});
}
</script>
<div id="content_wrapper">
<div class="content"><?php
echo '<h1>' . $lang['create_discussion'] . '</h1><br>';
$goto = 'discussion.php';
$autoforward = 3;
if($_SERVER['REQUEST_METHOD'] != 'POST') {
include_once('functions/flood.php');
echo "<form action=\"\" method=\"post\" name=\"disc\">
<p><input type=\"text\" name=\"subject\" class=\"fields\" size=\"30\" maxlength=\"50\"> <strong>" . $lang['subject'] . "*</strong></p>
<p><input type=\"text\" name=\"name\" class=\"fields\" size=\"30\" maxlength=\"60\"> <strong>" . $lang['name'] . "*</strong></p>
<p><input type=\"text\" name=\"email\" class=\"fields\" size=\"30\" maxlength=\"60\"> <strong>" . $lang['e_mail'] . "*</strong></p>
<p><a href=\"javascript:insert('[b][/b]','')\"><img border=\"0\" src=\"images/bbcode/bold.png\" title=\"" . $lang['bold'] . "\"></a><a href=\"javascript:insert('[i][/i]','')\"><img border=\"0\" src=\"images/bbcode/italic.png\" title=\"" . $lang['italic'] . "\"></a><a href=\"javascript:insert('[u][/u]','')\"><img border=\"0\" src=\"images/bbcode/underline.png\" title=\"" . $lang['underline'] . "\"></a><a href=\"javascript:insert('[url]http://[/url]','')\"><img border=\"0\" src=\"images/bbcode/link.png\" title=\"" . $lang['url_with'] . "\"></a><br>
<textarea name=\"discussion\" class=\"fields_text\" cols=\"35\" rows=\"8\"></textarea></p>
<p><small>" . $lang['spam_protection_question'] . " *</small><br>
<strong>" . $lang['sum_of'] . " " . $random1 . " + " . $code . " =</strong> <input size=\"5\" name=\"zip\" id=\"Spamschutz\" type=\"text\" class=\"fields\" /><input type=\"hidden\" name=\"zip2\" value=" . $rand_result . "></p>
<p><input type=\"submit\" class=\"button\" value=\"" . $lang['add_discussion'] . " \" name=\"" . $lang['add_discussion'] . "\"></p>
</form>";
}else{
if(sha1($_POST["zip"]) != $_POST["zip2"]) {
echo '<p class="false">' . $lang['invalid_spam'] . '!</p>
<p>[ <a href="javascript:history.back();">' . $lang['back'] . '</a> ]</p>';
}else{
$errors = array();
if(isset($_POST['subject'])) {
if(trim($_POST['subject']) == "") {
$errors[] = '<p>' . $lang['fill_in_subject'] . '.</p>';
}
if(isset($_POST['name'])) {
if(trim($_POST['name']) == "") {
$errors[] = '<p>' . $lang['fill_in_name'] . '.</p>';
}
if(isset($_POST['email'])) {
$email = htmlentities($_POST['email']);
if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)) {
$errors[] = '<p>' . $lang['invalid_syntax'] . '.</p>';
}
}else{
$errors[] = '<p>' . $lang['fill_in_email'] . '.</p>';
}
if(isset($_POST['discussion'])) {
if(trim($_POST['discussion']) == "") {
$errors[] = '<p>' . $lang['fill_in_discussion'] . '.</p>';
}
if(!empty($errors)) {
echo '<p class="false"><u>' . $lang['not_filled_all'] . '</u></p>
<p>[ <a href="javascript:history.back();">' . $lang['back'] . '</a> ]</p>';
echo '<ul>';
foreach($errors as $key => $value) {
echo '<li>' . $value . '</li>';
}
echo '</ul>';
echo "<script type=\"text/javascript\">showErrorMessage();</script>";
}else{
$sql = "INSERT INTO
discussions(subject, discussion, author, email, date)
VALUES ('" . mysql_real_escape_string($_POST["subject"]) . "',
'" . mysql_real_escape_string($_POST["discussion"]) . "',
'" . mysql_real_escape_string($_POST["name"]) . "',
'" . mysql_real_escape_string($_POST["email"]) . "',
NOW()
)";
$result = mysql_query($sql) OR die(mysql_error());
if(!$result) {
echo '<p class="false">' . $lang['couldnot_discussion'] . '</p>
[ <a href="javascript:history.back();">' . $lang['back'] . '</a> ]';
echo "<script type=\"text/javascript\">showErrorMessage();</script>";
}else{
echo '<p class="right">' . $lang['succes_discussion'] . '</p>
<p><meta http-equiv="refresh" content="' . $autoforward . '; URL=' . $goto . '">
<small>' . $lang['redirected_in'] . ' ' . $autoforward . ' ' . $lang['seconds'] . '...</small></p>';
echo "<script type=\"text/javascript\">showSuccessMessage();</script>";
}}}}}}}
echo '<div class="spacer_div"> </div>';
?>
</div>
</div>
<div id="infobox_wrapper">
<div class="infobox">
<?php include('layout/infobox.php'); ?>
</div>
</div>
<?php require('layout/footer.php'); ?>