public function new_clan($config, $player, $name) { $msg = ''; if (strlen($name > 20)) { $msg = 'za długa nazwa klanu, max 20 znaków'; } else { $name = textV($name); if ($player->clan_id > 0) { $msg = 'jesteś już w klanie, nie założysz nowego'; } else { $is = get_one("select c_id from clans where c_name = '" . $name . "' limit 1"); if (!empty($is)) { $msg = 'istnieje klan o takiej nazwie, wybierz inną'; } else { call("insert into clans (c_name) value ('{$name}')"); $id = get_one("select last_insert_id()"); call("delete from clans_users where cu_usr_id = " . $player->usr_id); call("insert into clans_users (cu_usr_id, cu_c_id, cu_status) value (" . $player->usr_id . ",{$id},2)"); call("update users set clan_id = {$id} where usr_id = " . $player->usr_id); $msg = "założono klan {$name}"; } } } return $msg; }
public function clan_msg($config, $player, $text) { $text = textV($text); if ($player->clan_id > 0) { call("insert into messages (m_from, m_to, m_type, m_text, m_date)\n\t\t\t\tselect " . $player->usr_id . ",usr_id,1,'" . $text . "', now() from users\n\t\t\t\twhere clan_id = " . $player->clan_id . "\n\t\t\t"); $msg = "wiadomość wysłano"; } return $msg; }
public function caravan_send($config, $player, $town, $wood, $stone, $iron) { $town = textV($town); $wood = (int) $wood; $stone = (int) $stone; $iron = (int) $iron; if ($wood + $stone + $iron < 1) { $msg = 'wyślij minimum 1 sztukę jakiegoś surowca'; } elseif ($player->clan_id == 0) { $msg = 'nie jesteś w klanie, karawany można wysyłać tylko do sojuszników w swoim klanie'; } elseif ($player->town->t_wood < $wood || $player->town->t_stone < $stone || $player->town->t_iron < $iron) { $msg = 'nie posiadasz tyle surowców'; } else { $can = get_row($q = "select clan_id, t_id from users inner join towns on t_usr_id = usr_id where t_name = '" . $town . "' limit 1"); if (empty($can)) { $msg = 'takie miasto nie istnieje'; } elseif ($can->clan_id != $player->clan_id) { $msg = 'te miasto nie jest w tym samym klanie co ty'; } else { $event_check = get_one("select count(*) from events where (e_type = 20 or e_type = 21) and e_done = 0 and e_t_id = " . $player->actual_town); if ($event_check > 9) { $msg = 'masz już maksymalną ilość karawan w podróży'; } else { $market_lvl = get_one("select go_lvl from game_objects where go_type = 1 and go_subtype = 6 and go_t_id = " . $player->actual_town); if (empty($market_lvl)) { $msg = 'nie posiadasz rynku, jak chcesz wysłać karawanę??'; } elseif ($market_lvl <= $event_check) { $msg = 'masz już maksymalną ilość karawan w podróży'; } else { $y = get_row("select * from map where m_t_id =" . $can->t_id); $x = get_row("select * from map where m_t_id =" . $player->actual_town); if ($x->m_x != $y->m_x && $x->m_y == $y->m_y) { $range = abs($y->m_x - $x->m_x) * 300; } elseif ($x->m_x == $y->m_x && $x->m_y != $y->m_y) { $range = abs($y->m_y - $x->m_y) * 300; } else { $range = floor(sqrt(pow(abs($y->m_x - $x->m_x), 2) + pow(abs($y->m_y - $x->m_y), 2))) * 300; } call("insert into caravan(ca_from, ca_to, ca_wood, ca_stone, ca_iron)\n\t\t\t\t\t\t\tvalue(" . $player->actual_town . "," . $can->t_id . "," . $wood . "," . $stone . "," . $iron . ")"); $ca = get_row("select last_insert_id() as ca, unix_timestamp() as estart"); require_once 'functions/TownMgr.php'; $TownMgr = new TownMgr(); $TownMgr->change_resources($config, $player->actual_town, -$wood, -$stone, -$iron, 0); require_once 'functions/EventsMgr.php'; $EventMgr = new EventsMgr(); $EventMgr->event_add($config, $player->actual_town, 20, $can->t_id, $ca->ca, 0, $ca->estart, $ca->estart + $range, 0); $msg = 'wysłano karawanę do miasta ' . $town; } } } } return $msg; }
public function buy_coins($config, $player, $code) { $code = textV($code); $can = get_one($q = "select usr_id from vip_code where code ='" . $code . "' limit 1"); if (!isset($can) || $can > 0) { $msg = 'niepoprawny kod'; } else { call("update users set coins = coins + 100 where usr_id = " . $player->usr_id); call("update vip_code set usr_id = " . $player->usr_id . ", date = now() where code = '" . $code . "'"); $msg = 'dodano 100 monet'; } return $msg; }
public function login($config, $login, $pass) { $msg = ''; $login = textV($login); $pass = md5(textV($pass)); $user = get_one("select usr_id from arena_users where login = '******' and pass = '******' limit 1"); if (!empty($user) && is_numeric($user) && $user > 0) { $_SESSION = array(); $_SESSION['user'] = $user; call("update arena_users set last_login = unix_timestamp() where usr_id = " . $user); call("update arena_map inner join users on m_who = usr_id set m_who = 0, m_status = 1 where last_action <= unix_timestamp() - 300"); reload($config, 'hero', ''); } else { $msg = 'Wprowadzono błędne dane '; } return $msg; }
public function colectors_send($config, $player, $town, $count) { $town = textV($town); $count = (int) $count; if ($count < 1) { $msg = 'wyślij minimum 1 zwiadowcę'; } else { $can = get_row($q = "select go_lvl from game_objects where go_type = 3 and go_subtype = 8 and go_t_id =" . $player->actual_town); if (empty($can)) { $msg = 'nie posiadasz zbieraczy'; } elseif ($can->go_lvl < $count) { $msg = 'nie posiadasz zbieraczy'; } else { $event_check = get_one("select count(*) from events where (e_type = 70 or e_type = 71) and e_done = 0 and e_t_id = " . $player->actual_town); if ($event_check > 9) { $msg = 'masz już maksymalną ilość wysłanych grup zbieraczy'; } else { $can = get_row("select t_id, t_usr_id from towns where t_name ='" . $town . "' limit 1"); if (empty($can)) { $msg = 'nie ma takiego miasta'; } else { $y = get_row("select * from map where m_t_id =" . $can->t_id); $x = get_row("select * from map where m_t_id =" . $player->actual_town); if ($x->m_x != $y->m_x && $x->m_y == $y->m_y) { $range = abs($y->m_x - $x->m_x) * 300; } elseif ($x->m_x == $y->m_x && $x->m_y != $y->m_y) { $range = abs($y->m_y - $x->m_y) * 300; } else { $range = floor(sqrt(pow(abs($y->m_x - $x->m_x), 2) + pow(abs($y->m_y - $x->m_y), 2))) * 300; } $tnow = get_one("select unix_timestamp()"); call("update game_objects set go_lvl = go_lvl - {$count} where go_type = 3 and go_subtype = 8 and go_t_id =" . $player->actual_town); call("insert into colectors (co_counts) value (" . $count . ")"); $id = get_one("select last_insert_id()"); require_once 'functions/EventsMgr.php'; $EventMgr = new EventsMgr(); $EventMgr->event_add($config, $player->actual_town, 70, $can->t_id, $id, 0, $tnow, $tnow + $range, 0); $msg = 'wysłano wyprawę do miasta ' . $town; } } } } return $msg; }
public function login($config, $login, $pass) { $msg = ''; $login = textV($login); $pass = sha1(md5(textV($pass))); $user = get_row("select * from users where login = '******' and pass = '******' limit 1"); if (!empty($user)) { if ($user->banned == 1) { $msg = 'gracz zbanowany'; } elseif (is_numeric($user->usr_id) && $user->usr_id > 0) { $_SESSION = array(); $_SESSION['user'] = $user->usr_id; reload($config, 'town', ''); } else { $msg = 'nieoczekiwany błąd'; } } else { $msg = 'Wprowadzono błędne dane '; } return $msg; }
break; case 'list': $clans = get_all("select *, (select count(*) from clans_users where cu_c_id = c_id and cu_status > 0) as players, (select count(*) from towns inner join users on t_usr_id = usr_id inner join clans_users on cu_usr_id = usr_id and cu_c_id = clan_id where clan_id = c_id and cu_status > 0) as townc from clans "); if (is_array($clans)) { $echo = "\n\t\t\t\t<table>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Nazwa klanu</th>\n\t\t\t\t\t<th>Graczy</th>\n\t\t\t\t\t<th>Miast</th>\n\t\t\t\t\t<th></th>\n\t\t\t\t</tr>\n\t\t\t\t"; foreach ($clans as $clan) { $echo .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . $clan->c_name . "</td>\n\t\t\t\t\t<td>" . $clan->players . "</td>\n\t\t\t\t\t<td>" . $clan->townc . "</td>\n\t\t\t\t\t<td><a href='?action=clan&act=clan&id=" . $clan->c_id . "'>[ zobacz klan ]</a></td>\n\t\t\t\t</tr>"; } $echo .= "</table>"; echo $echo; } break; case 'search': echo "\t\t\t\n\t\t\t<form action='?action=clan&act=search' method='post'>\n\t\t\t\tpodaj nazwę szukanego klanu: <input type='text' name='search_name' />\n\t\t\t\t<input type='submit' value='szukaj'/>\n\t\t\t</form>\n\t\t\t<br/><br/>\n\t\t\t"; if (!empty($_POST['search_name'])) { $_POST['search_name'] = textV($_POST['search_name']); $clans = get_all("select *, (select count(*) from clans_users where cu_c_id = c_id and cu_status > 0) as players, (select count(*) from towns inner join users on t_usr_id = usr_id inner join clans_users on cu_usr_id = usr_id and cu_c_id = clan_id where clan_id = c_id and cu_status > 0) as townc from clans where c_name like '" . $_POST['search_name'] . "'"); if (is_array($clans)) { $echo = "\n\t\t\t\t<table>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Nazwa klanu</th>\n\t\t\t\t\t<th>Graczy</th>\n\t\t\t\t\t<th>Miast</th>\n\t\t\t\t\t<th></th>\n\t\t\t\t</tr>\n\t\t\t\t"; foreach ($clans as $clan) { $echo .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . $clan->c_name . "</td>\n\t\t\t\t\t<td>" . $clan->players . "</td>\n\t\t\t\t\t<td>" . $clan->townc . "</td>\n\t\t\t\t\t<td><a href='?action=clan&act=clan&id=" . $clan->c_id . "'>[ zobacz klan ]</a></td>\n\t\t\t\t</tr>"; } $echo .= "</table>"; echo $echo; } else { echo "nie ma klanu o podobnej nazwie"; } } break; case 'clan': if (empty($_GET['id'])) {
<UL class='buttons'> <?php $player_towns = get_all("select t_id, t_name from towns where t_usr_id = " . $player->usr_id); $echo = ''; foreach ($player_towns as $town) { $echo .= "<LI><a href='?action=town&set_town=" . $town->t_id . "'>{$town->t_name}</a></LI>"; } echo $echo; ?> </UL> </div> </DIV> <DIV id="content" class="contentNormal"> <?php if (!empty($_POST['name'])) { $_POST['name'] = textV($_POST['name']); if (!empty($_POST['name'])) { if (strlen($_POST['name']) >= 5 && strlen($_POST['name']) <= 15) { $ok = get_one("select count(*) from towns where t_name = '" . $_POST['name'] . "'"); if ($ok > 0) { echo "ta nazwa jest zajęta<hr/>"; } else { call("update towns set t_name = '" . $_POST['name'] . "' where t_id = " . $player->town->t_id); reload($config, 'town', ''); } } else { echo "nieodpowiednia długość nazwy miasta (5-15znaków)<hr/>"; } } } ?>
if (empty($_GET['type'])) { $_GET['type'] = 0; } if (empty($_GET['subtype'])) { $_GET['subtype'] = 0; } if (empty($_GET['who'])) { $_GET['who'] = ''; } if (empty($_GET['mid'])) { $_GET['mid'] = 0; } $_GET['mid'] = intV($_GET['mid']); $_GET['type'] = intV($_GET['type']); $_GET['subtype'] = intV($_GET['subtype']); $_GET['who'] = textV($_GET['who']); if (!empty($_GET['who'])) { $who = get_one("select usr_id from arena_users where login = '******'who'] . "'"); $object = get_row("select * from arena_map where m_who = " . $who . " limit 1"); $player_map = get_row("select * from arena_map where m_who = " . $player->usr_id . " limit 1"); if (!empty($object)) { if ($player_map->m_x >= $object->m_x - 1 && $player_map->m_x <= $object->m_x + 1 && $player_map->m_y >= $object->m_y - 1 && $player_map->m_y <= $object->m_y + 1) { echo "\n\t\t\t<div class='highslide-header'><b>" . $_GET['who'] . "</b> [esc - wyjście]\n\t\t\t\t<ul>\n\t\t\t\t\t<li class='highslide-move'>\n\t\t\t\t\t\t<a style='color:#000000' href='#' style='color:#000000' title='przesuń' onclick='return false'>\n\t\t\t\t\t\t\t<span><></span>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</li>\n\t\t\t\t\t<li class='highslide-close'>\n\t\t\t\t\t\t<a style='color:#000000' href='#' title='zamknij' onclick='hs.height = 120; hs.width = 220; return hs.close(this)'>\n\t\t\t\t\t\t\t<span>zamknij</span>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\n\t\t\t<p>\n\t\t\thello\n\t\t\t</p>\n\t\t\t\n\t\t\t"; } else { echo "\n\t\t\t<div class='highslide-header'><b>" . $_GET['who'] . "</b> [esc - wyjście]\n\t\t\t\t<ul>\n\t\t\t\t\t<li class='highslide-move'>\n\t\t\t\t\t\t<a style='color:#000000' href='#' title='przesuń' onclick='return false'>\n\t\t\t\t\t\t\t<span><></span>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</li>\n\t\t\t\t\t<li class='highslide-close'>\n\t\t\t\t\t\t<a style='color:#000000' href='#' title='zamknij' onclick='hs.height = 120; hs.width = 220; return hs.close(this)'>\n\t\t\t\t\t\t\t<span>zamknij</span>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\n\t\t\t<p>\n\t\t\tza daleko\n\t\t\t</p>\n\t\t\t\n\t\t\t"; } } else { echo "\n\t\t\t<div class='highslide-header'><b>...</b> [esc - wyjście]\n\t\t\t\t<ul>\n\t\t\t\t\t<li class='highslide-move'>\n\t\t\t\t\t\t<a style='color:#000000' href='#' title='przesuń' onclick='return false'>\n\t\t\t\t\t\t\t<span><></span>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</li>\n\t\t\t\t\t<li class='highslide-close'>\n\t\t\t\t\t\t<a style='color:#000000' href='#' title='zamknij' onclick='hs.height = 120; hs.width = 220; return hs.close(this)'>\n\t\t\t\t\t\t\t<span>zamknij</span>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\n\t\t\t\n\t\t\t"; } } else { $object = get_row("select * from arena_map left join arena_monsters on mo_id = m_subtype where m_type = " . $_GET['type'] . " and m_subtype = " . $_GET['subtype'] . " and m_id = " . $_GET['mid'] . " limit 1");
public function msg_admin_send_mass($config, $text) { $text = textV($text); call("insert into arena_messages (m_from, m_to, m_type, m_text, m_date)\n\t\t\tselect 1,usr_id,1,'" . $text . "', now() from users\n\t\t"); return "wiadomość wysłano"; }
public function set_mail($config, $player, $email) { $email = textV($email); call("update arena_users set email = '" . $email . "' where usr_id = " . $player); }
public function army_send($config, $player, $town, $units) { $town = textV($town); $sum = 0; foreach ($units as $unit) { $unit = (int) $unit; $sum += $unit; } if ($sum < 1) { $msg = 'wyślij minimum 1 jednostkę'; } else { $check = count($units); foreach ($units as $key => $value) { $can = get_row("select * from game_objects where go_type = 3 and go_subtype = {$key} and go_t_id =" . $player->actual_town . " and go_lvl >= {$value}"); if (!empty($can)) { $check--; } $units1[$key]->data = $can; $units1[$key]->count = $value; } if ($check != 0) { $msg = 'nie posiadasz tyle jednostek'; } else { $event_check = get_one("select count(*) from events where (e_type = 30 or e_type = 31) and e_done = 0 and e_t_id = " . $player->actual_town); if ($event_check > 9) { $msg = 'masz już maksymalną ilość wysłanych wypraw wojskowych'; } else { $can = get_row("select t_id, t_usr_id from towns where t_name ='" . $town . "' limit 1"); if (empty($can)) { $msg = 'nie ma takiego miasta'; } elseif ($can->t_usr_id == $player->usr_id) { $msg = 'nie atakuj swojego miasta'; } else { $y = get_row("select * from map where m_t_id =" . $can->t_id); $x = get_row("select * from map where m_t_id =" . $player->actual_town); if ($x->m_x != $y->m_x && $x->m_y == $y->m_y) { $range = abs($y->m_x - $x->m_x) * 300; } elseif ($x->m_x == $y->m_x && $x->m_y != $y->m_y) { $range = abs($y->m_y - $x->m_y) * 300; } else { $range = floor(sqrt(pow(abs($y->m_x - $x->m_x), 2) + pow(abs($y->m_y - $x->m_y), 2))) * 300; } $tnow = get_one("select unix_timestamp()"); call("insert into army (a_t_id, a_vs_id) value (" . $player->actual_town . "," . $can->t_id . ")"); $army_id = get_one("select last_insert_id()"); $insert = "insert into army_units(au_a_id, au_gop_subtype, au_counts, au_attack, au_defence, au_life, au_range) values "; foreach ($units1 as $unit) { call("update game_objects set go_lvl = go_lvl - " . $unit->count . " where go_type = 3 and go_subtype = " . $unit->data->go_subtype . " and go_t_id =" . $player->actual_town); $insert .= "(" . $army_id . "," . $unit->data->go_subtype . "," . $unit->count . "," . $unit->data->go_attack . "," . $unit->data->go_defence . "," . $unit->data->go_life . "," . $unit->data->go_range . "),"; } $insert = substr($insert, 0, -1); call($insert); require_once 'functions/EventsMgr.php'; $EventMgr = new EventsMgr(); $EventMgr->event_add($config, $player->actual_town, 30, $can->t_id, $army_id, 0, $tnow, $tnow + $range, 0); $msg = 'wysłano wyprawę do miasta ' . $town; } } } } return $msg; }
<?php if (empty($_GET['player'])) { echo "\n\t<div class='pageSubnav' id='armyNav'>\n\t</div>\n\t<DIV id='content' class='contentNormal'>\n\t<div class='box'>\n\tnie wybrano gracza\n\t"; } else { $_GET['player'] = textV($_GET['player']); $get_player_info_and_towns = get_all("select u.login as login, u.avatar as avatar, t.t_name as town, c.c_name as clan, m.m_x as x, m.m_y as y, u.usr_id as usr, u.opis as opis from users u inner join towns t on t.t_usr_id = u.usr_id inner join map m on m.m_t_id = t.t_id left join clans c on c.c_id = u.clan_id where u.login ='******'player'] . "'"); if (!empty($get_player_info_and_towns)) { echo "\n\t\t<div class='pageSubnav' id='armyNav'>\n\t\t\t<h2>Opcje</h2>\n\t\t\t<ul class='buttons'>\n\t\t\t\t<li><a href='?action=messages&to=" . $get_player_info_and_towns[0]->login . "'>Wyślij wiadomość</a></li>\n\n\t\t\t</ul>\n\t\t</div>\n\t\t<DIV id='content' class='contentNormal'>\n\t\t<div class='box'>\n\t\t"; $count = count($get_player_info_and_towns); if ($get_player_info_and_towns[0] == 0) { $av = "<img src='avatar/noavatar.png' alt='' style='float:left' />"; } else { $av = "<img src='avatar/" . $get_player_info_and_towns[0]->usr . ".jpg' alt='' style='max-width:150px; max-height:150px;float:left'/>"; } if (!empty($get_player_info_and_towns[0]->clan)) { $get_player_info_and_towns[0]->clan = "[ klan " . $get_player_info_and_towns[0]->clan . " ] "; } echo "\n\t\t<h3>Gracz: " . $get_player_info_and_towns[0]->login . " ( miast: " . $count . " ) " . $get_player_info_and_towns[0]->clan . "</h3>\n\t\t" . $av . "\n\t\t<div style=' margin-left:160px;'>\n\t\t" . $get_player_info_and_towns[0]->opis . "\n\t\t</div>\n\t\t<hr style='clear:both'>\n\t\t<table>\n\t\t<tr>\n\t\t\t<th colspan=4 style=' padding:5px'><h4>miasta:</h4></th>\n\t\t</tr>\n\t\t"; if (is_array($get_player_info_and_towns)) { foreach ($get_player_info_and_towns as $town) { echo "\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2> nazwa: <b>" . $town->town . "</b></td>\n\t\t\t\t\t<td colspan=2 style='padding-left:20px'> położenie [ <a href='?action=map&x=" . $town->x . "&y=" . $town->y . "'>" . $town->x . " : " . $town->y . "</a> ]</td>\n\t\t\t\t</tr>"; } } else { echo "\n\t\t\t<tr>\n\t\t\t\t<td colspan=2> nazwa: " . $get_player_info_and_towns->town . "</td>\n\t\t\t\t<td colspan=2> położenie: [ " . $get_player_info_and_towns->x . " : " . $get_player_info_and_towns->y . " ]</td>\n\t\t\t</tr>"; } echo "\n\t\t</table>"; } else { echo "\n\t\t<div class='pageSubnav' id='armyNav'>\n\t\t</div>\n\t\t<DIV id='content' class='contentNormal'>\n\t\t<div class='box'>\n\t\tnie ma takiego użytkownika\n\t\t"; }