-1

まず、すべての回答に感謝します。彼らは皆感謝しています!OK、私はWebサイトユーザー用のTeamSpeakアクセス許可トークンを生成する方法をプログラミングしています。ボタンをクリックすると、2つのトークンが生成されます。それはすべてうまくいきます。システムの別の部分は、メンバーのWebサイトのユーザー名とIPアドレスを取得し、TeamSpeak3サーバーのMySQLデータベースを検索して、メンバーのserverID(自動インクリメント主キー)を見つけます。メンバーがこれを行うために使用するページをロードするだけで、エラーが発生します。「解析エラー:構文エラー、92行目の「FILEPATH-REPLACED」のファイルの予期しない終了」このファイルのコードは次のとおりです。

<?php
    if(!isset($member) || substr($_SERVER['PHP_SELF'], -11) != "console.php") {
    exit();
    }
    else {
    $memberInfo = $member->get_info();
    $consoleObj->select($_GET['cID']);
    if(!$member->hasAccess($consoleObj)) {
    exit();
    }
    }

    $rankObj = new Rank($mysqli);
    $rankObj->select($memberInfo['rank_id']);
    $RankInfo = $rankObj->get_info_filtered();
    $rankname = $RankInfo['name'];
    $cID = $_GET['cID'];
    $tsuid = "";

    $dispError = "";
    $countErrors = 0;
    if($_POST['submit']) {
        if($memberInfo['tsuid'] != "") {
        $tsuid = $memberInfo['tsuid'];
        $arrColumns = array("tsuid");
        $arrValues = array("");
        $member->update($arrColumns, $arrValues);
        }
        $ts3 = new IVTS3($tshost, $tsuser, $tspass, $tsdb);
        if($tsuid == "") {
        $tsuid = $ts3->getuid($memberInfo['username'], $memberInfo['ipaddress'], 0);
        if($tsuid == false) {
        die("Unable to retrieve TS UIDs. Please ensure you have been on our TeamSpeak Server using the same name as your website nickname. If you haven't been on our server, do so now, then regenerate tokens. Otherwise, contact Operations Support.");
        }
        $lastmembertoken = $memberInfo['tslasttokenmem'];
        $lastranktoken = $memberInfo['tslasttokenrank'];
        $lasttokens = ['rank' => $lastranktoken, 'mem' => $lastmembertoken];
        $newtoken = $ts3->createtoken($memberInfo['username'], $rankname, $lasttokens, $tsuid);
        $arrColumns = array("tslasttokenrank", "tslasttokenmem");
        $arrValues = array($newtoken['rank'], $newtoken['mem']);
        $member->update($arrColumns, $arrValues);
        echo "
                    <div style='display: none' id='successBox'>
                        <p align='center'>
                            Successfully generated new tokens!
                        </p>
                    </div>

                    <script type='text/javascript'>
                        popupDialog('New Tokens Created', '".$MAIN_ROOT."members/console.php?cID=$cID', 'successBox');
                    </script>

                ";
    }
    if(!$_POST['submit']) {
    $currentTokenRank = $memberInfo['tslasttokenrank'];
    $currentTokenMem = $memberInfo['tslasttokenmem'];
    if($currentTokenRank == "") {
    $currentTokenRank = "No Previously Generated Rank Token Exists (Click Generate Tokens Below)";
    }
    if($currentTokenMem == "") {
    $currentTokenMem = "No Previously Generated Membership Token Exists (Click Generate Tokens Below)";
    }
    echo "
    <form action='".$MAIN_ROOT."members/console.php?cID=".$cID."' method='post'>
    <div class='formDiv'>
    ";
    echo "
                    <div align='center'><h2>======IMPORTANT TEAMSPEAK DATA======</h2></div>
                    You need to use the following keys in TeamSpeak, they will give you your rank and membership group in TeamSpeak:<br>
                    <h2>Use the Membership Token First! Use it before using the Rank Token! If you fail to do this right then generate new tokens. If one or both of the tokens below have already been used, then you will need to generate new tokens.</h2>
                    Your Membership Token (Copy It): <b><u>$currentTokenMem</u></b><br>
                    Your Rank Token (Copy It): <b><u>$currentTokenRank</u></b>
                    <br>
                    HOW TO USE:<br>
                    1.) Open Teamspeak and connect to our server.<br>
                    2.) In the top menu bar click PERMISSIONS then USE PRIVILEGE KEY.<br>
                    3.) Paste the privilege token in and click OK. Ensure you do the Member Token First!<br>
                    4.) Do the same with the other key.<br>
                    <table class='formTable'>
                        <tr>
                            <td class='main' align='center' colspan='2'><br>
                                <input type='submit' name='submit' value='Generate Tokens' class='submitButton' style='width: 125px'>
                            </td>
                        </tr>
                    </table>
                </div>
            </form>

        ";
    }
?>

システムは、IVTS3クラスの2つの関数(getuidとcreatetoken)を参照します。createtokenコードは堅実です。エラーはありません。getuidコードはメインファイルとともに最近変更されたため、getuidコードは次のとおりです。

