using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text; using System.Security.Cryptography; namespace Mtxfw.VipSite { public partial class Admin_Member_JCHG_add : Mtxfw.Utility.MemberBase { public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config(""); public Mtxfw.DAL.Article daoArt = new Mtxfw.DAL.Article(); public String strTitle = "",strBody = ""; public int gtype = 0; public string Signature = ""; protected override void OnLoad(EventArgs e) { base.OnLoad(e); string hostname = Request.Url.Host; string secretId = config.AccessKeyId; long currentTimeStamp = Mtxfw.Utility.Common.CreatenTimestamp(DateTime.Now); long expireTime = Mtxfw.Utility.Common.CreatenTimestamp(DateTime.Now.AddHours(24)); string random = Mtxfw.Utility.Common.RandNum(6); long classId = 792211; string strkey = "secretId=" + secretId + "¤tTimeStamp=" + currentTimeStamp + "&expireTime=" + expireTime + "&random=" + random + "&classId=" + classId + "&storageRegion=ap-beijing"; byte[] bytesSign = hash_hmac_byte(strkey, config.AccessKeySecret); byte[] byteContent = System.Text.Encoding.Default.GetBytes(strkey); byte[] nCon = new byte[bytesSign.Length + byteContent.Length]; bytesSign.CopyTo(nCon, 0); byteContent.CopyTo(nCon, bytesSign.Length); Signature = Convert.ToBase64String(nCon); if (!IsPostBack) { if (Session["IFPassword"] == null) { Response.Redirect("/Member_IFPassword.aspx?Url=/Admin_Member_JCHG.aspx"); } if (IFStores != 1) { Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx"); } if (MemberJS.IndexOf("洞藏精彩回顾") == -1) { Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx"); } Data_Bind(); } Btn_Insert.Click += delegate(object s, EventArgs ex) { Mtxfw.Model.Article model = new Mtxfw.Model.Article(); model.senderid = 0; model.receiverid = 0; model.Title = Text_Title.Text; model.ParentID = 9; model.CategoryId = "0"; model.AddTime = DateTime.Now; Mtxfw.Utility.UploadFile upload = new Utility.UploadFile(File_AdsImg.PostedFile, config.webUpPath, config.webUpType, int.Parse(config.webUpSize)); if (File_AdsImg.FileName.Length > 0) { upload.StatrUpFile(); model.Author = upload.UploadPath; } else model.Author = Hidd_Img.Value; model.Content = Hidd_myEditor.Value; model.Paths = ""; model.Content2 = ""; model.Paths2 = ""; model.KeyWords = ""; model.media_id = ""; model.thumb_media_id = ""; model.wtype = 0; model.wtype2 = 0; model.LinkID = 0; model.Seef = 0; model.gtype = gtype; daoArt.Add(model); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = Card; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "添加洞藏精彩回顾,标题:" + model.Title + ""; logmodel.UType = 0; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); ClientScript.RegisterStartupScript(this.GetType(), "", ""); }; Btn_Update.Click += delegate(object s, EventArgs ex) { Int32 ID = int.Parse(Request.QueryString["ID"]); Mtxfw.Model.Article model = daoArt.GetModel(ID); model.Title = Text_Title.Text; Mtxfw.Utility.UploadFile upload = new Utility.UploadFile(File_AdsImg.PostedFile, config.webUpPath, config.webUpType, int.Parse(config.webUpSize)); if (File_AdsImg.FileName.Length > 0) { upload.StatrUpFile(); model.Author = upload.UploadPath; } else model.Author = Hidd_Img.Value; model.Content = Hidd_myEditor.Value; daoArt.Update(model); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = Card; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "修改洞藏精彩回顾,标题:" + model.Title + ""; logmodel.UType = 0; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); ClientScript.RegisterStartupScript(this.GetType(), "", ""); }; } protected void Data_Bind() { if (Request.UrlReferrer != null) { Hidd_Url.Value = Request.UrlReferrer.ToString(); } else { Hidd_Url.Value = "Admin_Member_JCHG.aspx"; } if (Request.QueryString["ID"] == null) { strTitle = "添加洞藏精彩回顾"; Page.Title = strTitle + " - " + GetWebName; Btn_Update.Visible = false; } else { strTitle = "更新洞藏精彩回顾"; Page.Title = strTitle + " - " + GetWebName; Btn_Insert.Visible = false; Mtxfw.Model.Article model = daoArt.GetModel(int.Parse(Request.QueryString["ID"])); if (model != null) { Text_Title.Text = model.Title; strBody = model.Content; if (!String.IsNullOrEmpty(model.Author)) { Img_Img.Visible = true; Img_Img.Src = Mtxfw.Utility.Common.GetCoverPic(model.Author, "40x40", config.webImgMode); Hidd_Img.Value = model.Author; } else { Img_Img.Visible = false; Hidd_Img.Value = String.Empty; } } } } private byte[] hash_hmac_byte(string signatureString, string secretKey) { var enc = Encoding.UTF8; HMACSHA1 hmac = new HMACSHA1(enc.GetBytes(secretKey)); hmac.Initialize(); byte[] buffer = enc.GetBytes(signatureString); return hmac.ComputeHash(buffer); } } }