function handle_involved($kill, $side, &$pilots, $sideAssignmentMap = array(), $completeInformation = FALSE)
{
    // -------------------------------------------------------------------------
    // FIX BATTLE REPORT a little by Evoke. Salvoxia
    // BEGIN
    // -------------------------------------------------------------------------
    // we dont want our corp/alliance to show up on the enemy's side
    if ($side == 'e') {
        if (config::get('cfg_corpid')) {
            $corpId = config::get('cfg_corpid');
            $corpId = $corpId[0];
            $excludeWhere = "AND ind_crp_id != {$corpId}";
        } elseif (config::get('cfg_allianceid')) {
            $allianceId = config::get('cfg_allianceid');
            $allianceId = $allianceId[0];
            $excludeWhere = "AND ind_all_id != {$allianceId}";
        } else {
            $excludeWhere = "";
        }
    }
    // we need to get all involved pilots, killlists dont supply them
    $qry = DBFactory::getDBQuery();
    $sql = "select ind_plt_id AS ind_plt_id, ind_crp_id, ind_all_id, ind_sec_status, ind_shp_id, ind_wep_id, ind_dmgdone,\n            typeName, plt_name, crp_name, all_name, scl_points, scl_id, scl_class\n            from kb3_inv_detail\n            left join kb3_invtypes on ind_wep_id=typeID\n            left join kb3_pilots on ind_plt_id=plt_id\n            left join kb3_corps on ind_crp_id=crp_id\n            left join kb3_alliances on ind_all_id=all_id\n            left join kb3_ships on ind_shp_id=shp_id\n            left join kb3_ship_classes on shp_class=scl_id\n            where ind_kll_id = " . $kill->getID() . " {$excludeWhere}\n            order by ind_order";
    $qry->execute($sql);
    while ($row = $qry->getRow()) {
        if (config::get('fleet_battles_mod_sideassign')) {
            // determine whether the pilot is member of an alliance
            if ($row["all_name"] == "None") {
                $entityType = "corp";
                $entityId = $row["ind_crp_id"];
            } else {
                $entityType = "alliance";
                $entityId = $row["ind_all_id"];
            }
            if (isset($sideAssignmentMap[$entityType][$entityId])) {
                $pilotSide = $sideAssignmentMap[$entityType][$entityId];
            } else {
                $pilotSide = $side;
            }
        } else {
            $pilotSide = $side;
        }
        // check for manual side assignment for pilot
        $ship = Cacheable::factory('Ship', $row['ind_shp_id']);
        $shipc = Cacheable::factory('ShipClass', $row['scl_id']);
        // check for npc names (copied from pilot class)
        $pos = strpos($row['plt_name'], "#");
        if ($pos !== false) {
            $name = explode("#", $row['plt_name']);
            $item = Item::getByID($name[2]);
            $row['plt_name'] = $item->getName();
        }
        // dont set pods as ships for pilots we already have
        if (isset($pilots[$pilotSide][$row['ind_plt_id']])) {
            if ($row['scl_id'] == 18 || $row['scl_id'] == 2) {
                continue;
            }
        }
        // search for ships with the same id
        if (isset($pilots[$pilotSide][$row['ind_plt_id']]) && is_array($pilots[$pilotSide][$row['ind_plt_id']])) {
            foreach ($pilots[$pilotSide][$row['ind_plt_id']] as $id => $_ship) {
                if ($row['ind_shp_id'] == $_ship['sid']) {
                    // we already got that pilot in this ship, continue
                    $pilots[$pilotSide][$row['ind_plt_id']][0]["times"] += 1;
                    // add up his damage done
                    $pilots[$pilotSide][$row['ind_plt_id']][0]["damage"] += $row['ind_dmgdone'];
                    continue 2;
                }
            }
        }
        if ($completeInformation) {
            $pilots[$pilotSide][$row['ind_plt_id']][] = array('name' => $row['plt_name'], 'plt_url' => edkURI::page("pilot_detail", $row["ind_plt_id"], "plt_id"), 'sid' => $row['ind_shp_id'], 'spic' => imageURL::getURL('Ship', $ship->getID(), 32), 'aid' => $row['ind_all_id'], 'ts' => strtotime($kill->getTimeStamp()), 'corp' => $row['crp_name'], 'alliance' => $row['all_name'], 'alliance_url' => edkURI::page("alliance_detail", $row['ind_all_id'], "all_id"), 'scl' => $row['scl_points'], 'ship' => $ship->getName(), 'shipClass' => $row['scl_class'], 'shipClassObject' => $shipc, 'weapon' => $row['itm_name'], 'cid' => $row['ind_crp_id'], 'crp_url' => edkURI::page("corp_detail", $row['ind_crp_id'], "crp_id"), 'times' => 1, 'damage' => $row['ind_dmgdone'], 'color' => getColorClassByClass($shipc));
        } else {
            $pilots[$pilotSide][$row['ind_plt_id']] = 1;
        }
    }
}
Example #2
0
		public function __construct($type, $id)
		{
			$this->type = $type;
			$this->id = $id;

			if( $type == 'item' )
			{
				$item = Item::getByID($id);
				if( $item instanceof Item )
				{
					$cat = $item->category;
					
					$categories = array($cat);
					while( $cat->getParent() instanceof Category )
					{
						$cat = $cat->getParent();
						array_push($categories, $cat);
					}
					$categories = array_reverse($categories);
					
					$this->path = '<a href="menu.php" class="button"><span class="icon book"></span>Menu</a>';
					foreach( $categories as $cat )
					{
						$this->path .= '|<a href="menu.php?cat=' . $cat->categoryid . '" class="button">' . $cat->name . '</a>';
					}
					$this->path .= '|<a href="#" class="button">' . $item->name . '</a>';
				}
			}
			elseif( $type == 'menu' )
			{
				$c = Category::getByID($id);
				if( $c instanceof Category )
				{
					$categories = array($c);
					
					while( $c->getParent() instanceof Category )
					{
						$c = $c->getParent();
						array_unshift($categories, $c);
					}
					
					$this->path = '<a href="menu.php" class="button"><span class="icon book"></span>Menu</a>';
					foreach( $categories as $cat )
					{
						$this->path .= '|<a href="menu.php?cat=' . $cat->categoryid . '" class="button">' . $cat->name . '</a>';
					}
				}
				else
				{
					$this->path = '<a href="menu.php" class="button"><span class="icon book"></span>Menu</a>';
				}
			}
			elseif( $type == 'report' )
			{
				switch($id)
				{
					case 0: $report_name = 'Item Frequency'; break;
					case 1: $report_name = 'Orders per Hour'; break;
				}
				$this->path = '<a href="reporting.php" class="button"><span class="icon book"></span>Reports</a>';
				if($id != null)
				{
					$this->path .= '|<a href="reporting.php?report='.$report_name.'" class="button"><span class="icon clock"></span>'.$report_name.'</a>';
				}
			}
		}
