summaryrefslogtreecommitdiff
path: root/ajax_comments.php
diff options
context:
space:
mode:
authorwjames5 <will@tekimaki.com>2007-06-11 21:22:34 +0000
committerwjames5 <will@tekimaki.com>2007-06-11 21:22:34 +0000
commitb919d54e069b289ea779a8c3102bc33df27dc582 (patch)
tree09f7505e73b98bbe88aa9bf7b5975072e050b901 /ajax_comments.php
parent60d7a7c6d59729bf43944b697954c6a4d079f687 (diff)
downloadliberty-b919d54e069b289ea779a8c3102bc33df27dc582.tar.gz
liberty-b919d54e069b289ea779a8c3102bc33df27dc582.tar.bz2
liberty-b919d54e069b289ea779a8c3102bc33df27dc582.zip
make ajax comments work with catpcha - preview comment if captcha is wrong
Diffstat (limited to 'ajax_comments.php')
-rw-r--r--ajax_comments.php55
1 files changed, 47 insertions, 8 deletions
diff --git a/ajax_comments.php b/ajax_comments.php
index 290e1b9..300794a 100644
--- a/ajax_comments.php
+++ b/ajax_comments.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Header: /cvsroot/bitweaver/_bit_liberty/ajax_comments.php,v 1.2 2007/06/11 20:15:48 squareing Exp $
+ * @version $Header: /cvsroot/bitweaver/_bit_liberty/ajax_comments.php,v 1.3 2007/06/11 21:22:34 wjames5 Exp $
* @package liberty
* @subpackage functions
*/
@@ -8,22 +8,61 @@ require_once( '../bit_setup_inc.php' );
$staticContent = new LibertyContent();
$gContent = $staticContent->getLibertyObject( $_REQUEST['parent_id'], $_REQUEST['parent_guid'] );
+$XMLContent = "";
if( !$gBitUser->hasPermission( 'p_liberty_post_comments' )) {
- echo tra( "You do not have the required permissions to post new comments" );
+ $statusCode = 401;
+ $XMLContent = tra( "You do not have the required permissions to post new comments" );
} elseif( $gContent->isCommentable() ) {
$commentsParentId = $_REQUEST['parent_id'];
$comments_return_url = $_REQUEST['comments_return_url'];
include_once( LIBERTY_PKG_PATH.'comments_inc.php' );
if( isset( $_REQUEST['post_comment_submit'] )) {
- $storeComment->loadComment();
- $postComment = $storeComment->mInfo;
- $postComment['parsed_data'] = $storeComment->parseData( $postComment );
+ if ($storeComment->loadComment()){
+ $statusCode = 200;
+ $postComment = $storeComment->mInfo;
+ $postComment['parsed_data'] = $storeComment->parseData( $postComment );
+ }else{
+ //if store is requested but it fails for some reason - like captcha mismatch
+ $statusCode = 400;
+ }
+ }else{
+ //we assume preview request which we return as ok - our js callback knows what to do when preview is requested
+ $statusCode = 200;
}
$gBitSmarty->assign('comment', $postComment);
$gBitSmarty->assign('commentsParentId', $commentsParentId);
- echo $gBitSmarty->fetch( 'bitpackage:liberty/display_comment.tpl' );
+ if( !empty($formfeedback) ){
+ $statusCode = 400;
+ require_once $gBitSmarty->_get_plugin_filepath( 'function', 'formfeedback' );
+ $XMLContent = smarty_function_formfeedback( $formfeedback, $gBitSmarty );
+ }
+ $XMLContent .= $gBitSmarty->fetch( 'bitpackage:liberty/display_comment.tpl' );
} else {
- echo tra( "Sorry, you can not post a comment here." );
+ $statusCode = 405;
+ $XMLContent = tra( "Sorry, you can not post a comment here." );
}
-?>
+
+//We return XML with a status code
+$mRet = "<req><status><code>".$statusCode."</code></status>"
+ ."<content><![CDATA[".$XMLContent."]]></content></req>";
+
+//since we are returning xml we must report so in the header
+//we also need to tell the browser not to cache the page
+//see: http://mapki.com/index.php?title=Dynamic_XML
+// Date in the past
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+// always modified
+header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+// HTTP/1.1
+header("Cache-Control: no-store, no-cache, must-revalidate");
+header("Cache-Control: post-check=0, pre-check=0", false);
+// HTTP/1.0
+header("Pragma: no-cache");
+//XML Header
+header("content-type:text/xml");
+
+print_r('<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>');
+print_r($mRet);
+die;
+?> \ No newline at end of file