Ejemplo n.º 1
0
function user_fleets_update($uid, $fleets)
{
    Assert::isId($uid);
    $user = getUserByID($uid);
    if (!$user) {
        trigger_error("user not found", E_USER_ERROR);
        return false;
    }
    $userfleets = user_fleet_list_byuser($uid);
    if (!$userfleets || !is_array($userfleets)) {
        trigger_error("user fleets for user {$uid} not found", E_USER_ERROR);
        return false;
    }
    #fleetstatus_delete_bykoords($user['gala'],$user['pos']);
    foreach ($userfleets as $fleet) {
        if (isset($fleets[$fleet['fleetnum']])) {
            fleet_update($fleet['fid'], $fleets[$fleet['fleetnum']]);
            #$fleets[$fleet['fleetnum']]['fleetnum'] = $fleet['fleetnum'];
            #fleetstatus_add($fleets[$fleet['fleetnum']]);
        }
    }
    query("update user set fleetupdate = unix_timestamp() where uid = {$uid}");
}
Ejemplo n.º 2
0
 function _loadFleetBox()
 {
     $list = user_fleet_list_byuser($this->userdata['uid']);
     for ($i = 1; $i < 3; $i++) {
         $item = $list[$i];
         if ($item['arrival']) {
             $item['eta'] = $item['arrival'] - time();
             $item['orbit'] = $item['ticks'] * 15 * 60;
             if ($item['eta'] < 0) {
                 $item['orbit'] = $item['orbit'] + $item['eta'];
                 $item['eta'] = 0;
                 if ($item['orbit'] < 0) {
                     $item['orbit'] = 0;
                 }
             }
             $item['eta'] = $this->formattime($item['eta'], true);
             $item['orbit'] = $this->formattime($item['orbit'], true);
         }
         $item['num'] = $i;
         $fleets[] = $item;
     }
     $this->box['fleets']['title'] = 'Flottenstatus';
     $this->box['fleets']['list'] = $fleets;
     $this->box['fleets']['template'] = 'box_fleets_content.html';
 }
Ejemplo n.º 3
0
 function Incoming_details()
 {
     if (!($id = param_num("id")) || !($inc = getuserbyid($id))) {
         $this->_header();
     }
     if (!($incfleets = inc_list_byuser($inc['gala'], $inc['pos']))) {
         $this->_header();
     }
     $result = user_fleet_list_byuser($id);
     //atter-deffersummen
     $deffersum = array();
     $attersum = array();
     $checkfleet = array("jaeger" => "Jäger", "bomber" => "Bomber", "fregatten" => "Fregatten", "zerstoerer" => "Zerstörer", "kreuzer" => "Kreuzer", "schlachter" => "Schlachter", "traeger" => "Träger", "kleptoren" => "Kleptoren", "cancris" => "Cancris");
     for ($i = 0; $i < count($result); $i++) {
         if ($result[$i]['return_flight']) {
             $result[$i]['name'] = "Rückflug";
             $result[$i]['class'] = "class=\"blue\"";
         } else {
             if ($result[$i]['status'] == 1) {
                 $result[$i]['name'] = "Angriff";
                 $result[$i]['class'] = "class=\"red\"";
             } elseif ($result[$i]['status'] == 2) {
                 $result[$i]['name'] = "Verteidigung";
                 $result[$i]['class'] = "class=\"green\"";
             } else {
                 $result[$i]['name'] = "Im Orbit";
             }
         }
         if ($result[$i]['tgala']) {
             $result[$i]['name'] .= " (" . $result[$i]['tgala'] . ":" . $result[$i]['tpos'] . ")";
         }
         if ($result[$i]['status']) {
             if ($result[$i]['arrival']) {
                 $eta = $result[$i]['arrival'] - time();
                 if ($eta < 0) {
                     $result[$i]['name'] .= " im Orbit: " . $this->formattime($result[$i]['orbittime'] * 60 + $eta, true);
                 } else {
                     $result[$i]['name'] .= " ETA " . $this->formattime($eta, true);
                 }
             } else {
                 $result[$i]['name'] .= "ETA n/a";
             }
         }
         // flotte im orbit
         if (!$result[$i]['status']) {
             foreach ($checkfleet as $key => $val) {
                 $deffersum[$key] += $result[$i][$key];
             }
         }
     }
     $this->template->assign("userfleet", $result);
     $fleetfilter = get_fleet_filter($this->userdata);
     // flottenfilter, eta formatierung
     $atter = 0;
     $deffer = 0;
     $atterlist = array();
     $defferlist = array();
     // kann editieren
     if ($inc['aid'] == $this->userdata['aid']) {
         $inc['canedit'] = 1;
     }
     $inc['cansetsafe'] = 1;
     foreach ($incfleets as $fleet) {
         if ($fleet['status'] == 1) {
             $inc['atter']++;
         } elseif ($fleet['status'] == 2) {
             $inc['deffer']++;
         }
         if (count($fleetfilter)) {
             if ($fleet['fsid'] && in_array($fleet['fsid'], $fleetfilter)) {
                 if ($fleet['status'] == 1) {
                     $inc['atter_filter'] = 1;
                 } elseif ($fleet['status'] == 2) {
                     $inc['deffer_filter'] = 1;
                 }
                 continue;
             }
         }
         if ($fleet['arrival']) {
             $eta = $fleet['arrival'] - time();
             if ($eta < 0) {
                 $fleet['eta'] = "im Orbit: " . $this->formattime($fleet['orbittime'] * 60 + $eta, true);
             } else {
                 $fleet['eta'] = $this->formattime($eta);
                 $fleet['title'] = $this->formattime($fleet['orbittime'] * 60, true) . " im Orbit";
             }
         }
         $fleet['canrecall'] = 1;
         if ($fleet['status'] == 2) {
             $deffer++;
             if (!$fleet['uid'] || $fleet['aid'] == $this->userdata['aid']) {
                 $fleet['canedit'] = 1;
             }
             $defferlist[] = $fleet;
             foreach ($checkfleet as $key => $val) {
                 $deffersum[$key] += $fleet[$key];
             }
         } elseif ($fleet['status'] == 1) {
             $atter++;
             $fleet['canedit'] = 1;
             $atterlist[] = $fleet;
             foreach ($checkfleet as $key => $val) {
                 $attersum[$key] += $fleet[$key];
             }
         }
     }
     if (!$inc['atter']) {
         $this->_header();
     }
     $inc['canupdateatter'] = 1;
     $this->template->assign("attersum", $attersum);
     $this->template->assign("deffersum", $deffersum);
     $this->template->assign("ircattdata", generate_irc_inc_summary($inc, $attersum, $deffersum));
     $this->template->assign("defferlist", $defferlist);
     if ($inc['fleetupdate']) {
         $inc['fleetupdate'] = formatdate_unix("d.m.Y", $inc['fleetupdate']) . ", " . date("H:i", $inc['fleetupdate']) . " Uhr";
     } else {
         $inc['fleetupdate'] = "noch nie";
     }
     if ($inc['deffupdate']) {
         $inc['deffupdate'] = formatdate_unix("d.m.Y", $inc['deffupdate']) . ", " . date("H:i", $inc['deffupdate']) . " Uhr";
     } else {
         $inc['deffupdate'] = "noch nie";
     }
     $inc['cansetsave'] = 1;
     $inc['canrecallall'] = 1;
     $inc['fleetfilter_set'] = 1;
     $this->template->assign("inc", $inc);
     $this->template->assign("atterlist", $atterlist);
     #$_SESSION['backlink'] = urlencode("takscreen.php?action=details&id=$id");
     $this->show('takscreen_inc_details', "Taktikschirm");
 }
