function print_entry($x, &$entry, $header = false)
 {
     if ($header) {
         $this->pdf->AddPage();
         $this->pdf->SetFont('Courier', '', 12);
         $this->pdf->TOC_Add($header);
         $this->pdf->Cell(0, 10, $header, 1);
         $this->pdf->Ln();
         $this->pdf->Ln();
     }
     $entryLink = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
     serendipity_plugin_api::hook_event('frontend_display', $entry, array('no_scramble' => true));
     $posted_by = ' ' . POSTED_BY . ' ' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['author']) : htmlspecialchars($entry['author'], ENT_COMPAT, LANG_CHARSET));
     if (is_array($entry['categories']) && sizeof($entry['categories']) > 0) {
         $posted_by .= ' ' . IN . ' ';
         $cats = array();
         foreach ($entry['categories'] as $cat) {
             $cats[] = $cat['category_name'];
         }
         $posted_by .= implode(', ', $cats);
     }
     $posted_by .= ' ' . AT . ' ' . serendipity_strftime('%H:%M', $entry['timestamp']);
     $this->pdf->SetFont('Arial', 'B', 11);
     $this->pdf->Write(4, $this->prep_out($entry['title']) . "\n");
     $this->pdf->Ln();
     $this->pdf->SetFont('Arial', '', 10);
     $html = $this->prep_out($entry['body'] . $entry['extended']) . "\n";
     if (serendipity_db_bool($this->get_config('html2pdf'))) {
         $this->pdf->WriteHTML($html);
     } else {
         $this->pdf->Write(4, $html);
     }
     $this->pdf->Ln();
     $this->pdf->SetFont('Courier', '', 9);
     $this->pdf->Write(4, $this->prep_out($posted_by) . "\n");
     $this->pdf->Ln();
     if ($this->single) {
         $this->printComments(serendipity_fetchComments($entry['id']));
     }
 }
/**
 * Fetches and prints a listing of comments by author
 */
function serendipity_printCommentsByAuthor()
{
    global $serendipity;
    $type = serendipity_db_escape_string($serendipity['GET']['commentMode']);
    if ($type == 'comments' || empty($type)) {
        $type = 'NORMAL';
    } elseif ($type == 'trackbacks') {
        $type = 'TRACKBACK';
    } elseif ($type == 'comments_and_trackbacks') {
        $type = '%';
    }
    if (!empty($serendipity['GET']['viewCommentAuthor'])) {
        $sql_where = " AND co.author = '" . serendipity_db_escape_string($serendipity['GET']['viewCommentAuthor']) . "'";
        $group_by = "GROUP BY co.author";
    } else {
        $sql_where = " AND 1";
        // Required fake 'where' condition
        $group_by = "";
    }
    if (!empty($serendipity['GET']['commentStartTime'])) {
        $sql_where .= " AND co.timestamp >= " . (int) $serendipity['GET']['commentStartTime'];
    }
    if (!empty($serendipity['GET']['commentEndTime'])) {
        $sql_where .= " AND co.timestamp <= " . (int) $serendipity['GET']['commentEndTime'];
    }
    if (empty($serendipity['GET']['page'])) {
        $serendipity['GET']['page'] = 1;
    }
    $sql_limit = $serendipity['fetchLimit'] * ($serendipity['GET']['page'] - 1) . ',' . $serendipity['fetchLimit'];
    $c = serendipity_fetchComments(null, $sql_limit, 'co.entry_id DESC, co.id ASC', false, $type, $sql_where);
    $entry_comments = array();
    foreach ($c as $i => $comment) {
        if (!isset($entry_comments[$comment['entry_id']])) {
            $comment['link'] = serendipity_archiveURL($comment['entry_id'], $comment['title'], 'serendipityHTTPPath', true, array('timestamp' => $comment['entrytimestamp']));
            $entry_comments[$comment['entry_id']] = $comment;
        }
        $entry_comments[$comment['entry_id']]['comments'][] = $comment;
    }
    foreach ($entry_comments as $entry_id => $_data) {
        $entry_comments[$entry_id]['tpl_comments'] =& serendipity_printComments($_data['comments'], VIEWMODE_LINEAR, 0, null, 'COMMENTS', 'comments.tpl');
    }
    $serendipity['smarty']->assign_by_ref('comments_by_authors', $entry_comments);
    if (!empty($id)) {
        $and .= " AND co.entry_id = '" . (int) $id . "'";
    }
    if (!$showAll) {
        $and .= ' AND co.status = \'approved\'';
    }
    $fc = "SELECT count(co.id) AS counter\n                                  FROM {$serendipity['dbPrefix']}comments AS co\n                                 WHERE co.entry_id > 0\n                                   AND co.type LIKE '" . $type . "'\n                                   AND co.status = 'approved' " . $sql_where . " " . $group_by;
    $cc = serendipity_db_query($fc, true, 'assoc');
    if (!isset($cc['counter'])) {
        $totalComments = 0;
    } else {
        $totalComments = $cc['counter'];
    }
    serendipity_printEntryFooter('', $totalComments);
    serendipity_smarty_fetch('ENTRIES', 'comments_by_author.tpl');
    return true;
}
/**
 * Receive a pingback
 *
 * @access public
 * @param   int     The entryid to receive a pingback for
 * @param   string  The foreign postdata to add
 * @return boolean
 */
