function read_comments($dir, $check) { global $root_dir, $show_cmt, $cmt_count, $total_count, $subfile_count, $deleted_files, $domain, $script_query, $template, $icon_size; $files = array(); // Read directory contents, put filenames in array, count files foreach (glob($dir . '/*.xml', GLOB_NOSORT) as $file) { $files[basename($file, '.xml')] = $file; $subfile_count[$file] = '0'; $total_count++; if (!preg_match('/-/', basename($file, '.xml'))) { $cmt_count++; } } // Sort files ascending alphabetically uksort($files, 'strnatcasecmp'); foreach ($files as $file) { $cmt_tree = ''; foreach (explode('-', basename($file, '.xml')) as $reply) { for ($i = 1; $i <= $reply; $i++) { if (!in_array($dir . '/' . $cmt_tree . ((!empty($cmt_tree) ? '-' : '') . $i) . '.xml', $files)) { if (!in_array($dir . '/' . $cmt_tree . ((!empty($cmt_tree) ? '-' : '') . $i) . '.xml', $deleted_files)) { deletion_notice($dir . '/' . $cmt_tree . ((!empty($cmt_tree) ? '-' : '') . $i) . '.xml', $show_cmt, $check); // Display notice $deleted_files[] = $dir . '/' . $cmt_tree . ((!empty($cmt_tree) ? '-' : '') . $i) . '.xml'; } } } $cmt_tree .= (!empty($cmt_tree) ? '-' : '') . $reply; } // Check whether to generate output if (!empty($check) and $check == 'yes' or $check == 'true') { $show_cmt = parse_comments($file, $show_cmt, 'yes'); } // Count comment if (preg_match('/-/', basename($file, '.xml'))) { $thread_parts = explode('-', basename($file)); $thread = $dir . '/' . basename($file, '-' . end($thread_parts)) . '.xml'; $subfile_count["{$thread}"] = isset($subfile_count["{$thread}"]) ? $subfile_count["{$thread}"] + 1 : 1; } $subfile_count["{$file}"]++; // Count comment } }
function parse_comments(&$comment, &$rss, &$xml, &$hashover) { // Skip deleted/unmoderated comments if (isset($comment['notice'])) { return; } // Encode HTML entities $comment['body'] = htmlentities($comment['body'], ENT_COMPAT, 'UTF-8', true); // Decode HTML entities $comment['body'] = html_entity_decode($comment['body'], ENT_COMPAT, 'UTF-8'); // Remove [img] tags $comment['body'] = preg_replace('/\\[(img|\\/img)\\]/i', '', $comment['body']); // Parse comment as markdown $comment['body'] = $hashover->markdown->parseMarkdown($comment['body']); // Get name from comment or use configured default $name = !empty($comment['name']) ? $comment['name'] : $hashover->setup->defaultName; // Create item element $item = $xml->createElement('item'); // Generate comment summary item title $title = $name . ' : '; $single_comment = str_replace(PHP_EOL, ' ', strip_tags($comment['body'])); if (mb_strlen($single_comment) > 40) { $title .= substr($single_comment, 0, 40) . '...'; } else { $title .= $single_comment; } // Create item title element $item_title = $xml->createElement('title'); $item_title_value = $xml->createTextNode(html_entity_decode($title, ENT_COMPAT, 'UTF-8')); $item_title->appendChild($item_title_value); // Add item title element to item element $item->appendChild($item_title); // Create item name element $item_name = $xml->createElement('name'); $item_name_value = $xml->createTextNode(html_entity_decode($name, ENT_COMPAT, 'UTF-8')); $item_name->appendChild($item_name_value); // Add item name element to item element $item->appendChild($item_name); // Add HTML anchor tag to URLs (hyperlinks) $comment['body'] = preg_replace('/((ftp|http|https):\\/\\/[a-z0-9-@:%_\\+.~#?&\\/=]+) {0,}/i', '<a href="\\1" target="_blank">\\1</a>', $comment['body']); // Replace newlines with break tags $comment['body'] = str_replace(PHP_EOL, '<br>', $comment['body']); // Create item description element $item_description = $xml->createElement('description'); $item_description_value = $xml->createTextNode($comment['body']); $item_description->appendChild($item_description_value); // Add item description element to item element $item->appendChild($item_description); // Create item avatar element $item_avatar = $xml->createElement('avatar'); $web_root = 'http://' . $hashover->setup->domain . $hashover->setup->httpRoot; $item_avatar_value = $xml->createTextNode($web_root . $comment['avatar']); $item_avatar->appendChild($item_avatar_value); // Add item avatar element to item element $item->appendChild($item_avatar); if (!empty($comment['likes'])) { // Create item likes element $item_likes = $xml->createElement('likes'); $item_likes_value = $xml->createTextNode($comment['likes']); $item_likes->appendChild($item_likes_value); // Add item likes element to item element $item->appendChild($item_likes); } if ($hashover->setup->allowsDislikes === true) { if (!empty($comment['dislikes'])) { // Create item dislikes element $item_dislikes = $xml->createElement('dislikes'); $item_dislikes_value = $xml->createTextNode($comment['dislikes']); $item_dislikes->appendChild($item_dislikes_value); // Add item dislikes element to item element $item->appendChild($item_dislikes); } } // Create item publication date element $item_pubDate = $xml->createElement('pubDate'); $item_pubDate_value = $xml->createTextNode(date('D, d M Y H:i:s O', $comment['sort-date'])); $item_pubDate->appendChild($item_pubDate_value); // Add item pubDate element to item element $item->appendChild($item_pubDate); // URL to comment for item guide and link elements $item_permalink_url = $hashover->setup->metadata['url'] . '#' . $comment['permalink']; // Create item guide element $item_guid = $xml->createElement('guid'); $item_guid_value = $xml->createTextNode($item_permalink_url); $item_guid->appendChild($item_guid_value); // Add item guide element to item element $item->appendChild($item_guid); // Create item link element $item_link = $xml->createElement('link'); $item_link_value = $xml->createTextNode($item_permalink_url); $item_link->appendChild($item_link_value); // Add item link element to item element $item->appendChild($item_link); // Add item element to main RSS element $rss->appendChild($item); // Recursively parse replies if (!empty($comment['replies'])) { foreach ($comment['replies'] as $reply) { parse_comments($reply, $rss, $xml, $hashover); } } }
} }, $html_template) . PHP_EOL; } else { echo '<a name="' . $comments["{$array}"]['permalink'] . '"></a>' . PHP_EOL; echo '<div style="margin: ' . $comments["{$array}"]['indent'] . '; clear: both;" class="' . $comments["{$array}"]['cmtclass'] . '">' . PHP_EOL; echo $comments["{$array}"]['deletion_notice'] . PHP_EOL; echo '</div>' . PHP_EOL; } } } // Display most popular comments if (!empty($top_likes)) { echo "\t" . '<br><b class="cmtfont">' . $text['popular_cmts'] . ' Comment' . (count($top_likes) != '1' ? 's' : '') . ':</b>' . PHP_EOL; $variable = ''; foreach ($top_likes as $file) { $likes_array = parse_comments($file, array(), 'no'); } parse_template(array_values($likes_array), $top_cmts); } // Display comment count echo "\t" . '<br><b class="cmtfont">' . $text['showing_cmts'] . ' ' . ($script = $cmt_count == "1" ? '0 Comments:</b>' . PHP_EOL : display_count() . ':</b>' . PHP_EOL); // Display comments, if there are no comments display a note if (!empty($show_cmt)) { parse_template($show_cmt, $total_count); } else { echo "\t" . '<div style="margin: 16px 0px 12px 0px;" class="cmtdiv">' . PHP_EOL; echo "\t\t" . '<span class="cmtnumber"><img width="' . $icon_size . '" height="' . $icon_size . '" src="/img/first-comment.png"></span>' . PHP_EOL; echo "\t\t" . '<div style="height: ' . $icon_size . 'px;" class="cmtbubble">' . PHP_EOL; echo "\t\t\t" . '<b class="cmtnote cmtfont" style="color: #000000;">Be the first to comment!</b>' . PHP_EOL; echo "\t\t" . '</div>' . PHP_EOL; echo "\t" . '</div>' . PHP_EOL;
echo jsAddSlashes('<input type="hidden" name="zip" value="" placeholder="Last Name">\\n'); echo jsAddSlashes('</div>\\n') . PHP_EOL; $rows = "'+rows+'"; $replyborder = (isset($_COOKIE['success']) and $_COOKIE['success'] == "no") ? ' border: 2px solid #FF0000 !important; -moz-border-radius: 5px 5px 0px 0px; border-radius: 5px 5px 0px 0px;' : ''; echo jsAddSlashes('<textarea rows="' . $rows . '" cols="63" name="comment" onFocus="this.value=(this.value==\'' . $text['comment_form'] . '\') ? \'\' : this.value;" onBlur="this.value=(this.value==\'\') ? \'' . $text['comment_form'] . '\' : this.value;" style="width: 100%;' . $replyborder . '" title="' . $text['cmt_tip'] . '">' . $text['comment_form'] . '</textarea><br>\\n'); echo jsAddSlashes('<input class="post_cmt" type="submit" value="' . $text['post_button'] . '" style="width: 100%;" onClick="return noemail();" onsubmit="return noemail();"><br>\\n'); echo (isset($_GET['canon_url']) or isset($canon_url)) ? jsAddSlashes('<input type="hidden" name="canon_url" value="' . $page_url . '">\\n') : ''; echo isset($_COOKIE['replied']) ? jsAddSlashes('<input type="hidden" name="reply_to" value="' . $_COOKIE['replied'] . '">\\n') : ''; echo jsAddSlashes('</div>\\n</form><br>\\n') . PHP_EOL; // Display three most popular comments if (!empty($top_likes)) { echo jsAddSlashes('<br><b class="cmtfont">' . $text['popular_cmts'] . ' Comment' . (count($top_likes) != '1' ? 's' : '') . ':</b>\\n') . PHP_EOL; echo 'var popComments = [' . PHP_EOL; for ($p = 1; $p <= count($top_likes) and $p <= $top_cmts; $p++) { if (!empty($top_likes)) { echo parse_comments(array_shift($top_likes), '', 'no'); } } echo '];' . PHP_EOL . PHP_EOL; echo 'for (var comment in popComments) {' . PHP_EOL; echo "\t" . 'parse_template(popComments[comment], false);' . PHP_EOL; echo '}' . PHP_EOL . PHP_EOL; } if (!empty($show_cmt)) { echo 'var comments = [' . PHP_EOL; echo $show_cmt; echo '];' . PHP_EOL . PHP_EOL; } // Display comment count echo jsAddSlashes('<br><b class="cmtfont">' . $text['showing_cmts'] . ' ' . ($script = $cmt_count == "1" ? '0 Comments:</b>\\n' : display_count() . ':</b>\\n')) . PHP_EOL; // Display comments, if there are no comments display a note
$temp_short = get_template('com_fulltemp.php', true); $temp_short .= '<script src="' . $furl . '/jsfunc.js" type="text/javascript"></script>' . "\n"; $temp_short = replace_masks($temp_short, array('post_id' => $news_info['post_id'], 'subject' => $news_info['subject'], 'description' => $news_info['description'], 'user' => $news_info['writer'], 'date' => $news_info['date'], 'send' => $news_info['link_tell_friend'], 'news' => $news_info['news'], 'fullstory' => $news_info['fullnews'], 'icon' => $news_info['icon'], 'nrc' => $news_info['nrc'], 'com' => $news_info['link_comments'], 'cat_id' => $news_info['cat_id'], 'cat_name' => $news_info['cat_name'], 'cat_icon' => $news_info['cat_icon'], 'pagination' => $pagination)); $temp_short = preg_replace('#{prev_page\\|(.+)}#U', $prev_page, $temp_short); $temp_short = preg_replace('#{next_page\\|(.+)}#U', $next_page, $temp_short); $count = 0; $comment_template = get_template('com_temp.php', true); $comments = ''; $validated_comments = array_reverse($validated_comments); foreach ($validated_comments as $comment) { if ($count < $start || $count >= $end) { // Valid comment, but not to be displayed on this post. $count++; continue; } parse_comments($comment['message'], $comment['author'], $comment['email']); $commenthtml = $comment_template; $comments .= replace_masks($commenthtml, array('poster' => $comment['author'], 'comment' => $comment['message'], 'date' => date($datefor, (int) $comment['timestamp']), 'posterip' => $comment['ip'])); $count++; } if (empty($comments)) { $comments = $com12; } $extras = show_extras('comment_form', 'comment', $smilcom, $bbc); $box = $extras . '<textarea id="comment" name="comment" rows="$2" cols="$1"></textarea>'; $temp_short = str_replace('{comments}', $comments, $temp_short); $temp_short = str_replace('[form]', '<form action="?fn_mode=comments&fn_action=post&fn_id=' . $id . $qs . '" method="post" id="comment_form">', $temp_short); $temp_short = str_replace('[/form]', '</form>', $temp_short); $temp_short = str_replace('[buttons]', '<input type="hidden" name="confirm_id" value="' . $session_id . '" /> <input type="hidden" name="fn_next" value="' . current_url() . '" /> <input type="submit" id="com_Submit" value="' . $com15 . '" />