function wp_list_comments() { $comments = ""; if (is_microblog_theme() && environment('threaded') && !isset($_POST['s'])) { global $db, $the_post, $prefix, $request; $result = $db->get_result("SELECT id FROM " . $prefix . "posts WHERE parent_id = " . $the_post->id); while ($row = $db->fetch_array($result)) { $pp = $db->get_record('posts', $row['id']); $cc = owner_of($pp); $comments .= render_comment($pp, $cc, $the_post); } } echo $comments; }
function render_comments($comments, $comment_attributes, $recaptcha_error) { if (sizeof($comments) > 0) { echo '<h4>Comments</h4>' . "\n"; echo '<ul class="comments">' . "\n"; foreach ($comments as $comment) { render_comment($comment); } echo '</ul>' . "\n"; } echo '<h4>Post Comment</h4>' . "\n"; echo '<form method="post">' . "\n"; echo '<input type="hidden" name="commenting" value="true" />' . "\n"; echo '<label for="comment_author">Name (optional)</label>' . "\n"; echo '<input id="comment_author" type="text" name="author" value="' . h($comment_attributes['author']) . '">' . "\n"; echo '<textarea name="body">' . h($comment_attributes['body']) . '</textarea>' . "\n"; echo recaptcha_get_html(RECAPTCHA_PUBLIC_KEY, $recaptcha_error); echo '<input type="submit" value="Post" />' . "\n"; echo '</form>'; }
function render_page($sid, $pid, $qid, $json) { //global $render; //global $parent; //global $keys; //global $total; global $can_moderate; global $hide_value; global $expand_value; $render = array(); $username = array(); $parent = array(); if ($sid != 0) { $comments = db_get_list("comment", "time", array("sid" => $sid)); } elseif ($pid != 0) { $comments = db_get_list("comment", "time", array("pid" => $pid)); } elseif ($qid != 0) { $comments = db_get_list("comment", "time", array("qid" => $qid)); } $total = count($comments); $k = array_keys($comments); if ($json) { writeln('{'); writeln(' "reply": ['); } else { if ($can_moderate) { writeln('<form action="/threshold" method="post">'); } writeln('<div class="comment_header">'); writeln(' <table class="fill">'); writeln(' <tr>'); if ($sid != 0) { writeln(' <td style="width: 30%"><a href="/post?sid=' . $sid . '" class="icon_16" style="background-image: url(\'/images/chat-16.png\')">Reply</a></td>'); } elseif ($pid != 0) { writeln(' <td style="width: 30%"><a href="/post?pid=' . $pid . '" class="icon_16" style="background-image: url(\'/images/chat-16.png\')">Reply</a></td>'); } elseif ($qid != 0) { writeln(' <td style="width: 30%"><a href="/post?qid=' . $qid . '" class="icon_16" style="background-image: url(\'/images/chat-16.png\')">Reply</a></td>'); } if ($can_moderate && false) { writeln(' <td style="width: 30%">'); writeln(' <table>'); writeln(' <tr>'); writeln(' <td>Hide</td>'); $s = "<select name=\"hide_value\">"; for ($i = -1; $i <= 5; $i++) { if ($i == $hide_value) { $s .= "<option selected=\"selected\">{$i}</option>"; } else { $s .= "<option>{$i}</option>"; } } $s .= "</select>"; writeln(' <td>' . $s . '</td>'); writeln(' <td><input type="submit" value="Change"/></td>'); writeln(' </tr>'); writeln(' </table>'); writeln(' </td>'); writeln(' <td style="width: 30%">'); writeln(' <table>'); writeln(' <tr>'); writeln(' <td>Expand</td>'); $s = "<select name=\"expand_value\">"; for ($i = -1; $i <= 5; $i++) { if ($i == $expand_value) { $s .= "<option selected=\"selected\">{$i}</option>"; } else { $s .= "<option>{$i}</option>"; } } $s .= "</select>"; writeln(' <td>' . $s . '</td>'); writeln(' <td><input type="submit" value="Change"/></td>'); writeln(' </tr>'); writeln(' </table>'); writeln(' </td>'); } writeln(' <td style="text-align: right; width: 30%">' . $total . ' comments</td>'); writeln(' </tr>'); writeln(' </table>'); writeln('</div>'); if ($can_moderate) { writeln('</form>'); } } for ($i = 0; $i < $total; $i++) { $comment = $comments[$k[$i]]; $zid = $comment["zid"]; if ($json) { $render[$comment["cid"]] = render_comment_json($comment["subject"], $zid, $comment["time"], $comment["cid"], $comment["comment"]); } else { $render[$comment["cid"]] = render_comment($comment["subject"], $zid, $comment["time"], $comment["cid"], $comment["comment"]); } $parent[$comment["cid"]] = $comment["parent"]; } $keys = array_keys($render); $s = ""; if (!$json && $can_moderate) { writeln('<form action="/moderate_noscript" method="post">'); if ($sid != 0) { writeln('<input type="hidden" name="sid" value="' . $sid . '"/>'); } elseif ($pid != 0) { writeln('<input type="hidden" name="pid" value="' . $pid . '"/>'); } elseif ($qid != 0) { writeln('<input type="hidden" name="qid" value="' . $qid . '"/>'); } } for ($i = 0; $i < $total; $i++) { $comment = $comments[$keys[$i]]; if ($comment["parent"] == 0) { if ($json) { $s .= recursive_render_json($render, $parent, $keys, $comment["cid"], 1) . "\n"; } else { writeln(recursive_render($render, $parent, $keys, $comment["cid"])); } } } if ($json) { if ($total > 0) { writeln(substr($s, 0, -2)); } writeln(' ]'); writeln('}'); } else { if ($can_moderate) { writeln('</form>'); } } }
function send_ping(&$model, &$rec) { if (!PING) { return; } global $db; global $request; $req =& $request; $Entry =& $db->get_table('entries'); $notify_table = $model->table; $recid = $rec->id; if (!empty($db->prefix)) { $chan = $db->prefix; } else { $chan = "chan"; } if (REALTIME_HOST) { $o = owner_of($rec); $payload = array(); if (environment('threaded') && isset($rec->parent_id) && $rec->parent_id > 0) { // push a P2 comment $par = $db->get_record('posts', $rec->parent_id); $tweet = render_comment($rec, $o, $par); $payload['html'] = $tweet; if ($rec->parent_id > 0) { $payload['in_reply_to'] = "#commentcontent-" . $rec->parent_id; } else { $payload['in_reply_to'] = "#content-" . $rec->parent_id; } } else { // push a P2 tweet $o = owner_of($rec); $tweet = '<hr />' . "\n"; $tweet .= '<h4>' . "\n"; $tweet .= '<span class="meta"> <span class="actions"> <a href="' . $request->url_for(array('resource' => $notify_table, 'id' => $recid)) . '" class="thepermalink">Permalink</a> | <a href="' . $request->url_for(array('resource' => $notify_table, 'id' => $recid)) . '" class="post-reply-link" rel="' . $recid . '">Reply</a> <br />' . "\n"; $tweet .= '</span> <br />' . "\n"; $tweet .= '<img alt="" src="' . $o->avatar . '" class="avatar avatar-48" height="48" width="48" /> <a class="nick" href="' . $o->profile . '" title="Posts by ' . $o->nickname . '">' . $o->nickname . '</a> ' . laconica_time($rec->created) . ' | <a href="">0</a> </span>' . "\n"; $tweet .= '</h4>' . "\n"; $tweet .= '<div class="postcontent" id="content-<?php echo $recid; ">' . "\n"; $tweet .= '<p>' . "\n"; $tweet .= render_notice($rec->title, $rec, $o); $tweet .= '</p>' . "\n"; $tweet .= '</div>' . "\n"; $tweet .= '<!-- // postcontent -->' . "\n"; $tweet .= '<div class="bottom_of_entry">' . "\n"; $tweet .= ' ' . "\n"; $tweet .= '</div>' . "\n"; $tweet .= '<div class="commentlist">' . "\n"; $tweet .= '</div>' . "\n"; $oldstyle = false; if ($oldstyle) { $tweet = ''; $tweet .= '<li id="prologue-' . $rec->id . '" class="user_id_' . $o->id . '">'; $tweet .= '<img alt=\'\' src=\'' . $o->avatar . '\' class=\'avatar avatar-48\' height=\'48\' width=\'48\' />'; $tweet .= '<h4>'; $tweet .= '<a href="' . $o->profile . '" title="Posts by ' . $o->nickname . '">' . $o->nickname . '</a> <span class="meta">' . date("g:i A", strtotime($rec->created)) . '<em>on</em> ' . date(get_settings('date_format'), strtotime($rec->created)) . ' |'; $tweet .= ' <span class="actions">'; $tweet .= ' <a href="' . $request->url_for(array('resource' => $notify_table, 'action' => 'entry.html', 'id' => $recid)) . '" class="thepermalink">Permalink</a>'; $tweet .= ' </span>'; $tweet .= ' <br />'; $tweet .= ' </span>'; $tweet .= ' </h4>'; $tweet .= ' <div class="postcontent" id="content-' . $rec->id . '"><p>' . render_notice($rec->title, $rec, $o) . '</p></div>'; $tweet .= ' <div class="bottom_of_entry"> </div>'; $tweet .= ' <ul class="commentlist">'; // $tweet .= ' <ul id="comments" class="commentlist">'; $tweet .= ' </ul>'; $tweet .= '</li>'; } $payload['html'] = $tweet; $payload['in_reply_to'] = 0; } if (!class_exists('Services_JSON')) { lib_include('json'); } $json = new Services_JSON(); $load = $json->encode($payload); $curl = curl_init("http://" . REALTIME_HOST . ":" . REALTIME_PORT); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 1); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'ADDMESSAGE ' . $chan . ' ' . addslashes($load)); $output = curl_exec($curl); } if (!get_profile_id()) { return; } if (array_key_exists('target_id', $model->field_array)) { $e = $Entry->find($rec->attributes['target_id']); if ($e) { $notify_table = $e->resource; $recid = $e->record_id; } } $url = environment('ping_server'); if (empty($url)) { return; } $url .= "=" . $request->url_for(array('resource' => $notify_table, 'action' => 'entry.html', 'id' => $recid)); $curl = curl_init($url); $method = "GET"; curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_HTTPGET, $method == "GET"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curl); }
// Pipecode is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Pipecode. If not, see <http://www.gnu.org/licenses/>. // include "render.php"; $cid = (int) $s2; if (!string_uses($cid, "[0-9]")) { die("invalid cid [{$cid}]"); } $comment = db_get_rec("comment", $cid); $can_moderate = false; $a = article_info($comment); print_header($comment["subject"]); writeln('<table class="fill">'); writeln('<tr>'); writeln('<td class="left_col">'); print_left_bar("main", "stories"); writeln('</td>'); writeln('<td class="fill">'); writeln('<h1>' . ucwords($a["type"]) . '</h1>'); writeln('<a href="' . $a["link"] . '">' . $a["title"] . '</a>'); writeln('<h2>Preview</h2>'); writeln(render_comment($comment["subject"], $comment["zid"], $comment["time"], $comment["cid"], $comment["comment"])); writeln('</div>'); writeln('</td>'); writeln('</tr>'); writeln('</table>');
print_header("Comments"); //writeln('<hr/>'); writeln('<table class="fill">'); writeln('<tr>'); writeln('<td class="left_col">'); if ($auth_zid == $zid) { print_left_bar("account", "comments"); } else { print_left_bar("user", "comments"); } writeln('</td>'); writeln('<td class="fill">'); writeln('<h1>Comments</h1>'); $row = run_sql("select cid, subject, time, comment from comment where zid = ? order by time desc limit {$row_start}, {$rows_per_page}", array($zid)); for ($i = 0; $i < count($row); $i++) { writeln(render_comment($row[$i]["subject"], $zid, $row[$i]["time"], $row[$i]["cid"], $row[$i]["comment"])); writeln('</div>'); } $s = ""; for ($i = 1; $i <= $pages_count; $i++) { if ($i == $page) { $s .= "{$i} "; } else { $s .= "<a href=\"?page={$i}\">{$i}</a> "; } } writeln('<div style="text-align: center">' . trim($s) . '</div>'); writeln('</td>'); writeln('</tr>'); writeln('</table>'); print_footer();