$cmtx_box .= "</div>"; $cmtx_box .= "<div style='clear: left;'></div>"; cmtx_repopulate(); //repopulate the form with submitted values } else { if (isset($_POST['cmtx_preview']) || isset($_POST['cmtx_prev'])) { //if preview was selected //remove any escapes from data $cmtx_name = cmtx_strip_slashes($cmtx_name); $cmtx_email = cmtx_strip_slashes($cmtx_email); $cmtx_website = cmtx_strip_slashes($cmtx_website); $cmtx_town = cmtx_strip_slashes($cmtx_town); $cmtx_country = cmtx_strip_slashes($cmtx_country); $cmtx_comment = cmtx_strip_slashes($cmtx_comment); //build the preview box using submitted values $cmtx_box = cmtx_generate_comment(true, 1, 0, $cmtx_name, $cmtx_email, $cmtx_website, $cmtx_town, $cmtx_country, $cmtx_rating, '0', $cmtx_comment, '', $cmtx_is_admin, 0, 0, 0, 0, date("Y-m-d H:i:s")); $cmtx_box .= "<div style='clear: left;'></div>"; cmtx_repopulate(); //repopulate the form with submitted values } else { if (cmtx_approval_needed()) { //if approval needed if (!cmtx_page_exists()) { //if page does not exist cmtx_create_page(); //create it now } if (cmtx_setting('approve_comments')) { //if approving all comments $cmtx_approve_reason = CMTX_APPROVE_REASON_ALL; } else {
function cmtx_get_comment_and_replies($id) { global $cmtx_mysql_table_prefix, $cmtx_page_id, $cmtx_loop_counter, $cmtx_comment_counter, $cmtx_offset, $cmtx_exit_loop; //globalise variables $cmtx_loop_counter++; //increase loop counter by 1 if (!cmtx_setting('enabled_pagination')) { //if pagination is disabled if ($cmtx_comment_counter != 0) { //don't display on first run echo '<div class="cmtx_height_between_comments"></div>'; } //switch box number each time if ($cmtx_comment_counter % 2 == 0) { $alternate = 1; } else { $alternate = 2; } //get the details of the comment $comments_q = cmtx_db_query("SELECT * FROM `" . $cmtx_mysql_table_prefix . "comments` WHERE `id` = '{$id}'"); $comments = cmtx_db_fetch_assoc($comments_q); //display comment echo cmtx_generate_comment(false, $alternate, $comments['id'], $comments['name'], $comments['email'], $comments['website'], $comments['town'], $comments['country'], $comments['rating'], $comments['reply_to'], $comments['comment'], $comments['reply'], $comments['is_admin'], $comments['likes'], $comments['dislikes'], $comments['is_sticky'], $comments['is_locked'], $comments['dated']); $cmtx_comment_counter++; //increase comment counter by 1 } else { //apply pagination if ($cmtx_loop_counter > $cmtx_offset + (cmtx_setting('comments_per_page') + 1)) { //if the page's comments have already been displayed $cmtx_exit_loop = true; //exit the loop to save on performance } if ($cmtx_loop_counter > $cmtx_offset && $cmtx_loop_counter < $cmtx_offset + (cmtx_setting('comments_per_page') + 1)) { //skip unwanted comments if ($cmtx_comment_counter != 0) { //don't display on first run echo '<div class="cmtx_height_between_comments"></div>'; } //switch box number each time if ($cmtx_comment_counter % 2 == 0) { $alternate = 1; } else { $alternate = 2; } //get the details of the comment $comments_q = cmtx_db_query("SELECT * FROM `" . $cmtx_mysql_table_prefix . "comments` WHERE `id` = '{$id}'"); $comments = cmtx_db_fetch_assoc($comments_q); //display comment echo cmtx_generate_comment(false, $alternate, $comments['id'], $comments['name'], $comments['email'], $comments['website'], $comments['town'], $comments['country'], $comments['rating'], $comments['reply_to'], $comments['comment'], $comments['reply'], $comments['is_admin'], $comments['likes'], $comments['dislikes'], $comments['is_sticky'], $comments['is_locked'], $comments['dated']); $cmtx_comment_counter++; //increase comment counter by 1 } } if (cmtx_comment_has_reply($id)) { //if the comment has a reply //get all of its replies $reply_q = cmtx_db_query("SELECT `id` FROM `" . $cmtx_mysql_table_prefix . "comments` WHERE `reply_to` = '{$id}' AND `is_approved` = '1' AND `page_id` = '{$cmtx_page_id}' ORDER BY `dated` ASC"); while ($replies = cmtx_db_fetch_assoc($reply_q)) { //while there are replies cmtx_get_comment_and_replies($replies['id']); //re-call this function to display the reply AND any replies it may have } } }