示例#1
0
                if ($cur_topic['poster_email'] != '' && !$panther_user['is_guest']) {
                    $item['author']['email'] = $cur_topic['poster_email'];
                }
            }
            $feed['items'][] = $item;
        }
        // Output feed as PHP code
        if (isset($cache_id)) {
            if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
                require PANTHER_ROOT . 'include/cache.php';
            }
            $content = '<?php' . "\n\n" . '$feed = ' . var_export($feed, true) . ';' . "\n\n" . '$cache_expire = ' . ($now + $panther_config['o_feed_ttl'] * 60) . ';' . "\n\n" . '?>';
            panther_write_cache_file('cache_' . $cache_id . '.php', $content);
        }
    }
    // If we only want to show a few items but due to caching we have too many
    if (count($feed['items']) > $show) {
        $feed['items'] = array_slice($feed['items'], 0, $show);
    }
    // Prepend the current base URL onto some links. Done after caching to handle http/https correctly
    $feed['link'] = $feed['link'];
    foreach ($feed['items'] as $key => $item) {
        $feed['items'][$key]['link'] = panther_htmlspecialchars_decode($item['link']);
        if (isset($item['author']['uri'])) {
            $feed['items'][$key]['author']['uri'] = $item['author']['uri'];
        }
    }
    $output_func = 'output_' . $type;
    $output_func($feed);
}
exit;
示例#2
0
 private function handle_url_tag($url, $link = '', $bbcode = false)
 {
     $url = panther_trim($url);
     // Deal with [url][img]http://example.com/test.png[/img][/url]
     if (preg_match('%<img src=\\"(.*?)\\"%', $url, $matches)) {
         return $this->handle_url_tag($matches[1], $url, $bbcode);
     }
     $full_url = str_replace(array(' ', '\'', '`', '"'), array('%20', '', '', ''), $url);
     if (strpos($url, 'www.') === 0) {
         // If it starts with www, we add http://
         $full_url = 'http://' . $full_url;
     } else {
         if (strpos($url, 'ftp.') === 0) {
             // Else if it starts with ftp, we add ftp://
             $full_url = 'ftp://' . $full_url;
         } else {
             if (strpos($url, '/') === 0) {
                 // Allow for relative URLs that start with a slash
                 $full_url = get_base_url() . $full_url;
             } else {
                 if (!preg_match('#^([a-z0-9]{3,6})://#', $url)) {
                     // Else if it doesn't start with abcdef://, we add http://
                     $full_url = 'http://' . $full_url;
                 }
             }
         }
     }
     // Ok, not very pretty :-)
     if ($bbcode) {
         if ($full_url == $link) {
             return '[url]' . $link . '[/url]';
         } else {
             return '[url=' . $full_url . ']' . $link . '[/url]';
         }
     } else {
         if ($link == '' || $link == $url) {
             $url = panther_htmlspecialchars_decode($url);
             $link = utf8_strlen($url) > 55 ? utf8_substr($url, 0, 39) . ' … ' . utf8_substr($url, -10) : $url;
             $link = panther_htmlspecialchars($link);
         } else {
             $link = stripslashes($link);
         }
         return '<a href="' . $full_url . '" rel="nofollow">' . $link . '</a>';
     }
 }