Пример #1
0
 function Incoming_list()
 {
     $filter =& $_SESSION['incfilter'];
     if (!$filter) {
         $filter['sort'] = "koords";
         $filter['order'] = "asc";
     }
     if ($_REQUEST['sort'] && $_REQUEST['order']) {
         $filter['sort'] = $_REQUEST['sort'];
         $filter['order'] = $_REQUEST['order'];
     }
     $filter['page'] = param_num("page", 1);
     $allylist = getAllyList();
     $formlist = array();
     $formlist[] = array("title" => "Allianz", "value" => 0);
     foreach ($allylist as $ally) {
         $formlist[] = array("title" => "[" . $ally['tag'] . "] " . $ally['name'], "value" => $ally['aid']);
     }
     $form = new formContainer();
     $form->add(new formSelectBox("ally", "Allianz", "numeric", $formlist, false));
     $form->add(new formCheckBox("safe", "Safestatus", "numeric", 1, false));
     $form->add(new formCheckBox("undertime", "unter der Deffzeit", "numeric", 1, false));
     if ($_POST['send']) {
         $form->submit(array("ally", "safe", "undertime"));
         $ally = $form->get("ally");
         $filter['undertime'] = $form->get("undertime");
         $filter['safe'] = $form->get("safe");
         if ($ally && !getAlly($ally)) {
             unset($ally);
         }
         if ($ally) {
             $galalist = getGalaListByAlly($ally, true);
         } else {
             $galalist = getGalaList(true);
         }
         if ($filter['ally'] != $ally) {
             $gala = 0;
         } else {
             $gala = $_POST['gala'];
         }
         $galaitems = array(array("title" => "Galaxie", "value" => 0));
         $selectedgala = 0;
         foreach ($galalist as $item) {
             $galaitem = array("title" => $item, "value" => $item);
             if ($item == $gala) {
                 $galaitem['selected'] = "selected";
                 $selectedgala = $gala;
             }
             $galaitems[] = $galaitem;
         }
         $filter['gala'] = $selectedgala;
         $filter['ally'] = $ally;
     } else {
         if ($filter['ally']) {
             $form->select("ally", $filter['ally']);
             $galalist = getGalaListByAlly($filter['ally'], true);
         } else {
             $galalist = getGalaList(true);
         }
         if ($filter['undertime']) {
             $form->select("undertime", 1);
         }
         if ($filter['safe']) {
             $form->select("safe", 1);
         }
         $galaitems = array(array("title" => "Galaxie", "value" => 0));
         $selectedgala = 0;
         foreach ($galalist as $item) {
             $galaitem = array("title" => $item, "value" => $item);
             if ($filter['gala'] == $item) {
                 $galaitem['selected'] = "selected";
                 $selectedgala = $filter['gala'];
             }
             $galaitems[] = $galaitem;
         }
         $filter['gala'] = $selectedgala;
     }
     $this->template->assign("galalist", $galaitems);
     $sort[$filter['sort']][$filter['order']] = '_active';
     $list = inc_list($filter, &$pages, &$filter['page'], 10, $this->userdata);
     for ($i = 0; $i < count($list); $i++) {
         $canrecallall = 0;
         $_incs = inc_list_byuser($list[$i]['gala'], $list[$i]['pos']);
         foreach ($_incs as $inc) {
             if ($inc['arrival']) {
                 if ($inc['unixeta'] < 0) {
                     $inc['orbit'] = true;
                     $inc['orbittime'] = $this->formattime($inc['unixeta'] + $inc['orbittime'] * 60, true);
                     $inc['eta'] = 0;
                 } else {
                     $inc['eta'] = $this->formattime($inc['unixeta'], true);
                     $inc['orbittime'] = $this->formattime($inc['orbittime'] * 60, true);
                 }
             } else {
                 $inc['eta'] = "n/a";
             }
             if (strlen($inc['nick']) > 20) {
                 $inc['nick'] = substr($nick['nick'], 0, 20) . "..";
             }
             $inc['canrecall'] = 1;
             if ($inc['status'] == 1) {
                 // atter
                 $list[$i]['atterlist'][] = $inc;
             } else {
                 // deffer
                 if (!$inc['uid'] || $inc['aid'] == $this->userdata['aid']) {
                     $inc['canedit'] = 1;
                 }
                 $list[$i]['defferlist'][] = $inc;
             }
             $list[$i]['canrecallall'] = $canrecallall;
             $list[$i]['cansetsave'] = 1;
             $list[$i]['backlink'] = urlencode("takscreen.php#" . $list[$i]['uid']);
         }
         /*      $list[$i]['atterlist'] = atter_list($list[$i]['incid']);
               $list[$i]['defferlist'] = deffer_list($list[$i]['incid']);
               for($j=0;$j < count($list[$i]['atterlist']);$j++){
                 $atter = &$list[$i]['atterlist'][$j];
         
                 if ($atter['unixeta'] < 0) {
                   $atter['orbit'] = $atter['unixeta']+75*60;
                   if ($atter['orbit'] < 0) $atter['orbit'] = 0;
                   $atter['orbit'] = $this->formattime($atter['orbit'],true);
                   $atter['unixeta'] = 0;
                 }
                 $atter['eta'] = $this->formattime($atter['unixeta'],true);
                 if(strlen($atter['inickname']) > 20){
                   $atter['inickname'] = substr($atter['inickname'],0,20)."..";
                 }
         #        if ($atter['ogala'] == $this->userdata['gala']) {
                   $canrecallall=1;
         #        }
               }
               for($j=0;$j < count($list[$i]['defferlist']);$j++){
                 $deffer = &$list[$i]['defferlist'][$j];
                 if ($deffer['unixeta'] < 0) {
                   $deffer['orbit'] = $deffer['unixeta']+$deffer['ticks']*15*60;
                   if ($deffer['orbit'] < 0) $deffer['orbit'] = 0;
                   $deffer['orbit'] = $this->formattime($deffer['orbit'],true);
                   $deffer['unixeta'] = 0;
                 }
                 $deffer['eta'] = $this->formattime($deffer['unixeta'],true);
                 if($deffer['isextern']) {
                   $deffer['nick'] = $deffer['enickname'];
                   $deffer['gala'] = $deffer['egala'];
                   $deffer['pos'] = $deffer['epos'];
                 }
                 if($deffer['aid'] == $this->userdata['aid']) {
                   $deffer['canupdatefleet'] = 1;
                 }
                 if(strlen($deffer['nick']) > 15){
                   $deffer['nick'] = substr($deffer['nick'],0,15)."..";
                 }
         
         #        if ($deffer['uid'] == $this->userdata['uid'] ||
         #        $deffer['ogala'] == $this->userdata['gala']) {
                   $deffer['canrecall'] = 1;
         #        }
               }
         #      if ($list[$i]['gala'] == $this->userdata['gala']) {
         #      }
               $list[$i]['backlink'] = urlencode("takscreen.php#".$list[$i]['incid']);
               */
     }
     $form->registerVars($this->template);
     $this->template->assign("pages", showPageBar($filter['page'], $pages, "takscreen.php?", "page", "menu"));
     $this->template->assign("allylist", $allylist);
     $this->template->assign("sort", $sort);
     $this->template->assign("list", $list);
     $this->show('takscreen_index', "Taktikschirm");
 }
