Пример #1
0
 $pagetitle = $story->DisplayElements('page_title');
 if (empty($pagetitle)) {
     $pagetitle = $story->DisplayElements('title');
 }
 $headercode = '';
 $permalink = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid());
 $headercode .= '<link rel="canonical" href="' . $permalink . '"' . XHTML . '>';
 // Meta Tags
 if ($_CONF['meta_tags'] > 0) {
     $meta_description = $story->DisplayElements('meta_description');
     $meta_keywords = $story->DisplayElements('meta_keywords');
     $headercode .= COM_createMetaTags($meta_description, $meta_keywords);
 }
 if ($story->DisplayElements('trackbackcode') == 0) {
     if ($_CONF['trackback_enabled']) {
         $trackbackurl = TRB_makeTrackbackUrl($story->getSid());
         $headercode .= LB . '<!--' . LB . TRB_trackbackRdf($permalink, $pagetitle, $trackbackurl) . LB . '-->' . LB;
     }
     if ($_CONF['pingback_enabled']) {
         header('X-Pingback: ' . $_CONF['site_url'] . '/pingback.php');
     }
 }
 $display .= COM_siteHeader('menu', $pagetitle, $headercode);
 if (isset($_GET['msg'])) {
     $msg = COM_applyFilter($_GET['msg'], true);
     if ($msg > 0) {
         $plugin = '';
         if (isset($_GET['plugin'])) {
             $plugin = COM_applyFilter($_GET['plugin']);
         }
         $display .= COM_showMessage($msg, $plugin);
Пример #2
0
/**
* Render all the trackback comments for a specific entry
*
* @param    string  $sid            entry id
* @param    string  $type           type of entry ('article' = story, etc.)
* @param    string  $title          the entry's title
* @param    string  $permalink      link to the entry
* @param    string  trackback_url   trackback URL for this entry
* @return   string                  HTML (formatted list of trackback comments)
*
*/
function TRB_renderTrackbackComments($sid, $type, $title, $permalink, $trackback_url = '')
{
    global $_CONF, $_TABLES, $LANG_TRB;
    $link_and_title = COM_createLink($title, $permalink);
    if (empty($trackback_url)) {
        $trackback_url = TRB_makeTrackbackUrl($sid, $type);
    }
    $template = COM_newTemplate($_CONF['path_layout'] . 'trackback');
    $template->set_file(array('trackback' => 'trackback.thtml', 'comment' => 'trackbackcomment.thtml'));
    $template->set_var('lang_trackback', $LANG_TRB['trackback']);
    $template->set_var('lang_trackback_url', $LANG_TRB['this_trackback_url']);
    $template->set_var('permalink', $permalink);
    $template->set_var('permalink_and_title', $link_and_title);
    $template->set_var('trackback_url', $trackback_url);
    $result = DB_query("SELECT cid,url,title,blog,excerpt,ipaddress,UNIX_TIMESTAMP(date) AS day " . "FROM {$_TABLES['trackback']} WHERE sid = '{$sid}' AND type = '{$type}' ORDER BY date");
    $numrows = DB_numRows($result);
    $template->set_var('trackback_comment_count', $numrows);
    $num_comments = sprintf($LANG_TRB['num_comments'], $numrows);
    $template->set_var('trackback_comment_text', $num_comments);
    if ($numrows == 0) {
        $template->set_var('lang_trackback_comments', $LANG_TRB['no_comments']);
        $template->set_var('lang_trackback_comments_no_link', $LANG_TRB['no_comments']);
    } else {
        $template->set_var('lang_trackback_comments', sprintf($LANG_TRB['intro_text'], $link_and_title));
        $template->set_var('lang_trackback_comments_no_link', sprintf($LANG_TRB['intro_text'], $title));
    }
    $delete_option = TRB_allowDelete($sid, $type);
    $token = '';
    if ($delete_option && $numrows > 0) {
        $token = SEC_createToken();
    }
    for ($i = 0; $i < $numrows; $i++) {
        $A = DB_fetchArray($result);
        $comment = TRB_formatComment($A['url'], $A['title'], $A['blog'], $A['excerpt'], $A['day'], $delete_option, $A['cid'], $A['ipaddress'], $token);
        $template->set_var('formatted_comment', $comment);
        $template->parse('trackback_comments', 'comment', true);
    }
    $template->parse('output', 'trackback');
    return $template->finish($template->get_var('output'));
}
Пример #3
0
/**
* Get content for a feed that holds all stories.
*
* @param    boolean  $frontpage_only true: only articles shown on the frontpage
* @param    string   $limit    number of entries or number of stories
* @param    string   $link     link to homepage
* @param    string   $update   list of story ids
* @param    int      $contentLength Length of summary to allow.
* @param    int      $fid       the id of the feed being fetched
* @return   array              content of the feed
*
*/
function SYND_getFeedContentAll($frontpage_only, $limit, &$link, &$update, $contentLength, $feedType, $feedVersion, $fid)
{
    global $_TABLES, $_CONF, $LANG01;
    $link = $_CONF['site_url'];
    $where = '';
    if (!empty($limit)) {
        if (substr($limit, -1) == 'h') {
            $limitsql = '';
            $hours = substr($limit, 0, -1);
            $where = " AND date >= DATE_SUB(NOW(),INTERVAL {$hours} HOUR)";
        } else {
            $limitsql = ' LIMIT ' . $limit;
        }
    } else {
        $limitsql = ' LIMIT 10';
    }
    // get list of topics that anonymous users have access to
    $topics = array();
    $tresult = DB_query("SELECT tid,topic FROM {$_TABLES['topics']}" . COM_getPermSQL('WHERE', 1));
    $tnumrows = DB_numRows($tresult);
    if ($tnumrows == 0) {
        // no public topics
        $update = '';
        return array();
    }
    $tlist = '';
    for ($i = 1; $i <= $tnumrows; $i++) {
        $T = DB_fetchArray($tresult);
        $tlist .= "'" . $T['tid'] . "'";
        if ($i < $tnumrows) {
            $tlist .= ',';
        }
        $topics[$T['tid']] = stripslashes($T['topic']);
    }
    if (!empty($tlist)) {
        $where .= " AND (ta.tid IN ({$tlist}))";
    }
    if ($frontpage_only) {
        $where .= ' AND frontpage = 1';
    }
    $sql = "SELECT sid,ta.tid,uid,title,introtext,bodytext,postmode,UNIX_TIMESTAMP(date) AS modified,commentcode,trackbackcode\n        FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n        WHERE draft_flag = 0 AND date <= NOW() AND ta.type = 'article' AND ta.id = sid AND ta.tdefault = 1 {$where} AND perm_anon > 0\n        GROUP BY sid,ta.tid\n        ORDER BY date DESC {$limitsql}";
    $result = DB_query($sql);
    $content = array();
    $sids = array();
    $nrows = DB_numRows($result);
    for ($i = 1; $i <= $nrows; $i++) {
        $row = DB_fetchArray($result);
        $sids[] = $row['sid'];
        $storytitle = stripslashes($row['title']);
        $fulltext = stripslashes($row['introtext'] . "\n" . $row['bodytext']);
        $fulltext = PLG_replaceTags($fulltext);
        $storytext = $contentLength == 1 ? $fulltext : COM_truncateHTML($fulltext, $contentLength, ' ...');
        $fulltext = trim($fulltext);
        $fulltext = str_replace(array("\r\n", "\r"), "\n", $fulltext);
        if ($row['postmode'] == 'plaintext') {
            if (!empty($storytext)) {
                $storytext = COM_nl2br($storytext);
            }
            if (!empty($fulltext)) {
                $fulltext = COM_nl2br($fulltext);
            }
        }
        $storylink = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $row['sid']);
        $extensionTags = PLG_getFeedElementExtensions('article', $row['sid'], $feedType, $feedVersion, $fid, $frontpage_only ? '::frontpage' : '::all');
        if ($_CONF['trackback_enabled'] && $feedType == 'RSS' && $row['trackbackcode'] >= 0) {
            $trbUrl = TRB_makeTrackbackUrl($row['sid']);
            $extensionTags['trackbacktag'] = '<trackback:ping>' . htmlspecialchars($trbUrl) . '</trackback:ping>';
        }
        $article = array('title' => $storytitle, 'summary' => $storytext, 'text' => $fulltext, 'link' => $storylink, 'uid' => $row['uid'], 'author' => COM_getDisplayName($row['uid']), 'date' => $row['modified'], 'format' => $row['postmode'], 'topic' => $topics[$row['tid']], 'extensions' => $extensionTags);
        if ($row['commentcode'] >= 0) {
            $article['commenturl'] = $storylink . '#comments';
        }
        $content[] = $article;
    }
    $update = implode(',', $sids);
    return $content;
}