-1

首先感谢任何和所有的答案。他们都很感激!好的,我正在编写一种为网站用户生成 TeamSpeak 权限令牌的方法。他们单击一个按钮并为他们生成 2 个令牌。这一切都很好。系统的另一部分获取会员网站用户名和IP地址,然后搜索TeamSpeak3服务器的MySQL数据库以找到会员服务器ID(自动增量主键)。在简单地加载该成员用来执行此操作的页面时,会给出一个错误:“解析错误:语法错误,第 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 回答