예제 #1
0
/**
 * @package EDK
 */
function update034()
{
    global $url, $smarty;
    //Checking if this Update already done
    if (CURRENT_DB_UPDATE < "034") {
        if (is_null(config::get('034updatestatus'))) {
            config::set('034updatestatus', 0);
        }
        $qry = DBFactory::getDBQuery(true);
        if (config::get('034updatestatus') < 1) {
            $qry->execute("SHOW COLUMNS FROM kb3_invtypes LIKE 'radius'");
            if ($qry->recordCount()) {
                $sql = "ALTER TABLE `kb3_invtypes` DROP COLUMN `radius` ";
                $qry->execute($sql);
            }
        }
        config::set("DBUpdate", "034");
        $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '034' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '034'");
        config::del("034updatestatus");
        $smarty->assign('refresh', 1);
        $smarty->assign('content', "Update 034 completed.");
        $smarty->display('update.tpl');
        die;
    }
}
예제 #2
0
/**
 *	Wrapper to do all to work.  Updates the items table based on the cached or live data.
 */
function ec_update_value($item_id)
{
    $query = DBFactory::getDBQuery();
    // Don't try if we can't open URLs with fopen.
    // Do to!
    //    if (1 != function_exists('curl_init')) {
    //            return;
    //    }
    // Don't try if the item id isn't an integer.
    if (!is_numeric($item_id)) {
        return;
    }
    // Verify we have a sync table to use.
    verify_sync_table();
    // The destroyed items etc feed in the -internal- killboard item ID.
    // EVE Central needs the external ID if we have it.
    $query->execute("SELECT typeID FROM kb3_invtypes WHERE typeID={$item_id}");
    $data = $query->getRow();
    $e_item_id = $data['typeID'];
    // Don't try if the item id isn't an integer or it's 0.
    if (!is_numeric($e_item_id) or 0 == $e_item_id) {
        return;
    }
    file_put_contents(KB_CACHEDIR . '/evecentral/activity.log', "Request for {$item_id} -> {$e_item_id}\n", FILE_APPEND);
    $value = ec_get_value($e_item_id);
    if (-99 != $value) {
        $query->execute("update kb3_item_price set price='{$value}' WHERE typeID={$item_id}");
        return true;
    } else {
        file_put_contents(KB_CACHEDIR . '/evecentral/activity.log', "Failed to find it.\n", FILE_APPEND);
    }
    return false;
}
예제 #3
0
function update014()
{
    global $url, $smarty;
    //Checking if this Update already done
    if (CURRENT_DB_UPDATE < "014") {
        if (is_null(config::get('014updatestatus'))) {
            config::set('014updatestatus', 0);
        }
        $qry = DBFactory::getDBQuery(true);
        if (config::get('014updatestatus') < 1) {
            // Add killmail summary. time, hash, trust.
            $sql = 'CREATE TABLE IF NOT EXISTS `kb3_mails` (
  `kll_id` int(11) NOT NULL auto_increment,
  `kll_timestamp` datetime NOT NULL default "0000-00-00 00:00:00",
  `kll_external_id` int(8) default NULL,
  `kll_hash` BINARY(16) NOT NULL,
  `kll_trust` TINYINT NOT NULL DEFAULT 0,
  PRIMARY KEY  (`kll_id`),
  UNIQUE KEY `external_id` (`kll_external_id`),
  UNIQUE KEY `time_hash` (`kll_timestamp`,`kll_hash`)
) Engine=InnoDB';
            $qry->execute($sql);
        }
        killCache();
        config::set("DBUpdate", "014");
        $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '014' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '014'");
        config::del("014updatestatus");
        $smarty->assign('refresh', 1);
        $smarty->assign('content', "Update 014 completed.");
        $smarty->display('update.tpl');
        die;
    }
}
예제 #4
0
/**
 * @package EDK
 */
