using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text.RegularExpressions; using System.Globalization; using System.Security.Cryptography; using System.Text; namespace Mtxfw.VipSite { public partial class Admin_Member_xsxt_add : Mtxfw.Utility.MemberBase { public Mtxfw.Utility.Config config0 = new Mtxfw.Utility.Config(""); public Mtxfw.DAL.Article daoArt = new Mtxfw.DAL.Article(); protected Mtxfw.DAL.user_Goods_lb daolb = new Mtxfw.DAL.user_Goods_lb(); public String strTitle = "",strBody = "", Signature = ""; public int gtype = 0; protected override void OnLoad(EventArgs e) { base.OnLoad(e); string hostname = Request.Url.Host; if (!IsPostBack) { if (Session["IFPassword"] == null) { Response.Redirect("/Member_IFPassword.aspx?Url=/Admin_Member_xsxt.aspx"); } if (IFStores != 1) { Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx"); } if (MemberJS.IndexOf("新手学堂") == -1) { Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx"); } DropType.DataSource = daolb.GetList("utype=2"); DropType.DataBind(); 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 = 24; model.CategoryId = DropType.SelectedItem.Value; model.AddTime = DateTime.Now; model.Author = hiddenphoto.Value; model.Content = Hidd_myEditor.Value; model.Paths = ""; model.Content2 = Text_content2.Text; model.Paths2 = ""; model.KeyWords = ""; model.media_id = ""; model.thumb_media_id = ""; model.wtype = Convert.ToInt32(Text_Num.Text); model.wtype2 = Convert.ToInt32(Text_Num2.Text); string strzd = daoArt.Getzd("max(LinkID)", "ParentID=" + model.ParentID).ToString(); if (strzd != "") { model.LinkID = (Convert.ToInt32(strzd)+1); } else { model.LinkID = 0; } model.Seef = 0; model.gtype = gtype; string strContent =model.Content; Regex R = new Regex(""); Match M = R.Match(strContent); if (M.Success) { string strResult0 = M.Groups[1].ToString(); if (strResult0.IndexOf("https://fv.pmhapp.cn/mdavideo/") != -1) { // 文件名 string Key = strResult0.Replace("https://fv.pmhapp.cn/", ""); Qiniu.Storage.Config config = new Qiniu.Storage.Config(); config.Zone = Qiniu.Storage.Zone.ZONE_CN_South; bool force = false; // 队列名称,如果没有,请设置为null // 另请参阅https://qiniu.kf5.com/hc/kb/article/112978/ string pipeline = "default.sys"; // 接收处理结果通知的URL,另请参阅 string notifyUrl = ""; // 要保存的目标空间 string dstBucket = config0.qiniuScope; string dstKey = Key.Replace("mdavideo/", "mdadvideo/"); string saveAsUri = Qiniu.Util.Base64.UrlSafeBase64Encode(dstBucket + ":" + dstKey); // 需要执行的数据处理,例如视频转码 string fopM = "avthumb/mp4"; //示例: "avthumb/mp4"; // 使用管道'|'命令,将处理结果saveas另存 string fops = fopM + "|saveas/" + saveAsUri; // 这个示例单独使用了一个Settings类,其中包含AccessKey和SecretKey // 实际应用中,请自行设置您的AccessKey和SecretKey Qiniu.Util.Mac mac = new Qiniu.Util.Mac(config0.qiniuAccessKey, config0.qiniuSecretKey); Qiniu.Storage.OperationManager ox = new Qiniu.Storage.OperationManager(mac, config); Qiniu.Storage.PfopResult result = ox.Pfop(dstBucket, Key, fops, pipeline, notifyUrl, force); if (result.Code == 200) { model.thumb_media_id = result.PersistentId; model.Content = model.Content.Replace("", ""); } } } 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); if (Session["UploadFileIng"] != null) { string[] stra = Session["UploadFileIng"].ToString().Split(','); foreach (string str in stra) { if (str.Trim() != "") { if (model.Content.IndexOf(str.Trim()) == -1) { if (System.IO.File.Exists(Server.MapPath(str.Trim()))) { System.IO.File.Delete(Server.MapPath(str.Trim())); } } } } Session.Remove("UploadFileIng"); } if (Session["UploadFileIng0"] != null) { string[] stra = Session["UploadFileIng0"].ToString().Split(','); foreach (string str in stra) { if (str.Trim() != "") { if (model.Author != str.Trim()) { if (System.IO.File.Exists(Server.MapPath(str.Trim()))) { System.IO.File.Delete(Server.MapPath(str.Trim())); } } } } Session.Remove("UploadFileIng0"); } System.Collections.IDictionaryEnumerator CacheEnum = Cache.GetEnumerator(); while (CacheEnum.MoveNext()) { Cache.Remove(CacheEnum.Key.ToString()); } 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.CategoryId = DropType.SelectedItem.Value; model.Title = Text_Title.Text; model.Author = hiddenphoto.Value; model.Content = Hidd_myEditor.Value; model.wtype = Convert.ToInt32(Text_Num.Text); model.wtype2 = Convert.ToInt32(Text_Num2.Text); string strContent =model.Content; Regex R = new Regex(""); Match M = R.Match(strContent); if (M.Success) { string strResult0 = M.Groups[1].ToString(); if (strResult0.IndexOf("https://fv.pmhapp.cn/mdavideo/") != -1) { // 文件名 string Key = strResult0.Replace("https://fv.pmhapp.cn/", ""); Qiniu.Storage.Config config = new Qiniu.Storage.Config(); config.Zone = Qiniu.Storage.Zone.ZONE_CN_South; bool force = false; // 队列名称,如果没有,请设置为null // 另请参阅https://qiniu.kf5.com/hc/kb/article/112978/ string pipeline = "default.sys"; // 接收处理结果通知的URL,另请参阅 string notifyUrl = ""; // 要保存的目标空间 string dstBucket = config0.qiniuScope; string dstKey = Key.Replace("mdavideo/", "mdadvideo/"); string saveAsUri = Qiniu.Util.Base64.UrlSafeBase64Encode(dstBucket + ":" + dstKey); // 需要执行的数据处理,例如视频转码 string fopM = "avthumb/mp4"; //示例: "avthumb/mp4"; // 使用管道'|'命令,将处理结果saveas另存 string fops = fopM + "|saveas/" + saveAsUri; // 这个示例单独使用了一个Settings类,其中包含AccessKey和SecretKey // 实际应用中,请自行设置您的AccessKey和SecretKey Qiniu.Util.Mac mac = new Qiniu.Util.Mac(config0.qiniuAccessKey, config0.qiniuSecretKey); Qiniu.Storage.OperationManager ox = new Qiniu.Storage.OperationManager(mac, config); Qiniu.Storage.PfopResult result = ox.Pfop(dstBucket, Key, fops, pipeline, notifyUrl, force); if (result.Code == 200) { model.thumb_media_id = result.PersistentId; model.Content = model.Content.Replace("", ""); } } } 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); if (Session["UploadFileIng"] != null) { string[] stra = Session["UploadFileIng"].ToString().Split(','); foreach (string str in stra) { if (str.Trim() != "") { if (model.Content.IndexOf(str.Trim()) == -1) { if (System.IO.File.Exists(Server.MapPath(str.Trim()))) { System.IO.File.Delete(Server.MapPath(str.Trim())); } } } } Session.Remove("UploadFileIng"); } if (Session["UploadFileIng0"] != null) { string[] stra = Session["UploadFileIng0"].ToString().Split(','); foreach (string str in stra) { if (str.Trim() != "") { if (model.Author!=str.Trim()) { if (System.IO.File.Exists(Server.MapPath(str.Trim()))) { System.IO.File.Delete(Server.MapPath(str.Trim())); } } } } Session.Remove("UploadFileIng0"); } System.Collections.IDictionaryEnumerator CacheEnum = Cache.GetEnumerator(); while (CacheEnum.MoveNext()) { Cache.Remove(CacheEnum.Key.ToString()); } ClientScript.RegisterStartupScript(this.GetType(), "", ""); }; } 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); } protected void Data_Bind() { if (Request.UrlReferrer != null) { Hidd_Url.Value = Request.UrlReferrer.ToString(); } else { Hidd_Url.Value = "Admin_Member_gong2.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; Text_Num.Text = model.wtype.ToString(); Text_Num2.Text = model.wtype2.ToString(); strBody = model.Content; for (int i = 0; i < DropType.Items.Count; i++) { if (DropType.Items[i].Value == model.CategoryId) { DropType.Items[i].Selected = true; } else { DropType.Items[i].Selected = false; } } hiddenphoto.Value = model.Author; } } } } }