Пример #2
0
function listUser($filter, $pages, $page = 1, $rows = 10)
{
    Assert::isId($page);
    Assert::isId($rows);
    #username
    if ($filter['username']) {
        if ($where) {
            $where .= " and ";
        }
        $where .= " u.nick LIKE '" . mysql_real_escape_string($filter['username']) . "%'";
    }
    #gala
    if ($filter['gala']) {
        Assert::isId($filter['gala']);
        if ($where) {
            $where .= " and ";
        }
        $where .= " u.gala = " . (int) $filter['gala'] . " ";
    }
    #ally
    if ($filter['ally']) {
        Assert::isId($filter['ally']);
        if ($where) {
            $where .= " and ";
        }
        $where .= " ga.aid = " . (int) $filter['ally'] . " ";
        if ($filter['checkallygalas']) {
            $galalist = getGalaListByAlly($filter['ally']);
            if ($galalist) {
                $galalist = getArrayFromList($galalist, "gala");
                $galalist = "(" . join(",", $galalist) . ")";
                $where .= " AND u.gala IN " . $galalist;
            } else {
                $page = 0;
                $pages = 0;
                return;
            }
        }
    }
    #phone
    if ($filter['phone']) {
        if ($where) {
            $where .= " and ";
        }
        $where .= " u.phone LIKE '" . mysql_real_escape_string($filter['phone']) . "%'";
    }
    #group
    if ($filter['group']) {
        Assert::isTrue((int) $filter['group'] >= -1);
        if ($where) {
            $where .= " and ";
        }
        if ((int) $filter['group'] == -1) {
            $where .= " u.gid = 0 ";
        } else {
            $where .= " u.gid = " . (int) $filter['group'];
        }
    }
    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'] == "group") {
        $sort = " groupname ";
    } elseif ($filter['sort'] == "login") {
        $sort = " u.loggedin ";
    } elseif ($filter['sort'] == "fleetupdate") {
        $sort = " u.fleetupdate ";
    } elseif ($filter['sort'] == "koords") {
        $sort = " u.gala " . $order . ", u.pos ";
    } elseif ($filter['sort'] == "phone") {
        $sort = " u.phone ";
    } else {
        $sort = " u.nick ";
    }
    $count = selectsqlLine("\n        select count(*) as count\n        from user u\n        left join galaxy ga on (ga.gala = u.gala)\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 u.*,a.tag,\n\t\t\t\t\tDATE_FORMAT(u.loggedin, '%d.%m.%y') as date,\n\t\t\t\t\tDATE_FORMAT(u.loggedin, '%H:%i') as time,\n\t\t\t\t\tg.name as groupname, g.descr as groupdescr,g.usertitle\n          from user u\n          left join groups  g using(gid)\n          left join galaxy ga on(ga.gala = u.gala)\n          left join alliance a on(a.aid = ga.aid)\n          " . $where . "\n\t\t\t\t\torder by " . $sort . " " . $order . "\n\t\t\t\t\tLIMIT " . $rows * ($page - 1) . ",{$rows}");
    return $return;
}
Пример #3
0
function inc_list($filter, &$pages, $page = 1, $rows = 10, $user = null)
{
    if ($filter['order'] == "asc") {
        $order = "ASC";
    } else {
        $order = "DESC";
    }
    if ($filter['sort'] == "time") {
        $sort = "maxtime " . $order;
    } else {
        $sort = "u.gala " . $order . "," . "u.pos " . $order;
    }
    if ($filter['safe']) {
        $awhere[] = " u.safe = 0 ";
    }
    if ($filter['undertime'] && isset($user)) {
        $allygalas = getGalaListByAlly($user['aid'], true);
        $ohaving[] = "(u.gala = " . $user['gala'] . " and max(fs.arrival)-unix_timestamp() > 15300)";
        $ohaving[] = "(u.gala IN (" . join(",", $allygalas) . ") and max(fs.arrival)-unix_timestamp() > 17100)";
        $ohaving[] = "(max(fs.arrival)-unix_timestamp() > 18900)";
        $having = "HAVING (" . join(" OR ", $ohaving) . ")";
    }
    if ($filter['ally']) {
        $awhere[] = " g.aid = " . $filter['ally'] . " ";
    }
    if ($filter['gala']) {
        $awhere[] = " fs.tgala = " . $filter['gala'] . " ";
    }
    if ($awhere) {
        $where = " where " . join("AND", $awhere);
        $where2 = join("AND", $awhere);
        $where3 = "AND " . join("AND", $awhere);
    }
    $victims = selectsql("\n        select *,max(arrival) as maxtime\n        from fleet_status fs, user u, galaxy g\n        where \n        u.gala = fs.tgala and\n        u.pos = fs.tpos and\n        g.gala = u.gala and\n        fs.status = 1 \n        {$where3}\n        group by u.uid\n        {$having}\n        order by {$sort}\n        ", "uid");
    #Seitenamzahl berechnen
    #  echo " pages: ".$pages;
    #  echo " page: ".$page;
    $pages = ceil(count($victims) / $rows);
    #Seite checken
    if ($pages < $page && $pages != 0) {
        $page = $pages;
    }
    if (!$victims) {
        return array();
    }
    $victims = array_splice($victims, ($page - 1) * $rows, $rows);
    #echo " pages: ".$pages;
    #echo " page: ".$page;
    return selectsql("\n    select u.*,g.*,a.*,max(arrival) as maxtime\n    from fleet_status fs, user u,galaxy g, alliance a\n    where \n    u.gala = fs.tgala and\n    u.pos = fs.tpos and\n    g.gala = u.gala and\n    a.aid = g.aid and \n    fs.return_flight != 1 \n    and u.uid IN (" . join(",", $victims) . ") \n    group by u.uid\n    order by {$sort}\n    ");
}