本文整理汇总了PHP中CFileMan::CopyEx方法的典型用法代码示例。如果您正苦于以下问题:PHP CFileMan::CopyEx方法的具体用法?PHP CFileMan::CopyEx怎么用?PHP CFileMan::CopyEx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileMan
的用法示例。
在下文中一共展示了CFileMan::CopyEx方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Init
//.........这里部分代码省略.........
},
fileNew: {
alt_name: "<?php
echo CUtil::JSEscape($altName);
?>
",
name: "<?php
echo CUtil::JSEscape($name_i);
?>
",
path: "<?php
echo CUtil::JSEscape($filePath);
?>
",
site: "<?php
echo CUtil::JSEscape($site);
?>
",
bDir: <?php
echo $bDir_i ? "true" : "false";
?>
,
size: "<?php
echo $bDir_i ? '-' : CFile::FormatSize($fTmp1->GetFileSize());
?>
",
date: "<?php
echo date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL")), CFilemanUtils::GetModifyTime($absPath_i) + CTimeZone::GetOffset());
?>
"
}
};
</script><?php
return;
} elseif ($caseOption == 'replace') {
// We don't need to replace, couse it's one file
if (CFileMan::NormalizePath($pathTo . "/" . $name_i) == $filePath) {
continue;
}
$strWarn = CFileMan::CopyEx($arPath_i, array($siteTo, CFileMan::NormalizePath($pathTo . "/" . $name_i)), !$Params['bCopy'], true);
if ($strWarn != "") {
$arWarnings[] = $strWarn;
$log = false;
} elseif ($Params['bSearch'] && $Params['ssess'] && !$Params['bCopy']) {
CFilemanSearch::DelFromSearchResult($Params['ssess'], $filePath);
}
} elseif ($caseOption == 'auto_rename') {
$strWarn = CFileMan::CopyEx($arPath_i, array($siteTo, CFileMan::NormalizePath($pathTo . "/" . $altName)), !$Params['bCopy']);
if ($strWarn != "") {
$arWarnings[] = $strWarn;
$log = false;
} elseif ($Params['bSearch'] && $Params['ssess'] && !$Params['bCopy']) {
CFilemanSearch::DelFromSearchResult($Params['ssess'], $filePath);
}
} elseif ($caseOption == 'skip') {
continue;
}
} else {
$strWarn = CFileMan::CopyEx($arPath_i, array($siteTo, CFileMan::NormalizePath($pathTo . "/" . $name_i)), !$Params['bCopy']);
if ($strWarn != "") {
$arWarnings[] = $strWarn;
$log = false;
} elseif ($Params['bSearch'] && $Params['ssess'] && !$Params['bCopy']) {
CFilemanSearch::DelFromSearchResult($Params['ssess'], $filePath);
}
}
$module_id = "fileman";
if (COption::GetOptionString($module_id, "log_page", "Y") == "Y" && $log) {
$res_log['copy_to'] = substr($pathTo, 1);
$res_log['path'] = substr($filePath, 1);
if ($Params['bCopy'] == "copy") {
if (!$bDir_i) {
CEventLog::Log("content", "FILE_COPY", "fileman", "", serialize($res_log));
} else {
CEventLog::Log("content", "SECTION_COPY", "fileman", "", serialize($res_log));
}
} else {
if (!$bDir_i) {
CEventLog::Log("content", "FILE_MOVE", "fileman", "", serialize($res_log));
} else {
CEventLog::Log("content", "SECTION_MOVE", "fileman", "", serialize($res_log));
}
}
}
}
}
$arWarnings;
?>
<script>
window.BXFM_result = {
status: "<?php
echo count($arWarnings) > 0 ? 'errors' : 'ok';
?>
",
errors: <?php
echo count($arWarnings) > 0 ? CUtil::PhpToJSObject($arWarnings) : '{}';
?>
};
</script><?php
}
示例2: CopyEx
function CopyEx($path_from, $path_to, $bDeleteAfterCopy = false, $bOverride = false)
{
global $APPLICATION, $USER;
CMain::InitPathVars($site_from, $path_from);
$DOC_ROOT_FROM = CSite::GetSiteDocRoot($site_from);
CMain::InitPathVars($site_to, $path_to);
$DOC_ROOT_TO = CSite::GetSiteDocRoot($site_to);
$strWarning = '';
//check: if we copy to the same directory
if (strpos($DOC_ROOT_TO . $path_to . "/", $DOC_ROOT_FROM . $path_from . "/") === 0) {
return GetMessage("FILEMAN_LIB_BAD_FOLDER") . ": \"" . $path_from . "\".\n";
}
$io = CBXVirtualIo::GetInstance();
if ($io->DirectoryExists($DOC_ROOT_FROM . $path_from)) {
// Minimal access - read/listing for copying files
if (!$USER->CanDoFileOperation('fm_view_listing', array($site_from, $path_from))) {
return GetMessage("FILEMAN_FILEMAN_FOLDER_READ_DENY") . " \"" . $path_from . "\".\n";
}
if ($bDeleteAfterCopy && !$USER->CanDoFileOperation('fm_delete_folder', array($site_from, $path_from))) {
return GetMessage("FILEMAN_FILEMAN_FOLDER_DEL_DENY") . " \"" . $path_from . "\".\n";
}
//Check: folder exist or not
$strWarTmp = CFileMan::CreateDir(array($site_to, $path_to));
if (strlen($strWarTmp) > 0) {
return $strWarTmp;
}
$APPLICATION->CopyFileAccessPermission(array($site_from, $path_from), array($site_to, $path_to));
} else {
// If we can write this file
if (!$USER->CanDoFileOperation('fm_create_new_file', array($site_to, $path_to))) {
return GetMessage("FILEMAN_FILEMAN_FILE_WRITE_DENY") . " \"" . $path_to . "\".\n";
}
// If we can't read source-file
if (!$USER->CanDoFileOperation('fm_view_file', array($site_from, $path_from))) {
return GetMessage("FILEMAN_FILEMAN_FILE_READ_DENY") . " \"" . $path_from . "\".\n";
}
// Copying php or system file without PHP or LPA access
if (!($USER->CanDoOperation('edit_php') || $USER->CanDoFileOperation('fm_lpa', $arPath) || !(HasScriptExtension($Elem["NAME"]) || substr($Elem["NAME"], 0, 1) == "."))) {
return GetMessage("FILEMAN_FILEMAN_FILE_READ_DENY") . " \"" . $path_from . "\".\n";
}
// If we can't move source-file
if ($bDeleteAfterCopy && !$USER->CanDoFileOperation('fm_delete_file', array($site_from, $path_from))) {
return GetMessage("FILEMAN_FILEMAN_FILE_DEL_DENY") . " \"" . $path_from . "\".\n";
}
//Check if folder already exist and trying to create if not
$p = strrpos($path_to, "/");
$path_to_dir = substr($path_to, 0, $p);
$strWarTmp = CFileMan::CreateDir(array($site_to, $path_to_dir));
if (strlen($strWarTmp) > 0) {
return $strWarTmp;
}
if ($io->FileExists($DOC_ROOT_TO . $path_to) || $io->DirectoryExists($DOC_ROOT_TO . $path_to)) {
if ($bOverride) {
$strWarn = CFileMan::DeleteEx(array($site_to, $path_to));
if ($strWarn != "") {
return $strWarn;
}
} else {
return GetMessage("FILEMAN_FILEMAN_FILE_WITH_NAME") . " \"" . $path_to . "\" " . GetMessage("FILEMAN_FILEMAN_ALREADY_EXISTS") . "!\n";
}
}
$APPLICATION->CopyFileAccessPermission(array($site_from, $path_from), array($site_to, $path_to));
//************************** Quota **************************//
if (COption::GetOptionInt("main", "disk_space") > 0) {
$f = $io->GetFile($DOC_ROOT_FROM . $path_from);
$size = $f->GetFileSize();
$quota = new CDiskQuota();
if (!$quota->checkDiskQuota(array("FILE_SIZE" => $size))) {
return $quota->LAST_ERROR;
}
}
//************************** Quota **************************//
// Copy file
if (DEBUG_FILE_MAN) {
echo "copy(" . $DOC_ROOT_FROM . $path_from . "," . $DOC_ROOT_TO . $path_to . ");<br>";
}
if (!$io->Copy($DOC_ROOT_FROM . $path_from, $DOC_ROOT_TO . $path_to)) {
$strWarning .= GetMessage('FILEMAN_COPY_ERROR', array('#PATH_FROM#' => htmlspecialcharsex($path_from), '#PATH_TO#' => htmlspecialcharsex($path_to)));
}
//************************** Quota **************************//
if (COption::GetOptionInt("main", "disk_space") > 0) {
$quota->updateDiskQuota("file", $size, "copy");
}
//************************** Quota **************************//
if (CModule::IncludeModule("search")) {
$site = CSite::GetSiteByFullPath($DOC_ROOT_TO . $path_to);
CSearch::ReIndexFile(array($site_to, $path_to), $site);
}
if ($bDeleteAfterCopy && strlen($strWarning) <= 0) {
// If was command "delete after copy"?
$strWarning .= CFileMan::DeleteFile(array($site_from, $path_from));
}
return $strWarning;
}
// Recursive
$d = $io->GetDirectory($DOC_ROOT_FROM . $path_from);
$arChildren = $d->GetChildren();
foreach ($arChildren as $child) {
$fn = $child->GetName();
if ($child->IsDirectory()) {
//.........这里部分代码省略.........
示例3: array
$lAdmin->AddGroupError($strWarning_tmp, $ID);
}
break;
case "copy":
case "move":
if (!($USER->CanDoFileOperation('fm_create_new_file', $arPath_i) || $USER->CanDoFileOperation('fm_create_new_folder', $arPath_i)) || !($USER->CanDoFileOperation('fm_delete_file', $arPath_i) || $USER->CanDoFileOperation('fm_delete_folder', $arPath_i)) && $_REQUEST['action'] == 'move') {
break;
}
if (!CSite::IsDistinctDocRoots() || CFileMan::__CheckSite($copy_to_site) === false) {
$copy_to_site = $site;
}
$name_i = $bSearch ? CFileman::GetFileName($ID) : $ID;
if (($mess = CFileMan::CheckFileName(str_replace('/', '', $copy_to))) !== true) {
$lAdmin->AddGroupError($mess, $ID);
} else {
$strWarning_tmp = CFileMan::CopyEx(array($site, CFileMan::NormalizePath($pathEx)), array($copy_to_site, CFileMan::NormalizePath($copy_to . "/" . $name_i)), $_REQUEST['action'] == "move" ? true : false);
}
if ($bSearch && $_REQUEST['action'] == "move") {
CFilemanSearch::DelFromSearchResult($searchSess, $pathEx);
}
if (strlen($strWarning_tmp) > 0) {
$lAdmin->AddGroupError($strWarning_tmp, $ID);
}
break;
}
}
}
InitSorting();
if (!$bSearch) {
$arDirs = array();
$arFiles = array();
示例4: Edit
//.........这里部分代码省略.........
if (!file_exists($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$template))
{
?><script>alert('Error: Incorrect template Id: <?php
echo CUtil::JSEscape($template);
?>
');</script><?
return;
}
if ($Params['bNew'])
{
$location = CUtil::addslashes(CFileMan::SecurePathVar($Params["location"]));
$newGroup = CUtil::addslashes(CFileMan::SecurePathVar($Params["newGroup"]));
$path = trim(($location ? $location.'/' : '').($newGroup ? $newGroup.'/' : ''), ' /');
if ($name == '')
{
$name = CSnippets::GetDefaultFileName($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$template."/snippets/".$path);
?><script>window.__bx_res_sn_filename = "<?php
echo CUtil::JSEscape($name);
?>
";</script><?
}
$name = $name.'.snp';
}
$key = $path.($path != '' ? '/' : '').$name;
// 1. Save new snippet with new content
if ($code)
$APPLICATION->SaveFileContent($contPath.'/'.$key, $code);
// 2. Rewrite title & description in .content.php
if ($title || $description)
{
if (file_exists($contPath."/.content.php"))
@include($contPath."/.content.php");
else
$SNIPPETS = array();
if ($title)
$SNIPPETS[$key]['title'] = $title;
if ($description)
$SNIPPETS[$key]['description'] = $description;
$contentSrc = '<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>'.chr(10);
$contentSrc .= '<?'.chr(10).'$SNIPPETS = Array();'.chr(10);
foreach ($SNIPPETS as $k=>$_arSn)
{
if (CSnippets::CheckFile(array('site' => $Params["site"], 'template' => $Params['template'], 'path' => $k)))
$contentSrc .= '$SNIPPETS[\''.CUtil::addslashes($k).'\'] = Array("title"=>\''.Cutil::addslashes($_arSn['title']).'\', "description"=>\''.Cutil::addslashes($_arSn['description']).'\');'.chr(10);
}
$contentSrc .= '?>';
$APPLICATION->SaveFileContent($contPath."/.content.php", $contentSrc);
}
CSnippets::ClearCache();
// 3. Handle thumbnail
if ($thumb !== false)
{
if (substr($thumb,0,1) == '/')
$thumb = substr($thumb,1);
$pos = strrpos($name,".");
if ($pos === FALSE)
return true;
//delete existent thumbnail
$f_name = substr($name, 0, $pos);
$img_path1 = BX_PERSONAL_ROOT.'/templates/'.$template.'/snippets/images/'.$path.($path == '' ? '' : '/').$f_name;
$DOC_ROOT = CSite::GetSiteDocRoot($site);
$arExt = array("gif", "jpg", "jpeg", "png", "bmp");
for ($i = 0, $c = count($arExt); $i < $c; $i++)
{
$p_ = $img_path1.".".$arExt[$i];
if(file_exists($DOC_ROOT.$p_))
CFileman::DeleteFile(Array($site, $p_));
}
if (empty($thumb) || strrpos($thumb, '.') === FALSE)
return true;
// Copy Thumbnail
$path_from_1 = $DOC_ROOT."/".$thumb;
$path_from = '/'.$thumb;
if (file_exists($path_from_1))
{
$pos = strrpos($thumb,".");
$f_ext = ($pos !== FALSE) ? strtolower(substr($thumb, $pos + 1)) : '';
if (in_array($f_ext, $arExt))
{
$path_to = $img_path1.'.'.$f_ext;
$strWarning_tmp = CFileMan::CopyEx(Array($site, $path_from), Array($site, $path_to));
}
}
}
}
示例5: check_freetrix_sessid
"SECTION_DELETE",
"main",
"",
serialize($res_log)
);
}
}
elseif(($_GET['action'] == 'copy' || $_GET['action'] == 'move') && check_freetrix_sessid() && $bFileman)
{
$normFrom = $io->CombinePath("/", $_GET["from"]);
$name = "";
if(($pos = strrpos($normFrom, "/")) !== false)
$name = substr($normFrom, $pos+1);
$normTo = $io->CombinePath("/", $_GET["to"]."/".$name);
if($normFrom <> "" && $normTo <> "")
$strWarning = CFileMan::CopyEx(array($_GET["site"], $normFrom), array($_GET["site"], $normTo), ($_GET['action'] == "move"? true : false));
}
if(isset($_GET['show_all_files']))
$arOptions['show_all_files'] = ($_GET['show_all_files'] == 'Y');
if(isset($_GET['show_file_info']))
$arOptions['show_file_info'] = ($_GET['show_file_info'] == 'Y');
if(isset($_GET['show_all_files']) || isset($_GET['show_file_info']))
CUserOptions::SetOption("public_structure", "options", $arOptions);
if($_GET['load_path'] <> '')
{
echo __struct_get_files($DOC_ROOT, _normalizePath($_GET['load_path']), "", ($_GET['dirsonly']=='Y'));
}
elseif($_GET['reload'] == 'Y')
{