function update016()
{
    global $url, $smarty;
    //Checking if this Update already done
    if (CURRENT_DB_UPDATE < "016") {
        $qry = DBFactory::getDBQuery(true);
        $sql = "ALTER TABLE `kb3_mails` ADD `kll_modified_time` DATETIME NOT NULL ";
        $qry->execute("SHOW COLUMNS FROM kb3_mails LIKE 'kll_modified_time'");
        if (!$qry->recordCount()) {
            $qry->execute($sql);
        }
        $sql = "ALTER TABLE `kb3_mails` ADD INDEX ( `kll_modified_time` ) ";
        $qry->execute("SHOW INDEXES FROM kb3_mails");
        $indexexists = false;
        while ($testresult = $qry->getRow()) {
            if ($testresult['Column_name'] == 'kll_modified_time') {
                $indexexists = true;
            }
        }
        if (!$indexexists) {
            $qry->execute($sql);
        }
        config::set("DBUpdate", "016");
        $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '016' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '016'");
        $smarty->assign('refresh', 1);
        $smarty->assign('content', "Update 016 completed.");
        $smarty->display('update.tpl');
        die;
    }
}
예제 #5
0
 private function updateChars()
 {
     if (empty($this->chars)) {
         return $this->chars;
     }
     foreach ($this->chars as $char) {
         // check if chars eveid exists in kb
         $sql = 'select plts.plt_id, plts.plt_externalid from kb3_pilots plts where plts.plt_name = "' . $char['Name'] . '"';
         $qry = DBFactory::getDBQuery();
         $qry->execute($sql);
         if ($qry->recordCount() != 0) {
             // pilot is in kb db, check he has his char id
             $row = $qry->getRow();
             $pilot_id = $row['plt_id'];
             $pilot_external_id = $row['plt_externalid'];
             if ($pilot_external_id == 0 && $pilot_id != 0) {
                 // update DB with ID
                 $qry->execute("UPDATE kb3_pilots SET plt_externalid = " . intval($char['charID']) . "\n                                     WHERE plt_id = " . $pilot_id);
             }
         } else {
             // pilot is not in DB
             // Set Corp
             $pilotscorp = Corporation::lookup($char['corpName']);
             // Check Corp was set, if not, add the Corp
             if (!$pilotscorp->getID()) {
                 $ialliance = Alliance::add('None');
                 $pilotscorp = Corporation::add($char['corpName'], $ialliance, gmdate("Y-m-d H:i:s"));
             }
             Pilot::add($char['Name'], $pilotscorp, gmdate("Y-m-d H:i:s"), intval($char['charID']));
         }
     }
     return;
 }
예제 #6
0
 /**
  *
  * @param array $itemarray
  * @param float $price
  */
 function ItemList($itemarray = null, $price = 0)
 {
     if (isset($itemarray)) {
         $this->itemarray = $itemarray;
     }
     $this->price = $price;
     $this->qry = DBFactory::getDBQuery();
 }
예제 #7
0
 /**
  * Log a new kill.
  *
  * @param integer $killid
  * @param string $note
  */
 public static function logKill($killid, $note = null)
 {
     if (is_null($note)) {
         $note = "IP:" . logger::getip();
     }
     $qry = DBFactory::getDBQuery(true);
     $qry->execute("INSERT INTO kb3_log (log_kll_id, log_site," . " log_ip_address, log_timestamp) values(" . $killid . ",'" . KB_SITE . "','" . $qry->escape($note) . "', UTC_TIMESTAMP())");
 }
예제 #8
0
 function execQuery()
 {
     $qry = DBFactory::getDBQuery();
     $qry->execute("select * from kb3_regions where reg_id = " . $this->id);
     $row = $qry->getRow();
     $this->name = $row['reg_name'];
     $this->coords = array($row['reg_x'], $row['reg_y'], $row['reg_z']);
 }
예제 #9
0
 public static function getShipClassIDByName($shipClassName)
 {
     $query = "SELECT scl_id FROM kb3_ship_classes WHERE scl_class = '{$shipClassName}'";
     $qry = DBFactory::getDBQuery();
     $qry->execute($query);
     $shipClassId = $qry->getRow();
     return $shipClassId["scl_id"];
 }
예제 #10
0
 public static function delKill($kill)
 {
     $qry = DBFactory::getDBQuery();
     $qry->execute("BEGIN");
     allianceSummary::delKill($kill);
     corpSummary::delKill($kill);
     pilotSummary::delKill($kill);
     $qry->execute("COMMIT");
 }
