Skip to content

Commit

Permalink
Access数据库管理页面禁止下载非.resx扩展名文件
Browse files Browse the repository at this point in the history
  • Loading branch information
mayswind committed Jun 10, 2015
1 parent a148190 commit cf301f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions website/SDNUOJ.Configuration/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.56")]
[assembly: AssemblyFileVersion("1.2.0.56")]
[assembly: AssemblyVersion("1.2.0.57")]
[assembly: AssemblyFileVersion("1.2.0.57")]
5 changes: 5 additions & 0 deletions website/SDNUOJ.Controllers/Core/DatabaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ public static IMethodResult AdminGetDataBaseDownloadPath(Int32 did)
return MethodResult.FailedAndLog("Database does not exist!");
}

if (!String.Equals(fi.Extension, ".resx", StringComparison.OrdinalIgnoreCase))
{
return MethodResult.FailedAndLog("Your can not download this file!");
}

return MethodResult.SuccessAndLog<String>(filePath, "Admin download database, name = {0}", fi.Name);
}

Expand Down
2 changes: 1 addition & 1 deletion website/SDNUOJ/Areas/Admin/Views/Database/List.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<td class="text-center">@((Item.Length / 1024.0).ToString("0.00")) KB</td>
<td class="text-center">@Html.ActionLink("压缩", "Compact", "Database", new { id = i }, null)</td>
<td class="text-center">@(!String.Equals(Item.Name, ViewBag.DefaultFileName as String) ? Html.ActionLink("还原", "Restore", "Database", new { id = i }, null) : Html.Raw("还原"))</td>
<td class="text-center">@(!String.Equals(Item.Name, ViewBag.DefaultFileName as String) ? Html.ActionLink("下载", "Download", "Database", new { id = i }, null) : Html.Raw("下载"))</td>
<td class="text-center">@((!String.Equals(Item.Name, ViewBag.DefaultFileName as String) && String.Equals(Item.Extension, ".resx", StringComparison.OrdinalIgnoreCase)) ? Html.ActionLink("下载", "Download", "Database", new { id = i }, null) : Html.Raw("下载"))</td>
<td class="text-center">@(!String.Equals(Item.Name, ViewBag.DefaultFileName as String) ? Html.ActionLink("删除", "Delete", "Database", new { id = i }, new { @data_advancelink = "true", @data_confirm = "true", @data_async = "true" }) : Html.Raw("删除"))</td>
</tr>
}
Expand Down

0 comments on commit cf301f3

Please sign in to comment.