新分配方案改了一部分

This commit is contained in:
lym
2026-03-20 02:20:12 +08:00
parent d049fc2c76
commit 1b8c475381
8 changed files with 215 additions and 54 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Web;
using System.IO;
@@ -92,23 +92,32 @@ namespace Mtxfw.VipSite
/// <returns></returns>
protected string CheckRequestSizeIsExists(string itsize, string filepath)
{
string _path = Path.Combine(config.webUpPath, itsize);
if (filepath.IndexOf("/Files/grimage/") == -1)
try
{
_path = Path.Combine(_path, filepath);
string _path = Path.Combine(config.webUpPath, itsize);
if (filepath.IndexOf("/Files/grimage/") == -1)
{
_path = Path.Combine(_path, filepath);
}
else
{
_path = _path.Replace("\\", "/") + filepath;
}
//_path = _path.Replace("\\", "/");
if (File.Exists(HttpContext.Current.Server.MapPath(_path)))
{
return _path;
}
else
{
return "";
}
}
else
catch (Exception ex)
{
_path = _path.Replace("\\", "/") + filepath;
}
if (File.Exists(HttpContext.Current.Server.MapPath(_path)))
{
return _path;
}
else
{
return "";
}
return "";
}
/// <summary>
@@ -135,6 +144,20 @@ namespace Mtxfw.VipSite
string itsize = Query.Get("itsize", "");
if (Mtxfw.Utility.Common.Is_ThumbNail_AllowSizes(itsize)) //是否为允许的尺寸
{
//https://fv.pmhapp.cn/ksd2023/20260309225240.png
//如果包含https则只取域名之后的部分
//if (ate_FilePath.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
// ate_FilePath.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
//{
// Uri uri = new Uri(ate_FilePath);
// ate_FilePath = uri.AbsolutePath;
// // 移除开头的斜杠(如果有)
// if (ate_FilePath.StartsWith("/"))
// {
// ate_FilePath = ate_FilePath.Substring(1);
// }
//}
//获取已存在的缩略图
string existfilepath = CheckRequestSizeIsExists(itsize, ate_FilePath);
//没有该尺寸已生成好的图,创建缩略图
@@ -151,8 +174,8 @@ namespace Mtxfw.VipSite
{
saveFilePath = saveFilePath.Replace("\\", "/") + ate_FilePath;
}
string savepath = Path.GetDirectoryName(saveFilePath);
saveFilePath = saveFilePath.Replace("\\", "/")
; string savepath = Path.GetDirectoryName(saveFilePath);
if (!Directory.Exists(HttpContext.Current.Server.MapPath(savepath)))
{
Directory.CreateDirectory(HttpContext.Current.Server.MapPath(savepath));