本文整理汇总了PHP中rrename函数的典型用法代码示例。如果您正苦于以下问题:PHP rrename函数的具体用法?PHP rrename怎么用?PHP rrename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rrename函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rrename
function rrename($source, $destination, $is_rec = FALSE)
{
if (is_dir($source)) {
if ($is_rec === FALSE) {
$pinfo = pathinfo($source);
$destination = rtrim($destination, '/') . DIRECTORY_SEPARATOR . $pinfo['basename'];
}
if (is_dir($destination) === FALSE) {
mkdir($destination, 0755, true);
}
$files = scandir($source);
foreach ($files as $file) {
if ($file != "." && $file != "..") {
rrename($source . DIRECTORY_SEPARATOR . $file, rtrim($destination, '/') . DIRECTORY_SEPARATOR . $file, TRUE);
}
}
} else {
if (file_exists($source)) {
if (is_dir($destination) === TRUE) {
$pinfo = pathinfo($source);
$dest2 = rtrim($destination, '/') . DIRECTORY_SEPARATOR . $pinfo['basename'];
} else {
$dest2 = $destination;
}
rename($source, $dest2);
}
}
}
示例2: response
// check for writability
if (is_really_writable($path) === FALSE || is_really_writable($path_thumb) === FALSE) {
response(trans('Dir_No_Write') . '<br/>' . str_replace('../', '', $path) . '<br/>' . str_replace('../', '', $path_thumb), 403)->send();
exit;
}
// check if server disables copy or rename
if (is_function_callable($action == 'copy' ? 'copy' : 'rename') === FALSE) {
response(sprintf(trans('Function_Disabled'), $action == 'copy' ? lcfirst(trans('Copy')) : lcfirst(trans('Cut'))), 403)->send();
exit;
}
if ($action == 'copy') {
rcopy($data['path'], $path);
rcopy($data['path_thumb'], $path_thumb);
} elseif ($action == 'cut') {
rrename($data['path'], $path);
rrename($data['path_thumb'], $path_thumb);
// cleanup
if (is_dir($data['path']) === TRUE) {
rrename_after_cleaner($data['path']);
rrename_after_cleaner($data['path_thumb']);
}
}
// cleanup
$_SESSION['RF']['clipboard']['path'] = NULL;
$_SESSION['RF']['clipboard_action'] = NULL;
break;
case 'chmod':
$mode = $_POST['new_mode'];
$rec_option = $_POST['is_recursive'];
$valid_options = array('none', 'files', 'folders', 'both');
$chmod_perm = is_dir($path) ? $chmod_dirs : $chmod_files;