Exemplo n.º 1
0
        public void GetPassWord_Email()
        {
            B_MailManage mailBll = new B_MailManage();

            if (!ZoomlaSecurityCenter.VCodeCheck(Request.Form["VCode_hid"], Request.Form["VCode"]))
            {
                function.WriteErrMsg("验证码不正确", "/User/GetPassword"); return;
            }
            M_UserInfo mu = GetUserByName(Request.Form["TxtUserName"]);

            if (string.IsNullOrEmpty(mu.Email) || mu.Email.Contains("@random"))
            {
                function.WriteErrMsg("用户未设置邮箱,无法通过邮箱找回"); return;
            }
            //生成Email验证链接
            string seturl = function.GetRandomString(12) + "," + DateTime.Now.ToString();

            mu.seturl = seturl;
            buser.UpDateUser(mu);
            //Email发送
            string url       = SiteConfig.SiteInfo.SiteUrl + "/User/GetPassWord?key=" + mu.seturl + "&uid=" + mu.UserID;
            string returnurl = "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>";
            string content   = mailBll.SelByType(B_MailManage.MailType.RetrievePWD);

            content = new OrderCommon().TlpDeal(content, GetPwdEmailDt(mu.UserName, SiteConfig.SiteInfo.SiteName, returnurl));
            MailInfo mailInfo = SendMail.GetMailInfo(mu.Email, SiteConfig.SiteInfo.SiteName, SiteConfig.SiteInfo.SiteName + "_找回密码", content);

            SendMail.Send(mailInfo);
            //不需要更新步骤,其从邮箱进入地址栏后再更新
            function.WriteSuccessMsg("密码重设请求提交成功,<a href='" + B_Plat_Common.GetMailSite(mu.Email) + "' target='_blank'>请前往邮箱查收</a>!!", "", 0); return;
        }
Exemplo n.º 2
0
        public IActionResult GetPassWord_Email()
        {
            B_MailManage mailBll = new B_MailManage();

            if (!VerifyHelper.Check(RequestEx["VCode_Hid"]))
            {
                return(WriteErr("验证码不正确", "/User/GetPassword"));
            }
            M_UserInfo mu = GetUserByName(RequestEx["TxtUserName"]);

            if (string.IsNullOrEmpty(mu.Email) || mu.Email.Contains("@random"))
            {
                return(WriteErr("用户未设置邮箱,无法通过邮箱找回"));
            }
            //生成Email验证链接
            string seturl = function.GetRandomString(12) + "," + DateTime.Now.ToString();

            mu.seturl = EncryptHelper.AESEncrypt(seturl);
            buser.UpDateUser(mu);
            //Email发送
            string url       = SiteConfig.SiteInfo.SiteUrl + "/User/Change/GetPassWord?key=" + mu.seturl + "&uid=" + mu.UserID;
            string returnurl = "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>";
            string content   = mailBll.SelByType(B_MailManage.MailType.RetrievePWD);

            content = new OrderCommon().TlpDeal(content, GetPwdEmailDt(mu.UserName, SiteConfig.SiteInfo.SiteName, returnurl));
            MailInfo mailInfo = SendMail.GetMailInfo(mu.Email, SiteConfig.SiteInfo.SiteName, SiteConfig.SiteInfo.SiteName + "_找回密码", content);

            SendMail.Send(mailInfo);
            //不需要更新步骤,其从邮箱进入地址栏后再更新
            string emailUrl = B_Plat_Common.GetMailSite(mu.Email);

            return(WriteOK("密码重设请求提交成功,<a href='" + emailUrl + "' target='_blank'>请前往邮箱查收</a>!!"));
        }
        public string SaveFile()
        {
            string vpath = B_Plat_Common.GetDirPath(B_Plat_Common.SaveType.Company_P);

            SFiles_Up.SaveUrl = vpath;
            return(SFiles_Up.SaveFile());
        }
Exemplo n.º 4
0
        //产生邀请链接
        public string GetULink()
        {
            M_User_Plat upMod = B_User_Plat.GetLogin();
            string      code  = B_Plat_Common.GetTimeStamp(upMod.CompID.ToString());
            string      ulink = SiteConfig.SiteInfo.SiteUrl + "/User/RegPlat?Invite=" + code;

            return(ulink);
        }