예제 #11
0
function update022()
{
    global $url, $smarty;
    //Checking if this Update already done
    if (CURRENT_DB_UPDATE < "022") {
        if (is_null(config::get('022updatestatus'))) {
            config::set('022updatestatus', 0);
        }
        $qry = DBFactory::getDBQuery(true);
        if (config::get('022updatestatus') < 1) {
            $qry->execute("DELETE FROM `kb3_ships` WHERE `shp_externalid` = 0 AND `shp_name` NOT LIKE '%Unknown%'");
            $qry->execute("DELETE FROM `kb3_ships` WHERE `shp_id` IN (206, 497, 348, 349,352, 354, 606)");
            config::set('022updatestatus', 1);
            $smarty->assign('refresh', 1);
            $smarty->assign('content', "22. Delete unused and duplicated ships from ships table.");
            $smarty->display('update.tpl');
            die;
        }
        if (config::get('022updatestatus') < 2) {
            // Add timestamp column to kb3_inv_detail
            $qry->execute("SHOW INDEX FROM `kb3_ships`");
            $indextexists = false;
            while ($testresult = $qry->getRow()) {
                if ($testresult['Column_name'] == 'shp_externalid') {
                    $indextexists = true;
                }
            }
            if (!$indextexists) {
                $qry->execute("ALTER TABLE `kb3_ships` ADD UNIQUE `shp_externalid` ( `shp_externalid` ) ");
                config::set('022updatestatus', 2);
                $smarty->assign('refresh', 1);
                $smarty->assign('content', "22. Ships table added unique index for external IDs.");
                $smarty->display('update.tpl');
                die;
            }
        }
        if (config::get('022updatestatus') < 3) {
            //not too happy about this one but it does force the ships to use *my* IDs, as it would be if i dumped it - FRK
            $qry->execute("INSERT IGNORE INTO `kb3_ships` (`shp_id` ,`shp_name` ,`shp_class` ,`shp_externalid` ,`shp_rce_id` ,`shp_baseprice` ,`shp_techlevel` ,`shp_isfaction`) VALUES (704 , 'Guristas Shuttle', '11', '21628', '1', '10000000', '1', '1');");
            $qry->execute("INSERT IGNORE INTO `kb3_ships` (`shp_id` ,`shp_name` ,`shp_class` ,`shp_externalid` ,`shp_rce_id` ,`shp_baseprice` ,`shp_techlevel` ,`shp_isfaction`) VALUES (705 , 'Civilian Gallente Shuttle', '11', '27303', '8', '0', '1', '0');");
            config::set('022updatestatus', 3);
            $smarty->assign('refresh', 1);
            $smarty->assign('content', "22. Insert missing shuttles.");
            $smarty->display('update.tpl');
            die;
        }
        killCache();
        config::set("DBUpdate", "022");
        $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '022' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '022'");
        config::del("022updatestatus");
        $smarty->assign('refresh', 1);
        $smarty->assign('content', "Update 022 completed.");
        $smarty->display('update.tpl');
        die;
    }
}
예제 #12
0
파일: about.php 프로젝트: biow0lf/evedev-kb
 function stats()
 {
     global $smarty;
     $qry = DBFactory::getDBQuery();
     $qry->execute("SELECT COUNT(*) AS cnt FROM kb3_kills");
     $row = $qry->getRow();
     $kills = $row['cnt'];
     $smarty->assign('kills', $kills);
     return $smarty->fetch(get_tpl("about_stats"));
 }
예제 #13
0
 public static function hasCampaigns($active = false)
 {
     $qry = DBFactory::getDBQuery();
     $sql = "select ctr_id\n                 from kb3_contracts\n\t         where ctr_site = '" . KB_SITE . "'";
     if ($active) {
         $sql .= " and ( ctr_ended is null or now() <= ctr_ended ) limit 1";
     }
     $qry->execute($sql);
     return $qry->recordCount() > 0;
 }
