Esempio n. 1
0
function listGalaxys($filter, $pages, $page, $rows)
{
    if ($filter && is_array($filter)) {
        if ($filter['sort'] == "tag") {
            $sort = " a.tag ";
        } elseif ($filter['sort'] == "member") {
            $sort = " member ";
        } else {
            $sort = " ga.gala ";
        }
        if ($filter['order'] == "asc") {
            $order = " ASC ";
        } else {
            $order = " DESC ";
        }
    } else {
        $sort = " ga.gala ";
        $order = " asc ";
    }
    if ($filter['ally']) {
        $awhere[] = " ga.aid = " . $filter['ally'];
    }
    if ($awhere) {
        $where = " where " . implode("AND", $awhere);
    }
    $count = selectsqlLine("select count(*) as count from galaxy ga " . $where);
    #Seitenamzahl berechnen
    $pages = ceil($count['count'] / $rows);
    #Seite checken
    if ($pages < $page && $pages != 0) {
        $page = $pages;
    }
    return selectsql("\n    select a.*,count(u.uid) as member,ga.*\n    from galaxy ga\n    left join alliance a on (a.aid = ga.aid)\n    left join user u on (u.gala = ga.gala)\n    " . $where . "\n    group by (ga.gala)\n    order by {$sort} {$order}\n    LIMIT " . $rows * ($page - 1) . ",{$rows}");
}
Esempio n. 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;
}
Esempio n. 3
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;
}
Esempio n. 4
0
function getNews($id)
{
    if (!is_numeric($id)) {
        return;
    }
    return selectsqlLine("select n.*,u.*,g.usertitle,count(cn.cid) as comments,DATE_FORMAT(n.time, '%d.%m.%y') as ndate,\n\t\t\t\t\t\t\tDATE_FORMAT(n.time, '%H:%i') as ntime \n\t\t\t\t\t\t\t\tfrom news n\n\t\t\t\t\t\t\t\tleft join  user u on (u.uid = n.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\tleft join com_news cn on (cn.nid = n.nid)\n\t\t\t\t\t\t\t\twhere n.nid = {$id} group by n.nid ");
}
Esempio n. 5
0
function getAllyByTag($tag)
{
    return selectsqlLine("\n    select * from alliance where tag = '{$tag}'\n    ");
}
Esempio n. 6
0
function getGroupByName($name)
{
    if (!$name) {
        echo "db.group:getGroupByName Fehlender Parameter!";
        return;
    }
    return selectsqlLine("select * from groups where name = '{$name}'");
}
Esempio n. 7
0
function fleet_get($fid)
{
    if (!$fid || !is_numeric($fid)) {
        return;
    }
    return selectsqlLine("select * from fleet where fid = {$fid}");
}