Esempio n. 1
0
require_once api_get_path(LIBRARY_PATH) . 'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
$error = '';
$fileInfo = array();
if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_RENAME) {
    $error = SYS_DISABLED;
} elseif (empty($_POST['name'])) {
    $error = ERR_RENAME_EMPTY;
} elseif (!preg_match("/^[a-zA-Z0-9 _\\-.]+\$/", $_POST['name'])) {
    $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']);
Esempio n. 2
0
//保存的图片的层级
$thisdir = dirname(__FILE__);
$default_pic = $thisdir . "/Image/default.png";
//默认图片的地址
$pic_url = isset($_GET['url']) ? $_GET['url'] : "";
$raw_pic_url = $pic_url;
$pic_size = isset($_GET['size']) ? $_GET['size'] : "";
$log_file = $thisdir . '/' . date("Y-m-d") . ".log";
$dzUp = new discuz_upload();
$dir2 = $dzUp->get_target_dir('common', strlen($pic_url));
$url_pathinfo = pathinfo($pic_url);
if (empty($url_pathinfo['extension'])) {
    $url_pathinfo['extension'] = 'png';
}
//判断是否是非法后缀,非法后缀则直接跳转
if (!isValidExt($pic_url)) {
    runlog('bigapp', 'invalid postfix, reject to optmize, just redirect [ url: ' . $pic_url . ' ]');
    redirect($pic_url);
}
$dir = getglobal('setting/attachdir') . './common/' . $dir2 . 'bigapp/';
//图片存储的目录
if ($pic_url != "" && array_key_exists($pic_size, $allow_pic_array)) {
    $size = $pic_size;
    $url_md5 = md5($pic_url);
    for ($i = 0; $i < $hashlevel; $i++) {
        $dir .= $url_md5[$i] . '/';
    }
    if ($dir != "" && !file_exists($dir)) {
        mkdir($dir, 0755, true);
    }
    $url_pathinfo = pathinfo($pic_url);