Example #1
0
function zaloz_ciuch($gracz, $id)
{
    $gracz = (int) $gracz;
    $id = (int) $id;
    $dane = row("select * from driver_gracze where gracz = " . $gracz);
    $ciuch = row($q = "select * from driver_ciuchy_gracze   inner join driver_ciuchy on id = c_id and gracz_id = " . $gracz . " where id = {$id} and status = 0 and gracz_id = " . $gracz . "");
    if (empty($ciuch)) {
        return "nie masz takiego sprzętu";
    } else {
        switch ($ciuch['typ']) {
            case 1:
                $zajety = one("select 1 from driver_ciuchy_gracze inner join driver_ciuchy on c_id = id where typ = 1 and status = 1 and gracz_id = " . $gracz);
                break;
            case 2:
                $zajety = one("select 1 from driver_ciuchy_gracze inner join driver_ciuchy on c_id = id where typ = 2 and status = 1 and gracz_id = " . $gracz);
                break;
            case 3:
                $zajety = one("select 1 from driver_ciuchy_gracze inner join driver_ciuchy on c_id = id where typ = 3 and status = 1 and gracz_id = " . $gracz);
                break;
            case 4:
                $zajety = one("select 1 from driver_ciuchy_gracze inner join driver_ciuchy on c_id = id where typ = 4 and status = 1 and gracz_id = " . $gracz);
                break;
        }
        if ($zajety == 1) {
            return "masz już założony sprzęt tego typu";
        }
        call("update driver_gracze set bonus_vmax = bonus_vmax + " . $ciuch['vmax'] . ", bonus_do100 = bonus_do100 + " . $ciuch['do100'] . " where gracz = {$gracz}");
        call("update driver_ciuchy_gracze set status = 1 where gracz_id = {$gracz} and c_id = {$id} limit 1");
        return "założono sprzęt";
    }
}
Example #2
0
function klan_odrzuc_podanie($gracz, $id)
{
    //zabezpiecz zmienne
    $id = (int) $id;
    //jeżeli gracz nie jest  w klanie to nie może nic usunąć
    if ($gracz['id_klanu'] == 0) {
        $msg = "nie jesteś w klanie";
    } else {
        //sprawdź rangę gracza w klanie
        $ranga = one("select status from tribal_klany_gracze where gracz_id = " . $gracz['gracz'] . " and klan_id = " . $gracz['id_klanu'] . " limit 1");
        //jeżeli to nie mistrz klanu to nie może usunąć nic
        if ($ranga == 1) {
            $msg = "nie jesteś mistrzem klanu ani jego zastępcą";
        } else {
            //odrzuć podanie
            call("delete from tribal_klany_gracze where id = " . $id . " and klan_id = " . $gracz['id_klanu'] . " and status = 0");
            //nic nie usunięto
            if (mysql_affected_rows() == 0) {
                $msg = "nie ma takiego podania";
            } else {
                //odrzucono podanie
                $msg = "odrzucono podanie";
            }
        }
    }
    return $msg;
}
Example #3
0
function klan_zaloz($gracz, $nazwa)
{
    //sprawdź długość nazwy klanu
    if (strlen($nazwa) > 15) {
        $msg = "za długa nazwa klanu";
    } else {
        //zabezpiecz zmienne
        $nazwa = vText($nazwa);
        //jeżeli gracz jest już w klanie to nie może założyć nowego
        if ($gracz['id_klanu'] > 0) {
            $msg = "jesteś już w klanie";
        } else {
            //sprawdź czy już istnieje klan o takiej nazwie
            $jest = one("select klan from tribal_klany where nazwa ='" . $nazwa . "' limit 1");
            //jeżeli nazwa zajęta
            if (!empty($jest)) {
                $msg = "nazwa jest zajęta";
            } else {
                //jeżeli wszystko ok to dodaj klan
                call("insert into tribal_klany(nazwa) value ('" . $nazwa . "')");
                //pobierz id klanu
                $id = mysql_insert_id();
                //ustaw rangę mistrza graczowi
                call("insert into tribal_klany_gracze(klan_id, gracz_id,status) value (" . $id . "," . $gracz['gracz'] . ",3)");
                call("update tribal_gracze set id_klanu = " . $id . " where gracz = " . $gracz['gracz']);
                $msg = "założono klan " . $nazwa;
            }
        }
    }
    return $msg;
}
Example #4
0
function nowa_osada($gracz)
{
    if ($gracz['id_miasta'] == 0) {
        $posiadane = one("select miasto from tribal_miasta where gracz_id = " . $gracz['gracz'] . " limit 1");
        if (empty($posiadane)) {
            call("insert into tribal_miasta (nazwa, gracz_id, ochrona) value ('" . $gracz['nazwa_miasta'] . "'," . $gracz['gracz'] . ", " . (time() + 10 * 86400) . ")");
            $id = mysql_insert_id();
            if ($id == 0) {
                call("insert into tribal_miasta (nazwa, gracz_id, czas_przyrostu, ochrona) value ('" . $gracz['nazwa_miasta'] . date("His") . "'," . $gracz['gracz'] . ", " . time() . ", " . (time() + 10 * 86400) . ")");
                $id = mysql_insert_id();
            }
            if ($id > 0) {
                $map = row("select count(*) as wolne, (select max(x) from tribal_mapa) as x_max, (select max(y) from tribal_mapa) as y_max from tribal_mapa where miasto_id = 0");
                if ($map['wolne'] < 30) {
                    $x = $map['x_max'];
                    $y = $map['y_max'];
                    $insert = "insert into tribal_mapa(x,y) values ";
                    for ($i = 1; $i < $x + 6; $i++) {
                        for ($j = 1; $j < $y + 6; $j++) {
                            if ($i > $x || $j > $y) {
                                $insert .= "({$i},{$j}),";
                            }
                        }
                    }
                    $insert = substr($insert, 0, -1);
                    call($insert);
                }
                call("update tribal_gracze set id_miasta = {$id} where gracz = " . $gracz['gracz']);
                call("update tribal_mapa set miasto_id = {$id} where miasto_id = 0 order by rand() limit 1");
            }
        } else {
            call("update tribal_gracze set id_miasta = " . $posiadane . " where gracz = " . $gracz['gracz']);
        }
    }
}
Example #5
0
function klan_ustaw_zastepce($gracz, $id)
{
    //zabezpiecz zmienne
    $id = (int) $id;
    //jeżeli gracz nie jest  w klanie to nie może nic usunąć
    if ($gracz['id_klanu'] == 0) {
        $msg = "nie jesteś w klanie";
    } else {
        //sprawdź rangę gracza w klanie
        $ranga = one($q = "select status from tribal_klany_gracze where gracz_id = " . $gracz['gracz'] . " and klan_id = " . $gracz['id_klanu'] . " limit 1");
        //jeżeli to nie mistrz klanu
        if ($ranga != 3) {
            $msg = "nie jesteś mistrzem klanu";
        } else {
            //pobierz dane klanowicza
            $podanie = row("select * from tribal_klany_gracze where gracz_id = " . $id . " and klan_id = " . $gracz['id_klanu'] . " and status = 1");
            if (empty($podanie)) {
                $msg = "nie ma takiego klanowicza";
            } else {
                //ustaw prawa zastępcy
                call("update tribal_klany_gracze set status = 2 where gracz_id = " . $id);
                $msg = "ustawiono zastępcę mistrza klanu";
            }
        }
    }
    return $msg;
}
function klan_akceptuj_podanie($gracz, $id)
{
    //zabezpiecz zmienne
    $id = (int) $id;
    //jeżeli gracz nie jest  w klanie to nie może nic usunąć
    if ($gracz['id_klanu'] == 0) {
        $msg = "nie jesteś w klanie";
    } else {
        //sprawdź rangę gracza w klanie
        $ranga = one("select status from tribal_klany_gracze where gracz_id = " . $gracz['gracz'] . " and klan_id = " . $gracz['id_klanu'] . " limit 1");
        //jeżeli to nie mistrz klanu to nie może usunąć nic
        if ($ranga == 1) {
            $msg = "nie jesteś mistrzem klanu ani jego zastępcą";
        } else {
            //pobierz dane podania
            $podanie = row("select * from tribal_klany_gracze where id = " . $id);
            //akceptuj podanie
            call("update tribal_klany_gracze set status = 1 where id = " . $id . " and klan_id = " . $gracz['id_klanu'] . " and status = 0");
            if (mysql_affected_rows() == 0) {
                $msg = "nie ma takiego podania";
            } else {
                //na wszelki wypadek usuń pozostałe podania gracza
                call("delete from tribal_klany_gracze where gracz_id = " . $podanie['gracz_id'] . " and status = 0");
                call("update tribal_gracze set id_klanu = " . $gracz['id_klanu'] . " where gracz = " . $podanie['gracz_id']);
                $msg = "zaakceptowano podanie";
            }
        }
    }
    return $msg;
}
Example #7
0
function klan_usun($gracz)
{
    //jeżeli gracz nie jest  w klanie to nie może nic usunąć
    if ($gracz['id_klanu'] == 0) {
        $msg = "nie jesteś w klanie";
    } else {
        //sprawdź rangę gracza w klanie
        $ranga = one("select status from tribal_klany_gracze where gracz_id = " . $gracz['gracz'] . " and klan_id = " . $gracz['id_klanu'] . " limit 1");
        //jeżeli to nie mistrz klanu to nie może usunąć nic
        if ($ranga != 3) {
            $msg = "nie jesteś mistrzem klanu";
        } else {
            //sprawdź czy w klanie pozostał sam mistrz
            $ilu = one("select count(*) from tribal_klany_gracze where klan_id = " . $gracz['id_klanu'] . " and status > 0");
            //jeżeli są jeszcze inni gracze to nie można usunąć klanu
            if ($ilu > 1) {
                $msg = "w klanie są gracze, wyrzuć wszystkich przed usunięciem klanu";
            } else {
                //został sam mistrz
                call("delete from tribal_klany where klan = " . $gracz['id_klanu']);
                call("delete from tribal_klany_gracze where klan_id = " . $gracz['id_klanu']);
                call("update tribal_gracze set id_klanu = 0 where id_klanu = " . $gracz['id_klanu']);
                $msg = "usunięto klan";
            }
        }
    }
    return $msg;
}
Example #8
0
function klan_zloz_podanie($gracz, $id)
{
    //zabezpiecz zmienne
    $id = (int) $id;
    //jeżeli gracz jest już w klanie to nie może dołączyć do innego
    if ($gracz['id_klanu'] > 0) {
        $msg = "jesteś już w klanie";
    } else {
        //sprawdź czy już istnieje klan o takiej nazwie
        $id_klanu = one("select klan from tribal_klany where klan =" . $id . " limit 1");
        //jeżeli nie ma takiego klanu
        if (empty($id_klanu)) {
            $msg = "nie ma takiego klanu";
        } else {
            //sprawdź czy nie złożył już podania do tego klanu
            $zlozyl = one("select id from tribal_klany_gracze where gracz_id = " . $gracz['gracz'] . " and klan_id = " . $id_klanu);
            if (!empty($zlozyl)) {
                $msg = "złożyłeś już podanie do tego klanu";
            } else {
                //złóż podanie
                call("insert into tribal_klany_gracze(klan_id, gracz_id,status) value (" . $id_klanu . "," . $gracz['gracz'] . ",0)");
                $msg = "złożono podanie do klanu " . $nazwa;
            }
        }
    }
    return $msg;
}
Example #9
0
 public function msg_del($user, $type, $msg_id)
 {
     $user = (int) $user;
     $type = (int) $type;
     $msg_id = (int) $msg_id;
     $status = one("select m_status from hellpit_messages where m_id = {$msg_id} and m_to = {$user} and m_type = 1 limit 1");
     switch ($type) {
         case 1:
             query("delete from hellpit_messages where m_id = {$msg_id} and m_to = {$user} and m_type = 1 limit 1");
             break;
         case 2:
             query("delete from hellpit_messages where m_id = {$msg_id} and m_from = {$user} and m_type = 2 limit 1");
             break;
         case 3:
             query("delete from hellpit_messages where m_id = {$msg_id} and m_to = {$user} and m_type = 3 limit 1");
             break;
         case 4:
             query("delete from hellpit_messages where m_id = {$msg_id} and m_to = {$user} and m_type = 4 limit 1");
             break;
         case 5:
             query("delete from hellpit_messages where m_id = {$msg_id} and m_to = {$user} and m_type = 5 limit 1");
             break;
         default:
             break;
     }
 }
