protected void Button1_Click(object sender, EventArgs e) { int id = 0; try { string strConn = ConfigurationManager.ConnectionStrings["anmcs"].ToString(); SqlConnection myConnection = new SqlConnection(strConn); SqlCommand myCommand = new SqlCommand(); myCommand.Connection = myConnection; myCommand.CommandText = "SELECT TOP 1 * from anm_Templates ORDER BY Template DESC"; myConnection.Open(); SqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { id = Convert.ToInt32(reader["Template"].ToString()); } myConnection.Close(); string idt = (id + 1).ToString(); FileUpload1.SaveAs(Server.MapPath("~\\css\\css") + idt + ".css"); anm_Utility ut = new anm_Utility(); ut.AddTemplate(TextBox1.Text.ToString(), TextBox2.Text.ToString(), TextBox3.Text.ToString()); } catch (Exception ex) { lblerror.Text = ex.Message; lblerror.Visible = true; } Response.Redirect(Page.Request.Url.AbsolutePath.ToString() + "?p=AdminTemplates"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.IsAuthenticated) { Page.Title = GetGlobalResourceObject("language", "Category") + " " + GetGlobalResourceObject("language", "Settings"); MembershipUser user = Membership.GetUser(); anm_Utility ut = new anm_Utility(); string role = ut.GetRole(user.UserName); if (role != "1") { Response.Redirect(Page.Request.Url.AbsolutePath.ToString() + "?p=Confirm&mes=" + GetGlobalResourceObject("language", "nopermission") + ""); } if (ut.GetSetting("TopMenu") != "") { CheckBox1.Checked = Convert.ToBoolean(ut.GetSetting("TopMenu")); } if (ut.GetSetting("SideMenu") != "") { CheckBox3.Checked = Convert.ToBoolean(ut.GetSetting("SideMenu")); } } else { FormsAuthentication.RedirectToLoginPage(); } } }
protected string LinkCat() { anm_Utility ut = new anm_Utility(); string strConn = ConfigurationManager.ConnectionStrings["anmcs"].ToString(); SqlConnection myConnection = new SqlConnection(strConn); SqlCommand myCommand = new SqlCommand("anm_getMainCategories", myConnection); myCommand.CommandType = CommandType.StoredProcedure; myConnection.Open(); SqlDataReader reader = myCommand.ExecuteReader(); string res = ""; string value = Request.QueryString["title"].ToString(); while (reader.Read()) { string idc = reader["idcategory"].ToString(); string category = reader["category"].ToString(); if (Request.QueryString["type"] != null) { res += "<a href='" + Page.Request.ApplicationPath.ToString() + "/ctg_" + idc + "/search" + Request.QueryString["type"] + "/" + ut.UrlEncode(value) + ".aspx'>" + reader["category"].ToString() + "</a> - "; } else { res += "<a href='" + Page.Request.ApplicationPath.ToString() + "/cat" + idc + "/search/" + ut.UrlEncode(value) + ".aspx'>" + reader["category"].ToString() + "</a> - "; } } myConnection.Close(); return(res); }
protected void ButtonEmail_Click(object sender, EventArgs e) { anm_Utility ut = new anm_Utility(); lblEmail.Text = ut.ChangeEmail(Membership.GetUser(), TextBoxEmail.Text); lblEmail.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { anm_Utility ut = new anm_Utility(); if (ut.GetSetting("OnlineUsers") == "True") { pnlVisitors.Visible = true; int numberOfUsersOnline = Membership.GetNumberOfUsersOnline(); Members.Text = numberOfUsersOnline.ToString(); string totalUsers = Application["OnlineUsers"].ToString(); TotalUsers.Text = totalUsers; int visitors = Convert.ToInt32(totalUsers) - numberOfUsersOnline; if (visitors < 0) { visitors = 0; } Visitors.Text = visitors.ToString(); var onlineUsers = (from a in Membership.GetAllUsers().Cast <MembershipUser>().ToList() where a.IsOnline select a.UserName).ToList(); string users = ""; for (int i = 0; i < onlineUsers.Count; i++) { if (i == 0) { users = onlineUsers[0]; } else { users = users + ", " + onlineUsers[i].Replace("&", "&"); } } OnlineNow.Text = users; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.IsAuthenticated) { Page.Title = GetGlobalResourceObject("language", "Article") + " " + GetGlobalResourceObject("language", "Settings"); MembershipUser user = Membership.GetUser(); anm_Utility ut = new anm_Utility(); string path = Page.Request.Url.AbsolutePath.ToString(); string role = ut.GetRole(user.UserName); if (role != "1") { Response.Redirect(Page.Request.Url.AbsolutePath.ToString() + "?p=Confirm&mes=" + GetGlobalResourceObject("language", "nopermission") + ""); } TextBox1.Text = ut.GetSetting("NumArticles"); if (ut.GetSetting("ApproveArticles") != "") { CheckBox1.Checked = Convert.ToBoolean(ut.GetSetting("ApproveArticles")); } if (ut.GetSetting("Copyright") != "") { CheckBox2.Checked = Convert.ToBoolean(ut.GetSetting("Copyright")); } } else { FormsAuthentication.RedirectToLoginPage(); } } else { Label4.Visible = false; } }
protected string SetleaveClink(string idnews, string title) { anm_Utility ut = new anm_Utility(); HLleaveComment.NavigateUrl = apath + "/articles/" + idnews + "/" + ut.RemoveNonAlfaNumeric(title) + ".aspx#response"; return(""); }
protected void Page_Load(object sender, EventArgs e) { if (Request.IsAuthenticated) { anm_Utility ut = new anm_Utility(); Page.Title = ut.GetSetting("SiteName") + " - " + GetGlobalResourceObject("language", "MyAccount"); MembershipUser user = Membership.GetUser(); if (user == null) { Response.Redirect(Page.Request.Url.AbsolutePath.ToString() + "?p=Confirm&mes=" + GetGlobalResourceObject("language", "nopermission") + ""); } lbl1.Text = "<b>" + user.UserName + "</b> " + GetGlobalResourceObject("language", "confirmdeleteacc"); string pathToCheck = Server.MapPath("~\\images\\Avatars\\") + user.UserName + ".jpg"; if (System.IO.File.Exists(pathToCheck)) { ImgAvatar.ImageUrl = anm_Utility.GetWebAppRoot() + "/images/Avatars/" + user.UserName + ".jpg"; } else { ImgAvatar.ImageUrl = anm_Utility.GetWebAppRoot() + "/images/Avatars/Anonymous.jpg"; } } else { FormsAuthentication.RedirectToLoginPage(); } }
protected string ViewArchiveMenu() { anm_Utility ut = new anm_Utility(); string menu = "";; int InitialYear = Convert.ToInt32(ut.GetSetting("Year")); int InitialMonth = Convert.ToInt32(ut.GetSetting("Month")); if (ut.GetSetting("ArchiveMenu") == "True") { if (ut.GetSetting("ArchiveType") == "2") { menu = ""; } else { if (Request.QueryString["category"] != null) { menu = ut.GetArchiveMenu(InitialYear, InitialMonth, Convert.ToInt32(Request.QueryString["category"].ToString())); } else if (category != "") { menu = ut.GetArchiveMenu(InitialYear, InitialMonth, Convert.ToInt32(category)); } else { menu = ut.GetArchiveMenu(InitialYear, InitialMonth); } } } return(menu); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.IsAuthenticated) { Page.Title = GetGlobalResourceObject("language", "Articles") + " "; string path = Page.Request.Url.AbsolutePath.ToString(); MembershipUser user = Membership.GetUser(); anm_Utility ut = new anm_Utility(); string role = ut.GetRole(user.UserName); if (role == "2") { Response.Redirect(path + "?p=AdminComments"); } else if (role != "1") { Response.Redirect(path + "?p=Confirm&mes=" + GetGlobalResourceObject("language", "nopermission") + ""); } } else { FormsAuthentication.RedirectToLoginPage(); } } }
protected string Edit() { string res = ""; anm_Utility ut = new anm_Utility(); if (Request.IsAuthenticated) { MembershipUser user = Membership.GetUser(); string role = ut.GetRole(user.UserName); if (role == "1") { string idn = ""; if (Request.QueryString["comment"] != null) { idn = ut.GetIdNewsByComment(Request.QueryString["comment"]); } else { idn = Request.QueryString["news"]; } res = "<a href='" + Page.Request.Url.AbsolutePath.ToString() + "?p=EditArticle&idnews=" + idn + "'>|" + GetGlobalResourceObject("language", "Edit") + "|</a>"; } } return(res); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DDcat.Items.Add(new ListItem(GetGlobalResourceObject("language", "All").ToString())); string strConn = ConfigurationManager.ConnectionStrings["anmcs"].ToString(); SqlConnection myConnection = new SqlConnection(strConn); SqlCommand myCommand = new SqlCommand("anm_getCategories", myConnection); myCommand.CommandType = CommandType.StoredProcedure; myConnection.Open(); SqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { string idc = reader["idcategory"].ToString(); string category = reader["category"].ToString(); DDcat.Items.Add(new ListItem(category, idc)); } myConnection.Close(); if (Request.QueryString["category"] != "") { DDcat.SelectedValue = Request.QueryString["category"]; } if (Request.QueryString["page"] != null) { currentpage = Convert.ToInt32(HttpContext.Current.Request.QueryString["page"].ToString()); } anm_Utility ut = new anm_Utility(); Label1.Text = ut.UrlDecode(Request.QueryString["title"].ToString()); LitCat.Text = GetGlobalResourceObject("language", "Category").ToString() + ": "; } }
protected void Delete_Comment(object sender, CommandEventArgs e) { anm_Utility ut = new anm_Utility(); string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ',' }); string idc = commandArgs[0]; string idn = commandArgs[1]; string value = commandArgs[2]; int nc = ut.GetCommentsNews(idn); string strConn = ConfigurationManager.ConnectionStrings["anmcs"].ToString(); SqlConnection myConnection = new SqlConnection(strConn); SqlCommand myCommand = new SqlCommand(); myCommand.Connection = myConnection; myConnection.Open(); myCommand.CommandText = "DELETE FROM anm_Comments WHERE idcomment =" + idc; object accountNumber = myCommand.ExecuteScalar(); myConnection.Close(); if (value == "True") { ut.IcreaseComments(idn, nc - 1); } if (Request.QueryString["idnews"] != null) { Response.Redirect(Page.Request.Url.AbsolutePath.ToString() + "?p=AdminComments&idnews=" + Request.QueryString["idnews"]); } else { Response.Redirect(Page.Request.Url.AbsolutePath.ToString() + "?p=AdminComments&idnews=*"); } }
protected void DeleteComment_Command(object sender, CommandEventArgs e) { try { anm_Utility ut = new anm_Utility(); string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ',' }); string idc = commandArgs[0]; string idn = commandArgs[1]; string value = commandArgs[2]; int nc = ut.GetCommentsNews(idn); string titlenews = ut.GetTitleNews(idn); string strConn = ConfigurationManager.ConnectionStrings["anmcs"].ToString(); SqlConnection myConnection = new SqlConnection(strConn); SqlCommand myCommand = new SqlCommand(); myCommand.Connection = myConnection; myConnection.Open(); myCommand.CommandText = "DELETE FROM anm_Comments WHERE idcomment =" + idc; object accountNumber = myCommand.ExecuteScalar(); myConnection.Close(); if (value == "True") { ut.IcreaseComments(idn, nc - 1); } Response.Redirect(apath + "/articles/" + idn + "/" + ut.RemoveNonAlfaNumeric(titlenews) + ".aspx"); } catch { } }
protected string ViewDate(string date) { DateTime d = Convert.ToDateTime(date); anm_Utility ut = new anm_Utility(); return(ut.GetRelativeTime(d)); }
protected void Button1_Click(object sender, EventArgs e) { anm_Utility ut = new anm_Utility(); try { ut.AddAuthor(DropDownList1.Text.ToString(), DropDownList2.Text.ToString()); } catch { } Response.Redirect(Page.Request.Url.AbsolutePath.ToString() + "?p=AdminAuthors"); }
protected void ButtonEmail_Click(object sender, EventArgs e) { anm_Utility ut = new anm_Utility(); lblalert.Text = ut.ChangeEmail(Membership.GetUser(lblusername.Text.ToString()), TextBoxEmail.Text); lblalert.Visible = true; GridView1.DataBind(); }
protected void Approve_Command(object sender, CommandEventArgs e) { string id = (string)e.CommandArgument; anm_Utility ut = new anm_Utility(); ut.ApproveNews(id); Response.Redirect(Page.Request.Url.AbsolutePath.ToString() + "?p=ApproveArticles"); }
protected void Page_Load(object sender, EventArgs e) { anm_Utility ut = new anm_Utility(); PnlSearch.Visible = Convert.ToBoolean(ut.GetSetting("SearchMenu")); txtSearch.Attributes["onclick"] = "this.value=''"; txtSearch.Attributes.Add("onkeypress", "javascript:if (event.keyCode == 13) __doPostBack('" + btnSearch.UniqueID + "','')"); }
protected string Navigation() { anm_Utility ut = new anm_Utility(); string idn = HttpContext.Current.Request.QueryString["news"]; string titlenews = ut.GetTitleNews(idn); return("<div class='navigationbar'>" + ut.GetNavigation() + titlenews + "</div>"); }
protected void Page_Load(object sender, EventArgs e) { anm_Utility ut = new anm_Utility(); if (ut.GetSetting("LastComments") == "True") { UpdatePanel1.Visible = true; } }
protected void BtnSearchClick(object sender, EventArgs e) { if (txtSearch.Text != "" && txtSearch.Text != GetGlobalResourceObject("language", "searchsite").ToString()) { anm_Utility ut = new anm_Utility(); string value = txtSearch.Text.ToString().Replace("&", "&"); Response.Redirect(anm_Utility.GetWebAppRoot() + "/search/" + ut.UrlEncode(value.Trim()) + ".aspx"); } }
protected void Page_Load(object sender, EventArgs e) { anm_Utility ut = new anm_Utility(); Hlvalidrss.NavigateUrl = "http://feed2.w3.org/check.cgi?url=" + ut.GetSetting("SiteUrl") + "/subscribe.aspx"; if (ut.GetSetting("Validator") != "False") { PnlValidators.Visible = true; } }
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { try { StringBuilder bodyMsg = new StringBuilder(); TextBox username = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName"); TextBox password = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Password"); TextBox email = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email"); CreateUserWizard cuw = (CreateUserWizard)sender; MembershipUser user = Membership.GetUser(cuw.UserName); Guid userID = (Guid)user.ProviderUserKey; anm_Utility ut = new anm_Utility(); string siteurl = (ut.GetSetting("SiteUrl")).Replace("http://", ""); if (ut.GetSetting("EmailConfirm") == "True") { bodyMsg.Append(GetGlobalResourceObject("language", "Thankaccount") + "\n\n" + GetGlobalResourceObject("language", "followlink")); string url = siteurl + Page.Request.Url.AbsolutePath.ToString() + "?p=Activate&ID=" + userID.ToString(); bodyMsg.Append("<br /><br /><a href=" + url + ">" + GetGlobalResourceObject("language", "ActivateAccount") + "</a>"); bodyMsg.Append("<br />"); bodyMsg.Append("<br />"); bodyMsg.Append(GetGlobalResourceObject("language", "linknowork") + " " + url); bodyMsg.Append("<br />"); bodyMsg.Append("<br />"); bodyMsg.AppendFormat("UserName: {0}", username.Text); bodyMsg.Append("<br />"); bodyMsg.AppendFormat("Password: {0}", password.Text); bodyMsg.Append("<br />"); bodyMsg.AppendFormat("Registered Email: {0}", email.Text); NetworkCredential loginInfo = new NetworkCredential(ut.GetSetting("MailUser"), ut.GetSetting("MailPassword")); MailMessage msg = new MailMessage(); msg.From = new MailAddress(ut.GetSetting("SiteEmail")); msg.To.Add(new MailAddress(CreateUserWizard1.Email)); msg.Subject = GetGlobalResourceObject("language", "AccountInformation").ToString(); msg.Body = bodyMsg.ToString(); msg.IsBodyHtml = true; SmtpClient client = new SmtpClient(ut.GetSetting("smtpserver"), Convert.ToInt32(ut.GetSetting("port"))); client.Credentials = loginInfo; client.Send(msg); Response.Redirect(Page.Request.Url.AbsolutePath.ToString() + "?p=confirm&mes=" + GetGlobalResourceObject("language", "Registrationcompleted") + " " + GetGlobalResourceObject("language", "checkemail") + ""); } else { Response.Redirect(Page.Request.Url.AbsolutePath.ToString() + "?p=confirm&mes=" + GetGlobalResourceObject("language", "Registrationcompleted") + ""); } } catch (Exception ex) { throw ex; } }
protected string ViewMenu() { anm_Utility ut = new anm_Utility(); string menu = ""; if (ut.GetSetting("TopMenu") == "True") { menu = ut.GetMenu(); } return(menu); }
protected string GetNcom(string idn, string c, string nc) { anm_Utility ut = new anm_Utility(); string res = ""; if (c == "True") { res = GetGlobalResourceObject("language", "comments") + ": " + nc; } return(res); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { anm_Utility ut = new anm_Utility(); Login1.DestinationPageUrl = Page.Request.Url.AbsolutePath.ToString(); HyperLink1.NavigateUrl = Page.Request.Url.AbsolutePath.ToString() + "?p=PasswordRecovery"; HyperLink2.NavigateUrl = Page.Request.Url.AbsolutePath.ToString() + "?p=NewUser"; Page.Title = ut.GetSetting("SiteName") + " - Login"; } }
protected string Comments(string idn, string c, string nc, string title) { string res = ""; anm_Utility ut = new anm_Utility(); if (c == "True") { res = "<a href='" + apath + "/articles/" + idn + "/" + ut.RemoveNonAlfaNumeric(title) + ".aspx#comments' class='imgcomment' rel='nofollow'> </a><a href='" + apath + "/articles/" + idn + "/" + ut.RemoveNonAlfaNumeric(title) + ".aspx#comments' class='comments'>" + GetGlobalResourceObject("language", "Comments") + " (" + nc + ")</a>"; } return(res); }
protected string HomeSlideshow() { if (Request.QueryString["tag"] == null && Request.QueryString["author"] == null && Request.QueryString["category"] == null && Request.QueryString["year"] == null && Request.QueryString["month"] == null && Request.QueryString["page"] == null) { anm_Utility ut = new anm_Utility(); return(ut.HomeSlideshow()); } else { return(""); } }
protected void ChangeFather(object sender, CommandEventArgs e) { anm_Utility ut = new anm_Utility(); string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ',' }); String idcategory = commandArgs[0]; string idfather = commandArgs[1]; lblcfc.Visible = DdlFatherCat.Visible = BtnFatherCat.Visible = true; lblidc.Text = idcategory; Label1.Visible = false; }