public function getuid($membername, $memberip, $method=0) {
    $tsuid = array();
    $membername = strtolower($membername);
    $clientid = $this->MySQL->query("SELECT client_id FROM clients WHERE client_lastip LIKE '%$memberip%' AND LOWER(client_nickname) LIKE '%$membername%'");
    while ($row = $clientid->fetch_assoc()) {
        $tsuid[] = $row['client_id'];
    }
    if ($tsuid == "") {
    $clientid = $this->MySQL->query("SELECT client_id FROM clients WHERE client_lastip LIKE '%$memberip%'");
    while ($row = $clientid->fetch_assoc()) {
        $tsuid[] = $row['client_id'];
    }
    }
    if ($tsuid == "") {
    $clientid = $this->MySQL->query("SELECT client_id FROM clients WHERE LOWER(client_nickname) LIKE '%$membername%'");
    while ($row = $clientid->fetch_assoc()) {
        $tsuid[] = $row['client_id'];
    }
    }
    if ($tsuid == "") {
    return false;
    }
    else {
    return $tsuid;
    }
}

前述のように、最初のコードブロックでファイルの終わりエラーが発生します。何かが足りないかもしれませんが、何度もチェックしましたが、まだ何も見つかりません。みんなありがとう。どんな質問でもできるだけ早く答えられます。

4

1 に答える 1

1

スクリプトの最後に中括弧がありません。固定コードは次のとおりです。

if (!isset($member) || substr($_SERVER['PHP_SELF'], -11) != "console.php") {
    exit();
} else {
    $memberInfo = $member->get_info();
    $consoleObj->select($_GET['cID']);
    if (!$member->hasAccess($consoleObj)) {
        exit();
    }
}

$rankObj = new Rank($mysqli);
$rankObj->select($memberInfo['rank_id']);
$RankInfo = $rankObj->get_info_filtered();
$rankname = $RankInfo['name'];
$cID      = $_GET['cID'];
$tsuid    = "";

$dispError   = "";
$countErrors = 0;
if ($_POST['submit']) {
    if ($memberInfo['tsuid'] != "") {
        $tsuid      = $memberInfo['tsuid'];
        $arrColumns = array(
            "tsuid"
        );
        $arrValues  = array(
            ""
        );
        $member->update($arrColumns, $arrValues);
    }
    $ts3 = new IVTS3($tshost, $tsuser, $tspass, $tsdb);
    if ($tsuid == "") {
        $tsuid = $ts3->getuid($memberInfo['username'], $memberInfo['ipaddress'], 0);
        if ($tsuid == false) {
            die("Unable to retrieve TS UIDs. Please ensure you have been on our TeamSpeak Server using the same name as your website nickname. If you haven't been on our server, do so now, then regenerate tokens. Otherwise, contact Operations Support.");
        }
        $lastmembertoken = $memberInfo['tslasttokenmem'];
        $lastranktoken   = $memberInfo['tslasttokenrank'];
        $lasttokens      = array(
            'rank' => $lastranktoken,
            'mem' => $lastmembertoken
        );
        $newtoken        = $ts3->createtoken($memberInfo['username'], $rankname, $lasttokens, $tsuid);
        $arrColumns      = array(
            "tslasttokenrank",
            "tslasttokenmem"
        );
        $arrValues       = array(
            $newtoken['rank'],
            $newtoken['mem']
        );
        $member->update($arrColumns, $arrValues);
        echo "
                    <div style='display: none' id='successBox'>
                        <p align='center'>
                            Successfully generated new tokens!
                        </p>
                    </div>

                    <script type='text/javascript'>
                        popupDialog('New Tokens Created', '" . $MAIN_ROOT . "members/console.php?cID=$cID', 'successBox');
                    </script>

                ";
    }
    if (!$_POST['submit']) {
        $currentTokenRank = $memberInfo['tslasttokenrank'];
        $currentTokenMem  = $memberInfo['tslasttokenmem'];
        if ($currentTokenRank == "") {
            $currentTokenRank = "No Previously Generated Rank Token Exists (Click Generate Tokens Below)";
        }
        if ($currentTokenMem == "") {
            $currentTokenMem = "No Previously Generated Membership Token Exists (Click Generate Tokens Below)";
        }
        echo "
    <form action='" . $MAIN_ROOT . "members/console.php?cID=" . $cID . "' method='post'>
    <div class='formDiv'>
    ";
        echo "
                <div align='center'><h2>======IMPORTANT TEAMSPEAK DATA======</h2></div>
                You need to use the following keys in TeamSpeak, they will give you your rank and membership group in TeamSpeak:<br>
                <h2>Use the Membership Token First! Use it before using the Rank Token! If you fail to do this right then generate new tokens. If one or both of the tokens below have already been used, then you will need to generate new tokens.</h2>
                Your Membership Token (Copy It): <b><u>$currentTokenMem</u></b><br>
                Your Rank Token (Copy It): <b><u>$currentTokenRank</u></b>
                <br>
                HOW TO USE:<br>
                1.) Open Teamspeak and connect to our server.<br>
                2.) In the top menu bar click PERMISSIONS then USE PRIVILEGE KEY.<br>
                3.) Paste the privilege token in and click OK. Ensure you do the Member Token First!<br>
                4.) Do the same with the other key.<br>
                <table class='formTable'>
                    <tr>
                        <td class='main' align='center' colspan='2'><br>
                            <input type='submit' name='submit' value='Generate Tokens' class='submitButton' style='width: 125px'>
                        </td>
                    </tr>
                </table>
            </div>
        </form>

    ";
    }

}
于 2013-03-21T01:56:37.263 に答える