- Timestamp:
- 12/13/06 17:22:00 (16 years ago)
- Location:
- dev
- Files:
-
- 1 added
- 1 removed
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/feed.php
r151 r152 1 1 <?php 2 ////// 3 ////// ////// 4 ////// liq's feed syndication mod v1.3 5 //////////// 6 //////////// 7 //////////// 8 //////////// 9 10 2 11 @set_time_limit(0); 3 4 // based on liq's feed syndication5 12 require_once("class.corp.php"); 6 13 require_once("class.alliance.php"); … … 10 17 require_once("globals.php"); 11 18 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"; 19 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']); 36 } 37 } 38 39 if ($_GET['corp']) 40 { 41 $_GET['corp_name'] = $_GET['corp']; 42 } 43 elseif ($_GET['alli']) 44 { 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 } 72 } 73 74 $kills = array(); 75 while ($kill = $klist->getKill()) 76 { 77 $kills[$kill->getID()] = $kill->getTimestamp(); 78 } 79 asort($kills); 80 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"; 90 } 91 $html .= " 19 $html .= " 20 <rss version=\"2.0\"> 21 <channel> 22 <title>" . KB_TITLE . "</title> 23 <description>Kill Feed v1.3</description> 24 <link>" . KB_HOST . "</link> 25 <copyright>" . KB_TITLE . "</copyright>\n"; 26 27 $klist = new KillList(); 28 $klist->setPodsNoobShips(true); 29 30 if ($_GET['week']) 31 { 32 $klist->setWeek($_GET['week']); 33 } 34 elseif (!$_GET['lastkllid']) 35 { 36 $klist->setWeek(date("W")); 37 } 38 if ($_GET['lastkllid']) 39 { 40 if (method_exists($klist, 'setMinKllID')) 41 { 42 $klist->setMinKllID($_GET['lastkllid']); 43 } 44 } 45 46 if ($_GET['corp'] || $_GET['corp_name']) 47 { 48 if ($_GET['corp']) 49 { 50 $c = $_GET['corp']; 51 } 52 if ($_GET['corp_name']) 53 { 54 $c = $_GET['corp_name']; 55 } 56 $corp = new Corporation(); 57 $corp->lookup(urldecode($c)); 58 } 59 60 if ($_GET['alli'] || $_GET['alliance_name']) 61 { 62 if ($_GET['alli']) 63 { 64 $a = $_GET['alli']; 65 } 66 if ($_GET['alliance_name']) 67 { 68 $a = $_GET['alliance_name']; 69 } 70 $alli = new Alliance(); 71 $alli->add(urldecode($a)); 72 } 73 74 if ($_GET['week']) 75 { 76 $klist->setWeek($_GET['week']); 77 } 78 elseif (!$_GET['lastkllid']) 79 { 80 $klist->setWeek(date("W")); 81 } 82 83 if ($_GET['losses']) 84 { 85 if (CORP_ID) 86 { 87 $klist->addVictimCorp(new Corporation(CORP_ID)); 88 } 89 if (ALLIANCE_ID) 90 { 91 $klist->addVictimAlliance(new Alliance(ALLIANCE_ID)); 92 } 93 if ($corp) 94 { 95 $klist->addInvolvedCorp($corp); 96 } 97 if ($alli) 98 { 99 $klist->addInvolvedAlliance($alli); 100 } 101 } 102 else 103 { 104 if (CORP_ID) 105 { 106 $klist->addInvolvedCorp(new Corporation(CORP_ID)); 107 } 108 if (ALLIANCE_ID) 109 { 110 $klist->addInvolvedAlliance(new Alliance(ALLIANCE_ID)); 111 } 112 if ($corp) 113 { 114 $klist->addVictimCorp($corp); 115 } 116 if ($alli) 117 { 118 $klist->addVictimAlliance($alli); 119 } 120 } 121 122 $kills = array(); 123 while ($kill = $klist->getKill()) 124 { 125 $kills[$kill->getID()] = $kill->getTimestamp(); 126 } 127 asort($kills); 128 129 foreach ($kills as $id => $timestamp) 130 { 131 $kill = new Kill($id); 132 $html .= "<item> 133 <title>" . $id . "</title> 134 <description> <![CDATA[ " . $kill->getRawMail() . " ]]> </description> 135 <guid>?a=kill_detail&kll_id=" . $id . "</guid> 136 <pubDate>" . strftime("%a, %d %b %Y %T %Z", strtotime($timestamp)) . "</pubDate> 137 </item>\n"; 138 } 139 $html .= " 92 140 </channel> 93 141 </rss>"; 142 143 if ($_GET['gz']) 144 { 145 echo gzdeflate($html, 9); 146 } 147 else 148 { 149 echo $html; 150 } 151 ?> 94 152 95 if ($_GET['compress'] == '1')96 {97 echo gzdeflate($html);98 }99 else100 {101 echo $html;102 }103 ?> -
dev/mods/feed_syndication/feed_fetcher.php
r150 r152 1 1 <?php 2 ////// 3 ////// ////// 4 ////// liq's feed syndication mod v1.3 5 //////////// 6 //////////// 7 //////////// 8 //////////// 9 2 10 3 // liq's feed syndication mod v1.2 4 5 @set_time_limit(0); 6 require_once( "class.kill.php" ); 7 require_once( "class.parser.php" ); 8 if ( file_exists("../../common/class.comments.php") ) // for the Eve-Dev Comment Class 11 @set_time_limit(0); 12 require_once( "common/class.kill.php" ); 13 require_once( "common/class.parser.php" ); 14 if ( file_exists("../../common/class.comments.php") ) // for the Eve-Dev Comment Class 9 15 require_once( "class.comments.php" ); 10 16 if ( file_exists("../../common/class.comment.php") ) // for the D2 Killboard Comment Class 11 17 require_once( "class.comment.php" ); 12 18 … … 53 59 class Fetcher { 54 60 55 function grab($url ) {56 global $x, $ fetchurl;61 function grab($url, $str) { 62 global $x, $uurl; 57 63 $x=0; 58 $fetchurl = $url; 64 $fetchurl = $url.$str; 65 $uurl = $url; 59 66 $xml_parser = xml_parser_create(); 60 67 xml_set_object ( $xml_parser, $this ); 61 68 xml_set_element_handler($xml_parser, "startElement", "endElement"); 62 69 xml_set_character_data_handler ( $xml_parser, 'characterData' ); 63 $fp = @fopen($url,"r"); 64 while ($data = @fread($fp, 4096)) { 65 if (!xml_parse( $xml_parser, $data, feof($fp) ) && !feof($fp) ) 66 return "<i>Error getting XML data from ".$url."</i><br><br>"; 70 $fp = @fopen($fetchurl,"r"); 71 while ($chunk = @fread($fp, 4096)) { 72 $data .= $chunk; 67 73 } 74 $data = preg_replace('<<!--.*?-->>', '', $data); // remove <!-- Cached --> message, else it will break gzinflate 75 76 if (!@gzinflate($data)) { 77 $cprs = "raw HTML stream"; 78 } else { 79 $data = gzinflate($data); 80 $cprs = "GZip compressed stream"; 81 } 82 83 if (!xml_parse( $xml_parser, $data, feof($fp) ) && !feof($fp) ) 84 return "<i>Error getting XML data from ".$url."</i><br><br>"; 85 68 86 @fclose($fp); 69 87 xml_parser_free($xml_parser); 88 70 89 if ($x) 71 $html = "<div class=block-header2>".$x." kills added from feed: ".$url."</div>";90 $html .= "<div class=block-header2>".$x." kills added from feed: ".$url." <i>(".$cprs.")</i></div>"; 72 91 else 73 $html = "<div class=block-header2>No kills added from feed: ".$url."</div>"; 92 $html .= "<div class=block-header2>No kills added from feed: ".$url." <i>(".$cprs.")</i></div>"; 93 //echo "url:".$url." --- "; 94 //echo " strg:".$str; 95 74 96 return $html; 75 97 } … … 84 106 85 107 function endElement($parser, $name) { 86 global $insideitem, $tag, $title, $description, $link, $html, $x, $ fetchurl;108 global $insideitem, $tag, $title, $description, $link, $html, $x, $uurl; 87 109 88 110 if ($name == "ITEM") { … … 105 127 if (class_exists('Comments') && getConfig('fetch_comment')) { // for the Eve-Dev Comment Class 106 128 $comments = new Comments($killid); 107 $comments->addComment("liq's feed syndication", getConfig('fetch_comment')." (mail fetched from: ".$fetchurl.")");129 $comments->addComment("liq's feed syndication", getConfig('fetch_comment')." mail fetched from: ".$uurl.")"); 108 130 } 109 131 if (class_exists('Comment') && getConfig('fetch_comment')) { // for the D2 Killboard Comment Class 110 132 $comment = new Comment($killid); 111 $comment->postComment(getConfig('fetch_comment')." \n\n <i>(mail fetched from:\n ".$fetchurl.")</i>", "liquidism");133 $comment->postComment(getConfig('fetch_comment')." \n\n\n <i>mail fetched from:\n ".$uurl."</i>", "liquidism"); 112 134 } 113 135 $x++; -
dev/mods/feed_syndication/readme.txt
r148 r152 1 2 // liq's feed syndication mod v1.1 1 ////// 2 ////// ////// 3 ////// liq's feed syndication mod v1.3 4 //////////// 5 //////////// 6 //////////// 7 //////////// 3 8 4 9 5 10 6 // installation:11 //INSTALLATION: 7 12 8 1. put all the files in your /common directory. 13 1. create directory mods/feed 14 2. put the files settings.php and feed_fetcher.php in /mods/feed_syndication directory. 15 3. put feed.php in your /common directory 16 3. login as admin and enable the feed-mod in 'Mods' 17 4. wee. youre done. 9 18 10 2. add the following line to admin_menu.php:11 $menubox->addOption( "Feeds", "?a= admin_feed" );12 13 3. youre done. 19 additionally you can add the following line to common/admin_menu.php for direct access: 20 $menubox->addOption( "Feeds", "?a=settings_feed_syndication" ); 21 or if you use eve-dev kilboard version 1.2.0 and above (using smarty templates): 22 $menubox->addOption("link", "Feeds", "?a=settings_feed_syndication"); 14 23 15 24 16 //files 25 26 //FILES: 17 27 18 28 feed.php <- prints out all kills of the actual week in rss format. … … 23 33 24 34 25 //notes26 35 27 -> enter feed urls in the format 'http://killboard.eve-d2.com/?a=feed' into the admin interface. 28 click 'save' to save your changes before you 'fetch' new kills. 36 //NOTES: 37 38 -> enter feed urls in the format: http://killboard.eve-d2.com/?a=feed 39 40 -> a list of known feeds can be found here: http://www.eve-dev.net/e107_plugins/forum/forum_viewtopic.php?1896 29 41 30 42 -> clicking the 'fetch' button will get all kills of the actual week. 31 43 32 -> ticking the 'grab-ALL-mails-box' will grab ALL kills! be careful with this option! 33 ** it can take several minutes or even hours to have all the kills parsed and added to your database ** 34 ** be patient. don't close your browser, don't reload. you only need to use this ONCE in a lifetime ** 44 -> ticking the 'grab-ALL-mails-box' will grab the kills of ALL weeks (iteration from week #1 through to week #52)! 45 ** be careful with this option! it can take several minutes or even hours to have all the kills parsed and added to your database ** 46 ** be patient. don't close your browser, don't reload. you only need to use this ONCE to initialize a feed connection. 47 after initializing, weekly updates are totally sufficient to keep your board uptodate ** 48 49 -> by default their kills aka. your losses get fetched unless you tick the 'get kills' 50 option in which case their losses aka. your kills get fetched 51 52 -> GZip compression is enabled by default because the board automatically 53 checks and decides if a fetched stream supports GZip compression - if not it uses regular html/rss output. 54 55 -> if you are running a master killboard (eg. to supply and share killdata with other killboards) edit settings.php and set 'MASTER' to 1. 56 the board will then even fetch kills not related to the alliance or corp ID you set in the killboards config.php. 57 leave this option untouched if youre running a normal killboard for your corp or alliance - it will just slow things down. 58 59 -> the feed is not supposed to be human readable so ffs dont complain about the formatting, 60 for human readable rss output use the rss mod ( /?a=rss ) instead. 35 61 36 62 37 //changes 63 64 //VERSION CHANGES: 65 66 //v1.3 67 68 feed.php: 69 - added support for GZip compressed output 70 - minor code cleanups 71 72 feed_fetcher.php: 73 - converted to a mod 74 - added support for getting GZip compressed feeds and a fallback if the feed is uncompressed 75 - changed the text in auto-comment to only show the remote killboards url and not the 76 complete path with all passed variables, making it more readable 77 78 admin_feed.php / settings.php 79 - converted to a mod 80 - renamed to settings.php 81 - added option to fetch streams with Gzip compression - enabled by default 82 - added support for master killboards whose only purpose is to collect and share kill data, see notes 83 84 85 //v1.2 86 87 feed.php: 88 - added output of feed's version number 89 90 feed_fetcher.php: 91 - none 92 93 admin_feed.php 94 - rearranged options to be inline with other admin settings pages 95 - added checkboxes to enable / disable fetching specific feed urls 96 38 97 39 98 //v1.1 … … 50 109 - included calls to the killboards comment function so you can add predefined comments to autoparsed kills aka. "post your losses noob". 51 110 52 admin_feed.php 111 admin_feed.php: 53 112 - made the number of feeds user selectable 54 113 - more detailed descriptions … … 56 115 - option to automatically enter a comment with the autoparsed kill 57 116 - option to get kills instead of losses 117 - added backwards compatibility to exi's v1.0 mod 58 118 59 119 -
dev/mods/feed_syndication/settings.php
r148 r152 1 <? 1 <?php 2 ////// 3 ////// ////// 4 ////// liq's feed syndication mod v1.3 5 //////////// 6 //////////// 7 //////////// 8 //////////// 2 9 3 // liq's feed syndication mod v1.2 10 11 // set this to 1 if you are running a master killboard and want 12 // to even fetch mails not related to your corp / alliance 13 define( MASTER, 0 ); 14 15 4 16 5 17 @set_time_limit(0); 18 require_once( "feed_fetcher.php" ); 6 19 require_once( "common/class.page.php" ); 7 20 require_once( "common/admin_menu.php" ); 8 require_once( "common/feed_fetcher.php" );9 21 require_once( 'common/class.corp.php' ); 10 22 require_once( 'common/class.alliance.php' ); … … 35 47 else 36 48 setConfig('fetch_verbose', '0'); 49 50 if ( $_POST['fetch_compress'] ) 51 setConfig('fetch_compress', '0'); 52 else 53 setConfig('fetch_compress', '1'); 37 54 38 55 if ( $_POST['fetch_comment'] ) … … 61 78 62 79 if ( $_POST['fetch'] ) { 63 if (CORP_ID ) {64 80 if (CORP_ID && !MASTER) { 81 $corp = new Corporation(CORP_ID); 65 82 $myid = '&corp='.urlencode($corp->getName()); 66 83 } 67 if (ALLIANCE_ID ) {84 if (ALLIANCE_ID && !MASTER) { 68 85 $alli = new Alliance(ALLIANCE_ID); 69 86 $myid = '&alli='.urlencode($alli->getName()); 70 87 } 71 88 72 89 for ($i=1; $i<=$feedcount; $i++) { … … 79 96 if ( $_POST['fetch_losses'] ) 80 97 $str .= "&losses=1"; 98 if ( !getConfig('fetch_compress') ) 99 $str .= "&gz=1"; 81 100 if ( $_POST['graball'] ) { 82 101 for ($l = 1; $l<=52; $l++) { 83 102 $html .= "<b>Week: ". $l ."</b><br>"; 84 $html .= $feedfetch->grab( $feed[$i]. $myid.$str."&week=".$l);103 $html .= $feedfetch->grab( $feed[$i]."&week=".$l, $myid.$str ); 85 104 } 86 105 } else 87 $html .= $feedfetch->grab( $feed[$i] .$myid.$str );106 $html .= $feedfetch->grab( $feed[$i], $myid.$str ); 88 107 } 89 108 … … 93 112 } 94 113 95 $html .= "<form id=options name=options method=post action=?a= admin_feed>";114 $html .= "<form id=options name=options method=post action=?a=settings_feed>"; 96 115 $html .= "</table>"; 97 116 … … 133 152 $html .= "\"><br><i> (leave blank for none)</i><br></td></tr>"; 134 153 154 $html .= "<tr><td height=30px width=150px><b>Enable compression?</b></td>"; 155 $html .= "<td><input type=checkbox name=fetch_compress id=fetch_compress"; 156 if ( !getConfig('fetch_compress') ) 157 $html .= " checked=\"checked\""; 158 $html .= "><i> (enables GZip compression for feeds that support this feature, for streams that do not support GZip compression regular html mode will be used automatically)</i></td>"; 159 $html .= "</tr>"; 160 135 161 $html .= "<tr><td height=30px width=150px><b>Verbose mode?</b></td>"; 136 162 $html .= "<td><input type=checkbox name=fetch_verbose id=fetch_verbose"; 137 163 if ( getConfig('fetch_verbose') ) 138 164 $html .= " checked=\"checked\""; 139 $html .= "><i> (displays errormessages when the imported mail is malformed, already exists, is notrelated etc.)</i></td>";165 $html .= "><i> (displays errormessages when the imported mail is rejected for being malformed, already existing, not being related etc.)</i></td>"; 140 166 $html .= "</tr></table><br><br>"; 141 167