當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Globals::isValidGame方法代碼示例

本文整理匯總了PHP中Globals::isValidGame方法的典型用法代碼示例。如果您正苦於以下問題:PHP Globals::isValidGame方法的具體用法?PHP Globals::isValidGame怎麽用?PHP Globals::isValidGame使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Globals的用法示例。


在下文中一共展示了Globals::isValidGame方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: create_error

if (empty($player_name)) {
    create_error('You must enter a player name!');
}
$race_id = $_REQUEST['race_id'];
if (empty($race_id) || $race_id == 1) {
    create_error('Please choose a race!');
}
if (!is_numeric($var['game_id'])) {
    create_error('Game ID is not numeric');
}
$gameID = $var['game_id'];
$db->query('SELECT 1 FROM player WHERE game_id = ' . $db->escapeNumber($gameID) . ' AND player_name = ' . $db->escape_string($player_name, true) . ' LIMIT 1');
if ($db->nextRecord() > 0) {
    create_error('The player name already exists.');
}
if (!Globals::isValidGame($gameID)) {
    create_error('Game not found!');
}
// does it cost something to join that game?
$credits = Globals::getGameCreditsRequired($gameID);
if ($credits > 0) {
    if ($account->getTotalSmrCredits() < $credits) {
        create_error('You do not have enough credits to join this game!');
    }
    $account->decreaseTotalSmrCredits($credits);
}
// check if hof entry is there
$db->query('SELECT 1 FROM account_has_stats WHERE account_id = ' . $db->escapeNumber(SmrSession::$account_id) . ' LIMIT 1');
if (!$db->nextRecord()) {
    $db->query('INSERT INTO account_has_stats (account_id, HoF_name) VALUES (' . $db->escapeNumber($account->getAccountID()) . ', ' . $db->escape_string($account->getLogin(), true) . ')');
}
開發者ID:smrealms,項目名稱:smrv2.0,代碼行數:31,代碼來源:game_join_processing.php

示例2: array

        $boxTypeID = $db->getInt('box_type_id');
        $container['box_type_id'] = $boxTypeID;
        $boxes[$boxTypeID] = array('ViewHREF' => SmrSession::getNewHREF($container), 'BoxName' => $db->getField('box_type_name'), 'TotalMessages' => $db->getField('count(message_id)'));
    }
    $template->assign('Boxes', $boxes);
} else {
    $template->assign('BackHREF', SmrSession::getNewHREF(create_container('skeleton.php', 'box_view.php')));
    $db->query('SELECT * FROM message_boxes WHERE box_type_id=' . $db->escapeNumber($var['box_type_id']) . ' ORDER BY send_time DESC');
    $messages = array();
    if ($db->getNumRows()) {
        $container = create_container('box_delete_processing.php');
        $container['box_type_id'] = $var['box_type_id'];
        $template->assign('DeleteHREF', SmrSession::getNewHREF($container));
        while ($db->nextRecord()) {
            $gameID = $db->getInt('game_id');
            $validGame = $gameID > 0 && Globals::isValidGame($gameID);
            $messageID = $db->getInt('message_id');
            $messages[$messageID] = array('ID' => $messageID);
            $senderAccount =& SmrAccount::getAccount($db->getField('sender_id'));
            $senderName = $senderAccount->getLogin() . ' (' . $senderAccount->getAccountID() . ')';
            if ($validGame) {
                $senderPlayer =& SmrPlayer::getPlayer($senderAccount->getAccountID(), $gameID);
                if ($senderAccount->getLogin() != $senderPlayer->getPlayerName()) {
                    $senderName .= ' a.k.a ' . $senderPlayer->getPlayerName();
                }
                $container = create_container('skeleton.php', 'box_reply.php');
                $container['sender_id'] = $senderAccount->getAccountID();
                $container['game_id'] = $gameID;
                $messages[$messageID]['ReplyHREF'] = SmrSession::getNewHREF($container);
            }
            $messages[$messageID]['SenderName'] = $senderName;
開發者ID:smrealms,項目名稱:smrv2.0,代碼行數:31,代碼來源:box_view.php


注:本文中的Globals::isValidGame方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。