238 lines
12 KiB
C#
238 lines
12 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
using System.Text;
|
||
using System.Data;
|
||
using System.Security.Cryptography;
|
||
using TencentCloud.Common;
|
||
using TencentCloud.Common.Profile;
|
||
using TencentCloud.Vod.V20180717;
|
||
using TencentCloud.Vod.V20180717.Models;
|
||
namespace Mtxfw.VipSite
|
||
{
|
||
public partial class Admin_Member_livefile : Mtxfw.Utility.MemberBase
|
||
{
|
||
Mtxfw.DAL.user_info daoUser = new Mtxfw.DAL.user_info();
|
||
Mtxfw.DAL.user_Results daoResults = new Mtxfw.DAL.user_Results();
|
||
Mtxfw.DAL.user_Results_jl2 daojl2 = new Mtxfw.DAL.user_Results_jl2();
|
||
public Mtxfw.Utility.Config cconfig = new Mtxfw.Utility.Config("");
|
||
public Mtxfw.DAL.user_livefile daolivefile = new Mtxfw.DAL.user_livefile();
|
||
public string strTitle = "", Signature = "";
|
||
public int ttype = 0;
|
||
public int gtype = 0;
|
||
protected override void OnLoad(EventArgs e)
|
||
{
|
||
base.OnLoad(e);
|
||
string hostname = Request.Url.Host;
|
||
|
||
string secretId = cconfig.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 + "¤tTimeStamp=" + currentTimeStamp + "&expireTime=" + expireTime + "&random=" + random + "&classId=" + classId + "&storageRegion=ap-beijing";
|
||
|
||
byte[] bytesSign = hash_hmac_byte(strkey, cconfig.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_livefile.aspx");
|
||
}
|
||
if (IFStores != 1)
|
||
{
|
||
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
|
||
}
|
||
if (MemberJS.IndexOf("视频管理") == -1)
|
||
{
|
||
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
|
||
}
|
||
Page.Title = "云视频管理 - " + GetWebName;
|
||
|
||
Data_Bind();
|
||
seclect_Drop.Items.Add(new ListItem("删除", "2"));
|
||
}
|
||
MyPager.PageChanged += delegate (object s, EventArgs ex)
|
||
{
|
||
Data_Bind();
|
||
};
|
||
|
||
}
|
||
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()
|
||
{
|
||
|
||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||
|
||
String MemberId = Request.QueryString["MemberId"];
|
||
String key = Request.QueryString["key"];
|
||
String SJ = Request.QueryString["SJ"];
|
||
String SJ2 = Request.QueryString["SJ2"];
|
||
sb.Append("gtype=" + gtype + " and ");
|
||
if (!String.IsNullOrEmpty(Request.QueryString["ttype"]))
|
||
{
|
||
ttype = Convert.ToInt32(Request.QueryString["ttype"].ToString());
|
||
sb.Append("ttype=" + ttype);
|
||
Drop_ttype.SelectedValue = ttype.ToString();
|
||
}
|
||
else
|
||
{
|
||
sb.Append("ttype<3");
|
||
Drop_ttype.SelectedValue = "";
|
||
}
|
||
if (!String.IsNullOrEmpty(SJ) && !String.IsNullOrEmpty(SJ2))
|
||
{
|
||
sb.Append("and (addtime between '" + SJ + " 00:00:00' and '" + SJ2 + " 23:59:59') ");
|
||
}
|
||
if (!String.IsNullOrEmpty(MemberId))
|
||
{
|
||
sb.Append(" and MemberId=" + MemberId);
|
||
}
|
||
if (!String.IsNullOrEmpty(key))
|
||
{
|
||
key = key.Trim();
|
||
sb.Append(" and MemberId=(Select id from user_info b where b.UserName='" + key + "')");
|
||
}
|
||
string groupby = "";
|
||
string strOrder = "addtime desc";
|
||
|
||
int Start = 0;
|
||
int Limit = 0;
|
||
Int32 Recount = 0;
|
||
MyPager.PageSize = 100;
|
||
Start = MyPager.PageSize * (MyPager.CurrentPageIndex - 1);
|
||
Limit = MyPager.PageSize;
|
||
DataSet dss = daolivefile.GetDataSet(groupby, strOrder, "*,(Select UserName From user_info b Where b.Id=MemberId) as MemberName,(Select realname From user_info b Where b.Id=MemberId) as realname", "", sb.ToString(), Start, Limit, out Recount);
|
||
Mtxfw.Utility.Tools.ToBind(Repeater1, dss.Tables[1]);
|
||
MyPager.RecordCount = Recount;
|
||
if (MyPager.RecordCount == 0)
|
||
{
|
||
MyPager.Visible = false;
|
||
}
|
||
|
||
}
|
||
protected void Run_Click(object s, System.EventArgs e)
|
||
{
|
||
CheckBox Check = new CheckBox();
|
||
string strs = seclect_Drop.SelectedItem.Value;
|
||
foreach (RepeaterItem Item in Repeater1.Items)
|
||
{
|
||
//在行中查找到该单选框
|
||
Check = (CheckBox)Item.FindControl("checka");
|
||
Int32 strID = Int32.Parse(Check.CssClass);
|
||
if (Check.Checked == true)
|
||
{
|
||
Mtxfw.Model.user_livefile mr = daolivefile.GetModel(strID);
|
||
if (mr != null)
|
||
{
|
||
if (strs == "2")
|
||
{
|
||
// 必要步骤:
|
||
// 实例化一个认证对象,入参需要传入腾讯云账户密钥对 SecretId,SecretKey。
|
||
// 本示例采用从环境变量读取的方式,则需要在环境变量中先设置这两个值。
|
||
// 您也可以直接将密钥对写入代码中,但是注意不要复制、上传或分享代码,以免泄露密钥对危及您的财产安全。
|
||
Credential cred = new Credential
|
||
{
|
||
SecretId = cconfig.AccessKeyId,
|
||
SecretKey = cconfig.AccessKeySecret
|
||
};
|
||
|
||
// 实例化一个 client 选项,可选的,没有特殊需求可以跳过
|
||
ClientProfile clientProfile = new ClientProfile();
|
||
// 指定签名算法(默认为 HmacSHA256)
|
||
clientProfile.SignMethod = ClientProfile.SIGN_SHA1;
|
||
// 非必要步骤
|
||
// 实例化一个客户端配置对象,可以指定超时时间等配置
|
||
HttpProfile httpProfile = new HttpProfile();
|
||
// SDK 默认使用 POST 方法。
|
||
// 如果您一定要使用 GET 方法,可以在这里设置。GET 方法无法处理一些较大的请求。
|
||
httpProfile.ReqMethod = "POST";
|
||
// SDK 有默认的超时时间,非必要请不要进行调整。
|
||
// 如有需要请在代码中查阅以获取最新的默认值。
|
||
httpProfile.Timeout = 30; // 请求连接超时时间,单位为秒,默认值为60
|
||
// SDK 会自动指定域名。通常无需指定域名,但如果您访问的是金融区的服务,则必须手动指定域名。
|
||
// 例如云服务器的上海金融区域名:cvm.ap-shanghai-fsi.tencentcloudapi.com
|
||
|
||
// 代理服务器,当您的环境下有代理服务器时设定
|
||
httpProfile.WebProxy = Environment.GetEnvironmentVariable("HTTPS_PROXY");
|
||
|
||
clientProfile.HttpProfile = httpProfile;
|
||
|
||
// 实例化要请求产品(以 CVM 为例)的 client 对象
|
||
// 第二个参数是地域信息,可以直接填写字符串 ap-guangzhou,或者引用预设的常量,clientProfile 是可选的
|
||
VodClient client = new VodClient(cred, "ap-beijing", clientProfile);
|
||
DeleteMediaRequest req = new DeleteMediaRequest();
|
||
req.FileId = mr.file_id;
|
||
DeleteMediaResponse res = client.DeleteMediaSync(req);
|
||
// 输出 JSON 格式的字符串回包
|
||
Mtxfw.Utility.Common.WriteHtml("/weixin/TencentCloudDelete.txt", AbstractModel.ToJsonString(res) + "|" + res.RequestId);
|
||
|
||
daolivefile.Delete(strID);
|
||
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 = "删除云视频,file_id为" + mr.file_id;
|
||
logmodel.UType = 0;
|
||
logmodel.gtype = gtype;
|
||
new DAL.User_CZ_log().Add(logmodel);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
Response.Redirect(Request.Url.AbsoluteUri);
|
||
}
|
||
public string getpics(string pics)
|
||
{
|
||
string returnpics = "";
|
||
string[] apic = pics.Split('|');
|
||
foreach (string pic in apic)
|
||
{
|
||
if (pic != "")
|
||
{
|
||
string strpic = Mtxfw.Utility.Common.GetCoverPic(pic.Split('|')[0], "100x100", "cut");
|
||
returnpics += "<img src=\"" + strpic + "\" />";
|
||
}
|
||
}
|
||
return returnpics;
|
||
}
|
||
public string cvideo(string video)
|
||
{
|
||
if (video.IndexOf("http://1301659355.vod2.myqcloud.com") != -1)
|
||
{
|
||
string key = "fHI4e1IgVr69Gx4sf1dC";
|
||
string strp = video.Replace("http://1301659355.vod2.myqcloud.com", "");
|
||
string Dir = strp.Substring(0, strp.LastIndexOf("/")) + "/";
|
||
string t = Mtxfw.Utility.Common.GetTimeStamp16(DateTime.Now.AddHours(24), false).ToLower();
|
||
string exper = "0";
|
||
string rlimit = "";
|
||
string us = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||
StringBuilder sb = new StringBuilder(32);
|
||
MD5 md5 = new MD5CryptoServiceProvider();
|
||
string strkey = key + Dir + t + exper + rlimit + us;
|
||
byte[] st = md5.ComputeHash(Encoding.GetEncoding("utf-8").GetBytes(strkey));
|
||
for (int i = 0; i < st.Length; i++)
|
||
{
|
||
sb.Append(st[i].ToString("x").PadLeft(2, '0'));
|
||
}
|
||
string sign = sb.ToString();
|
||
video += "?t=" + t + "&exper=" + exper + "&rlimit=" + rlimit + "&us=" + us + "&sign=" + sign;
|
||
}
|
||
return video;
|
||
}
|
||
}
|
||
} |