本文整理汇总了PHP中get_one函数的典型用法代码示例。如果您正苦于以下问题:PHP get_one函数的具体用法?PHP get_one怎么用?PHP get_one使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_one函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
$departModel = M('Depart');
$allDepart = $departModel->select();
$adminuid = C('users')['666666'];
$allDepart = get_one($allDepart, 'id');
if ($this->uid != $adminuid) {
$allDepart = array($allDepart[$this->uid]);
}
$this->assign('departList', $allDepart);
$this->display();
}
示例2: caravan_send
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;
}
示例3: buy_coins
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;
}
示例4: msg_send
public function msg_send($config, $user, $to, $text)
{
$user = (int) $user;
$to = textV($to);
$text = textV($text);
$to_user = get_one("select usr_id from users where login ='" . $to . "' limit 1");
if (!empty($to_user)) {
call("insert into messages (m_from, m_to, m_type, m_text, m_date)\n\t\t\t\t values(" . $user . "," . $to_user . ",2,'" . $text . "',now()),(" . $user . "," . $to_user . ",1,'" . $text . "',now())");
return "wiadomość wysłano";
} else {
return "nie ma takiego użytkownika";
}
}
示例5: new_town
public function new_town($config, $player)
{
if ($player->actual_town == 0) {
$is = get_one("select count(*) from towns where t_name ='" . $player->town . "'");
if ($is == 1) {
$player->town .= date("His");
}
call("\n\t\t\tinsert into towns (t_usr_id, t_name, t_nation, t_last_inc)\n\t\t\tvalue (" . $player->usr_id . ",'" . $player->town . "'," . $player->nation . ", unix_timestamp())\n\t\t\t");
$town_id = get_one("select last_insert_id()");
call("\n\t\t\tupdate map\n\t\t\tset m_t_id = {$town_id}\n\t\t\twhere m_t_id = 0\n\t\t\torder by rand() limit 1\n\t\t\t");
call("\n\t\t\tupdate users\n\t\t\tset actual_town = {$town_id}\n\t\t\twhere usr_id = " . $player->usr_id);
call("\n\t\t\tinsert into town_objects (to_t_id, to_gop_id, to_can)\n\t\t\tselect " . $town_id . ", gop_id, gop_can\n\t\t\tfrom game_objects_param\n\t\t\twhere gop_nation = " . $player->nation);
reload($config, 'town', '');
}
}
示例6: login
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 = '" . $login . "' and pass = '" . $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;
}
示例7: require_auth
/**
* Verifies if the user is logged in and authenticates if not and POST contains username, else displays the login form
* @return bool Returns true when the user has been logged in
*/
function require_auth()
{
global $errors;
// If user has already logged in...
if ($this->logged_in) {
return TRUE;
}
// Authenticate by POST data
if (isset($_POST['username'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$user_id = get_one("SELECT user_id FROM user WHERE username = '{$username}' AND password = '{$password}'");
if (!empty($user_id)) {
$_SESSION['user_id'] = $user_id;
return true;
} else {
$errors[] = "Vale kasutajanimi või parool";
}
}
// Display the login form
require 'templates/auth_template.php';
// Prevent loading the requested controller (not authenticated)
exit;
}
示例8: intval
<?php
require "config.php";
require "system/database.php";
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
if (isset($_GET["kuupaeva_id"]) && !empty($_GET["kuupaeva_id"])) {
$id = intval($_GET["kuupaeva_id"]);
$inimeste_arv = get_one("SELECT SUM(inimeste_arv) FROM broneering WHERE kuupaeva_id = {$id}");
$vabad = 26 - $inimeste_arv;
echo $vabad;
}
} else {
echo "Sa oled vales kohas. <a href='/do'>Mine tagasi esilehele!</a>";
}
示例9: isUser
require_once 'funkcje/podstawowe.php';
isUser($config);
$player = getUser($config);
if (empty($_GET['type'])) {
$_GET['type'] = 0;
}
if (empty($_GET['subtype'])) {
$_GET['subtype'] = 0;
}
if (empty($_GET['mid'])) {
$_GET['mid'] = 0;
}
$_GET['mid'] = intV($_GET['mid']);
$_GET['type'] = intV($_GET['type']);
$_GET['subtype'] = intV($_GET['subtype']);
$object = get_one("select m_id from arena_map inner join arena_monsters on mo_id = m_subtype where m_type = 5 and m_subtype = " . $_GET['subtype'] . " and m_id = " . $_GET['mid'] . " limit 1");
if (!empty($object)) {
switch ($_GET['subtype']) {
case 1:
$items = get_all("select * from arena_items_param ");
echo "\n\t\t\t\t\t\t\t<div class='highslide-header'><b>Meglash</b> [esc - wyjście]\n\t\t\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t\t\t<li class='highslide-move'>\n\t\t\t\t\t\t\t\t\t\t<a style='color:#000000' href='#' title='przesuń' onclick='return false'>\n\t\t\t\t\t\t\t\t\t\t\t<span><></span>\n\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t<li class='highslide-close'>\n\t\t\t\t\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\t\t\t\t<span>zamknij</span>\n\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t";
$echo = '';
if (is_array($items)) {
foreach ($items as $item) {
$options = '';
if ($item->ip_gold <= $player->gold) {
$options .= "<a style='color:#000000' href='?action=map&item_buy=" . $item->ip_id . "' >[ kup ]</a>";
}
$item->ip_text .= "<br/>";
if ($item->ip_attack > 0) {
$item->ip_text .= "Zwiększa <span class='red'>atak</span> herosa o <span class='red'>" . 1 * $item->ip_attack . "</span><br/>";
示例10: get_all
}
$skills = get_all("select * from arena_skills_param left join arena_user_skills on sp_id = us_sp_id and us_usr_id =" . $player->usr_id);
$echo = '';
foreach ($skills as $skill) {
if (empty($skill->us_lvl)) {
$skill->us_lvl = 0;
$skill->us_active = 0;
$price = 1;
} else {
$price = $skill->us_lvl;
}
$options = '';
if ($skill->us_active == 0 && $player->skills > $skill->us_lvl) {
$options = "<a href='?action=skills&skillup=" . $skill->sp_id . "'>[ zwiększ za " . $price . " PU ]</a> ";
}
$limit = get_one("select count(*) from arena_user_skills where us_usr_id = " . $player->usr_id . " and us_active = 1");
if ($skill->us_active == 0 && $skill->us_lvl > 0 && $limit < 3) {
$options .= "<a style='color:#F39604' href='?action=skills&active=" . $skill->sp_id . "'>[ aktywuj ]</a>";
} elseif ($skill->us_active == 1 && $skill->us_lvl > 0) {
$options .= "<a href='?action=skills&deactive=" . $skill->sp_id . "'>[ deaktywuj ]</a>";
}
$skill->sp_text .= "<br/>";
if ($skill->sp_attack > 0) {
$skill->sp_text .= "Aktywowana zdolność będzie zwiększać <span class='red'>atak</span> herosa o <span class='red'>" . $price * $skill->sp_attack . "</span> [" . $skill->sp_attack . " na każdy poziom ]<br/>";
}
if ($skill->sp_defence > 0) {
$skill->sp_text .= "Aktywowana zdolność będzie zwiększać <span class='red'>obronę</span> herosa o <span class='red'>" . $price * $skill->sp_defence . "</span> [" . $skill->sp_defence . " na każdy poziom ]<br/>";
}
if ($skill->sp_absorb > 0) {
$skill->sp_text .= "Aktywowana zdolność będzie zwiększać <span class='red'>absorbcję</span> herosa o <span class='red'>" . $price * $skill->sp_absorb . "</span> [" . $skill->sp_absorb . " na każdy poziom ]<br/>";
}
示例11: confirm_logged_in
<?php
require_once 'includes/load.php';
//ucitaj pomocne fajlove
include_once 'includes/header_admin.php';
//ukljuci admin menu
confirm_logged_in();
//potvrdi ulogovanost
if (isset($_GET['id'])) {
//ako je prosledjen id
$id = $_GET['id'];
//preuzmi id
$news = get_one('news', $id);
//preuzmi podatke
} else {
//ako nije prosledjen
echo redirect('staff.php');
//prebaci ga na staff.php
}
?>
<!-- POCETAK - prikazi sadrzaj vijesti -->
<h2><?php
echo $news['title'];
?>
</h2>
<?php
if (file_exists($news['img_path'])) {
echo '<center><img src="' . $news['img_path'] . '" width="400"></center>';
}
?>
示例12: build_end
//.........这里部分代码省略.........
//Wiedza o skałach
if ($object->go_lvl == 0) {
call("\n\t\t\t\t\t\t\tinsert into game_objects (go_t_id, go_type, go_subtype, go_gop_id, go_wood, go_stone, go_iron, go_pop, go_time)\n\t\t\t\t\t\t\tvalue( {$town}, {$type}, {$subtype}, {$object->gop_id}, {$object->gop_wood} * ((100 + {$object->gop_res_inc})/100), {$object->gop_stone} * ((100 + {$object->gop_res_inc})/100), {$object->gop_iron} * ((100 + {$object->gop_res_inc})/100), {$object->gop_pop} * ((100 + {$object->gop_res_inc})/100), {$object->gop_time} * ((100 + {$object->gop_time_inc})/100))");
call("update towns set t_iron_inc = t_iron_inc * 1.1 where t_id = {$town}");
} else {
call("update towns set t_iron_inc = t_iron_inc * 1.1 where t_id = {$town}");
call("\n\t\t\t\t\t\t\tupdate game_objects \n\t\t\t\t\t\t\tset go_lvl = go_lvl + 1, go_wood = go_wood * ((100 + {$object->gop_res_inc})/100), go_stone = go_stone * ((100 + {$object->gop_res_inc})/100), go_iron = go_iron * ((100 + {$object->gop_res_inc})/100), go_pop= go_pop * ((100 + {$object->gop_res_inc})/100), go_time = go_time * ((100 + {$object->gop_time_inc})/100)\n\t\t\t\t\t\t\twhere go_t_id = {$town} and go_type = {$type} and go_subtype = {$subtype}");
}
break;
case 4:
//higiena
if ($object->go_lvl == 0) {
call("\n\t\t\t\t\t\t\tinsert into game_objects (go_t_id, go_type, go_subtype, go_gop_id, go_wood, go_stone, go_iron, go_pop, go_time)\n\t\t\t\t\t\t\tvalue( {$town}, {$type}, {$subtype}, {$object->gop_id}, {$object->gop_wood} * ((100 + {$object->gop_res_inc})/100), {$object->gop_stone} * ((100 + {$object->gop_res_inc})/100), {$object->gop_iron} * ((100 + {$object->gop_res_inc})/100), {$object->gop_pop} * ((100 + {$object->gop_res_inc})/100), {$object->gop_time} * ((100 + {$object->gop_time_inc})/100))");
call("update towns set t_pop_max = t_pop_max * 1.1 where t_id = {$town}");
} else {
call("\n\t\t\t\t\t\t\tupdate game_objects \n\t\t\t\t\t\t\tset go_lvl = go_lvl + 1, go_wood = go_wood * ((100 + {$object->gop_res_inc})/100), go_stone = go_stone * ((100 + {$object->gop_res_inc})/100), go_iron = go_iron * ((100 + {$object->gop_res_inc})/100), go_pop= go_pop * ((100 + {$object->gop_res_inc})/100), go_time = go_time * ((100 + {$object->gop_time_inc})/100)\n\t\t\t\t\t\t\twhere go_t_id = {$town} and go_type = {$type} and go_subtype = {$subtype}");
call("update towns set t_pop_max = t_pop_max * 1.1 where t_id = {$town}");
}
break;
case 5:
//magazynynowanie
if ($object->go_lvl == 0) {
call("\n\t\t\t\t\t\t\tinsert into game_objects (go_t_id, go_type, go_subtype, go_gop_id, go_wood, go_stone, go_iron, go_pop, go_time)\n\t\t\t\t\t\t\tvalue( {$town}, {$type}, {$subtype}, {$object->gop_id}, {$object->gop_wood} * ((100 + {$object->gop_res_inc})/100), {$object->gop_stone} * ((100 + {$object->gop_res_inc})/100), {$object->gop_iron} * ((100 + {$object->gop_res_inc})/100), {$object->gop_pop} * ((100 + {$object->gop_res_inc})/100), {$object->gop_time} * ((100 + {$object->gop_time_inc})/100))");
call("update towns set t_res_max = t_res_max * 1.2 where t_id = {$town}");
} else {
call("update towns set t_res_max = t_res_max * 1.2 where t_id = {$town}");
call("\n\t\t\t\t\t\t\tupdate game_objects \n\t\t\t\t\t\t\tset go_lvl = go_lvl + 1, go_wood = go_wood * ((100 + {$object->gop_res_inc})/100), go_stone = go_stone * ((100 + {$object->gop_res_inc})/100), go_iron = go_iron * ((100 + {$object->gop_res_inc})/100), go_pop= go_pop * ((100 + {$object->gop_res_inc})/100), go_time = go_time * ((100 + {$object->gop_time_inc})/100)\n\t\t\t\t\t\t\twhere go_t_id = {$town} and go_type = {$type} and go_subtype = {$subtype}");
}
break;
}
break;
case 3:
//units
$is_unit = get_one("select go_id from game_objects where go_t_id = {$town} and go_type = {$type} and go_subtype = {$subtype} limit 1");
if (empty($is_unit)) {
call("\n\t\t\t\t\t\t\tinsert into game_objects (go_t_id, go_type, go_subtype, go_gop_id, go_wood, go_stone, go_iron, go_pop, go_time, go_attack, go_defence, go_life, go_range, go_lvl)\n\t\t\t\t\t\t\tvalue( {$town}, {$type}, {$subtype}, {$object->gop_id}, {$object->gop_wood} , {$object->gop_stone} , {$object->gop_iron}, {$object->gop_pop}, {$object->gop_time},{$object->gop_attack}, {$object->gop_defence}, {$object->gop_life}, {$object->gop_range}, {$count})");
} else {
call("\n\t\t\t\t\t\t\tupdate game_objects \n\t\t\t\t\t\t\tset go_lvl = go_lvl + {$count}\n\t\t\t\t\t\t\twhere go_t_id = {$town} and go_type = {$type} and go_subtype = {$subtype}");
}
break;
case 10:
require_once 'functions/SpyMgr.php';
$SpyMgr = new SpyMgr();
$newevent->e_t_id = $town;
$newevent->e_type = $type;
$newevent->e_subtype = $subtype;
$newevent->e_count = $count;
$newevent->e_start = $start;
$newevent->e_end = $end;
$SpyMgr->spy_battle($config, $newevent);
break;
case 11:
require_once 'functions/SpyMgr.php';
$SpyMgr = new SpyMgr();
$SpyMgr->spy_dismis($config, $town, $count);
break;
case 20:
require_once 'functions/MarketMgr.php';
$MarketMgr = new MarketMgr();
$MarketMgr->caravan_unload($config, $subtype, $count);
$back = $MarketMgr->caravan_back($config, $town, $count);
break;
case 21:
require_once 'functions/MarketMgr.php';
$MarketMgr = new MarketMgr();
$MarketMgr->caravan_unload($config, $town, $count);
示例13: getUser
function getUser($config)
{
$player = get_row("select *, unix_timestamp() as tnow from users where usr_id = {$_SESSION['user']}");
$player->msg = get_one("select count(*) from messages where m_status = 0 and m_type = 1 and m_to = " . $player->usr_id);
return $player;
}
示例14: foreach
$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/>";
}
}
}
?>
<form action='?action=town' method='post'>
<input type='text' name='name' value ='<?php
echo $player->town->t_name;
示例15: send_app
public function send_app($config, $player, $clan)
{
$clan = (int) $clan;
$msg = '';
if ($player->clan_id > 0) {
$msg = 'jesteś już w klanie';
} else {
$can = get_one("select c_id from clans where c_id = " . $clan);
$is = get_one("select count(*) from clans_users where cu_c_id = " . $clan . " and cu_usr_id = " . $player->usr_id);
if (empty($can)) {
$msg = 'nie ma takiego klanu';
} elseif ($is > 0) {
$msg = 'już złożyłeś podanie do tego klanu';
} else {
call("insert into clans_users (cu_c_id, cu_usr_id) value (" . $clan . "," . $player->usr_id . ")");
$msg = 'wysłano podanie ';
}
}
return $msg;
}