Update domain_delete.php
Fix the domain delete.
This commit is contained in:
@@ -23,16 +23,20 @@
|
|||||||
Contributor(s):
|
Contributor(s):
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
*/
|
*/
|
||||||
require_once "root.php";
|
|
||||||
require_once "resources/require.php";
|
//includes
|
||||||
require_once "resources/check_auth.php";
|
require_once "root.php";
|
||||||
if (permission_exists('domain_delete')) {
|
require_once "resources/require.php";
|
||||||
//access granted
|
require_once "resources/check_auth.php";
|
||||||
}
|
|
||||||
else {
|
//check permissions
|
||||||
echo "access denied";
|
if (permission_exists('domain_delete')) {
|
||||||
exit;
|
//access granted
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
echo "access denied";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
//add multi-lingual support
|
//add multi-lingual support
|
||||||
$language = new text;
|
$language = new text;
|
||||||
@@ -43,6 +47,7 @@ else {
|
|||||||
$id = check_str($_GET["id"]);
|
$id = check_str($_GET["id"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//delete domain data and files
|
||||||
if (strlen($id) > 0) {
|
if (strlen($id) > 0) {
|
||||||
//get the domain using the id
|
//get the domain using the id
|
||||||
$sql = "select * from v_domains ";
|
$sql = "select * from v_domains ";
|
||||||
@@ -96,7 +101,7 @@ if (strlen($id) > 0) {
|
|||||||
$db->beginTransaction();
|
$db->beginTransaction();
|
||||||
if (isset($apps)) foreach ($apps as &$app) {
|
if (isset($apps)) foreach ($apps as &$app) {
|
||||||
if (isset($app['db'])) foreach ($app['db'] as $row) {
|
if (isset($app['db'])) foreach ($app['db'] as $row) {
|
||||||
$table_name = $row['table'];
|
$table_name = $row['table']['name'];
|
||||||
if (isset($row['fields'])) foreach ($row['fields'] as $field) {
|
if (isset($row['fields'])) foreach ($row['fields'] as $field) {
|
||||||
if ($field['name'] == "domain_uuid") {
|
if ($field['name'] == "domain_uuid") {
|
||||||
$sql = "delete from $table_name where domain_uuid = '$id' ";
|
$sql = "delete from $table_name where domain_uuid = '$id' ";
|
||||||
@@ -107,7 +112,8 @@ if (strlen($id) > 0) {
|
|||||||
}
|
}
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
|
||||||
if (strlen($domain_name) > 0) {
|
//delete the directories
|
||||||
|
if (strlen($domain_name) > 0) {
|
||||||
//set the needle
|
//set the needle
|
||||||
if (count($_SESSION["domains"]) > 1) {
|
if (count($_SESSION["domains"]) > 1) {
|
||||||
$v_needle = 'v_'.$domain_name.'_';
|
$v_needle = 'v_'.$domain_name.'_';
|
||||||
@@ -129,76 +135,76 @@ if (strlen($id) > 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//delete the extension
|
//delete the extension
|
||||||
unlink($_SESSION['switch']['extensions']['dir'].'/'.$domain_name.'.xml');
|
unlink($_SESSION['switch']['extensions']['dir'].'/'.$domain_name.'.xml');
|
||||||
if (strlen($_SESSION['switch']['extensions']['dir']) > 0) {
|
if (strlen($_SESSION['switch']['extensions']['dir']) > 0) {
|
||||||
system('rm -rf '.$_SESSION['switch']['extensions']['dir'].'/'.$domain_name);
|
system('rm -rf '.$_SESSION['switch']['extensions']['dir'].'/'.$domain_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete fax
|
//delete fax
|
||||||
if (strlen($_SESSION['switch']['storage']['dir']) > 0) {
|
if (strlen($_SESSION['switch']['storage']['dir']) > 0) {
|
||||||
system('rm -rf '.$_SESSION['switch']['storage']['dir'].'/fax/'.$domain_name);
|
system('rm -rf '.$_SESSION['switch']['storage']['dir'].'/fax/'.$domain_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete the gateways
|
//delete the gateways
|
||||||
if($dh = opendir($_SESSION['switch']['sip_profiles']['dir'])) {
|
if($dh = opendir($_SESSION['switch']['sip_profiles']['dir'])) {
|
||||||
$files = Array();
|
$files = Array();
|
||||||
while($file = readdir($dh)) {
|
while($file = readdir($dh)) {
|
||||||
if($file != "." && $file != ".." && $file[0] != '.') {
|
if($file != "." && $file != ".." && $file[0] != '.') {
|
||||||
if(is_dir($dir . "/" . $file)) {
|
if(is_dir($dir . "/" . $file)) {
|
||||||
//this is a directory do nothing
|
//this is a directory do nothing
|
||||||
} else {
|
} else {
|
||||||
//check if file extension is xml
|
//check if file extension is xml
|
||||||
if (strpos($file, $v_needle) !== false && substr($file,-4) == '.xml') {
|
if (strpos($file, $v_needle) !== false && substr($file,-4) == '.xml') {
|
||||||
unlink($_SESSION['switch']['sip_profiles']['dir']."/".$file);
|
unlink($_SESSION['switch']['sip_profiles']['dir']."/".$file);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
closedir($dh);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
closedir($dh);
|
|
||||||
}
|
|
||||||
|
|
||||||
//delete the ivr menu
|
//delete the ivr menu
|
||||||
if($dh = opendir($_SESSION['switch']['conf']['dir']."/ivr_menus/")) {
|
if($dh = opendir($_SESSION['switch']['conf']['dir']."/ivr_menus/")) {
|
||||||
$files = Array();
|
$files = Array();
|
||||||
while($file = readdir($dh)) {
|
while($file = readdir($dh)) {
|
||||||
if($file != "." && $file != ".." && $file[0] != '.') {
|
if($file != "." && $file != ".." && $file[0] != '.') {
|
||||||
if(is_dir($dir . "/" . $file)) {
|
if(is_dir($dir . "/" . $file)) {
|
||||||
//this is a directory
|
//this is a directory
|
||||||
} else {
|
} else {
|
||||||
if (strpos($file, $v_needle) !== false && substr($file,-4) == '.xml') {
|
if (strpos($file, $v_needle) !== false && substr($file,-4) == '.xml') {
|
||||||
unlink($_SESSION['switch']['conf']['dir']."/ivr_menus/".$file);
|
unlink($_SESSION['switch']['conf']['dir']."/ivr_menus/".$file);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
closedir($dh);
|
||||||
|
}
|
||||||
|
|
||||||
|
//delete the recordings
|
||||||
|
if (strlen($_SESSION['switch'][recordings]['dir']) > 0) {
|
||||||
|
system('rm -rf '.$_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$domain_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//delete voicemail
|
||||||
|
if (strlen($_SESSION['switch']['voicemail']['dir']) > 0) {
|
||||||
|
system('rm -rf '.$_SESSION['switch']['voicemail']['dir'].'/'.$domain_name);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
closedir($dh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete the recordings
|
//apply settings reminder
|
||||||
if (strlen($_SESSION['switch'][recordings]['dir']) > 0) {
|
$_SESSION["reload_xml"] = true;
|
||||||
system('rm -rf '.$_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$domain_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
//delete voicemail
|
//clear the domains session array to update it
|
||||||
if (strlen($_SESSION['switch']['voicemail']['dir']) > 0) {
|
unset($_SESSION["domains"]);
|
||||||
system('rm -rf '.$_SESSION['switch']['voicemail']['dir'].'/'.$domain_name);
|
unset($_SESSION["domain_uuid"]);
|
||||||
}
|
unset($_SESSION["domain_name"]);
|
||||||
|
unset($_SESSION['domain']);
|
||||||
|
unset($_SESSION['switch']);
|
||||||
}
|
}
|
||||||
|
|
||||||
//apply settings reminder
|
|
||||||
$_SESSION["reload_xml"] = true;
|
|
||||||
|
|
||||||
//clear the domains session array to update it
|
|
||||||
unset($_SESSION["domains"]);
|
|
||||||
unset($_SESSION["domain_uuid"]);
|
|
||||||
unset($_SESSION["domain_name"]);
|
|
||||||
unset($_SESSION['domain']);
|
|
||||||
unset($_SESSION['switch']);
|
|
||||||
}
|
|
||||||
|
|
||||||
//redirect the browser
|
//redirect the browser
|
||||||
$_SESSION["message"] = $text['message-delete'];
|
$_SESSION["message"] = $text['message-delete'];
|
||||||
header("Location: domains.php");
|
header("Location: domains.php");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user