static function CheckCreateForErrors($username, $database, $access) { global $zdbh; // Check to make sure the user name is not blank before we go any further... if ($username == '') { self::$blank = true; return false; } // Check to make sure the user name is not blank before we go any further... if ($username == 'root') { self::$rootabuse = true; return false; } // Check to make sure the user name is not blank before we go any further... if ($database == '') { self::$blank = true; return false; } // Check to make sure the user name is not a duplicate... $sql = "SELECT COUNT(*) FROM x_mysql_users WHERE mu_name_vc=:username AND mu_deleted_ts IS NULL"; $numrows = $zdbh->prepare($sql); $numrows->bindParam(':username', $username); if ($numrows->execute()) { if ($numrows->fetchColumn() != 0) { self::$alreadyexists = true; return false; } } // Check to make sure the user name is not a duplicate (checks actual mysql table)... $sql = "SELECT EXISTS(SELECT 1 FROM mysql.user WHERE user = :username)"; $numrows = $zdbh->prepare($sql); $numrows->bindParam(':username', $username); if ($numrows->execute()) { if ($numrows->fetchColumn() != 0) { self::$alreadyexists = true; return false; } } // Check for invalid username if (!self::IsValidUserName($username)) { self::$badname = true; return false; } // Check for invalid IP address if ($access != "%" && strtolower($access) != "localhost") { if (!sys_monitoring::IsAnyValidIP($access)) { self::$badIP = true; return false; } } return true; }