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


PHP Website::generateSessionKey方法代碼示例

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


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

示例1: header

<?php

header('Content-Type: application/json');
if (!$logged) {
    echo '{"errorcode":-2}';
    // player is not logged
    return;
}
$res = $SQL->query("SELECT * FROM accounts_options WHERE account_id = " . $account_logged->getID())->fetch();
if ($data = json_decode(file_get_contents("php://input"))) {
    if ($sid = @$data->{"sid"}) {
        echo '{"errorcode":0,"token":"' . Website::generateSessionKey() . '"}';
    }
    if ($options = @$data->{"options"} && ($token = @$data->{"token"})) {
        if ($res["options"] == "") {
            $SQL->query("INSERT INTO accounts_options VALUES(" . $account_logged->getID() . ", '" . $data->{"options"} . "')");
        } else {
            $SQL->query("UPDATE accounts_options SET options = '" . str_replace("\n", "\\n", $data->{"options"}) . "' WHERE account_id = " . $account_logged->getID() . "");
        }
        echo '{"errorcode":0}';
    }
    return;
}
$options = str_replace("\n", "\\n", $res["options"]);
if ($options == "") {
    echo '{"errorcode":-1}';
    // player does not have any options
    return;
}
echo '{"errorcode":0,"options":"' . $options . '"}';
開發者ID:totolol123,項目名稱:TFS-Flash,代碼行數:30,代碼來源:client_options_serverscript.php

示例2: Player

<!-- PHP Handler -->
<?php 
if (!defined('INITIALIZED')) {
    exit;
}
$player = new Player();
$player->loadByName(htmlspecialchars($_REQUEST['name']));
if ($player->isLoaded()) {
    $account = array('sessionKey' => Website::generateSessionKey());
    $server = array('WorldID' => 1, 'ip' => $_SERVER['SERVER_ADDR'], 'port' => 7172);
    $accountCharacters = "";
    $selected_character = "";
    foreach ($account_logged->getPlayersList() as $character) {
        if (strtolower($player->getName()) == strtolower($character->getName())) {
            $selected_character = "<character name='" . htmlspecialchars($character->getName()) . "' worldid='" . $server['WorldID'] . "' selected='true' />";
        } else {
            $accountCharacters .= "<character name='" . htmlspecialchars($character->getName()) . "' worldid='" . $server['WorldID'] . "' selected='false' />";
        }
    }
    $accountCharacters .= $selected_character;
    $SQL->query("UPDATE `accounts` SET `authToken` = '" . $account['sessionKey'] . "' WHERE `name` = '" . $account_logged->getName() . "'");
}
?>

<html>
	<head>
		<title><?php 
echo htmlspecialchars($config['server']['serverName']);
?>
 Flash Client</title>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
開發者ID:totolol123,項目名稱:TFS-Flash,代碼行數:31,代碼來源:play.php


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