protected void EditArticle(object sender, EventArgs e) { if (txtNews.Text.ToString() == "") { Label1.Text = Label2.Text = GetGlobalResourceObject("language", "InsertArticle").ToString(); Label1.Visible = Label2.Visible = true; } else { try { DateTime date = DateTime.Parse(txtdate.Text); string filename = ""; anm_Utility ut = new anm_Utility(); MembershipUser currentUser = Membership.GetUser(); if (FileUpload1.Visible == true) { filename = FileUpload1.FileName; if (DDimages.Text != "Choose the image from the server:") { filename = DDimages.Text; } else if (filename != "") { string tempfileName = ""; string savePath = Server.MapPath("~\\images\\"); string pathToCheck = savePath + filename; if (System.IO.File.Exists(pathToCheck)) { int counter = 2; while (System.IO.File.Exists(pathToCheck)) { tempfileName = counter.ToString() + filename; pathToCheck = savePath + tempfileName; counter++; } filename = tempfileName; } FileUpload1.SaveAs(Server.MapPath("~\\images\\app_") + filename); string copyright = ""; try { if (Convert.ToBoolean(ut.GetSetting("Copyright"))) { copyright = ut.GetSetting("SiteName"); } } catch { copyright = ""; } int width = 0; try { width = Convert.ToInt32(ut.GetSetting("ArtImageWidth")); } catch { width = 200; } ut.GenerateImage(Server.MapPath("~\\images\\app_") + filename, Server.MapPath("~\\images\\full_") + filename, 0, 0, copyright, "", "jpeg", "White", "Arial", 0, "bl"); ut.GenerateImage(Server.MapPath("~\\images\\full_") + filename, Server.MapPath("~\\images\\") + filename, width, 0, "", "", "jpeg", "White", "Arial", 0, "bl"); File.Delete(Server.MapPath("~\\images\\app_") + filename); } } else { filename = txtImage.Text.ToString(); } string title = txtTitle.Text; title = title.Replace("&", "&"); string tags = txtTags.Text; tags = tags.Replace("&", "&"); tags = tags.Replace(", ", ","); while (tags.Contains(".,")) { tags = tags.Replace(".,", ","); } tags = tags.TrimEnd(','); tags = tags.TrimEnd('.'); ut.EditArticle(Request.QueryString["idnews"].ToString(), title.ToString(), currentUser.UserName.ToString(), filename, txtSummary.Text.ToString().Replace("&", "&"), txtNews.Text.ToString().Replace("&", "&"), ddlcategory.SelectedValue.ToString(), chkComments.Checked, chkPub.Checked, chkHL.Checked, chkSN.Checked, chkPB.Checked, date, tags, chkSS.Checked); Response.Redirect(Page.Request.Url.AbsolutePath.ToString() + "?p=AdminArticles"); } catch { Label1.Text = Label2.Text = GetGlobalResourceObject("language", "InsertvalidDate").ToString(); Label1.Visible = Label2.Visible = true; } } }