Portions created by the Initial Developer are Copyright (C) 2008-2010 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //if there are multiple domains then update the public dir path to include the domain if ($domains_processed == 1) { if (count($_SESSION["domains"]) > 1) { if (is_dir($_SESSION['switch']['dialplan']['dir'].'/public')) { //clear out the old xml files $v_needle = '_v_'; if($dh = opendir($_SESSION['switch']['dialplan']['dir'].'/public')) { $files = Array(); while($file = readdir($dh)) { if($file != "." && $file != ".." && $file[0] != '.') { if(is_dir($dir . "/" . $file)) { //this is a directory } else { if (strpos($file, $v_needle) !== false && substr($file,-4) == '.xml') { unlink($_SESSION['switch']['dialplan']['dir'].'/public/'.$file); } } } } closedir($dh); } } } } //if the public directory doesn't exist then create it if ($domains_processed == 1) { if (strlen($_SESSION['switch']['dialplan']['dir']) > 0) { if (!is_dir($_SESSION['switch']['dialplan']['dir'].'/public')) { mkdir($_SESSION['switch']['dialplan']['dir'].'/public', 0770, false); } } } //if multiple domains then make sure that the dialplan/public/domain_name.xml file exists if (count($_SESSION["domains"]) > 1) { //make sure the public directory and xml file exist if (strlen($_SESSION['switch']['dialplan']['dir']) > 0) { if (!is_dir($_SESSION['switch']['dialplan']['dir'].'/public'.$_SESSION['domains'][$domain_uuid]['domain_name'])) { mkdir($_SESSION['switch']['dialplan']['dir'].'/public/'.$_SESSION['domains'][$domain_uuid]['domain_name'], 0770, false); } $file = $_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$domain_uuid]['domain_name'].".xml"; if (!file_exists($file)) { $fout = fopen($file,"w"); $xml = "\n"; $xml .= " \n"; $xml .= "\n"; fwrite($fout, $xml); fclose($fout); unset($xml,$file); } } } ?>