$error = ERR_RENAME_FORMAT; } elseif (empty($_POST['original_path']) || !file_exists($_POST['original_path'])) { $error = ERR_RENAME_FILE_NOT_EXISTS; } elseif (substr(slashToBackslash(removeTrailingSlash($_POST['original_path'])), strrpos(slashToBackslash(removeTrailingSlash($_POST['original_path'])), "/") + 1) == $_POST['name']) { $error = ERR_NO_CHANGES_MADE; } elseif (file_exists(addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name'])) { $error = ERR_RENAME_EXISTS; } elseif (is_file($_POST['original_path']) && !isValidExt($_POST['name'], explode(",", CONFIG_UPLOAD_VALID_EXTS), explode(",", CONFIG_UPLOAD_INVALID_EXTS))) { $error = ERR_RENAME_FILE_TYPE_NOT_PERMITED; } elseif (!rename(removeTrailingSlash($_POST['original_path']), addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name'])) { $error = ERR_RENAME_FAILED; } else { //update record of session if image exists in session for cut or copy include_once CLASS_SESSION_ACTION; $sessionAction = new SessionAction(); $selectedDocuments = $sessionAction->get(); if (removeTrailingSlash($sessionAction->getFolder()) == getParentPath($_POST['original_path']) && sizeof($selectedDocuments)) { if (($key = array_search(basename($_POST['original_path']), $selectedDocuments)) !== false) { $selectedDocuments[$key] = $_POST['name']; $sessionAction->set($selectedDocuments); } } elseif (removeTrailingSlash($sessionAction->getFolder()) == removeTrailingSlash($_POST['original_path'])) { $sessionAction->setFolder($_POST['original_path']); } $path = addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name']; if (is_file($path)) { include_once CLASS_FILE; $file = new file($path); $fileInfo = $file->getFileInfo(); $fileInfo['mtime'] = date(DATE_TIME_FORMAT, $fileInfo['mtime']); } else {