-
Notifications
You must be signed in to change notification settings - Fork 1
/
uninstall.php
43 lines (39 loc) · 1.29 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
<?php
if (!defined("FREEPBX_IS_AUTH")) {
die("No direct script access allowed");
}
$module = "dundi";
require_once dirname(__FILE__) . "/functions.inc.php";
$tables = array(
"dundi_config",
"dundi_mappings",
"dundi_peers",
"dundi_contexts",
"dundi_context_entries",
);
foreach ($tables as $t) {
$result = $db->query("DROP TABLE $t");
if (DB::IsError($result)) {
out(sprintf(_("Cannot delete table %s: %s"), $t, $result->getMessage()));
} else {
out(sprintf(_("Deleted table %s."), $t));
}
}
$config_file = $amp_conf["ASTETCDIR"] . "/" . Dundi::$config_file;
if (file_exists($config_file)) {
if (rename($config_file, "$config_file.module")) {
out(sprintf(_("Renaming %s as %s."), $config_file, "$config_file.module"));
if (file_exists("$config_file.0")) {
if (rename("$config_file.0", $config_file)) {
out(sprintf(_("Restored previous configuration from %s."), "$config_file.0"));
} else {
out(sprintf(_("Unable to restore previous configuration from %s."), "$config_file.0"));
}
} else {
out(sprintf(_("Backup file %s does not exist, unable to restore previous configuration."), "$config_file.0"));
}
} else {
out(sprintf(_("Unable to rename %s, it should be removed manually."), $config_file));
}
}
?>