Example #3
0
 /**
  * Lookup an Item by name
  * @param string $name
  * @return Item|boolean
  */
 public static function lookup($name)
 {
     static $cache_name;
     if (isset($cache_name[$name])) {
         return $cache_name[$name];
     }
     $name = trim(stripslashes($name));
     $qry = DBFactory::getDBQuery();
     $query = "select typeID as itm_id from kb3_invtypes itm\n\t\t\t\t  where typeName = '" . $qry->escape($name) . "'";
     $qry->execute($query);
     if (!$qry->recordCount()) {
         $cache_name[$name] = false;
     } else {
         $row = $qry->getRow();
         $cache_name[$name] = Item::getByID((int) $row['itm_id']);
     }
     return $cache_name[$name];
 }
Example #4
0
		if( $tmpl->code == -1 && $tmpl->action == null )
		{
			$tmpl->code = 0;
		}
		unset($tmpl->item);
	}
	else
	{
		$tmpl->breadcrumb = new Breadcrumb('item', $tmpl->item->itemid);
		View::add($_SESSION['userid'], $tmpl->item->itemid);
		$usr = User::getByID($_SESSION['userid']);
		$tmp = array_slice($usr->Predict->recommend($tmpl->item), 0, 6);
		$tmpl->recommendations = array();
		foreach( $tmp as $rec )
		{
			array_push($tmpl->recommendations, Item::getByID($rec['itemid']));
		}
	}
	
	switch( $tmpl->code )
	{
		case 0:
			$tmpl->message = "Could not find item.";
			$tmpl->css = "error";
			break;
		case 10:
			$tmpl->message = "Deleting item succeeded.";
			$tmpl->css = "okay";
			break;
		case 11:
			$tmpl->message = "Deleting item failed.";
Example #5
0
	require_once('Item.php');
	
	$page = new Page(0, "OrderUp - Prediction_test");
	$tmpl = new Template();
	$page->run();
	
	$suggested_item_objects = array();
	
	$suggested_items = isset($_GET['item']) ? Predict::similar(Item::getByName($_GET['item'])) : -1;
	
	$tmpl->suggested_items = $suggested_items;
	if($suggested_items != -1)
	{
		foreach($suggested_items as $si)
		{
			array_push($suggested_item_objects, array(Item::getByID(intval($si['itemid'])), $si['similarity']));
		}
	}
	$tmpl->suggested_item_objects = $suggested_item_objects;
	
	$html = $tmpl->build('prediction_test.html');
	$css = $tmpl->build('reporting.css');
	$js = $tmpl->build('prediction_test.js');
	
	$appContent = array(
						'html'	=>	$html,
						'css'	=>	array(	'code' => $css,
											'link' => 'reporting'
											),
						'js' => $js
						);
Example #6
0
		public function __get($var)
		{
			if( $var == 'order' )
			{
				return Order::getByID($this->orderid);
			}
			elseif( $var == 'item' )
			{
				return Item::getByID($this->itemid);
			}
			elseif( $var == 'customizations' )
			{
				return Customization::getByOrderItem($this->order_itemis);
			}
			else
			{
				return $this->$var;
			}
		}
Example #7
0
							);
							array_push($active_items, $thisitem);
						}
					}
					else
					{
						//single item on order
						$thisitem = array(	'orderid' => $active_order_items->orderid,
											'name' => Item::getByID($active_order_items->itemid)->name,
											'specialComment' => Order::getByID($active_order_items->orderid)->specialComment,
											'tablenumber' => Order::getByID($active_order_items->orderid)->tableid,
											'time' => date("g:i (A) m/d/y", Order::getByID($active_order_items->orderid)->time),
											'status' => Order::getByID($active_order_items->orderid)->statusid,
											'user' => Order::getByID($active_order_items->orderid)->userid,
											'itemid' => $active_order_items->itemid,
											'catid' => Item::getByID($active_order_items->itemid)->categoryid
							);
							array_push($active_items, $thisitem);
					}
				}
			}
			else
			{
				$active_items = $active_order_items;
			}
	}
	
	//get all inactive orders
	if(Order::getAllInactive())
	{
			$inactive_order_objects = Order::getAllInactive();
Example #8
0
 /**
  * @param SimpleXMLElement $inv
  * @param Kill $kill
  * @param string $time YYYY-mm-dd hh:ss
  * @return boolean false on error
  */
 private function processInvolved($inv, &$kill, $time)
 {
     if (!(int) $inv['shipTypeID'] && !(int) $inv['weaponTypeID'] && !(int) $inv['characterID'] && !(string) $inv['characterName']) {
         $this->parsemsg[] = "Involved party blank.";
         return false;
     }
     $npc = false;
     $ship = Ship::getByID((int) $inv['shipTypeID']);
     $weapon = Cacheable::factory('Item', (int) $inv['weaponTypeID']);
     $alliance = new Alliance();
     if ((int) $inv['allianceID']) {
         $alliance = Alliance::add(strval($inv['allianceName']), (int) $inv['allianceID']);
     } else {
         if ((int) $inv['factionID']) {
             $alliance = Alliance::add(strval($inv['factionName']), (int) $inv['factionID']);
         } else {
             $alliance = Alliance::add("None");
         }
     }
     // get alliance from corp if ship is any kind of tower
     $shipClassID = $ship->getClass()->getID();
     if ($shipClassID == 35 || $shipClassID == 36 || $shipClassID == 37) {
         $corpByName = Corporation::lookup(strval($inv['corporationName']));
         if ($corpByName) {
             $alliance = $corpByName->getAlliance();
         }
     }
     $corp = Corporation::add(strval($inv['corporationName']), $alliance, $time, (int) $inv['corporationID']);
     $charid = (int) $inv['characterID'];
     $charname = (string) $inv['characterName'];
     // Allow for blank names for consistency with CCP API.
     if (preg_match("/(Mobile (Large|Medium|Small) Warp Disruptor I?I?|\\w+ Control Tower( \\w+)?)/", $charname)) {
         $charname = $inv['corporationName'] . ' - ' . $charname;
         $charid = 0;
     } else {
         if ($charname == "" && preg_match("/(Mobile \\w+ Warp|\\w+ Control Tower( \\w+)?)/", $weapon->getName())) {
             $charname = $inv['corporationName'] . ' - ' . $weapon->getName();
             $charid = 0;
         } else {
             if ($charname == "" && !$charid) {
                 // NPC ship
                 $ship = Ship::lookup("Unknown");
                 $weapon = Item::getByID((int) $inv['shipTypeID']);
                 $charname = $weapon->getName();
                 $npc = true;
                 $charid = $weapon->getID();
             } else {
                 if ($charname == "" && $charid) {
                     // Bugged kill
                     $this->parsemsg[] = "Involved party has blank pilot name.";
                     return false;
                 }
             }
         }
     }
     $pilot = Pilot::add((string) $charname, $corp, $time, $charid);
     $iparty = new InvolvedParty($pilot->getID(), $corp->getID(), $alliance->getID(), (double) $inv['securityStatus'], $ship->getID(), $weapon->getID(), (int) $inv['damageDone']);
     $kill->addInvolvedParty($iparty);
     if ((int) $inv['finalBlow'] == 1) {
         $kill->setFBPilotID($pilot->getID());
     }
     $this->npcOnly = $this->npcOnly && $npc;
     return true;
 }
Example #9
0
	set_include_path('../backbone:../global:../jquery:../components:../content:../images:../model:../render:../scripts:../styles');
	require_once('RedirectBrowserException.php');
	require_once('Item.php');

	require_once('Session.php');
	setSession(0, '/');
	
	$id = isset($_GET['id']) ? $_GET['id'] : -1;

	if( !isset($_SESSION['active']) || !$_SESSION['active'] || $_SESSION['roleid'] > 2 )
	{
		$urlenc = urlencode("components/DeleteItem.php?id=$id");
		throw new RedirectBrowserException("../login.php?code=10&fwd=$urlenc");
	}
	else
	{
		$item = Item::getByID($id);
		if( $item instanceof Item )
		{
			$res = $item->delete();
			if( $res )
			{
				throw new RedirectBrowserException("../item.php?code=10");
			}
			else
			{
				throw new RedirectBrowserException("../item.php?code=11&id=$id");
			}
		}
	}
?>
Example #10
0
		public function recommend($item)
		{
			if( !($item instanceof Item) )
			{
				if( is_integer($item) )
				{
					$item = Item::getByID($item);
				}
				else
				{
					return false;
				}
			}
			
			//get similarity array for the item
			$similar = Predict::similar($item);
			if( $similar )
			{
				foreach( $similar as $arr )
				{
					$id = $arr['itemid'];
					$similarity = $arr['similarity'];
					$arr['recommendation'] = $similarity + Predict::compare($item, $id);
				}
			}
			
			if( usort($similar, array(Predict, 'sortSimilarities')) )
			{
				return $similar;
			}
			else
			{
				return false;
			}
		}
Example #11
0
 /**
  * @param KillWrapper $kill
  * @param string $side a,e for ally, enemy
  */
 private function handle_involved($kill, $side)
 {
     // we need to get all involved pilots, killlists dont supply them
     $qry = DBFactory::getDBQuery();
     $sql = "select ind_plt_id, ind_crp_id, ind_all_id, ind_sec_status, ind_shp_id, ind_wep_id,\n\t\t\t\twtype.typeName, plt_name, crp_name, all_name, stype.typeName AS shp_name, scl_points, scl_id\n\t\t\t\tfrom kb3_inv_detail\n\t\t\t\tleft join kb3_invtypes wtype on ind_wep_id=wtype.typeID\n\t\t\t\tleft join kb3_invtypes stype on ind_shp_id=stype.typeID\n\t\t\t\tleft join kb3_pilots on ind_plt_id=plt_id\n\t\t\t\tleft join kb3_corps on ind_crp_id=crp_id\n\t\t\t\tleft join kb3_alliances on ind_all_id=all_id\n\t\t\t\tleft join kb3_ships on ind_shp_id=shp_id\n\t\t\t\tleft join kb3_ship_classes on shp_class=scl_id\n\t\t\t\twhere ind_kll_id = " . $kill->getID() . "\n\t\t\t\torder by ind_order";
     $qry->execute($sql);
     while ($row = $qry->getRow()) {
         // check for npc names (copied from pilot class)
         $pos = strpos($row['plt_name'], "#");
         if ($pos !== false) {
             $name = explode("#", $row['plt_name']);
             $item = Item::getByID($name[2]);
             $row['plt_name'] = $item->getName();
         }
         // dont set pods as ships for pilots we already have
         if (isset($this->pilots[$side][$row['ind_plt_id']])) {
             if ($row['scl_id'] == 18 || $row['scl_id'] == 2) {
                 continue;
             }
         }
         // search for ships with the same id
         if (isset($this->pilots[$side][$row['ind_plt_id']])) {
             foreach ($this->pilots[$side][$row['ind_plt_id']] as $id => $_ship) {
                 if ($row['ind_shp_id'] == $_ship['sid']) {
                     // we already got that pilot in this ship, continue
                     continue 2;
                 }
             }
         }
         $this->pilots[$side][$row['ind_plt_id']][] = array('name' => $row['plt_name'], 'plt_url' => edkURI::page('pilot_detail', $row['ind_plt_id']), 'corp' => $row['crp_name'], 'cid' => $row['ind_crp_id'], 'crp_url' => edkURI::page('corp_detail', $row['ind_crp_id']), 'alliance' => $row['all_name'], 'aid' => $row['ind_all_id'], 'all_url' => edkURI::page('alliance_detail', $row['ind_all_id']), 'ts' => strtotime($kill->getTimeStamp()), 'weapon' => $row['itm_name'], 'sid' => $row['ind_shp_id'], 'spic' => imageURL::getURL('Ship', $row['ind_shp_id'], 32), 'ship' => $row['ind_shp_id'] ? $row['shp_name'] : Language::get("Unknown"), 'scl' => $row['scl_points'], 'shpclass' => $row['scl_id']);
     }
 }
Example #12
0
 /**
  * Update the stored value of an item and the total value of this kill.
  *
  * Input values are taken from the query string.
  */
 private function updatePrices()
 {
     if (config::get('item_values')) {
         if (isset($_POST['submit']) && $_POST['submit'] == 'UpdateValue') {
             // Send new value for item to the database
             $qry = DBFactory::getDBQuery();
             $qry->autocommit(false);
             if (isset($_POST['SID'])) {
                 $SID = intval($_POST['SID']);
                 $Val = preg_replace('/[^0-9]/', '', $_POST[$SID]);
                 $qry->execute("INSERT INTO kb3_item_price (typeID, price) VALUES ('" . $SID . "', '" . $Val . "') ON DUPLICATE KEY UPDATE price = '" . $Val . "'");
                 Ship::delCache($this->kill->getVictimShip());
             } else {
                 $IID = intval($_POST['IID']);
                 $Val = preg_replace('/[^0-9]/', '', $_POST[$IID]);
                 $qry->execute("INSERT INTO kb3_item_price (typeID, price) VALUES ('" . $IID . "', '" . $Val . "') ON DUPLICATE KEY UPDATE price = '" . $Val . "'");
                 Item::delCache(Item::getByID($IID));
             }
             Kill::delCache($this->kill);
             $this->kill = Kill::getByID($this->kill->getID());
             $this->kill->calculateISKLoss(true);
             $qry->autocommit(true);
         }
     }
 }
Example #13
0
				'cat' => $cat,
				'img' => $img,
				'prep' => $prep,
				'lvl' => $lvl,
				'price' => $price,
				'ing' => $ing,
				'char' => $char				
				);
				
	if( !isset($_SESSION['active']) || !$_SESSION['active'] || $_SESSION['roleid'] > 2 )
	{
		kick(0, $data, 0);
	}
	
	//check for item
	$item = Item::getByID($data['id']);
	if( !$item )
	{
		kick(1, $data, 9);
	}
	
	if( $data['name'] == '' || $data['name'] == null )
	{
		kick(1, $data, 0);
	}
	
	if( $data['desc'] == '' || $data['desc'] == null )
	{
		kick(1, $data, 1);
	}