1 | <?php |
---|
2 | ////// |
---|
3 | ////// ////// |
---|
4 | ////// liq's feed syndication mod v1.4 |
---|
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 | @set_time_limit(0); |
---|
16 | require_once( "feed_fetcher.php" ); |
---|
17 | require_once( "common/class.page.php" ); |
---|
18 | require_once( "common/admin_menu.php" ); |
---|
19 | require_once( 'common/class.corp.php' ); |
---|
20 | require_once( 'common/class.alliance.php' ); |
---|
21 | |
---|
22 | $page = new Page( "Administration - Feed Syndication v1.4" ); |
---|
23 | $page->setAdmin(); |
---|
24 | |
---|
25 | $validurl = "/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}((:[0-9]{1,5})?\/.*)?$/i"; |
---|
26 | $html .= "<table class=kb-subtable>"; |
---|
27 | |
---|
28 | if (getConfig('fetch_feed_count')) |
---|
29 | $feedcount = getConfig('fetch_feed_count'); |
---|
30 | else |
---|
31 | $feedcount = 3; |
---|
32 | |
---|
33 | if ( $_POST['submit'] || $_POST['fetch'] ) { |
---|
34 | if ( ctype_digit($_POST['fetch_feed_count']) && $_POST['fetch_feed_count'] > 0) { |
---|
35 | $feedcount = $_POST['fetch_feed_count']; |
---|
36 | setConfig('fetch_feed_count', $feedcount); |
---|
37 | for ($i = 99; $i>=$feedcount; $i--) { |
---|
38 | delConfig('fetch_url_'.$i); |
---|
39 | } |
---|
40 | } |
---|
41 | if ( $_POST['fetch_verbose'] ) |
---|
42 | setConfig('fetch_verbose', '1'); |
---|
43 | else |
---|
44 | setConfig('fetch_verbose', '0'); |
---|
45 | |
---|
46 | if ( $_POST['fetch_compress'] ) |
---|
47 | setConfig('fetch_compress', '0'); |
---|
48 | else |
---|
49 | setConfig('fetch_compress', '1'); |
---|
50 | |
---|
51 | if ( $_POST['fetch_comment'] ) |
---|
52 | setConfig('fetch_comment', $_POST['fetch_comment']); |
---|
53 | else |
---|
54 | setConfig('fetch_comment', ''); |
---|
55 | |
---|
56 | for ($i = 1; $i<=$feedcount; $i++) { |
---|
57 | $url = "fetch_url_".$i; |
---|
58 | $friends = $_POST["friend_".$i]; |
---|
59 | if ( preg_match($validurl ,$_POST[$url]) ) { |
---|
60 | setConfig($url, $_POST[$url].':::'.$time[$i].':::'.$friends); |
---|
61 | $feed[$i] = $_POST[$url]; |
---|
62 | } else |
---|
63 | setConfig($url, ''); |
---|
64 | $feed[$i] = ''; |
---|
65 | } |
---|
66 | } |
---|
67 | $feed = array(); |
---|
68 | for ($i = 1; $i<=$feedcount; $i++) { |
---|
69 | $str = getConfig('fetch_url_'.$i); |
---|
70 | $tmp = explode(':::', $str); |
---|
71 | $feed[$i] = $tmp[0]; |
---|
72 | $time[$i] = $tmp[1]; |
---|
73 | $friend[$i] = $tmp[2]; |
---|
74 | } |
---|
75 | if ( $_POST['fetch'] ) { |
---|
76 | if (CORP_ID && !MASTER) { |
---|
77 | $corp = new Corporation(CORP_ID); |
---|
78 | $myid = '&corp='.urlencode($corp->getName()); |
---|
79 | } |
---|
80 | if (ALLIANCE_ID && !MASTER) { |
---|
81 | $alli = new Alliance(ALLIANCE_ID); |
---|
82 | $myid = '&alli='.urlencode($alli->getName()); |
---|
83 | } |
---|
84 | for ($i=1; $i<=$feedcount; $i++) { |
---|
85 | $feedfetch = new Fetcher(); |
---|
86 | $cfg = "fetch_url_".$i; |
---|
87 | if (preg_match($validurl , $feed[$i]) && $_POST["fetch_feed_".$i]) { |
---|
88 | $str = ''; |
---|
89 | //if ($time[$i]) |
---|
90 | // $str .= '&lastkllid='.$time[$i]; |
---|
91 | if ($friend[$i]) |
---|
92 | $str .= '&friend=1'; |
---|
93 | if ( $_POST['fetch_losses'] ) |
---|
94 | $str .= "&losses=1"; |
---|
95 | if ( !getConfig('fetch_compress') ) |
---|
96 | $str .= "&gz=1"; |
---|
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++) { |
---|
106 | $html .= "<b>Week: ". $l ."</b><br>"; |
---|
107 | $html .= $feedfetch->grab( $feed[$i]."&year=".$_POST['year']."&week=".$l, $myid.$str ); |
---|
108 | } |
---|
109 | } else |
---|
110 | $html .= $feedfetch->grab( $feed[$i], $myid.$str ); |
---|
111 | } |
---|
112 | setConfig($cfg, $feed[$i].':::'.$lastkllid.':::'.$friend); |
---|
113 | $time[$i] = $lastkllid; |
---|
114 | } |
---|
115 | } |
---|
116 | |
---|
117 | $html .= "<form id=options name=options method=post action=?a=settings_feed_syndication>"; |
---|
118 | $html .= "</table>"; |
---|
119 | |
---|
120 | $html .= "<div class=block-header2>Feeds</div><table>"; |
---|
121 | for ($i = 1; $i<=$feedcount; $i++) { |
---|
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=\""; |
---|
123 | if ( $feed[$i] ) |
---|
124 | $html .= $feed[$i]; |
---|
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>"; |
---|
130 | $html .= "<input type=checkbox name=fetch_feed_".$i." id=fetch_feed_".$i; |
---|
131 | if ( $feed[$i] ) |
---|
132 | $html .= " checked=\"checked\""; |
---|
133 | $html .= "><b>Fetch?</b><br>"; |
---|
134 | $html .= "</td></tr>"; |
---|
135 | } |
---|
136 | $html .= "</table><i>Example: http://killboard.eve-d2.com/?a=feed</i><br><br><br>"; |
---|
137 | |
---|
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>"; |
---|
170 | $html .= "<td><input type=checkbox name=fetch_losses id=fetch_losses>"; |
---|
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>"; |
---|
173 | $html .= "<input type=submit id=submit name=fetch value=\"Fetch!\"><br><br>"; |
---|
174 | |
---|
175 | $html .= "<div class=block-header2>Options</div><table>"; |
---|
176 | $html .= "<tr><td height=30px width=150px><b>Number of feeds:</b></td>"; |
---|
177 | $html .= "<td><input type=text name=fetch_feed_count size=2 maxlength=2 class=password value=\"".$feedcount."\"</td></tr>"; |
---|
178 | $html .= "<tr><td height=50px width=150px><b>Comment for automatically parsed killmails?</b></td>"; |
---|
179 | $html .= "<td><input type=text size=50 class=password name=fetch_comment id=fetch_comment value=\""; |
---|
180 | if ( getConfig('fetch_comment') ) |
---|
181 | $html .= getConfig('fetch_comment'); |
---|
182 | $html .= "\"><br><i> (leave blank for none)</i><br></td></tr>"; |
---|
183 | $html .= "<tr><td height=30px width=150px><b>Enable compression?</b></td>"; |
---|
184 | $html .= "<td><input type=checkbox name=fetch_compress id=fetch_compress"; |
---|
185 | if ( !getConfig('fetch_compress') ) |
---|
186 | $html .= " checked=\"checked\""; |
---|
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>"; |
---|
188 | $html .= "</tr>"; |
---|
189 | $html .= "<tr><td height=30px width=150px><b>Verbose mode?</b></td>"; |
---|
190 | $html .= "<td><input type=checkbox name=fetch_verbose id=fetch_verbose"; |
---|
191 | if ( getConfig('fetch_verbose') ) |
---|
192 | $html .= " checked=\"checked\""; |
---|
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>"; |
---|
194 | $html .= "</tr></table><br><br>"; |
---|
195 | $html .= "<input type=submit id=submit name=submit value=\"Save\">"; |
---|
196 | $html .= "</form>"; |
---|
197 | |
---|
198 | $page->addContext( $menubox->generate() ); |
---|
199 | $page->setContent( $html ); |
---|
200 | $page->generate(); |
---|
201 | ?> |
---|