本文整理汇总了PHP中Database::GetOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::GetOne方法的具体用法?PHP Database::GetOne怎么用?PHP Database::GetOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::GetOne方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getposition
public static function getposition($array)
{
$loc = Database::GetOne("config", array('mod' => 'locations'));
$tchar = Database::GetOne("characters", array('_id' => toId($_SESSION['cid'])));
$answer = json_encode(array('answer' => '1', 'loc' => $tchar['map'], 'map' => $loc[$tchar['map']]['map'], 'x' => $tchar['pos_x'], 'y' => $tchar['pos_y'], 'dir' => $tchar['dir'], 'skin' => $tchar['skin']));
return $answer;
}
示例2: actionIndex
function actionIndex()
{
if (!isset($_SESSION['id'])) {
header("Location: /");
die;
}
if (!isset($_SESSION['cid'])) {
header("Location: /cabinet");
die;
}
$main = new Templater();
$main->import("interface/game.tpl");
$main->setvar("%URL%", "http://" . $GLOBALS['url']);
$main->setvar("%STORAGE_TPL_URL%", "/storage/tpl");
$main->setvar("%YEAR%", date("Y"));
$main->setvar("%CSS%", "<style>" . templater("css/game.css", array("%ROOT%" => "/storage/tpl")) . "</style>");
$main->setvar("%GAME_TITLE%", $GLOBALS['name']);
$main->setvar("%STORAGE_STATIC_URL%", "/storage/static");
$GLOBALS['current_loc_info'] = Database::GetOne("config", array("mod" => "locations"))[char()->map];
if (!isset($GLOBALS['current_loc_info']['type']) or $GLOBALS['current_loc_info']['type'] == 'default') {
$main->setvar("%GUI%", template("interface/GUI.tpl"));
} else {
$GLOBALS['current_loc_type_info'] = Database::GetOne("config", array("mod" => "location_types"))[$GLOBALS['current_loc_info']['type']];
require_once MODS_ROOT . SEPARATOR . $GLOBALS['current_loc_type_info']['module'] . SEPARATOR . "location_type.php";
$main->setvar("%GUI%", isset($GLOBALS['to_gui']) ? $GLOBALS['to_gui'] : '');
}
$main->setvar("%CHATBOX%", template("boxes/chat.tpl"));
$main->renderEcho();
}
示例3: read
public function read($id)
{
$data = Database::GetOne("sessions", array("sess_id" => $id));
if (is_array($data)) {
Database::Edit("sessions", array("sess_id" => $id), array("sess_id" => $id, "time" => time()));
return $data['data'];
} else {
Database::Insert("sessions", array("sess_id" => $id, "time" => time()));
return "";
}
}
示例4: actionIndex
public function actionIndex()
{
$article = Database::GetOne('wiki_pages', array('type' => 'main'));
//$side_menu = Database::GetOne('wiki_side_menu',array('status' => 1));
$tpl = new Templater();
$tpl->import('wiki/wiki.tpl');
$tpl->setvar('%GAME_TITLE%', $GLOBALS['name']);
$tpl->setvar("%YEAR%", date("Y"));
$tpl->setvar("%CONTENT%", $article['content']);
$tpl->setvar("%SIDE_MENU%", 'Тут будет кастомное меню');
$tpl->renderEcho();
}
示例5: actionRead
function actionRead()
{
$main = new Templater();
$main->import("interface/news_list.tpl");
$main->setvar("%URL%", "http://" . $GLOBALS['url']);
$main->setvar("%STORAGE_TPL_URL%", "/storage/tpl");
$main->setvar("%YEAR%", date("Y"));
$main->setvar("%GAME_TITLE%", $GLOBALS['name']);
$main->setvar("%STORAGE_STATIC_URL%", "/storage/static");
$array = Database::GetOne("news", array('_id' => toId($_GET['id'])));
$html = templater("interface/news_full.tpl", array("%SUBJECT%" => $array['title'], "%DATE%" => $array['date'], "%ANNOUNCE%" => $array['short'], "%TEXT%" => $array['full'], "%ID%" => $array['_id']));
$main->setvar("%CONTENT%", $html);
$main->renderEcho();
}
示例6: actionIndex
function actionIndex()
{
if (!isset($char)) {
$char = new Char();
}
$currency = Database::GetOne("config", array("mod" => "currency"));
$inv_params = Database::GetOne("config", array("mod" => "inv_params"));
$inv_actions = Database::GetOne("config", array("mod" => "inv_actions"));
$main = new Templater();
$main->import("boxes/inv_page.tpl");
$main->setvar("%URL%", "http://" . $GLOBALS['url']);
$main->setvar("%STORAGE_TPL_URL%", "/storage/tpl");
$main->setvar("%YEAR%", date("Y"));
$main->setvar("%CSS%", "<style>" . templater("css/game.css", array("%ROOT%" => "/storage/tpl")) . "</style>");
$main->setvar("%GAME_TITLE%", $GLOBALS['name']);
$main->setvar("%STORAGE_STATIC_URL%", "/storage/static");
$result = '';
foreach ($char->inv->getItems() as $key => $value) {
if (!is_array($value)) {
continue;
}
$addparams = array("%NAME%" => $value['name'], "%IMG%" => $value['image'], "%COST%" => $value['cost'], "%COUNT%" => $value['count'], "%C_NAME%" => $currency[$value['currency']]['name'], "%C_IMG%" => $currency[$value['currency']]['img'], "%CAT%" => $value['cat']);
$id = $key;
foreach ($inv_params as $skey => $svalue) {
if (!strstr($skey, "p_")) {
continue;
}
$addparams["%" . $skey . "%"] = $char->inv->getParam($skey, $key);
$addparams['%_PARAMS_%'] .= "<tr><td>" . $inv_params[$skey]['name'] . "</td><td>" . $char->inv->getParam($skey, $key) . "</td></tr>";
}
foreach ($inv_actions as $skey => $svalue) {
if (!strstr($skey, "act_")) {
continue;
}
if (eval($svalue['eval'])) {
$addparams["%_SCR_ACTIONS_%"][] = "<a href='?act=" . $skey . "&id=" . $id . "'>" . $svalue['name'] . "</a>";
if ($_GET['act'] == $skey and $_GET['id'] == $id) {
call_user_func("UseItem", $skey, $id);
}
}
}
$addparams["%_SCR_ACTIONS_%"] = isset($addparams["%_SCR_ACTIONS_%"]) ? implode(" / ", $addparams["%_SCR_ACTIONS_%"]) : '';
$result .= templater("boxes/inv_list.tpl", $addparams);
}
$main->setvar("%CONTENT%", $result);
$main->renderEcho();
}
示例7: actionMakechar
function actionMakechar()
{
$error = '';
if (isset($_POST['name'])) {
$maxchars = Database::GetOne("config", array("mod" => "auth"))['maxchars'];
$chars = Database::Get("characters", array("player" => $_SESSION['id']))->count();
if ($chars >= $maxchars) {
echo "Исчерпан лимит персонажей на одного игрока (" . $maxchars . ")";
} else {
$id = Char::create(array("name" => $_POST['name'], "gender" => $_POST['gender'], "about" => $_POST['about']));
if ($id != false) {
header("Location: /");
} else {
$error = "Персонаж уже существует";
}
}
}
}
示例8: actionRegister
function actionRegister()
{
if (Database::GetOne("config", array("mod" => "auth"))['allowRegister'] == 0 and $_SESSION['invited'] !== true) {
echo "<script>alert('Регистрация закрыта'); window.location = '/';</script>";
die;
}
if ($res = Player::register($_POST['login'], $_POST['password'], $_POST['email'])) {
$_SESSION['id'] = $res;
if ($_SESSION['invited'] === true) {
$_SESSION['invited'] = false;
}
call_user_func("onPlayerRegister", $_POST['login'], $_POST['password'], $_POST['email']);
@header("Location: /cabinet");
die("<script>location.href = '/cabinet';</script>");
} else {
@header("Location: /index?result=regerror");
die("<script>location.href = '/index?result=regerror';</script>");
}
}
示例9: __call
function __call($func, $args)
{
$func = str_replace("action", "", $func);
if ($func != 'index') {
$array = Database::GetOne("characters", array("name" => $func));
} else {
$array = Database::GetOne("characters", array("_id" => toId($_SESSION['cid'])));
$func = $array['name'];
}
if (!isset($array['name'])) {
die("<h1>Персонаж " . $func . " не найден</h1>");
}
$params = Database::GetOne("config", array("mod" => "params"));
$main = new Templater();
$main->import("interface/playerinfo.tpl");
$main->setvar("%URL%", "http://" . $GLOBALS['url']);
$main->setvar("%STORAGE_TPL_URL%", "/storage/tpl");
$main->setvar("%YEAR%", date("Y"));
$main->setvar("%CSS%", "<style>" . templater("css/game.css", array("%ROOT%" => "/storage/tpl")) . "</style>");
$main->setvar("%GAME_TITLE%", $GLOBALS['name']);
$main->setvar("%STORAGE_STATIC_URL%", "/storage/static");
$main->setvar("%GUI%", template("interface/GUI.tpl"));
$main->setvar("%CHATBOX%", template("boxes/chat.tpl"));
$params_all = '';
foreach ($array as $key => $value) {
if (MongoReserved($key) or MongoReserved($value) or strstr($key, "p_")) {
continue;
}
$main->setvar("%" . $key . "%", $array[$key]);
}
foreach ($params as $key => $value) {
if (!strstr($key, "p_")) {
continue;
}
$v = char(__toString($array['_id']))->getParam($key);
$main->setvar("%" . $key . "%", $v);
$params_all .= '<p><b>' . $value['name'] . '</b>: ' . $v . '</p>';
}
$main->setvar("%PARAMS_ALL%", $params_all);
$main->renderEcho();
}
示例10: login
public static function login($login, $password, $session = true)
{
if (empty($login)) {
raptor_warning("Trying to login player with no login");
}
if (empty($password)) {
raptor_warning("Trying to login player with no password");
}
$data = Database::GetOne("config", array("mod" => "auth"))['authType'];
$check = Database::GetOne("players", array($data => $login, "password" => md5($password)));
if (empty($check['login'])) {
return false;
} else {
if ($session === true) {
$_SESSION['id'] = $check['_id']->__toString();
}
Database::Edit("players", array("_id" => $check['_id']), array("last_ip" => $_SERVER['REMOTE_ADDR'], "last_date" => raptor_date()));
return $check['_id'];
}
call_user_func("onPlayerLogin", $_POST['name']);
}
示例11: actionIndex
function actionIndex()
{
$char = new Char();
$params = Database::GetOne("config", array("mod" => "currency"));
$main = new Templater();
$main->import("boxes/money_page.tpl");
$main->setvar("%URL%", "http://" . $GLOBALS['url']);
$main->setvar("%STORAGE_TPL_URL%", "/storage/tpl");
$main->setvar("%YEAR%", date("Y"));
$main->setvar("%CSS%", "<style>" . templater("game.css", array("%ROOT%" => "/storage/tpl")) . "</style>");
$main->setvar("%GAME_TITLE%", $GLOBALS['name']);
$main->setvar("%STORAGE_STATIC_URL%", "/storage/static");
$result = '';
foreach ($params as $key => $value) {
if (!is_array($value)) {
continue;
}
$result .= templater("boxes/money_list.tpl", array("%NAME%" => $value['name'], "%IMG%" => $value['img'], "%COUNT%" => $char->{$key}));
}
$main->setvar("%CONTENT%", $result);
$main->renderEcho();
}
示例12: actionIndex
function actionIndex()
{
$char = new Char();
$params = Database::GetOne("config", array("mod" => "mod_paidservice"));
$main = new Templater();
$main->import("boxes/ps_page.tpl");
$main->setvar("%URL%", "http://" . $GLOBALS['url']);
$main->setvar("%STORAGE_TPL_URL%", "/storage/tpl");
$main->setvar("%YEAR%", date("Y"));
$main->setvar("%CSS%", "<style>" . templater("css/game.css", array("%ROOT%" => "/storage/tpl")) . "</style>");
$main->setvar("%GAME_TITLE%", $GLOBALS['name']);
$main->setvar("%STORAGE_STATIC_URL%", "/storage/static");
$result = '';
if (isset($_GET['buy'])) {
if (!isset($params[$_GET['buy']]['time'])) {
$main->setvar("%CONTENT%", "<h2>Услуга не найдена</h2>");
$main->renderEcho();
return 1;
}
if ($char->{$params}[$_GET['buy']]['currency'] < $params[$_GET['buy']]['cost']) {
$main->setvar("%CONTENT%", "<h2>Недостаточно денег</h2>");
$main->renderEcho();
return 1;
}
$char->giveMoney(-$params[$_GET['buy']]['cost'], $params[$_GET['buy']]['currency']);
eval($params[$_GET['buy']]['eval_bought']);
createTimer($_GET['buy'], $params[$_GET['buy']]['time'], $params[$_GET['buy']]['eval_expired']);
}
foreach ($params as $key => $value) {
if (!is_array($value)) {
continue;
}
$result .= templater("boxes/ps_list.tpl", array("%ID%" => $key, "%NAME%" => $value['name'], "%COST%" => $value['cost'], "%TIME%" => $value['time'], "%CURRENCY%" => Database::GetOne("config", array("mod" => "currency"))[$value['currency']]['name'], "%TIME%" => $value['time']));
}
$main->setvar("%CONTENT%", $result);
$main->renderEcho();
}
示例13: array
<?php
if (isset($_POST['mod'])) {
Database::Edit("config", array("mod" => "locations"), $_POST);
foreach ($_POST as $key => $value) {
Cache::set("rpgjs_cmd" . $key, $value, 3600);
}
echo "<div class='alert alert-success'>Настройки применены. Кэш обновлен.</div>";
}
$data = Database::GetOne("config", array("mod" => "locations"));
?>
<div class="well">Под <b>командами</b> здесь подразумеваются команды скриптового движка из RPG.JS в формате JSON<br> <a target="_blank" href='/ahelp/cmdlist'>Подробный список команд</a></div>
<form action="" method="POST">
<div class="form-group">
<label>Команды, вызываемые при запуске игры</label>
<textarea class="form-control" name="_onrun" rows="3"><?php
echo $data['_onrun'];
?>
</textarea>
</div>
<div class="form-group">
<label>Команды, вызываемые каждые 1.5 секунд</label>
<textarea class="form-control" name="_onsync" rows="3"><?php
echo $data['_onsync'];
?>
</textarea>
</div>
<button type="submit" name="mod" value="locations" class="btn btn-default">Сохранить</button>
</form>
示例14: array
if (isset($_POST['name'])) {
Database::Edit("config", array("mod" => "inv_params"), array($_GET['edit'] => $_POST));
echo '<div class="alert alert-success">Параметр <b>' . $_GET['edit'] . '</b> успешно отредактирован</div>';
}
$param = Database::GetOne("config", array("mod" => "inv_params"))[$_GET['edit']];
echo '<form action="" method="POST">
<div class="form-group"><label for="disabledSelect">Код параметра</label><input class="form-control" id="disabledInput" placeholder="' . $_GET['edit'] . '" disabled="" type="text"></div>
<div class="form-group"><label>Название параметра</label><input name="name" value="' . $param['name'] . '" class="form-control"><p class="help-block">Название, отображаемое игрокам</p></div>
<div class="form-group"><label>Название параметра на английском</label><input name="name_en" value="' . $param['name_en'] . '" class="form-control"></div>
<div class="form-group"><label>Тип параметра</label><select name="type" onchange="if (this.selectedIndex == 3) document.getElementById(\'script_text\').style.display = \'block\'" class="form-control"><option value="int" ' . ($param['type'] == 'int' ? 'selected' : '') . '>Целое число</option><option value="float" ' . ($param['type'] == 'float' ? 'selected' : '') . '>Дробное число</option><option ' . ($param['type'] == 'str' ? 'selected' : '') . ' value="str">Строка</option><option ' . ($param['type'] == 'id' ? 'selected' : '') . ' value="id">ID персонажа</option><option ' . ($param['type'] == 'script' ? 'selected' : '') . ' value="script" >Формула (скриптовое выражение)</option></select></div>
<div class="form-group" style="display: ' . ($param['type'] == 'script' ? 'block' : 'none') . ';" id="script_text"><label>Формула</label><input name="script" value="' . $param['script'] . '" class="form-control"><p class="help-block">PHP-код. Переменная $char - объект с персонажем, $inv - с инвентарём. Пример использования: <b>return $char->name;</b></p></div>
<button type="submit" class="btn btn-default">Сохранить</button>
</form>';
} else {
echo '<div class="container-fluid"><h2>Параметры предметов</h2>
<h5>Различные характеристики предметов</h5>
<br>
<form method="POST">
<p><input name="name" value="p_" type="text"></p>
<p><button name="new" type="submit" value="1" class="btn btn-xs btn-default">Создать параметр</button></p>
</form>
<hr><div class="table-responsive">
<table class="table table-hover table-striped"><tbody>';
foreach (Database::GetOne("config", array("mod" => "inv_params")) as $key => $value) {
if (!strstr($key, "p_")) {
continue;
}
echo "<tr><td> <b><font size=3>" . $value['name'] . "</font></b> </td> <td> <b><font size=3>" . $key . "</font></b> </td> <td> <a href='?edit=" . $key . "'>Редактировать</a> </td></tr>";
}
echo '</tbody></table>';
}
示例15: array
<?php
if (isset($_POST['edit'])) {
Database::Edit('wiki_pages', array('content' => $_POST['edit']));
}
if (isset($_POST['add'])) {
if ($_POST['type'] == true) {
$type = 'main';
} else {
$type = 'default';
}
Database::Insert('wiki_pages', array('content' => $_POST['add'], 'type' => 'default', 'title' => $_POST['title'], 'alias' => $_POST['alias'], 'type' => $type));
}
if (isset($_GET['edit'])) {
$content = Database::GetOne('wiki_pages', array('alias' => $_GET['edit']));
echo "<form action='' method='POST'>\n <input type='hidden' name='file' value='" . $_GET['edit'] . "'>\n\t\t<label for='page_type'>Тип страницы</label>\n\t\t<input id='page_type' type='radio' name='type'>\n <textarea rows=15 cols=105 name='edit'>" . $content['content'] . "</textarea> <br>\n <button type='submit' class='btn btn-default'>Сохранить</button>\n </form>\n <hr>";
} else {
echo "";
}
if (isset($_GET['remove'])) {
$content = Database::Remove('wiki_pages', array('alias' => $_GET['remove']));
} else {
echo "";
}
if (isset($_GET['add'])) {
echo "<form action='' method='POST'>\n <label for='title'>Название страницы</label>\n\t\t<input id='title' type='text' style='width:635px;' name='title'><br>\n\t\t<label for='page_type'>Избранное</label>\n\t\t<input id='page_type' type='radio' name='type'><br>\n <label for='title'>Алиас (только английские буквы)</label>\n <input id='title' type='text' style='width:513px;' name='alias'><br>\n <textarea rows=15 cols=105 name='add'></textarea> <br>\n <button type='submit' class='btn btn-success'>Добавить</button>\n </form>\n <hr>";
} else {
echo "";
}
?>
<h2>Страницы</h2>