コード例 #1
0
         $t_content = message_get_content($thread['TID'], $thread['LENGTH']);
         $t_user_array = message_get_user_array($thread['TID'], $thread['LENGTH']);
     }
     // Strip signatures from the RSS feed
     $t_content = message_apply_formatting($t_content, true);
     // Strip HTML and trim the content back.
     $t_content = strip_tags(trim(xml_strip_invalid_chars($t_content)));
     // Convert HTML special chars (& -> &, etc);
     $t_content = htmlspecialchars($t_content);
     $t_title = htmlspecialchars($t_title);
     // Check for double-encoded HTML chars (&, etc.)
     $t_content = preg_replace("/&(#[0-9]+|[a-z]+);/iu", "&\\1;", $t_content);
     $t_title = preg_replace("/&(#[0-9]+|[a-z]+);/iu", "&\\1;", $t_title);
     // Convert HTML entities to XML literals.
     $t_content = html_entity_to_decimal($t_content);
     $t_title = html_entity_to_decimal($t_title);
     // Output the item.
     echo "<item>\n";
     echo "  <guid isPermaLink=\"true\">{$forum_location}/index.php?webtag={$webtag}&amp;msg={$thread['TID']}.1</guid>\n";
     echo "  <pubDate>{$modified_date} UT</pubDate>\n";
     echo "  <title>{$t_title}</title>\n";
     echo "  <link>{$forum_location}/index.php?webtag={$webtag}&amp;msg={$thread['TID']}.1</link>\n";
     // Get the author of the message.
     if (isset($t_user_array['LOGON'])) {
         $t_user = htmlentities_array(format_user_name($t_user_array['LOGON'], $t_user_array['NICKNAME']));
         echo "  <dc:creator>{$t_user}</dc:creator>\n";
     }
     echo "  <description><![CDATA[{$t_content}]]></description>\n";
     echo "  <comments>{$forum_location}/index.php?webtag={$webtag}&amp;msg={$thread['TID']}.1</comments>\n";
     echo "</item>\n";
 }
コード例 #2
0
function rss_feed_read_database($filename)
{
    if (!($data = rss_feed_read_stream($filename))) {
        return false;
    }
    $data = html_entity_to_decimal($data);
    $rss_data = array();
    $parser = xml_parser_create();
    $values = array();
    $tags = array();
    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    xml_parse_into_struct($parser, $data, $values, $tags);
    xml_parser_free($parser);
    // loop through the structures
    foreach ($tags as $key => $value) {
        if ($key == 'item') {
            $ranges = $value;
            // each contiguous pair of array entries are the
            // lower and upper range for each molecule definition
            for ($i = 0; $i < count($ranges); $i += 2) {
                if (isset($ranges[$i]) && isset($ranges[$i + 1])) {
                    $offset = $ranges[$i] + 1;
                    $len = $ranges[$i + 1] - $offset;
                    $rss_data[] = rss_feed_parse_item(array_slice($values, $offset, $len));
                }
            }
        } else {
            continue;
        }
    }
    return $rss_data;
}