Esempio n. 1
0
 function parser_fleet()
 {
     $form = new formContainer();
     $form->add(new formInput("data", "Flottendaten", "string"));
     if ($_POST['send']) {
         $form->submit();
         if (!$form->hasErrors()) {
             $text = $form->get("data");
             $items = parse_taktikansicht($text);
             if ($items) {
                 foreach ($items as $item) {
                     $nick = $item['nick'];
                     $gala = $item['gala'];
                     $pos = $item['pos'];
                     $user = getUserByPos($gala, $pos);
                     if (!$user) {
                         $parse_errors[] = "({$gala}:{$pos}) {$nick} nicht im System";
                         continue;
                     }
                     if (strtolower($user['nick']) != strtolower($nick)) {
                         $parse_errors[] = "({$gala}:{$pos}) {$nick} hat falschen GN-Nick oder ist ungültig";
                     }
                     user_fleets_update($user['uid'], $item['fleets']);
                     user_deff_update($user['uid'], $item['deff']);
                     $parse_messages[] = "({$gala}:{$pos}) {$nick} erkannt";
                 }
                 $this->template->assign("parse_messages", $parse_messages);
                 $this->template->assign("parse_errors", $parse_errors);
             } else {
                 $form->setError("data");
                 $form->addError("Es wurde nichts erkannt!");
             }
         }
     }
     $form->registerVars(&$this->template);
     $this->show('takscreen_parser_fleet', 'Flotten/Deff parsen');
 }
Esempio n. 2
0
 function User_fleet_parser()
 {
     $id = param_num("id");
     if ($id) {
         $user = getUserByID($id);
         if (!$user) {
             $this->_header();
         }
         $this->template->assign("id", $id);
     } else {
         $id = $this->userdata['uid'];
     }
     $data = $_SESSION['steps'];
     #information message, step 2
     if ($data['fleetparser']) {
         #unset step
         unset($data['fleetparser']);
         $_SESSION['steps'] = $data;
         $this->forms['information']['url'] = $this->backtracking->backlink();
         $this->forms['information']['title'] = "Flotte/Deff updaten";
         $this->forms['information']['message'] = "Flotte/Deff aktualisiert";
         $this->forms['information']['style'] = "green";
         $this->show('message_information', "Flotte/Deff updaten");
     }
     $form = new formContainer();
     $form->add(new formInput("fleet", "Text", "string"));
     if ($_POST['send'] && $_POST['next_x']) {
         $form->submit();
         if (!$form->hasErrors()) {
             $text = $form->get("fleet");
             if (!($taktik = parse_taktikansicht($text))) {
                 $fleets = parse_user_flottenbewegung($text, $this->userdata["gala"], $this->userdata["pos"]);
                 //echo "<pre>".print_r($fleets,1)."</pre>";
                 $deff = parse_user_verteidigung($text);
                 if ($fleets === false && $deff === false) {
                     $form->setError("fleet");
                     $form->addError("es konnte nichts erkannt werden");
                 }
             } else {
                 $fleets = $taktik[0]['fleets'];
                 $deff = $taktik[0]['deff'];
             }
             if (!$form->hasErrors()) {
                 $_SESSION['steps']['fleetparser'] = 1;
                 if (!($fleets === false)) {
                     user_fleets_update($id, $fleets);
                 }
                 if (!($deff === false)) {
                     user_deff_update($id, $deff);
                 }
                 $this->_header("user.php?action=fleetparser&send");
             }
         }
     }
     $form->registerVars($this->template);
     $this->show("user_fleetupdate_parser", "Flottenupdate");
 }