예제 #14
0
function update021()
{
    global $url, $smarty;
    //Checking if this Update already done
    if (CURRENT_DB_UPDATE < "021") {
        $qry = DBFactory::getDBQuery(true);
        if (is_null(config::get('021updatestatus'))) {
            config::set('021updatestatus', 0);
        }
        if (config::get('021updatestatus') < 1) {
            // Add timestamp column to kb3_inv_detail
            $qry->execute("SHOW COLUMNS FROM kb3_ships LIKE 'shp_isfaction'");
            if (!$qry->recordCount()) {
                $qry->execute("ALTER TABLE `kb3_ships` ADD `shp_isfaction` TINYINT(1) DEFAULT '0' AFTER `shp_techlevel`;");
                config::set('021updatestatus', 1);
                $smarty->assign('refresh', 1);
                $smarty->assign('content', "21. kb3_ships shp_isfaction column added");
                $smarty->display('update.tpl');
                die;
            }
        }
        if (config::get('021updatestatus') < 3) {
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 3628;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17715;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17718;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17720;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17722;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17736;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17738;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17740;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17918;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17920;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17922;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17924;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17926;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17928;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17930;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 17932;");
            $qry->execute("UPDATE kb3_ships SET shp_isfaction = '1' WHERE shp_externalid = 32207;");
            config::set('021updatestatus', 3);
            $smarty->assign('refresh', 1);
            $smarty->assign('content', "21. faction tags added");
            $smarty->display('update.tpl');
            die;
        }
        killCache();
        config::set("DBUpdate", "021");
        $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '021' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '021'");
        config::del("021updatestatus");
        $smarty->assign('refresh', 1);
        $smarty->assign('content', "Update 021 completed.");
        $smarty->display('update.tpl');
        die;
    }
}
예제 #15
0
 public static function getMoonName($id)
 {
     if ($id != 0) {
         $qry = DBFactory::getDBQuery();
         $sql = 'select moo_name FROM kb3_moons WHERE moo_id = ' . $id;
         $qry->execute($sql);
         $row = $qry->getRow();
         return $row['moo_name'];
     } else {
         return false;
     }
 }
예제 #16
0
/**
 * @package EDK
 */
function update039()
{
    global $url, $smarty;
    //Checking if this Update already done
    if (CURRENT_DB_UPDATE < "039") {
        if (is_null(config::get('039updatestatus'))) {
            config::set('039updatestatus', 0);
        }
        $qry = DBFactory::getDBQuery(true);
        if (config::get('039updatestatus') < 1) {
            $qry->execute("UPDATE kb3_inv_detail SET ind_shp_id = 11194 WHERE ind_shp_id = 206");
            // Kitsune
            $qry->execute("UPDATE kb3_inv_detail SET ind_shp_id = 22428 WHERE ind_shp_id = 348");
            // Redeemer
            $qry->execute("UPDATE kb3_inv_detail SET ind_shp_id = 22430 WHERE ind_shp_id = 349");
            // Sin
            $qry->execute("UPDATE kb3_inv_detail SET ind_shp_id = 22436 WHERE ind_shp_id = 352");
            // Widow
            $qry->execute("UPDATE kb3_inv_detail SET ind_shp_id = 22440 WHERE ind_shp_id = 354");
            // Panther
            config::set('039updatestatus', 1);
            $smarty->assign('refresh', 1);
            $smarty->assign('content', "39. Update kb3_inv_detail.");
            $smarty->display('update.tpl');
            die;
        }
        if (config::get('039updatestatus') < 2) {
            $qry->execute("UPDATE kb3_kills SET kll_ship_id = 11194 WHERE kll_ship_id = 206");
            // Kitsune
            $qry->execute("UPDATE kb3_kills SET kll_ship_id = 22428 WHERE kll_ship_id = 348");
            // Redeemer
            $qry->execute("UPDATE kb3_kills SET kll_ship_id = 22430 WHERE kll_ship_id = 349");
            // Sin
            $qry->execute("UPDATE kb3_kills SET kll_ship_id = 22436 WHERE kll_ship_id = 352");
            // Widow
            $qry->execute("UPDATE kb3_kills SET kll_ship_id = 22440 WHERE kll_ship_id = 354");
            // Panther
            config::set('039updatestatus', 2);
            $smarty->assign('refresh', 1);
            $smarty->assign('content', "39. Update kb3_kills.");
            $smarty->display('update.tpl');
            die;
        }
        killCache();
        config::set("DBUpdate", "039");
        $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '039' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '039'");
        config::del("039updatestatus");
        $smarty->assign('refresh', 1);
        $smarty->assign('content', "Update 039 completed.");
        $smarty->display('update.tpl');
        die;
    }
}
예제 #17
0
/**
*
* @return string HTML string for toplists
*/
function topLists($filterArguments = array())
{
    if (empty($filterArguments)) {
        $whereSql = "";
    } else {
        $whereSql = "WHERE " . implode(" AND ", $filterArguments);
    }
    $sql = "SELECT COUNT( bop.battle_id ) AS cnt, bop.plt_id\n                        FROM kb3_battles_owner_pilots bop\n                        INNER JOIN kb3_pilots plt ON ( plt.plt_id = bop.plt_id ) \n                        INNER JOIN kb3_battles_cache bc ON bc.battle_id = bop.battle_id\n                        INNER JOIN kb3_systems sys ON sys.sys_name = bc.system\n                        INNER JOIN kb3_constellations con ON con.con_id = sys.sys_con_id\n                        INNER JOIN kb3_regions reg ON reg.reg_id = con.con_reg_id\n                        {$whereSql}\n                        GROUP BY bop.plt_id ORDER BY 1 DESC LIMIT 15";
    $query = DBFactory::getDBQuery();
    $query->execute($sql);
    $tkbox = new AwardBoxLong($query, "Top Fleet Attendees", "Fleet attendances", "fleets", "eagle", $query->recordCount());
    return $html = $tkbox->generate();
}
예제 #18
0
 function clearSumCache()
 {
     if ($_POST['option_clear_sum'] == 'on') {
         $qry = DBFactory::getDBQuery();
         $qry->execute("DELETE FROM kb3_sum_alliance");
         $qry->execute("DELETE FROM kb3_sum_corp");
         $qry->execute("DELETE FROM kb3_sum_pilot");
         // Clear page and query cache as well since they also contain the
         // summaries.
         CacheHandler::removeByAge('SQL', 0, true);
         CacheHandler::removeByAge('store', 0, true);
         $_POST['option_clear_sum'] == 'off';
     }
 }
