function crear($steamid, $sql_conn, $ts3_user, $ts3_pass, $ts3_host, $ts3_q_port, $ts3_sv_port){
require_once __DIR__ . "/../config/config.php";
require_once __DIR__ . "/../lib/ts3phpframework/libraries/TeamSpeak3/TeamSpeak3.php";
if (!$_POST['channel_name'] || !$_POST['channel_pass']) {
echo "El nombre del channel y la ID unica tienen que estar";
exit();
}
$sql = "SELECT steamid FROM steam_users_ts3_channels WHERE steamid = '".$steamid."'";
$result = $sql_conn->query($sql);
if ($result->num_rows > 0) {
$sql_conn->set_charset('utf8');
echo '
';
echo '
Ups! No puedes crear mas de un canal
';
echo "";
echo "
";
} elseif ($result->num_rows == 0) {
session_start();
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://" . $sql_conn . ":" . $ts3_pass . "@" . $ts3_host . ":" . $ts3_q_port . "/?server_port=" . $ts3_sv_port . "");
$clID = $ts3_VirtualServer->clientGetByUid($_POST['uuid']);
function generatePassword($length = 8) {
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$count = mb_strlen($chars);
for ($i = 0, $result = ''; $i < $length; $i++) {
$index = rand(0, $count - 1);
$result .= mb_substr($chars, $index, 1);
}
$_SESSION["password"] = $result;
}
generatePassword();
$infoCliente = $ts3_VirtualServer->execute("sendtextmessage", array(
"msg" => "Tu contraseña es " . $_SESSION["password"] . "",
"target" => $clID,
"targetmode" => TeamSpeak3::TEXTMSG_CLIENT
))->toList();
if (isset($_SESSION["password"])) {
echo'
';
}
}
}