- Timestamp:
- 12/12/06 20:06:30 (14 years ago)
- Location:
- dev
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/feed.php
r148 r150 1 1 <?php 2 3 // liq's feed syndication mod v1.2 4 2 5 @set_time_limit(0); 6 header('Content-type: text/xml'); 7 require_once( "class.corp.php" ); 8 require_once( "class.alliance.php" ); 9 require_once( "class.killlist.php" ); 10 require_once( "class.kill.php" ); 11 require_once( "db.php" ); 12 require_once( "globals.php" ); 3 13 4 // based on liq's feed syndication 5 require_once("class.corp.php"); 6 require_once("class.alliance.php"); 7 require_once("class.killlist.php");8 require_once("class.kill.php");9 require_once("db.php");10 require_once("globals.php"); 14 class RSSTable 15 { 16 function RSSTable($kill_list) { 17 $this->limit = 0; 18 $this->offset = 0; 19 $this->kill_list_ = $kill_list; 20 } 11 21 12 $html .= " 13 <rss version=\"2.0\"> 14 <channel> 15 <title>".KB_TITLE."</title> 16 <description>Kill Feed</description> 17 <link>".KB_HOST."</link> 18 <copyright>".KB_TITLE."</copyright>\n"; 22 function setLimit($limit) { 23 $this->limit_ = $limit; 24 } 19 25 20 $klist = new KillList(); 21 $klist->setPodsNoobShips(true); 22 23 if ($_GET['week']) 24 { 25 $klist->setWeek($_GET['week']); 26 } 27 elseif (!$_GET['lastkllid']) 28 { 29 $klist->setWeek(date("W")); 30 } 31 if ($_GET['lastkllid']) 32 { 33 if (method_exists($klist, 'setMinKllID')) 34 { 35 $klist->setMinKllID($_GET['lastkllid']); 26 function generate() { 27 $prevdate = ""; 28 $this->kill_list_->rewind(); 29 30 while ($kill = $this->kill_list_->getKill()) 31 { 32 $rawkill = new Kill( $kill->getID() ); 33 34 $html .= " 35 <item> 36 <title>".$rawkill->getID()."</title> 37 <description> <![CDATA[ ".$rawkill->getRawMail()." ]]> </description> 38 <guid>?a=kill_detail&kll_id=".$kill->getID()."</guid> 39 <pubDate>".strftime( "%a, %d %b %Y %T %Z" , strtotime($kill->getTimeStamp()))."</pubDate> 40 </item> "; 41 } 42 return $html; 36 43 } 37 44 } 38 45 39 if ($_GET['corp']) 46 $html .= " 47 <rss version=\"2.0\"><channel> 48 <title>".KB_TITLE."</title> 49 <link>".KB_HOST."</link> 50 <copyright>".KB_TITLE."</copyright>"; 51 52 $klist = new KillList(); 53 $klist->setOrdered(true); 54 $klist->setPodsNoobShips(true); 55 56 if ($_GET['corp'] || $_GET['corp_name']) 40 57 { 41 $_GET['corp_name'] = $_GET['corp']; 58 if ($_GET['corp']) 59 $c=$_GET['corp']; 60 if ($_GET['corp_name']) 61 $c=$_GET['corp_name']; 62 $corp = new Corporation(); 63 $corp->lookup( urldecode($c) ); 42 64 } 43 elseif ($_GET['alli'])65 if ($_GET['alli'] || $_GET['alliance_name']) 44 66 { 45 $_GET['alliance_name'] = $_GET['corp']; 46 } 47 if ($_GET['corp_name']) 48 { 49 $corp = new Corporation(); 50 $corp->lookup($_GET['corp_name']); 51 if ($_GET['losses']) 52 { 53 $klist->addVictimCorp($corp); 54 } 55 else 56 { 57 $klist->addInvolvedCorp($corp); 58 } 59 } 60 elseif ($_GET['alliance_name']) 61 { 62 $ally = new Alliance(); 63 $ally->add($_GET['alliance_name']); 64 if ($_GET['losses']) 65 { 66 $klist->addVictimAlliance($ally); 67 } 68 else 69 { 70 $klist->addInvolvedAlliance($ally); 71 } 67 if ($_GET['alli']) 68 $a=$_GET['alli']; 69 if ($_GET['alliance_name']) 70 $a=$_GET['alliance_name']; 71 $alli = new Alliance(); 72 $alli->add( urldecode($a) ); 72 73 } 73 74 74 $kills = array(); 75 while ($kill = $klist->getKill()) 76 { 77 $kills[$kill->getID()] = $kill->getTimestamp(); 75 if ($_GET['week']) 76 $klist->setWeek( $_GET['week'] ); 77 elseif (!$_GET['lastkllid']) 78 $klist->setWeek( date("W") ); 79 if ($_GET['lastkllid']) { 80 if (method_exists($klist, 'setMinKllID')) 81 $klist->setMinKllID($_GET['lastkllid']); 78 82 } 79 asort($kills);80 83 81 foreach ($kills as $id => $timestamp) 82 { 83 $kill = new Kill($id); 84 $html .= "<item> 85 <title>".$id."</title> 86 <description> <![CDATA[ ".$kill->getRawMail()." ]]> </description> 87 <guid>?a=kill_detail&kll_id=".$id."</guid> 88 <pubDate>".strftime("%a, %d %b %Y %T %Z" , strtotime($timestamp))."</pubDate> 89 </item>\n"; 84 if ( $_GET['losses']) { 85 $html .= "<description> Loss Feed v1.2</description>"; 86 if (CORP_ID) 87 $klist->addVictimCorp(new Corporation(CORP_ID)); 88 if (ALLIANCE_ID) 89 $klist->addVictimAlliance(new Alliance(ALLIANCE_ID)); 90 if ($corp) 91 $klist->addInvolvedCorp($corp); 92 if ($alli) 93 $klist->addInvolvedAlliance($alli); 94 95 } else { 96 $html .= "<description> Kill Feed v1.2</description>"; 97 if (CORP_ID) 98 $klist->addInvolvedCorp(new Corporation(CORP_ID)); 99 if (ALLIANCE_ID) 100 $klist->addInvolvedAlliance(new Alliance(ALLIANCE_ID)); 101 if ($corp) 102 $klist->addVictimCorp($corp); 103 if ($alli) 104 $klist->addVictimAlliance($alli); 90 105 } 91 $html .= "92 </channel>93 </rss>";94 106 95 if ($_GET['compress'] == '1') 96 { 97 echo gzdeflate($html); 98 } 99 else 100 { 101 echo $html; 102 } 107 $table = new RSSTable($klist); 108 $html .= $table->generate(); 109 $html .= "</channel></rss>"; 110 echo $html; 111 103 112 ?> -
dev/mods/feed_syndication/feed_fetcher.php
r148 r150 62 62 xml_set_character_data_handler ( $xml_parser, 'characterData' ); 63 63 $fp = @fopen($url,"r"); 64 while ($data = fread($fp, 4096)) {64 while ($data = @fread($fp, 4096)) { 65 65 if (!xml_parse( $xml_parser, $data, feof($fp) ) && !feof($fp) ) 66 66 return "<i>Error getting XML data from ".$url."</i><br><br>"; 67 67 } 68 fclose($fp);68 @fclose($fp); 69 69 xml_parser_free($xml_parser); 70 70 if ($x)