Example #1
0
 function parser_takscreen()
 {
     function parse_time($timedata)
     {
         $timelist = array();
         #mode1
         preg_match_all("/(\\d+?)\\sMin/ism", $timedata, $tak_timelist, PREG_SET_ORDER);
         if (count($tak_timelist)) {
             for ($j = 0; $j < count($tak_timelist); $j++) {
                 $timelist[] = $tak_timelist[$j][1];
             }
         } else {
             #mode3
             preg_match_all("/(\\d{1,2}):(\\d{1,2}):(\\d{1,2})/ism", $timedata, $tak_timelist_mode3, PREG_SET_ORDER);
             if (count($tak_timelist_mode3)) {
                 for ($j = 0; $j < count($tak_timelist_mode3); $j++) {
                     $timelist[] = $tak_timelist_mode3[$j][1] * 60 + $tak_timelist_mode3[$j][2];
                 }
             } else {
                 #mode4
                 preg_match_all("/(\\d{1,2}):(\\d{1,2})/ism", $timedata, $tak_timelist_mode4, PREG_SET_ORDER);
                 if (count($tak_timelist_mode4)) {
                     for ($j = 0; $j < count($tak_timelist_mode4); $j++) {
                         $timelist[] = $tak_timelist_mode4[$j][1] * 60 + $tak_timelist_mode4[$j][2];
                     }
                 } else {
                     #mode 5
                     preg_match_all("/(\\d{1,2})/ism", $timedata, $tak_timelist_mode5, PREG_SET_ORDER);
                     if (count($tak_timelist_mode5)) {
                         for ($j = 0; $j < count($tak_timelist_mode5); $j++) {
                             $timelist[] = $tak_timelist_mode5[$j][1] * 15;
                         }
                     } else {
                         $timelist[] = "error";
                     }
                 }
             }
         }
         return $timelist;
     }
     $form = new formContainer();
     $form->add(new formCheckBox("parse_user", "User parsen", "numeric", array(1), false));
     $form->add(new formCheckBox("parse_atter", "Atter parsen", "numeric", array(1), false));
     $form->add(new formCheckBox("parse_deffer", "Deffer parsen", "numeric", array(1), false));
     $form->add(new formInput("data", "Taktikschirmdaten", "string"));
     if ($_POST['userparse_step2']) {
         //parse userfleets, step 2
         $uids = split(",", urldecode($_POST['uids']));
         if ($uids && is_array($uids) && count($uids)) {
             $user = getUserbyID($uids[0]);
             $allygalas = getGalaListByAlly($user['aid'], true);
             $metagalas = getGalaList(true);
             foreach ($uids as $uid) {
                 $fleetdata = split("#", $_POST["user_" . $uid]);
                 $fleetdata[0] = split(",", urldecode($fleetdata[0]));
                 $fleetdata[1] = split(",", urldecode($fleetdata[1]));
                 #          echo "fleetdata:<br>";
                 #          echo "<br>";
                 for ($i = 0; $i < 2; $i++) {
                     #            echo"<br>";var_dump($fleetdata[$i]);echo"<br>";
                     if ($fleetdata[$i][0]) {
                         // do_update
                         if ($fleetdata[$i][1]) {
                             // do selectbox
                             $id = $_POST["select_" . $uid . "_" . ($i + 1)];
                             if (!$id || !is_numeric($id)) {
                                 continue;
                             }
                             if ($_POST["select_" . $uid . "_1"] == $_POST["select_" . $uid . "_2"]) {
                                 continue;
                             }
                             $id--;
                         } else {
                             // else
                             $id = $i;
                         }
                         $status = $fleetdata[$id][2];
                         $gala = $fleetdata[$id][3];
                         $pos = $fleetdata[$id][4];
                         $eta = $fleetdata[$id][5];
                         $return_flight = $fleetdata[$id][6];
                         if (!$return_flight) {
                             if ($status == 1) {
                                 $ticks = 5;
                                 $returntime = 450;
                             } elseif ($status == 2) {
                                 $ticks = 20;
                                 if ($gala == $user['gala']) {
                                     $returntime = 270;
                                 } elseif (in_array($gala, $allygalas)) {
                                     $returntime = 300;
                                 } elseif (in_array($gala, $metagalas)) {
                                     $returntime = 330;
                                 } else {
                                     $returntime = 360;
                                 }
                             }
                         }
                         #              echo "$uid: flotte ".($i+1).": do_update: ".$fleetdata[$i][0].", do_selectbox: ".$fleetdata[$i][1].", status: $status, gala: $gala, pos: $pos, eta: $eta, return_flight: $return_flight <br>";
                         User_fleet_status_update($uid, $id + 1, $status, $return_flight, floor($eta / 60), $gala, $pos, $ticks, $returntime);
                     }
                 }
             }
             // foreach
         }
         // if uids
         $this->_header("takscreen.php?action=takparser");
         exit;
     } elseif ($_POST['takscreenparse_step1']) {
         $form->submit();
         if (!$form->hasErrors()) {
             #echo $data."<br><br>";
             $data = stripslashes($form->get("data"));
             if (preg_match("/Sektor(.*?)<\\/table>/ism", $data, $res)) {
                 $res[1] = preg_replace("/<a.*?\\>(.*?)<\\/a>/ism", "\$1", $res[1]);
                 $res[1] = preg_replace("/<nobr>(.*?)<\\/nobr>/ism", "\$1", $res[1]);
                 $res[1] = preg_replace("/<span.*?\\>(.*?)<\\/span>/ism", "\$1", $res[1]);
                 $res[1] = preg_replace("/\\*/ism", "", $res[1]);
                 $res[1] = html_entity_decode($res[1]);
                 preg_match_all("/<tr[^>]*?class=\"r\"\\>\\s*?" . "<td.*?\\>.*?(\\d{1,4}):(\\d{1,2}).*?<\\/td>\\s*?" . "<td.*?\\>(.*?)<\\/td>\\s*?" . "<td.*?\\>(.*?)<\\/td>\\s*?" . "<td.*?\\>(.*?)<\\/td>\\s*?" . "<td.*?\\>(.*?)<\\/td>\\s*?" . "<td.*?\\>(.*?)<\\/td>\\s*?" . "<td.*?\\>(.*?)<\\/td>\\s*?" . "<td.*?\\>(.*?)<\\/td>\\s*?" . "<td.*?\\>(.*?)<\\/td>\\s*?" . "<td.*?\\>(.*?)<\\/td>\\s*?" . "<\\/tr>/ism", $res[1], $res, PREG_SET_ORDER);
                 $galalist = getGalaList();
                 $parse_messages = array();
                 for ($i = 0; $i < count($res); $i++) {
                     #print_r($res[$i]);
                     $line =& $res[$i];
                     $gala = $line[1];
                     $pos = $line[2];
                     $nick = trim($line[3]);
                     $user = getUserByPos($gala, $pos);
                     if ($user) {
                         $parse_messages[] = "<b>User " . $user['nick'] . " (" . $user['gala'] . ":" . $user['pos'] . ") aktualisiert</b>";
                         if (strtolower($user['nick']) != strtolower($nick)) {
                             $parse_errors[] = "<span class=\"red\"><b>" . $user['nick'] . " (" . $user['gala'] . ":" . $user['pos'] . ") hat falschen GN Nick oder ist ungültig</b></span>";
                             #echo "'".strtolower($nick)."' <> '".strtolower($user['nick'])."' <br>";
                         }
                         #atter matching
                         if ($form->get("parse_atter")) {
                             $this->_match_atter($gala, $pos, $line, &$parse_messages, &$parse_errors);
                         }
                         #deffer
                         if ($form->get("parse_deffer")) {
                             $this->_match_deffer($gala, $pos, $line, &$parse_messages, &$parse_errors);
                         }
                         /*              #parse user
                                       if($form->get("parse_user")) {
                                         $this->_match_user(&$user,$line,&$fleet_select);
                                         $uids[] = $user['uid'];
                                         $userparse_list[] = $user;
                                       }*/
                     } else {
                         $parse_errors[] = "<b>User " . $nick . " (" . $gala . ":" . $pos . ") existiert nicht in der Datenbank</b>";
                     }
                 }
                 // result
                 if ($form->get("parse_user")) {
                     $this->template->assign("uids", urlencode(join(",", $uids)));
                     $this->template->assign("userparse", $form->get("parse_user"));
                     $this->template->assign("userparse_list", $userparse_list);
                 }
                 $this->template->assign("parse_errors", $parse_errors);
                 $this->template->assign("parse_messages", $parse_messages);
                 $form->registerVars(&$this->template);
                 $this->show('takscreen_parser_takscreen_step2', 'Taktikschirm parsen');
                 exit;
             } else {
                 $parse_errors[] = "Taktikschirm nicht erkannt";
             }
         }
     } else {
         $parse_errors[] = "<b>ACHTUNG!</b> Unbedingt darauf achten dass euer Taktikschirm nicht älter als 15 min ist!";
         $form->select("parse_user", 0);
         $form->select("parse_deffer", 1);
         $form->select("parse_atter", 1);
     }
     $this->template->assign("parse_errors", $parse_errors);
     $form->registerVars(&$this->template);
     $this->show('takscreen_parser_takscreen', 'Taktikschirm parsen');
 }
