Import of recovered 0.7a
This commit is contained in:
commit
5d5f103a26
26 changed files with 1516 additions and 0 deletions
111
minclude/rss-import.inc
Normal file
111
minclude/rss-import.inc
Normal file
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
// Stuff for RDF parsing - based on code originally from
|
||||
// http://www.phpbuilder.com/columns/joe20000907.php3
|
||||
|
||||
function startElement($parser, $name, $attrs=''){
|
||||
|
||||
global $open_tags, $current_tag, $initem, $index;
|
||||
$current_tag = $name;
|
||||
|
||||
switch($name){
|
||||
case 'ITEM':
|
||||
$initem=1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function endElement($parser, $name, $attrs=''){
|
||||
|
||||
global $close_tags, $current_tag, $initem, $index;
|
||||
|
||||
switch($name){
|
||||
case 'ITEM':
|
||||
$index++;
|
||||
$initem = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function characterData($parser, $data) {
|
||||
|
||||
global $current_tag, $initem, $links, $titles, $channelurl, $channeltitle, $index;
|
||||
switch($current_tag){
|
||||
case 'TITLE':
|
||||
if (!$initem && chop($data) != "") {
|
||||
$channeltitle = $data;
|
||||
}
|
||||
else {
|
||||
$titles[$index] = $data;
|
||||
}
|
||||
$current_tag = '';
|
||||
break;
|
||||
|
||||
case 'LINK':
|
||||
if ($initem) {
|
||||
$links[$index] = $data;
|
||||
}
|
||||
else {
|
||||
$channelurl = $data;
|
||||
}
|
||||
$current_tag = '';
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function grab_headlines($xml_file) {
|
||||
global $index, $channeltitle, $channelurl, $links, $titles;
|
||||
|
||||
$index=0;
|
||||
|
||||
$xml_parser = make_xml_parser("characterData", "startElement","endElement");
|
||||
|
||||
//$xml_parser = xml_parser_create("UTF-8");
|
||||
//xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
|
||||
//xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
|
||||
//if (!xml_set_element_handler($xml_parser, 'startElement','endElement')){
|
||||
// die("Failed to set element handler!\n");
|
||||
// }
|
||||
//xml_set_character_data_handler($xml_parser, 'characterData');
|
||||
|
||||
|
||||
if (!($fp = fopen($xml_file, 'r'))) {
|
||||
die("Could not open $xml_file for parsing!\n");
|
||||
}
|
||||
|
||||
|
||||
// loop through the file and parse baby!
|
||||
while ($data = fread($fp, 4096)) {
|
||||
if (!($data = utf8_encode($data))) {
|
||||
echo 'ERROR'."\n";
|
||||
}
|
||||
|
||||
if (!xml_parse($xml_parser, $data, feof($fp))) {
|
||||
die(sprintf( "XML error: %s at line %d\n\n",
|
||||
xml_error_string(xml_get_error_code($xml_parser)),
|
||||
xml_get_current_line_number($xml_parser)));
|
||||
}
|
||||
}
|
||||
//if (sizeof($titles) > $limit
|
||||
//Output the title of the Channel ($channelname, $channelurl)
|
||||
print"<p class=\"menusubhead\"><a href=\"$channelurl\">$channeltitle</a></p>\n";
|
||||
//Output the links ($links[x], $titles[x])
|
||||
|
||||
for ($count=0;$count<$index;$count++) {
|
||||
if ($links[$count] == "" || $links[$count] == "\n") {
|
||||
$links[$count] = $channelurl;
|
||||
}
|
||||
print"<p class=\"menuoption\"><a href=\"$links[$count]\" class=\"linkurl\">$titles[$count]</a>\n";
|
||||
}
|
||||
xml_parser_free($xml_parser);
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue