Ejemplo n.º 1
0
    /// <summary>
    /// 确定提交
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string strError = Validates();

        if (strError != "")
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('" + strError + "');</script>");
            return;
        }
        model.CategoryId  = Convert.ToInt32(this.ddlType.SelectedValue);
        model.MarketId    = Convert.ToInt32(this.ddlMarket.SelectedValue);
        model.Titie       = SafeRequest.GetFormString("txtTitle");
        model.ReleaseDate = System.DateTime.Now;
        model.AddedDate   = System.DateTime.Now;
        model.ExpireDate  = System.DateTime.Now;
        model.Body        = SafeRequest.GetFormString("fckBody");
        model.Approved    = 1;
        model.AddedUserId = Convert.ToInt32(this.UserId);//默认登录进来人的编号
        if (_Pid != "")
        {
            model.ArticleId = Convert.ToInt32(_Pid);
            if (bll.Update(model))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>");
            }
        }
        else
        {
            if (bll.Add(model) > 0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('添加成功');layer_close_refresh();</script>");
            }
        }
    }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            SafeRequest safeRequest = new SafeRequest(ENCRYPTION_KEY);
            Response    response;

            // POST example
            NameValueCollection values = new NameValueCollection();

            values["some_key"] = "some_value";
            response           = safeRequest.Request(URL, values);
            Console.WriteLine(response.message);
            Console.ReadKey();

            // GET example
            // Note: Requests with null values still post an authentication key to verify the validity of the request.
            response = safeRequest.Request(URL);
            Console.WriteLine(response.message);
            Console.ReadKey();
        }
Ejemplo n.º 3
0
        public void SafeRequestEncryptDecrypt()
        {
            var      safeRequest = new SafeRequest(ENCRYPTION_KEY);
            Response response;

            // POST example
            var values = new NameValueCollection();

            values["some_key"] = "some_value";
            response           = safeRequest.Request(URL, values);
            var originalMessage = response.Message;

            // GET example
            // Note: Requests with null values still post an authentication key to verify the validity of the request.
            response = safeRequest.Request(URL);
            var newMessage = response.Message;

            Assert.IsNotNull(newMessage);
            Assert.AreEqual(originalMessage, newMessage);
        }
Ejemplo n.º 4
0
    /// <summary>
    /// 确定提交
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string strError = Validates();

        if (strError != "")
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('" + strError + "');</script>");
            return;
        }
        model.CategoryId  = Convert.ToInt32(this.ddlType.SelectedValue);
        model.Titie       = SafeRequest.GetFormString("txtTitle");
        model.ReleaseDate = Convert.ToDateTime(this.txtReleaseDate.Text.Trim());
        model.AddedDate   = System.DateTime.Now;
        model.ExpireDate  = System.DateTime.Now;
        model.Body        = SafeRequest.GetFormString("fckBody");
        model.Approved    = SafeRequest.GetFormInt("radioApproved", 0);
        model.AddedUserId = Convert.ToInt32(this.UserId);//默认登录进来人的编号
        if (_Pid != "")
        {
            model.ArticleId = Convert.ToInt32(_Pid);
            if (bll.Update(model))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>");
            }
        }
        else
        {
            int ret = bll.Add(model);
            if (ret == -2)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<Script>alert('该类别只允许添加1篇文章,请到列表中查找然后修改!');</Script>");
            }
            else
            {
                if (ret > 0)
                {
                    JSUtility.AlertAndRedirect("添加成功,请继续添加!", Request.RawUrl.ToString());
                }
            }
        }
    }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        LoadMenu();

        id = SafeRequest.GetQueryString("id");
    }
