首先感谢所有答案。他们都很感激!好吧,我正在编写一种为网站用户生成TeamSpeak权限令牌的方法。他们点击一个按钮,为他们生成2个令牌。一切正常。系统的另一部分获取成员网站用户名和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;
}
}
如上所述,我在第一个代码块上收到文件结束错误。我可能会遗漏一些东西,但我一遍又一遍地检查它仍然找不到任何东西。再次感谢你们。任何问题都将尽快得到解答。
答案 0 :(得分: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>
";
}
}