Advertisement
Vmodz

TestPanel

Nov 11th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.38 KB | None | 0 0
  1. <?php
  2. include 'v1_server_details.php';
  3.  
  4. set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
  5.  
  6. include('Net/SSH2.php');
  7.  
  8. for ($row = 1; $row < 101; $row++)
  9. {
  10.     if ( $_POST['server'] == $server_lists_array[$row][1] )
  11.     {
  12.         $hosts= $server_lists_array[$row][1];
  13.         $root_pass= $server_lists_array[$row][2];
  14.         $expiration= $server_lists_array[$row][3];
  15.         break;
  16.     }
  17. }
  18.  
  19. $error = false;
  20.  
  21.  
  22. if (isset($_POST['user']))  
  23. {
  24.     $username = trim(['user']);
  25.     $username = strip_tags($username);
  26.     $username = htmlspecialchars($username);
  27.     $password1 = trim(['password']);
  28.     $password1 = strip_tags($password1);
  29.     $password1 = htmlspecialchars($password1);
  30.     $cpassword = $confirmpassword;
  31.     $cpassword = strip_tags($cpassword);
  32.     $cpassword = htmlspecialchars($cpassword);
  33.     $password1 = $password;
  34.     $nDays = $expiration;
  35.     $datess = date('m/d/y', strtotime('+'.$nDays.' days'));
  36.     $password = escapeshellarg( crypt($password1) );
  37.    
  38.     if (empty($username))
  39.     {
  40.         $error = true;
  41.         $nameError = "Please Enter A Username.";
  42.     }
  43.     else if (strlen($username) < 2)
  44.     {
  45.         $error = true;
  46.         $nameError = "Username Must Have Atleast 2 Characters.";
  47.     }
  48.    
  49.     if (empty($password1))
  50.     {
  51.         $error = true;
  52.         $passError = "Please Enter A Password.";
  53.     }
  54.     else if(strlen($password1) < 2)
  55.     {
  56.         $error = true;
  57.         $passError = "Password Must Have Atleast 2 Characters.";
  58.     }
  59.    
  60.     if($password1 != $cpassword)
  61.     {
  62.         $error = true;
  63.         $cpaseror = "Password Didn't Match.";
  64.     }  
  65.    
  66.     if( !$error )
  67.     {
  68.         date_default_timezone_set('UTC');
  69.         date_default_timezone_set("Asia/Manila");
  70.         $my_date = date("Y-m-d H:i:s");
  71.  
  72.         //$connection = ssha_connect($hosts, 22);
  73.         $ssh = new Net_SSH2($hosts);
  74.         if (!$ssh->login('root', $root_pass))
  75.         {
  76.             die('Couldn\'t connect to server');
  77.         }
  78.         else
  79.         {
  80.             $show = true;
  81.             $res = $ssh->exec("useradd $username -m -p $password -e $datess -d  /tmp/$username -s /bin/false");
  82.             $exist = "useradd: user '$username' already exists";
  83.             $mailbox = "Creating mailbox file: File exists";
  84.            
  85.             $res = trim($res);
  86.            
  87.             $error = false;
  88.            
  89.             if($res == $exist)
  90.             {
  91.                 echo "Username Already Exist";
  92.             }
  93.             elseif($res == "" || $res == $mailbox)
  94.             {
  95.                 $errTyp = "success";
  96.                 $errMSG = "Successfully registered, you may Check your credentials";
  97.                 $username = '';
  98.                 $password = '';
  99.                 $cpassword = '';
  100.                 //echo "Successfully registered, you may Check your credentials";
  101.             }
  102.             else
  103.             {
  104.                 $errTyp = "danger";
  105.                 $errMSG = "Something went wrong, try again later...";
  106.                 //echo nl2br("Unknown Error Occurred\r\n$res");
  107.             }
  108.         }
  109.     }
  110. }
  111. ?>
  112.  
  113. <!DOCTYPE html>
  114. <html xmlns="http://www.w3.org/1999/xhtml">
  115. <head>
  116. <meta charset="utf-8">
  117. <meta name="viewport" content="width=device-width, initial-scale=1">
  118. <meta http-equiv="X-UA-Compatible" content="IE=edge" />  
  119. <title><?php echo $site_name;?>   |   <?php echo $site_description;?>   |   </title>
  120.         <script language='JavaScript'>
  121.         var txt = '   ' + document.title + '   '
  122.         var speed = 400;
  123.         var refresh = null;
  124.         function site_name()
  125.         {
  126.                     document.title = txt;
  127.                     txt = txt.substring(1, txt.length) + txt.charAt(0);
  128.                     refresh = setTimeout("site_name()", speed);
  129.         }
  130.         site_name();    
  131.     </script>
  132. <link rel="shortcut icon" type="image/x-icon" href="/logo.png" height="200" width"200">
  133. <meta name="description" content="<?php echo $site_description;?>"/>
  134. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootswatch/4.1.1/<?php echo $site_template;?>/bootstrap.min.css">
  135. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css">
  136. </head>
  137. <body>
  138.     <div class="navbar navbar-expand-lg navbar-dark bg-danger">
  139.         <div class="container">
  140.             <a class="navbar-brand" href="/"><?php echo $site_name;?></a>
  141.             <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navigatebar" aria-controls="navigatebar" aria-expanded="false" aria-label="Toggle navigation">
  142.             <span class="navbar-toggler-icon"></span>
  143.             </button>
  144.             <div class="collapse navbar-collapse" id="navigatebar">
  145.                 <ul class="navbar-nav mr-auto">
  146.                     <li class="nav-item">
  147.                         <a class="nav-link" href="https://www.phcorner.net/members/745093/">PHCorner</a>
  148.                     </li>
  149.                    
  150.                 </ul>
  151.             </div>
  152.         </div>
  153.     </div>
  154.     <header id="header" align="center">
  155.         <img src="/logo.png" alt="" height="250" width"250"/>
  156.     </header>
  157.     <div align="center">
  158.         <div class="col-md-4" align="center">
  159.             <div align="center">
  160.                 <div align="center" class="card-body">
  161.                     <form method="post" align="center" class="softether-create">
  162.                         <div class="form-group">
  163.                             <div class="alert-danger">
  164.                                 <span class="text-light"><?php echo $nameError; ?></span>
  165.                             </div>                 
  166.                             <div class="alert-danger">
  167.                                 <span class="text-light"><?php echo $passError; ?></span>
  168.                             </div>
  169.                             <div class="alert-danger">
  170.                                 <span class="text-light"><?php echo $cpaseror; ?></span>
  171.                             </div>
  172.                         </div>
  173.                         <div class="form-group">                                               
  174.                             <?php
  175.                                 if($show == true)
  176.                                     {
  177.                                         echo '<div class="card alert-danger">';
  178.                                         echo '<table class="table-danger">';
  179.                                         echo '<tr>'; echo '<td> </td>'; echo '<td> </td>'; echo '</tr>';           
  180.                                         echo '<tr>'; echo '<td>Host</td>'; echo '<td>'; echo $hosts; echo '</td>'; echo '</tr>';
  181.                                         echo '<tr>'; echo '<td>Username</td>'; echo '<td>'; echo $username; echo '</td>'; echo '</tr>';
  182.                                         echo '<tr>'; echo '<td>Password</td>'; echo '<td>'; echo $password1; echo '</td>'; echo '</tr>';
  183.                                         echo '<tr>'; echo '<td>SSH Port</td>'; echo '<td>'; echo $port_ssh; echo '</td>'; echo '</tr>';
  184.                                         echo '<tr>'; echo '<td>Dropbear Port</td>'; echo '<td>'; echo $port_dropbear; echo '</td>'; echo '</tr>';
  185.                                         echo '<tr>'; echo '<td>SSL Port</td>'; echo '<td>'; echo $port_ssl; echo '</td>'; echo '</tr>';
  186.                                         echo '<tr>'; echo '<td>Squid Port</td>'; echo '<td>'; echo $port_squid; echo '</td>'; echo '</tr>';
  187.                                         echo '<tr>'; echo '<td>OpenVPN Config</td>'; echo '<td>';echo '<a href="http://';echo $hosts; echo "/"; echo "client.ovpn"; echo'">download config</a>'; echo '</td>'; echo '</tr>';
  188.                                         echo '<tr>'; echo '<td>Expiration Date</td>'; echo '<td>'; echo $datess; echo '</td>'; echo '</tr>';                                                                                           
  189.                                         echo '<tr>'; echo '<td> </td>'; echo '<td> </td>'; echo '</tr>';
  190.                                         echo '</table>';
  191.                                         echo '</div>';
  192.                                     }                                      
  193.                             ?>
  194.  
  195.                         </div>
  196.                         <div class="form-group">
  197.                             <div class="input-group">                                  
  198.                                 <div class="input-group-prepend">
  199.                                     <span class="input-group-text"><i class="fas fa-globe" style="color:red;"></i></span>
  200.                                 </div>
  201.                                 <select class="custom-select" name="server" >
  202.                                     <option disabled selected value>Select Server</option>
  203.                                         <optgroup label="LadyClare Servers">
  204.                                         <?php
  205.                                             for($row = 1; $row < 101; $row++)
  206.                                             {
  207.                                                 if(!empty($server_lists_array[$row][1]))
  208.                                                 {
  209.                                                     echo '<option>';
  210.                                                     echo $server_lists_array[$row][1];
  211.                                                     echo '</option>';
  212.                                                 }
  213.                                                 else
  214.                                                 {
  215.                                                     break;
  216.                                                 }
  217.                                                
  218.                                             }
  219.                                         ?>
  220.                                         </optgroup>                                                    
  221.                                 </select>
  222.                             </div>
  223.                         </div>                             
  224.                        
  225.                         <div class="form-group">                               
  226.                             <div class="input-group">                                  
  227.                                 <div class="input-group-prepend">
  228.                                     <span class="input-group-text"><i class="fas fa-user-circle" style="color:red;"></i></span>
  229.                                 </div>
  230.                                     <input type="text" class="form-control" id="username" placeholder="Username" name="user" autocomplete="off" >
  231.                             </div>
  232.                         </div>
  233.                         <div class="form-group">                               
  234.                             <div class="input-group">
  235.                                 <div class="input-group-prepend">
  236.                                     <span class="input-group-text"><i class="fas fa-key" style="color:red;"></i></span>
  237.                                 </div>
  238.                                     <input type="text" class="form-control" id="password" placeholder="Password" name="password" autocomplete="off"  >
  239.                             </div>                     
  240.                         </div>                     
  241.                         <div class="form-group">                                   
  242.                             <div class="input-group">                                  
  243.                                 <div class="input-group-prepend">
  244.                                     <span class="input-group-text"><i class="fas fa-key" style="color:red;"></i></span>
  245.                                 </div>
  246.                                     <input type="text" class="form-control" id="confirm" placeholder="Confirm Password" name="confirmpassword" autocomplete="off" >
  247.                             </div>                     
  248.                         </div>                     
  249.                         <div class="form-group ">
  250.                             <button type="submit" id="button" class="btn btn-danger btn-block btn-action">CREATE ACCOUNT</button>
  251.                         </div>
  252.                     </form>                
  253.                 </div>
  254.             </div>
  255.         </div>
  256.     </div>
  257. </body>
  258. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement