Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class OperazioniFTP {
- var $host = null;
- var $username = null;
- var $password = null;
- var $new_password = null ;
- var $new_retype_password = null;
- private $ftp_db_user = null;
- private $ftp_db_pass = null;
- private $ftp_db_name = null;
- private $ftp_db_host = "localhost";
- protected $conn_id = null;
- function __construct() {
- var_dump($this->ftp_db_pass);
- var_dump($this->ftp_db_user);
- // $this->db_connect();
- }
- function recupera_credenziali_proftpd() {
- $handle = file_get_contents('/etc/proftpd/sql.conf');
- $handle = preg_replace('/\s\s+/', ' ' ,$handle);
- $array_configurations =explode("\n",$handle);
- foreach ($array_configurations as $conf_line) {
- $array_esploso = explode(" ",$conf_line);
- if($array_esploso[0] == "SQLConnectInfo"){
- // $string = $array_esploso[1];
- // var_dump($string);
- list($database, $host)=explode("@", $array_esploso[1]);
- $array_esploso['database']=$database;
- $array_esploso['host']=$host;
- $array_esploso['username']=$array_esploso[2];
- $array_esploso['password']=$array_esploso[3];
- unset($array_esploso[1]);
- unset($array_esploso[2]);
- unset($array_esploso[3]);
- }
- if($array_esploso[0] == "SQLUserInfo"){
- $array_esploso['table'] = $array_esploso[1];
- unset($array_esploso[1]);
- }
- $output_array[array_shift($array_esploso)] = $array_esploso;
- }
- print_r($output_array);
- $this->ftp_db_user = $output_array['SQLConnectInfo']['username'];
- $this->ftp_db_pass = $output_array['SQLConnectInfo']['password'];
- $this->ftp_db_name = $output_array['SQLConnectInfo']['database'];
- $this->ftp_db_host = $output_array['SQLConnectInfo']['host'];
- $this->ftp_db_table = $output_array['SQLUserInfo']['table'];
- // var_dump($this->ftp_db_pass);
- return true;
- }
- function db_connect(){
- $user = $this->ftp_db_user;
- $pass = $this->ftp_db_pass;
- $host = $this->ftp_db_host;
- $database = $this->ftp_db_name;
- $table = $this->ftp_db_table;
- $mysqli = new mysqli($host, $user, $pass, $database);
- if ($mysqli->connect_error) {
- die('Connect Error (' . $mysqli->connect_errno . ') '
- . $mysqli->connect_error);
- }
- }
- function ftp_check(){
- // Connect
- $this->conn_id = ftp_connect($this->host);
- // Open a session to an external ftp site
- $login_result = ftp_login ($this->conn_id, $this->username, $this->password);
- // Check open
- // return ((!$this->conn_id) || (!$login_result)) ? false : true ;
- return ((!$this->conn_id) || (!$login_result)) ? false : $this->cambia_password() ;
- }
- protected function cambia_password(){
- $SQL = "UPDATE `ftp`.`web1` SET `crypassword` = ENCRYPT('".$this->new_password."') WHERE `userid` = '".$this->username."' LIMIT 1";
- // echo $SQL;
- //return true;
- }
- function __destruct() {
- ftp_close($this->conn_id);
- }
- }
- $azione = new OperazioniFTP();
- $azione->username=$_GET['username'];
- $azione->password=$_GET['actual_password'];
- $azione->host="localhost";
- $azione->recupera_credenziali_proftpd();
- $azione->new_password = (!$_GET['new_password']) ? die("ko,nuova password mancante") : $_GET['new_password'];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement