MVC中的Roxy文件管理器不接受会话路径

时间:2021-08-24 03:44:57

Hi guys i downloaded a file manager http://www.roxyfileman.com for my MVC project.So i added to my project and every thing works fine but every one can use this product i mean everyone can type the url and upload the file to my host !!!! this filemanager has a json config file as you can see here :

大家好,我为我的MVC项目下载了一个文件管理器http://www.roxyfileman.com。所以我添加到我的项目和每件事都很好,但每个人都可以使用这个产品,我的意思是每个人都可以输入url和上传文件到我的主机!!!这个文件管理器有一个json配置文件,如下所示:

{
"FILES_ROOT":        "fileman/Uploads",
"SESSION_PATH_KEY":   "FileManager",
"THUMBS_VIEW_WIDTH":  "140",
"THUMBS_VIEW_HEIGHT": "120",
"PREVIEW_THUMB_WIDTH":"300",
"PREVIEW_THUMB_HEIGHT":"200",
"MAX_IMAGE_WIDTH":     "0",
"MAX_IMAGE_HEIGHT":    "0",
"INTEGRATION":       "tinymce3",
"DIRLIST":           "asp_net/main.ashx?a=DIRLIST",
"CREATEDIR":         "asp_net/main.ashx?a=CREATEDIR",
"DELETEDIR":         "asp_net/main.ashx?a=DELETEDIR",
"MOVEDIR":           "asp_net/main.ashx?a=MOVEDIR",
"COPYDIR":           "asp_net/main.ashx?a=COPYDIR",
"RENAMEDIR":         "asp_net/main.ashx?a=RENAMEDIR",
"FILESLIST":         "asp_net/main.ashx?a=FILESLIST",
"UPLOAD":            "asp_net/main.ashx?a=UPLOAD",
"DOWNLOAD":          "asp_net/main.ashx?a=DOWNLOAD",
"DOWNLOADDIR":       "asp_net/main.ashx?a=DOWNLOADDIR",
"DOWNLOADDIR":       "asp_net/main.ashx?a=DOWNLOADDIR",
"DELETEFILE":        "asp_net/main.ashx?a=DELETEFILE",
"MOVEFILE":          "asp_net/main.ashx?a=MOVEFILE",
"COPYFILE":          "asp_net/main.ashx?a=COPYFILE",
"RENAMEFILE":        "asp_net/main.ashx?a=RENAMEFILE",
"GENERATETHUMB":     "asp_net/main.ashx?a=GENERATETHUMB",
"DEFAULTVIEW":       "list",
"FORBIDDEN_UPLOADS": "zip js jsp jsb mhtml mht xhtml xht php phtml php3 php4 php5 phps shtml jhtml pl sh py cgi exe scr dll msi vbs bat com pif cmd vxd cpl htpasswd htaccess",
"ALLOWED_UPLOADS":   "jpg",
"FILEPERMISSIONS":   "0644",
"DIRPERMISSIONS":      "0755",
"LANG":              "auto",
"DATEFORMAT":        "dd/MM/yyyy HH:mm"

}

}

So as you can see the second part is Session key,so i add a session to my project when the users log in as you can see here :

正如你看到的第二部分是Session key,我在用户登录时为我的项目添加了一个Session如你在这里看到的

   public ActionResult Login(LoginModel model, string returnUrl)
    {
        if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
        {
            Session.Add("FileManager",true);
            return RedirectToLocal(returnUrl);
        }

        // If we got this far, something failed, redisplay form
        ModelState.AddModelError("", "The user name or password provided is incorrect.");
        return View(model);
    }

So i added a session FileManager ,and i added to json config file .but it doesn't work .

所以我添加了一个session FileManager,并添加到json配置文件中,但是它不起作用。

Best regards http://www.roxyfileman.com/install

http://www.roxyfileman.com/install问好

1 个解决方案

#1


2  

This is what I did to fix the program which I had the same issue.

这就是我修复程序的方法我也遇到了同样的问题。

in fileman ast_net folder modify main.ashx starting from line 201:

在fileman ast_net文件夹中修改main。ashx从第201行开始:

From:

来自:

protected string GetFilesRoot(){
    string ret = GetSetting("FILES_ROOT");
    if (_context.Session["SESSION_PATH_KEY"] != null)
        ret = (string)_context.Session[GetSetting("SESSION_PATH_KEY")];

    if(ret == "")
        ret = _context.Server.MapPath("../Uploads");
    else
        ret = FixPath(ret);
    return ret;
}

To:

:

protected string GetFilesRoot(){
    string ret = GetSetting("FILES_ROOT");

    if (GetSetting("SESSION_PATH_KEY") != null)
        ret = (string)_context.Session[GetSetting("SESSION_PATH_KEY")];

    if(ret == "")
        ret = _context.Server.MapPath("../Uploads");
    else
        ret = FixPath(ret);
    return ret;
}

in the conf.json i have left the FILES_ROOT variable empty and had set "SESSION_PATH_KEY": "SESSIONFILEPATH"

json中,我将FILES_ROOT变量留空,并设置了“SESSION_PATH_KEY”:“SESSIONFILEPATH”

in my login script where we set the session: Session["SESSIONFILEPATH"] = "~/assests/1/";

在我的登录脚本中,我们设置会话:session ["SESSIONFILEPATH"] = "~/assests/1/";

From here you should be able to dynamically change your folder location which I am doing but for this example i just left it as is.

从这里开始,你应该可以动态地改变你的文件夹位置,就像我正在做的一样,但是在这个例子中,我只是保持原样。

I did not MVC but this should work the same for it.

我没有MVC,但是这个应该也适用。

I hope it helps, if it does please vote =)

我希望它能有所帮助,如果它真的有用请投票=)

Cheers!

干杯!

#1


2  

This is what I did to fix the program which I had the same issue.

这就是我修复程序的方法我也遇到了同样的问题。

in fileman ast_net folder modify main.ashx starting from line 201:

在fileman ast_net文件夹中修改main。ashx从第201行开始:

From:

来自:

protected string GetFilesRoot(){
    string ret = GetSetting("FILES_ROOT");
    if (_context.Session["SESSION_PATH_KEY"] != null)
        ret = (string)_context.Session[GetSetting("SESSION_PATH_KEY")];

    if(ret == "")
        ret = _context.Server.MapPath("../Uploads");
    else
        ret = FixPath(ret);
    return ret;
}

To:

:

protected string GetFilesRoot(){
    string ret = GetSetting("FILES_ROOT");

    if (GetSetting("SESSION_PATH_KEY") != null)
        ret = (string)_context.Session[GetSetting("SESSION_PATH_KEY")];

    if(ret == "")
        ret = _context.Server.MapPath("../Uploads");
    else
        ret = FixPath(ret);
    return ret;
}

in the conf.json i have left the FILES_ROOT variable empty and had set "SESSION_PATH_KEY": "SESSIONFILEPATH"

json中,我将FILES_ROOT变量留空,并设置了“SESSION_PATH_KEY”:“SESSIONFILEPATH”

in my login script where we set the session: Session["SESSIONFILEPATH"] = "~/assests/1/";

在我的登录脚本中,我们设置会话:session ["SESSIONFILEPATH"] = "~/assests/1/";

From here you should be able to dynamically change your folder location which I am doing but for this example i just left it as is.

从这里开始,你应该可以动态地改变你的文件夹位置,就像我正在做的一样,但是在这个例子中,我只是保持原样。

I did not MVC but this should work the same for it.

我没有MVC,但是这个应该也适用。

I hope it helps, if it does please vote =)

我希望它能有所帮助,如果它真的有用请投票=)

Cheers!

干杯!