Example #10
0
function trenuj($gracz, $typ, $id, $ilu, $kolejka_trenowania)
{
    //zabezpiecz zmienne
    $id = (int) $id;
    $ilu = (int) $ilu;
    $obiekt = one("select poziom from tribal_budynki_miasta where miasto_id = " . $gracz['id_miasta'] . " and budynek_id = " . $typ . " limit 1");
    if (empty($obiekt)) {
        $error = "nie posiadasz wymaganego budynku";
    } elseif ($ilu < 1) {
        $error = "muszisz trenować minimum 1 jednostkę";
    } else {
        $jednostka = row("select * from tribal_jednostki where wymagany_budynek = " . $typ . " and jednostka = " . $id . " and poziom_wymaganego_budynku <= " . $obiekt);
        if (empty($jednostka)) {
            $error = "nie ma takiej jednostki, lub nie masz wymaganego budynku na odpowiednim poziomie";
        } elseif ($jednostka['drewno'] * $ilu > $gracz['dane_miasta']['drewno'] || $jednostka['kamien'] * $ilu > $gracz['dane_miasta']['kamien'] || $jednostka['zelazo'] * $ilu > $gracz['dane_miasta']['zelazo'] || $jednostka['jedzenie'] * $ilu > $gracz['dane_miasta']['jedzenie'] || $jednostka['populacja'] * $ilu > $gracz['dane_miasta']['populacja_max'] - $gracz['dane_miasta']['populacja']) {
            $error = "nie masz wystarczającej ilości surowców";
        } else {
            $kolejka = row("select \n\t\t\t(select count(*) from tribal_eventy where typ = 3 and miasto_id = " . $gracz['id_miasta'] . ") as kolejka,\n\t\t\t(select count(*) from tribal_eventy where typ = 3 and podtyp = " . $id . " and miasto_id = " . $gracz['id_miasta'] . ") as w_kolejce\n\t\t\t");
            if ($kolejka['kolejka'] == $kolejka_trenowania) {
                $error = "kolejka zajęta";
            } else {
                //dodaj event
                fx('dodaj_event');
                dodaj_event($gracz['id_miasta'], 3, $id, $ilu, $jednostka['czas_treningu'] * $ilu);
                fx('surowce');
                surowce($gracz['id_miasta'], -$jednostka['drewno'] * $ilu, -$jednostka['kamien'] * $ilu, -$jednostka['zelazo'] * $ilu, -$jednostka['jedzenie'] * $ilu, $jednostka['populacja'] * $ilu);
                //zabierz surowce
                $error = "rozpoczęto trening";
            }
        }
    }
    return $error;
}
Example #11
0
function col($q)
{
    $t = one($q);
    if ($t) {
        return array_shift($t);
    }
    return null;
}
Example #12
0
function rozwiaz_szpiegow($event)
{
    //zabezpiecz zmienne
    fx('wiadomosc_wyslij');
    $login = one($q = "select login from tribal_gracze inner join tribal_miasta on gracz_id = gracz  where miasto = " . $event['miasto_id']);
    call("update tribal_jednostki_miasta set ilosc = ilosc + " . $event['ilosc'] . " where jednostka_id = 5 and miasto_id = " . $event['miasto_id']);
    $a = wiadomosc_wyslij(1, $login, "Szpiedzy powrócili do miasta");
}
Example #13
0
function main()
{
    one(1);
    two(1);
    three(1);
    set_error_handler('error_handler');
    one(1);
    two(1);
    three(1);
}
Example #14
0
function dodaj_event($miasto, $typ, $podtyp, $ilosc, $czas)
{
    $ostatni = one("select koniec from  tribal_eventy where miasto_id = {$miasto} and typ = {$typ} order by event desc limit 1");
    if (empty($ostatni)) {
        $ostatni = mktime();
    }
    if ($typ > 3) {
        $ostatni = mktime();
    }
    call("insert into tribal_eventy(typ, podtyp, miasto_id, ilosc, start, koniec) value ({$typ}, {$podtyp}, {$miasto}, {$ilosc}, {$ostatni}, {$ostatni} + {$czas}) ");
}
Example #15
0
function show_pics_data($params)
{
    $fres = fopen("update.sql", "w");
    var_dump(one(q("select count(*) from gallery where thumb = 0")));
    exit;
    $galleries = q("select * from gallery");
    while ($row = fetch($galleries)) {
        fwrite($fres, sprintf("update gallery set thumb = %s, approved = %s where id = %s;\n", $row["thumb"], $row["approved"], $row["id"]));
    }
    fclose($fres);
}
Example #16
0
function zawroc_szpiegow($gracz, $event)
{
    $event = (int) $event;
    $czas = one("select  " . time() . " - start  from tribal_eventy where event = {$event} and typ = 20 and miasto_id =" . $gracz['id_miasta']);
    if (empty($czas)) {
        $error = "nie ma takiej wyprawy";
    } else {
        call("update tribal_eventy set typ = 21, start = " . time() . ", koniec = " . (time() + $czas) . " where event =" . $event);
        $error = "zawrócono wyprawę";
    }
    return $error;
}
Example #17
0
function buduj($gracz, $id, $kolejka_budowy)
{
    //zabezpiecz zmienne
    $id = (int) $id;
    $info = row("select bm.poziom as poziom, bm.drewno as bmdrewno, bm.kamien as bmkamien, bm.zelazo as bmzelazo, bm.jedzenie as bmjedzenie, bm.populacja as bmpopulacja, bm.czas_budowy as bmczas_budowy,  b.* from tribal_budynki b left join tribal_budynki_miasta bm on b.budynek = bm.budynek_id and bm.miasto_id = " . $gracz['id_miasta'] . " where b.budynek = " . $id . " limit 1");
    if (empty($info)) {
        $error = "nie ma takiego obiektu";
    } else {
        if (!empty($info['poziom'])) {
            $info['drewno'] = $info['bmdrewno'];
            $info['kamien'] = $info['bmkamien'];
            $info['zelazo'] = $info['bmzelazo'];
            $info['jedzenie'] = $info['bmjedzenie'];
            $info['populacja'] = $info['bmpopulacja'];
            $info['czas_budowy'] = $info['bmczas_budowy'];
        } else {
            $info['poziom'] = 0;
        }
        $budowany = one("select count(*) from tribal_eventy where typ = 1 and podtyp = {$id} and miasto_id = " . $gracz['id_miasta']);
        if ($budowany > 0) {
            $error = "budujesz już ten budynek";
        } else {
            $kolejka = one("select count(*) from tribal_eventy where typ = 1 and miasto_id = " . $gracz['id_miasta']);
            if ($kolejka == $kolejka_budowy) {
                $error = "kolejka budowy zajęta";
            } else {
                if ($info['drewno'] > $gracz['dane_miasta']['drewno'] || $info['kamien'] > $gracz['dane_miasta']['kamien'] || $info['zelazo'] > $gracz['dane_miasta']['zelazo'] || $info['jedzenie'] > $gracz['dane_miasta']['jedzenie'] || $info['populacja'] > $gracz['dane_miasta']['populacja_max'] - $gracz['dane_miasta']['populacja']) {
                    $error = "nie masz wystarczającej ilości surowców";
                } elseif ($info['poziom'] == $info['max_poziom']) {
                    $error = "osiągnięto maksymalny poziom";
                } else {
                    $wymagania = one("\n\t\t\t\t\tselect\n\t\t\t\t\t\tcase when count(*) >=\n\t\t\t\t\t\t(select count(*) from tribal_budynki_wymagania\n\t\t\t\t\t\twhere budynek_id = {$id})\n\t\t\t\t\t\tthen 1 else 0 end\n\n\t\t\t\t\t\tfrom tribal_budynki_wymagania t2,\n\t\t\t\t\t\ttribal_budynki_miasta t1\n\t\t\t\t\t\twhere t2.budynek_id = {$id}\n\t\t\t\t\t\tand t1.budynek_id = t2.wymagany_budynek_id\n\t\t\t\t\t\tand t1.miasto_id = " . $gracz['id_miasta'] . " \n\t\t\t\t\t\tand t1.poziom >= t2.wymagany_poziom\n\t\t\t\t\t");
                    if ($wymagania == 1) {
                        //dodaj event
                        fx('dodaj_event');
                        dodaj_event($gracz['id_miasta'], 1, $id, 1, $info['czas_budowy']);
                        fx('surowce');
                        surowce($gracz['id_miasta'], -$info['drewno'], -$info['kamien'], -$info['zelazo'], -$info['jedzenie'], $info['populacja']);
                        //zabierz surowce
                        $error = "rozpoczęto budowę";
                    } else {
                        $error = "nie spełniono wymagań do budowy tego budynku";
                    }
                }
            }
        }
    }
    return $error;
}
Example #18
0
function raport($do, $tekst)
{
    //zabezpiecz zmienne
    $do = vText($do);
    $tekst = vText($tekst);
    //sprawdź czy gracz istnieje (wg id)
    $test = one("select gracz from tribal_gracze where login = '******'");
    if (empty($test)) {
        return "nie ma takiego gracza";
    } else {
        //wyślij wiadomość
        call($q = "insert into tribal_wiadomosci (od, do, tekst,  data, typ) value (1, {$test},'" . $tekst . "', now(),3)");
        return "wysłano wiadomość";
    }
}
Example #19
0
/**
 * Node section
 *
 * @param array $§
 *
 * @return string
 */
