
07-02-2004, 08:35
|
 |
Registered User
AKA: Kevin Beranek
 FRC #0269 (Cooney Robotics)
Team Role: College Student
|
|
Join Date: Jan 2004
Rookie Year: 2003
Location: Wisconsin
Posts: 47
|
|
|
Re: CD Feed
Thank you, this is pretty much what I was looking for.
Quote:
|
Originally Posted by SilverStar
Here's some new code that links to the correct CD thread.
Unfortunately, the external.xml that CD provides only gives the thread's author, not the post's author. I hope this changed soon
You can see the following code in action at: http://nrg.chaosnet.org/resource/pro...eed/cdfeed.php
The code is also stored in the repository, as usual...
PHP Code:
<?php // If you want to use this PHP code, provide credit to [removed] $cdfeed = "[url="http://www.chiefdelphi.com/forums/external.php?type=XML"]http://www.chiefdelphi.com/forums/external.php?type=XML[/url]"; $fp = fopen($cdfeed, "r") or die("<b>Unable read ChiefDelphi feed!</b>\n"); while(!feof($fp)) { $xmld = $xmld.fgets($fp, 1024); } $open_stack = array(); $atts_stack = array(); $parser = xml_parser_create(); xml_set_element_handler($parser, "start_handler", "end_handler"); xml_set_character_data_handler($parser, "character_handler"); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING,0); xml_parse($parser, $xmld); xml_parser_free($parser); function start_handler($p, $name, $atts) { global $open_stack; global $atts_stack; global $cdthreads; $open_stack[] = array($name,"",$atts); if ($name == "thread"){ $cdthreads[]=array("id"=>$atts['id'],"title"=>"","auth"=>"","time"=>0,"date"=>0); $id=$atts['id']; print "<a href=\"<A href="http://www.chiefdelphi.com/forums/showthread.php?t=$id\">n">http://www.chiefdelphi.com/forums/showthread.php?t=$id\">\n"; } } function character_handler($p, $txt) { global $open_stack; $cur_index = count($open_stack)-1; $open_stack[$cur_index][1].=$txt; } function end_handler($p, $name) { global $open_stack; $el = array_pop($open_stack); if ($name == "thread"){ print "</a>\n"; } if ($name == "title") { echo "<b>$el[1]</b><br>"; $cdthreads[count($cdthreads)-1]['title']=$el[1]; } if ($name == "author") { echo "By <i>$el[1]</i>"; $cdthreads[count($cdthreads)-1]['auth']=$el[1]; } if ($name == "date") { echo "On $el[1],"; $cdthreads[count($cdthreads)-1]['date']=$el[1]; } if ($name == "time") { echo " at $el[1]<p>"; $cdthreads[count($cdthreads)-1]['time']=$el[1]; }
} // At this point, all the threads have been printed out if PRINTOUT equaled one // Also all the threads are stored in $cdthreads associative array.
?>
|
Last edited by Brandon Martus : 02-08-2016 at 08:18.
|