-
Notifications
You must be signed in to change notification settings - Fork 111
/
uninstall.php
executable file
·140 lines (114 loc) · 4 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
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
<?PHP
/**
* Endpoint Manager Uninstaller
*
* @author Andrew Nagy
* @license MPL / GPLv2 / LGPL
* @package Endpoint Manager
*/
require dirname($_SERVER["SCRIPT_FILENAME"]). "/modules/endpointman/includes/functions.inc";
global $endpoint;
$endpoint = new endpointmanager();
global $db;
if (! function_exists("out")) {
function out($text) {
echo $text."<br />";
}
}
if (! function_exists("outn")) {
function outn($text) {
echo $text;
}
}
out("Removing Phone Modules Directory");
$endpoint->rmrf(PHONE_MODULES_PATH);
exec("rm -R ". PHONE_MODULES_PATH);
out("Dropping all relevant tables");
$sql = "DROP TABLE `endpointman_brand_list`";
$result = $db->query($sql);
$sql = "DROP TABLE `endpointman_global_vars`";
$result = $db->query($sql);
$sql = "DROP TABLE `endpointman_mac_list`";
$result = $db->query($sql);
$sql = "DROP TABLE `endpointman_line_list`";
$result = $db->query($sql);
$sql = "DROP TABLE `endpointman_model_list`";
$result = $db->query($sql);
$sql = "DROP TABLE `endpointman_oui_list`";
$result = $db->query($sql);
$sql = "DROP TABLE `endpointman_product_list`";
$result = $db->query($sql);
$sql = "DROP TABLE `endpointman_template_list`";
$result = $db->query($sql);
$sql = "DROP TABLE `endpointman_time_zones`";
$result = $db->query($sql);
$sql = "DROP TABLE `endpointman_custom_configs`";
$result = $db->query($sql);
$sql = 'SELECT value FROM `admin` WHERE `variable` LIKE CONVERT(_utf8 \'version\' USING latin1) COLLATE latin1_swedish_ci';
$amp_version = $db->getOne($sql);
//Do unlinks ourself because retrieve_conf doesn't always remove stuff...
//images
$dir = $amp_conf['AMPWEBROOT'].'/admin/assets/endpointman/images';
foreach (glob(LOCAL_PATH."assets/images/*.*") as $filename) {
if(file_exists($dir.'/'.basename($filename)) && (readlink($dir.'/'.basename($filename)) == $filename)) {
unlink($dir.'/'.basename($filename));
}
}
if(is_link($dir)) {
unlink($dir);
}
//javascripts
$dir = $amp_conf['AMPWEBROOT'].'/admin/assets/endpointman/js';
foreach (glob(LOCAL_PATH."assets/js/*.*") as $filename) {
if(file_exists($dir.'/'.basename($filename)) && (readlink($dir.'/'.basename($filename)) == $filename)) {
unlink($dir.'/'.basename($filename));
}
}
if(is_link($dir)) {
unlink($dir);
}
//theme
$dir = $amp_conf['AMPWEBROOT'].'/admin/assets/endpointman/theme';
foreach (glob(LOCAL_PATH."assets/theme/*.*") as $filename) {
if(file_exists($dir.'/'.basename($filename)) && (readlink($dir.'/'.basename($filename)) == $filename)) {
unlink($dir.'/'.basename($filename));
}
}
if(is_link($dir)) {
unlink($dir);
}
out('Removing symlink to web provisioner');
if(is_link($amp_conf['AMPWEBROOT']."/provisioning")) {
unlink($amp_conf['AMPWEBROOT']."/provisioning");
}
//ari-modules
$dir = $amp_conf['AMPWEBROOT'].'/recordings/modules';
foreach (glob(LOCAL_PATH."ari/modules/*.*") as $filename) {
if(file_exists($dir.'/'.basename($filename)) && (readlink($dir.'/'.basename($filename)) == $filename)) {
unlink($dir.'/'.basename($filename));
}
}
//ari-images
$dir = $amp_conf['AMPWEBROOT'].'/recordings/theme/images';
foreach (glob(LOCAL_PATH."ari/images/*.*") as $filename) {
if(file_exists($dir.'/'.basename($filename)) && (readlink($dir.'/'.basename($filename)) == $filename)) {
unlink($dir.'/'.basename($filename));
}
}
//ari-js
$dir = $amp_conf['AMPWEBROOT'].'/recordings/theme/js';
foreach (glob(LOCAL_PATH."ari/js/*.*") as $filename) {
if(file_exists($dir.'/'.basename($filename)) && (readlink($dir.'/'.basename($filename)) == $filename)) {
unlink($dir.'/'.basename($filename));
}
}
//ari-theme
$dir = $amp_conf['AMPWEBROOT'].'/recordings/theme';
foreach (glob(LOCAL_PATH."ari/theme/*.*") as $filename) {
if(file_exists($dir.'/'.basename($filename)) && (readlink($dir.'/'.basename($filename)) == $filename)) {
unlink($dir.'/'.basename($filename));
}
}
if(!is_link($amp_conf['AMPWEBROOT'].'/admin/assets/endpointman')) {
$endpoint->rmrf($amp_conf['AMPWEBROOT'].'/admin/assets/endpointman');
}