Exemplo n.º 5
0
        protected void ImgUP_Btn_Click(object sender, EventArgs e)
        {
            string vpath = B_Plat_Common.GetDirPath(B_Plat_Common.SaveType.Person_P);
            string fname = function.GetRandomString(6) + Path.GetExtension(SFile_Up.FileUrl);

            SFile_Up.SaveUrl = vpath + fname;
            M_UserInfo mu = buser.GetLogin();

            buser.UpdateByID(mu);
        }
Exemplo n.º 6
0
        public IActionResult Email_SendEmail()
        {
            CheckNum = function.GetRandomString(8).ToLower();
            string   mailcontent = "您好,您正在<a href='" + SiteConfig.SiteInfo.SiteUrl + "'>" + SiteConfig.SiteInfo.SiteName + "</a>网站修改邮箱,您本次的验证码为:" + CheckNum;
            MailInfo mailInfo    = SendMail.GetMailInfo(mu.Email, SiteConfig.SiteInfo.SiteName, "修改邮箱[" + SiteConfig.SiteInfo.SiteName + "]", mailcontent);

            SendMail.Send(mailInfo);
            ShowMsg("注册验证码已成功发送到你的注册邮箱,<a href='" + B_Plat_Common.GetMailSite(mu.Email) + "' target='_blank'>请前往邮箱查收并验证</a>!", "info");
            ViewBag.email = mu.Email;
            return(View("Email"));
        }
Exemplo n.º 7
0
    //发送验证邮件
    protected void SendEMail_Btn_Click(object sender, EventArgs e)
    {
        M_UserInfo mu = buser.GetLogin();

        CheckNum = function.GetRandomString(8).ToLower();
        //-------------------------------------
        //string regurl = SiteConfig.SiteInfo.SiteUrl.TrimEnd('/') + "/User/ChangeEmail.aspx?CheckNum=" + code;
        string   mailcontent = "您好,您正在<a href='" + SiteConfig.SiteInfo.SiteUrl + "'>" + SiteConfig.SiteInfo.SiteName + "</a>网站修改邮箱,您本次的验证码为:" + CheckNum;
        MailInfo mailInfo    = SendMail.GetMailInfo(mu.Email, SiteConfig.SiteInfo.SiteName, "修改邮箱[" + SiteConfig.SiteInfo.SiteName + "]", mailcontent);

        SendMail.Send(mailInfo);
        ShowInfo("注册验证码已成功发送到你的注册邮箱,<a href='" + B_Plat_Common.GetMailSite(mu.Email) + "' target='_blank'>请前往邮箱查收并验证</a>!");
    }
Exemplo n.º 8
0
    //-----------------Step2
    protected void SendNewEmail_Btn_Click(object sender, EventArgs e)
    {
        NewEmail = NewEmail_T.Text.Trim();
        if (buser.IsExistMail(NewEmail))
        {
            ShowAlert("该邮箱已存在"); NewEmail = ""; return;
        }
        NewCheckNum = function.GetRandomString(8).ToLower();
        string   mailcontent = "您好,您正在<a href='" + SiteConfig.SiteInfo.SiteUrl + "'>" + SiteConfig.SiteInfo.SiteName + "</a>网站修改邮箱,您本次的验证码为:" + NewCheckNum;
        MailInfo mailInfo    = SendMail.GetMailInfo(NewEmail, SiteConfig.SiteInfo.SiteName, "修改邮箱[" + SiteConfig.SiteInfo.SiteName + "]", mailcontent);

        SendMail.Send(mailInfo);
        ShowInfo("注册验证码已成功发送到你的注册邮箱,<a href='" + B_Plat_Common.GetMailSite(NewEmail) + "' target='_blank'>请前往邮箱查收并验证</a>!");
    }
Exemplo n.º 9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (function.isAjax())
     {
         string imgstr = Request.Form["base64"];
         string result = "{\"msg\":\"上传失败\",\"imgurl\":\"\"}";
         if (!string.IsNullOrEmpty(imgstr) && imgstr.Contains("base64,"))
         {
             string vpath = B_Plat_Common.GetDirPath(B_Plat_Common.SaveType.Blog) + function.GetRandomString(6) + ".jpg";
             imgstr = Regex.Split(imgstr, Regex.Unescape("base64,"))[1];
             imghelper.Base64ToImg(vpath, imgstr);
             result = "{\"msg\":\"上传成功\",\"imgurl\":\"" + vpath + "\"}";
         }
         Response.Write(result);
         Response.Flush(); Response.End();
     }
 }
Exemplo n.º 10
0
        public ActionResult Email_SendNewEmail()
        {
            string newEmail = Request["newemail"];

            ViewBag.newemail = newEmail;
            Step             = 2;
            if (buser.IsExistMail(newEmail))
            {
                ShowMsg("该邮箱已存在", "danger"); return(View("Email"));
            }
            NewCheckNum = function.GetRandomString(8).ToLower();
            string   mailcontent = "您好,您正在<a href='" + SiteConfig.SiteInfo.SiteUrl + "'>" + SiteConfig.SiteInfo.SiteName + "</a>网站修改邮箱,您本次的验证码为:" + NewCheckNum;
            MailInfo mailInfo    = SendMail.GetMailInfo(newEmail, SiteConfig.SiteInfo.SiteName, "修改邮箱[" + SiteConfig.SiteInfo.SiteName + "]", mailcontent);

            SendMail.Send(mailInfo);
            ShowMsg("注册验证码已成功发送到你的注册邮箱,<a href='" + B_Plat_Common.GetMailSite(newEmail) + "' target='_blank'>请前往邮箱查收并验证</a>!", "info");
            return(View("Email"));
        }
Exemplo n.º 11
0
    //创建用户,并发送邮件,email:compid:时间戮
    protected void Step1_Btn_Click(object sender, EventArgs e)
    {
        int compid = 0;

        if (!string.IsNullOrEmpty(Request.QueryString["Invite"]))
        {
            string invite = Request.QueryString["Invite"];
            compid = DataConverter.CLng(EncryptHelper.AESDecrypt(invite).Split(':')[0]);
        }
        Email_T.Text = Email_T.Text.Trim();
        string      code     = B_Plat_Common.GetTimeStamp(Email_T.Text + ":" + compid);
        string      url      = SiteConfig.SiteInfo.SiteUrl.TrimEnd('/') + "/User/RegPlat.aspx?code=" + code;
        string      emailTlp = mailBll.SelByType(B_MailManage.MailType.PlatReg); //SiteConfig.UserConfig.EmailPlatReg;
        MailAddress adMod    = new MailAddress(Email_T.Text);
        MailInfo    mailInfo = new MailInfo()
        {
            ToAddress = adMod, IsBodyHtml = true
        };

        mailInfo.FromName = SiteConfig.SiteInfo.SiteName;
        mailInfo.Subject  = SiteConfig.SiteInfo.SiteName + "注册邮件";
        mailInfo.MailBody = new OrderCommon().TlpDeal(emailTlp, GetPlatRegDt(url, Email_T.Text));
        if (SendMail.Send(mailInfo) == SendMail.MailState.Ok)//发送成功,生成用户,显示下一步提示
        {
            M_UserInfo mu = new M_UserInfo();
            //if (buser.IsExistMail(Email_T.Text)) { function.WriteErrMsg("帐号错误请检查注册选项或联系官方!!"); }
            mu.Email    = Email_T.Text;
            mu.UserName = Email_T.Text;//OK后再更改用户名
            mu.UserPwd  = function.GetRandomString(6);
            mu.Question = "尚未定义问题";
            mu.Answer   = function.GetRandomString(6);
            mu.RegTime  = DateTime.Now;
            mu.Status   = 1;
            mu.Remark   = code;
            buser.AddModel(mu);
            MailSite_A.NavigateUrl = B_Plat_Common.GetMailSite(mu.Email);
            function.Script(this, "showme();");
        }
        else
        {
            function.WriteErrMsg("邮件发送失败,请检测邮箱地址是否正确!!");
        }
    }
Exemplo n.º 12
0
        private string SendEMail(string email, string url)
        {
            string      result   = "";
            string      emailTlp = SiteConfig.UserConfig.EmailPlatReg;
            MailInfo    mailInfo = new MailInfo();
            MailAddress adMod    = new MailAddress(email);

            mailInfo.ToAddress  = adMod;
            mailInfo.IsBodyHtml = true;
            mailInfo.FromName   = SiteConfig.SiteInfo.SiteName;
            mailInfo.Subject    = SiteConfig.SiteInfo.SiteName + "注册邮件";
            mailInfo.MailBody   = emailTlp.Replace("{Url}", url).Replace("{Email}", email);
            if (buser.IsExistMail(email))
            {
                result = email + "发送失败,原因:该帐号已存在!";
            }
            else if (SendMail.Send(mailInfo) == SendMail.MailState.Ok)//发送成功,生成用户
            {
                M_UserInfo mu = new M_UserInfo();
                mu.Email    = email;
                mu.UserName = email;
                mu.UserPwd  = function.GetRandomString(6);
                mu.Question = "尚未定义问题";
                mu.Answer   = function.GetRandomString(6);
                mu.RegTime  = DateTime.Now;
                mu.Status   = 0;
                mu.Remark   = B_Plat_Common.GetTimeStamp(email);
                buser.AddModel(mu);
                result = email + "发送成功";
            }
            else
            {
                result = email + "发送失败,原因:Email发送失败!";
            }
            return(result);
        }
Exemplo n.º 13
0
        private M_Blog_Msg FillMsg(string msg, out string puremsg, int pid = 0, int rid = 0, string files = "")
        {
            puremsg = msg;
            M_User_Plat upMod = B_User_Plat.GetLogin();
            M_Blog_Msg  model = new M_Blog_Msg();

            model.MsgType = 1;
            model.Status  = 1;
            model.CUser   = upMod.UserID;
            model.CUName  = upMod.TrueName;
            model.ProID   = CurProID;
            model.CompID  = upMod.CompID;
            model.pid     = pid;
            model.ReplyID = rid;
            #region 信息内容处理
            //#话题(转码后会带有#符号,所以需要转码前处理完成)
            if (msg.Contains("#"))
            {
                msg = msg.Replace(deftopic, "");
                string tlp = "<a href='/Plat/Blog?Skey={0}' title='话题浏览'>{1}</a>";
                Dictionary <string, string> itemDic = new Dictionary <string, string>();
                for (int i = 0; !string.IsNullOrEmpty(regHelper.GetValueBySE(msg, "#", "#", false)) && i < 5; i++)//最多不能超过5个话题
                {
                    string topic = "#" + regHelper.GetValueBySE(msg, "#", "#", false) + "#";
                    msg   = msg.Replace(topic, "{" + i + "}");
                    topic = topic.Replace(" ", "").Replace(",", "");
                    itemDic.Add("{" + i + "}", string.Format(tlp, Server.UrlEncode(topic), topic));
                    model.Topic += topic + ",";
                }
                msg = HttpUtility.HtmlEncode(msg);
                foreach (var item in itemDic)
                {
                    msg = msg.Replace(item.Key, item.Value);
                }
            }
            else
            {
                msg = HttpUtility.HtmlEncode(msg);
            }
            //URL转链接
            {
                string          tlp = "<a href='{0}' target='_blank'>{0}</a>";
                MatchCollection mcs = regHelper.GetUrlsByStr(msg);
                foreach (Match m in mcs)
                {
                    //同网址,信息替换多次会产生Bug,如多个www.baidu.com
                    string url = m.Value.IndexOf("://") < 0 ? "http://" + m.Value : m.Value;
                    msg = msg.Replace(m.Value, string.Format(tlp, url));
                }
            }
            //表情
            {
                if (!string.IsNullOrEmpty(ImgFace_Hid.Value))
                {
                    string    imgHtml = "<img src='/Plugins/Ueditor/dialogs/emotion/{0}' class='imgface_img' />";
                    DataTable imgDT   = JsonHelper.JsonToDT(ImgFace_Hid.Value);
                    foreach (DataRow dr in imgDT.Rows)
                    {
                        msg     = msg.Replace(dr["title"].ToString(), string.Format(imgHtml, dr["realurl"].ToString()));
                        puremsg = puremsg.Replace(dr["title"].ToString(), "");
                    }
                }
            }
            //@功能
            {
                MatchCollection mc = regHelper.GetValuesBySE(msg, "@", "]");
                int             id = 0;
                string          atuser = "", atgroup = "", name = "";
                string          uTlp = "<a href='javascript:;' onclick='ShowUser({0});'>{1}</a>";
                string          gTlp = "<a href='javascript:;' onclick='ShowGroup({0});'>{1}</a>";
                foreach (Match m in mc)
                {
                    //@what130[uid:19],名字替换为超链接,之后的取值取入数据库
                    if (string.IsNullOrEmpty(m.Value))
                    {
                        continue;
                    }
                    if (m.Value.Contains("uid:"))
                    {
                        id      = DataConvert.CLng(regHelper.GetValueBySE(m.Value, "uid:", "]", false));
                        name    = regHelper.GetValueBySE(m.Value, "@", @"\[").Replace("[", "");
                        atuser += id + ",";
                        msg     = msg.Replace(m.Value, string.Format(uTlp, id, name));
                    }
                    else if (m.Value.Contains("gid:"))
                    {
                        id       = DataConvert.CLng(regHelper.GetValueBySE(m.Value, "gid:", "]", false));
                        name     = regHelper.GetValueBySE(m.Value, "@", @"\[").Replace("[", "");
                        atgroup += id + ",";
                        msg      = msg.Replace(m.Value, string.Format(gTlp, id, name));
                    }
                    puremsg = puremsg.Replace(m.Value, "");
                }
                if (!string.IsNullOrEmpty(atuser) || !string.IsNullOrEmpty(atgroup))
                {
                    atuser += upBll.SelByGIDS(atgroup);
                    if (!string.IsNullOrEmpty(atuser.Replace(",", "")))
                    {
                        model.ATUser = StrHelper.IdsFormat(atuser);
                        //model.ATUser = model.ATUser.Replace("," + upMod.UserID, "");//过滤自己
                        //提示被@人
                        M_Notify notifyMod = new M_Notify();
                        notifyMod.CUName    = upMod.UserName;
                        notifyMod.Title     = "Hi,[" + B_User.GetUserName(upMod.TrueName, upMod.UserName) + "]@你了,点击查看详情";
                        notifyMod.Content   = puremsg.Length > 30 ? puremsg.Substring(0, 30) : puremsg;
                        notifyMod.ReceUsers = model.ATUser;
                        B_Notify.NotifyList.Add(notifyMod);
                    }
                }
            }
            //--------------------------------
            msg = msg.Replace("\r", "").Replace("\n", "<br/>");//替换换行标识
            #endregion
            //msg = msg.Replace("&#39;", "\'");
            model.MsgContent = msg;
            if (rid > 0)
            {
                M_Blog_Msg msgMod = msgBll.SelReturnModel(model.ReplyID);
                model.ReplyUserID = msgMod.CUser;
                model.ReplyUName  = msgMod.CUName;
            }
            if (string.IsNullOrEmpty(files) && !string.IsNullOrEmpty(Request.Form["Attach_Hid"]))
            {
                files = SafeSC.PathDeal(Request.Form["Attach_Hid"].Trim());
            }
            if (!string.IsNullOrEmpty(files))//为安全,不允许全路径,必须后台对路径处理
            {
                string uppath = B_Plat_Common.GetDirPath(B_Plat_Common.SaveType.Blog);
                foreach (string file in files.Split('|'))
                {
                    if (string.IsNullOrEmpty(file))
                    {
                        continue;
                    }
                    model.Attach += uppath + file + "|";
                }
            }
            if (!string.IsNullOrEmpty(Request.Form["GOnlyMe_Chk"]))
            {
                model.GroupIDS = "0";
            }
            else
            {
                model.GroupIDS = string.IsNullOrEmpty(Request.Form["GroupIDS_Chk"]) ? "" : Request.Form["GroupIDS_Chk"];//后期需加入检测,避免前台伪造
            }
            model.ColledIDS = "";
            return(model);
        }
