Changeset 353
- Timestamp:
- 10/21/08 08:42:44 (14 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/includes/class.parser.php
r339 r353 34 34 35 35 // Parser fix, since some killmails don't have a final blow, they would break the KB. 36 //On mails without final kill info the first name on the list becomes thefinal blow holder36 //On mails without final blow info, the first name on the list becomes the final blow holder 37 37 if (strpos($this->killmail_, 'laid the final blow') < 1) 38 38 { … … 52 52 $upper_limit = count($victim); 53 53 54 $victimname = "Unknown"; 54 $victimname = "Unknown"; //lovely default values 55 55 $factionname = "None"; 56 56 $alliancename = "None"; … … 67 67 if(preg_match("/Victim: (.*)/", $victim[$counter], $matches)) 68 68 { 69 $victimname = $matches[1]; 69 if($matches[1]) 70 $victimname = $matches[1]; 70 71 } 71 72 elseif (preg_match("/Corp: (.*)/", $victim[$counter], $matches)) 72 73 { 73 $corpname = $matches[1]; 74 if($matches[1]) 75 $corpname = $matches[1]; 74 76 } 75 77 elseif (preg_match("/Alliance: (.*)/", $victim[$counter], $matches)) 76 78 { 77 $alliancename = $matches[1]; 79 if($matches[1]) 80 $alliancename = $matches[1]; 78 81 } 79 82 elseif (preg_match("/Faction: (.*)/", $victim[$counter], $matches)) 80 83 { 81 $factionname = $matches[1]; 84 if($matches[1]) 85 $factionname = $matches[1]; 82 86 } 83 87 elseif (preg_match("/Destroyed: (.*)/", $victim[$counter], $matches)) 84 88 { 85 $shipname = $matches[1]; 89 if($matches[1]) 90 $shipname = $matches[1]; 86 91 } 87 92 elseif (preg_match("/System: (.*)/", $victim[$counter], $matches)) 88 93 { 89 $systemname = $matches[1]; 94 if($matches[1]) 95 $systemname = $matches[1]; 90 96 } 91 97 elseif (preg_match("/Security: (.*)/", $victim[$counter], $matches)) 92 98 { 93 $systemsec = $matches[1]; 99 if($matches[1]) 100 $systemsec = $matches[1]; 94 101 } 95 102 elseif (preg_match("/Damage Taken: (.*)/", $victim[$counter], $matches)) 96 103 { 97 $dmgtaken = $matches[1]; 98 $this->dmgtaken = $dmgtaken; 104 if($matches[1]) 105 { 106 $dmgtaken = $matches[1]; 107 $this->dmgtaken = $dmgtaken; 108 } 99 109 } 100 110 elseif (preg_match("/Moon: (.*)/", $victim[$counter], $matches)) 101 111 { 102 $moon = $matches[1]; 103 $victimname = $matches[1]; 104 $pos = 1; 112 if($matches[1]) 113 { 114 $moon = $matches[1]; 115 $victimname = $matches[1]; 116 $pos = 1; 117 } 105 118 } 106 119 } … … 110 123 //the rest aren't required but for completeness, you'd want them in :) 111 124 if (strcmp($victimname, 'Unknown') == 0) 125 { 112 126 $this->error('Victim has no name.'); 127 unset($victimname); //we unset the variable so that it fails the next check 128 } 113 129 114 130 if (strcmp($corpname, 'Unknown') == 0) 131 { 115 132 $this->error('Victim has no corp.'); 133 unset($corpname); 134 } 116 135 117 136 if (strcmp($shipname, 'Unknown') == 0) 137 { 118 138 $this->error('Victim has no ship type.'); 139 unset($shipname); 140 } 119 141 120 142 if (strcmp($systemname, 'Unknown') == 0) 143 { 121 144 $this->error('Killmail lacks solar system information.'); 145 unset($systemname); 146 } 122 147 123 148 //modification here … … 231 256 if(preg_match("/Name: (.*)/", $involved[$counter], $matches)) 232 257 { 233 if( stristr($involved[$counter], '/'))258 if($matches[1]) //new check - involved party has name 234 259 { 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]) 260 if(stristr($involved[$counter], '/')) 242 261 { 243 $finalblow = 1; 244 $iwname = $name; 245 $end = strpos($corperation, '(') -1; 246 $corperation = substr($corperation, 0, $end); 262 $slash = strpos($involved[$counter], '/'); 263 $name = trim(substr($involved[$counter], 5, $slash-5)); 264 $corperation = trim(substr($involved[$counter], $slash+1, strlen($involved[$counter])- $shash+1)); 265 266 //now if the corp bit has final blow info, note it 267 preg_match("/(.*) \\(laid the final blow\\)/", $corperation, $matched); 268 if($matched[1]) 269 { 270 $finalblow = 1; 271 $iwname = $name; 272 $end = strpos($corperation, '(') -1; 273 $corperation = substr($corperation, 0, $end); 274 } 275 else 276 { 277 $finalblow = 0; 278 $iwname = $name; 279 } 280 $ipname = $name; 281 $icname = $corperation; 247 282 } 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]) 283 else 261 284 { 262 285 $ipname = $matches[1]; 263 $finalblow = 1; 286 preg_match("/(.*) \\(laid the final blow\\)/", $ipname, $matches); 287 if ($matches[1]) 288 { 289 $ipname = $matches[1]; 290 $finalblow = 1; 291 } 292 else $finalblow = 0; 264 293 } 265 else $finalblow = 0;266 294 } 267 295 } 268 296 else if(preg_match("/Alliance: (.*)/", $involved[$counter], $matches)) 269 297 { 270 $ianame = $matches[1]; 298 if($matches[1]) 299 $ianame = $matches[1]; 271 300 } 272 301 else if(preg_match("/Faction: (.*)/", $involved[$counter], $matches)) 273 302 { 274 $ifname = $matches[1]; 303 if($matches[1]) 304 $ifname = $matches[1]; 275 305 } 276 306 else if(preg_match("/Corp: (.*)/", $involved[$counter], $matches)) 277 307 { 278 $icname = $matches[1]; 308 if($matches[1]) 309 $icname = $matches[1]; 279 310 } 280 311 else if(preg_match("/Ship: (.*)/", $involved[$counter], $matches)) 281 312 { 282 $isname = $matches[1]; 313 if($matches[1]) 314 $isname = $matches[1]; 283 315 } 284 316 else if(preg_match("/Weapon: (.*)/", $involved[$counter], $matches)) 285 317 { 286 $iwname = $matches[1]; 318 if($matches[1]) 319 $iwname = $matches[1]; 287 320 } 288 321 else if(preg_match("/Security: (.*)/", $involved[$counter], $matches)) 289 322 { 290 $secstatus = $matches[1]; 323 if($matches[1]) 324 $secstatus = $matches[1]; 291 325 } 292 326 else if(preg_match("/Damage Done: (.*)/", $involved[$counter], $matches)) 293 327 { 294 $idmgdone = $matches[1]; 328 if($matches[1]) 329 $idmgdone = $matches[1]; 295 330 } 296 331 else { … … 309 344 $ialliance = new Alliance(); 310 345 $ialliance->add($ianame); 346 311 347 $icorp = new Corporation(); 312 $icorp->add($icname, $ialliance, $kill->getTimeStamp()); 313 348 if (strcmp($icname, 'None') == 0) 349 { 350 $this->error('Involved party has no corp.'); 351 } 352 else 353 { //don't add corp, because pilots have to be in corps. 354 $icorp->add($icname, $ialliance, $kill->getTimeStamp()); 355 } 356 357 $ipilot = new Pilot(); 358 314 359 if (strcmp($ipname, 'Unknown') == 0) 315 360 { 316 $this->error('Involved pilot has no name.'); 317 } 318 319 $ipilot = new Pilot(); 320 $ipilot->add($ipname, $icorp, $timestamp); 361 $this->error('Involved party has no name.'); 362 } 363 else 364 { 365 //don't add pilot if the pilot's unknown or dud 366 $ipilot->add($ipname, $icorp, $timestamp); 367 } 321 368 322 369 $iship = new Ship(); … … 604 651 'Dropped items:', 'Qty:', 'Unknown', 'Drone Bay', 'Drone Bay'); 605 652 606 //if (strpos($this->killmail, chr(246)) === false)607 //{608 // $this->killmail_ = utf8_decode($this->killmail_);609 //}610 653 $this->killmail_ = str_replace($search, $replace, $this->killmail_); 611 654 return;