1 | <?php |
---|
2 | ////// |
---|
3 | ////// ////// |
---|
4 | ////// liq's feed syndication mod v1.3 |
---|
5 | //////////// |
---|
6 | //////////// |
---|
7 | //////////// |
---|
8 | //////////// |
---|
9 | |
---|
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 | |
---|
16 | |
---|
17 | @set_time_limit(0); |
---|
18 | require_once( "feed_fetcher.php" ); |
---|
19 | require_once( "common/class.page.php" ); |
---|
20 | require_once( "common/admin_menu.php" ); |
---|
21 | require_once( 'common/class.corp.php' ); |
---|
22 | require_once( 'common/class.alliance.php' ); |
---|
23 | |
---|
24 | $page = new Page( "Administration - Feeds" ); |
---|
25 | $page->setAdmin(); |
---|
26 | |
---|
27 | $validurl = "/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}((:[0-9]{1,5})?\/.*)?$/i"; |
---|
28 | $html .= "<table class=kb-subtable>"; |
---|
29 | |
---|
30 | if (getConfig('fetch_feed_count')) |
---|
31 | $feedcount = getConfig('fetch_feed_count'); |
---|
32 | else |
---|
33 | $feedcount = 3; |
---|
34 | |
---|
35 | |
---|
36 | if ( $_POST['submit'] || $_POST['fetch'] ) { |
---|
37 | if ( ctype_digit($_POST['fetch_feed_count']) ) { |
---|
38 | setConfig('fetch_feed_count', $_POST['fetch_feed_count']); |
---|
39 | $feedcount = $_POST['fetch_feed_count']; |
---|
40 | for ($i = 99; $i>=$feedcount; $i--) { |
---|
41 | delConfig('fetch_url_'.$i); |
---|
42 | } |
---|
43 | } |
---|
44 | |
---|
45 | if ( $_POST['fetch_verbose'] ) |
---|
46 | setConfig('fetch_verbose', '1'); |
---|
47 | else |
---|
48 | setConfig('fetch_verbose', '0'); |
---|
49 | |
---|
50 | if ( $_POST['fetch_compress'] ) |
---|
51 | setConfig('fetch_compress', '0'); |
---|
52 | else |
---|
53 | setConfig('fetch_compress', '1'); |
---|
54 | |
---|
55 | if ( $_POST['fetch_comment'] ) |
---|
56 | setConfig('fetch_comment', $_POST['fetch_comment']); |
---|
57 | else |
---|
58 | setConfig('fetch_comment', ''); |
---|
59 | |
---|
60 | for ($i = 1; $i<=$feedcount; $i++) { |
---|
61 | $url = "fetch_url_".$i; |
---|
62 | if ( preg_match($validurl ,$_POST[$url]) ) { |
---|
63 | setConfig($url, $_POST[$url].':::'.$time[$i]); |
---|
64 | $feed[$i] = $_POST[$url]; |
---|
65 | } else |
---|
66 | setConfig($url, ''); |
---|
67 | $feed[$i] = ''; |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | $feed = array(); |
---|
72 | for ($i = 1; $i<=$feedcount; $i++) { |
---|
73 | $str = getConfig('fetch_url_'.$i); |
---|
74 | $tmp = explode(':::', $str); |
---|
75 | $feed[$i] = $tmp[0]; |
---|
76 | $time[$i] = $tmp[1]; |
---|
77 | } |
---|
78 | |
---|
79 | if ( $_POST['fetch'] ) { |
---|
80 | if (CORP_ID && !MASTER) { |
---|
81 | $corp = new Corporation(CORP_ID); |
---|
82 | $myid = '&corp='.urlencode($corp->getName()); |
---|
83 | } |
---|
84 | if (ALLIANCE_ID && !MASTER) { |
---|
85 | $alli = new Alliance(ALLIANCE_ID); |
---|
86 | $myid = '&alli='.urlencode($alli->getName()); |
---|
87 | } |
---|
88 | |
---|
89 | for ($i=1; $i<=$feedcount; $i++) { |
---|
90 | $feedfetch = new Fetcher(); |
---|
91 | $cfg = "fetch_url_".$i; |
---|
92 | if (preg_match($validurl , $feed[$i]) && $_POST["fetch_feed_".$i]) { |
---|
93 | $str = ''; |
---|
94 | if ($time[$i]) |
---|
95 | $str .= '&lastkllid='.$time[$i]; |
---|
96 | if ( $_POST['fetch_losses'] ) |
---|
97 | $str .= "&losses=1"; |
---|
98 | if ( !getConfig('fetch_compress') ) |
---|
99 | $str .= "&gz=1"; |
---|
100 | if ( $_POST['graball'] ) { |
---|
101 | for ($l = 1; $l<=52; $l++) { |
---|
102 | $html .= "<b>Week: ". $l ."</b><br>"; |
---|
103 | $html .= $feedfetch->grab( $feed[$i]."&week=".$l, $myid.$str ); |
---|
104 | } |
---|
105 | } else |
---|
106 | $html .= $feedfetch->grab( $feed[$i], $myid.$str ); |
---|
107 | } |
---|
108 | |
---|
109 | setConfig($cfg, $feed[$i].':::'.$lastkllid); |
---|
110 | $time[$i] = $lastkllid; |
---|
111 | } |
---|
112 | } |
---|
113 | |
---|
114 | $html .= "<form id=options name=options method=post action=?a=settings_feed>"; |
---|
115 | $html .= "</table>"; |
---|
116 | |
---|
117 | $html .= "<div class=block-header2>Feeds</div><table>"; |
---|
118 | |
---|
119 | for ($i = 1; $i<=$feedcount; $i++) { |
---|
120 | $html .= "<tr><td width=85px><b>Feed url #".$i."</b></td><td><input type=text name=fetch_url_".$i." size=50 class=password value=\""; |
---|
121 | if ( $feed[$i] ) |
---|
122 | $html .= $feed[$i]; |
---|
123 | $html .= "\"> "; |
---|
124 | $html .= "<input type=checkbox name=fetch_feed_".$i." id=fetch_feed_".$i; |
---|
125 | if ( $feed[$i] ) |
---|
126 | $html .= " checked=\"checked\""; |
---|
127 | $html .= "><b>Fetch?</b><br>"; |
---|
128 | $html .= "</td></tr>"; |
---|
129 | } |
---|
130 | |
---|
131 | $html .= "</table><i>Example: http://killboard.eve-d2.com/?a=feed</i><br><br><br>"; |
---|
132 | |
---|
133 | $html .= "<table><tr><td height=30px width=150px><b>Get kills instead of losses?</b></td>"; |
---|
134 | $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 | |
---|
142 | $html .= "<input type=submit id=submit name=fetch value=\"Fetch!\"><br><br>"; |
---|
143 | |
---|
144 | $html .= "<div class=block-header2>Options</div><table>"; |
---|
145 | $html .= "<tr><td height=30px width=150px><b>Number of feeds:</b></td>"; |
---|
146 | $html .= "<td><input type=text name=fetch_feed_count size=2 maxlength=2 class=password value=\"".$feedcount."\"</td></tr>"; |
---|
147 | |
---|
148 | $html .= "<tr><td height=50px width=150px><b>Comment for automatically parsed killmails?</b></td>"; |
---|
149 | $html .= "<td><input type=text size=50 class=password name=fetch_comment id=fetch_comment value=\""; |
---|
150 | if ( getConfig('fetch_comment') ) |
---|
151 | $html .= getConfig('fetch_comment'); |
---|
152 | $html .= "\"><br><i> (leave blank for none)</i><br></td></tr>"; |
---|
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 | |
---|
161 | $html .= "<tr><td height=30px width=150px><b>Verbose mode?</b></td>"; |
---|
162 | $html .= "<td><input type=checkbox name=fetch_verbose id=fetch_verbose"; |
---|
163 | if ( getConfig('fetch_verbose') ) |
---|
164 | $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>"; |
---|
166 | $html .= "</tr></table><br><br>"; |
---|
167 | |
---|
168 | $html .= "<input type=submit id=submit name=submit value=\"Save\">"; |
---|
169 | $html .= "</form>"; |
---|
170 | |
---|
171 | $page->addContext( $menubox->generate() ); |
---|
172 | $page->setContent( $html ); |
---|
173 | $page->generate(); |
---|
174 | |
---|
175 | ?> |
---|