Exemplo n.º 14
0
        public IActionResult UploadFileHandler()
        {
            //HttpRequest Request = context.Request;
            //context.Response.ContentType = "text/plain";
            //context.Request.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
            //context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
            var file = Request.Form.Files["Filedata"];

            if (file == null)
            {
                file = Request.Form.Files["file"];//接受Uploadify或WebUploader传参,优先Uploadify
            }
            if (file == null || file.Length < 1)
            {
                return(Content(Failed.ToString()));
            }
            if (SafeSC.FileNameCheck(file.FileName))
            {
                throw new Exception("不允许上传该后缀名的文件");
            }
            M_UserInfo mu = buser.GetLogin();

            if (adminMod == null && mu.IsNull)
            {
                throw new Exception("未登录");
            }
            /*-------------------------------------------------------------------------------------------*/
            M_User_Plat upMod = new B_User_Plat().SelReturnModel(mu.UserID);
            string      uploadPath = SiteConfig.SiteOption.UploadDir.TrimEnd('/') + "/", filename = "", ppath = "", result = "0";//上传根目录,文件名,上物理路径,结果
            string      action = GetParam("action"), value = GetParam("value");

            try
            {
                switch (action)
                {
                    #region OA与能力中心
                case "OAattach":    //OA--公文||事务--附件
                                    //uploadPath += "OA/" + mu.UserName + mu.UserID + "/" + DateTime.Now.ToString("yyyyMMdd") + "/";
                    uploadPath = ZLHelper.GetUploadDir_User(mu, "OA");
                    ppath      = function.VToP(uploadPath);
                    //判断是否有同名文件的存在
                    break;

                case "Blog":    //能力中心--博客
                    uploadPath = B_Plat_Common.GetDirPath(upMod, B_Plat_Common.SaveType.Blog);
                    ppath      = function.VToP(uploadPath);
                    break;

                case "Plat_Doc":    //能力中心--我的文档
                    uploadPath = B_Plat_Common.GetDirPath(upMod, B_Plat_Common.SaveType.Person) + SafeSC.PathDeal(GetParam("Dir"));
                    ppath      = function.VToP(uploadPath);
                    break;

                case "Plat_Doc_Common":    //能力中心--公司文档
                    uploadPath = B_Plat_Common.GetDirPath(upMod, B_Plat_Common.SaveType.Company) + SafeSC.PathDeal(GetParam("Dir"));
                    ppath      = function.VToP(uploadPath);
                    break;

                case "Plat_Task":    //能力中心--任务中心附件
                    int tid = Convert.ToInt32(value);
                    ZoomLa.Model.Plat.M_Plat_Task taskMod = new B_Plat_Task().SelReturnModel(tid);
                    uploadPath = B_Plat_Common.GetDirPath(upMod, B_Plat_Common.SaveType.Plat_Task) + taskMod.TaskName + "/";
                    break;

                case "Plat_Project":    //能力中心--项目
                    int pid = Convert.ToInt32(value);
                    ZoomLa.Model.Plat.M_Plat_Pro proMod = new B_Plat_Pro().SelReturnModel(pid);
                    uploadPath = B_Plat_Common.GetDirPath(upMod, B_Plat_Common.SaveType.Plat_Task) + proMod.Name + "/";
                    break;

                    #endregion
                case "ModelFile":    //组图,多图等
                {
                    int nodeid = Convert.ToInt32(value);
                    //M_Node nodeMod = new B_Node().GetNodeXML(nodeid);
                    string exname = Path.GetExtension(file.FileName).Replace(".", "");
                    //string fpath = nodeMod.NodeDir + "/" + exname + "/" + DateTime.Now.ToString("yyyy/MM/");
                    uploadPath = ZLHelper.GetUploadDir_System("field", "images", "yyyyMMdd");
                    filename   = DateTime.Now.ToString("HHmmss") + function.GetRandomString(6, 2) + "." + exname;
                }
                break;

                case "admin_custom":    //管理员上传,自定义路径
                {
                    if (adminMod == null || adminMod.AdminId < 1)
                    {
                        throw new Exception("管理员未登录");
                    }
                    uploadPath = GetParam("save");       //BannerAdd
                }
                break;

                default:    //通常格式,不需做特殊处理的格式但必须登录
                    if (mu.UserID > 0)
                    {
                        //uploadPath = context.Server.UrlDecode(uploadPath + "User/" + mu.UserName + mu.UserID + "/");
                        uploadPath = ZLHelper.GetUploadDir_User(mu, "User", "", "");
                    }
                    else if (adminMod != null)
                    {
                        //uploadPath = context.Server.UrlDecode(uploadPath + "Admin/" + adminMod.AdminName + adminMod.AdminId + "/");
                        uploadPath = ZLHelper.GetUploadDir_Admin(adminMod, "", "", "yyyyMMdd");
                    }
                    else
                    {
                        //注册等页面用户未登录
                        uploadPath = ZLHelper.GetUploadDir_System("user", "register", DateTime.Now.ToString("yyyyMMdd"));
                    }
                    break;
                }
                string uploadDir = Path.GetDirectoryName(function.VToP(uploadPath));
                if (!Directory.Exists(uploadDir))
                {
                    SafeSC.CreateDir(function.PToV(uploadDir));
                }
                if (action.Equals("Plat_Doc") || action.Equals("Plat_Doc_Common"))
                {
                    #region 能力中心文档
                    M_Plat_File fileMod = new M_Plat_File();
                    B_Plat_File fileBll = new B_Plat_File();
                    fileMod.FileName  = file.FileName;
                    fileMod.SFileName = function.GetRandomString(12) + Path.GetExtension(file.FileName);
                    fileMod.VPath     = uploadPath.Replace("//", "/");
                    fileMod.UserID    = upMod.UserID.ToString();
                    fileMod.CompID    = upMod.CompID;
                    //SafeSC.SaveFile(uploadPath, file, fileMod.SFileName);
                    fileMod.FileSize = new FileInfo(ppath + fileMod.SFileName).Length.ToString();
                    fileBll.Insert(fileMod);
                    #endregion
                }
                else if (action.Equals("Cloud_Doc"))
                {
                    #region 用户中心云盘
                    if (!buser.CheckLogin())
                    {
                        throw new Exception("云盘,用户未登录");
                    }
                    M_User_Cloud cloudMod = new M_User_Cloud();
                    B_User_Cloud cloudBll = new B_User_Cloud();
                    uploadPath         = HttpUtility.UrlDecode(cloudBll.H_GetFolderByFType(GetParam("type"), mu)) + GetParam("value");
                    cloudMod.FileName  = file.FileName;
                    cloudMod.SFileName = function.GetRandomString(12) + Path.GetExtension(file.FileName);
                    cloudMod.VPath     = (uploadPath + "/").Replace("//", "/");
                    cloudMod.UserID    = mu.UserID;
                    cloudMod.FileType  = 1;
                    //result = SafeSC.SaveFile(cloudMod.VPath, file, cloudMod.SFileName);
                    //if (SafeSC.IsImage(cloudMod.SFileName))
                    //{
                    //    string icourl = SiteConfig.SiteOption.UploadDir + "YunPan/" + mu.UserName + mu.UserID + "/ico" + value + "/";
                    //    if (!Directory.Exists(function.VToP(icourl))) { SafeSC.CreateDir(icourl); }
                    //    ImgHelper imghelp = new ImgHelper();
                    //    imghelp.CompressImg(file, 100, icourl + cloudMod.SFileName);
                    //}
                    cloudMod.FileSize = new FileInfo(function.VToP(cloudMod.VPath) + cloudMod.SFileName).Length.ToString();
                    cloudBll.Insert(cloudMod);
                    #endregion
                }
                else
                {
                    //string fname = CreateFName(file.FileName);
                    //if (SafeC.IsImageFile(file.FileName) && file.Length > (5 * 1024 * 1024))//图片超过5M则压缩
                    //{
                    //    result = uploadPath + function.GetRandomString(6) + fname;
                    //    new ImgHelper().CompressImg(file, 5 * 1024, result);
                    //}
                    //else
                    //{
                    result = SafeC.SaveFile(uploadPath, filename, file.OpenReadStream(), (int)file.Length);
                    //}
                    //添加水印
                    //if (WaterModuleConfig.WaterConfig.EnableUserWater)
                    //{
                    //    //未以管理员身份登录,并有会员身份登录记录
                    //    if (adminMod == null && !mu.IsNull)
                    //    {
                    //        Image img = WaterImages.DrawFont(ImgHelper.ReadImgToMS(result), mu.UserName + " " + DateTime.Now.ToString("yyyy/MM/dd"), 9);
                    //        ImgHelper.SaveImage(result, img);
                    //    }
                    //}
                    //else if (DataConverter.CStr(context.Request["IsWater"]).Equals("1"))
                    //{
                    //    //前台主动标识需要使用水印
                    //    result = ImgHelper.AddWater(result);
                    //}
                }
                ZLLog.L(ZLEnum.Log.fileup, new M_Log()
                {
                    UName   = mu.UserName,
                    Source  = Request.RawUrl(),
                    Message = "上传成功|文件名:" + file.FileName + "|" + "保存路径:" + uploadPath
                });
            }
            catch (Exception ex)
            {
                ZLLog.L(ZLEnum.Log.fileup, new M_Log()
                {
                    UName   = mu.UserName,
                    Source  = Request.RawUrl(),
                    Message = "上传失败|文件名:" + file.FileName + "|" + "原因:" + ex.Message
                });
            }
            return(Content(result));
        }