Ejemplo n.º 4
0
 function User_fleet_manuell()
 {
     $id = param_num("id");
     if ($id) {
         $user = getUserByID($id);
         if (!$user || $user['aid'] != $this->userdata['aid']) {
             $this->_header();
         }
         $this->template->assign("id", $id);
     } else {
         $id = $this->userdata['uid'];
     }
     $data = $_SESSION['steps'];
     #information message, step 2
     if ($data['fleetmanuell']) {
         #unset step
         unset($data['fleetmanuell']);
         $_SESSION['steps'] = $data;
         $this->forms['information']['url'] = $this->backtracking->backlink();
         $this->forms['information']['title'] = "Flotte updaten";
         $this->forms['information']['message'] = "Flotte aktualisiert";
         $this->forms['information']['style'] = "green";
         $this->show('message_information', "Flotte updaten");
     }
     $names = array("Jäger" => "jaeger", "Bomber" => "bomber", "Fregatten" => "fregatten", "Zerstörer" => "zerstoerer", "Kreuzer" => "kreuzer", "Schlachtschiffe" => "schlachter", "Träger" => "traeger", "Kleptoren" => "kleptoren", "Schutzschiffe" => "cancris");
     $fleets = user_fleet_list_byuser($id);
     $form = new formContainer();
     foreach ($names as $title => $name) {
         for ($i = 0; $i < 3; $i++) {
             $form->add(new formInput($name . $i, $title, "numeric"));
         }
     }
     if ($_POST['send'] && $_POST['next_x']) {
         $form->submit();
         if (!$form->hasErrors()) {
             $_result = array();
             foreach ($fleets as $fleet) {
                 foreach ($names as $title => $name) {
                     $_result[$fleet['fleetnum']][$name] = $form->get($name . $fleet['fleetnum']);
                 }
             }
             user_fleets_update($id, $_result);
             $_SESSION['steps']['fleetmanuell'] = 1;
             $this->_header("user.php?action=fleetmanuell&send");
         }
     } else {
         foreach ($fleets as $fleet) {
             $num = $fleet['fleetnum'];
             foreach ($names as $key => $name) {
                 $val =& $fleet[$name];
                 if ($val) {
                     $form->set($name . $num, $val);
                 } else {
                     $form->set($name . $num, 0);
                 }
             }
         }
     }
     #    $this->template->assign("errors",$errors);
     #    $this->template->assign("items",$items);
     $form->registerVars($this->template);
     $this->show("user_fleetupdate_manuell", "Flottenupdate");
 }