Beispiel #1
0
         $subscribelinkimg = '<img src="' . _ff_getImage('forumnotify_off') . '" alt="' . $LANG_GF01['FORUMUNSUBSCRIBE'] . '" title="' . $LANG_GF01['FORUMUNSUBSCRIBE'] . '" style="vertical-align:middle;"/>';
         $subscribelink = $_CONF['site_url'] . '/forum/notify.php?filter=2';
         $subcribelanguage = $LANG_GF01['FORUMUNSUBSCRIBE'];
         $sub_option = 'unsubscribe_forum';
         $formsubscribed = TRUE;
     }
     $token = SEC_createToken();
     $topiclisting->set_var(array('subscribelink' => $subscribelink, 'subscribelinkimg' => $subscribelinkimg, 'forumsubscribed' => $forumsubscribed, 'LANG_subscribe' => $subcribelanguage, 'forum' => $forum, 'suboption' => $sub_option, 'token' => $token, 'token_name' => CSRF_TOKEN));
 }
 if (!COM_isAnonUser()) {
     $link = '<a href="' . $_CONF['site_url'] . '/forum/index.php?op=markallread&amp;cat_id=' . $category['id'] . '&amp;forum_id=' . (int) $forum . '">';
     $topiclisting->set_var(array('markreadurl' => $_CONF['site_url'] . '/forum/index.php?op=markallread&amp;cat_id=' . $category['id'] . '&amp;forum_id=' . (int) $forum, 'markreadlink' => $link, 'LANG_markread' => $LANG_GF02['msg84']));
 }
 $rssFeed = DB_getItem($_TABLES['syndication'], 'filename', 'type="forum" AND topic=' . (int) $forum . ' AND is_enabled=1');
 if (($rssFeed != '' || $rssFeed != NULL) && $skipForum == false) {
     $baseurl = SYND_getFeedUrl();
     $imgurl = '<img src="' . _ff_getImage('rss_feed') . '" alt="' . $LANG_GF01['rss_link'] . '" title="' . $LANG_GF01['rss_link'] . '" style="vertical-align:middle;"/>';
     $topiclisting->set_var('rssfeed', '<a href="' . $baseurl . $rssFeed . '">' . $imgurl . '</a>');
     $topiclisting->set_var('rssfeed_url', $baseurl . $rssFeed);
 } else {
     $topiclisting->set_var('rssfeed', '');
 }
 $topiclisting->set_var(array('cat_name' => $category['cat_name'], 'cat_id' => $category['id'], 'forum_name' => $category['forum_name'], 'forum_id' => $forum, 'LANG_TOPIC' => $LANG_GF01['TOPICSUBJECT'], 'LANG_STARTEDBY' => $LANG_GF01['STARTEDBY'], 'LANG_REPLIES' => $LANG_GF01['REPLIES'], 'LANG_VIEWS' => $LANG_GF01['VIEWS'], 'LANG_LASTPOST' => $LANG_GF01['LASTPOST'], 'LANG_AUTHOR' => $LANG_GF01['AUTHOR'], 'LANG_MSG05' => $LANG_GF01['LASTPOST'], 'LANG_newforumposts' => $LANG_GF02['msg113']));
 if ($canPost && $skipForum == false) {
     $topiclisting->set_var(array('LANG_newtopic' => $LANG_GF01['NEWTOPIC'], 'newtopiclinkimg' => '<img src="' . _ff_getImage('post_newtopic') . '" style="vertical-align:middle;" alt="' . $LANG_GF01['NEWTOPIC'] . '" title="' . $LANG_GF01['NEWTOPIC'] . '"/>', 'newtopiclink' => $_CONF['site_url'] . '/forum/createtopic.php?mode=newtopic&amp;forum=' . $forum));
 }
 $bmArray = array();
 if (!COM_isAnonUser() && $skipForum == false) {
     $sql = "SELECT * FROM {$_TABLES['ff_bookmarks']} WHERE uid=" . (int) $uid;
     $result = DB_query($sql);
     while (($bm = DB_fetchArray($result)) != NULL) {
Beispiel #2
0
/**
 * Return information for a story
 * This is the story equivalent of PLG_getItemInfo. See lib-plugins.php for
 * details.
 *
 * @param    string $sid     story ID or '*'
 * @param    string $what    comma-separated list of story properties
 * @param    int    $uid     user ID or 0 = current user
 * @param    array  $options (reserved for future extensions)
 * @return   mixed               string or array of strings with the information
 */
function plugin_getiteminfo_story($sid, $what, $uid = 0, $options = array())
{
    global $_CONF, $_TABLES;
    // parse $what to see what we need to pull from the database
    $properties = explode(',', $what);
    $fields = array();
    foreach ($properties as $p) {
        switch ($p) {
            case 'date-created':
                $fields[] = 'UNIX_TIMESTAMP(date) AS unixdate';
                break;
            case 'date-modified':
                $fields[] = 'UNIX_TIMESTAMP(date) AS unixdate';
                break;
            case 'description':
                $fields[] = 'introtext';
                $fields[] = 'bodytext';
                break;
            case 'excerpt':
                $fields[] = 'introtext';
                break;
            case 'feed':
                $fields[] = 'ta.tid';
                break;
            case 'id':
                $fields[] = 'sid';
                break;
            case 'title':
                $fields[] = 'title';
                break;
            case 'url':
                // needed for $sid == '*', but also in case we're only requesting
                // the URL (so that $fields isn't emtpy)
                $fields[] = 'sid';
                break;
            default:
                // nothing to do
                break;
        }
    }
    $fields = array_unique($fields);
    if (count($fields) == 0) {
        $retval = array();
        return $retval;
    }
    // prepare SQL request
    if ($sid == '*') {
        $where = ' WHERE';
    } else {
        $where = " WHERE (sid = '" . DB_escapeString($sid) . "') AND";
    }
    $where .= ' (draft_flag = 0) AND (date <= NOW())';
    if ($uid > 0) {
        $permSql = COM_getPermSql('AND', $uid) . " AND ta.type = 'article' AND ta.id = sid AND ta.tdefault = 1 " . COM_getTopicSql('AND', $uid, 'ta');
    } else {
        $permSql = COM_getPermSql('AND') . " AND ta.type = 'article' AND ta.id = sid AND ta.tdefault = 1 " . COM_getTopicSql('AND', 0, 'ta');
    }
    $sql = "SELECT " . implode(',', $fields) . " FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta" . $where . $permSql;
    if ($sid != '*') {
        $sql .= ' LIMIT 1';
    }
    $result = DB_query($sql);
    $numRows = DB_numRows($result);
    $retval = array();
    for ($i = 0; $i < $numRows; $i++) {
        $A = DB_fetchArray($result);
        $props = array();
        foreach ($properties as $p) {
            switch ($p) {
                case 'date-created':
                    $props['date-created'] = $A['unixdate'];
                    break;
                case 'date-modified':
                    $props['date-modified'] = $A['unixdate'];
                    break;
                case 'description':
                    $props['description'] = trim(PLG_replaceTags(stripslashes($A['introtext']) . ' ' . stripslashes($A['bodytext'])));
                    break;
                case 'excerpt':
                    $excerpt = stripslashes($A['introtext']);
                    if (!empty($A['bodytext'])) {
                        $excerpt .= "\n\n" . stripslashes($A['bodytext']);
                    }
                    $props['excerpt'] = trim(PLG_replaceTags($excerpt));
                    break;
                case 'feed':
                    $feedfile = DB_getItem($_TABLES['syndication'], 'filename', "topic = '::all'");
                    if (empty($feedfile)) {
                        $feedfile = DB_getItem($_TABLES['syndication'], 'filename', "topic = '::frontpage'");
                    }
                    if (empty($feedfile)) {
                        $feedfile = DB_getItem($_TABLES['syndication'], 'filename', "topic = '{$A['tid']}'");
                    }
                    if (empty($feedfile)) {
                        $props['feed'] = '';
                    } else {
                        $props['feed'] = SYND_getFeedUrl($feedfile);
                    }
                    break;
                case 'id':
                    $props['id'] = $A['sid'];
                    break;
                case 'title':
                    $props['title'] = stripslashes($A['title']);
                    break;
                case 'url':
                    if (empty($A['sid'])) {
                        $props['url'] = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid);
                    } else {
                        $props['url'] = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']);
                    }
                    break;
                default:
                    // return empty string for unknown properties
                    $props[$p] = '';
                    break;
            }
        }
        $mapped = array();
        foreach ($props as $key => $value) {
            if ($sid == '*') {
                if ($value != '') {
                    $mapped[$key] = $value;
                }
            } else {
                $mapped[] = $value;
            }
        }
        if ($sid == '*') {
            $retval[] = $mapped;
        } else {
            $retval = $mapped;
            break;
        }
    }
    if ($sid != '*' && count($retval) == 1) {
        $retval = $retval[0];
    }
    return $retval;
}
/**
*   Get the feed subscription urls & icons.
*   This returns a ready-to-display set of icons for visitors
*   to subscribe to RSS feeds
*
*   @return string  HTML for icons
*/
function EVLIST_getFeedIcons()
{
    global $_CONF, $_EV_CONF, $_TABLES;
    $retval = '';
    // Anon access required for feed access anyway
    if ($_EV_CONF['allow_anon_view'] != 1) {
        return $retval;
    }
    // Get the feed info for configured feeds
    $result = DB_query("SELECT title, filename \n            FROM {$_TABLES['syndication']}\n            WHERE type='" . DB_escapeString($_EV_CONF['pi_name']) . "'");
    if (DB_numRows($result) > 0) {
        $T = new Template(EVLIST_PI_PATH . '/templates/');
        $T->set_file('feed', 'rss_icon.thtml');
        $feed_url = SYND_getFeedUrl();
        while ($A = DB_fetchArray($result, false)) {
            $T->set_var(array('feed_title' => $A['title'], 'feed_url' => $feed_url . $A['filename']));
            $T->parse('output', 'feed', true);
        }
        $retval = $T->finish($T->get_var('output'));
    }
    return $retval;
}
Beispiel #4
0
/**
* Returns the site header
*
* This loads the proper templates, does variable substitution and returns the
* HTML for the site header with or without blocks depending on the value of $what
*
* Programming Note:
*
* The two functions COM_siteHeader and COM_siteFooter provide the framework for
* page display in Geeklog.  COM_siteHeader controls the display of the Header
* and left blocks and COM_siteFooter controls the dsiplay of the right blocks
* and the footer.  You use them like a sandwich.  Thus the following code will
* display a Geeklog page with both right and left blocks displayed.
*
* <code>
* <?php
* require_once 'lib-common.php';
* // Change to COM_siteHeader('none') to not display left blocks
* $display .= COM_siteHeader();
* $display .= "Here is your html for display";
* // Change to COM_siteFooter() to not display right blocks
* $display .= COM_siteFooter(true);
* echo $display;
* ? >
* </code>
*
* Note that the default for the header is to display the left blocks and the
* default of the footer is to not display the right blocks.
*
* This sandwich produces code like this (greatly simplified)
* <code>
* // COM_siteHeader
* <table><tr><td colspan="3">Header</td></tr>
* <tr><td>Left Blocks</td><td>
*
* // Your HTML goes here
* Here is your html for display
*
* // COM_siteFooter
* </td><td>Right Blocks</td></tr>
* <tr><td colspan="3">Footer</td></table>
* </code>
*
* @param    string  $what       If 'none' then no left blocks are returned, if 'menu' (default) then right blocks are returned
* @param    string  $pagetitle  optional content for the page's <title>
* @param    string  $headercode optional code to go into the page's <head>
* @return   string              Formatted HTML containing the site header
* @see function COM_siteFooter
*
*/
function COM_siteHeader($what = 'menu', $pagetitle = '', $headercode = '')
{
    global $_CONF, $_TABLES, $_USER, $LANG01, $LANG_BUTTONS, $LANG_DIRECTION, $_IMAGE_TYPE, $topic, $_COM_VERBOSE, $_SCRIPTS;
    // If the theme implemented this for us then call their version instead.
    $function = $_CONF['theme'] . '_siteHeader';
    if (function_exists($function)) {
        return $function($what, $pagetitle, $headercode);
    }
    // If we reach here then either we have the default theme OR
    // the current theme only needs the default variable substitutions
    switch ($_CONF['doctype']) {
        case 'html401transitional':
            $doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
            break;
        case 'html401strict':
            $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
            break;
        case 'xhtml10transitional':
            $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
            break;
        case 'xhtml10strict':
            $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
            break;
        default:
            // fallback: HTML 4.01 Transitional w/o system identifier
            $doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
            break;
    }
    // send out the charset header
    header('Content-Type: text/html; charset=' . COM_getCharset());
    if (!empty($_CONF['frame_options'])) {
        header('X-FRAME-OPTIONS: ' . $_CONF['frame_options']);
    }
    $header = COM_newTemplate($_CONF['path_layout']);
    $header->set_file(array('header' => 'header.thtml', 'menuitem' => 'menuitem.thtml', 'menuitem_last' => 'menuitem_last.thtml', 'menuitem_none' => 'menuitem_none.thtml', 'leftblocks' => 'leftblocks.thtml', 'rightblocks' => 'rightblocks.thtml'));
    $header->postprocess_fn = 'PLG_replaceTags';
    $header->set_var('doctype', $doctype);
    if (XHTML == '') {
        $header->set_var('xmlns', '');
    } else {
        $header->set_var('xmlns', ' xmlns="http://www.w3.org/1999/xhtml"');
    }
    // get topic if not on home page
    if (!isset($_GET['topic'])) {
        if (isset($_GET['story'])) {
            $sid = COM_applyFilter($_GET['story']);
        } elseif (isset($_GET['sid'])) {
            $sid = COM_applyFilter($_GET['sid']);
        } elseif (isset($_POST['story'])) {
            $sid = COM_applyFilter($_POST['story']);
        }
        if (empty($sid) && $_CONF['url_rewrite'] && strpos($_SERVER['PHP_SELF'], 'article.php') !== false) {
            COM_setArgNames(array('story', 'mode'));
            $sid = COM_applyFilter(COM_getArgument('story'));
        }
        if (!empty($sid)) {
            $topic = DB_getItem($_TABLES['stories'], 'tid', "sid='{$sid}'");
        }
    } else {
        $topic = COM_applyFilter($_GET['topic']);
    }
    $feed_url = array();
    if ($_CONF['backend'] == 1) {
        $baseurl = SYND_getFeedUrl();
        $sql = 'SELECT format, filename, title, language FROM ' . $_TABLES['syndication'] . " WHERE (header_tid = 'all')";
        if (!empty($topic)) {
            $sql .= " OR (header_tid = '" . addslashes($topic) . "')";
        }
        $result = DB_query($sql);
        $numRows = DB_numRows($result);
        for ($i = 0; $i < $numRows; $i++) {
            $A = DB_fetchArray($result);
            if (!empty($A['filename'])) {
                $format_type = SYND_getMimeType($A['format']);
                $format_name = SYND_getFeedType($A['format']);
                $feed_title = $format_name . ' Feed: ' . $A['title'];
                $feed_url[] = '<link rel="alternate" type="' . $format_type . '" hreflang="' . $A['language'] . '" href="' . $baseurl . $A['filename'] . '" title="' . htmlspecialchars($feed_title) . '"' . XHTML . '>';
            }
        }
    }
    $header->set_var('feed_url', implode(LB, $feed_url));
    // for backward compatibility only - use {feed_url} instead
    $feed = SYND_getDefaultFeedUrl();
    $header->set_var('rdf_file', $feed);
    $header->set_var('rss_url', $feed);
    $relLinks = array();
    if (COM_onFrontpage()) {
        $relLinks['canonical'] = '<link rel="canonical" href="' . $_CONF['site_url'] . '/"' . XHTML . '>';
    } else {
        $relLinks['home'] = '<link rel="home" href="' . $_CONF['site_url'] . '/" title="' . $LANG01[90] . '"' . XHTML . '>';
    }
    $loggedInUser = !COM_isAnonUser();
    if ($loggedInUser || $_CONF['loginrequired'] == 0 && $_CONF['searchloginrequired'] == 0) {
        if (substr($_SERVER['PHP_SELF'], -strlen('/search.php')) != '/search.php' || isset($_GET['mode'])) {
            $relLinks['search'] = '<link rel="search" href="' . $_CONF['site_url'] . '/search.php" title="' . $LANG01[75] . '"' . XHTML . '>';
        }
    }
    if ($loggedInUser || $_CONF['loginrequired'] == 0 && $_CONF['directoryloginrequired'] == 0) {
        if (strpos($_SERVER['PHP_SELF'], '/article.php') !== false) {
            $relLinks['contents'] = '<link rel="contents" href="' . $_CONF['site_url'] . '/directory.php" title="' . $LANG01[117] . '"' . XHTML . '>';
        }
    }
    if (!$_CONF['disable_webservices']) {
        $relLinks['service'] = '<link rel="service" ' . 'type="application/atomsvc+xml" ' . 'href="' . $_CONF['site_url'] . '/webservices/atom/?introspection" ' . 'title="' . $LANG01[130] . '"' . XHTML . '>';
    }
    // TBD: add a plugin API and a lib-custom.php function
    $header->set_var('rel_links', implode(LB, $relLinks));
    $pagetitle_siteslogan = false;
    if (empty($pagetitle)) {
        if (empty($topic)) {
            $pagetitle = $_CONF['site_slogan'];
            $pagetitle_siteslogan = true;
        } else {
            $pagetitle = stripslashes(DB_getItem($_TABLES['topics'], 'topic', "tid = '{$topic}'"));
        }
    }
    if (!empty($pagetitle)) {
        $header->set_var('page_site_splitter', ' - ');
    } else {
        $header->set_var('page_site_splitter', '');
    }
    $header->set_var('page_title', $pagetitle);
    $header->set_var('site_name', $_CONF['site_name']);
    if (COM_onFrontpage() or $pagetitle_siteslogan) {
        $title_and_name = $_CONF['site_name'];
        if (!empty($pagetitle)) {
            $title_and_name .= ' - ' . $pagetitle;
        }
    } else {
        $title_and_name = '';
        if (!empty($pagetitle)) {
            $title_and_name = $pagetitle . ' - ';
        }
        $title_and_name .= $_CONF['site_name'];
    }
    $header->set_var('page_title_and_site_name', $title_and_name);
    COM_setLangIdAndAttribute($header);
    $header->set_var('background_image', $_CONF['layout_url'] . '/images/bg.' . $_IMAGE_TYPE);
    $header->set_var('site_mail', "mailto:{$_CONF['site_mail']}");
    $header->set_var('site_name', $_CONF['site_name']);
    $header->set_var('site_slogan', $_CONF['site_slogan']);
    $msg = rtrim($LANG01[67]) . ' ' . $_CONF['site_name'];
    if (!empty($_USER['username'])) {
        $msg .= ', ' . COM_getDisplayName($_USER['uid'], $_USER['username'], $_USER['fullname']);
    }
    $curtime = COM_getUserDateTimeFormat();
    $header->set_var('welcome_msg', $msg);
    $header->set_var('datetime', $curtime[0]);
    $header->set_var('site_logo', $_CONF['layout_url'] . '/images/logo.' . $_IMAGE_TYPE);
    $header->set_var('theme', $_CONF['theme']);
    $header->set_var('charset', COM_getCharset());
    $header->set_var('direction', $LANG_DIRECTION);
    // Now add variables for buttons like e.g. those used by the Yahoo theme
    $header->set_var('button_home', $LANG_BUTTONS[1]);
    $header->set_var('button_contact', $LANG_BUTTONS[2]);
    $header->set_var('button_contribute', $LANG_BUTTONS[3]);
    $header->set_var('button_sitestats', $LANG_BUTTONS[7]);
    $header->set_var('button_personalize', $LANG_BUTTONS[8]);
    $header->set_var('button_search', $LANG_BUTTONS[9]);
    $header->set_var('button_advsearch', $LANG_BUTTONS[10]);
    $header->set_var('button_directory', $LANG_BUTTONS[11]);
    // Get plugin menu options
    $plugin_menu = PLG_getMenuItems();
    if ($_COM_VERBOSE) {
        COM_errorLog('num plugin menu items in header = ' . count($plugin_menu), 1);
    }
    // Now add nested template for menu items
    COM_renderMenu($header, $plugin_menu);
    if (count($plugin_menu) == 0) {
        $header->parse('plg_menu_elements', 'menuitem_none', true);
    } else {
        $count_plugin_menu = count($plugin_menu);
        for ($i = 1; $i <= $count_plugin_menu; $i++) {
            $header->set_var('menuitem_url', current($plugin_menu));
            $header->set_var('menuitem_text', key($plugin_menu));
            if ($i == $count_plugin_menu) {
                $header->parse('plg_menu_elements', 'menuitem_last', true);
            } else {
                $header->parse('plg_menu_elements', 'menuitem', true);
            }
            next($plugin_menu);
        }
    }
    // Call to plugins to set template variables in the header
    PLG_templateSetVars('header', $header);
    if ($_CONF['left_blocks_in_footer'] == 1) {
        $header->set_var('left_blocks', '');
        $header->set_var('geeklog_blocks', '');
    } else {
        $lblocks = '';
        /* Check if an array has been passed that includes the name of a plugin
         * function or custom function
         * This can be used to take control over what blocks are then displayed
         */
        if (is_array($what)) {
            $function = $what[0];
            if (function_exists($function)) {
                $lblocks = $function($what[1], 'left');
            } else {
                $lblocks = COM_showBlocks('left', $topic);
            }
        } else {
            if ($what != 'none') {
                // Now show any blocks -- need to get the topic if not on home page
                $lblocks = COM_showBlocks('left', $topic);
            }
        }
        if (empty($lblocks)) {
            $header->set_var('left_blocks', '');
            $header->set_var('geeklog_blocks', '');
        } else {
            $header->set_var('geeklog_blocks', $lblocks);
            $header->parse('left_blocks', 'leftblocks', true);
            $header->set_var('geeklog_blocks', '');
        }
    }
    if ($_CONF['right_blocks_in_footer'] == 1) {
        $header->set_var('right_blocks', '');
        $header->set_var('geeklog_blocks', '');
    } else {
        $rblocks = '';
        /* Check if an array has been passed that includes the name of a plugin
         * function or custom function
         * This can be used to take control over what blocks are then displayed
         */
        if (is_array($what)) {
            $function = $what[0];
            if (function_exists($function)) {
                $rblocks = $function($what[1], 'right');
            } else {
                $rblocks = COM_showBlocks('right', $topic);
            }
        } else {
            if ($what != 'none') {
                // Now show any blocks -- need to get the topic if not on home page
                $rblocks = COM_showBlocks('right', $topic);
            }
        }
        if (empty($rblocks)) {
            $header->set_var('right_blocks', '');
            $header->set_var('geeklog_blocks', '');
        } else {
            $header->set_var('geeklog_blocks', $rblocks, true);
            $header->parse('right_blocks', 'rightblocks', true);
        }
    }
    // Call any plugin that may want to include extra Meta tags
    // or Javascript functions
    $headercode .= PLG_getHeaderCode();
    // Meta Tags
    // 0 = Disabled, 1 = Enabled, 2 = Enabled but default just for homepage
    if ($_CONF['meta_tags'] > 0) {
        $meta_description = '';
        $meta_keywords = '';
        $no_meta_description = 1;
        $no_meta_keywords = 1;
        //Find out if the meta tag description or keywords already exist in the headercode
        if ($headercode != '') {
            $pattern = '/<meta ([^>]*)name="([^"\'>]*)"([^>]*)/im';
            if (preg_match_all($pattern, $headercode, $matches, PREG_SET_ORDER)) {
                // Loop through all meta tags looking for description and keywords
                for ($i = 0; $i < count($matches) && ($no_meta_description == 1 || $no_meta_keywords == 1); $i++) {
                    $str_matches = strtolower($matches[$i][0]);
                    $pos = strpos($str_matches, 'name=');
                    if (!(is_bool($pos) && !$pos)) {
                        $name = trim(substr($str_matches, $pos + 5), '"');
                        $pos = strpos($name, '"');
                        $name = substr($name, 0, $pos);
                        if (strcasecmp("description", $name) == 0) {
                            $pos = strpos($str_matches, 'content=');
                            if (!(is_bool($pos) && !$pos)) {
                                $no_meta_description = 0;
                            }
                        }
                        if (strcasecmp("keywords", $name) == 0) {
                            $pos = strpos($str_matches, 'content=');
                            if (!(is_bool($pos) && !$pos)) {
                                $no_meta_keywords = 0;
                            }
                        }
                    }
                }
            }
        }
        if (COM_onFrontpage() && $_CONF['meta_tags'] == 2) {
            // Display default meta tags only on home page
            if ($no_meta_description) {
                $meta_description = $_CONF['meta_description'];
            }
            if ($no_meta_keywords) {
                $meta_keywords = $_CONF['meta_keywords'];
            }
        } else {
            if ($_CONF['meta_tags'] == 1) {
                // Display default meta tags anywhere there are no tags
                if ($no_meta_description) {
                    $meta_description = $_CONF['meta_description'];
                }
                if ($no_meta_keywords) {
                    $meta_keywords = $_CONF['meta_keywords'];
                }
            }
        }
        if ($no_meta_description or $no_meta_keywords) {
            $headercode .= COM_createMetaTags($meta_description, $meta_keywords);
        }
    }
    $headercode = $_SCRIPTS->getHeader() . $headercode;
    $header->set_var('plg_headercode', $headercode);
    // The following lines allow users to embed PHP in their templates.  This
    // is almost a contradition to the reasons for using templates but this may
    // prove useful at times ...
    // Don't use PHP in templates if you can live without it!
    $tmp = $header->finish($header->parse('index_header', 'header'));
    $xml_declaration = '';
    if (get_cfg_var('short_open_tag') == '1') {
        if (preg_match('/(<\\?xml[^>]*>)(.*)/s', $tmp, $match)) {
            $xml_declaration = $match[1] . LB;
            $tmp = $match[2];
        }
    }
    ob_start();
    eval('?>' . $tmp);
    $retval = $xml_declaration . ob_get_contents();
    ob_end_clean();
    return $retval;
}
Beispiel #5
0
/**
 * used for the list of feeds in admin/syndication.php
 *
 * @param  string $fieldName
 * @param  string $fieldValue
 * @param  array  $A
 * @param  array  $icon_arr
 * @param  string $token
 * @return string
 */
function ADMIN_getListField_syndication($fieldName, $fieldValue, $A, $icon_arr, $token)
{
    global $_CONF, $_TABLES, $LANG_ADMIN, $LANG33;
    switch ($fieldName) {
        case 'edit':
            $retval = COM_createLink($icon_arr['edit'], "{$_CONF['site_admin_url']}/syndication.php?mode=edit&amp;fid={$A['fid']}");
            break;
        case 'type':
            if ($A['type'] === 'article') {
                $retval = $LANG33[55];
            } else {
                $retval = ucwords($A['type']);
            }
            break;
        case 'format':
            $retval = str_replace('-', ' ', ucwords($A['format']));
            break;
        case 'updated':
            if ($A['is_enabled'] == 1) {
                $retval = strftime($_CONF['daytime'], $A['date']);
            } else {
                $retval = $LANG_ADMIN['na'];
            }
            break;
        case 'is_enabled':
            if ($A['is_enabled'] == 1) {
                $switch = ' checked="checked"';
            } else {
                $switch = '';
            }
            $retval = '<input type="checkbox" name="enabledfeeds[]" onclick="submit()" value="' . $A['fid'] . '"' . $switch . XHTML . '>' . '<input type="hidden" name="visiblefeeds[]" value="' . $A['fid'] . '"' . XHTML . '>';
            break;
        case 'header_tid':
            if ($A['header_tid'] === 'all') {
                $retval = $LANG33[43];
            } elseif ($A['header_tid'] === 'none') {
                $retval = $LANG33[44];
            } else {
                $retval = DB_getItem($_TABLES['topics'], 'topic', "tid = '{$A['header_tid']}'");
            }
            break;
        case 'filename':
            $url = SYND_getFeedUrl();
            $retval = COM_createLink($A['filename'], $url . $A['filename']);
            break;
        default:
            $retval = $fieldValue;
            break;
    }
    return $retval;
}
Beispiel #6
0
/**
* Create and return the HTML document
*
* @param    string  $content        Main content for the page
* @param    array   $information    An array defining variables to be used when creating the output
*                       string  'what'          If 'none' then no left blocks are returned, if 'menu' (default) then right blocks are returned
*                       string  'pagetitle'     Optional content for the page's <title>
*                       string  'breadcrumbs'   Optional content for the page's breadcrumb
*                       string  'headercode'    Optional code to go into the page's <head>
*                       boolean 'rightblock'    Whether or not to show blocks on right hand side default is no (-1)
*                       array   'custom'        An array defining custom function to be used to format Rightblocks
* @see      function COM_siteHeader
* @see      function COM_siteFooter
* @return   string              Formated HTML document
*
*/
function COM_createHTMLDocument(&$content = '', $information = array())
{
    global $_CONF, $_TABLES, $_USER, $LANG01, $LANG_BUTTONS, $LANG_DIRECTION, $_IMAGE_TYPE, $topic, $_COM_VERBOSE, $_SCRIPTS, $_PAGE_TIMER, $relLinks;
    // Retrieve required variables from information array
    if (isset($information['what'])) {
        $what = $information['what'];
    } else {
        $what = 'menu';
    }
    if (isset($information['pagetitle'])) {
        $pagetitle = $information['pagetitle'];
    } else {
        $pagetitle = '';
    }
    if (isset($information['headercode'])) {
        $headercode = $information['headercode'];
    } else {
        $headercode = '';
    }
    if (isset($information['breadcrumbs'])) {
        $breadcrumbs = $information['breadcrumbs'];
    } else {
        $breadcrumbs = '';
    }
    if (isset($information['rightblock'])) {
        $rightblock = $information['rightblock'];
    } else {
        $rightblock = -1;
    }
    if (isset($information['custom'])) {
        $custom = $information['custom'];
    } else {
        $custom = '';
    }
    // If the theme does not support the CSS layout then call the legacy functions (Geeklog 1.8.1 and older).
    if ($_CONF['supported_version_theme'] == '1.8.1') {
        return COM_siteHeader($what, $pagetitle, $headercode) . $content . COM_siteFooter($rightblock, $custom);
    }
    // If the theme implemented this for us then call their version instead.
    $function = $_CONF['theme'] . '_createHTMLDocument';
    if (function_exists($function)) {
        return $function($content, $information);
    }
    // If we reach here then either we have the default theme OR
    // the current theme only needs the default variable substitutions
    switch ($_CONF['doctype']) {
        case 'html401transitional':
            $doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
            break;
        case 'html401strict':
            $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
            break;
        case 'xhtml10transitional':
            $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
            break;
        case 'xhtml10strict':
            $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
            break;
        case 'html5':
        case 'xhtml5':
            $doctype = '<!DOCTYPE html>';
            break;
        default:
            // fallback: HTML 4.01 Transitional w/o system identifier
            $doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
            break;
    }
    // send out the charset header
    header('Content-Type: text/html; charset=' . COM_getCharset());
    if (!empty($_CONF['frame_options'])) {
        header('X-FRAME-OPTIONS: ' . $_CONF['frame_options']);
    }
    $header = COM_newTemplate($_CONF['path_layout']);
    $header->set_file(array('header' => 'header.thtml', 'menunavigation' => 'menunavigation.thtml', 'leftblocks' => 'leftblocks.thtml', 'rightblocks' => 'rightblocks.thtml'));
    $blocks = array('menuitem', 'menuitem_last', 'menuitem_none');
    foreach ($blocks as $block) {
        $header->set_block('menunavigation', $block);
    }
    $header->parse('menu_elements', 'menunavigation', true);
    $header->set_var('doctype', $doctype . LB);
    if (XHTML == '') {
        $header->set_var('xmlns', '');
    } else {
        $header->set_var('xmlns', ' xmlns="http://www.w3.org/1999/xhtml"');
    }
    $feed_url = array();
    if ($_CONF['backend'] == 1) {
        $baseurl = SYND_getFeedUrl();
        $sql = 'SELECT format, filename, title, language FROM ' . $_TABLES['syndication'] . " WHERE (header_tid = 'all')";
        if (!empty($topic)) {
            $sql .= " OR (header_tid = '" . DB_escapeString($topic) . "')";
        }
        $result = DB_query($sql);
        $numRows = DB_numRows($result);
        for ($i = 0; $i < $numRows; $i++) {
            $A = DB_fetchArray($result);
            if (!empty($A['filename'])) {
                $format_type = SYND_getMimeType($A['format']);
                $format_name = SYND_getFeedType($A['format']);
                $feed_title = $format_name . ' Feed: ' . $A['title'];
                $feed_url[] = '<link rel="alternate" type="' . $format_type . '" hreflang="' . $A['language'] . '" href="' . $baseurl . $A['filename'] . '" title="' . htmlspecialchars($feed_title) . '"' . XHTML . '>';
            }
        }
    }
    $header->set_var('feed_url', implode(LB, $feed_url));
    // for backward compatibility only - use {feed_url} instead
    $feed = SYND_getDefaultFeedUrl();
    if (COM_onFrontpage()) {
        $relLinks['canonical'] = '<link rel="canonical" href="' . $_CONF['site_url'] . '/"' . XHTML . '>';
    } else {
        $relLinks['home'] = '<link rel="home" href="' . $_CONF['site_url'] . '/" title="' . $LANG01[90] . '"' . XHTML . '>';
    }
    $loggedInUser = !COM_isAnonUser();
    if ($loggedInUser || $_CONF['loginrequired'] == 0 && $_CONF['searchloginrequired'] == 0) {
        if (substr($_SERVER['PHP_SELF'], -strlen('/search.php')) != '/search.php' || isset($_GET['mode'])) {
            $relLinks['search'] = '<link rel="search" href="' . $_CONF['site_url'] . '/search.php" title="' . $LANG01[75] . '"' . XHTML . '>';
        }
    }
    if ($loggedInUser || $_CONF['loginrequired'] == 0 && $_CONF['directoryloginrequired'] == 0) {
        if (strpos($_SERVER['PHP_SELF'], '/article.php') !== false) {
            $relLinks['contents'] = '<link rel="contents" href="' . $_CONF['site_url'] . '/directory.php" title="' . $LANG01[117] . '"' . XHTML . '>';
        }
    }
    if (!$_CONF['disable_webservices']) {
        $relLinks['service'] = '<link rel="service" ' . 'type="application/atomsvc+xml" ' . 'href="' . $_CONF['site_url'] . '/webservices/atom/?introspection" ' . 'title="' . $LANG01[130] . '"' . XHTML . '>';
    }
    // TBD: add a plugin API and a lib-custom.php function
    $header->set_var('rel_links', implode(LB, $relLinks));
    $pagetitle_siteslogan = false;
    if (empty($pagetitle)) {
        if (empty($topic)) {
            $pagetitle = $_CONF['site_slogan'];
            $pagetitle_siteslogan = true;
        } else {
            $pagetitle = stripslashes(DB_getItem($_TABLES['topics'], 'topic', "tid = '{$topic}'"));
        }
    }
    if (!empty($pagetitle)) {
        $header->set_var('page_site_splitter', ' - ');
    } else {
        $header->set_var('page_site_splitter', '');
    }
    $header->set_var('page_title', $pagetitle);
    $header->set_var('site_name', $_CONF['site_name']);
    if (COM_onFrontpage() or $pagetitle_siteslogan) {
        $title_and_name = $_CONF['site_name'];
        if (!empty($pagetitle)) {
            $title_and_name .= ' - ' . $pagetitle;
        }
    } else {
        $title_and_name = '';
        if (!empty($pagetitle)) {
            $title_and_name = $pagetitle . ' - ';
        }
        $title_and_name .= $_CONF['site_name'];
    }
    $header->set_var('page_title_and_site_name', $title_and_name);
    COM_setLangIdAndAttribute($header);
    $header->set_var('background_image', $_CONF['layout_url'] . '/images/bg.' . $_IMAGE_TYPE);
    $msg = rtrim($LANG01[67]) . ' ' . $_CONF['site_name'];
    if (!empty($_USER['username'])) {
        $msg .= ', ' . COM_getDisplayName($_USER['uid'], $_USER['username'], $_USER['fullname']);
    }
    $curtime = COM_getUserDateTimeFormat();
    $header->set_var('welcome_msg', $msg);
    $header->set_var('datetime', $curtime[0]);
    $header->set_var('site_logo', $_CONF['layout_url'] . '/images/logo.' . $_IMAGE_TYPE);
    $header->set_var('theme', $_CONF['theme']);
    $header->set_var('datetime_html5', strftime('%FT%T', $curtime[1]));
    $header->set_var('charset', COM_getCharset());
    $header->set_var('direction', $LANG_DIRECTION);
    $template_vars = array('rdf_file' => $feed, 'rss_url' => $feed, 'site_mail' => "mailto:{$_CONF['site_mail']}", 'site_name' => $_CONF['site_name'], 'site_slogan' => $_CONF['site_slogan'], 'button_home' => $LANG_BUTTONS[1], 'button_contact' => $LANG_BUTTONS[2], 'button_contribute' => $LANG_BUTTONS[3], 'button_sitestats' => $LANG_BUTTONS[7], 'button_personalize' => $LANG_BUTTONS[8], 'button_search' => $LANG_BUTTONS[9], 'button_advsearch' => $LANG_BUTTONS[10], 'button_directory' => $LANG_BUTTONS[11]);
    $header->set_var($template_vars);
    // Get plugin menu options
    $plugin_menu = PLG_getMenuItems();
    if ($_COM_VERBOSE) {
        COM_errorLog('num plugin menu items in header = ' . count($plugin_menu), 1);
    }
    // Now add nested template for menu items
    COM_renderMenu($header, $plugin_menu);
    if (count($plugin_menu) == 0) {
        $header->parse('plg_menu_elements', 'menuitem_none', true);
    } else {
        $count_plugin_menu = count($plugin_menu);
        for ($i = 1; $i <= $count_plugin_menu; $i++) {
            $header->set_var('menuitem_url', current($plugin_menu));
            $header->set_var('menuitem_text', key($plugin_menu));
            if ($i == $count_plugin_menu) {
                $header->parse('plg_menu_elements', 'menuitem_last', true);
            } else {
                $header->parse('plg_menu_elements', 'menuitem', true);
            }
            next($plugin_menu);
        }
    }
    // Call to plugins to set template variables in the header
    PLG_templateSetVars('header', $header);
    if ($_CONF['left_blocks_in_footer'] == 1) {
        $header->set_var('left_blocks', '');
        $header->set_var('geeklog_blocks', '');
    } else {
        $lblocks = '';
        /* Check if an array has been passed that includes the name of a plugin
         * function or custom function
         * This can be used to take control over what blocks are then displayed
         */
        if (is_array($what)) {
            $function = $what[0];
            if (function_exists($function)) {
                $lblocks = $function($what[1], 'left');
            } else {
                $lblocks = COM_showBlocks('left', $topic);
            }
        } else {
            if ($what != 'none') {
                // Now show any blocks -- need to get the topic if not on home page
                $lblocks = COM_showBlocks('left', $topic);
            }
        }
        if (empty($lblocks)) {
            $header->set_var('left_blocks', '');
            $header->set_var('geeklog_blocks', '');
        } else {
            $header->set_var('geeklog_blocks', $lblocks);
            $header->parse('left_blocks', 'leftblocks', true);
            $header->set_var('geeklog_blocks', '');
        }
    }
    if ($_CONF['right_blocks_in_footer'] == 1) {
        $header->set_var('right_blocks', '');
        $header->set_var('geeklog_blocks', '');
    } else {
        $rblocks = '';
        /* Check if an array has been passed that includes the name of a plugin
         * function or custom function
         * This can be used to take control over what blocks are then displayed
         */
        if (is_array($what)) {
            $function = $what[0];
            if (function_exists($function)) {
                $rblocks = $function($what[1], 'right');
            } else {
                $rblocks = COM_showBlocks('right', $topic);
            }
        } else {
            if ($what != 'none') {
                // Now show any blocks -- need to get the topic if not on home page
                $rblocks = COM_showBlocks('right', $topic);
            }
        }
        if (empty($rblocks)) {
            $header->set_var('right_blocks', '');
            $header->set_var('geeklog_blocks', '');
        } else {
            $header->set_var('geeklog_blocks', $rblocks, true);
            $header->parse('right_blocks', 'rightblocks', true);
        }
    }
    // Set last topic session variable
    if ($topic == TOPIC_ALL_OPTION) {
        $topic = '';
        // Do not save 'all' option. Nothing is the same thing
    }
    SESS_setVariable('topic', $topic);
    // Call any plugin that may want to include extra Meta tags
    // or Javascript functions
    $headercode .= PLG_getHeaderCode();
    // Meta Tags
    // 0 = Disabled, 1 = Enabled, 2 = Enabled but default just for homepage
    if ($_CONF['meta_tags'] > 0) {
        $meta_description = '';
        $meta_keywords = '';
        $no_meta_description = 1;
        $no_meta_keywords = 1;
        //Find out if the meta tag description or keywords already exist in the headercode
        if ($headercode != '') {
            $pattern = '/<meta ([^>]*)name="([^"\'>]*)"([^>]*)/im';
            if (preg_match_all($pattern, $headercode, $matches, PREG_SET_ORDER)) {
                // Loop through all meta tags looking for description and keywords
                for ($i = 0; $i < count($matches) && ($no_meta_description == 1 || $no_meta_keywords == 1); $i++) {
                    $str_matches = strtolower($matches[$i][0]);
                    $pos = strpos($str_matches, 'name=');
                    if (!(is_bool($pos) && !$pos)) {
                        $name = trim(substr($str_matches, $pos + 5), '"');
                        $pos = strpos($name, '"');
                        $name = substr($name, 0, $pos);
                        if (strcasecmp("description", $name) == 0) {
                            $pos = strpos($str_matches, 'content=');
                            if (!(is_bool($pos) && !$pos)) {
                                $no_meta_description = 0;
                            }
                        }
                        if (strcasecmp("keywords", $name) == 0) {
                            $pos = strpos($str_matches, 'content=');
                            if (!(is_bool($pos) && !$pos)) {
                                $no_meta_keywords = 0;
                            }
                        }
                    }
                }
            }
        }
        if (COM_onFrontpage() && $_CONF['meta_tags'] == 2) {
            // Display default meta tags only on home page
            if ($no_meta_description) {
                $meta_description = $_CONF['meta_description'];
            }
            if ($no_meta_keywords) {
                $meta_keywords = $_CONF['meta_keywords'];
            }
        } else {
            if ($_CONF['meta_tags'] == 1) {
                // Display default meta tags anywhere there are no tags
                if ($no_meta_description) {
                    $meta_description = $_CONF['meta_description'];
                }
                if ($no_meta_keywords) {
                    $meta_keywords = $_CONF['meta_keywords'];
                }
            }
        }
        if ($no_meta_description or $no_meta_keywords) {
            $headercode .= COM_createMetaTags($meta_description, $meta_keywords);
        }
    }
    $header->set_var('breadcrumb_trail', $breadcrumbs);
    COM_hit();
    // Set template directory
    $footer = COM_newTemplate($_CONF['path_layout']);
    // Set template file
    $footer->set_file(array('footer' => 'footer.thtml', 'rightblocks' => 'rightblocks.thtml', 'leftblocks' => 'leftblocks.thtml'));
    $year = date('Y');
    $copyrightyear = $year;
    if (!empty($_CONF['copyrightyear'])) {
        $copyrightyear = $_CONF['copyrightyear'];
    }
    if (!empty($_CONF['owner_name'])) {
        $copyrightname = $_CONF['owner_name'];
    } else {
        $copyrightname = $_CONF['site_name'];
    }
    $footer->set_var('copyright_notice', '&nbsp;' . $LANG01[93] . ' &copy; ' . $copyrightyear . ' ' . $copyrightname . '<br' . XHTML . '>&nbsp;' . $LANG01[94]);
    $footer->set_var('copyright_msg', $LANG01[93] . ' &copy; ' . $copyrightyear . ' ' . $_CONF['site_name']);
    $footer->set_var('current_year', $year);
    $footer->set_var('lang_copyright', $LANG01[93]);
    $footer->set_var('trademark_msg', $LANG01[94]);
    $footer->set_var('powered_by', $LANG01[95]);
    $footer->set_var('geeklog_url', 'http://www.geeklog.net/');
    $footer->set_var('geeklog_version', VERSION);
    $footer->set_var($template_vars);
    /* Right blocks. Argh. Don't talk to me about right blocks...
     * Right blocks will be displayed if Right_blocks_in_footer is set [1],
     * AND (this function has been asked to show them (first param) OR the
     * show_right_blocks conf variable has been set to override what the code
     * wants to do.
     *
     * If $custom sets an array (containing functionname and first argument)
     * then this is used instead of the default (COM_showBlocks) to render
     * the right blocks (and left).
     *
     * [1] - if it isn't, they'll be in the header already.
     *
     */
    $displayRightBlocks = true;
    if ($_CONF['right_blocks_in_footer'] == 1) {
        if ($rightblock < 0 || !$rightblock) {
            if (isset($_CONF['show_right_blocks'])) {
                $displayRightBlocks = $_CONF['show_right_blocks'];
            } else {
                $displayRightBlocks = false;
            }
        } else {
            $displayRightBlocks = true;
        }
    } else {
        $displayRightBlocks = false;
    }
    if ($displayRightBlocks) {
        /* Check if an array has been passed that includes the name of a plugin
         * function or custom function.
         * This can be used to take control over what blocks are then displayed
         */
        if (is_array($custom)) {
            $function = $custom['0'];
            if (function_exists($function)) {
                $rblocks = $function($custom['1'], 'right');
            } else {
                $rblocks = COM_showBlocks('right', $topic);
            }
        } else {
            $rblocks = COM_showBlocks('right', $topic);
        }
        if (empty($rblocks)) {
            $footer->set_var('geeklog_blocks', '');
            $footer->set_var('right_blocks', '');
        } else {
            $footer->set_var('geeklog_blocks', $rblocks);
            $footer->parse('right_blocks', 'rightblocks', true);
            $footer->set_var('geeklog_blocks', '');
        }
    } else {
        $footer->set_var('geeklog_blocks', '');
        $footer->set_var('right_blocks', '');
    }
    if ($_CONF['left_blocks_in_footer'] == 1) {
        $lblocks = '';
        /* Check if an array has been passed that includes the name of a plugin
         * function or custom function
         * This can be used to take control over what blocks are then displayed
         */
        if (is_array($custom)) {
            $function = $custom[0];
            if (function_exists($function)) {
                $lblocks = $function($custom[1], 'left');
            }
        } else {
            if ($what != 'none') {
                $lblocks = COM_showBlocks('left', $topic);
            }
        }
        if (empty($lblocks)) {
            $footer->set_var('left_blocks', '');
            $footer->set_var('geeklog_blocks', '');
        } else {
            $footer->set_var('geeklog_blocks', $lblocks);
            $footer->parse('left_blocks', 'leftblocks', true);
            $footer->set_var('geeklog_blocks', '');
        }
    }
    // Global centerspan variable set in index.php
    if (isset($GLOBALS['centerspan'])) {
        $footer->set_var('centerblockfooter-span', '</td></tr></table>');
    }
    $exectime = $_PAGE_TIMER->stopTimer();
    $exectext = $LANG01[91] . ' ' . $exectime . ' ' . $LANG01[92];
    $footer->set_var('execution_time', $exectime);
    $footer->set_var('execution_textandtime', $exectext);
    /* Check leftblocks and rightblocks */
    $layout_columns = 'left-center-right';
    $emptylblocks = empty($lblocks);
    $emptyrblocks = empty($rblocks);
    if (!$emptylblocks && $emptyrblocks) {
        $layout_columns = 'left-center';
    }
    if ($emptylblocks && !$emptyrblocks) {
        $layout_columns = 'center-right';
    }
    if ($emptylblocks && $emptyrblocks) {
        $layout_columns = 'center';
    }
    $header->set_var('layout_columns', $layout_columns);
    // All blocks, autotags, template files, etc, now have been rendered (since can be done in footer) so all scripts and css should be set now
    $headercode = $_SCRIPTS->getHeader() . $headercode;
    $header->set_var('plg_headercode', $headercode);
    $retval_header = $header->finish($header->parse('index_header', 'header'));
    // Call to plugins to set template variables in the footer
    PLG_templateSetVars('footer', $footer);
    // Call any plugin that may want to include extra JavaScript functions
    $plugin_footercode = PLG_getFooterCode();
    // Retrieve any JavaScript libraries, variables and functions
    $footercode = $_SCRIPTS->getFooter();
    // $_SCRIPTS code should be placed before plugin_footer_code but plugin_footer_code should still be allowed to set $_SCRIPTS
    $footercode .= $plugin_footercode;
    $footer->set_var('plg_footercode', $footercode);
    // Actually parse the template and make variable substitutions
    $footer->parse('index_footer', 'footer');
    return $retval_header . $content . $footer->finish($footer->get_var('index_footer'));
}
Beispiel #7
0
     $story_template->set_var('lang_email_story_alt', $LANG01[64]);
 }
 $printUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '&amp;mode=print');
 if ($_CONF['hideprintericon'] == 0) {
     $story_options[] = COM_createLink($LANG11[3], $printUrl, array('rel' => 'nofollow'));
     $story_template->set_var('print_story_url', $printUrl);
     $story_template->set_var('lang_print_story', $LANG11[3]);
     $story_template->set_var('lang_print_story_alt', $LANG01[65]);
 }
 if ($_CONF['backend'] == 1) {
     $tid = $story->displayElements('tid');
     $result = DB_query("SELECT filename, title, format FROM {$_TABLES['syndication']} WHERE type = 'article' AND topic = '{$tid}' AND is_enabled = 1");
     $feeds = DB_numRows($result);
     for ($i = 0; $i < $feeds; $i++) {
         list($filename, $title, $format) = DB_fetchArray($result);
         $feedUrl = SYND_getFeedUrl($filename);
         $feedTitle = sprintf($LANG11[6], $title);
         $feedType = SYND_getMimeType($format);
         $feedClass = 'feed-link';
         if (!empty($LANG_DIRECTION) && $LANG_DIRECTION == 'rtl') {
             $feedClass .= '-rtl';
         }
         $story_options[] = COM_createLink($feedTitle, $feedUrl, array('type' => $feedType, 'class' => $feedClass));
     }
 }
 if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled'] || $_CONF['ping_enabled']) && SEC_hasRights('story.ping') && $story->displayElements('draft_flag') == 0 && $story->displayElements('day') < time() && $story->displayElements('perm_anon') != 0) {
     // also check permissions for the topic
     $topic_anon = DB_getItem($_TABLES['topics'], 'perm_anon', "tid = '" . addslashes($story->displayElements('tid')) . "'");
     // check special case: no link when Trackbacks are disabled for this
     // story AND pinging weblog directories is disabled
     if ($topic_anon != 0 && ($story->displayElements('trackbackcode') >= 0 || $_CONF['ping_enabled'])) {
Beispiel #8
0
function MG_buildFullRSS()
{
    global $LANG_CHARSET, $MG_albums, $_MG_CONF, $_CONF, $_TABLES;
    $feedpath = MG_getFeedPath();
    if ($_MG_CONF['rss_full_enabled'] != 1) {
        @unlink($feedpath . '/' . $_MG_CONF['rss_feed_name'] . '.rss');
        return;
    }
    $rss = new UniversalFeedCreator();
    $rss->title = $_CONF['site_name'] . ' Media Gallery RSS Feed';
    $rss->description = $_CONF['site_slogan'];
    $rss->descriptionTruncSize = 500;
    $rss->descriptionHtmlSyndicated = true;
    $rss->encoding = strtoupper($_CONF['default_charset']);
    $rss->link = $_CONF['site_url'];
    $feedurl = SYND_getFeedUrl();
    $rss->syndicationURL = $feedurl . $_MG_CONF['rss_feed_name'] . '.rss';
    MG_parseAlbumsRSS($rss, 0);
    $rss->saveFeed($_MG_CONF['rss_feed_type'], $feedpath . "/" . $_MG_CONF['rss_feed_name'] . '.rss', 0);
    @chmod($feedpath . '/' . $_MG_CONF['rss_feed_name'] . '.rss', 0664);
    return;
}
Beispiel #9
0
/**
 * get field data for the feed list administration
 *
 */
function FEED_getListField($fieldname, $fieldvalue, $A, $icon_arr, $token)
{
    global $_CONF, $_USER, $_TABLES, $LANG_ADMIN, $LANG33, $_IMAGE_TYPE;
    $retval = '';
    $enabled = $A['is_enabled'] == 1 ? true : false;
    $dt = new Date('now', $_USER['tzid']);
    switch ($fieldname) {
        case 'edit':
            $attr['title'] = $LANG_ADMIN['edit'];
            $retval = COM_createLink($icon_arr['edit'], $_CONF['site_admin_url'] . '/syndication.php?edit=x&amp;fid=' . $A['fid'], $attr);
            break;
        case 'delete':
            $attr['title'] = $LANG_ADMIN['delete'];
            $attr['onclick'] = 'return confirm(\'' . $LANG33[56] . '\');"';
            $retval = COM_createLink($icon_arr['delete'], $_CONF['site_admin_url'] . '/syndication.php?delete=x&amp;fid=' . $A['fid'] . '&amp;' . CSRF_TOKEN . '=' . $token, $attr);
            break;
        case 'type':
            if ($A['type'] == 'article') {
                $type = $LANG33[55];
            } else {
                $type = ucwords($A['type']);
            }
            $retval = $enabled ? $type : '<span class="disabledfield">' . $type . '</span>';
            break;
        case 'format':
            $format = str_replace('-', ' ', ucwords($A['format']));
            $retval = $enabled ? $format : '<span class="disabledfield">' . $format . '</span>';
            break;
        case 'updated':
            $dt->setTimeStamp($A['date']);
            $datetime = $dt->format($_CONF['daytime'], true);
            $retval = $enabled ? $datetime : '<span class="disabledfield">' . $datetime . '</span>';
            break;
        case 'is_enabled':
            if ($enabled) {
                $switch = ' checked="checked"';
                $title = 'title="' . $LANG_ADMIN['disable'] . '" ';
            } else {
                $title = 'title="' . $LANG_ADMIN['enable'] . '" ';
                $switch = '';
            }
            $switch = $enabled ? ' checked="checked"' : '';
            $retval = '<input type="checkbox" name="enabledfeeds[' . $A['fid'] . ']" ' . $title . 'onclick="submit()" value="' . $A['fid'] . '"' . $switch . '/>';
            $retval .= '<input type="hidden" name="feedarray[' . $A['fid'] . ']" value="1" ' . '/>';
            break;
        case 'header_tid':
            if ($A['header_tid'] == 'all') {
                $tid = $LANG33[43];
            } elseif ($A['header_tid'] == 'none') {
                $tid = $LANG33[44];
            } else {
                $tid = DB_getItem($_TABLES['topics'], 'topic', "tid = '" . DB_escapeString($A['header_tid']) . "'");
            }
            $retval = $enabled ? $tid : '<span class="disabledfield">' . $tid . '</span>';
            break;
        case 'filename':
            if ($enabled) {
                $url = SYND_getFeedUrl();
                $attr['title'] = $A['description'];
                $retval = COM_createLink($A['filename'], $url . $A['filename'], $attr);
            } else {
                $retval = '<span class="disabledfield">' . $A['filename'] . '</span>';
            }
            break;
        default:
            $retval = $enabled ? $fieldvalue : '<span class="disabledfield">' . $fieldvalue . '</span>';
            break;
    }
    return $retval;
}
/**
* Update a feed.
* Re-written by Michael Jervis (mike AT fuckingbrit DOT com)
* to use the new architecture
*
* @param   int   $fid   feed id
*
*/
function SYND_updateFeed($fid)
{
    global $_CONF, $_TABLES, $_SYND_DEBUG;
    SYND_fixCharset($fid);
    $result = DB_query("SELECT * FROM {$_TABLES['syndication']} WHERE fid = {$fid}");
    $A = DB_fetchArray($result);
    if ($A['is_enabled'] == 1) {
        // Import the feed handling classes:
        require_once $_CONF['path_system'] . '/classes/syndication/parserfactory.class.php';
        require_once $_CONF['path_system'] . '/classes/syndication/feedparserbase.class.php';
        // Load the actual feed handlers:
        $factory = new FeedParserFactory($_CONF['path_system'] . '/classes/syndication/');
        $format = explode('-', $A['format']);
        $feed = $factory->writer($format[0], $format[1]);
        if ($feed) {
            $feed->encoding = $A['charset'];
            $feed->lang = $A['language'];
            if ($A['type'] == 'article') {
                if ($A['topic'] == '::all') {
                    $content = SYND_getFeedContentAll(false, $A['limits'], $link, $data, $A['content_length'], $format[0], $format[1], $fid);
                } elseif ($A['topic'] == '::frontpage') {
                    $content = SYND_getFeedContentAll(true, $A['limits'], $link, $data, $A['content_length'], $format[0], $format[1], $fid);
                } else {
                    // feed for a single topic only
                    $content = SYND_getFeedContentPerTopic($A['topic'], $A['limits'], $link, $data, $A['content_length'], $format[0], $format[1], $fid);
                }
            } else {
                $content = PLG_getFeedContent($A['type'], $fid, $link, $data, $format[0], $format[1]);
                // can't randomly change the api to send a max length, so
                // fix it here:
                if ($A['content_length'] != 1) {
                    $count = count($content);
                    for ($i = 0; $i < $count; $i++) {
                        $content[$i]['summary'] = $A['content_length'] == 1 ? $content[$i]['text'] : COM_truncateHTML($content[$i]['text'], $A['content_length'], ' ...');
                    }
                }
            }
            if (empty($link)) {
                $link = $_CONF['site_url'];
            }
            $feed->title = $A['title'];
            $feed->description = $A['description'];
            if (empty($A['feedlogo'])) {
                $feed->feedlogo = '';
            } else {
                $feed->feedlogo = $_CONF['site_url'] . $A['feedlogo'];
            }
            $feed->sitelink = $link;
            $feed->copyright = 'Copyright ' . strftime('%Y') . ' ' . $_CONF['site_name'];
            $feed->sitecontact = $_CONF['site_mail'];
            $feed->system = 'Geeklog';
            /* Gather any other stuff */
            $feed->namespaces = array_merge($feed->namespaces, PLG_getFeedNSExtensions($A['type'], $format[0], $format[1], $A['topic'], $fid));
            /* If the feed is RSS, and trackback is enabled */
            if ($_CONF['trackback_enabled'] && $format[0] == 'RSS') {
                /* Check to see if an article has trackbacks enabled, and if
                 * at least one does, then include the trackback namespace:
                 */
                $trackbackenabled = false;
                foreach ($content as $item) {
                    if (array_key_exists('extensions', $item) && array_key_exists('trackbacktag', $item['extensions'])) {
                        // Found at least one article, with a trackbacktag
                        // in it's extensions tag.
                        $trackbackenabled = true;
                        break;
                    }
                }
                if ($trackbackenabled) {
                    $feed->namespaces[] = 'xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"';
                }
            }
            /* Inject the namespace for Atom into RSS feeds. Illogical?
             * Well apparantly not:
             * http://feedvalidator.org/docs/warning/MissingAtomSelfLink.html
             */
            if ($format[0] == 'RSS') {
                $feed->namespaces[] = 'xmlns:atom="http://www.w3.org/2005/Atom"';
            }
            if (!empty($A['filename'])) {
                $filename = $A['filename'];
            } else {
                $pos = strrpos($_CONF['rdf_file'], '/');
                $filename = substr($_CONF['rdf_file'], $pos + 1);
            }
            $feed->url = SYND_getFeedUrl($filename);
            $feed->extensions = PLG_getFeedExtensionTags($A['type'], $format[0], $format[1], $A['topic'], $fid, $feed);
            /* Inject the self reference for Atom into RSS feeds. Illogical?
             * Well apparantly not:
             * http://feedvalidator.org/docs/warning/MissingAtomSelfLink.html
             */
            if ($format[0] == 'RSS') {
                $feed->extensions[] = '<atom:link href="' . $feed->url . '" rel="self" type="application/rss+xml" />';
            }
            $feed->articles = $content;
            $feed->createFeed(SYND_getFeedPath($filename));
        } else {
            COM_errorLog("Unable to get a feed writer for {$format[0]} version {$format[1]}.", 1);
        }
        if (empty($data)) {
            $data = 'NULL';
        } else {
            $data = "'" . $data . "'";
        }
        if ($_SYND_DEBUG) {
            COM_errorLog("update_info for feed {$fid} is {$data}", 1);
        }
        DB_query("UPDATE {$_TABLES['syndication']} SET updated = NOW(), update_info = {$data} WHERE fid = {$fid}");
    }
}
Beispiel #11
0
/**
 * used for the list of feeds in admin/syndication.php
 *
 */
function ADMIN_getListField_syndication($fieldname, $fieldvalue, $A, $icon_arr, $token)
{
    global $_CONF, $_TABLES, $LANG_ADMIN, $LANG33, $_IMAGE_TYPE;
    static $added_token;
    $retval = '';
    switch ($fieldname) {
        case 'edit':
            $retval = COM_createLink($icon_arr['edit'], "{$_CONF['site_admin_url']}/syndication.php?mode=edit&amp;fid={$A['fid']}");
            break;
        case 'type':
            if ($A['type'] == 'article') {
                $retval = $LANG33[55];
            } else {
                $retval = ucwords($A['type']);
            }
            break;
        case 'format':
            $retval = str_replace('-', ' ', ucwords($A['format']));
            break;
        case 'updated':
            $retval = strftime($_CONF['daytime'], $A['date']);
            break;
        case 'is_enabled':
            if ($A['is_enabled'] == 1) {
                $switch = ' checked="checked"';
            } else {
                $switch = '';
            }
            $retval = "<input type=\"checkbox\" name=\"enabledfeeds[]\" " . "onclick=\"submit()\" value=\"{$A['fid']}\"{$switch}" . XHTML . ">";
            if (!isset($added_token)) {
                $retval .= "<input type=\"hidden\" name=\"" . CSRF_TOKEN . "\" value=\"{$token}\"" . XHTML . ">";
                $added_token = true;
            }
            break;
        case 'header_tid':
            if ($A['header_tid'] == 'all') {
                $retval = $LANG33[43];
            } elseif ($A['header_tid'] == 'none') {
                $retval = $LANG33[44];
            } else {
                $retval = DB_getItem($_TABLES['topics'], 'topic', "tid = '{$A['header_tid']}'");
            }
            break;
        case 'filename':
            $url = SYND_getFeedUrl();
            $retval = COM_createLink($A['filename'], $url . $A['filename']);
            break;
        default:
            $retval = $fieldvalue;
            break;
    }
    return $retval;
}
Beispiel #12
0
/**
* Returns the site header
*
* This loads the proper templates, does variable substitution and returns the
* HTML for the site header with or without blocks depending on the value of $what
*
* Programming Note:
*
* The two functions COM_siteHeader and COM_siteFooter provide the framework for
* page display in glFusion.  COM_siteHeader controls the display of the Header
* and left blocks and COM_siteFooter controls the dsiplay of the right blocks
* and the footer.  You use them like a sandwich.  Thus the following code will
* display a glFusion page with both right and left blocks displayed.
*
* <code>
* <?php
* require_once('lib-common.php');
* $display .= COM_siteHeader(); //Change to COM_siteHeader('none') to not display left blocks
* $display .= "Here is your html for display";
* $display .= COM_siteFooter(true);  // Change to COM_siteFooter() to not display right blocks
* echo $display;
* ? >
* </code>
*
* Note that the default for the header is to display the left blocks and the
* default of the footer is to not display the right blocks.
*
* This sandwich produces code like this (greatly simplified)
* <code>
* // COM_siteHeader
* <table><tr><td colspan="3">Header</td></tr>
* <tr><td>Left Blocks</td><td>
*
* // Your HTML goes here
* Here is your html for display
*
* // COM_siteFooter
* </td><td>Right Blocks</td></tr>
* <tr><td colspan="3">Footer</td></table>
* </code>
*
* @param    string  $what       If 'none' then no left blocks are returned, if
*                               'menu' (default) then right blocks are returned
* @param    string  $pagetitle  optional content for the page's <title>
* @param    string  $headercode optional code to go into the page's <head>
* @return   string              Formatted HTML containing the site header
* @see function COM_siteFooter
*
*/
function COM_siteHeader($what = 'menu', $pagetitle = '', $headercode = '')
{
    global $_CONF, $_SYSTEM, $_VARS, $_TABLES, $_USER, $LANG01, $LANG_BUTTONS, $LANG_DIRECTION, $_IMAGE_TYPE, $topic, $_COM_VERBOSE, $theme_what, $theme_pagetitle, $theme_headercode, $theme_layout, $blockInterface;
    if (!isset($_USER['theme']) || $_USER['theme'] == '') {
        $_USER['theme'] = $_CONF['theme'];
    }
    $function = $_USER['theme'] . '_siteHeader';
    if (function_exists($function)) {
        return $function($what, $pagetitle, $headercode);
    }
    $dt = new Date('now', $_USER['tzid']);
    static $headerCalled = 0;
    if ($headerCalled == 1) {
        return '';
    }
    $headerCalled = 1;
    if (is_array($what)) {
        $theme_what = array();
    }
    $theme_pagetitle = $pagetitle;
    $theme_headercode = $headercode;
    if (isset($blockInterface['left'])) {
        $currentURL = COM_getCurrentURL();
        if (strpos($currentURL, $_CONF['site_admin_url']) === 0) {
            if ($blockInterface['left']['location'] == 'right' || $blockInterface['left']['location'] == 'left') {
                $theme_what = 'none';
            } else {
                $theme_what = $what;
            }
        } else {
            $theme_what = $what;
        }
    } else {
        $theme_what = $what;
    }
    $header = new Template($_CONF['path_layout']);
    $header->set_file('header', 'htmlheader.thtml');
    $cacheID = SESS_getVar('cacheID');
    if (empty($cacheID) || $cacheID == '') {
        if (!isset($_VARS['cacheid'])) {
            $cacheID = 'css_' . md5(time());
            $_VARS['cacheid'] = $cacheID;
        } else {
            $cacheID = $_VARS['cacheid'];
        }
        SESS_setVar('cacheID', $cacheID);
    }
    // give the theme a chance to load stuff....
    $function = $_USER['theme'] . '_headerVars';
    if (function_exists($function)) {
        $function($header);
    }
    // get topic if not on home page
    if (!isset($_GET['topic'])) {
        if (isset($_GET['story'])) {
            $sid = COM_applyFilter($_GET['story']);
        } elseif (isset($_GET['sid'])) {
            $sid = COM_applyFilter($_GET['sid']);
        } elseif (isset($_POST['story'])) {
            $sid = COM_applyFilter($_POST['story']);
        }
        if (empty($sid) && $_CONF['url_rewrite'] && strpos($_SERVER['PHP_SELF'], 'article.php') !== false) {
            COM_setArgNames(array('story', 'mode'));
            $sid = COM_applyFilter(COM_getArgument('story'));
        }
        if (!empty($sid)) {
            $topic = DB_getItem($_TABLES['stories'], 'tid', "sid='" . DB_escapeString($sid) . "'");
        }
    } else {
        $topic = COM_applyFilter($_GET['topic']);
    }
    $feed_url = array();
    if ($_CONF['backend'] == 1) {
        // add feed-link to header if applicable
        if (SESS_isSet('feedurl')) {
            $feed_url = unserialize(SESS_getVar('feedurl'));
        } else {
            $baseurl = SYND_getFeedUrl();
            $sql = 'SELECT format, filename, title, language FROM ' . $_TABLES['syndication'] . " WHERE (header_tid = 'all')";
            if (!empty($topic)) {
                $sql .= " OR (header_tid = '" . DB_escapeString($topic) . "')";
            }
            $result = DB_query($sql);
            $numRows = DB_numRows($result);
            for ($i = 0; $i < $numRows; $i++) {
                $A = DB_fetchArray($result);
                if (!empty($A['filename'])) {
                    $format = explode('-', $A['format']);
                    $format_type = strtolower($format[0]);
                    $format_name = ucwords($format[0]);
                    $feed_url[] = '<link rel="alternate" type="application/' . $format_type . '+xml"' . ' href="' . $baseurl . $A['filename'] . '" title="' . $format_name . ' Feed: ' . $A['title'] . '"/>';
                }
            }
            SESS_setVar('feedurl', serialize($feed_url));
        }
    }
    $header->set_var('feed_url', implode(LB, $feed_url));
    $relLinks = array();
    if (!COM_onFrontpage()) {
        $relLinks['home'] = '<link rel="home" href="' . $_CONF['site_url'] . '/" title="' . $LANG01[90] . '"/>';
    } else {
        CMT_updateCommentcodes();
    }
    $loggedInUser = !COM_isAnonUser();
    if ($loggedInUser || $_CONF['loginrequired'] == 0 && $_CONF['searchloginrequired'] == 0) {
        if (substr($_SERVER['PHP_SELF'], -strlen('/search.php')) != '/search.php' || isset($_GET['mode'])) {
            $relLinks['search'] = '<link rel="search" href="' . $_CONF['site_url'] . '/search.php" title="' . $LANG01[75] . '"/>';
        }
    }
    if ($loggedInUser || $_CONF['loginrequired'] == 0 && $_CONF['directoryloginrequired'] == 0) {
        if (strpos($_SERVER['PHP_SELF'], '/article.php') !== false) {
            $relLinks['contents'] = '<link rel="contents" href="' . $_CONF['site_url'] . '/directory.php" title="' . $LANG01[117] . '"/>';
        }
    }
    if (!$_CONF['disable_webservices']) {
        $relLinks['service'] = '<link rel="service" ' . 'type="application/atomsvc+xml" ' . 'href="' . $_CONF['site_url'] . '/webservices/atom/index.php?introspection" ' . 'title="' . $LANG01[130] . '"/>' . LB;
    }
    $header->set_var('rel_links', implode(LB, $relLinks));
    if (empty($pagetitle) && isset($_CONF['pagetitle'])) {
        $pagetitle = $_CONF['pagetitle'];
    }
    if (empty($pagetitle)) {
        if (empty($topic)) {
            $pagetitle = $_CONF['site_slogan'];
        } else {
            $pagetitle = DB_getItem($_TABLES['topics'], 'topic', "tid = '" . DB_escapeString($topic) . "'");
        }
    }
    if (!empty($pagetitle)) {
        $header->set_var('page_site_splitter', ' - ');
    } else {
        $header->set_var('page_site_splitter', '');
    }
    $header->set_var('page_title', $pagetitle);
    $header->set_var('site_name', $_CONF['site_name']);
    if (COM_onFrontpage()) {
        $title_and_name = $_CONF['site_name'];
        if (!empty($pagetitle)) {
            $title_and_name .= ' - ' . $pagetitle;
        }
    } else {
        $title_and_name = '';
        if (!empty($pagetitle)) {
            $title_and_name = $pagetitle . ' - ';
        }
        $title_and_name .= $_CONF['site_name'];
    }
    $header->set_var('page_title_and_site_name', $title_and_name);
    $rdf = substr_replace($_CONF['rdf_file'], $_CONF['site_url'], 0, strlen($_CONF['path_html']) - 1) . LB;
    list($cacheFile, $style_cache_url) = COM_getStyleCacheLocation();
    list($cacheFile, $js_cache_url) = COM_getJSCacheLocation();
    $header->set_var(array('site_name' => $_CONF['site_name'], 'site_slogan' => $_CONF['site_slogan'], 'rdf_file' => $rdf, 'rss_url' => $rdf, 'css_url' => $_CONF['layout_url'] . '/style.css', 'theme' => $_USER['theme'], 'style_cache_url' => $style_cache_url, 'js_cache_url' => $js_cache_url, 'charset' => COM_getCharset(), 'cacheid' => $_USER['theme'] . $cacheID, 'direction' => empty($LANG_DIRECTION) ? 'ltr' : $LANG_DIRECTION, 'plg_headercode' => $headercode . PLG_getHeaderCode()));
    // Call to plugins to set template variables in the header
    PLG_templateSetVars('header', $header);
    $header->parse('index_header', 'header');
    $retval = $header->finish($header->get_var('index_header'));
    echo $retval;
    // Start caching / capturing output from glFusion / plugins
    ob_start();
    return '';
}
Beispiel #13
0
/**
* Return information for a story
*
* This is the story equivalent of PLG_getItemInfo. See lib-plugins.php for
* details.
*
* @param    string  $sid        story ID or '*'
* @param    string  $what       comma-separated list of story properties
* @param    int     $uid        user ID or 0 = current user
* @return   mixed               string or array of strings with the information
*
*/
function STORY_getItemInfo($sid, $what, $uid = 0, $options = array())
{
    global $_CONF, $_TABLES, $LANG09;
    $properties = explode(',', $what);
    $fields = array();
    foreach ($properties as $p) {
        switch ($p) {
            case 'date-created':
                $fields[] = 'UNIX_TIMESTAMP(date) AS unixdate';
                break;
            case 'description':
            case 'raw-description':
                $fields[] = 'introtext';
                $fields[] = 'bodytext';
                break;
            case 'excerpt':
                $fields[] = 'introtext';
                break;
            case 'feed':
                $fields[] = 'tid';
                break;
            case 'id':
                $fields[] = 'sid';
                break;
            case 'title':
                $fields[] = 'title';
                break;
            case 'url':
            case 'label':
                $fields[] = 'sid';
                break;
            case 'status':
                $fields[] = 'draft_flag';
                break;
            case 'author':
                $fields[] = 'uid';
                break;
            default:
                break;
        }
    }
    $fields = array_unique($fields);
    if (count($fields) == 0) {
        $retval = array();
        return $retval;
    }
    if ($sid == '*') {
        $where = ' WHERE';
    } else {
        $where = " WHERE (sid = '" . DB_escapeString($sid) . "') AND";
    }
    $where .= ' (date <= NOW())';
    if ($uid > 0) {
        $permSql = COM_getPermSql('AND', $uid) . COM_getTopicSql('AND', $uid);
    } else {
        $permSql = COM_getPermSql('AND') . COM_getTopicSql('AND');
    }
    $sql = "SELECT " . implode(',', $fields) . " FROM {$_TABLES['stories']}" . $where . $permSql;
    if ($sid != '*') {
        $sql .= ' LIMIT 1';
    }
    $result = DB_query($sql);
    $numRows = DB_numRows($result);
    $retval = array();
    for ($i = 0; $i < $numRows; $i++) {
        $A = DB_fetchArray($result);
        $props = array();
        foreach ($properties as $p) {
            switch ($p) {
                case 'date-created':
                    $props['date-created'] = $A['unixdate'];
                    break;
                case 'description':
                    $props['description'] = trim(PLG_replaceTags($A['introtext'] . ' ' . $A['bodytext'], 'glfusion', 'story'));
                    break;
                case 'raw-description':
                    $props['raw-description'] = trim($A['introtext'] . ' ' . $A['bodytext']);
                    break;
                case 'excerpt':
                    $excerpt = $A['introtext'];
                    $props['excerpt'] = trim(PLG_replaceTags($excerpt, 'glfusion', 'story'));
                    break;
                case 'feed':
                    $feedfile = DB_getItem($_TABLES['syndication'], 'filename', "topic = '::all'");
                    if (empty($feedfile)) {
                        $feedfile = DB_getItem($_TABLES['syndication'], 'filename', "topic = '::frontpage'");
                    }
                    if (empty($feedfile)) {
                        $feedfile = DB_getItem($_TABLES['syndication'], 'filename', "topic = '{$A['tid']}'");
                    }
                    if (empty($feedfile)) {
                        $props['feed'] = '';
                    } else {
                        $props['feed'] = SYND_getFeedUrl($feedfile);
                    }
                    break;
                case 'id':
                    $props['id'] = $A['sid'];
                    break;
                case 'title':
                    $props['title'] = $A['title'];
                    break;
                case 'url':
                    if (empty($A['sid'])) {
                        $props['url'] = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid);
                    } else {
                        $props['url'] = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']);
                    }
                    break;
                case 'label':
                    $props['label'] = $LANG09[65];
                    break;
                case 'status':
                    if ($A['draft_flag'] == 0) {
                        $props['status'] = 1;
                    } else {
                        $props['status'] = 0;
                    }
                    break;
                case 'author':
                    $props['author'] = $A['uid'];
                    break;
                default:
                    $props[$p] = '';
                    break;
            }
        }
        $mapped = array();
        foreach ($props as $key => $value) {
            if ($sid == '*') {
                if ($value != '') {
                    $mapped[$key] = $value;
                }
            } else {
                $mapped[$key] = $value;
            }
        }
        if ($sid == '*') {
            $retval[] = $mapped;
        } else {
            $retval = $mapped;
            break;
        }
    }
    if ($sid != '*' && count($retval) == 1) {
        $tRet = array_values($retval);
        $retval = $tRet[0];
    }
    return $retval;
}
Beispiel #14
0
/**
* Update a feed.
*
* @param   int   $fid   feed id
*
*/
function SYND_updateFeed($fid)
{
    global $_CONF, $_TABLES, $_SYND_DEBUG;
    require_once $_CONF['path'] . '/lib/feedcreator/feedcreator.class.php';
    $result = DB_query("SELECT * FROM {$_TABLES['syndication']} WHERE fid = '" . DB_escapeString($fid) . "'");
    $A = DB_fetchArray($result);
    if ($A['is_enabled'] == 1) {
        $format = explode('-', $A['format']);
        $rss = new UniversalFeedCreator();
        if ($A['content_length'] > 1) {
            $rss->descriptionTruncSize = $A['content_length'];
        }
        $rss->descriptionHtmlSyndicated = false;
        $rss->encoding = $A['charset'];
        $rss->language = $A['language'];
        $rss->title = $A['title'];
        $rss->description = $A['description'];
        $imgurl = '';
        if ($A['feedlogo'] != '') {
            $image = new FeedImage();
            $image->title = $A['title'];
            $image->url = $_CONF['site_url'] . $A['feedlogo'];
            $image->link = $_CONF['site_url'];
            $rss->image = $image;
        }
        $rss->link = $_CONF['site_url'];
        if (!empty($A['filename'])) {
            $filename = $A['filename'];
        } else {
            $pos = strrpos($_CONF['rdf_file'], '/');
            $filename = substr($_CONF['rdf_file'], $pos + 1);
        }
        $rss->syndicationURL = SYND_getFeedUrl($filename);
        $rss->copyright = 'Copyright ' . strftime('%Y') . ' ' . $_CONF['site_name'];
        if ($A['type'] == 'article') {
            if ($A['topic'] == '::all') {
                $content = SYND_getFeedContentAll(false, $A['limits'], $link, $data, $A['content_length'], $format[0], $format[1], $fid);
            } elseif ($A['topic'] == '::frontpage') {
                $content = SYND_getFeedContentAll(true, $A['limits'], $link, $data, $A['content_length'], $format[0], $format[1], $fid);
            } else {
                // feed for a single topic only
                $content = SYND_getFeedContentPerTopic($A['topic'], $A['limits'], $link, $data, $A['content_length'], $format[0], $format[1], $fid);
            }
        } else {
            $content = PLG_getFeedContent($A['type'], $fid, $link, $data, $format[0], $format[1]);
        }
        if (is_array($content)) {
            foreach ($content as $feedItem) {
                $item = new FeedItem();
                foreach ($feedItem as $var => $value) {
                    if ($var == 'date') {
                        $dt = new Date($value, $_CONF['timezone']);
                        $item->date = $dt->toISO8601(true);
                    } else {
                        if ($var == 'summary') {
                            $item->description = $value;
                        } else {
                            if ($var == 'link') {
                                $item->guid = $value;
                                $item->{$var} = $value;
                            } else {
                                $item->{$var} = $value;
                            }
                        }
                    }
                }
                $rss->addItem($item);
            }
        }
        if (empty($link)) {
            $link = $_CONF['site_url'];
        }
        $rss->editor = $_CONF['site_mail'];
        $rc = $rss->saveFeed($format[0] . '-' . $format[1], SYND_getFeedPath($filename), 0);
        if (empty($data)) {
            $data = 'NULL';
        } else {
            $data = "'" . $data . "'";
        }
        if ($_SYND_DEBUG) {
            COM_errorLog("update_info for feed {$fid} is {$data}", 1);
        }
        DB_query("UPDATE {$_TABLES['syndication']} SET updated = NOW(), update_info = {$data} WHERE fid = '" . DB_escapeString($fid) . "'");
    }
}