コード例 #1
0
ファイル: szpiedzy.php プロジェクト: WlasnaGra/Tribal2
<?php

if (!empty($_POST['cel']) && !empty($_POST['jednostki'])) {
    require_once 'funkcje/wyslij_szpiegow.php';
    $error = wyslij_szpiegow($User, $_POST['cel'], $_POST['jednostki']);
    echo $error . "<hr/>";
}
if (!empty($_GET['przerwij'])) {
    require_once 'funkcje/zawroc_szpiegow.php';
    $error = zawroc_szpiegow($User, $_GET['przerwij']);
    echo $error . "<hr/>";
}
$szpiedzy = mysql_fetch_array(mysql_query("select * from tribal_jednostki left join tribal_jednostki_miasta on jednostka = jednostka_id where miasto_id = " . $User['id_miasta'] . " and jednostka = 5"));
if (empty($szpiedzy)) {
    echo "nie posiadasz szpiegów/zwiadowców<hr/>";
} else {
    echo "\n\t<form action='?akcja=szpiedzy' method='post'>\n\t<table>\n\t<tr>\n\t\t<th></th>\n\t\t<th>ilość</th>\n\t\t<th>poślij</th>\n\t</tr>\n\t\n\t\t<tr style='text-align:center'>\n\t\t\t<td>" . $szpiedzy['nazwa'] . "</td>\n\t\t\t<td>" . $szpiedzy['ilosc'] . "</td>\n\t\t\t<td>\n\t\t\t\t<input type='text' name='jednostki' value='0'>\n\t\t\t</td>\n\t\t</tr>\n\t<tr>\n\t\t<td colspan=3>\n\t\t\tcel: <input type='text' name='cel' value='" . $_GET['cel'] . "'> <input type='submit' value='zaatakuj'/>\n\t\t</td>\n\t</tr>\n\t</table>\n\n\t</form>\n\t";
}
$ataki = mysql_query("select * from  tribal_eventy  inner join tribal_miasta on podtyp = miasto where (typ = 20 or typ = 21) and miasto_id =" . $User['id_miasta']);
if (mysql_num_rows($ataki) > 0) {
    echo "\n\t<table>\n\t<tr>\n\t\t<th>cel</th>\n\t\t<th>pozostało</th>\n\t</tr>\n\t";
    $ref = $ataki[0]['koniec'] - time();
    header('refresh:' . $ref);
    while ($atak = mysql_fetch_array($ataki)) {
        $pozostało = $atak['koniec'] - time();
        if ($atak['typ'] == 20) {
            $tekst = "szpiedzy kierują się na miasto " . $atak['nazwa'];
            echo "\n\t\t\t<tr>\n\t\t\t\t<td>" . $tekst . "</td>\n\t\t\t\t<td><span id='a" . $atak['event'] . "'></span><script type='text/javascript'>liczCzas('a" . $atak['event'] . "'," . $pozostało . ")</script><a href='?akcja=szpiedzy&przerwij=" . $atak['event'] . "'>[ x ]</a></td>\n\t\t\t</tr>";
        } else {
            $tekst = "szpiedzy powracają z miasta " . $atak['nazwa'];
            echo "\n\t\t\t<tr>\n\t\t\t\t<td>" . $tekst . "</td>\n\t\t\t\t<td><span id='a" . $atak['event'] . "'></span><script type='text/javascript'>liczCzas('a" . $atak['event'] . "'," . $pozostało . ")</script></td>\n\t\t\t</tr>";
コード例 #2
0
ファイル: szpiedzy.php プロジェクト: WlasnaGra/Tribal
<?php

if (!empty($_POST['cel']) && !empty($_POST['jednostki'])) {
    fx('wyslij_szpiegow');
    $error = wyslij_szpiegow($gracz, $_POST['cel'], $_POST['jednostki']);
    echo $error . "<hr/>";
}
if (!empty($_GET['przerwij'])) {
    fx('zawroc_szpiegow');
    $error = zawroc_szpiegow($gracz, $_GET['przerwij']);
    echo $error . "<hr/>";
}
$szpiedzy = row("select * from tribal_jednostki left join tribal_jednostki_miasta on jednostka = jednostka_id where miasto_id = " . $gracz['id_miasta'] . " and jednostka = 5");
if (!is_array($szpiedzy)) {
    echo "nie posiadasz szpiegów/zwiadowców<hr/>";
} else {
    echo "\n\t<form action='?akcja=szpiedzy' method='post'>\n\t<table>\n\t<tr style='background:#CCC8B3'>\n\t\t<th>nazwa</th>\n\t\t<th>ilość</th>\n\t\t<th>poślij</th>\n\t</tr>\n\t\n\t\t<tr style='text-align:center'>\n\t\t\t<td>" . $szpiedzy['nazwa'] . "</td>\n\t\t\t<td>" . $szpiedzy['ilosc'] . "</td>\n\t\t\t<td>\n\t\t\t\t<input type='text' name='jednostki' value='0'>\n\t\t\t</td>\n\t\t</tr>\n\t<tr style='background:#CCC8B3'>\n\t\t<td colspan=3>\n\t\t\tcel: <input type='text' name='cel' value='" . $_GET['cel'] . "'> <input type='submit' value='zaatakuj'/>\n\t\t</td>\n\t</tr>\n\t</table>\n\n\t</form>\n\t";
}
$ataki = all("select * from  tribal_eventy  inner join tribal_miasta on podtyp = miasto where (typ = 20 or typ = 21) and miasto_id =" . $gracz['id_miasta']);
if (is_array($ataki)) {
    echo "\n\t<table>\n\t<tr>\n\t\t<th>cel</th>\n\t\t<th>pozostało</th>\n\t</tr>\n\t";
    $ref = $ataki[0]['koniec'] - time();
    refresh($ref);
    foreach ($ataki as $atak) {
        $pozostało = $atak['koniec'] - time();
        if ($atak['typ'] == 20) {
            $tekst = "szpiedzy kierują się na miasto " . $atak['nazwa'];
            echo "\n\t\t\t<tr>\n\t\t\t\t<td>" . $tekst . "</td>\n\t\t\t\t<td><span id='a" . $atak['event'] . "'></span><script type='text/javascript'>liczCzas('a" . $atak['event'] . "'," . $pozostało . ")</script><a href='?akcja=szpiedzy&przerwij=" . $atak['event'] . "'>[ x ]</a></td>\n\t\t\t</tr>";
        } else {
            $tekst = "szpiedzy powracają z miasta " . $atak['nazwa'];
            echo "\n\t\t\t<tr>\n\t\t\t\t<td>" . $tekst . "</td>\n\t\t\t\t<td><span id='a" . $atak['event'] . "'></span><script type='text/javascript'>liczCzas('a" . $atak['event'] . "'," . $pozostało . ")</script></td>\n\t\t\t</tr>";