예제 #19
0
function update010()
{
    global $url, $smarty;
    //Checking if this Update already done
    if (CURRENT_DB_UPDATE < "010") {
        $qry = DBFactory::getDBQuery(true);
        $sql = "CREATE TABLE IF NOT EXISTS `kb3_sum_pilot` (\r\n\t\t  `psm_plt_id` int(11) NOT NULL DEFAULT '0',\r\n\t\t  `psm_shp_id` int(3) NOT NULL DEFAULT '0',\r\n\t\t  `psm_kill_count` int(11) NOT NULL DEFAULT '0',\r\n\t\t  `psm_kill_isk` float NOT NULL DEFAULT '0',\r\n\t\t  `psm_loss_count` int(11) NOT NULL DEFAULT '0',\r\n\t\t  `psm_loss_isk` float NOT NULL DEFAULT '0',\r\n\t\t  PRIMARY KEY (`psm_plt_id`,`psm_shp_id`)\r\n\t\t) ENGINE=InnoDB";
        $qry->execute($sql);
        config::set("DBUpdate", "010");
        $smarty->assign('refresh', 1);
        $smarty->assign('content', "Update 010 completed.");
        $smarty->display('update.tpl');
        die;
    }
}
예제 #20
0
 private static function _put($key, $data, $hard = false)
 {
     if ($hard) {
         self::$roles['hard'][$key] = $key;
         if (!isset(self::$roles['keys'][$key])) {
             // this indicates a hard role without a database entry
             // generate an identification number
             $id = abs(crc32($key));
             // insert it into the database
             $db = DBFactory::getDBQuery();
             $db->execute('INSERT INTO `kb3_roles` VALUES("' . $id . '", "' . KB_SITE . '", "' . $key . '", "' . $data . '");');
         }
     }
     self::$roles['keys'][$key] = $data;
 }
예제 #21
0
/**
 * @package EDK
 */
