Only install class copy methods only add if the directory exists.

This commit is contained in:
Mark Crane
2014-02-13 00:23:00 +00:00
parent 60b7f7cb2a
commit abb1097e02

View File

@@ -113,75 +113,81 @@ include "root.php";
function copy_conf() { function copy_conf() {
clearstatcache(); clearstatcache();
$src_dir = $this->switch_conf_dir; if (file_exists($this->switch_conf_dir)) {
$dst_dir = $this->switch_conf_dir.'.orig'; $src_dir = $this->switch_conf_dir;
if ($src_dir != "/conf") { $dst_dir = $this->switch_conf_dir.'.orig';
mkdir($src_dir, 0755, true); if ($src_dir != "/conf") {
} mkdir($src_dir, 0755, true);
if (is_readable($src_dir)) { }
//make a backup copy of the conf directory if (is_readable($src_dir)) {
if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") { //make a backup copy of the conf directory
$this->recursive_copy($src_dir, $dst_dir); if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") {
$this->recursive_delete($this->switch_conf_dir); $this->recursive_copy($src_dir, $dst_dir);
} $this->recursive_delete($this->switch_conf_dir);
else { }
exec ('mv '.$src_dir.' '.$dst_dir); else {
//exec ('cp -RLp '.$src_dir.' '.$dst_dir); exec ('mv '.$src_dir.' '.$dst_dir);
} //exec ('cp -RLp '.$src_dir.' '.$dst_dir);
//make sure the conf directory exists }
if (!mkdir($this->switch_conf_dir, 0755, true)) { //make sure the conf directory exists
//throw new Exception("Failed to create the switch conf directory '".$this->switch_conf_dir."'. "); if (!mkdir($this->switch_conf_dir, 0755, true)) {
} //throw new Exception("Failed to create the switch conf directory '".$this->switch_conf_dir."'. ");
}
}
} }
} }
function copy_scripts() { function copy_scripts() {
clearstatcache(); clearstatcache();
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/scripts'; if (file_exists($this->switch_scripts_dir)) {
$dst_dir = $this->switch_scripts_dir; $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/scripts';
if (is_readable($this->switch_scripts_dir)) { $dst_dir = $this->switch_scripts_dir;
$this->recursive_copy($src_dir, $dst_dir); if (is_readable($this->switch_scripts_dir)) {
unset($src_dir, $dst_dir); $this->recursive_copy($src_dir, $dst_dir);
unset($src_dir, $dst_dir);
}
} }
} }
function copy_sounds() { function copy_sounds() {
clearstatcache(); clearstatcache();
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sounds/en/us/callie/custom/8000'; if (file_exists($this->switch_sounds_dir)) {
$dst_dir = $this->switch_sounds_dir.'/en/us/callie/custom/8000'; $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sounds/en/us/callie/custom/8000';
if (is_readable($this->switch_sounds_dir)) { $dst_dir = $this->switch_sounds_dir.'/en/us/callie/custom/8000';
if ($handle = opendir($src_dir)) { if (is_readable($this->switch_sounds_dir)) {
$i = 0; if ($handle = opendir($src_dir)) {
$files = array(); $i = 0;
while (false !== ($file = readdir($handle))) { $files = array();
if ($file != "." && $file != ".." && is_file($src_dir.'/'.$file)) { while (false !== ($file = readdir($handle))) {
if (!file_exists($dst_dir.'/'.$file) ) { if ($file != "." && $file != ".." && is_file($src_dir.'/'.$file)) {
//copy the file if it does not exist in the destination directory if (!file_exists($dst_dir.'/'.$file) ) {
if (copy($src_dir.'/'.$file, $dst_dir.'/'.$file)) { //copy the file if it does not exist in the destination directory
$this->result['copy']['sounds']['8000'][] = "copied from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n"; if (copy($src_dir.'/'.$file, $dst_dir.'/'.$file)) {
} $this->result['copy']['sounds']['8000'][] = "copied from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n";
else { }
$this->result['copy']['sounds']['8000'][] = "copy failed from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n"; else {
$this->result['copy']['sounds']['8000'][] = "copy failed from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n";
}
} }
} }
} }
} }
}
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sounds/en/us/callie/custom/16000'; $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sounds/en/us/callie/custom/16000';
$dst_dir = $this->switch_sounds_dir.'/en/us/callie/custom/16000'; $dst_dir = $this->switch_sounds_dir.'/en/us/callie/custom/16000';
if ($handle = opendir($src_dir)) { if ($handle = opendir($src_dir)) {
$i = 0; $i = 0;
$files = array(); $files = array();
while (false !== ($file = readdir($handle))) { while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_file($src_dir.'/'.$file)) { if ($file != "." && $file != ".." && is_file($src_dir.'/'.$file)) {
if (!file_exists($dst_dir.'/'.$file) ) { if (!file_exists($dst_dir.'/'.$file) ) {
//copy the file if it does not exist in the destination directory //copy the file if it does not exist in the destination directory
if (copy($src_dir.'/'.$file, $dst_dir.'/'.$file)) { if (copy($src_dir.'/'.$file, $dst_dir.'/'.$file)) {
$this->result['copy']['sounds']['16000'][] = "copied from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n"; $this->result['copy']['sounds']['16000'][] = "copied from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n";
} }
else { else {
$this->result['copy']['sounds']['16000'][] = "copy failed from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n"; $this->result['copy']['sounds']['16000'][] = "copy failed from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n";
}
} }
} }
} }
@@ -192,23 +198,27 @@ include "root.php";
function copy_swf() { function copy_swf() {
clearstatcache(); clearstatcache();
$file = "slim.swf"; if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/recordings')) {
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/htdocs'; $file = "slim.swf";
$dst_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/recordings'; $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/htdocs';
if (copy($src_dir.'/'.$file, $dst_dir.'/'.$file)) { $dst_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/recordings';
$this->result['copy']['swf'][] = "copied from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n"; if (copy($src_dir.'/'.$file, $dst_dir.'/'.$file)) {
} $this->result['copy']['swf'][] = "copied from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n";
else { }
$this->result['copy']['swf'][] = "copy failed from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n"; else {
$this->result['copy']['swf'][] = "copy failed from ".$src_dir."/".$file." to ".$dst_dir."/".$file."<br />\n";
}
} }
} }
function copy_phrases() { function copy_phrases() {
clearstatcache(); clearstatcache();
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/conf/lang"; if (file_exists($this->switch_conf_dir."/lang")) {
$dst_dir = $this->switch_conf_dir."/lang"; $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/conf/lang";
if (is_readable($this->switch_conf_dir)) { $dst_dir = $this->switch_conf_dir."/lang";
$this->recursive_copy($src_dir, $dst_dir); if (is_readable($this->switch_conf_dir)) {
$this->recursive_copy($src_dir, $dst_dir);
}
} }
} }