Files
g.hnyhua.cn/Mtxfw.VipSite/Admin_Member_gong_add1.aspx.cs
2026-02-07 15:48:27 +08:00

353 lines
17 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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_gong_add1 : 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;
string secretId = config0.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 = 659337;
string strkey = "secretId=" + secretId + "&currentTimeStamp=" + currentTimeStamp + "&expireTime=" + expireTime + "&random=" + random + "&classId=" + classId + "&storageRegion=ap-beijing";
byte[] bytesSign = hash_hmac_byte(strkey, config0.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_gong2.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=0 and gtype="+gtype);
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 = 19;
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 = 0;
string strContent =model.Content;
Regex R = new Regex("<source src=\"([\\S\\s\\t\\n]*?)\" type=\"video/mp4\"/>");
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 = config0.webUrl + "/pay/qiniunotifyUrl.aspx";
// 要保存的目标空间
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("<source src=\"" + strResult0 + "\" type=\"video/mp4\"/>", "<source src=\"" + strResult0.Replace("mdavideo/", "mdadvideo/") + "\" type=\"video/mp4\"/>");
}
}
}
int aid = daoArt.Add(model);
daoArt.UpdateuSel("ltype", Convert.ToInt32(Drop_ShowType.SelectedItem.Value), aid);
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(), "", "<script type='text/javascript'>alert('添加教程成功!');location.replace('" + Hidd_Url.Value + "')</script>");
};
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("<source src=\"([\\S\\s\\t\\n]*?)\" type=\"video/mp4\"/>");
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("<source src=\"" + strResult0 + "\" type=\"video/mp4\"/>", "<source src=\"" + strResult0.Replace("mdavideo/", "mdadvideo/") + "\" type=\"video/mp4\"/>");
}
}
}
daoArt.Update(model);
daoArt.UpdateuSel("ltype", Convert.ToInt32(Drop_ShowType.SelectedItem.Value), model.id);
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(), "", "<script type='text/javascript'>alert('更新教程成功!');location.replace('" + Hidd_Url.Value + "')</script>");
};
}
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;
}
}
for (int i = 0; i < Drop_ShowType.Items.Count; i++)
{
if (Drop_ShowType.Items[i].Value == model.ltype.ToString())
{
Drop_ShowType.Items[i].Selected = true;
}
else
{
Drop_ShowType.Items[i].Selected = false;
}
}
hiddenphoto.Value = model.Author;
}
}
}
}
}