Exemplo n.º 15
0
        public M_Blog_Msg FillMsg(string msg, int pid = 0, int rid = 0)
        {
            M_User_Plat upMod = B_User_Plat.GetLogin();
            M_Blog_Msg  model = new M_Blog_Msg();

            model.MsgType = 1;
            model.Status  = 1;
            model.CUser   = upMod.UserID;
            model.CUName  = upMod.TrueName;
            #region 信息内容处理
            msg = Server.HtmlEncode(msg); //避免写入js,后面可插入Html
                                          //------处理@功能
            //@功能
            {
                MatchCollection mc = regHelper.GetValuesBySE(msg, "@", "]");
                int             id = 0;
                string          atuser = "", atgroup = "", name = "";
                string          uTlp = "<a href='javascript:;' onclick='ShowUser({0});'>{1}</a>";
                string          gTlp = "<a href='javascript:;' onclick='ShowGroup({0});'>{1}</a>";
                foreach (Match m in mc)
                {
                    if (string.IsNullOrEmpty(m.Value))
                    {
                        continue;
                    }
                    if (m.Value.Contains("uid:"))
                    {
                        id      = DataConvert.CLng(regHelper.GetValueBySE(m.Value, "uid:", "]", false));
                        name    = regHelper.GetValueBySE(m.Value, "@", @"\[").Replace("[", "");
                        atuser += id + ",";
                        msg     = msg.Replace(m.Value, string.Format(uTlp, id, name));
                    }
                    else if (m.Value.Contains("gid:"))
                    {
                        id       = DataConvert.CLng(regHelper.GetValueBySE(m.Value, "gid:", "]", false));
                        name     = regHelper.GetValueBySE(m.Value, "@", @"\[").Replace("[", "");
                        atgroup += id + ",";
                        msg      = msg.Replace(m.Value, string.Format(gTlp, id, name));
                    }
                    msg = msg.Replace(m.Value, "");
                }
                if (!string.IsNullOrEmpty(atuser) || !string.IsNullOrEmpty(atgroup))
                {
                    atuser += upBll.SelByGIDS(atgroup);
                    if (!string.IsNullOrEmpty(atuser.Replace(",", "")))
                    {
                        model.ATUser = StrHelper.IdsFormat(atuser);
                        //model.ATUser = model.ATUser.Replace("," + upMod.UserID, "");//过滤自己
                        //提示被@人
                        M_Notify notifyMod = new M_Notify();
                        notifyMod.CUName    = upMod.UserName;
                        notifyMod.Title     = "Hi,有人@你了,点击查看详情";
                        notifyMod.Content   = msg.Length > 30 ? msg.Substring(0, 30) : msg;
                        notifyMod.ReceUsers = model.ATUser;
                        B_Notify.NotifyList.Add(notifyMod);
                    }
                }
            }
            #endregion
            model.MsgContent = msg;
            model.pid        = pid;
            model.ReplyID    = rid;
            if (rid > 0)
            {
                M_Blog_Msg msgMod = msgBll.SelReturnModel(model.ReplyID);
                model.ReplyUserID = msgMod.CUser;
                model.ReplyUName  = msgMod.CUName;
            }
            if (!string.IsNullOrEmpty(Request.Form["Attach_Hid"]))//为安全,不允许全路径,必须后台对路径处理
            {
                string     uppath = B_Plat_Common.GetDirPath(B_Plat_Common.SaveType.Blog);
                M_UserInfo bus    = buser.GetLogin();
                string     files  = SafeSC.PathDeal(Request.Form["Attach_Hid"].Trim());
                foreach (string file in files.Split('|'))
                {
                    if (string.IsNullOrEmpty(file))
                    {
                        continue;
                    }
                    model.Attach += uppath + file + "|";
                }
            }
            model.GroupIDS  = Request.Form["GroupIDS_Chk"];//后期需加入检测,避免前台伪造
            model.ColledIDS = "";
            //model.CompID = upMod.CompID;
            return(model);
        }