Advertisement
Guest User

Untitled

a guest
Jan 28th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. <?php
  2.  
  3. //DATI DI CONNESSIONE2
  4. $server2   = "156.54.212.103";
  5. $username2 = "root";
  6. $password2 = "vivi1995.";
  7.  
  8. //DATI DATABASE
  9. $user = $_POST['usr'];
  10. $var1 = $_POST['pass'];
  11.  
  12. // richiamo lo script responsabile della connessione a MySQL
  13. require 'connect.php';
  14.  
  15. if($user == ''){
  16.     echo "Selezionare un user di cui modificare la nota";
  17.     exit;
  18. }else{
  19.     $sql = "UPDATE bex_usr SET password = '".$var1."' WHERE name = '".$user."'";
  20.     // invio la query
  21.     $result = mysql_query($sql);
  22.    
  23.     //ESECUZIONE E CATTURA DELLA RISPOSTA
  24.     $connection2 = ssh2_connect($server2, 22);
  25.     ssh2_auth_password($connection2, $username2, $password2);
  26.     $stream = ssh2_exec($connection2, $command);
  27.    
  28.     $command = "sed -i '/\b\('$user'\)\b/d' /etc/ppp/chap-secrets";
  29.     $command2 = "sed -i '$ a\'$user' 'l2tp' '$var1' * #Creato da Bex ' /etc/ppp/chap-secrets";
  30.        
  31.     $stream = ssh2_exec($connection2, $command);
  32.     stream_set_blocking($stream, true);
  33.     $stream = ssh2_exec($connection2, $command2);
  34.     stream_set_blocking($stream, true);
  35.  
  36.     echo "$user ha cambiato la sua password in $var1";
  37.    
  38. }
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement