本文整理汇总了PHP中recursive_copy函数的典型用法代码示例。如果您正苦于以下问题:PHP recursive_copy函数的具体用法?PHP recursive_copy怎么用?PHP recursive_copy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了recursive_copy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recursive_copy
function recursive_copy($src, $dst)
{
$dir = opendir($src);
@mkdir($dst);
while (false !== ($file = readdir($dir))) {
if ($file != '.' && $file != '..') {
if (is_dir($src . '/' . $file)) {
recursive_copy($src . '/' . $file, $dst . '/' . $file);
} else {
copy($src . '/' . $file, $dst . '/' . $file);
}
}
}
closedir($dir);
}
示例2: recursive_copy
function recursive_copy($src, $dst)
{
if (!file_exists($src) && !is_dir($src)) {
die("Template not found");
}
$dir = opendir($src);
mkdir($dst);
while (false !== ($file = readdir($dir))) {
if ($file != '.' && $file != '..') {
if (is_dir($src . '/' . $file)) {
recursive_copy($src . '/' . $file, $dst . '/' . $file);
} else {
copy($src . '/' . $file, $dst . '/' . $file);
}
}
}
closedir($dir);
}
示例3: recursive_copy
function recursive_copy($source, $destination)
{
$counter = 0;
if (substr($source, strlen($source), 1) != "/") {
$source .= "/";
}
if (substr($destination, strlen($destination), 1) != "/") {
$destination .= "/";
}
if (!is_dir($destination)) {
makeDirs($destination);
}
$itens = listFiles($source);
foreach ($itens as $id => $name) {
if ($name[0] == "/") {
$name = substr($name, 1);
}
if (is_file($source . $name)) {
// file
if ($name != "Thumbs.db") {
$counter++;
if (!copy($source . $name, $destination . $name)) {
echo "Error: " . $source . $name . " -> " . $destination . $name . "<br/>";
} else {
safe_chmod($destination . $name, 0775);
}
} else {
@unlink($source . $name);
}
} else {
if (is_dir($source . $name)) {
// dir
if (!is_dir($destination . $name)) {
safe_mkdir($destination . $name);
}
$counter += recursive_copy($source . $name, $destination . $name);
}
}
}
return $counter;
}
示例4: recursive_copy
function recursive_copy($source, $dest)
{
global $return;
if (is_dir($source)) {
$dir_handle = opendir($source);
while ($file = readdir($dir_handle)) {
if ($file != "." && $file != "..") {
if (is_dir($source . "/" . $file)) {
if (!is_dir($dest . "/" . $file)) {
mkdir($dest . "/" . $file);
}
recursive_copy($source . "/" . $file, $dest . "/" . $file);
} else {
copy($source . "/" . $file, $dest . "/" . $file);
$return['copied'][] = $source . "/" . $file;
}
}
}
closedir($dir_handle);
} else {
copy($source, $dest);
$return['copied'][] = $source;
}
}
示例5: copy_scripts
protected function copy_scripts()
{
$this->write_progress("\tCopying Scripts");
$script_dir = $this->global_settings->switch_script_dir();
if (strlen($script_dir) == 0) {
throw new Exception("Cannot copy scripts the 'script_dir' is empty");
}
if (file_exists($script_dir)) {
if (file_exists('/usr/share/examples/fusionpbx/resources/install/scripts')) {
$src_dir = '/usr/share/examples/fusionpbx/resources/install/scripts';
} else {
$src_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/resources/install/scripts';
}
$dst_dir = $script_dir;
if (is_readable($script_dir)) {
recursive_copy($src_dir, $dst_dir, $_SESSION['scripts']['options']['text']);
unset($src_dir, $dst_dir);
} else {
throw new Exception("Cannot read from '{$src_dir}' to get the scripts");
}
chmod($dst_dir, 0774);
} else {
$this->write_progress("\tSkipping scripts, script_dir is unset");
}
}
示例6: backup_dir
protected function backup_dir($dir, $backup_name)
{
if (!is_readable($dir)) {
throw new Exception("backup_dir() source directory '" . $dir . "' does not exist.");
}
$dst_tar = join(DIRECTORY_SEPARATOR, array(sys_get_temp_dir(), "{$backup_name}.tar"));
//pharData is the correct ay to do it, but it keeps creating incomplete archives
//$tar = new PharData($dst_tar);
//$tar->buildFromDirectory($dir);
$this->write_debug("backing up to {$dst_tar}");
if (file_exists('/bin/tar')) {
exec('tar -cvf ' . $dst_tar . ' -C ' . $dir . ' .');
} else {
$this->write_debug('WARN: old config could not be compressed');
$dst_dir = join(DIRECTORY_SEPARATOR, array(sys_get_temp_dir(), "{$backup_name}"));
recursive_copy($dir, $dst_dir);
}
}
示例7: copy_files
/**
* Copy the switch scripts from the web directory to the switch directory
*/
public function copy_files()
{
if (strlen($_SESSION['switch']['scripts']['dir']) > 0) {
$dst_dir = $_SESSION['switch']['scripts']['dir'];
if (strlen($dst_dir) == 0) {
throw new Exception("Cannot copy scripts the 'script_dir' is empty");
}
if (file_exists($dst_dir)) {
//get the source directory
if (file_exists('/usr/share/examples/fusionpbx/resources/install/scripts')) {
$src_dir = '/usr/share/examples/fusionpbx/resources/install/scripts';
} else {
$src_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/resources/install/scripts';
}
if (is_readable($dst_dir)) {
recursive_copy($src_dir, $dst_dir);
unset($src_dir, $dst_dir);
} else {
throw new Exception("Cannot read from '{$src_dir}' to get the scripts");
}
chmod($dst_dir, 0774);
} else {
throw new Exception("Scripts directory doesn't exist");
}
}
}
示例8: recursive_copy
/** Recursively copy a directory
*/
function recursive_copy($dirsourceparent, $dirdest, &$md5sums, $dirsource = "")
{
global $dryrun;
global $check_md5s;
global $amp_conf;
global $asterisk_conf;
global $install_moh;
global $make_links;
$moh_subdir = isset($amp_conf['MOHDIR']) ? trim(trim($amp_conf['MOHDIR']), '/') : 'mohmp3';
// total # files, # actually copied
$num_files = $num_copied = 0;
if ($dirsource && $dirsource[0] != "/") {
$dirsource = "/" . $dirsource;
}
if (is_dir($dirsourceparent . $dirsource)) {
$dir_handle = opendir($dirsourceparent . $dirsource);
}
/*
echo "dirsourceparent: "; var_dump($dirsourceparent);
echo "dirsource: "; var_dump($dirsource);
echo "dirdest: "; var_dump($dirdest);
*/
while (isset($dir_handle) && ($file = readdir($dir_handle))) {
if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn") {
$source = $dirsourceparent . $dirsource . "/" . $file;
$destination = $dirdest . $dirsource . "/" . $file;
if ($dirsource == "" && $file == "moh" && !$install_moh) {
// skip to the next dir
continue;
}
// configurable in amportal.conf
if (strpos($destination, "htdocs_panel") == 1) {
$destination = str_replace("/htdocs_panel", trim($amp_conf["FOPWEBROOT"]), $destination);
} else {
$destination = str_replace("/htdocs", trim($amp_conf["AMPWEBROOT"]), $destination);
}
$destination = str_replace("/htdocs_panel", trim($amp_conf["FOPWEBROOT"]), $destination);
// $destination=str_replace("/cgi-bin",trim($amp_conf["AMPCGIBIN"]),$destination);
if (strpos($dirsource, 'modules') === false) {
$destination = str_replace("/bin", trim($amp_conf["AMPBIN"]), $destination);
}
$destination = str_replace("/sbin", trim($amp_conf["AMPSBIN"]), $destination);
// the following are configurable in asterisk.conf
$destination = str_replace("/astetc", trim($asterisk_conf["astetcdir"]), $destination);
$destination = str_replace("/moh", trim($asterisk_conf["astvarlibdir"]) . "/{$moh_subdir}", $destination);
$destination = str_replace("/astvarlib", trim($asterisk_conf["astvarlibdir"]), $destination);
if (strpos($dirsource, 'modules') === false) {
$destination = str_replace("/agi-bin", trim($asterisk_conf["astagidir"]), $destination);
}
if (strpos($dirsource, 'modules') === false) {
$destination = str_replace("/sounds", trim($asterisk_conf["astvarlibdir"]) . "/sounds", $destination);
}
// if this is a directory, ensure destination exists
if (is_dir($source)) {
if (!file_exists($destination)) {
if (!$dryrun && $destination != "") {
amp_mkdir($destination, "0750", true);
}
}
}
//var_dump($md5sums);
if (!is_dir($source)) {
$md5_source = preg_replace("|^/?amp_conf/|", "/", $source);
if ($check_md5s && file_exists($destination) && isset($md5sums[$md5_source]) && md5_file($destination) != $md5sums[$md5_source]) {
// double check using diff utility (and ignoring whitespace)
// This is a somewhat edge case (eg, the file doesn't match
// it's md5 sum from the previous version, but no substantial
// changes exist compared to the current version), but it
// pervents a useless prompt to the user.
if (checkDiff($source, $destination)) {
$overwrite = ask_overwrite($source, $destination);
} else {
debug("NOTE: MD5 for " . $destination . " was different, but `diff` did not detect any (non-whitespace) changes: overwriting");
$overwrite = true;
}
} else {
$overwrite = true;
}
$num_files++;
if ($overwrite) {
debug(($make_links ? "link" : "copy") . " " . $source . " -> " . $destination);
if (!$dryrun) {
if ($make_links) {
// symlink, unlike copy, doesn't overwrite - have to delete first
if (is_link($destination) || file_exists($destination)) {
unlink($destination);
}
symlink($_ENV["PWD"] . "/" . $source, $destination);
} else {
copy($source, $destination);
}
$num_copied++;
}
} else {
debug("not overwriting " . $destination);
}
} else {
//echo "recursive_copy($dirsourceparent, $dirdest, $md5sums, $dirsource/$file)";
//.........这里部分代码省略.........
示例9: fopen
} else {
echo '<form method="post">';
echo '<input name="submit" type="hidden" value="submit" />';
echo '</form>';
if (!empty($_POST['submit'])) {
$hostfile = fopen($zip_url . $zip_name, 'r');
$fh = fopen($zip_name, 'w');
while (!feof($hostfile)) {
$output = fread($hostfile, 8192);
fwrite($fh, $output);
}
fclose($hostfile);
fclose($fh);
require_once 'pclzip.lib.php';
$archive = new PclZip($zip_name);
if (($v_result_list = $archive->extract()) == 0) {
die("Error : " . $archive->errorInfo(true));
}
unlink($zip_name);
//DELETE ZIP
recursive_copy($src_dir, $dest_dir);
//COPY FILES
//system('/bin/rm -rf ' . escapeshellarg($src_dir)); //LINUX DELETE
system('rd /Q /S "' . $src_dir . '"');
//WINDOWS DELETE
include 'mysql_update.php';
//UPDATE MYSQL
echo "Updater finished!";
//FINAL
}
}
示例10: createStore
public function createStore()
{
$this->load->dbforge();
$this->load->helper('file_helper');
$this->load->helper('Mobile_Detect_helper');
$this->load->helper('create_db_helper');
$detect = new Mobile_Detect();
$deviceName = "";
if ($detect->isMobile()) {
$deviceName = "mobile";
} else {
if ($detect->isTablet()) {
$deviceName = "tablet";
} else {
$deviceName = "pc";
}
}
$post = $this->input->post();
$clientInfo = $post["clientInfo"];
$userId = $this->session->userdata("userid");
$databaseObj = $this->template->getTemplateName($post["key"]);
$resultObj = $databaseObj->result()[0];
$projectName = $resultObj->TemplateProjectName;
$projectImage = $resultObj->TemplateImage;
recursive_copy("assets/template/" . $projectName, "../" . $post["domainName"]);
copy("assets/images/screen-shot/" . $projectImage, "assets/images/screen-shot/" . $post["domainName"] . ".jpg");
$databaseObj->next_result();
$databaseObj = $this->template->createStore($post["storeName"], $post["domainName"], $userId, $post["key"], $clientInfo["appCodeName"], $clientInfo["appVersion"], $this->input->ip_address(), $deviceName, $clientInfo["platform"]);
$newStore = $databaseObj->result()[0];
$databaseObj->next_result();
execSql($newStore->TemplateType, $post["domainName"], get_instance());
}
示例11: copy_conf
protected function copy_conf()
{
//send a message
$this->write_progress("\tCopying Config");
//make a backup of the config
if (file_exists($this->global_settings->switch_conf_dir())) {
$this->backup_dir($this->global_settings->switch_conf_dir(), 'fusionpbx_switch_config');
recursive_delete($this->global_settings->switch_conf_dir());
}
//make sure the conf directory exists
if (!is_dir($this->global_settings->switch_conf_dir())) {
if (!mkdir($this->global_settings->switch_conf_dir(), 0774, true)) {
throw new Exception("Failed to create the switch conf directory '" . $this->global_settings->switch_conf_dir() . "'. ");
}
}
//copy resources/templates/conf to the freeswitch conf dir
if (file_exists('/usr/share/examples/fusionpbx/resources/templates/conf')) {
$src_dir = "/usr/share/examples/fusionpbx/resources/templates/conf";
} else {
$src_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/resources/templates/conf";
}
$dst_dir = $this->global_settings->switch_conf_dir();
if (is_readable($dst_dir)) {
recursive_copy($src_dir, $dst_dir);
unset($src_dir, $dst_dir);
}
$fax_dir = join(DIRECTORY_SEPARATOR, array($this->global_settings->switch_storage_dir(), 'fax'));
if (!is_readable($fax_dir)) {
mkdir($fax_dir, 0777, true);
}
$voicemail_dir = join(DIRECTORY_SEPARATOR, array($this->global_settings->switch_storage_dir(), 'voicemail'));
if (!is_readable($voicemail_dir)) {
mkdir($voicemail_dir, 0777, true);
}
//write the xml_cdr.conf.xml file
if (file_exists($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/app/xml_cdr")) {
xml_cdr_conf_xml();
}
//write the switch.conf.xml file
if (file_exists($this->global_settings->switch_conf_dir())) {
switch_conf_xml();
}
}
示例12: sync_directory
function sync_directory()
{
global $v_id, $db;
$v_settings_array = v_settings();
foreach ($v_settings_array as $name => $value) {
${$name} = $value;
}
//if the directory does not exist then create it.
clearstatcache();
if (!is_dir($v_sounds_dir . "/en/us/callie/directory/48000")) {
mkdir($v_sounds_dir . "/en/us/callie/directory/48000", 0700, true);
$src_dir = $v_web_dir . '/includes/install/sounds/directory/48000';
$dest_dir = $v_sounds_dir . "/en/us/callie/directory/48000";
//echo "src_dir $src_dir<br />\n";
//echo "dest_dir $dest_dir<br />\n";
recursive_copy($src_dir, $dest_dir);
}
$tmp = "include(\"config.js\");\n";
$tmp .= "//var sounds_dir\n";
$tmp .= "var admin_pin = \"\";\n";
$tmp .= "var search_type = \"\";\n";
$tmp .= "//var tmp_dir\n";
$tmp .= "var digitmaxlength = 0;\n";
$tmp .= "var timeoutpin = 5000;\n";
$tmp .= "var timeouttransfer = 5000;\n";
$tmp .= "\n";
$tmp .= "var dtmf = new Object( );\n";
$tmp .= "dtmf.digits = \"\";\n";
$tmp .= "\n";
$tmp .= "function mycb( session, type, obj, arg ) {\n";
$tmp .= "\ttry {\n";
$tmp .= "\t\tif ( type == \"dtmf\" ) {\n";
$tmp .= "\t\t\tconsole_log( \"info\", \"digit: \"+obj.digit+\"\\n\" );\n";
$tmp .= "\t\t\tif ( obj.digit == \"#\" ) {\n";
$tmp .= "\t\t\t\t//console_log( \"info\", \"detected pound sign.\\n\" );\n";
$tmp .= "\t\t\t\texit = true;\n";
$tmp .= "\t\t\t\treturn( false );\n";
$tmp .= "\t\t\t}\n";
$tmp .= "\t\t\tif ( obj.digit == \"*\" ) {\n";
$tmp .= "\t\t\t\t//console_log( \"info\", \"detected pound sign.\\n\" );\n";
$tmp .= "\t\t\t\texit = true;\n";
$tmp .= "\t\t\t\treturn( false );\n";
$tmp .= "\t\t\t}\n";
$tmp .= "\t\t\tdtmf.digits += obj.digit;\n";
$tmp .= "\t\t\tif ( dtmf.digits.length >= digitmaxlength ) {\n";
$tmp .= "\t\t\t\texit = true;\n";
$tmp .= "\t\t\t\treturn( false );\n";
$tmp .= "\t\t\t}\n";
$tmp .= "\t\t}\n";
$tmp .= "\t} catch (e) {\n";
$tmp .= "\t\tconsole_log( \"err\", e+\"\\n\" );\n";
$tmp .= "\t}\n";
$tmp .= "\treturn( true );\n";
$tmp .= "} //end function mycb\n";
$tmp .= "\n";
$tmp .= "function directory_search(search_type) {\n";
$tmp .= "\n";
$tmp .= "\tdigitmaxlength = 3;\n";
$tmp .= "\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-enter-person.wav\");\n";
$tmp .= "\tif (search_type == \"last_name\") {\n";
$tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-last_name.wav\", mycb, \"dtmf\");\n";
$tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-to_search_by.wav\", mycb, \"dtmf\");\n";
$tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-first_name.wav\", mycb, \"dtmf\");\n";
$tmp .= "\t}\n";
$tmp .= "\tif (search_type == \"first_name\") {\n";
$tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-first_name.wav\", mycb, \"dtmf\");\n";
$tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-to_search_by.wav\", mycb, \"dtmf\");\n";
$tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-last_name.wav\", mycb, \"dtmf\");\n";
$tmp .= "\t}\n";
$tmp .= "\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-press.wav\", mycb, \"dtmf\");\n";
$tmp .= "\tsession.execute(\"say\", \"en name_spelled iterated 1\");\n";
$tmp .= "\tsession.collectInput( mycb, dtmf, timeoutpin );\n";
$tmp .= "\tvar dtmf_search = dtmf.digits;\n";
$tmp .= "\t//console_log( \"info\", \"--\" + dtmf.digits + \"--\\n\" );\n";
$tmp .= "\tif (dtmf_search == \"1\") {\n";
$tmp .= "\t\t//console_log( \"info\", \"press 1 detected: \" + dtmf.digits + \"\\n\" );\n";
$tmp .= "\t\t//console_log( \"info\", \"press 1 detected: \" + search_type + \"\\n\" );\n";
$tmp .= "\t\tif (search_type == \"last_name\") {\n";
$tmp .= "\t\t\t//console_log( \"info\", \"press 1 detected last_name: \" + search_type + \"\\n\" );\n";
$tmp .= "\t\t\tsearch_type = \"first_name\";\n";
$tmp .= "\t\t}\n";
$tmp .= "\t\telse {\n";
$tmp .= "\t\t\t//console_log( \"info\", \"press 1 detected first_name: \" + search_type + \"\\n\" );\n";
$tmp .= "\t\t\tsearch_type = \"last_name\";\n";
$tmp .= "\t\t}\n";
$tmp .= "\t\tdtmf_search = \"\";\n";
$tmp .= "\t\tdtmf.digits = \"\";\n";
$tmp .= "\t\tdirectory_search(search_type);\n";
$tmp .= "\t\treturn;\n";
$tmp .= "\t}\n";
$tmp .= "\tconsole_log( \"info\", \"first 3 letters of first or last name: \" + dtmf.digits + \"\\n\" );\n";
$tmp .= "\n";
$tmp .= "\t//session.execute(\"say\", \"en name_spelled pronounced mark\");\n";
$tmp .= "\t//<action application=\"say\" data=\"en name_spelled iterated \${destination_number}\"/>\n";
$tmp .= "\t//session.execute(\"say\", \"en number iterated 12345\");\n";
$tmp .= "\t//session.execute(\"say\", \"en number pronounced 1001\");\n";
$tmp .= "\t//session.execute(\"say\", \"en short_date_time pronounced [timestamp]\");\n";
$tmp .= "\t//session.execute(\"say\", \"en CURRENT_TIME pronounced CURRENT_TIME\");\n";
$tmp .= "\t//session.execute(\"say\", \"en CURRENT_DATE pronounced CURRENT_DATE\");\n";
$tmp .= "\t//session.execute(\"say\", \"en CURRENT_DATE_TIME pronounced CURRENT_DATE_TIME\");\n";
//.........这里部分代码省略.........
示例13: recursive_copy
/**
* From http://www.php.net/manual/en/function.copy.php#91256
* Copy file or folder from source to destination
* @param string $source file or folder
* @param string $dest file or folder
* @param array $options (optional) folderPermission,filePermission
* @return boolean
*/
function recursive_copy($source, $dest, $options = array('folderPermission' => 0755, 'filePermission' => 0755))
{
$result = false;
if (is_file($source)) {
if ($dest[strlen($dest) - 1] == '/') {
if (!file_exists($dest)) {
cmfcDirectory::makeAll($dest, $options['folderPermission'], true);
}
$__dest = $dest . '/' . basename($source);
} else {
$__dest = $dest;
}
$result = copy($source, $__dest);
chmod($__dest, $options['filePermission']);
} elseif (is_dir($source)) {
if ($dest[strlen($dest) - 1] == '/') {
if ($source[strlen($source) - 1] == '/') {
//Copy only contents
} else {
//Change parent itself and its contents
$dest = $dest . basename($source);
@mkdir($dest);
chmod($dest, $options['filePermission']);
}
} else {
if ($source[strlen($source) - 1] == '/') {
//Copy parent directory with new name and all its content
@mkdir($dest, $options['folderPermission']);
chmod($dest, $options['filePermission']);
} else {
//Copy parent directory with new name and all its content
@mkdir($dest, $options['folderPermission']);
chmod($dest, $options['filePermission']);
}
}
$dirHandle = opendir($source);
while ($file = readdir($dirHandle)) {
if ($file != '.' && $file != '..') {
if (!is_dir($source . "/" . $file)) {
$__dest = $dest . '/' . $file;
} else {
$__dest = $dest . '/' . $file;
}
//echo "$source/$file ||| $__dest<br />";
$result = recursive_copy($source . "/" . $file, $__dest, $options);
}
}
closedir($dirHandle);
} else {
$result = false;
}
return $result;
}
示例14: chdir
# Unpdates shebang for Unix
###############################################################################
*/
#error_reporting(0); // Disable PHP errors and warnings
// Comment to Enable for testing
chdir(dirname(__FILE__));
// Change wd to this files location
include_once "../../main/includes/config.inc.php";
include_once "../../main/includes/functions.php";
run_location_tracker();
// Have servers moved update configuration accordingly
//=== Update shebang in all files in folder cgi-bin and sub-folders ===========
print "\n ============= End of line and shebang update =============\n\n";
if (perl_installed()) {
//Copy all fies to new folder and update end of lines
recursive_copy($base_f . '/cgi-bin', $base_f . '/cgi-bin-unix');
// Copy folder tree before conversion
$start_dir = $base_f . '/cgi-bin-unix';
// starting folder
$file_type = '/(\\.pl|\\.cgi)/';
// list file types to convert
$search_str = '/\\r/';
// string to search for
$replace_str = "";
// replace string
recursive_search_replace($start_dir, $file_type, $search_str, $replace_str);
// replace
//Update shebang to Unix
$start_dir = $base_f . "/cgi-bin-unix";
// Unix Perl folder
$file_type = '/(\\.pl|\\.cgi)/';
示例15: recursive_copy
/** Recursively copy a directory
*/
function recursive_copy($dirsourceparent, $dirdest, &$md5sums, $dirsource = "")
{
global $dryrun;
global $check_md5s;
global $amp_conf;
global $asterisk_conf;
global $install_moh;
global $make_links;
$overwrite = false;
$moh_subdir = isset($amp_conf['MOHDIR']) ? trim(trim($amp_conf['MOHDIR']), '/') : 'mohmp3';
// total # files, # actually copied
$num_files = $num_copied = 0;
if ($dirsource && $dirsource[0] != "/") {
$dirsource = "/" . $dirsource;
}
if (is_dir($dirsourceparent . $dirsource)) {
$dir_handle = opendir($dirsourceparent . $dirsource);
}
/*
echo "dirsourceparent: "; var_dump($dirsourceparent);
echo "dirsource: "; var_dump($dirsource);
echo "dirdest: "; var_dump($dirdest);
*/
while (isset($dir_handle) && ($file = readdir($dir_handle))) {
if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn" && $file != ".git") {
$source = $dirsourceparent . $dirsource . "/" . $file;
$destination = $dirdest . $dirsource . "/" . $file;
if ($dirsource == "" && $file == "moh" && !$install_moh) {
// skip to the next dir
continue;
}
// configurable in amportal.conf
$destination = preg_replace("/^\\/htdocs\\//i", trim($amp_conf["AMPWEBROOT"]) . "/", $destination);
if (strpos($dirsource, 'modules') === false) {
$destination = str_replace("/bin", trim($amp_conf["AMPBIN"]), $destination);
}
$destination = str_replace("/sbin", trim($amp_conf["AMPSBIN"]), $destination);
// the following are configurable in asterisk.conf
$destination = str_replace("/astetc", trim($asterisk_conf["astetcdir"]), $destination);
$destination = str_replace("/moh", trim($asterisk_conf["astvarlibdir"]) . "/{$moh_subdir}", $destination);
$destination = str_replace("/astvarlib", trim($asterisk_conf["astvarlibdir"]), $destination);
if (strpos($dirsource, 'modules') === false) {
$destination = str_replace("/agi-bin", trim($asterisk_conf["astagidir"]), $destination);
}
if (strpos($dirsource, 'modules') === false) {
$destination = str_replace("/sounds", trim($asterisk_conf["astvarlibdir"]) . "/sounds", $destination);
}
// if this is a directory, ensure destination exists
if (is_dir($source)) {
if (!file_exists($destination)) {
if (!$dryrun && $destination != "") {
amp_mkdir($destination, "0750", true);
}
}
}
//var_dump($md5sums);
if (!is_dir($source)) {
$md5_source = preg_replace("|^/?amp_conf/|", "/", $source);
if ($check_md5s && file_exists($destination) && isset($md5sums[$md5_source]) && md5_file($destination) != $md5sums[$md5_source]) {
// double check using diff utility (and ignoring whitespace)
// This is a somewhat edge case (eg, the file doesn't match
// it's md5 sum from the previous version, but no substantial
// changes exist compared to the current version), but it
// prevents a useless prompt to the user.
if (checkDiff($source, $destination)) {
$overwrite = ask_overwrite($source, $destination);
} else {
debug("NOTE: MD5 for " . $destination . " was different, but `diff` did not detect any (non-whitespace) changes: overwriting");
$overwrite = true;
}
} else {
$overwrite = true;
}
// These are modified by apply_conf.sh, there may be others that fit in this category also. This keeps these from
// being symlinked and then developers inadvertently checking in the changes when they should not have.
//
$never_symlink = array("cdr_mysql.conf", "manager.conf", "vm_email.inc", "modules.conf");
$num_files++;
if ($overwrite) {
debug(($make_links ? "link" : "copy") . " " . $source . " -> " . $destination);
if (!$dryrun) {
if ($make_links && !in_array(basename($source), $never_symlink)) {
// symlink, unlike copy, doesn't overwrite - have to delete first
if (is_link($destination) || file_exists($destination)) {
unlink($destination);
}
$links = recursive_readlink($source);
if (!empty($links)) {
@symlink(substitute_readlinks($source, $links), $destination);
} else {
if (file_exists(dirname(__FILE__) . "/" . $source)) {
@symlink(dirname(__FILE__) . "/" . $source, $destination);
}
}
} else {
$ow = false;
if (file_exists($destination)) {
if (checkDiff($source, $destination) && !$make_links) {
//.........这里部分代码省略.........