Advertisement
gabestah

kAuction - ProcessRaidXml

Nov 10th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.45 KB | None | 0 0
  1. <?php
  2. function ProcessRaidXml($xmlData)
  3.     {
  4.         global $gDb;
  5.         if ($xmlData) $xml = xml2array("<?xml version='1.0' encoding='UTF-8' ?>" . $xmlData);
  6.         if ($xml['kAuction'])
  7.         {
  8.             if ($xml['kAuction']['raid'])
  9.             {
  10.                 $xRaid = $xml['kAuction']['raid'];          
  11.                 $oRaid = new Raid(GetSqlDate($xRaid['startDate']), GetSqlDate($xRaid['endDate']), $xRaid['zone'], $xRaid['duration']);
  12.                 if ($oRaid->Id) // Valid Raid added
  13.                 {
  14.                     // Check if valid actor data
  15.                     if ($xRaid['actors'] && $xRaid['actors']['actor'])
  16.                     {
  17.                         foreach ($xRaid['actors']['actor'] as $kA => $vA)
  18.                         {
  19.                             $actor = new Actor($oRaid, $vA['name'], $vA['class'], $vA['presence']);                            
  20.                             if (!array_search($actor, $oRaid->Actors))
  21.                             {
  22.                                 array_push($oRaid->Actors, $actor);
  23.                             }
  24.                         }
  25.                     }
  26.                     // Check if valid item data
  27.                     if ($xRaid['items'] && $xRaid['items']['item'])
  28.                     {
  29.                         foreach ($xRaid['items']['item'] as $kI => $vI)
  30.                         {
  31.                             $item = new Item($vI['itemId'], $vI['name']);
  32.                             $mob = new Mob($vI['corpseName']);
  33.                             $oActor = null;
  34.                             if ($vI['winner'])
  35.                             {
  36.                                 foreach ($oRaid->Actors as $actor)
  37.                                 {
  38.                                     if ($actor->Name == $vI['winner'])
  39.                                     {
  40.                                         $oActor = $actor;
  41.                                     }
  42.                                 }
  43.                             }
  44.                             $auction = new Auction($oRaid, $item, $mob, GetSqlDate($vI['dateTime']), $oActor, $vI['bidType'], $vI['disenchant'], $vI['auctionType'], $vI['councilMembers']);
  45.                             // Check if valid bids data
  46.                             if ($vI['bids'] && $vI['bids']['bid'])
  47.                             {
  48.                                 if (array_key_exists(0, $vI['bids']['bid'])) // Check if multiples
  49.                                 {
  50.                                     foreach ($vI['bids']['bid'] as $kBid => $vBid)
  51.                                     {
  52.                                         $bid = new Bid($auction, new Actor($oRaid, $vBid['name']), $vBid['bidType'], $oRaid, new Item($vBid['currentItemId'], $vBid['currentItemName']), $vBid['roll'], $vBid['voters']);
  53.                                         if (!array_search($bid, $auction->Bids))
  54.                                         {
  55.                                             array_push($auction->Bids, $bid);
  56.                                         }
  57.                                     }
  58.                                 }
  59.                                 else // Check if singular
  60.                                 {
  61.                                     $vBid = $vI['bids']['bid'];    
  62.                                     $bid = new Bid($auction, new Actor($oRaid, $vBid['name']), $vBid['bidType'], $oRaid, new Item($vBid['currentItemId'], $vBid['currentItemName']), $vBid['roll'], $vBid['voters']);
  63.                                     if (!array_search($bid, $auction->Bids))
  64.                                     {
  65.                                         array_push($auction->Bids, $bid);
  66.                                     }      
  67.                                 }
  68.                             }                        
  69.                         }
  70.                     }        
  71.                     $r = $gDb->GetQueryResult(new Query("SELECT Id FROM vcp_actor_raid WHERE Raid_Id = -1"));
  72.                     if ($r && mysqli_num_rows($r) > 0)
  73.                     {
  74.                         while ($row = $gDb->FetchAssoc($r))
  75.                         {  
  76.                             $vrr = new VcpRaidRecord($row['Id']);
  77.                             $vrr->RaidId = $oRaid->Id;
  78.                             $vrr->Update();
  79.                         }
  80.                     }                            
  81.                 }
  82.             }      
  83.         }        
  84.     }
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement