Esempio n. 1
0
 /**
  * Resets the MariaDB Password
  *
  * The procedure is described in:
  * http://dev.mysql.com/doc/mysql-windows-excerpt/5.0/en/resetting-permissions-windows.html
  */
 public function setPassword($password)
 {
     // commands
     $stop_mariadb = "taskkill /f /IM mysqld.exe 1>nul 2>nul";
     $mysqld_exe = WPNXM_BIN . 'mariadb\\bin\\mysqld.exe';
     $start_mariadb_change_pw = $mysqld_exe . ' --defaults-file=' . WPNXM_BIN . '\\bin\\\\mariadb\\\\my.ini --init-file=' . WPNXM_BIN . '\\bin\\\\mariadb\\\\init_passwd_change.txt';
     $start_mariadb_normal = $mysqld_exe . ' --defaults-file=' . WPNXM_BIN . '\\bin\\\\mariadb\\\\my.ini';
     // create the init-file with the password update query
     file_put_contents(WPNXM_DIR . '\\bin\\mariadb\\init_passwd_change.txt', "UPDATE mysql.user SET PASSWORD=PASSWORD('{$password}') WHERE User='******';\nFLUSH PRIVILEGES;");
     // write new password to wpn-xm ini
     $ini = new \Webinterface\Helper\INIReaderWriter(WPNXM_INI);
     $ini->set('mariadb', 'password', $password);
     $ini->write();
     // stop mysqld and execute the init-file, then restart
     exec($stop_mariadb);
     exec($start_mariadb_change_pw);
     sleep(2);
     exec($stop_mariadb);
     exec($start_mariadb_normal);
     unlink(WPNXM_DIR . '\\bin\\mariadb\\init_passwd_change.txt');
     // test connection with new password
     $connection = new \mysqli("localhost", "root", $password, "mysql");
     if (mysqli_connect_errno()) {
         $response = '<div class="alert alert-danger">Database Connection with new password FAILED.';
         $response .= '(MySQL ["' . mysqli_connect_errno() . '"]"' . mysqli_connect_error() . '")</div>';
     } else {
         $response = '<div class="alert alert-success">Password changed SUCCESSFULLY.</div>';
     }
     $connection->close();
     unset($connection);
     return $response;
 }
Esempio n. 2
0
 public function getPassword()
 {
     $ini = new \Webinterface\Helper\INIReaderWriter(WPNXM_INI);
     return $ini->get('MariaDB', 'password');
 }
 public static function getEnabledExtensionsFromIni()
 {
     $enabled_extensions = array();
     $extension = '';
     // read php.ini
     $ini_file = php_ini_loaded_file();
     $ini = new \Webinterface\Helper\INIReaderWriter($ini_file);
     $ini->read($ini_file);
     $lines = $ini->returnArray();
     // check php.ini array for extension entries
     foreach ($lines as $line) {
         if ($line['type'] != 'entry') {
             continue;
         }
         if ($line['key'] != 'extension') {
             continue;
         }
         $extension = $line['value'];
         // cut everything of after ".dll"
         // as there might be comments on the line (; #)
         $extension = substr($extension, 0, strpos($extension, '.dll'));
         $enabled_extensions[] = $extension . '.dll';
     }
     asort($enabled_extensions);
     // get rid of the numeric index, by doing a key/value flip
     // this allows to easily check for an extension name by using isset in a foreach loop
     return array_flip($enabled_extensions);
 }