105 lines
4.0 KiB
C#
105 lines
4.0 KiB
C#
/**
|
|
* Created by visual studio2010
|
|
* User: xuheng
|
|
* Date: 12-3-7
|
|
* Time: 下午16:29
|
|
* To change this template use File | Settings | File Templates.
|
|
*/
|
|
using System;
|
|
using System.Web;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
using System.Web.SessionState;
|
|
namespace Mtxfw.shop
|
|
{
|
|
public class imageManager : IHttpHandler, IRequiresSessionState
|
|
{
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
if (context.Session["MemberIdMemberId"] != null || (context.Session["MemberId"] != null && context.Session["MemberName"] != null))
|
|
{
|
|
context.Response.ContentType = "text/plain";
|
|
|
|
string[] paths = Config.ImageSavePath; //需要遍历的目录列表,最好使用缩略图地址,否则当网速慢时可能会造成严重的延时
|
|
string[] filetype = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" }; //文件允许格式
|
|
|
|
string action = context.Server.HtmlEncode(context.Request["action"]);
|
|
|
|
if (action == "get")
|
|
{
|
|
String str = String.Empty;
|
|
|
|
foreach (string path in paths)
|
|
{
|
|
DirectoryInfo info = new DirectoryInfo(context.Server.MapPath("/" + path));
|
|
|
|
//目录验证
|
|
if (info.Exists)
|
|
{
|
|
foreach (FileInfo fi in info.GetFiles())
|
|
{
|
|
if (Array.IndexOf(filetype, fi.Extension) != -1)
|
|
{
|
|
str += path + fi.Name + "ue_separate_ue";
|
|
}
|
|
}
|
|
DirectoryInfo[] infoArr = info.GetDirectories();
|
|
foreach (DirectoryInfo tmpInfo in infoArr)
|
|
{
|
|
foreach (FileInfo fi in tmpInfo.GetFiles())
|
|
{
|
|
if (Array.IndexOf(filetype, fi.Extension) != -1)
|
|
{
|
|
str += path + tmpInfo.Name + "/" + fi.Name + "ue_separate_ue";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
context.Response.Write(str);
|
|
}
|
|
if (action == "del")
|
|
{
|
|
string[] delpics = context.Server.UrlDecode(context.Request["delpics"]).Split(',');
|
|
foreach (string pic in delpics)
|
|
{
|
|
if (pic != "")
|
|
{
|
|
try
|
|
{
|
|
if (File.Exists(context.Server.MapPath(pic)))
|
|
{
|
|
File.Delete(context.Server.MapPath(pic));
|
|
}
|
|
else
|
|
{
|
|
Mtxfw.Utility.Config config = new Mtxfw.Utility.Config();
|
|
if (File.Exists(context.Server.MapPath(config.webUpPath + pic)))
|
|
{
|
|
File.Delete(context.Server.MapPath(config.webUpPath + pic));
|
|
}
|
|
}
|
|
}
|
|
catch (Exception err)
|
|
{
|
|
Mtxfw.Utility.Common.WriteHtml("/weixin/weixin.txt", err.ToString());
|
|
}
|
|
}
|
|
}
|
|
context.Response.Write("true");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|
|
} |