function add_pingback($id, $postdata)
{
    global $serendipity;
    log_pingback("Reached add_pingback. ID:[{$id}]");
    // XML-RPC Method call without named parameter. This seems to be the default way using XML-RPC
    if (preg_match('@<methodCall>\\s*<methodName>\\s*pingback.ping\\s*</methodName>\\s*<params>\\s*<param>\\s*<value>\\s*<string>([^<]*)</string>\\s*</value>\\s*</param>\\s*<param>\\s*<value>\\s*<string>([^<]*)</string>\\s*</value>\\s*</param>\\s*</params>\\s*</methodCall>@is', $postdata, $matches)) {
        log_pingback("Pingback wp structure.");
        $remote = $matches[1];
        $local = $matches[2];
        log_pingback("remote={$remote}, local={$local}");
        $path = parse_url($remote);
        $comment['title'] = 'PingBack';
        $comment['url'] = $remote;
        $comment['comment'] = '';
        $comment['name'] = $path['host'];
        fetchPingbackData($comment);
        // if no ID parameter was given, try to get one from targetURI
        if (!isset($id) || $id == 0) {
            log_pingback("ID not found");
            $id = evaluateIdByLocalUrl($local);
            log_pingback("ID set to {$id}");
        }
        if ($id > 0) {
            // first check, if we already have this pingback
            $comments = serendipity_fetchComments($id, 1, 'co.id', true, 'PINGBACK', " AND co.url='" . serendipity_db_escape_string($remote) . "'");
            if (is_array($comments) && sizeof($comments) == 1) {
                log_pingback("We already have that PINGBACK!");
                return 0;
                // We already have it!
            }
            // We don't have it, so save the pingback
            serendipity_saveComment($id, $comment, 'PINGBACK');
            return 1;
        } else {
            return 0;
        }
    }
    // XML-RPC Method call with named parameter. I'm not sure, if XML-RPC supports this, but just to be sure
    $sourceURI = getPingbackParam('sourceURI', $postdata);
    $targetURI = getPingbackParam('targetURI', $postdata);
    if (isset($sourceURI) && isset($targetURI)) {
        log_pingback("Pingback spec structure.");
        $path = parse_url($sourceURI);
        $local = $targetURI;
        $comment['title'] = 'PingBack';
        $comment['url'] = $sourceURI;
        $comment['comment'] = '';
        $comment['name'] = $path['host'];
        fetchPingbackData($comment);
        // if no ID parameter was given, try to get one from targetURI
        if (!isset($id) || $id == 0) {
            log_pingback("ID not found");
            $id = evaluateIdByLocalUrl($local);
            log_pingback("ID set to {$id}");
        }
        if ($id > 0) {
            serendipity_saveComment($id, $comment, 'PINGBACK');
            return 1;
        } else {
            return 0;
        }
    }
    return 0;
}
    function showElementCommentlist($where, $limit)
    {
        global $serendipity;
        $summaryLength = 200;
        $i = 0;
        if (version_compare(substr($serendipity['version'], 0, 3), '1.6') >= 0) {
            $comments = serendipity_fetchComments(null, $limit, 'co.id DESC', true, 'NORMAL', $where);
        } else {
            $comments = serendipity_db_query("SELECT c.*, e.title FROM {$serendipity['dbPrefix']}comments c\n                                        LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = c.entry_id)\n                                        WHERE 1 = 1 " . $where . (!serendipity_checkPermission('adminEntriesMaintainOthers') ? 'AND e.authorid = ' . (int) $serendipity['authorid'] : '') . "\n                                        ORDER BY c.id DESC LIMIT {$limit}");
        }
        if (!is_array($comments)) {
            return;
        }
        if (count($comments) == 0) {
            return;
        }
        echo '<table width="100%" cellpadding="3" border="0" cellspacing="0">';
        foreach ($comments as $rs) {
            $i++;
            $comment = array('fullBody' => $rs['body'], 'summary' => serendipity_mb('substr', $rs['body'], 0, $summaryLength), 'status' => $rs['status'], 'type' => $rs['type'], 'id' => $rs['id'], 'title' => $rs['title'], 'timestamp' => $rs['timestamp'], 'referer' => $rs['referer'], 'url' => $rs['url'], 'ip' => $rs['ip'], 'entry_url' => serendipity_archiveURL($rs['entry_id'], $rs['title']), 'email' => $rs['email'], 'author' => empty($rs['author']) ? ANONYMOUS : $rs['author'], 'entry_id' => $rs['entry_id']);
            $entrylink = serendipity_archiveURL($comment['entry_id'], 'comments', 'serendipityHTTPPath', true) . '#c' . $comment['id'];
            if (strlen($comment['fullBody']) > strlen($comment['summary'])) {
                $comment['summary'] .= ' ...';
                $comment['excerpt'] = true;
                // When summary is not the full body, strip HTML tags from summary, as it might break and leave unclosed HTML.
                $comment['fullBody'] = nl2br(function_exists('serendipity_specialchars') ? serendipity_specialchars($comment['fullBody']) : htmlspecialchars($comment['fullBody'], ENT_COMPAT, LANG_CHARSET));
                $comment['summary'] = nl2br(strip_tags($comment['summary']));
            } else {
                $comment['excerpt'] = false;
                $comment['fullBody'] = $comment['summary'] = nl2br(function_exists('serendipity_specialchars') ? serendipity_specialchars($comment['fullBody']) : htmlspecialchars($comment['fullBody'], ENT_COMPAT, LANG_CHARSET));
            }
            #serendipity_plugin_api::hook_event('backend_view_comment', $comment, '&amp;serendipity[page]='. $page . $searchString);
            $class = 'serendipity_admin_list_item_' . ($i % 2 == 0 ? 'even' : 'uneven');
            if ($comment['status'] == 'pending' || $comment['status'] === 'confirm') {
                $class .= ' serendipity_admin_comment_pending';
            }
            $header_class = $comment['status'] == 'pending' || $comment['status'] === 'confirm' ? 'serendipityAdminMsgNote serendipity_admin_comment_pending_header' : '';
            ?>
        <tr>
            <td class="<?php 
            echo $header_class;
            ?>
">
        <?php 
            if ($header_class == 'serendipityAdminMsgNote serendipity_admin_comment_pending_header') {
                ?>
                    <img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="<?php 
                echo serendipity_getTemplateFile('admin/img/admin_msg_note.png');
                ?>
" alt="" />
        <?php 
            }
            ?>
                <a name="c<?php 
            echo $comment['id'];
            ?>
"></a>
                <?php 
            echo ($comment['type'] == 'NORMAL' ? COMMENT : ($comment['type'] == 'TRACKBACK' ? TRACKBACK : PINGBACK)) . ' #' . $comment['id'] . ', ' . IN_REPLY_TO . ' <strong><a href="' . $comment['entry_url'] . '">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($comment['title']) : htmlspecialchars($comment['title'], ENT_COMPAT, LANG_CHARSET)) . '</a></strong>, ' . ON . ' ' . serendipity_formatTime('%b %e %Y, %H:%M', $comment['timestamp']);
            ?>
            </td>
        </tr>
        <tr>
            <td class="serendipity_admin_list_item <?php 
            echo $class;
            ?>
" id="comment_<?php 
            echo $comment['id'];
            ?>
">
                <table width="100%" cellspacing="0" cellpadding="3" border="0">
                    <tr>
                        <td width="40%"><strong><?php 
            echo AUTHOR;
            ?>
</strong>: <?php 
            echo (function_exists('serendipity_specialchars') ? serendipity_specialchars(serendipity_truncateString($comment['author'], 30)) : htmlspecialchars(serendipity_truncateString($comment['author'], 30), ENT_COMPAT, LANG_CHARSET)) . $comment['action_author'];
            ?>
</td>
                        <td><strong><?php 
            echo EMAIL;
            ?>
</strong>:
                            <?php 
            if (empty($comment['email'])) {
                echo 'N/A';
            } else {
                ?>
                                    <a href="mailto:<?php 
                echo function_exists('serendipity_specialchars') ? serendipity_specialchars($comment['email']) : htmlspecialchars($comment['email'], ENT_COMPAT, LANG_CHARSET);
                ?>
" title="<?php 
                echo function_exists('serendipity_specialchars') ? serendipity_specialchars($comment['email']) : htmlspecialchars($comment['email'], ENT_COMPAT, LANG_CHARSET);
                ?>
"><?php 
                echo function_exists('serendipity_specialchars') ? serendipity_specialchars(serendipity_truncateString($comment['email'], 30)) : htmlspecialchars(serendipity_truncateString($comment['email'], 30), ENT_COMPAT, LANG_CHARSET);
                ?>
</a>
                            <?php 
            }
            ?>
                        <?php 
            echo $comment['action_email'];
            ?>
                        </td>
                    </tr>
                    <tr>
                        <td width="40%"><strong>IP</strong>:
                            <?php 
            if (empty($comment['ip'])) {
                echo '0.0.0.0';
            } else {
                echo function_exists('serendipity_specialchars') ? serendipity_specialchars($comment['ip']) : htmlspecialchars($comment['ip'], ENT_COMPAT, LANG_CHARSET);
            }
            ?>
                            <?php 
            echo $comment['action_ip'];
            ?>
                            </td>
                        <td><strong><?php 
            echo URL;
            ?>
</strong>:
                            <?php 
            if (empty($comment['url'])) {
                echo 'N/A';
            } else {
                ?>
                                    <a href="<?php 
                echo function_exists('serendipity_specialchars') ? serendipity_specialchars($comment['url']) : htmlspecialchars($comment['url'], ENT_COMPAT, LANG_CHARSET);
                ?>
" title="<?php 
                echo function_exists('serendipity_specialchars') ? serendipity_specialchars($comment['url']) : htmlspecialchars($comment['url'], ENT_COMPAT, LANG_CHARSET);
                ?>
" target="_blank"><?php 
                echo function_exists('serendipity_specialchars') ? serendipity_specialchars(serendipity_truncateString($comment['url'], 30)) : htmlspecialchars(serendipity_truncateString($comment['url'], 30), ENT_COMPAT, LANG_CHARSET);
                ?>
</a>
                            <?php 
            }
            ?>
                            <?php 
            echo $comment['action_url'];
            ?>
                            </td>
                    </tr>
                    <tr>
                        <td width="40%">&nbsp;</td>
                        <td><strong><?php 
            echo REFERER;
            ?>
</strong>:
                            <?php 
            if (empty($comment['referer'])) {
                echo 'N/A';
            } else {
                ?>
                                  <a href="<?php 
                echo function_exists('serendipity_specialchars') ? serendipity_specialchars($comment['referer']) : htmlspecialchars($comment['referer'], ENT_COMPAT, LANG_CHARSET);
                ?>
" title="<?php 
                echo function_exists('serendipity_specialchars') ? serendipity_specialchars($comment['referer']) : htmlspecialchars($comment['referer'], ENT_COMPAT, LANG_CHARSET);
                ?>
" target="_blank"><?php 
                echo function_exists('serendipity_specialchars') ? serendipity_specialchars(serendipity_truncateString($comment['referer'], 30)) : htmlspecialchars(serendipity_truncateString($comment['referer'], 30), ENT_COMPAT, LANG_CHARSET);
                ?>
</a>
                            <?php 
            }
            ?>
                            <?php 
            echo $comment['action_referer'];
            ?>
                            </td>
                    <tr>
                        <td style="border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC" colspan="3">
                            <div id="<?php 
            echo $comment['id'];
            ?>
_summary"><?php 
            echo $comment['summary'];
            ?>
</div>
                            <div id="<?php 
            echo $comment['id'];
            ?>
_full" style="display: none"><?php 
            echo $comment['fullBody'];
            ?>
</div>
                        </td>
                    </tr>
                </table>
        <?php 
            if (($comment['status'] == 'pending' || $comment['status'] === 'confirm') && !serendipity_db_bool($this->get_config('read_only'))) {
                ?>
                  <a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=approve&amp;serendipity[id]=<?php 
                echo $comment['id'];
                ?>
&amp;<?php 
                echo serendipity_setFormToken('url');
                ?>
" class="serendipityIconLink" title="<?php 
                echo APPROVE;
                ?>
"><img src="<?php 
                echo serendipity_getTemplateFile('admin/img/accept.png');
                ?>
" alt="<?php 
                echo APPROVE;
                ?>
" /><?php 
                echo APPROVE;
                ?>
</a>
        <?php 
            }
            ?>
        <?php 
            if ($comment['status'] == 'approved' && !serendipity_db_bool($this->get_config('read_only'))) {
                ?>
                  <a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=pending&amp;serendipity[id]=<?php 
                echo $comment['id'];
                ?>
&amp;<?php 
                echo serendipity_setFormToken('url');
                ?>
" class="serendipityIconLink" title="<?php 
                echo SET_TO_MODERATED;
                ?>
"><img src="<?php 
                echo serendipity_getTemplateFile('admin/img/clock.png');
                ?>
" alt="<?php 
                echo SET_TO_MODERATED;
                ?>
" /><?php 
                echo SET_TO_MODERATED;
                ?>
</a>
        <?php 
            }
            ?>
        <?php 
            if ($comment['excerpt']) {
                ?>
                  <a href="#c<?php 
                echo $comment['id'];
                ?>
" onclick="FT_toggle(<?php 
                echo $comment['id'];
                ?>
); return false;" title="<?php 
                echo VIEW;
                ?>
" class="serendipityIconLink"><img src="<?php 
                echo serendipity_getTemplateFile('admin/img/zoom.png');
                ?>
" alt="<?php 
                echo TOGGLE_ALL;
                ?>
" /><span id="<?php 
                echo $comment['id'];
                ?>
_text"><?php 
                echo TOGGLE_ALL;
                ?>
</span></a>
        <?php 
            }
            ?>
                  <a target="_blank" href="<?php 
            echo $entrylink;
            ?>
" title="<?php 
            echo VIEW;
            ?>
" class="serendipityIconLink"><img src="<?php 
            echo serendipity_getTemplateFile('admin/img/zoom.png');
            ?>
" alt="<?php 
            echo VIEW;
            ?>
" /><?php 
            echo VIEW;
            ?>
</a>
                  <a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=edit&amp;serendipity[id]=<?php 
            echo $comment['id'];
            ?>
&amp;serendipity[entry_id]=<?php 
            echo $comment['entry_id'];
            ?>
&amp;<?php 
            echo serendipity_setFormToken('url');
            ?>
" title="<?php 
            echo EDIT;
            ?>
" class="serendipityIconLink"><img src="<?php 
            echo serendipity_getTemplateFile('admin/img/edit.png');
            ?>
" alt="<?php 
            echo EDIT;
            ?>
" /><?php 
            echo EDIT;
            ?>
</a>
        <?php 
            if (!serendipity_db_bool($this->get_config('read_only'))) {
                ?>
                  <a href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=delete&amp;serendipity[id]=<?php 
                echo $comment['id'];
                ?>
&amp;serendipity[entry_id]=<?php 
                echo $comment['entry_id'];
                ?>
&amp;<?php 
                echo serendipity_setFormToken('url');
                ?>
" onclick='return confirm("<?php 
                echo sprintf(COMMENT_DELETE_CONFIRM, $comment['id'], function_exists('serendipity_specialchars') ? serendipity_specialchars($comment['author']) : htmlspecialchars($comment['author'], ENT_COMPAT, LANG_CHARSET));
                ?>
")' title="<?php 
                echo DELETE;
                ?>
" class="serendipityIconLink"><img src="<?php 
                echo serendipity_getTemplateFile('admin/img/delete.png');
                ?>
" alt="<?php 
                echo DELETE;
                ?>
" /><?php 
                echo DELETE;
                ?>
</a>
        <?php 
            }
            ?>
                  <a target="_blank" onclick="cf = window.open(this.href, 'CommentForm', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1'); cf.focus(); return false;" href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=reply&amp;serendipity[id]=<?php 
            echo $comment['id'];
            ?>
&amp;serendipity[entry_id]=<?php 
            echo $comment['entry_id'];
            ?>
&amp;serendipity[noBanner]=true&amp;serendipity[noSidebar]=true&amp;<?php 
            echo serendipity_setFormToken('url');
            ?>
" title="<?php 
            echo REPLY;
            ?>
" class="serendipityIconLink"><img src="<?php 
            echo serendipity_getTemplateFile('admin/img/user_editor.png');
            ?>
" alt="<?php 
            echo REPLY;
            ?>
" /><?php 
            echo REPLY;
            ?>
</a>
                  <?php 
            echo $comment['action_more'];
            ?>
            </td>
        </tr>
        <?php 
        }
        echo '</table>';
    }