function update029()
{
    global $url, $smarty;
    //Checking if this Update already done
    if (CURRENT_DB_UPDATE < "029") {
        $qry = DBFactory::getDBQuery(true);
        $qry2 = DBFactory::getDBQuery(true);
        $newrows = array();
        $sql = 'SELECT cfg_site FROM kb3_config GROUP BY cfg_site';
        $qry->execute($sql);
        while ($row = $qry->getRow()) {
            $qry2->execute("SELECT cfg_value FROM kb3_config WHERE cfg_site = '" . $row['cfg_site'] . "' AND cfg_key = 'cfg_pilotid'");
            if ($row2 = $qry2->getRow()) {
                if (is_null($row2['cfg_value']) || is_numeric($row2['cfg_value'])) {
                    $newrows[] = '"' . $row['cfg_site'] . '", "cfg_pilotid", "' . serialize(array((int) $row['cfg_value'])) . '"';
                }
            } else {
                $newrows[] = '"' . $row['cfg_site'] . '", "cfg_pilotid", "' . serialize(array()) . '"';
            }
            $qry2->execute("SELECT cfg_value FROM kb3_config WHERE cfg_site = '" . $row['cfg_site'] . "' AND cfg_key = 'cfg_corpid'");
            if ($row2 = $qry2->getRow()) {
                if (is_null($row2['cfg_value']) || is_numeric($row2['cfg_value'])) {
                    $newrows[] = '"' . $row['cfg_site'] . '", "cfg_corpid", "' . serialize(array((int) $row['cfg_value'])) . '"';
                }
            } else {
                $newrows[] = '"' . $row['cfg_site'] . '", "cfg_corpid", "' . serialize(array()) . '"';
            }
            $qry2->execute("SELECT cfg_value FROM kb3_config WHERE cfg_site = '" . $row['cfg_site'] . "' AND cfg_key = 'cfg_allianceid'");
            if ($row2 = $qry2->getRow()) {
                if (is_null($row2['cfg_value']) || is_numeric($row2['cfg_value'])) {
                    $newrows[] = '"' . $row['cfg_site'] . '", "cfg_allianceid", "' . serialize(array((int) $row['cfg_value'])) . '"';
                }
            } else {
                $newrows[] = '"' . $row['cfg_site'] . '", "cfg_allianceid", "' . serialize(array()) . '"';
            }
        }
        if ($newrows) {
            $qry->execute('REPLACE INTO kb3_config (cfg_site, cfg_key, cfg_value) VALUES' . '(' . join('), (', $newrows) . ')');
        }
        config::set("DBUpdate", "029");
        $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '029' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '029'");
        config::del("029updatestatus");
        $smarty->assign('refresh', 1);
        $smarty->assign('content', "Update 029 completed.");
        $smarty->display('update.tpl');
        die;
    }
}
예제 #22
0
/**
 * @package EDK
 */
function update042()
{
    global $url, $smarty;
    //Checking if this Update already done
    if (CURRENT_DB_UPDATE < "042") {
        if (is_null(config::get('042updatestatus'))) {
            config::set('042updatestatus', 0);
        }
        $qry = DBFactory::getDBQuery(true);
        if (config::get('042updatestatus') < 1) {
            $qry->execute("ALTER TABLE kb3_alliances ADD COLUMN all_active TINYINT(1) NOT NULL DEFAULT 1 AFTER all_start_date");
            $qry->execute("ALTER TABLE kb3_alliances DROP INDEX all_name");
            $qry->execute("ALTER TABLE kb3_alliances ADD UNIQUE all_name_active ( all_name, all_active )");
            config::set('042updatestatus', 1);
            $smarty->assign('refresh', 1);
            $smarty->assign('content', "42. Add Active column to alliances.");
            $smarty->display('update.tpl');
            die;
        }
        if (config::get('042updatestatus') < 2) {
            $qry->execute("ALTER TABLE kb3_corps ADD COLUMN crp_active TINYINT(1) NOT NULL DEFAULT 1 AFTER crp_startdate");
            $qry->execute("ALTER TABLE kb3_corps DROP INDEX crp_name");
            $qry->execute("ALTER TABLE kb3_corps ADD UNIQUE crp_name_active ( crp_name, crp_active )");
            config::set('042updatestatus', 2);
            $smarty->assign('refresh', 1);
            $smarty->assign('content', "42. Add Active column to corps.");
            $smarty->display('update.tpl');
            die;
        }
        if (config::get('042updatestatus') < 3) {
            $qry->execute("ALTER TABLE kb3_pilots ADD COLUMN plt_active TINYINT(1) NOT NULL DEFAULT 1 AFTER plt_lpoints");
            $qry->execute("ALTER TABLE kb3_pilots DROP INDEX plt_name");
            $qry->execute("ALTER TABLE kb3_pilots ADD UNIQUE plt_name_active ( plt_name, plt_active )");
            config::set('042updatestatus', 3);
            $smarty->assign('refresh', 1);
            $smarty->assign('content', "42. Add Active column to pilots.");
            $smarty->display('update.tpl');
            die;
        }
        config::set("DBUpdate", "042");
        $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '042' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '042'");
        config::del("042updatestatus");
        $smarty->assign('refresh', 1);
        $smarty->assign('content', "Update 042 completed.");
        $smarty->display('update.tpl');
        die;
    }
}
예제 #23
0
파일: sig.php 프로젝트: biow0lf/evedev-kb
function lastKill($id)
{
    $id = (int) $id;
    if (!$id) {
        return false;
    }
    $sql = "SELECT UNIX_TIMESTAMP(max(ind_timestamp)) as last " . "FROM kb3_inv_detail WHERE ind_plt_id = {$id}";
    $qry = DBFactory::getDBQuery();
    $qry->execute($sql);
    $row = $qry->getRow();
    if (!$row['last']) {
        return false;
    } else {
        return time() - (int) $row['last'];
    }
}
예제 #24
0
 public function reset()
 {
     $sql = "DELETE from kb3_navigation WHERE KBSITE = '" . $this->site . "'";
     $qry = DBFactory::getDBQuery(true);
     $qry->autocommit(false);
     $qry->execute($sql);
     // return false if query fails
     if (!$qry->execute($sql)) {
         return false;
     }
     //keep these urls hardcoded, we don't need session IDs in the database
     $sql = "INSERT INTO `kb3_navigation` (`nav_type`,`intern`,`descr` ,`url` ,`target`,`posnr`,`page` ,`hidden`,`KBSITE`) VALUES" . " ('top',1,'Home','?a=home','_self',1,'ALL_PAGES',0,'" . $this->site . "')," . " ('top',1,'Campaigns','?a=campaigns','_self',2,'ALL_PAGES',0,'" . $this->site . "')," . " ('top',1,'Post Mail','?a=post','_self',3,'ALL_PAGES',0,'" . $this->site . "')," . " ('top',1,'Stats','?a=self_detail','_self',4,'ALL_PAGES',0,'" . $this->site . "')," . " ('top',1,'Awards','?a=awards','_self',5,'ALL_PAGES',0,'" . $this->site . "')," . " ('top',1,'Standings','?a=standings','_self',6,'ALL_PAGES',0,'" . $this->site . "')," . " ('top',1,'Search','?a=search','_self',7,'ALL_PAGES',0,'" . $this->site . "')," . " ('top',1,'Admin','?a=admin','_self',8,'ALL_PAGES',0,'" . $this->site . "')," . " ('top',1,'About','?a=about','_self',9,'ALL_PAGES',0,'" . $this->site . "');";
     $qry->execute($sql);
     $qry->autocommit(true);
     return true;
 }
