Пример #1
0
function deleteAlly($id)
{
    $galas = selectsql("select gala from galaxy where aid = {$id}");
    if ($galas) {
        #Galaxien löschen
        deleteGalaxy(getArrayFromList($galas, "gala"));
    }
    return query("delete from alliance where aid = {$id}");
}
Пример #2
0
function listLogfile($filter, $pages, $page = 1, $rows = 10)
{
    if ($page < 0 || $rows < 0 || !is_numeric($page) || !is_numeric($rows)) {
        return;
    }
    #username
    if ($filter['username']) {
        if ($where) {
            $where .= " and ";
        }
        $where .= " u.nick LIKE '" . $filter['username'] . "%'";
    }
    #koords
    if ($filter['gala']) {
        if ($where) {
            $where .= " and ";
        }
        $where .= " u.gala = " . $filter['gala'] . " ";
    }
    #category
    if ($filter['cat']) {
        if ($where) {
            $where .= " and ";
        }
        $where .= " l.cat = '" . $filter['cat'] . "'";
    }
    if ($where) {
        $where = " where " . $where;
    }
    #order by
    if ($filter['order'] == "asc") {
        $order = " ASC ";
    } else {
        $order = " DESC ";
    }
    if ($filter['sort'] == "username") {
        $sort = " u.nick ";
    } elseif ($filter['sort'] == "cat") {
        $sort = " l.cat ";
    } elseif ($filter['sort'] == "date") {
        $sort = " l.time ";
    } else {
        $sort = " l.time ";
    }
    $count = selectsqlLine("select count(*) as count from actionlog l left join user u using(uid)\n\t\t\t\t\t\t\t\t" . $where);
    #Seitenamzahl berechnen
    $pages = ceil($count['count'] / $rows);
    #Seite checken
    if ($pages < $page && $pages != 0) {
        $page = $pages;
    }
    $return = selectsql("select * from actionlog l left join user u using(uid)\n\t\t\t\t\t\t\t\t" . $where . "\n\t\t\t\t\t\t\t\torder by " . $sort . " " . $order . "\n\t\t\t\t\t\t\tLIMIT " . $rows * ($page - 1) . ",{$rows}");
    return $return;
}
Пример #3
0
function listNewsComments($nid, $pages, $page = 1, $rows = 10)
{
    if (!is_numeric($nid)) {
        return;
    }
    if ($page < 0 || $rows < 0 || !is_numeric($page) || !is_numeric($rows)) {
        return;
    }
    $pages = getNewsCommentsPages($nid, $rows);
    #Seite checken
    if ($pages < $page && $pages != 0) {
        $page = $pages;
    }
    $return = selectsql("select c.*,u.*,g.usertitle,DATE_FORMAT(c.time, '%d.%m.%y') as cdate,\n\t\t\t\t\t\t\tDATE_FORMAT(c.time, '%H:%i') as ctime, cn.nid  \n\t\t\t\t\t\t\t\tfrom com_news cn\n\t\t\t\t\t\t\t\tleft join comments c on(c.cid = cn.cid)\n\t\t\t\t\t\t\t\tleft join  user u on (u.uid = c.uid)\n\t\t\t\t\t\t\t\tleft join groups g on (g.gid = u.gid)\n\t\t\t\t\t\t\t\twhere cn.nid = {$nid} \n\t\t\t\t\t\t\t\torder by time asc \n\t\t\t\t\t\t\t\tLIMIT " . $rows * ($page - 1) . ",{$rows}");
    return $return;
}
Пример #4
0
function deleteGalaxy($id)
{
    if (is_array($id)) {
        $sql = "(" . join(",", $id) . ")";
        if (!$sql) {
            return;
        }
        $user = selectsql("select uid from user where gala IN " . $sql);
    } else {
        $user = selectsql("select uid from user where gala = {$id}");
    }
    if ($user) {
        #delete user from galaxy
        deleteUser(getArrayFromList($user, "uid"));
    }
    #delete galaxys
    if (is_array($id)) {
        $user = query("delete from galaxy where gala IN " . $sql);
    } else {
        $user = query("delete from galaxy where gala = {$id}");
    }
    return 1;
}
Пример #5
0
function highscore_list($filter, $pages, $page = 1, $rows = 50)
{
    Assert::isId($page);
    Assert::isId($rows);
    if ($filter['hours'] || $filter['days']) {
        if ($filter['hours']) {
            Assert::isNumeric($filter['hours']);
            $timeout = date("Y-m-d H:m:s", time() - (int) $filter['hours'] * 60 * 60);
        } else {
            Assert::isNumeric($filter['days']);
            $timeout = date("Y-m-d H:m:s", time() - (int) $filter['days'] * 24 * 60 * 60);
        }
        $count = selectsql("\n              select count(*) as count\n              from user u\n              left join activity a on (a.uid = u.uid)\n              where a.stamp > '{$timeout}'\n              group by u.uid\n        ");
        $count = count($count);
        #Seitenamzahl berechnen
        $pages = ceil($count / $rows);
        #Seite checken
        if ($pages < $page && $pages != 0) {
            $page = $pages;
        }
        $result = selectsql("\n          select u.*,ga.*,a.*,sum(ac.bonus) as activity_points\n          from user u\n          left join activity ac on (ac.uid = u.uid)\n          left join galaxy ga on (ga.gala = u.gala)\n          left join alliance a on(a.aid = ga.aid)\n          where ac.stamp > '{$timeout}'\n          group by u.uid\n          order by activity_points desc, u.nick asc\n          LIMIT " . $rows * ($page - 1) . ",{$rows}\n        ");
    } else {
        $count = selectsqlLine("\n              select count(*) as count\n              from user u\n        ");
        #Seitenamzahl berechnen
        $pages = ceil($count['count'] / $rows);
        #Seite checken
        if ($pages < $page && $pages != 0) {
            $page = $pages;
        }
        $result = selectsql("\n          select * from user u\n          left join galaxy ga on (ga.gala = u.gala)\n          left join alliance a on(a.aid = ga.aid)\n          order by u.activity_points desc, u.nick asc\n          LIMIT " . $rows * ($page - 1) . ",{$rows}\n        ");
    }
    for ($i = 0; $i < count($result); $i++) {
        $result[$i]['place'] = $rows * ($page - 1) + $i + 1;
    }
    return $result;
}
Пример #6
0
function listGroupsByRank($rank)
{
    if (!isset($rank) || !is_numeric($rank)) {
        echo "db.group:listGroupByRank Ungültiger Parameter!";
        return;
    }
    $list = selectsql("\n    SELECT  * , max(rank) as maxrank, min(rank) as minrank FROM groups g, group_rights gr\n      WHERE gr.gid = g.gid\n      AND gr.rank <= {$rank}\n      group by g.gid\n      order by g.gid asc\n    ");
    for ($i = 0; $i < count($list); $i++) {
        if ($list[$i]['maxrank'] == $rank) {
            $list[$i]['changed'] = 1;
        }
    }
    return $list;
}
Пример #7
0
function fleetstatus_refresh()
{
    $ids = selectsql("\n    select fs.fsid,fid from fleet_status fs\n    left join user u on (u.gala = fs.gala and u.pos = fs.pos)\n    where fs.arrival+(fs.orbittime*60)-unix_timestamp() < 0 and fs.arrival is not null and u.uid is null\n  ");
    if (count($ids)) {
        //    addToLogFile("<b>System:</b> ".count($ids)." Deffer recallt","Incomings");
        $fids = array();
        $fsids = array();
        for ($i = 0; $i < count($ids); $i++) {
            if ($ids[$i]['fid']) {
                $fids[] = $ids[$i]['fid'];
            }
            $fsids[] = $ids[$i]['fsid'];
        }
        if ($fids) {
            query("delete from fleet where fid IN (" . join(",", $fids) . ")");
        }
        query("delete from fleet_status where fsid IN (" . join(",", $fsids) . ")");
    }
    query("\n    update fleet_status set return_flight = 1,\n      arrival = returntime*60+arrival+orbittime*60,\n      returntime = NULL, orbittime = NULL\n      where return_flight = 0 AND arrival+orbittime*60-unix_timestamp() < 0 and arrival is not null");
    query("\n    delete from fleet_status  \n      where return_flight = 1 AND arrival-unix_timestamp() < 0 and arrival is not null");
}
Пример #8
0
function attack_delete($id)
{
    if (!is_numeric($id)) {
        return;
    }
    query("delete from attack where attid = {$id}");
    query("delete from attack_target where attid = {$id}");
    $atter = selectsql("\n    select  aa.sid from attack_atter aa\n    left join attack_target at on (at.sid = aa.sid)\n    where at.sid is null\n  ", "sid");
    if ($atter) {
        query("delete from attack_atter where sid IN (" . join(",", $atter) . ")");
    }
}
Пример #9
0
function bot_list()
{
    return selectsql("select * from ircbots order by name asc");
}
Пример #10
0
function updateScan($scan)
{
    $logger =& LoggerManager::getLogger("db.scans");
    $logger->debug(array("function" => "updateScan", "scan" => $scan));
    if (!is_numeric($scan['gala']) || !is_numeric($scan['pos'])) {
        return;
    }
    #scan exists
    $dbscan = existScan($scan['gala'], $scan['pos']);
    if (!$dbscan) {
        $sid = insertsql(" insert into scans (gala,pos,nick) values (" . $scan['gala'] . "," . $scan['pos'] . ",'" . addslashes($scan['nick']) . "')");
        if (!$sid) {
            return;
        }
        $dbscan = array("sid" => $sid, "gala" => $scan['gala'], "pos" => $scan['pos']);
    }
    #sektorscan
    if ($scan['type'] == "sector") {
        #existiert schon -> update
        $val = array("sector_punkte" => $scan['punkte'], "sector_kristall" => $scan['kristall'], "sector_metall" => $scan['metall'], "sector_roids" => $scan['roids'], "sector_ships" => $scan['ships'], "sector_deff" => $scan['deff'], "sector_prec" => $scan['prec'], "sector_svs" => $scan['svs'], "sector_scanner" => $scan['scanner'], "sector_time" => time());
    }
    if ($scan['type'] == "unit") {
        if ($dbscan['hasunit'] && $dbscan['unit_fid']) {
            updateFleet($dbscan['unit_fid'], $scan['kleptoren'], $scan['cancris'], $scan['fregatten'], $scan['zerstoerer'], $scan['kreuzer'], $scan['schlachter'], $scan['traeger'], $scan['jaeger'], $scan['bomber']);
            $fid = $dbscan['unit_fid'];
        } else {
            $fid = addFleet($scan['kleptoren'], $scan['cancris'], $scan['fregatten'], $scan['zerstoerer'], $scan['kreuzer'], $scan['schlachter'], $scan['traeger'], $scan['jaeger'], $scan['bomber']);
            if (!$fid) {
                return;
            }
        }
        $val = array("unit_prec" => $scan['prec'], "unit_svs" => $scan['svs'], "unit_scanner" => $scan['scanner'], "unit_fid" => $fid, "unit_time" => time());
    }
    if ($scan['type'] == "gscan") {
        $val = array("gscan_prec" => $scan['prec'], "gscan_svs" => $scan['svs'], "gscan_scanner" => $scan['scanner'], "gscan_horus" => $scan['horus'], "gscan_rubium" => $scan['rubium'], "gscan_coon" => $scan['coon'], "gscan_pulsar" => $scan['pulsar'], "gscan_centurion" => $scan['centurion'], "gscan_time" => time());
    }
    // miliscan updaten
    if ($scan['type'] == "mili") {
        if (miliscan_fleet_get($dbscan['sid'])) {
            $fleetlist = selectsql("select * from scanmili_fleet where sid = " . $dbscan['sid'] . " order by num ASC");
            for ($i = 0; $i < 3; $i++) {
                miliscan_fleet_update($fleetlist[$i]['fid'], $scan['fleets'][$i]);
            }
        } else {
            for ($i = 0; $i < 3; $i++) {
                miliscan_fleet_add($dbscan['sid'], $i, $scan['fleets'][$i]);
            }
        }
        // 100% scan und user ist tic member
        //		if($scan['prec'] == "100" && ($user = user_get_bypos($scan['gala'],$scan['pos']))) {
        //
        //		}
        $val = array("mili_prec" => $scan['prec'], "mili_svs" => $scan['svs'], "mili_scanner" => $scan['scanner'], "mili_time" => time());
        $logger->debug(array("message" => "mili update done", "vals" => $val));
    }
    if ($scan['type'] == "news") {
        $val = array("news_prec" => $scan['prec'], "news_svs" => $scan['svs'], "news_scanner" => $scan['scanner'], "news_newsdata" => $scan['newsdata'], "news_time" => time());
    }
    if (!$dbscan['nick'] || strtolower($dbscan['nick']) != strtolower($scan['nick'])) {
        $val['nick'] = $scan['nick'];
    }
    if (strtolower($dbscan['nick']) != strtolower($scan['nick'])) {
        query("update scans set nick = null where lower(nick) = lower('" . mysql_escape_string($scan['nick']) . "')");
    }
    if (count($val)) {
        $updates = array();
        foreach ($val as $key => $value) {
            if (!isset($value)) {
                $value = "NULL";
            } else {
                if (!is_numeric($value)) {
                    $value = "'" . mysql_escape_string($value) . "'";
                }
            }
            $updates[] = "{$key} = {$value}";
        }
        $logger->debug(array("function" => "updateScan", "message" => "before update scans", "vals" => $vals, "updates" => $updates));
        query("update scans set " . join(",", $updates) . " where sid = " . $dbscan['sid']);
    }
    $logger->debug("update scan done");
    return $dbscan['sid'];
}