Example #2
0
			<div id="content_2" class="content">
			<table width="100%" height="100%" id="loader2"><tr>
  <td align="center" valign="middle"><img src="<?php 
echo $sitepath;
?>
images/loading.gif" width="16" height="16"/>&nbsp;&nbsp;<b>Loading, Please Wait...</b></td></tr></table>
			<div id="panel2">
	<?php 
if ($artikel) {
    ?>
		<font size="+1"><?php 
    echo $title;
    ?>
</font><small><br/>
		<i>Ditulis oleh <?php 
    echo getUserbyID($artikel[1]);
    ?>
 pada <?php 
    echo date("d M Y H:i", $artikel[2]);
    ?>
</i></small>
		<br/><br/>
		<?php 
    echo $artikel[4];
    ?>
	<?php 
} else {
    ?>
		<font size="+1">404</font>
		<p><i>Maaf, halaman yang anda cari tidak ditemukan</i></p>
	<?php 
Example #3
0
require_once 'Models/Users.php';
//--------------------------->>>
function getUserbyID($user, $username)
{
    $result = $user->getUser($username);
    $contact = $result->fetch_array(MYSQLI_ASSOC);
    return $contact;
}
//--------------------------->>>
session_start();
if (isset($_SESSION["username"])) {
    header("Location: http://localhost:8888/ContactsBook/main.php");
}
if (isset($_POST["submit"])) {
    $user = new Users();
    $valor = getUserbyID($user, $_POST["usname"]);
    $pass = md5($_POST["pssword"]);
    if (!$valor) {
        $pos = 1;
    } elseif ($valor['password'] === $pass) {
        session_start();
        $_SESSION["username"] = $valor['name'];
        $_SESSION["user"] = $valor['username'];
        header("Location: http://localhost:8888/ContactsBook/main.php");
    } else {
        $pos = 1;
    }
}
//--------------------------->>>
?>
<!DOCTYPE html>