-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNameCorrection.php
executable file
·91 lines (72 loc) · 2.22 KB
/
NameCorrection.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env php
<?php
include_once "includes/autoloader.php";
main();
function main()
{
/* iterate each table and correct names within the database */
foreach(data::$db_tables as $table)
{
UpdatePlayerNamesInDB($table);
}
}
function UpdatePlayerNamesInDB($table)
{
$mysqli = connection::establishDBConnection();
$sql_multi_query = "";
$query_limit = 50;
foreach (data::$player_aliases as $authID => $name)
{
if (in_array($authID, data::$steamid_ignore))
{
continue;
}
$name = $mysqli->real_escape_string($name);
if ($table === "SourceTV_Survival_Main")
{
for ($i = 1; $i <= 4; $i++)
{
$query = "UPDATE `$table` SET p{$i}_name = \"$name\" WHERE p{$i}_authID = \"$authID\";";
$sql_multi_query .= $query . "\n";
}
}
elseif ($table === "SourceTV_Survival_LoggedEvents"
|| $table === "SourceTV_Survival_ConnectionLog"
|| $table === "SourceTV_Survival_PlayerClips")
{
$query = "UPDATE `$table` SET name = \"$name\" WHERE authID = \"$authID\";";
$sql_multi_query .= $query . "\n";
}
elseif ($table === "OnLogAction_Logs")
{
$query = "UPDATE `$table` SET client_name = \"$name\" WHERE client_authID = \"$authID\";";
$sql_multi_query .= $query . "\n";
$query = "UPDATE `$table` SET target_name = \"$name\" WHERE target_authID = \"$authID\";";
$sql_multi_query .= $query . "\n";
}
elseif ($table === "gasconfigs_v2_logs")
{
$query = "UPDATE `$table` SET owner_name = \"$name\" WHERE owner_steam64ID = \"$authID\";";
$sql_multi_query .= $query . "\n";
$query = "UPDATE `$table` SET name_user_who_loaded_config = \"$name\" WHERE steam64ID_user_who_loaded_config = \"$authID\";";
$sql_multi_query .= $query . "\n";
}
else
{
$logFile = new logFile;
$logFile -> LogFatalError("Table '$table' not yet defined in UpdatePlayerNamesInDB()");
}
// flush so the query doesn't get too big
if (substr_count( $sql_multi_query, "\n" ) > $query_limit)
{
connection::multiquery_and_close_connection($sql_multi_query, true);
$sql_multi_query = "";
}
}
if (!empty($sql_multi_query))
{
connection::multiquery_and_close_connection($sql_multi_query, true);
$sql_multi_query = "";
}
connection::KillDBConnection($mysqli);
}