function wp_getComments($message)
{
    global $serendipity;
    $val = $message->params[1];
    $username = $val->getval();
    $val = $message->params[2];
    $password = $val->getval();
    if (!serendipity_authenticate_author($username, $password)) {
        return new XML_RPC_Response('', XMLRPC_ERR_CODE_AUTHFAILED, XMLRPC_ERR_NAME_AUTHFAILED);
    }
    $val = $message->params[3];
    $comment_filter = $val->getval();
    $limit = !empty($comment_filter['number']) ? $comment_filter['number'] : '10';
    // defaults to 10
    if (!empty($comment_filter['offset'])) {
        $limit = serendipity_db_limit($comment_filter['offset'], $limit);
    }
    if (version_compare($serendipity['version'], '1.6.1') >= 0) {
        $order = ' co.timestamp DESC';
    } else {
        $order = ' DESC';
    }
    //  old versions have a bug here producing wrong results
    $showAll = $comment_filter['status'] != 'approve';
    $type = 'comments_and_trackbacks';
    $entries = serendipity_fetchComments($comment_filter['post_id'], $limit, $order, $showAll, $type);
    $xml_entries_vals = array();
    foreach ((array) $entries as $entry) {
        if ($entry['commentid']) {
            $xml_entries_vals[] = _wp_createSingleCommentResult($entry);
        }
    }
    $xml_entries = new XML_RPC_Value($xml_entries_vals, 'array');
    return new XML_RPC_Response($xml_entries);
}
/**
 * Smarty Function: Show comments to an entry
 *
 * @access public
 * @param   array       Smarty parameter input array:
 *                          entry: The $entry data
 *                          mode: The default viewmode (threaded/linear)
 * @param   object  Smarty object
 * @return  string      The HTML code with the comments
 */