function section_node(array &$§) : string
{
    if (empty($§['vars']['crit']) || !($menu = one('menu', $§['vars']['crit'])) || !($data = all('node', ['root_id' => $menu['id'], 'project_id' => $menu['project_id']]))) {
        return '';
    }
    $data = array_filter($data, function ($item) use($data) {
        if (strpos($item['target'], 'http') === 0) {
            return true;
        }
        if ($item['target']) {
            return allowed(privilege_url($item['target']));
        }
        foreach ($data as $i) {
            if ($i['lft'] > $item['lft'] && $i['rgt'] < $item['rgt'] && $i['target'] && allowed(privilege_url($i['target']))) {
                return true;
            }
        }
        return false;
    });
    $count = count($data);
    $level = 0;
    $i = 0;
    $html = '';
    foreach ($data as $item) {
        $attrs = [];
        $class = '';
        if ($item['target'] === request('path')) {
            $attrs['class'] = 'active';
            $class .= ' class="active"';
        }
        if ($item['level'] > $level) {
            $html .= '<ul><li' . $class . '>';
        } elseif ($item['level'] < $level) {
            $html .= '</li>' . str_repeat('</ul></li>', $level - $item['level']) . '<li' . $class . '>';
        } else {
            $html .= '</li><li' . $class . '>';
        }
        if ($item['target']) {
            $attrs['href'] = $item['target'];
            $html .= html_tag('a', $attrs, $item['name']);
        } else {
            $html .= html_tag('span', [], $item['name']);
        }
        $html .= ++$i === $count ? str_repeat('</li></ul>', $item['level']) : '';
        $level = $item['level'];
    }
    return $html;
}
Example #20
0
function wiadomosc_wyslij($od, $do, $tekst)
{
    //zabezpiecz zmienne
    $od = (int) $od;
    $do = vText($do);
    $tekst = vText($tekst);
    //sprawdź czy gracz istnieje (wg id)
    $test = one("select gracz from genix_gracze where login = '******'");
    if (empty($test)) {
        return "nie ma takiego gracza";
    } else {
        //wyślij wiadomość
        call($q = "insert into genix_wiadomosci (od, do, tekst,  data, typ) value ({$od}, {$test},'" . $tekst . "', now(),2)");
        call($q = "insert into genix_wiadomosci (od, do, tekst,  data, typ) value ({$od}, {$test},'" . $tekst . "', now(),1)");
        return "wysłano wiadomość";
    }
}
Example #21
0
function klan_wyrzuc($gracz, $id)
{
    //zabezpiecz zmienne
    $id = (int) $id;
    //jeżeli gracz nie jest  w klanie to nie może nic usunąć
    if ($gracz['id_klanu'] == 0) {
        $msg = "nie jesteś w klanie";
    } else {
        //sprawdź rangę gracza w klanie
        $ranga = one("select status from tribal_klany_gracze where gracz_id = " . $gracz['gracz'] . " and klan_id = " . $gracz['id_klanu'] . " limit 1");
        switch ($ranga) {
            case 1:
                //jeżeli to nie mistrz klanu to nie może nikogo wyrzucić
                $msg = "nie jesteś mistrzem klanu ani jego zastępcą";
                break;
            case 2:
                //zastępca może usunąć tylko zwykłego klanowicza
                //wyrzuć gracza z klanu
                call($q = "delete from tribal_klany_gracze where gracz_id = " . $id . " and klan_id = " . $gracz['id_klanu'] . " and status =1");
                //nic nie usunięto
                if (mysql_affected_rows() == 0) {
                    $msg = "nie ma takiego klanowicza ";
                } else {
                    //wyrzucono
                    $msg = "wyrzucono gracza z klanu";
                }
                break;
            case 3:
                //mistrz może usunąć każdego klanowicza
                //wyrzuć gracza z klanu
                call("delete from tribal_klany_gracze where gracz_id  = " . $id . " and klan_id = " . $gracz['id_klanu'] . " and status < 3");
                //nic nie usunięto
                if (mysql_affected_rows() == 0) {
                    $msg = "nie ma takiego klanowicza ";
                } else {
                    //wyrzucono
                    $msg = "wyrzucono gracza z klanu";
                }
                break;
        }
    }
    return $msg;
}
Example #22
0
function rozwiaz_armie($id)
{
    //zabezpiecz zmienne
    $id = (int) $id;
    fx('wiadomosc_wyslij');
    $login = one($q = "select login from tribal_gracze inner join tribal_miasta on gracz_id = gracz inner join tribal_ataki on miasto = miasto_id where atak = " . $id);
    $atak_info = row("select * from tribal_ataki where atak = {$id}");
    $jednostki = all("select * from tribal_ataki_jednostki inner join tribal_ataki a on a.atak = atak_id where atak_id = {$id}");
    if (is_array($jednostki)) {
        foreach ($jednostki as $jednostka) {
            call("update tribal_jednostki_miasta set ilosc = ilosc + " . $jednostka['ilosc'] . " where jednostka_id = " . $jednostka['jednostka_id'] . " and miasto_id = " . $jednostka['miasto_id']);
        }
    }
    call("delete from tribal_ataki_jednostki where atak_id = {$id}");
    call("delete from tribal_ataki where atak = {$id}");
    fx('surowce');
    surowce($atak_info['miasto_id'], $atak_info['drewno'], $atak_info['kamien'], $atak_info['zelazo'], $atak_info['jedzenie'], 0);
    fx('raport');
    $a = raport($login, "Armia powróciła do miasta ,rozładowano " . $atak_info['drewno'] . " drewna,  " . $atak_info['kamien'] . " kamienia,  " . $atak_info['zelazo'] . " żelaza i " . $atak_info['jedzenie'] . " jedzenia");
}
Example #23
0
function klan_odejdz($gracz)
{
    //jeżeli gracz nie jest  w klanie to nie może odejść
    if ($gracz['id_klanu'] == 0) {
        $msg = "nie jesteś w klanie";
    } else {
        //sprawdź rangę gracza w klanie
        $ranga = one("select status from tribal_klany_gracze where gracz_id = " . $gracz['gracz'] . " and klan_id = " . $gracz['id_klanu'] . " limit 1");
        //jeżeli to mistrz to nie może odejść
        if ($ranga == 3) {
            $msg = "jesteś mistrzem klanu i nie możesz odejść";
        } else {
            //odejdź
            call("delete from tribal_klany_gracze where gracz_id = " . $gracz['gracz'] . " and klan_id = " . $gracz['id_klanu']);
            call("update tribal_gracze set id_klanu = 0 where gracz = " . $gracz['gracz']);
            $msg = "odszedłeś z klanu";
        }
    }
    return $msg;
}
Example #24
0
function zaloz_osade($gracz, $nazwa, $x, $y)
{
    $x = (int) $x;
    $y = (int) $y;
    $nazwa = mysql_real_escape_string(substr($nazwa, 0, 15));
    $jest = one("select miasto from tribal_miasta where nazwa = '" . $nazwa . "' limit 1");
    if (!empty($jest)) {
        return "taka nazwa miasta jest już zarezerwowana";
    }
    $jest = one("select pole from tribal_mapa where x = " . $x . " and y = " . $y . " and miasto_id = 0 limit 1");
    if (empty($jest)) {
        return "pole na mapie jest zajęte przez inne miasto";
    }
    call("update tribal_jednostki_miasta set ilosc = ilosc - 1 where miasto_id = " . $gracz['id_miasta'] . "  and jednostka_id = 11 and ilosc > 0");
    if (mysql_affected_rows() == 0) {
        return "nie posiadasz Wybrańców w tym mieście";
    }
    call("insert into tribal_miasta (nazwa, gracz_id, czas_przyrostu, ochrona) value ('" . $nazwa . "'," . $gracz['gracz'] . ", " . time() . ", " . (time() + 10 * 86400) . ")");
    $id = mysql_insert_id();
    call("update tribal_mapa set miasto_id = " . $id . " where x = " . $x . " and y = " . $y);
    return "założono nową osadę";
}
Example #25
0
function wyslij_szpiegow($gracz, $cel, $ilu)
{
    //zabezpiecz zmienne
    $cel = vText($cel);
    $ilu = (int) $ilu;
    if ($ilu < 1) {
        $error = 'wyślij minimum 1 jednostkę';
    } else {
        $ma = one("select ilosc from tribal_jednostki_miasta where jednostka_id = 5 and miasto_id =" . $gracz['id_miasta']);
        if ($ma < $ilu) {
            $error = 'nie posiadasz tylu szpiegów';
        } else {
            $vs = row("select * from tribal_miasta where nazwa='" . $cel . "' limit 1");
            if (empty($vs)) {
                $error = 'nie ma takiego miasta';
            } elseif ($vs['gracz_id'] == $gracz['gracz']) {
                $error = 'nie szpieguj swoich miast';
            } else {
                $x = row("select * from tribal_mapa where miasto_id = " . $gracz['id_miasta']);
                $y = row("select * from tribal_mapa where miasto_id = " . $vs['miasto']);
                if ($x['x'] != $vs['x'] && $x['y'] == $vs['y']) {
                    $zasieg = abs($vs['x'] - $x['x']) * 300;
                } elseif ($x['x'] == $vs['x'] && $x['y'] != $vs['y']) {
                    $zasieg = abs($vs['y'] - $x['y']) * 300;
                } else {
                    $zasieg = floor(sqrt(pow(abs($vs['x'] - $x['x']), 2) + pow(abs($vs['y'] - $x['y']), 2))) * 300;
                }
                call("update tribal_jednostki_miasta set ilosc = ilosc - {$ilu} where jednostka_id = 5 and miasto_id =" . $gracz['id_miasta']);
                fx('dodaj_event');
                dodaj_event($gracz['id_miasta'], 20, $vs['miasto'], $ilu, $zasieg);
                $error = 'wysłano';
            }
        }
    }
    return $error;
}
Example #26
0
function main_town($miasto)
{
    fx('usun_event');
    $eventy_budynki = all("select * from tribal_eventy where miasto_id = {$miasto} and typ = 1 and koniec <= " . time());
    if (is_array($eventy_budynki)) {
        foreach ($eventy_budynki as $wybudowany) {
            usun_event($wybudowany['event']);
            call("update tribal_gracze g inner join tribal_miasta on g.gracz = gracz_id set g.punkty = g.punkty + 1 where miasto = " . $miasto);
            $info = one("select count(*) from tribal_budynki_miasta where miasto_id = {$miasto} and budynek_id = " . $wybudowany['podtyp']);
            $obiekt = row("select * from  tribal_budynki where budynek = " . $wybudowany['podtyp']);
            if (!empty($info)) {
                call($q = "update tribal_budynki_miasta set \n\t\t\t\tdrewno = drewno * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100), \n\t\t\t\tkamien = kamien * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100),\n\t\t\t\tjedzenie = jedzenie * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100),\n\t\t\t\tzelazo = zelazo * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100),\n\t\t\t\tpopulacja = populacja * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100),\n\t\t\t\tczas_budowy = czas_budowy * ((100 + " . $obiekt['wzrost_czasu_budowy'] . " )/100),\n\t\t\t\tpoziom = poziom + 1\n\t\t\t\twhere miasto_id = {$miasto} and budynek_id = \n\t\t\t\t" . $wybudowany['podtyp']);
                $poziom = 1;
            } else {
                call($q = "insert into tribal_budynki_miasta(miasto_id, budynek_id, drewno, kamien, zelazo, jedzenie, populacja, czas_budowy, poziom) value ({$miasto}, " . $wybudowany['podtyp'] . ", " . $obiekt['drewno'] . ", " . $obiekt['kamien'] . ", " . $obiekt['zelazo'] . ", " . $obiekt['jedzenie'] . ", " . $obiekt['populacja'] . ", " . $obiekt['czas_budowy'] . ", 1)");
                $poziom = 0;
            }
            switch ($wybudowany['podtyp']) {
                case 1:
                    if ($poziom == 0) {
                        call("update tribal_miasta set drewno_przyrost = drewno_przyrost + 50 where miasto = {$miasto}");
                    } else {
                        call("update tribal_miasta set drewno_przyrost = drewno_przyrost * 1.2 where miasto = {$miasto}");
                    }
                    break;
                case 2:
                    if ($poziom == 0) {
                        call("update tribal_miasta set kamien_przyrost = kamien_przyrost + 50 where miasto = {$miasto}");
                    } else {
                        call("update tribal_miasta set kamien_przyrost = kamien_przyrost * 1.2 where miasto = {$miasto}");
                    }
                    break;
                case 3:
                    if ($poziom == 0) {
                        call("update tribal_miasta set zelazo_przyrost = zelazo_przyrost + 50 where miasto = {$miasto}");
                    } else {
                        call("update tribal_miasta set zelazo_przyrost = zelazo_przyrost * 1.2 where miasto = {$miasto}");
                    }
                    break;
                case 4:
                    if ($poziom == 0) {
                        call("update tribal_miasta set jedzenie_przyrost = jedzenie_przyrost + 50 where miasto = {$miasto}");
                    } else {
                        call("update tribal_miasta set jedzenie_przyrost = jedzenie_przyrost * 1.2 where miasto = {$miasto}");
                    }
                    break;
                case 5:
                    call("update tribal_miasta set populacja_max = populacja_max * 1.3 where miasto = {$miasto}");
                    break;
                case 6:
                    call("update tribal_miasta set surowce_max = surowce_max * 1.3 where miasto = {$miasto}");
                    break;
            }
        }
    }
    $eventy_technologie = all("select * from tribal_eventy where miasto_id = {$miasto} and typ = 2 and koniec <= " . time());
    if (is_array($eventy_technologie)) {
        foreach ($eventy_technologie as $wybudowany) {
            usun_event($wybudowany['event']);
            $info = one("select count(*) from tribal_technologie_miasta where miasto_id = {$miasto} and technologia_id = " . $wybudowany['podtyp']);
            $obiekt = row("select * from  tribal_technologie where technologia = " . $wybudowany['podtyp']);
            if (!empty($info)) {
                call("update tribal_technologie_miasta set \n\t\t\t\tdrewno = drewno * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100), \n\t\t\t\tkamien = kamien * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100),\n\t\t\t\tjedzenie = jedzenie * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100),\n\t\t\t\tzelazo = zelazo * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100),\n\t\t\t\tczas_rozwoju = czas_rozwoju * ((100 + " . $obiekt['wzrost_czasu_budowania'] . " )/100),\n\t\t\t\tpoziom = poziom + 1\n\t\t\t\twhere miasto_id = {$miasto} and technologia_id = \n\t\t\t\t" . $wybudowany['podtyp']);
                $poziom = 1;
            } else {
                call("insert into tribal_technologie_miasta(miasto_id, technologia_id, drewno, kamien, zelazo, jedzenie,  czas_rozwoju, poziom) value ({$miasto}, " . $wybudowany['podtyp'] . ", " . $obiekt['drewno'] . ", " . $obiekt['kamien'] . ", " . $obiekt['zelazo'] . ", " . $obiekt['jedzenie'] . ", " . $obiekt['czas_rozwoju'] . ", 1)");
                $poziom = 0;
            }
        }
    }
    $eventy_jednostki = all("select * from tribal_eventy where miasto_id = {$miasto} and typ = 3 and koniec <= " . time());
    if (is_array($eventy_jednostki)) {
        foreach ($eventy_jednostki as $wybudowany) {
            usun_event($wybudowany['event']);
            $info = one("select count(*) from tribal_jednostki_miasta where miasto_id = {$miasto} and jednostka_id = " . $wybudowany['podtyp']);
            if (!empty($info)) {
                call("update tribal_jednostki_miasta set \n\t\t\t\tilosc = ilosc + " . $wybudowany['ilosc'] . "\n\t\t\t\twhere miasto_id = {$miasto} and jednostka_id = \n\t\t\t\t" . $wybudowany['podtyp']);
            } else {
                call("insert into tribal_jednostki_miasta(miasto_id, jednostka_id, ilosc) value ({$miasto}, " . $wybudowany['podtyp'] . "," . $wybudowany['ilosc'] . ")");
            }
        }
    }
    fx('rozwiaz_armie');
    $eventy_ataki_powrot = all("select * from tribal_eventy where miasto_id = {$miasto} and typ = 11 and koniec <= " . time());
    if (is_array($eventy_ataki_powrot)) {
        foreach ($eventy_ataki_powrot as $atak) {
            usun_event($atak['event']);
            rozwiaz_armie($atak['ilosc']);
        }
    }
    fx('bitwa');
    $eventy_bitwy = all("select * from tribal_eventy where miasto_id = {$miasto} and typ = 10 and koniec <= " . time());
    if (is_array($eventy_bitwy)) {
        foreach ($eventy_bitwy as $atak) {
            usun_event($atak['event']);
            bitwa($atak);
        }
    }
    fx('rozwiaz_szpiegow');
    $eventy_szpiedzy_powrot = all("select * from tribal_eventy where miasto_id = {$miasto} and typ = 21 and koniec <= " . time());
    if (is_array($eventy_szpiedzy_powrot)) {
        foreach ($eventy_szpiedzy_powrot as $atak) {
            usun_event($atak['event']);
            rozwiaz_szpiegow($atak);
        }
    }
    fx('szpiegowanie');
    $eventy_szpiegowanie = all("select * from tribal_eventy where miasto_id = {$miasto} and typ = 20 and koniec <= " . time());
    if (is_array($eventy_szpiegowanie)) {
        foreach ($eventy_szpiegowanie as $atak) {
            usun_event($atak['event']);
            szpiegowanie($atak);
        }
    }
}
Example #27
0
    $player = getPlayer($_SESSION['user']);
}
if (empty($player)) {
    $player->role = -1;
}
$header = 'templates/master/header.php';
$footer = 'templates/master/footer.php';
$master_act = array("default", "login", "register", "rank", "contact", "rules", "help");
$user_act = array("logout", "pit", "account", "hellmarket", "rank", "messages", "contact", "rules", "help", "admin", "kody_vip", "create", "vip");
if (empty($_GET['x'])) {
    $_GET['x'] = 'default';
}
if (in_Array($_GET['x'], $user_act) && $player->role >= 0) {
    if (!empty($_GET['set_pit'])) {
        $_GET['set_pit'] = (int) $_GET['set_pit'];
        $is = one("select pit_id from hellpit_pits where pit_id = " . $_GET['set_pit'] . " and pit_user = "******"update hellpit_users set actual_pit = " . $_GET['set_pit'] . " where user = "******"update hellpit_users set exp = exp - exp_lvl, exp_lvl = exp_lvl * 1.666, skills = skills + 3, lvl = lvl + 1 where user = " . $player->user);
        reload($_GET['x']);
    }
    $header = 'templates/user/header.php';
Example #28
0
<?php

// def_alias - создаёт алиас для функции.
def('one', function () {
    echo 1;
});
def_alias('one', 'two');
one();
two();
?>
---
11
Example #29
0
/**
 * User Login Action
 *
 * @return void
 */
function action_user_login() : void
{
    if (registered()) {
        redirect(url('user/dashboard'));
    }
    if ($data = http_post('data')) {
        if (!empty($data['username']) && !empty($data['password']) && ($item = one('user', ['username' => $data['username'], 'active' => true, 'project_id' => project('ids')])) && password_verify($data['password'], $item['password'])) {
            message(_('Welcome %s', $item['name']));
            session_regenerate_id(true);
            session('user', $item['id']);
            redirect(url('user/dashboard'));
        }
        message(_('Invalid username and password combination'));
    }
    layout_load();
    vars('head', ['title' => _('Login')]);
}
Example #30
0
function main()
{
    var_dump(one() % 0);
}