123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace iNethinkCMS.Web.UserCenter
- {
- public partial class DownloadFile : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- string SysLoginUserName = iNethinkCMS.Command.Command_Session.Get("admin_username");
- if (String.IsNullOrEmpty(SysLoginUserName))
- {
- Response.Write("<font color='#ff0000'>对不起,需要登录后才能下载。</font>");
- }
- else
- {
- int id = 0;
- if (Request.QueryString["id"] != null && Request.QueryString["id"].ToString().Length > 1)
- {
- try
- {
- id = Convert.ToInt32(Request.QueryString["id"].ToString());
- }
- catch { }
- }
- if (Request.QueryString["File"] != null && Request.QueryString["File"].ToString().Length > 1)
- {
- string downloadFileName = Request.QueryString["File"].ToString();
- if (downloadFileName.ToLower().StartsWith("http://") || downloadFileName.ToLower().StartsWith("https://"))
- {
- if (id > 0)
- {
- Response.Write("<iframe style=\"display:none;\" src=\"/plugs/count/count.aspx?id=" + id.ToString() + "\"></iframe>");
- }
- iNethinkCMS.Command.MessageBox.ResponseScript(this, "location.href='" + downloadFileName+ "'");
- // Response.Write("<script type=\"text/javascript\"></script>");
- }
- else
- {
- try
- {
- string iframeSrc = "/upload/day_" + downloadFileName;
- string downloadFilePath = Server.MapPath(iframeSrc);
- if (!System.IO.File.Exists(downloadFilePath))
- {
- iframeSrc = "/upload/" + downloadFileName;
- downloadFilePath = Server.MapPath(iframeSrc);
- if (!System.IO.File.Exists(downloadFilePath))
- {
- iframeSrc = "/" + downloadFileName;
- downloadFilePath = Server.MapPath(iframeSrc);
- }
- }
- if (System.IO.File.Exists(downloadFilePath))
- {
- Response.Write("<iframe style=\"display:none;\" src=\"" + iframeSrc + "\"></iframe>");
- if (id > 0)
- {
- Response.Write("<iframe style=\"display:none;\" src=\"/plugs/count/count.aspx?id=" + id.ToString() + "\"></iframe>");
- }
- }
- else
- {
- Response.Write("<font color='#ff0000'>请求下载的文件不存在或已被删除...</font>");
- }
- }
- catch(Exception ex) {
- Response.Write("<font color='#ff0000'>请求下载的文件路径不正确,"+ex.Message+"</font>");
- }
- }
- }
- else
- {
- Response.Write("<font color='#ff0000'>请求下载参数不正确。</font>");
- }
- }
- }
- else {
- Response.Write("<font color='#ff0000'>请求已过期,请重新请求...</font>");
- }
- }
- }
- }
|