46 | | if (preg_match("/Victim: (.*?)Alliance: (.*)/", $header)) |
47 | | { |
48 | | $this->error('Found no linefeeds.'); |
49 | | return 0; |
50 | | } |
51 | | |
52 | | if (preg_match("/Victim: (.*)/", $header, $matches)) |
53 | | { |
54 | | $victimname = trim($matches[1]); |
55 | | } |
56 | | else |
57 | | { |
58 | | $this->error('No victim found.'); |
59 | | } |
60 | | if (preg_match("/Alliance: (.*)/", $header, $matches)) |
61 | | { |
62 | | $alliancename = trim($matches[1]); |
63 | | } |
64 | | else |
65 | | { |
66 | | $this->error('No alliance found.'); |
67 | | } |
68 | | if (preg_match("/Corp: (.*)/", $header, $matches)) |
69 | | { |
70 | | $corpname = trim($matches[1]); |
71 | | } |
72 | | else |
73 | | { |
74 | | $this->error('No corp found.'); |
75 | | } |
76 | | if (preg_match("/Destroyed: (.*)/", $header, $matches)) |
77 | | { |
78 | | $shipname = trim($matches[1]); |
79 | | } |
80 | | else |
81 | | { |
82 | | $this->error('No destroyed ship found.'); |
83 | | } |
84 | | if (preg_match("/System: (.*)/", $header, $matches)) |
85 | | { |
86 | | $systemname = trim($matches[1]); |
87 | | } |
88 | | else |
89 | | { |
90 | | $this->error('No system found.'); |
91 | | } |
92 | | if (preg_match("/Security: (.*)/", $header, $matches)) |
93 | | { |
94 | | $systemsec = trim($matches[1]); |
95 | | } |
96 | | else |
97 | | { |
98 | | $this->error('No security found.'); |
99 | | } |
100 | | $dmgtaken = false; |
101 | | if (preg_match("/Damage Taken: (.*)/", $header, $matches)) |
102 | | { |
103 | | $dmgtaken = trim($matches[1]); |
104 | | $this->dmgtaken = $dmgtaken; |
105 | | } |
106 | | $empyrean = false; |
107 | | if (preg_match("/Faction: (.*)/", $header, $matches)) |
108 | | { |
109 | | $empyrean = true; |
110 | | } |
111 | | |
| 51 | $victim = explode("\n", trim(substr($this->killmail_, 0, $involvedpos))); |
| 52 | $upper_limit = count($victim); |
| 53 | |
| 54 | $victimname = "Unknown"; |
| 55 | $factionname = "None"; |
| 56 | $alliancename = "None"; |
| 57 | $corpname = "Unknown"; |
| 58 | $shipname = "Unknown"; |
| 59 | $systemname = "Unknown"; |
| 60 | $systemsec = "0.0"; |
| 61 | $dmgtaken = '0'; |
| 62 | $this->dmgtaken = '0'; |
| 63 | $pos = 0; |
| 64 | |
| 65 | for($counter = 0; $counter <= $upper_limit; $counter++) |
| 66 | { |
| 67 | if(preg_match("/Victim: (.*)/", $victim[$counter], $matches)) |
| 68 | { |
| 69 | $victimname = $matches[1]; |
| 70 | } |
| 71 | elseif (preg_match("/Corp: (.*)/", $victim[$counter], $matches)) |
| 72 | { |
| 73 | $corpname = $matches[1]; |
| 74 | } |
| 75 | elseif (preg_match("/Alliance: (.*)/", $victim[$counter], $matches)) |
| 76 | { |
| 77 | $alliancename = $matches[1]; |
| 78 | } |
| 79 | elseif (preg_match("/Faction: (.*)/", $victim[$counter], $matches)) |
| 80 | { |
| 81 | $factionname = $matches[1]; |
| 82 | } |
| 83 | elseif (preg_match("/Destroyed: (.*)/", $victim[$counter], $matches)) |
| 84 | { |
| 85 | $shipname = $matches[1]; |
| 86 | } |
| 87 | elseif (preg_match("/System: (.*)/", $victim[$counter], $matches)) |
| 88 | { |
| 89 | $systemname = $matches[1]; |
| 90 | } |
| 91 | elseif (preg_match("/Security: (.*)/", $victim[$counter], $matches)) |
| 92 | { |
| 93 | $systemsec = $matches[1]; |
| 94 | } |
| 95 | elseif (preg_match("/Damage Taken: (.*)/", $victim[$counter], $matches)) |
| 96 | { |
| 97 | $dmgtaken = $matches[1]; |
| 98 | $this->dmgtaken = $dmgtaken; |
| 99 | } |
| 100 | elseif (preg_match("/Moon: (.*)/", $victim[$counter], $matches)) |
| 101 | { |
| 102 | $moon = $matches[1]; |
| 103 | $victimname = $matches[1]; |
| 104 | $pos = 1; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | //report the errors for the things that make sense. |
| 109 | //we need pilot names, corp names, ship types, and the system to be sure |
| 110 | //the rest aren't required but for completeness, you'd want them in :) |
| 111 | if (strcmp($victimname, 'Unknown') == 0) |
| 112 | $this->error('Victim has no name.'); |
| 113 | |
| 114 | if (strcmp($corpname, 'Unknown') == 0) |
| 115 | $this->error('Victim has no corp.'); |
| 116 | |
| 117 | if (strcmp($shipname, 'Unknown') == 0) |
| 118 | $this->error('Victim has no ship type.'); |
| 119 | |
| 120 | if (strcmp($systemname, 'Unknown') == 0) |
| 121 | $this->error('Killmail lacks solar system information.'); |
| 122 | |
| 123 | //modification here |
| 124 | if ($pos == 1) |
| 125 | { |
| 126 | $victimname = $moon; |
| 127 | } |
| 128 | //end of modification |
220 | | preg_match("/(.*) \/ (.*)/", $ipname, $pmatches); |
221 | | $icname = $pmatches[2]; |
222 | | $isname = "Unknown"; |
223 | | $iwname = $pmatches[1]; |
224 | | if ($dmgtaken) |
225 | | { |
226 | | preg_match("/Damage Done: (.*)/", $involved[++$i], $matches); |
227 | | $idmgdone = $matches[1]; |
228 | | } |
229 | | |
230 | | if (!strlen($icname) && !strlen($iwname)) |
231 | | { |
232 | | // fucked up bclinic killmail, no person here, continue |
233 | | $i++; |
234 | | continue; |
235 | | } |
236 | | |
237 | | $tmpcorp = new Corporation(); |
238 | | $tmpcorp->lookup($icname); |
239 | | |
240 | | if (!$tmpcorp->getID()) |
241 | | { |
242 | | // not a known corp, add it |
243 | | $ialliance = new Alliance(); |
244 | | $ialliance->add('None'); |
245 | | $icorp = new Corporation(); |
246 | | $icorp->add($icname, $ialliance, $kill->getTimeStamp()); |
247 | | $tmpcorp = $icorp; |
248 | | } |
249 | | $iweapon = new Item(); |
250 | | $iweapon->lookup($pmatches[1]); |
251 | | $ipname = '#'.$tmpcorp->getID().'#'.$iweapon->getID().'#'.$iwname; |
252 | | $tmpall = $tmpcorp->getAlliance(); |
253 | | // name will be None if no alliance is set |
254 | | $ianame = $tmpall->getName(); |
255 | | |
256 | | $ialliance = &$tmpall; |
257 | | $icorp = &$tmpcorp; |
258 | | |
259 | | $i++; |
260 | | } |
261 | | else |
262 | | { |
263 | | if ($empyrean) |
264 | | { |
265 | | preg_match("/Corp: (.*)/", $involved[$i + 2], $matches); |
266 | | $icname = $matches[1]; |
267 | | |
268 | | preg_match("/Alliance: (.*)/", $involved[$i + 3], $matches); |
269 | | $ianame = $matches[1]; |
270 | | |
271 | | preg_match("/Ship: (.*)/", $involved[$i + 5], $matches); |
272 | | $isname = $matches[1]; |
273 | | |
274 | | preg_match("/Weapon: (.*)/", $involved[$i + 6], $matches); |
275 | | $iwname = $matches[1]; |
276 | | $i += 7; |
277 | | } |
278 | | else |
279 | | { |
280 | | preg_match("/Alliance: (.*)/", $involved[$i + 2], $matches); |
281 | | $ianame = $matches[1]; |
282 | | |
283 | | preg_match("/Corp: (.*)/", $involved[$i + 3], $matches); |
284 | | $icname = $matches[1]; |
285 | | |
286 | | preg_match("/Ship: (.*)/", $involved[$i + 4], $matches); |
287 | | $isname = $matches[1]; |
288 | | |
289 | | preg_match("/Weapon: (.*)/", $involved[$i + 5], $matches); |
290 | | $iwname = $matches[1]; |
291 | | $i += 6; |
292 | | } |
293 | | |
294 | | if ($dmgtaken) |
295 | | { |
296 | | preg_match("/Damage Done: (.*)/", $involved[$i++], $matches); |
297 | | $idmgdone = $matches[1]; |
| 228 | |
| 229 | for($counter = $i; $counter <= $iparts; $counter++) |
| 230 | { |
| 231 | if(preg_match("/Name: (.*)/", $involved[$counter], $matches)) |
| 232 | { |
| 233 | if(stristr($involved[$counter], '/')) |
| 234 | { |
| 235 | $slash = strpos($involved[$counter], '/'); |
| 236 | $name = trim(substr($involved[$counter], 5, $slash-5)); |
| 237 | $corperation = trim(substr($involved[$counter], $slash+1, strlen($involved[$counter])- $shash+1)); |
| 238 | |
| 239 | //now if the corp bit has final blow info, note it |
| 240 | preg_match("/(.*) \\(laid the final blow\\)/", $corperation, $matched); |
| 241 | if($matched[1]) |
| 242 | { |
| 243 | $finalblow = 1; |
| 244 | $iwname = $name; |
| 245 | $end = strpos($corperation, '(') -1; |
| 246 | $corperation = substr($corperation, 0, $end); |
| 247 | } |
| 248 | else |
| 249 | { |
| 250 | $finalblow = 0; |
| 251 | $iwname = $name; |
| 252 | } |
| 253 | $ipname = $name; |
| 254 | $icname = $corperation; |
| 255 | } |
| 256 | else |
| 257 | { |
| 258 | $ipname = $matches[1]; |
| 259 | preg_match("/(.*) \\(laid the final blow\\)/", $ipname, $matches); |
| 260 | if ($matches[1]) |
| 261 | { |
| 262 | $ipname = $matches[1]; |
| 263 | $finalblow = 1; |
| 264 | } |
| 265 | else $finalblow = 0; |
| 266 | } |
| 267 | } |
| 268 | else if(preg_match("/Alliance: (.*)/", $involved[$counter], $matches)) |
| 269 | { |
| 270 | $ianame = $matches[1]; |
| 271 | } |
| 272 | else if(preg_match("/Faction: (.*)/", $involved[$counter], $matches)) |
| 273 | { |
| 274 | $ifname = $matches[1]; |
| 275 | } |
| 276 | else if(preg_match("/Corp: (.*)/", $involved[$counter], $matches)) |
| 277 | { |
| 278 | $icname = $matches[1]; |
| 279 | } |
| 280 | else if(preg_match("/Ship: (.*)/", $involved[$counter], $matches)) |
| 281 | { |
| 282 | $isname = $matches[1]; |
| 283 | } |
| 284 | else if(preg_match("/Weapon: (.*)/", $involved[$counter], $matches)) |
| 285 | { |
| 286 | $iwname = $matches[1]; |
| 287 | } |
| 288 | else if(preg_match("/Security: (.*)/", $involved[$counter], $matches)) |
| 289 | { |
| 290 | $secstatus = $matches[1]; |
| 291 | } |
| 292 | else if(preg_match("/Damage Done: (.*)/", $involved[$counter], $matches)) |
| 293 | { |
| 294 | $idmgdone = $matches[1]; |
| 295 | } |
| 296 | else { |
| 297 | $counter++; |
| 298 | $i = $counter; |
| 299 | break; |
| 300 | } |
| 301 | |
| 302 | if ($this->needs_final_blow_) |
| 303 | { |
| 304 | $finalblow = 1; |
| 305 | $this->needs_final_blow_ = 0; |
| 306 | } |
304 | | } |
305 | | |
306 | | $ipilot = new Pilot(); |
307 | | $ipilot->add($ipname, $icorp, $timestamp); |
308 | | |
309 | | $iship = new Ship(); |
310 | | $iship->lookup($isname); |
311 | | if (!$iship->getID()) |
312 | | { |
313 | | $this->error('Ship not found.', $isname); |
314 | | } |
315 | | |
316 | | if (!trim($iwname)) |
317 | | { |
318 | | // set weapon to unknown in case we didn't found one |
319 | | $iwname = 'Unknown'; |
320 | | } |
321 | | $iweapon = new Item(); |
322 | | $iweapon->lookup($iwname); |
323 | | if (!$iweapon->getID()) |
324 | | { |
325 | | $this->error('Weapon not found.', $iwname); |
326 | | } |
327 | | |
328 | | if (ALLIANCE_ID != 0 && $ialliance->getID() == ALLIANCE_ID) |
329 | | { |
330 | | $authorized = true; |
331 | | } |
332 | | elseif (CORP_ID != 0) |
333 | | { |
334 | | $corps = explode(",", CORP_ID); |
335 | | foreach($corps as $corp) |
336 | | { |
337 | | if ($icorp->getID() == $corp) |
338 | | $authorized = true; |
339 | | } |
340 | | } |
341 | | if (!$authorized) |
342 | | { |
343 | | if ($string = config::get('post_permission')) |
344 | | { |
345 | | if ($string == 'all') |
346 | | { |
347 | | $authorized = true; |
348 | | } |
349 | | else |
350 | | { |
351 | | $tmp = explode(',', $string); |
352 | | foreach ($tmp as $item) |
| 313 | |
| 314 | if (strcmp($ipname, 'Unknown') == 0) |
| 315 | { |
| 316 | $this->error('Involved pilot has no name.'); |
| 317 | } |
| 318 | |
| 319 | $ipilot = new Pilot(); |
| 320 | $ipilot->add($ipname, $icorp, $timestamp); |
| 321 | |
| 322 | $iship = new Ship(); |
| 323 | $iship->lookup($isname); |
| 324 | if (!$iship->getID()) |
| 325 | { |
| 326 | $this->error('Ship not found.', $isname); |
| 327 | } |
| 328 | |
| 329 | $iweapon = new Item(); |
| 330 | $iweapon->lookup($iwname); |
| 331 | if (strcmp($iwname, 'Unknown') == 0) |
| 332 | { |
| 333 | $this->error('No weapon found for pilot "'.$ipname .'"'); |
| 334 | } elseif (!$iweapon->getID()) |
| 335 | { |
| 336 | $this->error('Weapon not found.', $iwname); |
| 337 | } |
| 338 | |
| 339 | if (ALLIANCE_ID != 0 && $ialliance->getID() == ALLIANCE_ID) |
| 340 | { |
| 341 | $authorized = true; |
| 342 | } |
| 343 | elseif (CORP_ID != 0) |
| 344 | { |
| 345 | $corps = explode(",", CORP_ID); |
| 346 | foreach($corps as $corp) |
| 347 | { |
| 348 | if ($icorp->getID() == $corp) |
| 349 | $authorized = true; |
| 350 | } |
| 351 | } |
| 352 | if (!$authorized) |
| 353 | { |
| 354 | if ($string = config::get('post_permission')) |
| 355 | { |
| 356 | if ($string == 'all') |
387 | | } |
388 | | |
389 | | $iparty = new InvolvedParty($ipilot->getID(), $icorp->getID(), |
390 | | $ialliance->getID(), $secstatus, $iship, $iweapon); |
391 | | if ($dmgtaken) |
392 | | { |
393 | | $iparty->dmgdone_ = $idmgdone; |
394 | | } |
395 | | $kill->addInvolvedParty($iparty); |
396 | | |
397 | | if ($finalblow == 1) |
398 | | { |
399 | | $kill->setFBPilotID($ipilot->getID()); |
400 | | $kill->setFBCorpID($icorp->getID()); |
401 | | $kill->setFBAllianceID($ialliance->getID()); |
402 | | } |
| 399 | |
| 400 | $iparty = new InvolvedParty($ipilot->getID(), $icorp->getID(), |
| 401 | $ialliance->getID(), $secstatus, $iship, $iweapon); |
| 402 | if ($dmgtaken) |
| 403 | { |
| 404 | $iparty->dmgdone_ = $idmgdone; |
| 405 | } |
| 406 | $kill->addInvolvedParty($iparty); |
| 407 | |
| 408 | if ($finalblow == 1) |
| 409 | { |
| 410 | $kill->setFBPilotID($ipilot->getID()); |
| 411 | $kill->setFBCorpID($icorp->getID()); |
| 412 | $kill->setFBAllianceID($ialliance->getID()); |
| 413 | } |
| 414 | } |
430 | | if ($dmgtaken) |
431 | | { |
432 | | $startpos = strpos($this->killmail_, "Dropped items:"); |
433 | | if ($startpos) |
434 | | { |
435 | | $endpos = strlen($this->killmail_) - $startpos + 14; |
436 | | |
437 | | $dropped = explode("\n", trim(substr($this->killmail_, $startpos + 14, $endpos))); |
438 | | #var_dump($dropped); exit; |
439 | | |
440 | | $dropped_items = $this->scanForItems($dropped); |
441 | | foreach ($dropped_items as $item) |
442 | | { |
443 | | $ditem = new DroppedItem($item['item'], $item['quantity'], $item['location']); |
444 | | $kill->addDroppedItem($ditem); |
445 | | } |
| 439 | |
| 440 | $startpos = strpos($this->killmail_, "Dropped items:"); |
| 441 | if ($startpos) |
| 442 | { |
| 443 | $endpos = strlen($this->killmail_) - $startpos + 14; |
| 444 | |
| 445 | $dropped = explode("\n", trim(substr($this->killmail_, $startpos + 14, $endpos))); |
| 446 | #var_dump($dropped); exit; |
| 447 | |
| 448 | $dropped_items = $this->scanForItems($dropped); |
| 449 | foreach ($dropped_items as $item) |
| 450 | { |
| 451 | $ditem = new DroppedItem($item['item'], $item['quantity'], $item['location']); |
| 452 | $kill->addDroppedItem($ditem); |
589 | | $replace = array('Victim:','Alliance: None','Alliance: None','Alliance: None','Alliance:', |
590 | | 'Alliance: None','Alliance: None','Alliance: None', |
591 | | 'Faction: NONE','Faction: NONE','Faction: NONE', |
592 | | 'Destroyed items','Destroyed:', 'Security:', |
593 | | 'Involved parties:', 'Qty:', 'Corp:', '(Cargo)', 'Ship:', 'Weapon:','(In Container)', |
594 | | 'Damage Done:', 'Damage Taken:', '(laid the final blow)', |
595 | | 'Dropped items:', 'Qty:', 'Unknown', 'Drone Bay', 'Drone Bay'); |
| 597 | $replace = array('Victim:','Alliance: None','Alliance: None','Alliance: None', |
| 598 | 'Alliance: None','Alliance: None','Alliance: None','Alliance:', |
| 599 | 'Faction: None','Faction: None','Faction: None', |
| 600 | 'Faction: None','Faction: None','Faction: None','Faction:', |
| 601 | 'Destroyed items','Destroyed:', 'Security:', |
| 602 | 'Involved parties:', 'Qty:', 'Corp:', '(Cargo)', 'Ship:', 'Weapon:','(In Container)', |
| 603 | 'Damage Done:', 'Damage Taken:', '(laid the final blow)', |
| 604 | 'Dropped items:', 'Qty:', 'Unknown', 'Drone Bay', 'Drone Bay'); |