Esempio n. 1
0
 /**
  * Return the pilot's CCP ID.
  * When populateList is true, the lookup will return 0 in favour of getting the
  *  external ID from CCP. This helps the kill_detail page load times.
  *
  * @param boolean $populateList
  * @return integer
  */
 public function getExternalID($populateList = false)
 {
     if ($this->externalid) {
         return $this->externalid;
     }
     if (!$populateList) {
         $this->execQuery();
         if ($this->externalid) {
             return $this->externalid;
         }
         $pqry = new DBPreparedQuery();
         $sql = "SELECT typeID FROM kb3_invtypes, kb3_pilots WHERE typeName = plt_name AND plt_id = ?";
         $id = "";
         $pqry->prepare($sql);
         $pqry->bind_param('i', $this->id);
         $pqry->bind_result($id);
         if ($pqry->execute()) {
             if ($pqry->recordCount()) {
                 $pqry->fetch();
                 $this->setCharacterID($id);
                 return $this->externalid;
             }
         }
         // If getName() != name_ then this is a structure, not a pilot.
         if ($this->getName() != $this->name) {
             return 0;
         }
         $myID = new API_NametoID();
         $myID->setNames($this->getName());
         $myID->fetchXML();
         $myNames = $myID->getNameData();
         if ($this->setCharacterID($myNames[0]['characterID'])) {
             return $this->externalid;
         } else {
             return 0;
         }
     } else {
         return 0;
     }
 }
Esempio n. 2
0
 function delScout($s_id, $pilotid)
 {
     $qry = new DBQuery(true);
     $qry->execute("delete from kb3_scout where inp_kll_id = " . $this->killID_ . " and scout_id = " . $s_id . " limit 1");
     //get pilot order to be deleted
     $pqry = new DBPreparedQuery();
     $pqry->prepare("select ind_order from kb3_inv_detail where ind_kll_id = ? and ind_plt_id = ?");
     $pqry->bind_param('ii', $this->killID_, $pilotid);
     $pqry->bind_result($scoutOrder);
     if (!$pqry->execute() || !$pqry->recordCount()) {
         return false;
     } else {
         $pqry->fetch();
     }
     //get highest pilot order
     $pqry = new DBPreparedQuery();
     $pqry->prepare("select max(ind_order) from kb3_inv_detail where ind_kll_id = ?");
     $pqry->bind_param('i', $this->killID_);
     $pqry->bind_result($maxScoutOrder);
     if (!$pqry->execute() || !$pqry->recordCount()) {
         return false;
     } else {
         $pqry->fetch();
     }
     $qry->execute("delete from kb3_inv_detail where ind_kll_id = " . $this->killID_ . " and ind_plt_id = " . $pilotid . " and ind_shp_id = '9999' limit 1");
     //reorder remaining scouts
     for ($i = $scoutOrder + 1; $i <= $maxScoutOrder; $i++) {
         $qry->execute("update kb3_inv_detail set ind_order = '" . ($i - 1) . "' where ind_kll_id = '" . $this->killID_ . "' and ind_shp_id = '9999' and ind_order = '" . $i . "' limit 1");
     }
     //remove from pilot's stats
     $qry->execute("SELECT 1 FROM kb3_sum_pilot WHERE psm_plt_id = '" . $pilotid . "'");
     if ($qry->recordCount() > 0) {
         $this->kill = new Kill($this->killID_);
         $qry->execute("UPDATE kb3_sum_pilot SET psm_kill_count = psm_kill_count - 1, psm_kill_isk = psm_kill_isk - '" . $this->kill->getISKLoss() . "' WHERE psm_plt_id = '" . $pilotid . "' AND psm_shp_id = '" . $this->kill->getVictimShip()->getClass()->getID() . "'");
         $qry->execute("UPDATE kb3_pilots SET plt_kpoints = plt_kpoints - '" . $this->kill->getKillPoints() . "' WHERE plt_id = '" . $pilotid . "'");
     }
     //make sure involved count is shown correctly (it's generated before this class is loaded)
     header("Location: ?a=kill_detail&kll_id=" . $this->killID_);
     exit;
 }
Esempio n. 3
0
 /**
  * Look up a Ship by name.
  *
  * @param string $name a string containing a ship name.
  */
 static function lookup($name)
 {
     static $cache_name = array();
     static $pqry = null;
     static $id = 0;
     static $shp_name = "";
     static $scl_id = 0;
     static $typeName = "";
     if (isset($cache_name[$name])) {
         return $cache_name[$name];
     }
     if ($name == "Unknown") {
         $cache_name[$name] = Ship::getByID(0);
         return $cache_name[$name];
     }
     if ($pqry === null) {
         $pqry = new DBPreparedQuery();
         $pqry->prepare("SELECT typeID, typeName, shp_class" . " FROM kb3_ships RIGHT JOIN kb3_invtypes ON shp_id=typeID" . " WHERE typeName = ?");
     }
     $shp_name = $name = trim(stripslashes($name));
     $pqry->bind_param('s', $shp_name);
     $pqry->bind_result($id, $typeName, $scl_id);
     if (!$pqry->execute() || !$pqry->recordCount()) {
         return false;
     } else {
         $pqry->fetch();
     }
     if ($scl_id == null && $id) {
         $qry = DBFactory::getDBQuery();
         $qry->execute("INSERT INTO kb3_ships (shp_id, shp_class) values({$id}, 18)");
         $scl_id = 18;
         // "Unknown"
     }
     $shipclass = ShipClass::getByID($scl_id);
     $cache_name[$name] = new Ship($id, null, $typeName, $shipclass);
     return $cache_name[$name];
 }
