Esempio n. 1
0
 public function isIdArray($num, $message = null)
 {
     if (!$message) {
         $message = "check for id array";
     }
     if (is_array($num)) {
         if (count($num) > 0) {
             for ($i = 0; $i < count($num); $i++) {
                 Assert::isId($num[$i], $message . ", id at index " . $i . " invalid");
             }
         } else {
             trigger_error($message . ", id array is empty", E_USER_ERROR);
         }
     } else {
         Assert::isId($num, $message . ", ");
     }
 }
Esempio n. 2
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. 3
0
function fleet_update($fid, $fleet)
{
    Assert::isId($fid);
    $logger =& LoggerManager::getLogger("db.takscreen");
    $logger->debug(array("function" => "fleet_update", "fid" => $fid, "fleet" => $fleet));
    $checkfleet = array("jaeger", "bomber", "fregatten", "zerstoerer", "kreuzer", "schlachter", "traeger", "kleptoren", "cancris");
    $update = array();
    foreach ($checkfleet as $key) {
        if (isset($fleet[$key]) && is_numeric($fleet[$key])) {
            $update[] = "{$key} = " . (int) $fleet[$key];
        } else {
            $update[] = "{$key} = 0";
        }
    }
    return query("\n      update fleet set " . join(",", $update) . " where fid = {$fid}\n    ");
    $logger->debug("fleetupdate done");
}
Esempio n. 4
0
function miliscan_fleet_get_bykoords($gala, $pos, $num)
{
    Assert::isId($gala);
    Assert::isId($pos);
    Assert::isNumeric($num);
    return selectsqlline("\n    select * from scans s\n      left join scanmili_fleet mf using(sid)\n      left join fleet f on (f.fid = mf.fid)\n      where s.gala = {$gala} and s.pos = {$pos} and mf.num = {$num}\n  ");
}