コード例 #1
0
        private bool DoAdd()
        {
            bool result = false;

            Model.plugin_link model = new Model.plugin_link();
            BLL.plugin_link   bll   = new BLL.plugin_link();

            model.site_path = ddlSitePath.SelectedValue;
            model.title     = txtTitle.Text.Trim();
            model.is_lock   = Utils.StrToInt(rblIsLock.SelectedValue, 0);
            if (cbIsRed.Checked == true)
            {
                model.is_red = 1;
            }
            else
            {
                model.is_red = 0;
            }
            model.sort_id   = Utils.StrToInt(txtSortId.Text.Trim(), 99);
            model.user_name = txtUserName.Text.Trim();
            model.user_tel  = txtUserTel.Text.Trim();
            model.email     = txtEmail.Text.Trim();
            model.site_url  = txtSiteUrl.Text.Trim();
            model.img_url   = txtImgUrl.Text.Trim();
            model.is_image  = 1;
            if (string.IsNullOrEmpty(model.img_url))
            {
                model.is_image = 0;
            }
            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加友情链接:" + model.title); //记录日志
                result = true;
            }
            return(result);
        }
コード例 #2
0
ファイル: ajax.ashx.cs プロジェクト: hui3694/forcomp
        private void link_add(HttpContext context)
        {
            StringBuilder strTxt = new StringBuilder();

            BLL.plugin_link   bll   = new BLL.plugin_link();
            Model.plugin_link model = new Model.plugin_link();

            string _site_path = DTRequest.GetQueryString("site");
            string _code      = DTRequest.GetFormString("txtCode");
            string _title     = DTRequest.GetFormString("txtTitle");
            string _user_name = DTRequest.GetFormString("txtUserName");
            string _user_tel  = DTRequest.GetFormString("txtUserTel");
            string _email     = DTRequest.GetFormString("txtEmail");
            string _site_url  = DTRequest.GetFormString("txtSiteUrl");
            string _img_url   = DTRequest.GetFormString("txtImgUrl");

            //检查站点目录
            if (string.IsNullOrEmpty(_site_path))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,网站传输参数有误!\"}");
                return;
            }
            //校检验证码
            if (string.IsNullOrEmpty(_code))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入验证码!\"}");
                return;
            }
            if (context.Session[DTKeys.SESSION_CODE] == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,系验证码已过期!\"}");
                return;
            }
            if (_code.ToLower() != (context.Session[DTKeys.SESSION_CODE].ToString()).ToLower())
            {
                context.Response.Write("{\"status\":0, \"msg\":\"验证码与系统的不一致!\"}");
                return;
            }
            if (string.IsNullOrEmpty(_title))
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"对不起,请输入网站标题!\"}");
                return;
            }
            if (string.IsNullOrEmpty(_site_url))
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"对不起,请输入网站网址!\"}");
                return;
            }
            model.site_path = Utils.DropHTML(_site_path);
            model.title     = Utils.DropHTML(_title);
            model.is_lock   = 1;
            model.is_red    = 0;
            model.user_name = Utils.DropHTML(_user_name);
            model.user_tel  = Utils.DropHTML(_user_tel);
            model.email     = Utils.DropHTML(_email);
            model.site_url  = Utils.DropHTML(_site_url);
            model.img_url   = Utils.DropHTML(_img_url);
            model.is_image  = 1;
            if (string.IsNullOrEmpty(model.img_url))
            {
                model.is_image = 0;
            }
            if (bll.Add(model) > 0)
            {
                context.Response.Write("{\"status\": 1, \"msg\": \"恭喜您,提交成功!\"}");
                return;
            }
            context.Response.Write("{\"status\": 0, \"msg\": \"对不起,保存过程中发生错误!\"}");
            return;
        }