Esempio n. 4
0
/**
 * Search function for the search.php page.
 *
 * @param string $searchphrase
 * @param string $type
 * @param integer $limit
 * @return xajaxResponse
 */
function doAjaxSearch($searchphrase = '', $type = 'pilot', $limit = 10)
{
    $qry = new DBPreparedQuery();
    switch ($type) {
        case "pilot":
            $sql = "select plt.plt_name as name1, crp.crp_name as name2, plt.plt_id as id\n\t\t\t\t  from kb3_pilots plt, kb3_corps crp\n\t\t\t\t where plt.plt_name  like ?\n\t\t\t\t   and plt.plt_crp_id = crp.crp_id\n\t\t\t\t order by plt.plt_name LIMIT {$limit}";
            break;
        case "corp":
            $sql = "select crp.crp_name as name1, ali.all_name as name2, crp.crp_id as id\n\t\t\t\t  from kb3_corps crp, kb3_alliances ali\n\t\t\t\t where crp.crp_name like  ?\n\t\t\t\t   and crp.crp_all_id = ali.all_id\n\t\t\t\t order by crp.crp_name LIMIT {$limit}";
            break;
        case "alliance":
            $sql = "select ali.all_name as name1, '' as name2, ali.all_id as id\n\t\t\t\t  from kb3_alliances ali\n\t\t\t\t where ali.all_name like  ?\n\t\t\t\t order by ali.all_name LIMIT {$limit}";
            break;
        case "system":
            $sql = "select sys.sys_name as name1, reg.reg_name as name2, sys.sys_id as id\n\t\t\t\t  from kb3_systems sys, kb3_constellations con, kb3_regions reg\n\t\t\t\t where sys.sys_name like  ?\n\t\t\t\t\tand con.con_id = sys.sys_con_id and reg.reg_id = con.con_reg_id\n\t\t\t\t order by sys.sys_name LIMIT {$limit}";
            break;
        case "item":
            $sql = "select typeName as name1, '' as name2, typeID as id\n\t\t\t\tfrom kb3_invtypes where typeName like ? LIMIT {$limit}";
            break;
        default:
            $objResponse = new xajaxResponse();
            $objResponse->assign('searchresults', "innerHTML", 'Invalid type');
            return $objResponse;
    }
    $name1 = 'No result';
    $name2 = '';
    $id = 0;
    $qry->prepare($sql);
    $searchphrase2 = $searchphrase . '%';
    $qry->bind_param('s', $searchphrase2);
    $qry->bind_result($name1, $name2, $id);
    $result = '';
    if (!$qry->execute()) {
        $result = $qry->getErrorMsg();
    } else {
        if (!$qry->recordCount()) {
            $result = "No results";
        } else {
            $result = "<table class='kb-table' width='450'><tr class='kb-table-header'>";
            switch ($type) {
                case "pilot":
                    $result .= "<td>Pilot</td><td>Corporation</td></tr>";
                    break;
                case "corp":
                    $result .= "<td>Corporation</td><td>Alliance</td></tr>";
                    break;
                case "alliance":
                    $result .= "<td>Alliance</td><td></td></tr>";
                    break;
                case "system":
                    $result .= "<td>System</td><td>Region</td></tr>";
                    break;
                case "item":
                    $result .= "<td>Item</td><td></td></tr>";
                    break;
            }
            while ($qry->fetch()) {
                $result .= "<tr class='kb-table-row-even'><td><a href='";
                switch ($type) {
                    case "pilot":
                        $result .= edkURI::page('pilot_detail', $id, 'plt_id') . "'>";
                        break;
                    case "corp":
                        $result .= edkURI::page('corp_detail', $id, 'crp_id') . "'>";
                        break;
                    case "alliance":
                        $result .= edkURI::page('alliance_detail', $id, 'all_id') . "'>";
                        break;
                    case "system":
                        $result .= edkURI::page('system_detail', $id, 'sys_id') . "'>";
                        break;
                    case "item":
                        $result .= edkURI::page('invtype', $id) . "'>";
                        break;
                }
                $result .= $name1 . "</a></td><td>" . $name2 . "</td></tr>";
            }
            $result .= "</table>";
        }
    }
    $objResponse = new xajaxResponse();
    $objResponse->assign('searchresults', "innerHTML", $result);
    return $objResponse;
}