ACC SHELL
<?php
// set $rootCommentID first!
// add new comment (form)
$page->addCommentForm = 'addCommentForm';
// add new comment (form)
if ( isset( $_POST['addComment'] ) && isset( $_POST['nick'] ) && isset( $_POST['dvacetdva'] ) && ( $_POST['dvacetdva'] == '22' ) )
{
$comments = print_r( $_POST, true );
$_POST['nick'] = htmlspecialchars( trim($_POST['nick']) );
//$_POST['predmet'] = htmlspecialchars( trim($_POST['predmet']) );
$_POST['text'] = htmlspecialchars( trim($_POST['text']) );
$dbFields = array( 'parentID' => $rootCommentID, 'nick' => $_POST['nick'],
/*('title') => $_POST['predmet'],*/ ('text') => $_POST['text'],
'url'=>$_SERVER['REQUEST_URI'] );
$db->insertItem( 'comment', $dbFields );
unset( $_POST );
header( 'Location: ' . 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
}
// show comments
$articleComments = $db->getAllItems( 'comment', " WHERE `parentID`=" . $rootCommentID . " ORDER BY `createdDateTime` ASC" );
$page->comments = array();
$page->commentsCount = count( $articleComments );
if ( $page->commentsCount > 0 )
{
$page->noComments = false;
$i = 0;
foreach ( $articleComments as $articleComment )
{
$page->comments[$i] = new stdClass();
$datetime = date_create( $articleComment['createdDateTime'] );
$page->comments[$i]->cDate = date_format( $datetime, "d.m.Y" ) . ' ' . date_format( $datetime, "H:i:s" );
$page->comments[$i]->userNickname = htmlspecialchars( $articleComment['nick'] );
//$page->comments[$i]->title = htmlspecialchars( stripslashes($articleComment['title']) );
$page->comments[$i]->text = strip_tags( stripslashes($articleComment['text']) );
$i++;
}
}
else
{
$page->noComments = true;
}
?>
ACC SHELL 2018