-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.php
87 lines (71 loc) · 2.1 KB
/
uninstall.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
<?php
$ngx_file = '/www/server/nginx/conf/nginx.conf';
$fileInfo = file_get_contents($ngx_file);
$data = str_ireplace("include /www/server/panel/plugin/restrict/restict.conf;", '#include /www/server/panel/plugin/restrict/restict.conf;', $fileInfo);
file_put_contents($ngx_file, $data);
exit();
$file = '/www/server/panel/class/panelSite.py';
$fileInfo = file_get_contents($file);
$phpTpl = <<<'ModelTpl'
#PHP-INFO-END
#restict 插件
include /www/server/panel/plugin/restrict/restict.conf;
#restict 插件-END
ModelTpl;
un_ngx_replace();
function webconfig()
{
$db_path = "/www/server/panel/data/default.db";
$sql = "SELECT id,name FROM sites where id >0";
$db = new SQLite3($db_path);
$d = $db->query($sql);
$i = 0;
while ($res = $d->fetchArray())
{
$data[$i]['id'] = $res['id'];
$data[$i]['name'] = $res['name'];
$i++;
}
return $data;
}
function ngx_replace()
{
$conf = webconfig();
$config = "/www/server/panel/vhost/nginx/";
foreach ($conf as $value) {
$files = $config.$value['name'].'.conf';
ngx_replace_file($files);
}
}
function un_ngx_replace()
{
$conf = webconfig();
$config = "/www/server/panel/vhost/nginx/";
foreach ($conf as $value) {
$files = $config.$value['name'].'.conf';
un_ngx_replace_file($files);
}
}
function ngx_replace_file($file)
{
$fileInfo = file_get_contents($file);
$phpTpl = <<<'ModelTpl'
#PHP-INFO-END
#restict 插件
include /www/server/panel/plugin/restrict/restict.conf;
#restict 插件-END
ModelTpl;
$data = str_ireplace('#PHP-INFO-END', $phpTpl, $fileInfo);
file_put_contents($file, $data);
}
function un_ngx_replace_file($file)
{
$fileInfo = file_get_contents($file);
$phpTpl = <<<'ModelTpl'
#restict 插件
include /www/server/panel/plugin/restrict/restict.conf;
#restict 插件-END
ModelTpl;
$data = str_ireplace($phpTpl,'', $fileInfo);
file_put_contents($file, $data);
}