本文整理汇总了PHP中copy_recursive函数的典型用法代码示例。如果您正苦于以下问题:PHP copy_recursive函数的具体用法?PHP copy_recursive怎么用?PHP copy_recursive使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copy_recursive函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replaceCustomSmartyPlugins
/**
* Scan Smarty plugins directories and relocate custom plugins to correct location
*/
public function replaceCustomSmartyPlugins()
{
// Step 1: scan vendor/Smarty/plugin directory to get a list of system plugins
$vendorSmartyPluginsList = array();
$vendorSmartyPluginsPath = 'vendor/Smarty/plugins/';
$failedToCopySmartyPluginsList = array();
$customSmartyPluginsPaths = array('include/Smarty/plugins/', 'custom/include/Smarty/plugins/');
$includeSmartyPluginsPath = 'include/SugarSmarty/plugins/';
$correctCustomSmartyPluginsPath = 'custom/include/SugarSmarty/plugins/';
if (is_dir($vendorSmartyPluginsPath)) {
$iter = new FilesystemIterator($vendorSmartyPluginsPath, FilesystemIterator::UNIX_PATHS);
foreach ($iter as $item) {
if ($item->getFileName() == '.' || $item->getFileName() == '..' || $item->isDir() || $item->getExtension() != 'php') {
continue;
}
$filename = $item->getFilename();
$vendorSmartyPluginsList[] = $filename;
}
}
// Step 2: scan custom plugin directories and relocate ONLY custom plugins to correct location
foreach ($customSmartyPluginsPaths as $customSmartyPluginsPath) {
if (is_dir($customSmartyPluginsPath)) {
$iter = new FilesystemIterator($customSmartyPluginsPath, FilesystemIterator::UNIX_PATHS);
foreach ($iter as $item) {
if ($item->getFilename() == '.' || $item->getFilename() == '..' || $item->isDir() || $item->getExtension() != 'php') {
continue;
}
$file = $item->getPathname();
if (!in_array($item->getFilename(), $vendorSmartyPluginsList) && !is_file($includeSmartyPluginsPath . $item->getFilename())) {
$this->log("Copy custom plugin {$file} to {$correctCustomSmartyPluginsPath}");
if (!sugar_is_dir($correctCustomSmartyPluginsPath)) {
mkdir_recursive($correctCustomSmartyPluginsPath);
}
if (copy_recursive($file, $correctCustomSmartyPluginsPath . $item->getFilename())) {
$this->upgrader->fileToDelete($file);
} else {
$failedToCopySmartyPluginsList[] = $file;
}
}
}
}
}
//Step 3: remove all files from custom Smarty plugins destinations except the {$correctCustomSmartyPluginsPath}
if (empty($failedToCopySmartyPluginsList)) {
foreach ($customSmartyPluginsPaths as $customSmartyPluginsPath) {
if (is_dir($customSmartyPluginsPath)) {
$this->log("Path {$customSmartyPluginsPath} is deleted from custom plugins directory due to a relocation of vendors");
rmdir_recursive($customSmartyPluginsPath);
}
}
} else {
foreach ($failedToCopySmartyPluginsList as $failedToCopySmartyPluginsItem) {
$this->log("File {$failedToCopySmartyPluginsItem} cannot be copied to new location automatically");
}
}
}
示例2: tearDown
public function tearDown()
{
parent::tearDown();
if ($this->packageExists) {
//Copy original contents back in
copy_recursive('custom/modules/' . $this->package . '_bak', 'custom/modules/' . $this->package);
rmdir_recursive('custom/modules/' . $this->package . '_bak');
} else {
rmdir_recursive('custom/modules/' . $this->package);
}
unset($_SESSION['avail_modules'][$this->package]);
}
示例3: backup
/**
* backup
* Private method to handle backing up the file to custom/backup directory
*
* @param $file File or directory to backup to custom/backup directory
*/
protected function backup($file)
{
$basename = basename($file);
$basepath = str_replace($basename, '', $file);
if (!empty($basepath) && !file_exists('custom/backup/' . $basepath)) {
mkdir_recursive('custom/backup/' . $basepath);
}
if (is_dir($file)) {
copy_recursive($file, 'custom/backup/' . $file);
} else {
copy($file, 'custom/backup/' . $file);
}
}
示例4: copy_recursive
function copy_recursive($source, $dest)
{
if (is_file($source)) {
return copy($source, $dest);
}
if (!sugar_is_dir($dest, 'instance')) {
sugar_mkdir($dest);
}
$status = true;
$d = dir($source);
while ($f = $d->read()) {
if ($f == "." || $f == "..") {
continue;
}
$status &= copy_recursive("{$source}/{$f}", "{$dest}/{$f}");
}
$d->close();
return $status;
}
示例5: copy_recursive
/**
* ディレクトリを再帰的にコピー
*
* @param string $src
* @param string $dst
*/
function copy_recursive($src, $dst)
{
// In case you'd like to delete exsiting files, you should call rmdir_recursive..
if (file_exists($dst)) {
rmdir_recursive($dst);
}
if (is_dir($src)) {
mkdir($dst);
$files = scandir($src);
foreach ($files as $file) {
if ($file != "." && $file != "..") {
copy_recursive("{$src}/{$file}", "{$dst}/{$file}");
}
}
} else {
if (file_exists($src)) {
copy($src, $dst);
}
}
}
示例6: copy_recursive
function copy_recursive($src, $dst)
{
//if (file_exists($dst)) rrmdir($dst);
if (is_dir($src)) {
if (!file_exists($dst)) {
mkdir($dst);
}
//mkdir($dst);
$files = scandir($src);
foreach ($files as $file) {
// ignore .svn directories
if ($file != "." && $file != ".." && $file != '.svn') {
copy_recursive("{$src}/{$file}", "{$dst}/{$file}");
}
}
} else {
if (file_exists($src)) {
copy($src, $dst);
}
}
}
示例7: copy_recursive
function copy_recursive($source, $target, $excludes = array())
{
if (is_dir($source)) {
mkdir($target);
$d = dir($source);
while (false !== ($entry = $d->read())) {
if ('.' === $entry or '..' === $entry or in_array($entry, $excludes)) {
continue;
}
$Entry = $source . '/' . $entry;
if (is_dir($Entry)) {
copy_recursive($Entry, $target . '/' . $entry, $excludes);
continue;
}
copy($Entry, $target . '/' . $entry);
}
$d->close();
} else {
copy($source, $target);
}
}
示例8: copy_recursive
function copy_recursive($source, $dest)
{
if (is_dir($source)) {
$dirHandle = opendir($source);
while ($file = readdir($dirHandle)) {
if (!is_dir($dest)) {
mkdir($dest);
}
if ($file != "." && $file != "..") {
if (is_dir($source . "/" . $file)) {
if (!is_dir($dest . "/" . $file)) {
mkdir($dest . "/" . $file);
}
copy_recursive($source . "/" . $file, $dest . "/" . $file);
} else {
copy($source . "/" . $file, $dest . "/" . $file);
}
}
}
closedir($dirHandle);
} else {
copy($source, $dest);
}
}
示例9: array
if (preg_match('/^([\\w]+)\\.php$/', $dirEntry, $regs)) {
$pluginInfo[$regs[1]] = array('installUrl' => $packageurl, 'developer' => $developer, 'projectName' => $project_name, 'installDate' => time());
}
$bu_dir = time();
if (file_exists($pluginDestination . '/' . $dirEntry)) {
print ' ' . s('updating existing plugin');
if (preg_match('/(.*)\\.php$/', $dirEntry, $regs)) {
$pluginsForUpgrade[] = $regs[1];
}
@rename($pluginDestination . '/' . $dirEntry, $pluginDestination . '/' . $dirEntry . '.' . $bu_dir);
} else {
print ' ' . s('new plugin');
}
# var_dump($pluginInfo);
print '<br/>';
if (copy_recursive($GLOBALS['tmpdir'] . '/phpListPluginInstall/' . $dir_prefix . '/plugins/' . $dirEntry, $pluginDestination . '/' . $dirEntry)) {
delFsTree($pluginDestination . '/' . $dirEntry . '.' . $bu_dir);
$installOk = true;
} elseif (is_dir($pluginDestination . '/' . $dirEntry . '.' . $bu_dir)) {
## try to place old one back
@rename($pluginDestination . '/' . $dirEntry . '.' . $bu_dir, $pluginDestination . '/' . $dirEntry);
}
}
}
foreach ($pluginInfo as $plugin => $pluginDetails) {
# print 'Writing '.$pluginDestination.'/'.$plugin.'.info.txt<br/>';
file_put_contents($pluginDestination . '/' . $plugin . '.info.txt', serialize($pluginDetails));
}
## clean up
delFsTree($GLOBALS['tmpdir'] . '/phpListPluginInstall');
if ($installOk) {
示例10: get_required_upgrades
function get_required_upgrades($soapclient, $session)
{
global $sugar_config, $sugar_version;
require_once 'vendor/nusoap//nusoap.php';
$errors = array();
$upgrade_history = new UpgradeHistory();
$upgrade_history->disable_row_level_security = true;
$installeds = $upgrade_history->getAllOrderBy('date_entered ASC');
$history = array();
require_once 'soap/SoapError.php';
$error = new SoapError();
foreach ($installeds as $installed) {
$history[] = array('id' => $installed->id, 'filename' => $installed->filename, 'md5' => $installed->md5sum, 'type' => $installed->type, 'status' => $installed->status, 'version' => $installed->version, 'date_entered' => $installed->date_entered, 'error' => $error->get_soap_array());
}
$result = $soapclient->call('get_required_upgrades', array('session' => $session, 'client_upgrade_history' => $history, 'client_version' => $sugar_version));
$tempdir_parent = create_cache_directory("disc_client");
$temp_dir = tempnam($tempdir_parent, "sug");
sugar_mkdir($temp_dir, 0775);
$upgrade_installed = false;
if (empty($soapclient->error_str) && $result['error']['number'] == 0) {
foreach ($result['upgrade_history_list'] as $upgrade) {
$file_result = $soapclient->call('get_encoded_file', array('session' => $session, 'filename' => $upgrade['filename']));
if (empty($soapclient->error_str) && $result['error']['number'] == 0) {
if ($file_result['md5'] == $upgrade['md5']) {
$newfile = write_encoded_file($file_result, $temp_dir);
unzip($newfile, $temp_dir);
global $unzip_dir;
$unzip_dir = $temp_dir;
if (file_exists("{$temp_dir}/manifest.php")) {
require_once "{$temp_dir}/manifest.php";
global $manifest_arr;
$manifest_arr = $manifest;
if (!isset($manifest['offline_client_applicable']) || $manifest['offline_client_applicable'] == true || $manifest['offline_client_applicable'] == 'true') {
if (file_exists("{$temp_dir}/scripts/pre_install.php")) {
require_once "{$temp_dir}/scripts/pre_install.php";
pre_install();
}
if (isset($manifest['copy_files']['from_dir']) && $manifest['copy_files']['from_dir'] != "") {
$zip_from_dir = $manifest['copy_files']['from_dir'];
}
$source = "{$temp_dir}/{$zip_from_dir}";
$dest = getcwd();
copy_recursive($source, $dest);
if (file_exists("{$temp_dir}/scripts/post_install.php")) {
require_once "{$temp_dir}/scripts/post_install.php";
post_install();
}
//save newly installed upgrade
$new_upgrade = new UpgradeHistory();
$new_upgrade->filename = $upgrade['filename'];
$new_upgrade->md5sum = $upgrade['md5'];
$new_upgrade->type = $upgrade['type'];
$new_upgrade->version = $upgrade['version'];
$new_upgrade->status = "installed";
$new_upgrade->save();
$upgrade_installed = true;
}
}
}
}
}
}
return $upgrade_installed;
}
示例11: upgradeDCEFiles
function upgradeDCEFiles($argv, $instanceUpgradePath)
{
//copy and update following files from upgrade package
$upgradeTheseFiles = array('cron.php', 'download.php', 'index.php', 'install.php', 'soap.php', 'sugar_version.php', 'vcal_server.php');
foreach ($upgradeTheseFiles as $file) {
$srcFile = clean_path("{$instanceUpgradePath}/{$file}");
$destFile = clean_path("{$argv[3]}/{$file}");
if (file_exists($srcFile)) {
if (!is_dir(dirname($destFile))) {
mkdir_recursive(dirname($destFile));
// make sure the directory exists
}
copy_recursive($srcFile, $destFile);
$_GET['TEMPLATE_PATH'] = $destFile;
$_GET['CONVERT_FILE_ONLY'] = true;
if (!class_exists('TemplateConverter')) {
include $argv[7] . 'templateConverter.php';
} else {
TemplateConverter::convertFile($_GET['TEMPLATE_PATH']);
}
}
}
}
示例12: copy_recursive
/**
* Recursively copy files
* @param string $path file path with no trailing slash
* @return void
*/
function copy_recursive($path)
{
$path .= '/';
if (!is_readable('site/' . $path)) {
mkdir('site/' . $path, 0755, true);
}
foreach (scandir($path) as $file) {
if (in_array($file, array('.', '..'), true)) {
continue;
} elseif (is_dir($path . $file)) {
copy_recursive($path . $file);
} else {
copy($path . $file, 'site/' . $path . $file);
}
}
}
示例13: exportProject
function exportProject($package, $export = true, $clean = true)
{
$tmppath = "custom/modulebuilder/projectTMP/";
if (file_exists($this->getPackageDir())) {
if (mkdir_recursive($tmppath)) {
copy_recursive($this->getPackageDir(), $tmppath . "/" . $this->name);
$manifest = $this->getManifest(true, $export) . $this->exportProjectInstall($package, $export);
$fp = sugar_fopen($tmppath . '/manifest.php', 'w');
fwrite($fp, $manifest);
fclose($fp);
if (file_exists('modules/ModuleBuilder/MB/LICENSE.txt')) {
copy('modules/ModuleBuilder/MB/LICENSE.txt', $tmppath . '/LICENSE.txt');
} else {
if (file_exists('LICENSE.txt')) {
copy('LICENSE.txt', $tmppath . '/LICENSE.txt');
}
}
$readme_contents = $this->readme;
$readmefp = sugar_fopen($tmppath . '/README.txt', 'w');
fwrite($readmefp, $readme_contents);
fclose($readmefp);
}
}
require_once 'include/utils/zip_utils.php';
$date = date('Y_m_d_His');
$zipDir = "custom/modulebuilder/packages/ExportProjectZips";
if (!file_exists($zipDir)) {
mkdir_recursive($zipDir);
}
$cwd = getcwd();
chdir($tmppath);
zip_dir('.', $cwd . '/' . $zipDir . '/project_' . $this->name . $date . '.zip');
chdir($cwd);
if ($clean && file_exists($tmppath)) {
rmdir_recursive($tmppath);
}
if ($export) {
header('Location:' . $zipDir . '/project_' . $this->name . $date . '.zip');
}
return $zipDir . '/project_' . $this->name . $date . '.zip';
}
示例14: upgradeSugarCache
/**
* change from using the older SugarCache in 6.1 and below to the new one in 6.2
*/
function upgradeSugarCache($file)
{
global $sugar_config;
// file = getcwd().'/'.$sugar_config['upload_dir'].$_FILES['upgrade_zip']['name'];
$cacheUploadUpgradesTemp = clean_path(mk_temp_dir("{$sugar_config['upload_dir']}upgrades/temp"));
unzip($file, $cacheUploadUpgradesTemp);
if (!file_exists(clean_path("{$cacheUploadUpgradesTemp}/manifest.php"))) {
logThis("*** ERROR: no manifest file detected while bootstraping upgrade wizard files!");
return;
} else {
include clean_path("{$cacheUploadUpgradesTemp}/manifest.php");
}
$allFiles = array();
if (file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/database"))) {
$allFiles = findAllFiles(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/database"), $allFiles);
}
if (file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/SugarCache"))) {
$allFiles = findAllFiles(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/SugarCache"), $allFiles);
}
if (file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/external_cache.php"))) {
$allFiles[] = clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/external_cache.php");
}
$cwd = clean_path(getcwd());
foreach ($allFiles as $k => $file) {
$file = clean_path($file);
$destFile = str_replace(clean_path($cacheUploadUpgradesTemp . '/' . $manifest['copy_files']['from_dir']), $cwd, $file);
if (!is_dir(dirname($destFile))) {
mkdir_recursive(dirname($destFile));
// make sure the directory exists
}
if (stristr($file, 'uw_main.tpl')) {
logThis('Skipping "' . $file . '" - file copy will during commit step.');
} else {
logThis('updating UpgradeWizard code: ' . $destFile);
copy_recursive($file, $destFile);
}
}
logThis('is sugar_file_util there ' . file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/sugar_file_utils.php")));
if (file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/sugar_file_utils.php"))) {
$file = clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/sugar_file_utils.php");
$destFile = str_replace(clean_path($cacheUploadUpgradesTemp . '/' . $manifest['copy_files']['from_dir']), $cwd, $file);
copy($file, $destFile);
}
}
示例15: clean_copy_assets
function clean_copy_assets($path)
{
@mkdir($path);
$options = $GLOBALS["options"];
//Clean
clean_directory($path);
//Copy assets
$unnecessaryImgs = array('./img/favicon.png', './img/favicon-blue.png', './img/favicon-green.png', './img/favicon-navy.png', './img/favicon-red.png');
$unnecessaryJs = array();
if ($options['colors']) {
$unnecessaryLess = array('./less/daux-blue.less', './less/daux-green.less', './less/daux-navy.less', './less/daux-red.less');
copy_recursive('./less', $path . '/', $unnecessaryLess);
$unnecessaryImgs = array_diff($unnecessaryImgs, array('./img/favicon.png'));
} else {
$unnecessaryJs = array('./js/less.min.js');
@mkdir($path . '/css');
@copy('./css/daux-' . $options['theme'] . '.min.css', $path . '/css/daux-' . $options['theme'] . '.min.css');
$unnecessaryImgs = array_diff($unnecessaryImgs, array('./img/favicon-' . $options['theme'] . '.png'));
}
copy_recursive('./img', $path . '/', $unnecessaryImgs);
copy_recursive('./js', $path . '/', $unnecessaryJs);
}