예제 #25
0
function update025()
{
    global $url, $smarty;
    //Checking if this Update already done
    if (CURRENT_DB_UPDATE < "025") {
        $qry = DBFactory::getDBQuery(true);
        $qry->execute("INSERT IGNORE INTO `kb3_item_locations` (" . "`itl_id` , `itl_location`)" . " VALUES ('8',  'Implant');");
        killCache();
        config::set("DBUpdate", "025");
        $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '025' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '025'");
        $smarty->assign('refresh', 1);
        $smarty->assign('content', "25. kb3_item_locations updated.");
        $smarty->display('update.tpl');
        die;
    }
}
예제 #26
0
/**
 * @package EDK
 */
function update019()
{
    global $url, $smarty;
    //Checking if this Update already done
    if (CURRENT_DB_UPDATE < "019") {
        $qry = DBFactory::getDBQuery(true);
        $sql = "ALTER TABLE `kb3_pilots` CHANGE `plt_name` `plt_name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
        $qry->execute($sql);
        config::set("DBUpdate", "019");
        $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '019' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '019'");
        $smarty->assign('refresh', 1);
        $smarty->assign('content', "Update 019 completed.");
        $smarty->display('update.tpl');
        die;
    }
}
예제 #27
0
function update011()
{
    global $url, $smarty;
    //Checking if this Update already done
    if (CURRENT_DB_UPDATE < "011") {
        $qry = DBFactory::getDBQuery(true);
        $sql = "ALTER TABLE `kb3_ships` CHANGE `shp_baseprice` `shp_baseprice` BIGINT( 12 ) NOT NULL DEFAULT '0'";
        $qry->execute($sql);
        config::set("DBUpdate", "011");
        $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '011' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '011'");
        $smarty->assign('refresh', 1);
        $smarty->assign('content', "Update 011 completed.");
        $smarty->display('update.tpl');
        die;
    }
}
예제 #28
0
 /**
  * Fetch item values.
  * 
  * @return int The count of values fetched
  */
 public function fetch_values()
 {
     // New query
     $qry = DBFactory::getDBQuery();
     $items = array();
     // Fetch normal items
     $sxe = new SimpleXMLElement($this->fetchItemValues());
     // Check that file contains data
     if (!count($sxe->result[0]->rowset[0])) {
         return 0;
     }
     // Loop ALL std prices
     foreach ($sxe->result[0]->rowset[0]->row as $stat) {
         // If there is almost nothing for sale, AT ALL, don't include!
         if ($stat['vol'] < 5) {
             continue;
         }
         // Use sell median
         $weighted_average = round($stat['median'], 0);
         // Make sure we still have data
         if (!$weighted_average) {
             continue;
         }
         // Add to std array
         $items[(int) $stat['typeID']] = '' . $weighted_average;
     }
     // prepare counter
     $i = 0;
     foreach ($items as $key => $value) {
         // Insert new values into the database and update the old
         // For the first item start the query. For later items add ','
         if ($i) {
             $querytext .= ",";
         } else {
             $querytext = "INSERT INTO kb3_item_price (typeID, price) VALUES ";
         }
         $querytext .= "('{$key}'," . number_format($value, 0, '', '') . ")";
         $i++;
     }
     // Finish query with a check for duplicates. If so, just update
     $querytext .= " ON DUPLICATE KEY UPDATE price = VALUES(price);";
     $qry->execute($querytext);
     config::set('lastfetch', time());
     return $i;
 }
