本文整理汇总了PHP中CFile::Rename方法的典型用法代码示例。如果您正苦于以下问题:PHP CFile::Rename方法的具体用法?PHP CFile::Rename怎么用?PHP CFile::Rename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::Rename方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFileValue
function getFileValue(&$str, $dir)
{
$pic = false;
if ($str != "") {
$b_file = new CFile("temp/" . $str);
if ($b_file->id > 0) {
$b_file->Rename($dir . $str);
$pic = $str;
} else {
$b_file2 = new CFile($dir . $str);
if ($b_file2->id > 0) {
$pic = $str;
} else {
$pic = false;
}
}
}
return $pic;
}
示例2: array
$cfile->id = $file['id'];
$cfile->name = $file['fname'];
$cfile->path = $file['path'];
/*
if (empty($cfile->name) || empty($cfile->path)) {
$cnt_path_fail++;
continue;
}
*/
//$to = preg_replace('/\/attach\//', '/private/account/', $cfile->path);
//$to .= $cfile->name;
$to = "{$cfile->path}private/account/{$cfile->name}";
//print_r("USER https://www.fl.ru/users/{$file['login']}/setup/finance/\n");
//print_r("FROM https://st.fl.ru/{$cfile->path}{$cfile->name} TO https://st.fl.ru/{$to}\n\n");
//exit;
if (!$cfile->Rename($to)) {
$cnt_rename_fail++;
/*
$users_links_fail["https://www.fl.ru/users/{$file['login']}/setup/finance/"][] = array(
'from' => "https://st.fl.ru/{$file['path']}{$file['fname']}",
'to' => "https://st.fl.ru/{$to}"
);
*/
continue;
}
unset($cfile);
$cnt_succes++;
/*
$users_links_ok["https://www.fl.ru/users/{$file['login']}/setup/finance/"][] = array(
'from' => "https://st.fl.ru/{$file['path']}{$file['fname']}",
'to' => "https://st.fl.ru/{$to}"
示例3: CFile
$cf = new CFile($_FILES['document'], dav_file_upload::FILE_TABLE);
if ($cf->CheckPath($path)) {
$destname = dav_file_upload_createDestName($cf);
//check existing file
$existingFile = new CFile("{$path}/{$destname}");
if ($existingFile->id > 0) {
$ext = $existingFile->getext($existingFile->name);
$tmp = $existingFile->secure_tmpname($path . '/', '.' . $ext);
$rename_name = substr_replace($tmp, "", 0, strlen($path) + 1);
$s = preg_replace("#\\." . $ext . "\$#", "", $destname);
$length = strlen($s . '_' . $rename_name);
if ($length > 64 && strlen($rename_name) < 64) {
$s = substr($s, 0, 63 - strlen($rename_name));
$rename_name = $s . "_" . $rename_name;
}
$existingFile->Rename("{$path}/{$rename_name}");
$info = 'Файл был заменен';
$old_link = WDCPREFIX . '/' . $path . '/' . $rename_name;
}
$cf->server_root = 1;
$cf->max_size = dav_file_upload::MAX_FILE_SIZE;
$cf->MoveUploadedFile($path . '/', true, $destname);
$err = is_string($cf->error[0]) ? $cf->error : $cf->error[0];
if ($err == '') {
$link = WDCPREFIX . '/' . $cf->path . $cf->name;
$name = WDCPREFIX . '/' . $cf->path . $cf->name;
$info = 'Файл был загружен';
//добавляем запись в таблицу replace_file_log
dav_file_upload::addRecord($cf->id, $cf->name, $rename_name);
}
} else {
示例4: header
**/
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/stdf.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/CFile.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/dav_file_upload.php';
if (!hasPermissions('admin')) {
header('Location: /404.php');
exit;
}
$srcdir = $_SERVER['DOCUMENT_ROOT'] . '/about';
$ls = scandir($srcdir);
foreach ($ls as $item) {
if ($item != '.' && $item !== '..' && !is_dir("{$srcdir}/{$item}")) {
$filedata = array('name' => $item, 'tmp_name' => "{$srcdir}/{$item}", 'size' => filesize("{$srcdir}/{$item}"));
$srcfile = new CFile($filedata);
$srcfile->unlinkOff = true;
$path = 'about/documents';
$destfile = new CFile("{$path}/{$item}", dav_file_upload::FILE_TABLE);
$rename_name = '';
if ($destfile->id) {
$ext = $destfile->getext($destfile->name);
$tmp = $destfile->secure_tmpname($path . '/', '.' . $ext);
$rename_name = substr_replace($tmp, '', 0, strlen($path) + 1);
$destfile->Rename("{$path}/{$rename_name}");
}
$srcfile->server_root = 1;
$srcfile->max_size = dav_file_upload::MAX_FILE_SIZE;
$r = $srcfile->MoveUploadedFile($path . '/', true, $item);
dav_file_upload::addRecord($srcfile->id, $srcfile->name, $rename_name);
echo "Copy {$srcdir}/{$item} " . WDCPREFIX . '/' . $path . '/' . $item . '<br><br>';
}
}
示例5: _postDbSuccess
/**
* Выполняется после успешного занесения проекта в БД.
* Удаляет ненужные файлы с сервера, перемещает новые, формирует RSS-файл.
* При удалении старых аттачей с сервера и из бызы file_projects, они автоматом удаляются из project_attach.
*/
private function _postDbSuccess()
{
if ($this->_tmpFiles) {
foreach ($this->_tmpFiles as $name) {
$cfile = new CFile($this->_tmpAbsDir . $name);
$cfile->Rename($this->_dstAbsDir . $name);
}
$this->_tmpFiles = NULL;
}
if ($this->_deletedFiles) {
//echo '<pre>';
//print_r($this->_deletedFiles);
$this->_fixDeletedFilesInHistory();
//print_r($this->_deletedFiles);
//echo '</pre>';
//exit;
$cfile = new CFile();
foreach ($this->_deletedFiles as $f) {
$cfile->Delete(0, $f['path'], $f['name']);
}
}
$_SESSION['isExistProjects'] = true;
$this->destroy();
}
示例6: saveAction
function saveAction()
{
$db = front::og("db");
$form = front::$_req["form"];
$id_comm = front::$_req["comment"];
$parent = front::$_req["parent"];
if (!$id_comm) {
$id_comm = false;
}
// global $session;
$validate_errors = array();
$save = array();
if (($str = trim($form['title'])) && mb_strlen($str) >= 3) {
$save['title'] = change_q_x_a(antispam($str), 0, 96);
} else {
$validate_errors['title'] = 'Заголовок короче 3 символов';
}
if (($str = trim($form['msg'])) && mb_strlen($str) >= 3) {
$save['msg'] = change_q_x_a(antispam($str), false, false);
} else {
$validate_errors['msg'] = 'Текст короче 3 символов';
}
if (strlen($form['msg']) > blogs::MAX_DESC_CHARS) {
$validate_errors['msg'] = "Максимальный размер сообщения " . blogs::MAX_DESC_CHARS . " символов!";
} else {
$save['msg'] = change_q_x_a(antispam($form['msg']), false, false);
}
$yt_link = substr(change_q_x(antispam(str_replace('watch?v=', 'v/', $form['yt_link'])), true), 0, 128);
if ($yt_link != '') {
if (strpos($yt_link, 'http://ru.youtube.com/v/') !== 0 && strpos($yt_link, 'http://youtube.com/v/') !== 0 && strpos($yt_link, 'http://www.youtube.com/v/') !== 0) {
$validate_errors['yt_link'] = "Неверная ссылка.";
}
}
if (sizeof($validate_errors) > 0) {
echo json_encode(array("success" => 0, "validate" => $validate_errors));
exit(1);
}
$save = front::toWin(array("title" => $form["title"], "msg" => $form["msg"], "yt_link" => $yt_link));
$id = intval($id = front::$_req["id"]);
if ($id_comm) {
// if($parent > 0) {
//
// } else {
$save["id_blog"] = $parent;
$save["id_reply"] = $id;
$save["id_user"] = get_uid();
$id = $db->insert("corporative_blog", $save);
// }
//if($id_comm && $id > 0) {
// $save["id_blog"] = $id;
// $save["id_reply"] = $id;
// }
} else {
if ($id > 0) {
$save["id_modified"] = get_uid();
$save["id_deleted"] = 0;
$save["date_change"] = date("Y-m-d H:i:s");
$aff = $db->update("UPDATE corporative_blog SET ?s WHERE (id = ?n)", $save, $id);
} else {
$save["id_user"] = get_uid();
$id = $db->insert("corporative_blog", $save);
}
}
if ($form["files_deleted"] != "") {
$form["files_deleted"] = preg_replace('/\\\\\\"/', '"', $form["files_deleted"]);
$filesBefore = json_decode($form["files_deleted"]);
$login = $_SESSION['login'];
foreach ($filesBefore as $file) {
if (!$file->db_id) {
continue;
}
front::og("db")->delete("DELETE FROM corporative_blog_attach WHERE id = ?n", $file->db_id);
}
}
if ($form["files"] != "") {
//$filesBefore = explode(";", $form["files"]);
// vardump($form["files"]);
$form["files"] = preg_replace('/\\\\\\"/', '"', $form["files"]);
$filesBefore = json_decode($form["files"]);
if ($group == 7) {
$max_image_size = array('width' => 400, 'height' => 600, 'less' => 0);
} else {
$max_image_size = array('width' => 470, 'height' => 1000, 'less' => 0);
}
$login = $_SESSION["login"];
if ($filesBefore) {
foreach ($filesBefore as $file) {
if (!$file->temp) {
continue;
}
$b_file = new CFile("temp/" . $file->id);
if ($b_file->id > 0) {
$b_file->Rename("users/" . substr($login, 0, 2) . "/" . $login . "/upload" . "/" . $file->id);
$ext = $b_file->getext();
if (in_array($ext, $GLOBALS['graf_array'])) {
$is_image = TRUE;
} else {
$is_image = FALSE;
}
$b_file->max_size = blogs::MAX_FILE_SIZE;
//.........这里部分代码省略.........
示例7: saveAction
public function saveAction()
{
$db = front::og('db');
$form = front::$_req['form'];
$id_comm = front::$_req['comment'];
$parent = front::$_req['parent'];
if (!$id_comm) {
$id_comm = false;
}
// global $session;
$validate_errors = array();
$save = array();
if (($str = trim($form['title'])) && mb_strlen($str) >= 3) {
$save['title'] = change_q_x_a(antispam($str), 0, 96);
} else {
$validate_errors['title'] = 'Заголовок короче 3 символов';
}
if (($str = trim($form['msg'])) && mb_strlen($str) >= 3) {
$save['msg'] = change_q_x_a(antispam($str), false, false);
} else {
$validate_errors['msg'] = 'Текст короче 3 символов';
}
if (strlen($form['msg']) > blogs::MAX_DESC_CHARS) {
$validate_errors['msg'] = 'Максимальный размер сообщения ' . blogs::MAX_DESC_CHARS . ' символов!';
} else {
$save['msg'] = change_q_x_a(antispam($form['msg']), false, false);
}
$yt_link = substr(change_q_x(antispam(str_replace('watch?v=', 'v/', $form['yt_link'])), true), 0, 128);
if ($yt_link != '') {
if (strpos($yt_link, 'http://ru.youtube.com/v/') !== 0 && strpos($yt_link, 'http://youtube.com/v/') !== 0 && strpos($yt_link, 'http://www.youtube.com/v/') !== 0) {
$validate_errors['yt_link'] = 'Неверная ссылка.';
}
}
if (sizeof($validate_errors) > 0) {
echo json_encode(array('success' => 0, 'validate' => $validate_errors));
exit(1);
}
$save = front::toWin(array('title' => $form['title'], 'msg' => $form['msg'], 'yt_link' => $yt_link));
$id = intval($id = front::$_req['id']);
if ($id_comm) {
// if($parent > 0) {
//
// } else {
$save['id_blog'] = $parent;
$save['id_reply'] = $id;
$save['id_user'] = get_uid();
$id = $db->insert('corporative_blog', $save);
// }
//if($id_comm && $id > 0) {
// $save["id_blog"] = $id;
// $save["id_reply"] = $id;
// }
} else {
if ($id > 0) {
$save['id_modified'] = get_uid();
$save['id_deleted'] = 0;
$save['date_change'] = date('Y-m-d H:i:s');
$aff = $db->update('UPDATE corporative_blog SET ?s WHERE (id = ?n)', $save, $id);
} else {
$save['id_user'] = get_uid();
$id = $db->insert('corporative_blog', $save);
}
}
if ($form['files_deleted'] != '') {
$form['files_deleted'] = preg_replace('/\\\\\\"/', '"', $form['files_deleted']);
$filesBefore = json_decode($form['files_deleted']);
$login = $_SESSION['login'];
foreach ($filesBefore as $file) {
if (!$file->db_id) {
continue;
}
front::og('db')->delete('DELETE FROM corporative_blog_attach WHERE id = ?n', $file->db_id);
}
}
if ($form['files'] != '') {
//$filesBefore = explode(";", $form["files"]);
// vardump($form["files"]);
$form['files'] = preg_replace('/\\\\\\"/', '"', $form['files']);
$filesBefore = json_decode($form['files']);
if ($group == 7) {
$max_image_size = array('width' => 400, 'height' => 600, 'less' => 0);
} else {
$max_image_size = array('width' => 470, 'height' => 1000, 'less' => 0);
}
$login = $_SESSION['login'];
if ($filesBefore) {
foreach ($filesBefore as $file) {
if (!$file->temp) {
continue;
}
$b_file = new CFile('temp/' . $file->id);
if ($b_file->id > 0) {
$b_file->Rename('users/' . substr($login, 0, 2) . '/' . $login . '/upload' . '/' . $file->id);
$ext = $b_file->getext();
if (in_array($ext, $GLOBALS['graf_array'])) {
$is_image = true;
} else {
$is_image = false;
}
$b_file->max_size = blogs::MAX_FILE_SIZE;
//.........这里部分代码省略.........