break; case "HE": die(json_encode(array('error' => false, 'message' => "HawkEye (Custom Logger Required) - NOT YET IMPLEMENTED"))); case "BB": die(json_encode(array('error' => false, 'message' => "BigBrother (Custom Logger Required) - NOT YET IMPLEMENTED"))); case "": die(json_encode(array('error' => false, 'message' => "LOG TYPE CANNOT BE BLANK."))); default: die(json_encode(array('error' => false, 'message' => "Custom Logger - NOT YET IMPLEMENTED"))); } @mysql_select_db($_POST['base']) or die(json_encode(array('error' => true, 'message' => "SQL connection OK, Database [" . $_POST['base'] . "] exists, but an error occurred when trying to connect to the database: " . mysql_error()))); $sql_Logging_IsValid = "SHOW TABLES LIKE '{$db_table_find}'"; //echo "SQL QUERY: <BR>" . $sql_Logging_IsValid . "<BR>"; $res_Logging_IsValid = @mysql_query($sql_Logging_IsValid) or die(json_encode(array('error' => true, 'message' => "Database connection OK, but an error occurred while checking " . DB_Type_Name($_POST['type']) . " installation: " . mysql_error()))); if (mysql_num_rows($res_Logging_IsValid) > 0) { die(json_encode(array('error' => false, 'message' => "HOST OK"))); } else { die(json_encode(array('error' => true, 'message' => "Database connection OK, but could not find " . DB_Type_Name($_POST['type']) . " installation."))); } } else { die(json_encode(array('error' => false, 'message' => "HOST OK"))); } } else { die(json_encode(array('error' => true, 'message' => "SQL connection OK, but could not find database [" . $_POST['base'] . "] ."))); } } else { die(json_encode(array('error' => true, 'message' => "HOST BAD"))); } } else { die(json_encode(array('error' => true, 'message' => "Please complete all fields."))); }
function Check_DB_Exists($validate_table, $db_type, $db_host, $db_base, $db_user, $db_pass, $db_prefix) { //print_r($_POST); if ($db_host == "" || $db_base == "" || $db_user == "" || $db_pass == "") { return array('error' => true, 'message' => "Check_DB_Exists: Missing a required variable."); } $connect = @mysql_connect($db_host, $db_user, $db_pass); if ($connect) { // Get ID of players whose names partially match the search parameter $sql_DB_IsValid = "SHOW DATABASES LIKE '" . $db_base . "'"; //echo "SQL QUERY: <BR>" . $sql_DB_IsValid . "<BR>"; $res_DB_IsValid = @mysql_query($sql_DB_IsValid); if (!$res_DB_IsValid) { return array('error' => true, 'message' => "SQL connection OK, but an error occurred while looking for database [" . $db_base . "] ."); } if (mysql_num_rows($res_DB_IsValid) > 0) { if ($validate_table) { switch (trim(strtoupper($db_type))) { case "LB": $db_table_find = "lb-players"; break; case "GD": $db_table_find = "gd_players"; break; case "HE": return array('error' => false, 'message' => "Logging Type Invalid: HawkEye (Custom Logger Required) - NOT YET IMPLEMENTED"); // For future use: 'hawk_players' is the default table // For future use: 'hawk_players' is the default table case "BB": return array('error' => false, 'message' => "Logging Type Invalid: BigBrother (Custom Logger Required) - NOT YET IMPLEMENTED"); // For future use: 'bbusers' is the correct table // For future use: 'bbusers' is the correct table case "": return array('error' => false, 'message' => "Logging Type Invalid: LOG TYPE CANNOT BE BLANK."); default: return array('error' => false, 'message' => "Logging Type Invalid: Custom Logger - NOT YET IMPLEMENTED"); } if (@mysql_select_db($db_base)) { $sql_Logging_IsValid = "SHOW TABLES LIKE '{$db_table_find}'"; //echo "SQL QUERY: <BR>" . $sql_Logging_IsValid . "<BR>"; $res_Logging_IsValid = @mysql_query($sql_Logging_IsValid); if ($res_Logging_IsValid) { if (mysql_num_rows($res_Logging_IsValid) > 0) { return array('error' => false, 'message' => "HOST OK"); } else { return array('error' => true, 'message' => "Database connection OK, but could not find " . DB_Type_Name($db_type) . " installation."); } } else { return array('error' => true, 'message' => "Database connection OK, but an error occurred while checking " . DB_Type_Name($db_type) . " installation: " . mysql_error()); } } else { return array('error' => true, 'message' => "SQL connection OK, Database [" . $db_base . "] exists, but an error occurred when trying to connect to the database: " . mysql_error()); } } else { return array('error' => false, 'message' => "SUCCESS: SQL Connection OK, Database [" . $db_base . "] exists. DB is selectable. "); } } else { return array('error' => true, 'message' => "SQL connection OK, but could not find database [" . $db_base . "] ."); } } else { return array('error' => true, 'message' => mysql_error()); } }