Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 '<div class="container">';
- echo ' <div class="alert alert-danger" role="alert"><strong>Ups!</strong> No puedes crear mas de un canal</div>';
- echo "<script>console.log('Anteriormente ya has creado un canal');</script>";
- echo "<div>";
- } 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'<script type="text/javascript">
- $(document).ready(function() {
- $("form").submit(function() {
- $.ajax({
- type: "POST",
- url: "/include/verificar-canal.php",
- data: $(this).serialize(),
- success: function(data) {
- $("#result").html(data);
- }
- })
- return false;
- });
- })
- </script>
- <form method="post" id="esconder">
- <div class="form-group">
- <input name="pass" id= "pass" type="password" class="form-control" placeholder="Introduce la ocntraseña que te hemos mandado">
- <input type="hidden" name="channel_name" value="<?php echo $_POST["channel_name"]; ?>">
- <input type="hidden" name="channel_pass" value="<?php echo $_POST["channel_pass"]; ?>">
- <input type="hidden" name="uuid" value="<?php echo $_POST["uuid"]; ?>">
- <input type="hidden" name="steamid" value="<?php echo $_POST["steam_steamid"]; ?>">
- </div>
- <input class="btn btn-primary" type="submit" name="submit" value="Submit">
- </form>
- <div id="result"></div>';
- }
- }
- }
Advertisement