function &serendipity_smarty_printComments($params, &$smarty)
{
    global $serendipity;
    if (!isset($params['entry'])) {
        trigger_error("Smarty Error: " . __FUNCTION__ . ": missing 'entry' parameter", E_USER_WARNING);
        return;
    }
    if (!isset($params['mode'])) {
        $params['mode'] = VIEWMODE_THREADED;
    }
    if (isset($params['order']) && $params['order'] != 'DESC') {
        $params['order'] = 'ASC';
    }
    $comments = serendipity_fetchComments($params['entry'], (int) $params['limit'], 'co.id ' . $params['order']);
    if (!empty($serendipity['POST']['preview'])) {
        $comments[] = array('email' => $serendipity['POST']['email'], 'author' => $serendipity['POST']['name'], 'body' => $serendipity['POST']['comment'], 'url' => $serendipity['POST']['url'], 'parent_id' => $serendipity['POST']['replyTo'], 'timestamp' => time());
    }
    if (empty($params['depth'])) {
        $params['depth'] = 0;
    }
    if (empty($params['trace'])) {
        $params['trace'] = null;
    }
    if (empty($params['block'])) {
        $params['block'] = 'COMMENTS';
    }
    if (empty($params['template'])) {
        $params['template'] = 'comments.tpl';
    }
    $out = serendipity_printComments($comments, $params['mode'], $params['depth'], $params['trace'], $params['block'], $params['template']);
    return $out;
}
Example #7
0
        serendipity_approveComment((int) $serendipity['GET']['id'], (int) $rs['entry_id'], true, true);
        $msg .= DONE . ': ' . sprintf(COMMENT_MODERATED, (int) $serendipity['GET']['id']);
    }
}
/* We are asked to delete a comment */
if (isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'delete' && serendipity_checkFormToken()) {
    serendipity_deleteComment($serendipity['GET']['id'], $serendipity['GET']['entry_id']);
    $msg .= DONE . ': ' . sprintf(COMMENT_DELETED, (int) $serendipity['GET']['id']);
}
/* We are either in edit mode, or preview mode */
if (isset($serendipity['GET']['adminAction']) && ($serendipity['GET']['adminAction'] == 'edit' || $serendipity['GET']['adminAction'] == 'reply') || isset($serendipity['POST']['preview'])) {
    $serendipity['smarty_raw_mode'] = true;
    // Force output of Smarty stuff in the backend
    serendipity_smarty_init();
    if ($serendipity['GET']['adminAction'] == 'reply' || $serendipity['GET']['adminAction'] == 'doReply') {
        $c = serendipity_fetchComments($serendipity['GET']['entry_id'], 1, 'co.id', false, 'NORMAL', ' AND co.id=' . (int) $serendipity['GET']['id']);
        if (isset($serendipity['POST']['preview'])) {
            $c[] = array('email' => $serendipity['POST']['email'], 'author' => $serendipity['POST']['name'], 'body' => $serendipity['POST']['comment'], 'url' => $serendipity['POST']['url'], 'timestamp' => time(), 'parent_id' => $serendipity['GET']['id']);
        }
        $target_url = '?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=doReply&amp;serendipity[id]=' . (int) $serendipity['GET']['id'] . '&amp;serendipity[entry_id]=' . (int) $serendipity['GET']['entry_id'] . '&amp;serendipity[noBanner]=true&amp;serendipity[noSidebar]=true&amp;' . serendipity_setFormToken('url');
        $codata = $serendipity['POST'];
        $codata['replyTo'] = (int) $serendipity['GET']['id'];
        $out = serendipity_printComments($c);
        $serendipity['smarty']->display(serendipity_getTemplateFile('comments.tpl', 'serendipityPath'));
        if (!isset($codata['name'])) {
            $codata['name'] = $serendipity['serendipityRealname'];
        }
        if (!isset($codata['email'])) {
            $codata['email'] = $serendipity['serendipityEmail'];
        }
    } else {
Example #8
0
        if ($none_match == $last_modified && $modified_since == $last_modified || !$none_match && $modified_since == $last_modified || !$modified_since && $none_match == $last_modified) {
            header('HTTP/1.0 304 Not Modified');
            header('Status: 304 Not Modified');
            return;
        }
    }
}
if (isset($modified_since) && (stristr($_SERVER['HTTP_USER_AGENT'], 'planet') !== FALSE || $serendipity['enforce_RFC2616'])) {
    // People shall get a usual HTTP response according to RFC2616. See serendipity_config.inc.php for details
    $modified_since = FALSE;
}
switch ($_GET['type']) {
    case 'comments_and_trackbacks':
    case 'trackbacks':
    case 'comments':
        $entries = serendipity_fetchComments(isset($_GET['cid']) ? $_GET['cid'] : null, $serendipity['RSSfetchLimit'], 'desc', false, $_GET['type']);
        $description = $title . ' - ' . $description;
        if (isset($_GET['cid'])) {
            $title = $title . ' - ' . COMMENTS_FROM . ' "' . $latest_entry[0]['title'] . '"';
        } else {
            $title = $title . ' - ' . COMMENTS;
        }
        $comments = TRUE;
        break;
    case 'content':
    default:
        if (isset($_GET['all']) && $_GET['all']) {
            // Fetch all entries in reverse order for later importing. Fetch sticky entries as normal entries.
            $entries = serendipity_fetchEntries(null, true, '', false, false, 'id ASC', '', false, true);
        } else {
            $entries = serendipity_fetchEntries(null, true, $serendipity['RSSfetchLimit'], false, isset($modified_since) ? $modified_since : false, 'timestamp DESC', '', false, true);
 static function loadCommentSpiceByEntry($entryId)
 {
     if (empty($entryId)) {
         return FALSE;
     }
     $comments = serendipity_fetchComments($entryId);
     $result = array();
     foreach ($comments as $comment) {
         $result[] = DbSpice::loadCommentSpice($comment['id']);
     }
     return $result;
 }