예제 #29
0
function update009()
{
    global $url, $smarty;
    //Checking if this Update already done
    if (CURRENT_DB_UPDATE < "009") {
        $qry = DBFactory::getDBQuery(true);
        $sql = "CREATE TABLE IF NOT EXISTS `kb3_sum_alliance` (\r\n\t\t  `asm_all_id` int(11) NOT NULL DEFAULT '0',\r\n\t\t  `asm_shp_id` int(3) NOT NULL DEFAULT '0',\r\n\t\t  `asm_kill_count` int(11) NOT NULL DEFAULT '0',\r\n\t\t  `asm_kill_isk` float NOT NULL DEFAULT '0',\r\n\t\t  `asm_loss_count` int(11) NOT NULL DEFAULT '0',\r\n\t\t  `asm_loss_isk` float NOT NULL DEFAULT '0',\r\n\t\t  PRIMARY KEY (`asm_all_id`,`asm_shp_id`)\r\n\t\t) ENGINE=InnoDB";
        $qry->execute($sql);
        $sql = "CREATE TABLE IF NOT EXISTS `kb3_sum_corp` (\r\n\t\t  `csm_crp_id` int(11) NOT NULL DEFAULT '0',\r\n\t\t  `csm_shp_id` int(3) NOT NULL DEFAULT '0',\r\n\t\t  `csm_kill_count` int(11) NOT NULL DEFAULT '0',\r\n\t\t  `csm_kill_isk` float NOT NULL DEFAULT '0',\r\n\t\t  `csm_loss_count` int(11) NOT NULL DEFAULT '0',\r\n\t\t  `csm_loss_isk` float NOT NULL DEFAULT '0',\r\n\t\t  PRIMARY KEY (`csm_crp_id`,`csm_shp_id`)\r\n\t\t) ENGINE=InnoDB";
        $qry->execute($sql);
        config::set("DBUpdate", "009");
        $qry->execute("UPDATE kb3_config SET cfg_value = '009' WHERE cfg_key = 'DBUpdate'");
        $smarty->assign('refresh', 1);
        $smarty->assign('content', "Update 009 completed.");
        $smarty->display('update.tpl');
        die;
    }
}
예제 #30
0
/**
 * @package EDK
 */
function update030()
{
    global $url, $smarty;
    //Checking if this Update already done
    if (CURRENT_DB_UPDATE < "030") {
        $qry = DBFactory::getDBQuery(true);
        $newrows = array();
        $sql = 'ALTER TABLE kb3_eveunits MODIFY COLUMN displayName CHAR(25) DEFAULT NULL';
        $qry->execute($sql);
        config::set("DBUpdate", "030");
        $qry->execute("INSERT INTO kb3_config (cfg_site, cfg_key, cfg_value) SELECT cfg_site, 'DBUpdate', '030' FROM kb3_config GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '030'");
        config::del("030updatestatus");
        $smarty->assign('refresh', 1);
        $smarty->assign('content', "Update 030 completed.");
        $smarty->display('update.tpl');
        die;
    }
}