Ejemplo n.º 6
0
    /// <summary>
    /// 确定提交
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string strError = Validates();

        if (!string.IsNullOrEmpty(strError))
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('" + strError + "');</script>");
            return;
        }
        model.CategoryId      = Convert.ToInt32(this.ddlType.SelectedValue);
        model.Title           = SafeRequest.GetFormString("txtTitle");
        model.SubHead         = SafeRequest.GetFormString("txtSubHead");
        model.PublicationUnit = SafeRequest.GetFormString("txtUnit");
        model.FromSource      = SafeRequest.GetFormString("txtFromSouce");
        // model.KeyWord = SafeRequest.GetFormString("txtKeyWord");
        model.ReleaseDate  = !string.IsNullOrEmpty(this.txtReleaseDate.Text.Trim()) ? Convert.ToDateTime(this.txtReleaseDate.Text.Trim()) : System.DateTime.Now;
        model.IsTop        = 0; //SafeRequest.GetFormInt("radioTopList", 0);
        model.IndexCommend = 0; //SafeRequest.GetFormInt("radioIndexCommentList", 0);
        model.HotPic       = SafeRequest.GetFormString("radioHotList");
        model.HotDays      = SafeRequest.GetFormInt("txtHotDays", 3);
        //model.ArticleType = SafeRequest.GetFormInt("radioArticleTypeList", 0);
        model.Body = this.fckBody.Text;

        //追加底部
        if (cbFooter.Checked)
        {
            if (model.Body.IndexOf("start_auto_footer") == -1 && model.Body.IndexOf("end_auto_footer") == -1)
            {
                string autoFooter = "<!--start_auto_footer-->" + this.fckBodyFooter.Text + "<!--end_auto_footer-->";
                model.Body = model.Body + autoFooter;
            }
            //写入缓存
            NG.CachHelper.Redis.RedisHelper redis = new NG.CachHelper.Redis.RedisHelper();
            redis.SetStringCash("News_Footer", this.fckBodyFooter.Text);
            redis.Close();
        }

        //   model.IsComment = 0;// SafeRequest.GetFormInt("radioIsComment", 0);
        model.Approved   = SafeRequest.GetFormInt("radioApproved", 0);
        model.Sort       = SafeRequest.GetFormInt("txtSort", 99);
        model.AddedDate  = System.DateTime.Now;
        model.ExpireDate = System.DateTime.Now;
        model.ViewCount  = 0;
        // model.IsScrool = 0;
        // model.AddedUserId = Convert.ToInt32(_userId);//默认登录进来人的编号
        model.AddedUserId = 1;
        //~/upload/News/
        #region 保存图片
        if (!this.picUpload.Value.Equals("") && this.picUpload.PostedFile.ContentLength > 10)
        {
            string FileTZM = this.picUpload.PostedFile.FileName.Substring(this.picUpload.PostedFile.FileName.LastIndexOf(".") + 1);//得到文件的扩展名

            if (!IsPic(FileTZM.ToLower()))
            {
                JSUtility.Alert("上传图片格式不正确!");
                return;
            }
            if (this.picUpload.PostedFile.ContentLength > 1048576)
            {
                JSUtility.Alert("上传图片过大!");
                return;
            }
            Random rnd            = new Random();
            string UpLoadFileTime = DateTime.Now.ToString("yyMMddHHmmss") + rnd.Next(9999).ToString("0000"); //生成一个新的数图片名称
            string fileName       = UpLoadFileTime + "." + FileTZM;                                          //产生上传图片的名称
            if (!Directory.Exists(Request.MapPath("~/upload/News/")))
            {
                Directory.CreateDirectory(Request.MapPath("~/upload/News/"));
            }
            string Url = Request.MapPath("~/upload/News/" + fileName);
            picUpload.PostedFile.SaveAs(Url);
            model.ImgLink = "/upload/News/" + fileName;
        }
        else
        {
            model.ImgLink = ViewState["ImgLink"].ToString();
        }
        #endregion


        if (_Pid != "")
        {
            model.NewsID = _Pid;
            if (bll.Update(model))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>");
            }
        }
        else
        {
            model.NewsID = IdCreator.CreateId("T_News", "NewsId");
            if (bll.Add(model))
            {
                JSUtility.AlertAndRedirect("添加成功,请继续添加!", Request.RawUrl.ToString());
            }
        }
    }
Ejemplo n.º 7
0
    //保存
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        model.Title       = SafeRequest.GetFormString("txtTitle");
        model.DisplayMode = SafeRequest.GetFormInt("RadioButtonList1", 0);
        model.CategoryId  = SafeRequest.GetFormInt("DrCategory", 0);
        model.Link        = txtLink.Text.Trim();
        model.Sort        = SafeRequest.GetFormInt("txtSort", 0);

        #region 保存图片
        if (!this.picUpload.Value.Equals(""))
        {
            string UploadFileLastName = this.picUpload.PostedFile.FileName.Substring(this.picUpload.PostedFile.FileName.LastIndexOf(".") + 1);//得到文件的扩展名

            if (!PubFunction.IsPic(UploadFileLastName))
            {
                JSUtility.Alert("上传图片格式不正确!");
                return;
            }
            Random rnd            = new Random();
            string UpLoadFileTime = DateTime.Now.ToString("HHmmss") + rnd.Next(9999).ToString("0000"); //生成一个新的数图片名称
            string fileName       = UpLoadFileTime + "." + UploadFileLastName;                         //产生上传图片的名称

            string SaveFile = DateTime.Now.ToString("yyyy/MM/dd/").Replace("-", "/");

            #region 设置保存的路径
            string SevedDirectory = System.Web.VirtualPathUtility.Combine(mainPath, SaveFile);
            string phydic         = MapPath(SevedDirectory);

            if (!System.IO.Directory.Exists(phydic))
            {
                System.IO.Directory.CreateDirectory(phydic);
            }
            #endregion

            this.picUpload.PostedFile.SaveAs(phydic + "" + fileName);
            string fckimg = string.Empty;
            string source = string.Empty;
            fckimg = "<a href='" + this.ResolveUrl(SevedDirectory + fileName) + "' target='_blank'  id='upannexx'>" + fileName + "</a>";
            source = this.ResolveUrl(SevedDirectory + fileName);

            model.Image = SaveFile + fileName;
        }
        else
        {
            model.Image = ViewState["ImgLink"].ToString();
        }

        #endregion

        string BackUrl = "LinkList.aspx?PageIndex=" + PageIndex;

        if (_Lid != "0")
        {
            model.LinkId = Convert.ToInt32(_Lid);
            bll.Update(model);
            ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>");

            //状态
            if (Session["LinkStatus_Hashtable"] != null)
            {
                Hashtable hTable = (Hashtable)Session["LinkStatus_Hashtable"];
                hTable["ReadSessionStatus"]     = "1";
                Session["LinkStatus_Hashtable"] = hTable;
            }

            /*日志归档*/
            string sql = @"select l.title from T_link l where linkid=" + this._Lid + "";
            PubFunction.InsertLog("其它管理", "友情链接", "友情链接列表", "修改", sql, _Lid);
        }
        else
        {
            int i = bll.Add(model);
            JSUtility.AlertAndRedirect("添加成功,请继续添加!", Request.RawUrl.ToString());


            /*日志归档*/
            string sql = @"select l.title from T_link l where linkid=" + i.ToString() + "";
            PubFunction.InsertLog("其它管理", "友情链接", "友情链接列表", "添加", sql, i.ToString());
        }
    }