-
Notifications
You must be signed in to change notification settings - Fork 7
/
update.php
174 lines (130 loc) · 4.87 KB
/
update.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
ob_start();
require './config/config.php';
require './config/version.php';
include'frontend/functions.php';
echo '<h2><strong>Database Update was necessary:</strong></h2>';
echo '<h4>Version is now: "'.$lastversion.'"<br><br><hr>';
// Column update for 'spots -> iv'
$update1 = "ALTER TABLE `spots` ADD `iv` INT(3) NOT NULL AFTER `cp`;";
if(!mysqli_query($conn,$update1))
{
echo '- Not updated, column "IV" already exists :-)';
}
else
{
echo '- Added column \'iv\' to `spots`';
}
header("Refresh: 5; url= index.php");
echo '<br><hr>';
// Column update for 'users -> url' and 'users -> lastUplooad'
$update2 = "ALTER TABLE `users` ADD `url` TEXT NOT NULL AFTER `trn_date`, ADD `lastUpload` VARCHAR(200) NOT NULL AFTER `url`;";
if(!mysqli_query($conn,$update2))
{
echo '- Not updated, profile pic columns already exist :-)';
}
else
{
echo '- Added columns \'lastUpload\' and \'url\' to `users`';
}
header("Refresh: 5; url= index.php");
echo '<br><hr>';
// Column update for ex-raids
$update3 = "ALTER TABLE `gyms` ADD `exraid` INT(1) NOT NULL AFTER `raidby`, ADD `exraiddate` DATETIME NULL AFTER `exraid`;";
if(!mysqli_query($conn,$update3))
{
echo '- Not updated, ex-raid columns already exist :-)';
}
else
{
echo '- Added columns \'exraid\' and \'exraiddate\' to `gyms`';
}
header("Refresh: 5; url= index.php");
echo '<br><hr>';
// Make `uname` UNIQUE
$unamequery = "SHOW KEYS FROM users WHERE Key_name='uname'";
$unameresult = $conn->query($unamequery);
$row_cnt = $unameresult->num_rows;
if ($row_cnt !== 1) {
$update4 = "CREATE TABLE users2 LIKE users;";
$update4.= "ALTER IGNORE TABLE users2 ADD UNIQUE(uname);";
$update4.= "INSERT IGNORE INTO users2 SELECT * FROM users;";
$update4.= "RENAME TABLE users TO old_users, users2 TO users;";
$update4.= "DROP TABLE old_users;";
if(!mysqli_multi_query($conn,$update4))
{}
else
{
echo '- \"uname\" is now UNIQUE';
}
header("Refresh: 5; url= ./index.php");
echo '<br><hr>';
echo '<br><b>Back to index in 5 seconds..</b>';
} else { echo "- Not updated, \"uname\" already UNIQUE :-)";
header("Refresh: 5; url= index.php");
echo '<br><hr>';
}
// END OF UNAME QUERY
// Create new columns @ users for trading
$update5 = "ALTER TABLE `users` ADD `offtrades` INT(9) NOT NULL DEFAULT '0' AFTER `lastUpload`, ADD `reqtrades` INT(9) NOT NULL DEFAULT '0' AFTER `offtrades`;";
if(!mysqli_query($conn,$update5))
{
echo '- Not updated, trading columns already exist :-)';
}
else
{
echo '- Added columns \'offtrades\' and \'reqtrades\' to `users`';
}
header("Refresh: 5; url= ./index.php");
echo '<br><hr>';
// Create new columns @ users for trading
$update5 = "ALTER TABLE `users` ADD `offtrades` INT(9) NOT NULL DEFAULT '0' AFTER `lastUpload`, ADD `reqtrades` INT(9) NOT NULL DEFAULT '0' AFTER `offtrades`;";
if(!mysqli_query($conn,$update5))
{
echo '- Not updated, trading columns already exist :-)';
}
else
{
echo '- Added columns \'offtrades\' and \'reqtrades\' to `users`';
}
header("Refresh: 5; url= ./index.php");
echo '<br><hr>';
// Create new columns @ users for trading part 2
$update6 = "ALTER TABLE `offers` ADD `opentrade` INT(1) NOT NULL AFTER `accepted`, ADD `shiny` INT(1) NOT NULL AFTER `opentrade`, ADD `alolan` INT(1) NOT NULL AFTER `shiny`, ADD `notes` INT(255) NOT NULL AFTER `alolan`, ADD `complete` INT(1) NOT NULL AFTER `notes`, ADD `cloc` INT(255) NOT NULL AFTER `complete`;";
if(!mysqli_query($conn,$update6))
{
echo '- Not updated, trading columns already exist :-)';
}
else
{
echo '- Added columns \'opentrades, shiny, alolan, notes, complete, cloc\' to `offers`';
}
header("Refresh: 5; url= ./index.php");
echo '<br><hr>';
// Create new columns @ users for trading part 3
$update7 = "ALTER TABLE `trades` ADD `oid` INT(10) NOT NULL AFTER `tid`;";
if(!mysqli_query($conn,$update7))
{
echo '- Not updated, trading columns already exist :-)';
}
else
{
echo '- Added columns \'oid\' to `trades`';
}
header("Refresh: 5; url= ./index.php");
echo '<br><hr>';
// Create new columns @ messages for pm deletion
$update8 = "ALTER TABLE `messages` ADD `del_in` INT(1) NOT NULL DEFAULT '0' AFTER `from_user`, ADD `del_out` INT(1) NOT NULL DEFAULT '0' AFTER `del_in`;";
if(!mysqli_query($conn,$update8))
{
echo '- Not updated, columns already exist :-)';
}
else
{
echo '- Added columns \'del_in\' and \'del_out\' to `messages`';
}
header("Refresh: 5; url= ./index.php");
echo '<br><hr>';
echo '<br><b>Back to index in 5 seconds..</b>';
// End make columns for trading
?>