forked from entaopy/shadowsocks-plugin-for-whmcs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade.php
executable file
·60 lines (43 loc) · 1.65 KB
/
upgrade.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
<?php
$servers = require dirname(__FILE__) . '/servers.php';
foreach ($servers as $server) {
try {
$dbhost = $server['dbhost'];
$dbname = $server['dbname'];
$db = new PDO("mysql:host=$dbhost;dbname=$dbname",$server['dbuser'],$server['dbpass']);
$version = (isset($_GET['ver']) && in_array($_GET['ver'],array(1,2))) ? $_GET['ver'] : die('VERSION NOT FOUND.');
switch ($version) {
case 1:
//TODO:
//暂停更新
case 2:
$change_table = $db->exec('ALTER TABLE `port_tmp` RENAME `recycle_bin`');
if(!$change_table) {
$error = $db->errorInfo();
echo $error[2];
}
$add_created_at = $db->exec('ALTER TABLE `recycle_bin` ADD `created_at` INT(10) NOT NULL');
if(!$add_created_at) {
$error = $db->errorInfo();
echo $error[2];
}
$change_start = $db->exec('ALTER TABLE `user` CHANGE `start` `created_at` INT(10) NOT NULL');
if(!$change_start) {
$error = $db->errorInfo();
echo $error[2];
}
$add_updated_at = $db->exec('ALTER TABLE `user` ADD `updated_at` INT(10) NOT NULL');
if(!$add_updated_at) {
$error = $db->errorInfo();
echo $error[2];
}
break;
default:
# code...
break;
}
} catch (Exception $e) {
echo $e->getMessage();
}
}
echo 'Done.';