[Comoblog-commit] comoblog add_comment.php,1.3,1.4
Status: Inactive
Brought to you by:
markwallis
|
From: iamdecal <iam...@us...> - 2006-02-24 00:27:50
|
Update of /cvsroot/comoblog/comoblog In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32079 Modified Files: add_comment.php Log Message: added extra cookie handler for the comment-url Index: add_comment.php =================================================================== RCS file: /cvsroot/comoblog/comoblog/add_comment.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- add_comment.php 1 Dec 2005 14:56:16 -0000 1.3 +++ add_comment.php 24 Feb 2006 00:27:40 -0000 1.4 @@ -1,96 +1,99 @@ -<?php -require_once ("include/config.inc.php"); - -if (CFG_INTERACTION_COMMENTS != 'yes') { - error_404(); -} - -$tpl = new XTemplate ("templates/add_comment.tpl.htm"); -$tpl->assign('TXT', $TXT); - -$tpl->assign('CFG_BODY_BGCOLOR', CFG_BODY_BGCOLOR); -$tpl->assign('CFG_BACKGROUND_COLOR', CFG_BACKGROUND_COLOR); - -$form['post_id'] = ''; -if(isset($_POST['post_id'])) $form['post_id'] = $_POST['post_id']; -elseif(isset($_GET['i'])) $form['post_id'] = $_GET['i']; -else exit(); - -$form['comment_author'] = ''; -if (isset($_POST['comment_author'])) $form['comment_author'] = $_POST['comment_author']; - -$form['comment_author_email'] == ''; -if (isset($_POST['comment_author_email'])) $form['comment_author_email'] = $_POST['comment_author_email']; - -$form['comment_text'] == ''; -if (isset($_POST['comment_text'])) $form['comment_text'] = $_POST['comment_text']; - -// addition to allow HTML in comments if flagged - needs an admin option to turn on or off -$form['comment_convert'] == ''; -if (isset($_POST['comment_convert'])) $form['comment_convert'] = $_POST['comment_convert']; - - - -if ($_SERVER['REQUEST_METHOD'] == 'POST') { - $errors = array(); - - if ($form['comment_author'] == '') - array_push ($errors, 'Please type your name'); - - if ($form['comment_author_email'] != '' && !is_valid_email($form['comment_author_email'])) - array_push ($errors, 'Invalid email address'); - - if ($form['comment_text'] == '') - array_push ($errors, 'Please write your comment'); - - if (count($errors) == 0) { - $comment = $form; - - $comment = comment_add ($comment); - - $cookie_period = 60*60*24*365; - $domain = parse_url(CFG_SITE_URL); - $domain = $domain['host']; - setcookie("comment-name", $form['comment_author'], time() + $cookie_period, "/", $domain, 0); - setcookie("comment-email", $form['comment_author_email'], time() + $cookie_period, "/", $domain, 0); - - Header ("Location: list_comments.php?i=".$comment['post_id']); - exit(); - } - else { - foreach ($errors as $key=>$value) { - $tpl->assign("ERROR", $value); - $tpl->parse("main.form_errors.error"); - } - $tpl->parse("main.form_errors"); - } -} - - - - - -$tpl->assign("ACTION", basename($_SERVER['PHP_SELF'])); - -if (isset($_COOKIE['comment-name'])) - $form['comment_author'] = $_COOKIE['comment-name']; -if (isset($_COOKIE['comment-email'])) - $form['comment_author_email'] = $_COOKIE['comment-email']; - -$tpl->assign("FORM", $form); - - -// html comments are allowed -if (CFG_INTERACTION_HTML_COMMENTS == 'yes'){ - $tpl->parse('main.html_comments'); -} - - - -$tpl->parse("main"); -$tpl->out("main"); - - -// close db connection -mysql_close (); -?> +<?php +require_once ("include/config.inc.php"); + +if (CFG_INTERACTION_COMMENTS != 'yes') { + error_404(); +} + +$tpl = new XTemplate ("templates/add_comment.tpl.htm"); +$tpl->assign('TXT', $TXT); + +$tpl->assign('CFG_BODY_BGCOLOR', CFG_BODY_BGCOLOR); +$tpl->assign('CFG_BACKGROUND_COLOR', CFG_BACKGROUND_COLOR); + +$form['post_id'] = ''; +if(isset($_POST['post_id'])) $form['post_id'] = $_POST['post_id']; +elseif(isset($_GET['i'])) $form['post_id'] = $_GET['i']; +else exit(); + +$form['comment_author'] = ''; +if (isset($_POST['comment_author'])) $form['comment_author'] = $_POST['comment_author']; + +$form['comment_author_email'] == ''; +if (isset($_POST['comment_author_email'])) $form['comment_author_email'] = $_POST['comment_author_email']; + +$form['comment_text'] == ''; +if (isset($_POST['comment_text'])) $form['comment_text'] = $_POST['comment_text']; + +// addition to allow HTML in comments if flagged - needs an admin option to turn on or off +$form['comment_convert'] == ''; +if (isset($_POST['comment_convert'])) $form['comment_convert'] = $_POST['comment_convert']; + + + +if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $errors = array(); + + if ($form['comment_author'] == '') + array_push ($errors, 'Please type your name'); + + if ($form['comment_author_email'] != '' && !is_valid_email($form['comment_author_email'])) + array_push ($errors, 'Invalid email address'); + + if ($form['comment_text'] == '') + array_push ($errors, 'Please write your comment'); + + if (count($errors) == 0) { + $comment = $form; + + $comment = comment_add ($comment); + + $cookie_period = 60*60*24*365; + $domain = parse_url(CFG_SITE_URL); + $domain = $domain['host']; + setcookie("comment-name", $form['comment_author'], time() + $cookie_period, "/", $domain, 0); + setcookie("comment-email", $form['comment_author_email'], time() + $cookie_period, "/", $domain, 0); + + setcookie("comment-url", $form['comment_author_url'], time() + $cookie_period, "/", $domain, 0); + + Header ("Location: list_comments.php?i=".$comment['post_id']); + exit(); + } + else { + foreach ($errors as $key=>$value) { + $tpl->assign("ERROR", $value); + $tpl->parse("main.form_errors.error"); + } + $tpl->parse("main.form_errors"); + } +} + + + + + +$tpl->assign("ACTION", basename($_SERVER['PHP_SELF'])); + +if (isset($_COOKIE['comment-name'])) + $form['comment_author'] = $_COOKIE['comment-name']; +if (isset($_COOKIE['comment-email'])) + $form['comment_author_email'] = $_COOKIE['comment-email']; +if (isset($_COOKIE['comment-url'])) + $form['comment_author_url'] = $_COOKIE['comment-url']; +$tpl->assign("FORM", $form); + + +// html comments are allowed +if (CFG_INTERACTION_HTML_COMMENTS == 'yes'){ + $tpl->parse('main.html_comments'); +} + + + +$tpl->parse("main"); +$tpl->out("main"); + + +// close db connection +mysql_close (); +?> |