Changeset 170
- Timestamp:
- 01/06/07 16:35:16 (16 years ago)
- Location:
- dev
- Files:
-
- 1 added
- 1 removed
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/feed.php
r154 r170 1 1 <?php 2 // liq's feed syndication mod v1.3 2 ////// 3 ////// ////// 4 ////// liq's feed syndication mod v1.4 5 //////////// 6 //////////// 7 //////////// 8 //////////// 9 3 10 4 11 @set_time_limit(0); … … 7 14 require_once("class.killlist.php"); 8 15 require_once("class.kill.php"); 16 require_once("db.php"); 17 require_once("globals.php"); 9 18 10 $html .= "<rss version=\"2.0\"> 11 <channel> 12 <title>".KB_TITLE."</title> 13 <description>Kill Feed v1.3</description> 14 <link>".KB_HOST."</link> 15 <copyright>".KB_TITLE."</copyright>\n"; 19 $html .= "<rss version=\"2.0\"> 20 <channel> 21 <title>" . KB_TITLE . "</title> 22 <link>http://" . KB_HOST . "</link> 23 <description>Kill Feed v1.4</description> 24 <copyright>" . KB_TITLE . "</copyright>\n"; 25 26 $klist = new KillList(); 27 $klist->setPodsNoobShips(true); 28 29 if ($_GET['week']) 30 { 31 $klist->setWeek($_GET['week']); 32 } 33 elseif (!$_GET['lastkllid']) 34 { 35 $klist->setWeek(date("W")); 36 } 37 38 if ($_GET['year']) 39 { 40 $klist->setYear($_GET['year']); 41 } 42 elseif (!$_GET['lastkllid']) 43 { 44 $klist->setYear(date("Y")); 45 } 46 47 if ($_GET['lastkllid'] && method_exists($klist, 'setMinKllID')) 48 { 49 $klist->setMinKllID($_GET['lastkllid']); 50 } 51 52 if ($_GET['corp'] || $_GET['corp_name']) 53 { 54 if ($_GET['corp']) 55 { 56 $c = $_GET['corp']; 57 } 58 if ($_GET['corp_name']) 59 { 60 $c = $_GET['corp_name']; 61 } 62 $corp = new Corporation(); 63 $corp->lookup(urldecode($c)); 64 } 65 66 if ($_GET['alli'] || $_GET['alliance_name']) 67 { 68 if ($_GET['alli']) 69 { 70 $a = $_GET['alli']; 71 } 72 if ($_GET['alliance_name']) 73 { 74 $a = $_GET['alliance_name']; 75 } 76 $alli = new Alliance(); 77 $alli->add(urldecode($a)); 78 } 79 80 if ($_GET['losses']) 81 { 82 if (CORP_ID) //local 83 { 84 $klist->addVictimCorp(new Corporation(CORP_ID)); 85 } 86 if (ALLIANCE_ID) //local 87 { 88 $klist->addVictimAlliance(new Alliance(ALLIANCE_ID)); 89 } 90 if ($corp && !$_GET['friend']) //remote 91 { 92 $klist->addInvolvedCorp($corp); 93 } 94 if ($alli && !$_GET['friend']) //remote 95 { 96 $klist->addInvolvedAlliance($alli); 97 } 98 } 99 else 100 { 101 if (CORP_ID) //local 102 { 103 $klist->addInvolvedCorp(new Corporation(CORP_ID)); 104 } 105 if (ALLIANCE_ID) //local 106 { 107 $klist->addInvolvedAlliance(new Alliance(ALLIANCE_ID)); 108 } 109 if ($corp && !$_GET['friend']) //remote 110 { 111 $klist->addVictimCorp($corp); 112 } 113 if ($alli && !$_GET['friend']) //remote 114 { 115 $klist->addVictimAlliance($alli); 116 } 117 } 118 119 $kills = array(); 120 while ($kill = $klist->getKill()) 121 { 122 $kills[$kill->getID()] = $kill->getTimestamp(); 123 } 124 asort($kills); 125 126 foreach ($kills as $id => $timestamp) 127 { 128 $kill = new Kill($id); 129 $html .= "<item> 130 <title>" . $id . "</title> 131 <description><![CDATA[ " . $kill->getRawMail() . " ]]></description> 132 <guid>?a=kill_detail&kll_id=" . $id . "</guid> 133 <pubDate>" . strftime("%a, %d %b %Y %T %Z", strtotime($timestamp)) . "</pubDate> 134 </item>\n"; 135 } 136 137 $html .= "</channel></rss>"; 138 139 if ($_GET['gz']) 140 { 141 echo gzdeflate($html, 9); 142 } 143 else 144 { 145 echo $html; 146 } 147 ?> 16 148 17 $klist = new KillList();18 $klist->setPodsNoobShips(true);19 20 if ($_GET['week'])21 {22 $klist->setWeek($_GET['week']);23 }24 elseif (!$_GET['lastkllid'])25 {26 $klist->setWeek(date("W"));27 }28 if ($_GET['lastkllid'])29 {30 if (method_exists($klist, 'setMinKllID'))31 {32 $klist->setMinKllID($_GET['lastkllid']);33 }34 }35 36 if ($_GET['corp'] || $_GET['corp_name'])37 {38 if ($_GET['corp'])39 {40 $c = $_GET['corp'];41 }42 if ($_GET['corp_name'])43 {44 $c = $_GET['corp_name'];45 }46 $corp = new Corporation();47 $corp->lookup(urldecode($c));48 }49 50 if ($_GET['alli'] || $_GET['alliance_name'])51 {52 if ($_GET['alli'])53 {54 $a = $_GET['alli'];55 }56 if ($_GET['alliance_name'])57 {58 $a = $_GET['alliance_name'];59 }60 $alli = new Alliance();61 $alli->add(urldecode($a));62 }63 64 if ($_GET['week'])65 {66 $klist->setWeek($_GET['week']);67 }68 elseif (!$_GET['lastkllid'])69 {70 $klist->setWeek(date("W"));71 }72 73 if ($_GET['losses'])74 {75 if (CORP_ID)76 {77 $klist->addVictimCorp(new Corporation(CORP_ID));78 }79 if (ALLIANCE_ID)80 {81 $klist->addVictimAlliance(new Alliance(ALLIANCE_ID));82 }83 if ($corp)84 {85 $klist->addInvolvedCorp($corp);86 }87 if ($alli)88 {89 $klist->addInvolvedAlliance($alli);90 }91 }92 else93 {94 if (CORP_ID)95 {96 $klist->addInvolvedCorp(new Corporation(CORP_ID));97 }98 if (ALLIANCE_ID)99 {100 $klist->addInvolvedAlliance(new Alliance(ALLIANCE_ID));101 }102 if ($corp)103 {104 $klist->addVictimCorp($corp);105 }106 if ($alli)107 {108 $klist->addVictimAlliance($alli);109 }110 }111 112 $kills = array();113 while ($kill = $klist->getKill())114 {115 $kills[$kill->getID()] = $kill->getTimestamp();116 }117 asort($kills);118 119 foreach ($kills as $id => $timestamp)120 {121 $kill = new Kill($id);122 $html .= "<item>123 <title>".$id."</title>124 <description> <![CDATA[ ".$kill->getRawMail()." ]]> </description>125 <guid>?a=kill_detail&kll_id=".$id."</guid>126 <pubDate>".strftime("%a, %d %b %Y %T %Z", strtotime($timestamp))."</pubDate>127 </item>\n";128 }129 $html .= "</channel>130 </rss>";131 132 if ($_GET['gz'] || $_GET['compress'] == 1)133 {134 echo gzdeflate($html, 9);135 }136 else137 {138 echo $html;139 }140 ?> -
dev/mods/feed_syndication/feed_fetcher.php
r152 r170 2 2 ////// 3 3 ////// ////// 4 ////// liq's feed syndication mod v1. 34 ////// liq's feed syndication mod v1.4 5 5 //////////// 6 6 //////////// … … 10 10 11 11 @set_time_limit(0); 12 @ini_set('memory_limit',999999999); 13 12 14 require_once( "common/class.kill.php" ); 13 15 require_once( "common/class.parser.php" ); 14 16 if ( file_exists("../../common/class.comments.php") ) // for the Eve-Dev Comment Class 15 require_once( "c lass.comments.php" );17 require_once( "common/class.comments.php" ); 16 18 if ( file_exists("../../common/class.comment.php") ) // for the D2 Killboard Comment Class 17 require_once( "c lass.comment.php" );19 require_once( "common/class.comment.php" ); 18 20 19 21 $insideitem = false; … … 81 83 } 82 84 83 if (!xml_parse( $xml_parser, $data, feof($fp) ) && !feof($fp) )85 if (!xml_parse( $xml_parser, $data, @feof($fp) ) && !@feof($fp) ) 84 86 return "<i>Error getting XML data from ".$url."</i><br><br>"; 85 87 86 88 @fclose($fp); 87 89 xml_parser_free($xml_parser); 88 89 if ($x) 90 $html .= "<div class=block-header2>".$x." kills added from feed: ".$url." <i>(".$cprs.")</i></div>"; 91 else 92 $html .= "<div class=block-header2>No kills added from feed: ".$url." <i>(".$cprs.")</i></div>"; 93 //echo "url:".$url." --- "; 94 //echo " strg:".$str; 90 91 if ( getConfig('fetch_verbose') ) { 92 if ($x) 93 $html .= "<div class=block-header2>".$x." kills added from feed: ".$url."<br>".$str." <i><br>(".$cprs.")</i><br><br></div>"; 94 else 95 $html .= "<div class=block-header2>No kills added from feed: ".$url."<br>".$str." <i><br>(".$cprs.")</i><br><br></div>"; 96 } else { 97 if ($x) 98 $html .= "<div class=block-header2>".$x." kills added from feed: ".$url." <i>(".$cprs.")</i><br><br></div>"; 99 else 100 $html .= "<div class=block-header2>No kills added from feed: ".$url." <i>(".$cprs.")</i><br><br></div>"; 101 } 95 102 96 103 return $html; … … 161 168 162 169 } 163 164 170 ?> -
dev/mods/feed_syndication/readme.txt
r152 r170 1 1 ////// 2 2 ////// ////// 3 ////// liq's feed syndication mod v1. 33 ////// liq's feed syndication mod v1.4 4 4 //////////// 5 5 //////////// … … 11 11 //INSTALLATION: 12 12 13 ### --> STANDALONE version: 14 1. put all files in your /common directory 15 16 2. add the following line to common/admin_menu.php: 17 $menubox->addOption( "Feeds", "?a=admin_feed" ); 18 or if you use eve-dev kilboard version 1.2.0 and above (using smarty templates): 19 $menubox->addOption("link", "Feeds", "?a=admin_feed"); 20 21 3. wee. youre done. 22 23 4. you can access the feed interface now via the menubox in admin menu 24 25 26 ### --> MOD version: 13 27 1. create directory mods/feed 28 14 29 2. put the files settings.php and feed_fetcher.php in /mods/feed_syndication directory. 30 15 31 3. put feed.php in your /common directory 32 16 33 3. login as admin and enable the feed-mod in 'Mods' 34 17 35 4. wee. youre done. 18 36 37 5. click 'Settings' in the 'Mods' menu to access the feed interface 38 19 39 additionally you can add the following line to common/admin_menu.php for direct access: 20 $menubox->addOption( "Feeds", "?a=settings_feed _syndication" );40 $menubox->addOption( "Feeds", "?a=settings_feed" ); 21 41 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");42 $menubox->addOption("link", "Feeds", "?a=settings_feed"); 23 43 24 44 … … 38 58 -> enter feed urls in the format: http://killboard.eve-d2.com/?a=feed 39 59 40 -> a list of known feeds can be found here: http:// www.eve-dev.net/e107_plugins/forum/forum_viewtopic.php?189660 -> a list of known feeds can be found here: http://myeve.eve-online.com/ingameboard.asp?a=topic&threadID=443506&page=1#2 41 61 42 -> clicking the 'fetch' button will get all kills of the actual week.62 -> your actual week is automatically selected in the first and last week boxes. 43 63 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 ** 64 -> clicking the 'fetch' button will by default get all kills of the actual week unless you select a different timeframe. 65 66 -> selecting a timeframe with the first and last week boxes lets the fetcher get all mails of this timeframe. 67 ** be careful with this option! it can take several minutes or even hours to have all 68 the kills parsed and added to your database, especially if you select a really long timeframe ** 69 ** be patient. don't close your browser, don't reload. after doing a full fetch first, weekly updates are totally sufficient to keep your board uptodate ** 70 48 71 49 72 -> by default their kills aka. your losses get fetched unless you tick the 'get kills' … … 53 76 checks and decides if a fetched stream supports GZip compression - if not it uses regular html/rss output. 54 77 78 55 79 -> 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 80 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. 81 leave this option untouched if youre running a normal killboard for your corp or alliance - it will just slow things down and 82 wont work for you without modifications to the parser class. 58 83 59 -> the feed is not supposed to be human readable so ffs dont complain about the formatting ,84 -> the feed is not supposed to be human readable so ffs dont complain about the formatting. 60 85 for human readable rss output use the rss mod ( /?a=rss ) instead. 61 86 … … 63 88 64 89 //VERSION CHANGES: 90 91 92 //v1.4 93 94 feed.php: 95 - added selection of the year to output 96 - added support for friend<->friend killboard fetching 97 - minor code cleanups 98 - other stuff i forgot 99 100 feed_fetcher.php: 101 - added a fix for the memory exhaustion bug some boards had (check if your php is running in php-safe-mode. if so, disable it) 102 - improved verbose output 103 104 admin_feed.php / settings.php 105 - replaced the grab-all switch with an advanced range selection system by week and year 106 - added support for friend<->friend killboard fetching 107 - minor code cleanups 108 - other stuff i forgot 109 65 110 66 111 //v1.3 -
dev/mods/feed_syndication/settings.php
r152 r170 2 2 ////// 3 3 ////// ////// 4 ////// liq's feed syndication mod v1. 34 ////// liq's feed syndication mod v1.4 5 5 //////////// 6 6 //////////// … … 12 12 // to even fetch mails not related to your corp / alliance 13 13 define( MASTER, 0 ); 14 15 16 14 17 15 @set_time_limit(0); … … 22 20 require_once( 'common/class.alliance.php' ); 23 21 24 $page = new Page( "Administration - Feed s" );22 $page = new Page( "Administration - Feed Syndication v1.4" ); 25 23 $page->setAdmin(); 26 24 … … 33 31 $feedcount = 3; 34 32 35 36 33 if ( $_POST['submit'] || $_POST['fetch'] ) { 37 if ( ctype_digit($_POST['fetch_feed_count']) ) { 38 setConfig('fetch_feed_count', $_POST['fetch_feed_count']); 34 if ( ctype_digit($_POST['fetch_feed_count']) && $_POST['fetch_feed_count'] > 0) { 39 35 $feedcount = $_POST['fetch_feed_count']; 36 setConfig('fetch_feed_count', $feedcount); 40 37 for ($i = 99; $i>=$feedcount; $i--) { 41 38 delConfig('fetch_url_'.$i); 42 39 } 43 40 } 44 45 41 if ( $_POST['fetch_verbose'] ) 46 42 setConfig('fetch_verbose', '1'); … … 60 56 for ($i = 1; $i<=$feedcount; $i++) { 61 57 $url = "fetch_url_".$i; 58 $friends = $_POST["friend_".$i]; 62 59 if ( preg_match($validurl ,$_POST[$url]) ) { 63 setConfig($url, $_POST[$url].':::'.$time[$i] );60 setConfig($url, $_POST[$url].':::'.$time[$i].':::'.$friends); 64 61 $feed[$i] = $_POST[$url]; 65 62 } else … … 68 65 } 69 66 } 70 71 67 $feed = array(); 72 68 for ($i = 1; $i<=$feedcount; $i++) { … … 75 71 $feed[$i] = $tmp[0]; 76 72 $time[$i] = $tmp[1]; 73 $friend[$i] = $tmp[2]; 77 74 } 78 79 75 if ( $_POST['fetch'] ) { 80 76 if (CORP_ID && !MASTER) { … … 85 81 $alli = new Alliance(ALLIANCE_ID); 86 82 $myid = '&alli='.urlencode($alli->getName()); 87 } 88 83 } 89 84 for ($i=1; $i<=$feedcount; $i++) { 90 85 $feedfetch = new Fetcher(); … … 92 87 if (preg_match($validurl , $feed[$i]) && $_POST["fetch_feed_".$i]) { 93 88 $str = ''; 94 if ($time[$i]) 95 $str .= '&lastkllid='.$time[$i]; 89 //if ($time[$i]) 90 // $str .= '&lastkllid='.$time[$i]; 91 if ($friend[$i]) 92 $str .= '&friend=1'; 96 93 if ( $_POST['fetch_losses'] ) 97 94 $str .= "&losses=1"; 98 95 if ( !getConfig('fetch_compress') ) 99 96 $str .= "&gz=1"; 100 if ( $_POST['graball'] ) { 101 for ($l = 1; $l<=52; $l++) { 97 if ( $_POST['range1'] && $_POST['range2'] ) { 98 if ( $_POST['range1'] > $_POST['range2'] ) { 99 $range1 = $_POST['range2']; 100 $range2 = $_POST['range1']; 101 } else { 102 $range1 = $_POST['range1']; 103 $range2 = $_POST['range2']; 104 } 105 for ($l = $range1; $l<=$range2; $l++) { 102 106 $html .= "<b>Week: ". $l ."</b><br>"; 103 $html .= $feedfetch->grab( $feed[$i]."& week=".$l, $myid.$str );107 $html .= $feedfetch->grab( $feed[$i]."&year=".$_POST['year']."&week=".$l, $myid.$str ); 104 108 } 105 109 } else 106 110 $html .= $feedfetch->grab( $feed[$i], $myid.$str ); 107 111 } 108 109 setConfig($cfg, $feed[$i].':::'.$lastkllid); 112 setConfig($cfg, $feed[$i].':::'.$lastkllid.':::'.$friend); 110 113 $time[$i] = $lastkllid; 111 114 } 112 115 } 113 116 114 $html .= "<form id=options name=options method=post action=?a=settings_feed >";117 $html .= "<form id=options name=options method=post action=?a=settings_feed_syndication>"; 115 118 $html .= "</table>"; 116 119 117 120 $html .= "<div class=block-header2>Feeds</div><table>"; 118 119 121 for ($i = 1; $i<=$feedcount; $i++) { 120 122 $html .= "<tr><td width=85px><b>Feed url #".$i."</b></td><td><input type=text name=fetch_url_".$i." size=50 class=password value=\""; … … 122 124 $html .= $feed[$i]; 123 125 $html .= "\"> "; 126 $html .= "<input type=checkbox name=friend_".$i." id=friend_".$i; 127 if ( $friend[$i] ) 128 $html .= " checked=\"checked\""; 129 $html .= "><b>Friend?</b>"; 124 130 $html .= "<input type=checkbox name=fetch_feed_".$i." id=fetch_feed_".$i; 125 131 if ( $feed[$i] ) … … 128 134 $html .= "</td></tr>"; 129 135 } 130 131 136 $html .= "</table><i>Example: http://killboard.eve-d2.com/?a=feed</i><br><br><br>"; 132 137 133 $html .= "<table><tr><td height=30px width=150px><b>Get kills instead of losses?</b></td>"; 138 $html .= "<table><tr><td height=20px width=150px><b>First week:</b></td>"; 139 $html .= '<td><select name="range1">'; 140 $now = date("W"); 141 for ($i = 1; $i<=52; $i++) { 142 if ( $now == $i ) 143 $html .= '<option selected="selected "value="'.$i.'">'.$i.'</option>'; 144 else 145 $html .= '<option value="'.$i.'">'.$i.'</option>'; 146 } 147 $html .= '</select>'; 148 $html .= "<i></i></td></tr>"; 149 $html .= "<tr><td height=20px width=150px><b>Last week:</b></td>"; 150 $html .= '<td><select name="range2">'; 151 for ($i = 52; $i>=1; $i--) { 152 if ( $now == $i ) 153 $html .= '<option selected="selected "value="'.$i.'">'.$i.'</option>'; 154 else 155 $html .= '<option value="'.$i.'">'.$i.'</option>'; 156 } 157 $html .= '</select>'; 158 $html .= "<i></i></td></tr>"; 159 160 $html .= "<tr><td height=20px width=150px><b>Year:</b></td>"; 161 $html .= '<td><select name="year">'; 162 $html .= '<option "value="2009">2009</option>'; 163 $html .= '<option "value="2008">2008</option>'; 164 $html .= '<option selected="selected "value="">2007</option>'; 165 $html .= '<option "value="2006">2006</option>'; 166 $html .= '<option "value="2005">2005</option>'; 167 $html .= '</select>'; 168 $html .= "</td></tr>"; 169 $html .= "<tr><td height=40px width=150px><b>Get kills instead of losses?</b></td>"; 134 170 $html .= "<td><input type=checkbox name=fetch_losses id=fetch_losses>"; 135 $html .= "<i> (by default only your losses get fetched, when ticked all kills where one of your pilots is involved get fetched instead)</i></td></tr>"; 136 137 $html .= "<tr><td height=30px width=150px><b>Grab ALL mails from the feed servers?</b></td>"; 138 $html .= "<td><input type=checkbox name=graball id=graball>"; 139 $html .= "<i> (fetches all mails from the feed servers! use this may take upto several hours depending on the amount of kills to import!)</i></td>"; 140 $html .= "</tr></table><br><br>"; 141 171 $html .= "<i> (by default only their kills, your losses, get fetched, when ticked this is inversed)</i></td></tr>"; 172 $html .= "</table><br><br>"; 142 173 $html .= "<input type=submit id=submit name=fetch value=\"Fetch!\"><br><br>"; 143 174 … … 145 176 $html .= "<tr><td height=30px width=150px><b>Number of feeds:</b></td>"; 146 177 $html .= "<td><input type=text name=fetch_feed_count size=2 maxlength=2 class=password value=\"".$feedcount."\"</td></tr>"; 147 148 178 $html .= "<tr><td height=50px width=150px><b>Comment for automatically parsed killmails?</b></td>"; 149 179 $html .= "<td><input type=text size=50 class=password name=fetch_comment id=fetch_comment value=\""; … … 151 181 $html .= getConfig('fetch_comment'); 152 182 $html .= "\"><br><i> (leave blank for none)</i><br></td></tr>"; 153 154 183 $html .= "<tr><td height=30px width=150px><b>Enable compression?</b></td>"; 155 184 $html .= "<td><input type=checkbox name=fetch_compress id=fetch_compress"; … … 158 187 $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 188 $html .= "</tr>"; 160 161 189 $html .= "<tr><td height=30px width=150px><b>Verbose mode?</b></td>"; 162 190 $html .= "<td><input type=checkbox name=fetch_verbose id=fetch_verbose"; 163 191 if ( getConfig('fetch_verbose') ) 164 192 $html .= " checked=\"checked\""; 165 $html .= "><i> (displays errormessages when the imported mail is rejected for being malformed, already existing, not being related etc.)</i></td>";193 $html .= "><i> (displays advanced feed request information and errormessages when the imported mail is rejected for being malformed, already exists or is not related to your corp or alliance)</i></td>"; 166 194 $html .= "</tr></table><br><br>"; 167 168 195 $html .= "<input type=submit id=submit name=submit value=\"Save\">"; 169 196 $html .= "</form>"; … … 172 199 $page->setContent( $html ); 173 200 $page->generate(); 174 175 201 ?>