/// <summary> /// 增加一条数据 /// 上存照片活跃抽奖入口---姚志光 /// </summary> public int Add(BCW.Model.Upfile model) { //return dal.Add(model); int ID = dal.Add(model); try { string xmlPath = "/Controls/winners.xml"; string TextForUbb = (ub.GetSub("TextForUbb", xmlPath)); //设置内线提示的文字 string WinnersStatus = (ub.GetSub("WinnersStatus", xmlPath)); //状态1维护2测试0正常 string WinnersOpenOrClose = (ub.GetSub("WinnersOpenOrClose", xmlPath)); //0|停止放送机会|1|开启放送机会 string WinnersOpenChoose = (ub.GetSub("WinnersOpenChoose", xmlPath)); //1全社区2社区3仅游戏 string WinnersGuessOpen = (ub.GetSub("WinnersGuessOpen", xmlPath)); //1发内线2不发内线 int usid = model.UsID; string username = new BCW.BLL.User().GetUsName(usid); string Notes = "上传照片"; int id = new BCW.BLL.Action().GetMaxId(); int isHit = new BCW.winners.winners().CheckActionForAll(0, 0, usid, username, Notes, id); if (isHit == 1) { if (WinnersGuessOpen == "1") { new BCW.BLL.Guest().Add(0, usid, username, TextForUbb);//发内线到该ID } } return(ID); } catch { return(ID); } }
private void EditSavePage() { int id = int.Parse(Utils.GetRequest("id", "post", 2, @"^[1-9]\d*$", "相册ID错误")); string Files = Utils.GetRequest("Files", "post", 2, @"^[^\^]{1,100}$", "缩略图地址限100字内,可留空"); string PrevFiles = Utils.GetRequest("PrevFiles", "post", 3, @"^[^\^]{1,100}$", "文件地址限100字内"); string Content = Utils.GetRequest("Content", "post", 3, @"^[^\^]{1,30}$", "请输入不超30字的描述"); int UsID = int.Parse(Utils.GetRequest("UsID", "post", 2, @"^[1-9]\d*$", "用户ID错误")); int IsVerify = int.Parse(Utils.GetRequest("IsVerify", "post", 2, @"^[0-1]$", "审核状态选择错误")); DateTime AddTime = Utils.ParseTime(Utils.GetRequest("AddTime", "post", 2, DT.RegexTime, "添加时间填写出错")); BCW.Model.Upfile model = new BCW.Model.Upfile(); model.ID = id; model.Files = Files; model.PrevFiles = PrevFiles; model.Content = Content; model.UsID = UsID; model.IsVerify = IsVerify; model.AddTime = AddTime; new BCW.BLL.Upfile().Update(model); Utils.Success("编辑文件", "编辑文件成功..", Utils.getUrl("albums.aspx?act=edit&id=" + id + "&backurl=" + Utils.getPage(0) + ""), "1"); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(BCW.Model.Upfile model) { dal.Update(model); }
/// <summary> /// 上传文件 /// </summary> private void SaveFiles(int meid, int leibie, int NodeId, out int kk) { //允许上传数量 int maxAddNum = Convert.ToInt32(ub.GetSub("UpAddNum", xmlPath)); int AddNum = 0; if (maxAddNum > 0) { //计算今天上传数量 AddNum = new BCW.BLL.Upfile().GetTodayCount(meid); } //遍历File表单元素 System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files; // int j = 1; int j = files.Count; int k = 0; try { string GetFiles = string.Empty; //for (int iFile = 0; iFile < files.Count; iFile++) for (int iFile = files.Count - 1; iFile > -1; iFile--) { //检查文件扩展名字 System.Web.HttpPostedFile postedFile = files[iFile]; string fileName, fileExtension; fileName = System.IO.Path.GetFileName(postedFile.FileName); string UpExt = ub.GetSub("UpaFileExt", xmlPath); int UpLength = Convert.ToInt32(ub.GetSub("UpaMaxFileSize", xmlPath)); if (fileName != "") { fileExtension = System.IO.Path.GetExtension(fileName).ToLower(); //检查是否允许上传格式 if (UpExt.IndexOf(fileExtension) == -1) { continue; } //非法上传 if (fileExtension == ".asp" || fileExtension == ".aspx" || fileExtension == ".jsp" || fileExtension == ".php" || fileExtension == ".asa" || fileExtension == ".cer" || fileExtension == ".cdx" || fileExtension == ".htr" || fileExtension == ".exe") { continue; } if (postedFile.ContentLength > Convert.ToInt32(UpLength * 1024)) { continue; } string DirPath = string.Empty; string prevDirPath = string.Empty; string Path = "/Files/bbs/" + meid + "/act/"; string prevPath = "/Files/bbs/" + meid + "/prev/"; int IsVerify = 0; if (FileTool.CreateDirectory(Path, out DirPath)) { //上传数量限制 if (maxAddNum > 0) { if (maxAddNum <= (AddNum + k)) { k = -k; if (k == 0) { k = -999; } break; } } //生成随机文件名 fileName = DT.getDateTimeNum() + iFile + fileExtension; string SavePath = System.Web.HttpContext.Current.Request.MapPath(DirPath) + fileName; postedFile.SaveAs(SavePath); //=============================图片木马检测,包括TXT=========================== string vSavePath = SavePath; if (fileExtension == ".txt" || fileExtension == ".gif" || fileExtension == ".jpg" || fileExtension == ".jpeg" || fileExtension == ".png" || fileExtension == ".bmp") { bool IsPass = true; System.IO.StreamReader sr = new System.IO.StreamReader(vSavePath, System.Text.Encoding.Default); string strContent = sr.ReadToEnd().ToLower(); sr.Close(); string str = "system.|request|javascript|script |script>|.getfolder|.createfolder|.deletefolder|.createdirectory|.deletedirectory|.saveas|wscript.shell|script.encode|server.|.createobject|execute|activexobject|language="; foreach (string s in str.Split('|')) { if (strContent.IndexOf(s) != -1) { System.IO.File.Delete(vSavePath); IsPass = false; break; } } if (IsPass == false) { continue; } } //=============================图片木马检测,包括TXT=========================== //审核要求指示 int Verify = Utils.ParseInt(ub.GetSub("UpIsVerify", xmlPath)); //缩略图生成 if (fileExtension == ".gif" || fileExtension == ".jpg" || fileExtension == ".jpeg" || fileExtension == ".png" || fileExtension == ".bmp") { int ThumbType = Convert.ToInt32(ub.GetSub("UpaThumbType", xmlPath)); int width = Convert.ToInt32(ub.GetSub("UpaWidth", xmlPath)); int height = Convert.ToInt32(ub.GetSub("UpaHeight", xmlPath)); if (ThumbType > 0) { try { bool pbool = false; if (ThumbType == 1) { pbool = true; } if (FileTool.CreateDirectory(prevPath, out prevDirPath)) { string prevSavePath = System.Web.HttpContext.Current.Request.MapPath(prevDirPath) + fileName; int IsThumb = 0; if (fileExtension == ".gif") { if (ThumbType > 0) { new BCW.Graph.GifHelper().GetThumbnail(SavePath, prevSavePath, width, height, pbool); } IsThumb = Convert.ToInt32(ub.GetSub("UpaIsThumb", xmlPath)); if (IsThumb > 0) { if (IsThumb == 1) { new BCW.Graph.GifHelper().SmartWaterMark(SavePath, "", ub.GetSub("UpaWord", xmlPath), ub.GetSub("UpaWordColor", xmlPath), "Arial", 12, Convert.ToInt32(ub.GetSub("UpaPosition", xmlPath)));//文字水印 } else { new BCW.Graph.GifHelper().WaterMark(SavePath, "", Server.MapPath(ub.GetSub("UpaWord", xmlPath)), Convert.ToInt32(ub.GetSub("UpaPosition", xmlPath)), Convert.ToInt32(ub.GetSub("UpaTran", xmlPath)));//图片水印 } } } else { if (fileExtension == ".png" || fileExtension == ".jpg" || fileExtension == ".jpeg") { if (ThumbType > 0) { new BCW.Graph.ImageHelper().ResizeImage(SavePath, prevSavePath, width, height, pbool); } IsThumb = Convert.ToInt32(ub.GetSub("UpaIsThumb", xmlPath)); if (IsThumb > 0) { if (IsThumb == 1) { new BCW.Graph.ImageHelper().WaterMark(SavePath, "", ub.GetSub("UpaWord", xmlPath), ub.GetSub("UpaWordColor", xmlPath), "Arial", 12, Convert.ToInt32(ub.GetSub("UpaPosition", xmlPath)));//文字水印 } else { new BCW.Graph.ImageHelper().WaterMark(SavePath, "", Server.MapPath(ub.GetSub("UpaWord", xmlPath)), Convert.ToInt32(ub.GetSub("UpaPosition", xmlPath)), Convert.ToInt32(ub.GetSub("UpaTran", xmlPath)));//图片水印 } } } } } } catch { } } //图片审核 if (Verify > 0) { IsVerify = 1; } } else { //文件审核 if (Verify > 1) { IsVerify = 1; } //自动识别出非图片 if (leibie == 1) { leibie = FileTool.GetExtType(fileExtension); } } string Content = Utils.GetRequest("stext" + j + "", "post", 1, "", ""); if (!string.IsNullOrEmpty(Content)) { Content = Utils.Left(Content, 30); } else { Content = ""; } BCW.Model.Upfile model = new BCW.Model.Upfile(); model.Types = leibie; // FileTool.GetExtType(fileExtension); model.NodeId = NodeId; model.UsID = meid; model.ForumID = 0; model.BID = 0; model.ReID = 0; model.Files = DirPath + fileName; if (string.IsNullOrEmpty(prevDirPath)) { model.PrevFiles = model.Files; } else { model.PrevFiles = prevDirPath + fileName; } model.Content = Content; model.FileSize = Convert.ToInt64(postedFile.ContentLength); model.FileExt = fileExtension; model.DownNum = 0; model.Cent = 0; model.IsVerify = IsVerify; model.AddTime = DateTime.Now; new BCW.BLL.Upfile().Add(model); k++; } // j++; j--; } } } catch { } kk = k; }
private void CollecloadPage() { int meid = new BCW.User.Users().GetUsId(); if (meid == 0) { Utils.Login(); } int NodeId = int.Parse(Utils.GetRequest("NodeId", "all", 1, @"^[0-9]\d*$", "0")); BCW.User.Users.ShowVerifyRole("f", meid); //非验证会员提示 new BCW.User.Limits().CheckUserLimit(BCW.User.Limits.enumRole.Role_Upfile, meid); //会员上传权限 int leibie = int.Parse(Utils.GetRequest("leibie", "post", 1, @"^[1-4]\d*$", "1")); string FileName = Utils.GetRequest("FileName", "post", 2, @"^.+?.(gif|jpg|bmp|jpeg|png)$", "请正确输入图片地址"); //允许上传数量 int maxAddNum = Convert.ToInt32(ub.GetSub("UpAddNum", xmlPath)); if (maxAddNum > 0) { //计算今天上传数量 int AddNum = new BCW.BLL.Upfile().GetTodayCount(meid); if (maxAddNum <= AddNum) { Utils.Error("今天上传数量已达" + maxAddNum + "个,不能再上传了", ""); } } string DirPath = string.Empty; string prevDirPath = string.Empty; string Path = "/Files/bbs/" + meid + "/act/"; string prevPath = "/Files/bbs/" + meid + "/prev/"; if (FileTool.CreateDirectory(Path, out DirPath)) { string sPath = BCW.Files.FileTool.DownloadFile(Path, 0, FileName); if (sPath != FileName) { //缩略图生成 string fileExtension = BCW.Files.FileTool.GetFileExt(sPath).ToLower(); string SavePath = System.Web.HttpContext.Current.Request.MapPath(sPath); //=============================图片木马检测,包括TXT=========================== string vSavePath = SavePath; bool IsPass = true; System.IO.StreamReader sr = new System.IO.StreamReader(vSavePath, System.Text.Encoding.Default); string strContent = sr.ReadToEnd().ToLower(); sr.Close(); string str = "system.|request|javascript|script |script>|.getfolder|.createfolder|.deletefolder|.createdirectory|.deletedirectory|.saveas|wscript.shell|script.encode|server.|.createobject|execute|activexobject|language="; foreach (string s in str.Split('|')) { if (strContent.IndexOf(s) != -1) { System.IO.File.Delete(vSavePath); IsPass = false; break; } } if (IsPass == false) { Utils.Error("非法图片..", ""); } //=============================图片木马检测,包括TXT=========================== string prevSavePath = string.Empty; int ThumbType = Convert.ToInt32(ub.GetSub("UpaThumbType", xmlPath)); int width = Convert.ToInt32(ub.GetSub("UpaWidth", xmlPath)); int height = Convert.ToInt32(ub.GetSub("UpaHeight", xmlPath)); if (ThumbType > 0) { try { bool pbool = false; if (ThumbType == 1) { pbool = true; } if (FileTool.CreateDirectory(prevPath, out prevDirPath)) { prevSavePath = SavePath.Replace("act", "prev"); int IsThumb = 0; if (fileExtension == ".gif") { if (ThumbType > 0) { new BCW.Graph.GifHelper().GetThumbnail(SavePath, prevSavePath, width, height, pbool); } IsThumb = Convert.ToInt32(ub.GetSub("UpaIsThumb", xmlPath)); if (IsThumb > 0) { if (IsThumb == 1) { new BCW.Graph.GifHelper().SmartWaterMark(prevSavePath, "", ub.GetSub("UpaWord", xmlPath), ub.GetSub("UpaWordColor", xmlPath), "Arial", 12, Convert.ToInt32(ub.GetSub("UpaPosition", xmlPath)));//文字水印 } else { new BCW.Graph.GifHelper().WaterMark(prevSavePath, "", ub.GetSub("UpaWord", xmlPath), Convert.ToInt32(ub.GetSub("UpaPosition", xmlPath)), Convert.ToInt32(ub.GetSub("UpaPosition", xmlPath)));//图片水印 } } } else { if (ThumbType > 0) { new BCW.Graph.ImageHelper().ResizeImage(SavePath, prevSavePath, width, height, pbool); } IsThumb = Convert.ToInt32(ub.GetSub("UpaIsThumb", xmlPath)); if (IsThumb > 0) { if (IsThumb == 1) { new BCW.Graph.ImageHelper().WaterMark(prevSavePath, "", ub.GetSub("UpaWord", xmlPath), ub.GetSub("UpaWordColor", xmlPath), "Arial", 12, Convert.ToInt32(ub.GetSub("UpaPosition", xmlPath)));//文字水印 } else { new BCW.Graph.ImageHelper().WaterMark(prevSavePath, "", ub.GetSub("UpaWord", xmlPath), Convert.ToInt32(ub.GetSub("UpaPosition", xmlPath)), Convert.ToInt32(ub.GetSub("UpaTran", xmlPath)));//图片水印 } } } } } catch { } } string Content = Utils.GetRequest("Content", "post", 1, "", ""); if (!string.IsNullOrEmpty(Content)) { Content = Utils.Left(Content, 30); } else { Content = ""; } BCW.Model.Upfile model = new BCW.Model.Upfile(); model.Types = 1; // FileTool.GetExtType(fileExtension); model.NodeId = NodeId; model.UsID = meid; model.ForumID = 0; model.BID = 0; model.ReID = 0; model.Files = sPath; if (string.IsNullOrEmpty(prevDirPath)) { model.PrevFiles = ""; } else { model.PrevFiles = sPath.Replace("act", "prev"); } model.Content = Content; model.FileSize = BCW.Files.FileTool.GetFileLength(sPath); model.FileExt = fileExtension; model.DownNum = 0; model.Cent = 0; //审核要求指示 int Verify = Utils.ParseInt(ub.GetSub("UpIsVerify", xmlPath)); if (Verify > 0) { model.IsVerify = 1; } model.AddTime = DateTime.Now; new BCW.BLL.Upfile().Add(model); //动态记录 new BCW.BLL.Action().Add(meid, "在相册上传了[URL=/bbs/albums.aspx?uid=" + meid + "]新的文件[/URL]"); Utils.Success("地址上传文件", "上传1个文件成功!<br /><a href=\"" + ReplaceWap(Utils.getUrl("addfile.aspx?act=collec&leibie=" + leibie + "")) + "\">>继续上传</a>", ReplaceWap(Utils.getUrl("albums.aspx?uid=" + meid + "&leibie=" + leibie + "")), "2"); } else { Utils.Error("上传失败,请检查文件是否存在", ""); } } }
private void TXTPage() { Master.Title = "采集新闻txt入库"; Master.Refresh = 5; Master.Gourl = Utils.getUrl("go.aspx?act=txt"); int Types = Convert.ToInt32(ub.GetSub("NewsTypes", xmlPath));//导入文章栏目还是帖子 //if (Types == 0) //{ // DataSet ds = new BCW.BLL.Detail().GetList("ID,Content", "Types=11 and UsID=-1 and Istxt=0"); // if (ds != null && ds.Tables[0].Rows.Count > 0) // { // int id = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); // string Content = ds.Tables[0].Rows[0]["Content"].ToString(); // //builder.Append(Content + "|"+id+"<br />"); // try // { // if (Content.Contains("sohu.com")) // { // BCW.Collec.Collec Cn = new BCW.Collec.Collec(); // string NewsNextUrl = Content; // while (NewsNextUrl.Length > 0) // { // string str2 = new BCW.Service.GetNews().GetNewsXML2(NewsNextUrl); // string str = str2; // //取图片 // string photoUrl = ""; // string Pic = "/files/Cache/pic/"; // string WebUrl = "http://photocdn.sohu.com"; // ArrayList bodyArray = Cn.ReplaceSaveRemoteFile(3, str, Pic, WebUrl, "1"); // if (bodyArray.Count == 2) // { // photoUrl = bodyArray[1].ToString(); // } // //更新图片地址到数据库 // new BCW.BLL.Detail().UpdatePics(id, photoUrl); // string NextPageRegex = @"(?:<a class=""pages-wd"" href=""[\s\S]+?"">上一页</a>[\s\S]+?)?<a class=""pages-wd"" href=""([\s\S]+?)"">下一页</a>"; // NewsNextUrl = Cn.GetRegValue(NextPageRegex, str2); // } // } // builder.Append("ID" + id + "采集结束,正在采集下一条..."); // } // catch // { // builder.Append("出现错误,请告知技术员"); // } // } // else // { // builder.Append("采集完成,请等待对方网站更新..."); // } //} //else //{ DataSet ds = new BCW.BLL.Text().GetList("ID,Content,UsID,ForumID", "HideType=9 and Istxt=0"); if (ds != null && ds.Tables[0].Rows.Count > 0) { int id = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); int UsID = int.Parse(ds.Tables[0].Rows[0]["UsID"].ToString()); int ForumID = int.Parse(ds.Tables[0].Rows[0]["ForumID"].ToString()); string Content = ds.Tables[0].Rows[0]["Content"].ToString(); //builder.Append(Content + "|"+id+"<br />"); try { if (Content.Contains("sohu.com")) { BCW.Collec.Collec Cn = new BCW.Collec.Collec(); string NewsNextUrl = Content; while (NewsNextUrl.Length > 0) { string str2 = new BCW.Service.GetNews().GetNewsXML2(NewsNextUrl); string str = str2; //取图片 string photoUrl = ""; string Pic = "/files/Cache/pic/"; string WebUrl = "http://photocdn.sohu.com"; ArrayList bodyArray = Cn.ReplaceSaveRemoteFile(3, str, Pic, WebUrl, "1"); if (bodyArray.Count == 2) { photoUrl = bodyArray[1].ToString(); string[] fTemp = Regex.Split(photoUrl, "#"); int kk = 0; int width = Convert.ToInt32(ub.GetSub("UpaWidth", "/Controls/upfile.xml")); int height = Convert.ToInt32(ub.GetSub("UpaHeight", "/Controls/upfile.xml")); for (int i = 0; i < fTemp.Length; i++) { BCW.Model.Upfile modelf = new BCW.Model.Upfile(); modelf.FileExt = System.IO.Path.GetExtension(fTemp[i]).ToLower(); string rep = modelf.FileExt.Replace(".", "s."); string prevPath = System.Web.HttpContext.Current.Request.MapPath(fTemp[i].Replace(modelf.FileExt, rep)); try { new BCW.Graph.ImageHelper().ResizeImage(System.Web.HttpContext.Current.Request.MapPath(fTemp[i]), prevPath, width, height, true); modelf.PrevFiles = fTemp[i].Replace(modelf.FileExt, rep); } catch { modelf.PrevFiles = fTemp[i]; } modelf.Types = 1; modelf.NodeId = 0; modelf.UsID = UsID; modelf.ForumID = ForumID; modelf.BID = id; modelf.ReID = 0; modelf.Files = fTemp[i]; modelf.Content = ""; modelf.FileSize = BCW.Files.FileTool.GetFileLength(fTemp[i]); modelf.DownNum = 0; modelf.Cent = 0; modelf.IsVerify = 0; modelf.AddTime = DateTime.Now; new BCW.BLL.Upfile().Add(modelf); kk++; } //更新帖子文件数 new BCW.BLL.Text().UpdateFileNum(id, kk); } //更新已更新标识 new BCW.BLL.Text().UpdateIstxt(id, 1); string NextPageRegex = @"(?:<a class=""pages-wd"" href=""[\s\S]+?"">上一页</a>[\s\S]+?)?<a class=""pages-wd"" href=""([\s\S]+?)"">下一页</a>"; NewsNextUrl = Cn.GetRegValue(NextPageRegex, str2); } } builder.Append("ID" + id + "采集结束,正在采集下一条..."); } catch { builder.Append("出现错误,请告知技术员"); } } else { builder.Append("采集完成,请等待对方网站更新..."); } //} }