function Add_DB_save() { $q = new mysql(); if (is_numeric($_POST["instance-id"]) && $_POST["instance-id"] > 0) { $q = new mysql_multi($_POST["instance-id"]); } $sql = "CREATE DATABASE `{$_POST["Add-DB-save"]}`"; if (!$q->EXECUTE_SQL($sql)) { echo "{$_POST["Add-DB-save"]}\n\n{$q->mysql_error}"; return; } }
function members_add_save() { if ($GLOBALS["VERBOSE"]) { echo __FUNCTION__ . "<br>"; } $server = trim($_POST["servername"]); $username = trim($_POST["username"]); $password = url_decode_special_tool($_POST["password"]); if ($server == "*") { $server = "%"; } if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " ->mysql()<br>"; } $q = new mysql(); if (is_numeric($_POST["instance-id"]) && $_POST["instance-id"] > 0) { $q = new mysql_multi($_GET["instance-id"]); } $OrginalPassword = $q->mysql_password; $sql = "SELECT User FROM user WHERE Host='{$server}' AND User='******'"; if ($GLOBALS["VERBOSE"]) { echo $sql . "<br>"; } $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, "mysql")); if ($GLOBALS["VERBOSE"]) { echo "User:{$ligne["User"]}<br>"; } if (trim($ligne["User"]) == null) { $sql = "CREATE USER '{$username}'@'{$server}' IDENTIFIED BY '{$password}';"; if ($GLOBALS["VERBOSE"]) { echo $sql . "<br>"; } if (!$q->EXECUTE_SQL($sql)) { $q->mysql_admin = "root"; $q->mysql_password = $OrginalPassword; if (!$q->EXECUTE_SQL($sql)) { $q->mysql_admin = "root"; $q->mysql_password = null; if (!$q->EXECUTE_SQL($sql)) { echo "CREATE USER user:{$username}\nHost:{$server}\n\n{$q->mysql_error}"; return; } } } } $sql = "GRANT ALL PRIVILEGES ON * . * TO '{$username}'@'{$server}' IDENTIFIED BY '{$password}' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0"; if ($GLOBALS["VERBOSE"]) { echo $sql . "<br>"; } if (!$q->EXECUTE_SQL($sql)) { $q->mysql_admin = "root"; $q->mysql_password = $OrginalPassword; $q->ok = true; if (!$q->EXECUTE_SQL($sql)) { $q->mysql_admin = "root"; $q->mysql_password = null; $q->ok = true; if (!$q->EXECUTE_SQL($sql)) { echo "user GRANT ALL PRIVILEGES ON:{$username}\nHost:{$server}\n\n{$q->mysql_error}"; return; } } } }
function flush_privs() { $instance_id = $_POST["instance-id"]; $q = new mysql(); if ($instance_id > 0) { $q = new mysql_multi($instance_id); } $sql = "FLUSH PRIVILEGES"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); if (!$q->EXECUTE_SQL($sql, "mysql")) { $q->mysql_admin = "root"; $q->mysql_password = $OrginalPassword; $q->ok = true; if (!$q->EXECUTE_SQL($sql, "mysql")) { $q->mysql_admin = "root"; $q->mysql_password = null; $q->ok = true; if (!$q->EXECUTE_SQL($sql, "mysql")) { echo "{$sql}\n\n{$q->mysql_error}\n"; return; } } } }