Dalexhd

Untitled

Aug 31st, 2017
428
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.29 KB | None | 0 0
  1. function crear($steamid, $sql_conn, $ts3_user, $ts3_pass, $ts3_host, $ts3_q_port, $ts3_sv_port){
  2.  
  3.     require_once __DIR__ . "/../config/config.php";
  4.     require_once __DIR__ . "/../lib/ts3phpframework/libraries/TeamSpeak3/TeamSpeak3.php";
  5.     if (!$_POST['channel_name'] || !$_POST['channel_pass']) {
  6.         echo "El nombre del channel y la ID unica tienen que estar";
  7.         exit();
  8.     }
  9.  
  10.     $sql = "SELECT steamid FROM steam_users_ts3_channels WHERE steamid = '".$steamid."'";
  11.     $result = $sql_conn->query($sql);
  12.     if ($result->num_rows > 0) {
  13.         $sql_conn->set_charset('utf8');
  14.         echo '<div class="container">';
  15.         echo ' <div class="alert alert-danger" role="alert"><strong>Ups!</strong> No puedes crear mas de un canal</div>';
  16.  
  17.         echo "<script>console.log('Anteriormente ya has creado un canal');</script>";
  18.         echo "<div>";
  19.     } elseif ($result->num_rows == 0) {
  20.  
  21.  
  22.         session_start();
  23.         $ts3_VirtualServer = TeamSpeak3::factory("serverquery://" . $sql_conn . ":" . $ts3_pass . "@" . $ts3_host . ":" . $ts3_q_port . "/?server_port=" . $ts3_sv_port . "");
  24.         $clID = $ts3_VirtualServer->clientGetByUid($_POST['uuid']);
  25.         function generatePassword($length = 8) {
  26.             $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  27.             $count = mb_strlen($chars);
  28.             for ($i = 0, $result = ''; $i < $length; $i++) {
  29.                 $index = rand(0, $count - 1);
  30.                 $result .= mb_substr($chars, $index, 1);
  31.             }
  32.             $_SESSION["password"] = $result;
  33.         }
  34.         generatePassword();
  35.         $infoCliente = $ts3_VirtualServer->execute("sendtextmessage", array(
  36.             "msg" => "Tu contraseña es " . $_SESSION["password"] . "",
  37.             "target" => $clID,
  38.             "targetmode" => TeamSpeak3::TEXTMSG_CLIENT
  39.             ))->toList();
  40.         if (isset($_SESSION["password"])) {
  41.             echo'<script type="text/javascript">
  42.  
  43.             $(document).ready(function() {
  44.                 $("form").submit(function() {
  45.                     $.ajax({
  46.                         type: "POST",
  47.                         url: "/include/verificar-canal.php",
  48.                         data: $(this).serialize(),
  49.                         success: function(data) {
  50.  
  51.                             $("#result").html(data);
  52.                         }
  53.                     })        
  54.                     return false;
  55.                 });
  56.             })
  57.         </script>
  58.         <form method="post" id="esconder">
  59.             <div class="form-group">
  60.                 <input name="pass" id= "pass" type="password" class="form-control" placeholder="Introduce la ocntraseña que te hemos mandado">
  61.                 <input type="hidden" name="channel_name" value="<?php echo $_POST["channel_name"]; ?>">
  62.                 <input type="hidden" name="channel_pass" value="<?php echo $_POST["channel_pass"]; ?>">
  63.                 <input type="hidden" name="uuid" value="<?php echo $_POST["uuid"]; ?>">
  64.                 <input type="hidden" name="steamid" value="<?php echo $_POST["steam_steamid"]; ?>">
  65.             </div>
  66.             <input class="btn btn-primary" type="submit" name="submit" value="Submit">
  67.  
  68.         </form>
  69.         <div id="result"></div>';
  70.  
  71.     }
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83. }
  84.  
  85. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment