protected void Page_Load(object sender, EventArgs e) { if (Session["email"] == null) { Response.Redirect("NoSession.aspx"); } int id = int.Parse(Request.Form["id"]); SqlConnection conn = new SqlConnection(Connfigger.GetConnectionString()); conn.Open(); SqlCommand command; SqlParameter param; command = new SqlCommand("catalog_item_delete", conn); command.CommandType = CommandType.StoredProcedure; param = new SqlParameter(); param.ParameterName = "@id"; param.SqlDbType = SqlDbType.Int; param.Value = id; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@email"; param.SqlDbType = SqlDbType.NVarChar; param.Value = (string)Session["email"]; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); command.ExecuteNonQuery(); conn.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["email"] == null) { Response.Redirect("NoSession.aspx"); } if (Request.QueryString["id"] != null) { this.id = int.Parse(Request.QueryString["id"]); } if (this.id == 0) { string objLang = ""; if (Request.QueryString["objLang"] != null) { objLang = Request.QueryString["objLang"]; } this.dic.LoadXml("<dictionary prominence='5' loginRequired='0' tcRequired='0'><objLang code='" + objLang + "'/><dicType code=''/><metaLang code='" + objLang + "'/><title lang='" + objLang + "'/><homepage/></dictionary>"); } else { SqlConnection conn = new SqlConnection(Connfigger.GetConnectionString()); conn.Open(); SqlCommand command; SqlParameter param; command = new SqlCommand("catalog_item_get", conn); command.CommandType = CommandType.StoredProcedure; param = new SqlParameter(); param.ParameterName = "@id"; param.SqlDbType = SqlDbType.Int; param.Value = this.id; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { this.dic.LoadXml((string)reader["Xml"]); //remove history: XmlNodeList histNodes = this.dic.SelectNodes("//history"); foreach (XmlNode n in histNodes) { n.ParentNode.RemoveChild(n); } } reader.Close(); conn.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Form.Count > 0) { if (Request.Form["email"] != "") { this.email = Request.Form["email"]; } if (Request.Form["password"] != "") { this.password = Request.Form["password"]; } SqlConnection conn = new SqlConnection(Connfigger.GetConnectionString()); conn.Open(); SqlCommand command; SqlParameter param; command = new SqlCommand("user_login", conn); command.CommandType = CommandType.StoredProcedure; param = new SqlParameter(); param.ParameterName = "@email"; param.SqlDbType = SqlDbType.NVarChar; param.Value = this.email; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@password"; param.SqlDbType = SqlDbType.NVarChar; param.Value = this.password; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { this.stage = "success"; Session.Add("email", (string)reader["Email"]); Session.Add("isAdmin", (bool)reader["IsAdmin"]); } else { this.stage = "error"; } reader.Close(); conn.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["email"] == null) { Response.Redirect("NoSession.aspx"); } XmlDocument dic = new XmlDocument(); dic.LoadXml((string)Request.Form["xml"]); int parentID = 0; int.TryParse(dic.DocumentElement.GetAttribute("parentID"), out parentID); SqlConnection conn = new SqlConnection(Connfigger.GetConnectionString()); conn.Open(); SqlCommand command; SqlParameter param; command = new SqlCommand("catalog_item_save", conn); command.CommandType = CommandType.StoredProcedure; param = new SqlParameter(); param.ParameterName = "@xml"; param.SqlDbType = SqlDbType.Xml; param.Value = dic.DocumentElement.OuterXml; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); if (parentID > 0) { param = new SqlParameter(); param.ParameterName = "@parentID"; param.SqlDbType = SqlDbType.Int; param.Value = parentID; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); } param = new SqlParameter(); param.ParameterName = "@email"; param.SqlDbType = SqlDbType.NVarChar; param.Value = (string)Session["email"]; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); command.ExecuteNonQuery(); conn.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["email"] == null) { Response.Redirect("NoSession.aspx"); } if (!(bool)Session["IsAdmin"]) { Response.Redirect("NoSession.aspx"); } XmlDocument doc = new XmlDocument(); doc.LoadXml((string)Request.Form["xml"]); SqlConnection conn = new SqlConnection(Connfigger.GetConnectionString()); conn.Open(); SqlCommand command; SqlParameter param; command = new SqlCommand("admin_save", conn); command.CommandType = CommandType.StoredProcedure; param = new SqlParameter(); param.ParameterName = "@xml"; param.SqlDbType = SqlDbType.Xml; param.Value = doc.DocumentElement.OuterXml; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@currentUser"; param.SqlDbType = SqlDbType.NVarChar; param.Value = (string)Session["email"]; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); command.ExecuteNonQuery(); conn.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["email"] == null) { Response.Redirect("NoSession.aspx"); } if (!(bool)Session["IsAdmin"]) { Response.Redirect("NoSession.aspx"); } SqlConnection conn = new SqlConnection(Connfigger.GetConnectionString()); conn.Open(); SqlCommand command; SqlParameter param; command = new SqlCommand("admin_get", conn); command.CommandType = CommandType.StoredProcedure; param = new SqlParameter(); param.ParameterName = "@currentUser"; param.SqlDbType = SqlDbType.NVarChar; param.Value = (string)Session["email"]; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { this.doc.LoadXml((string)reader["Xml"]); } reader.Close(); conn.Close(); }
protected void Page_Load(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(Connfigger.GetConnectionString()); conn.Open(); SqlCommand command; SqlParameter param; command = new SqlCommand("catalog_all", conn); command.CommandType = CommandType.StoredProcedure; SqlDataReader reader = command.ExecuteReader(); List <int> ids = new List <int>(); while (reader.Read()) //Read catalog items: { XmlDocument doc = new XmlDocument(); doc.LoadXml((string)reader["Xml"]); doc.DocumentElement.SetAttribute("id", ((int)reader["ID"]).ToString()); if (reader["ParentID"] != DBNull.Value) { doc.DocumentElement.SetAttribute("parentID", ((int)reader["ParentID"]).ToString()); } this.dictionaries.Add(doc); ids.Add((int)reader["ID"]); //remove history: XmlNodeList histNodes = doc.SelectNodes("//history"); foreach (XmlNode n in histNodes) { n.ParentNode.RemoveChild(n); } } reader.Close(); conn.Close(); //Remove dictionaries whose parent is also here: List <XmlDocument> temp = new List <XmlDocument>(); foreach (XmlDocument xmlDic in this.dictionaries) { int parentID = int.Parse(this.getXmlValue(xmlDic, "/dictionary/@parentID", "0")); if (!ids.Contains(parentID)) { temp.Add(xmlDic); } } this.dictionaries = temp; Response.ContentType = "text/xml"; //Response.AppendHeader("Content-Disposition", "attachment; filename=catalog.xml"); Response.Write("<dictionaries>\r\n\r\n"); Response.Write("<!--Exported from the European Dictionary Portal on " + DateTime.Now.ToString("yyyy-MM-dd") + "\r\n"); Response.Write("Available under Open Database Licence, http://opendatacommons.org/licenses/odbl/summary/\r\n"); Response.Write("If you use this, do not forget to attribute the European Dictionary Portal, http://www.dictionaryportal.eu/-->\r\n\r\n"); foreach (XmlDocument xmlDic in this.dictionaries) { Response.Write(PrettyPrintXml(xmlDic.DocumentElement.OuterXml) + "\r\n\r\n"); } Response.Write("</dictionaries>\r\n"); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { this.pageMode = (string)Context.Items["pageMode"]; this.uilang = (string)Context.Items["uilang"]; this.metadata = new Metadata(this.uilang, Server); if (Request.QueryString["objLang"] != null) { this.objLang = Request.QueryString["objLang"]; } if (Request.QueryString["dicType"] != null) { this.dicType = Request.QueryString["dicType"]; } if (Request.QueryString["metaLang"] != null) { this.metaLang = Request.QueryString["metaLang"]; } if (Request.QueryString["txt"] != null) { this.txt = Request.QueryString["txt"]; } if (pageMode == "catalog") { if (this.objLang == "x" && this.metaLang == "x" && this.dicType == "x") { this.pageMode = "catalogHome"; } else { this.pageMode = "catalogListing"; } } SqlConnection conn = new SqlConnection(Connfigger.GetConnectionString()); conn.Open(); SqlCommand command; SqlParameter param; command = new SqlCommand("catalog_list", conn); command.CommandType = CommandType.StoredProcedure; param = new SqlParameter(); param.ParameterName = "@pageMode"; param.SqlDbType = SqlDbType.NVarChar; param.Value = this.pageMode; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@objLang"; param.SqlDbType = SqlDbType.NVarChar; param.Value = this.objLang; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@dicType"; param.SqlDbType = SqlDbType.NVarChar; param.Value = this.dicType; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@metaLang"; param.SqlDbType = SqlDbType.NVarChar; param.Value = this.metaLang; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); if (this.pageMode == "permalink") { param = new SqlParameter(); param.ParameterName = "@dictID"; param.SqlDbType = SqlDbType.Int; param.Value = (int)Context.Items["dictID"]; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); } SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) //read objLangs: { Hierarchy h = new Hierarchy(); h.objLang = (string)reader["ObjLang"]; h.count = (int)reader["DictCount"]; this.hierarchies.Add(h); this.objLangs.Add(h.objLang); } reader.NextResult(); while (reader.Read()) //read searchable objLangs: { string code = (string)reader["SearchableObjLang"]; this.searchableObjLangs.Add(code); } reader.NextResult(); while (reader.Read()) //read metaLangs: { string code = (string)reader["MetaLang"]; this.metaLangs.Add(code); } reader.NextResult(); while (reader.Read()) //read objLangs-dicType combos: { string objLang = (string)reader["ObjLang"]; foreach (Hierarchy h in this.hierarchies) { if (h.objLang == objLang) { h.dicTypes.Add((string)reader["DicType"], (int)reader["DictCount"]); break; } } } reader.NextResult(); while (reader.Read()) //read objLangs-metaLang combos: { string objLang = (string)reader["ObjLang"]; foreach (Hierarchy h in this.hierarchies) { if (h.objLang == objLang) { h.metaLangs.Add((string)reader["MetaLang"], (int)reader["DictCount"]); break; } } } reader.NextResult(); List <int> ids = new List <int>(); while (reader.Read()) //Read catalog items: { XmlDocument doc = new XmlDocument(); doc.LoadXml((string)reader["Xml"]); doc.DocumentElement.SetAttribute("id", ((int)reader["ID"]).ToString()); if (reader["ParentID"] != DBNull.Value) { doc.DocumentElement.SetAttribute("parentID", ((int)reader["ParentID"]).ToString()); } this.dictionaries.Add(doc); ids.Add((int)reader["ID"]); } reader.Close(); conn.Close(); this.dictionariesCount = this.dictionaries.Count; //if(this.pageMode == "catalogListing") { // //Remove dictionaries whose parent is also here: // this.dictionariesCount = this.dictionaries.Count; // List<XmlDocument> temp = new List<XmlDocument>(); // foreach(XmlDocument xmlDic in this.dictionaries) { // int parentID = int.Parse(this.getXmlValue(xmlDic, "/dictionary/@parentID", "0")); // if(!ids.Contains(parentID)) temp.Add(xmlDic); // } // this.dictionaries = temp; //} if (this.pageMode == "permalink" && this.dictionaries.Count == 0) { Response.Redirect("/" + this.uilang + "/"); } if (this.pageMode == "permalink" && this.dictionaries.Count > 0) { this.permalinkTitle = this.getInnerXml(this.dictionaries[0], "/dictionary/title", ""); this.permalinkTitle = System.Text.RegularExpressions.Regex.Replace(this.permalinkTitle, @"\</[^\>]+\>", ")"); this.permalinkTitle = System.Text.RegularExpressions.Regex.Replace(this.permalinkTitle, @"\<[^\>]+\>", "("); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["uilang"] != null) { this.uilang = Request.QueryString["uilang"]; } if (Request.QueryString["txt"] != null) { this.txt = Request.QueryString["txt"]; } if (Request.QueryString["id"] != null) { this.id = int.Parse(Request.QueryString["id"]); } if (Request.QueryString["index"] != null) { this.index = int.Parse(Request.QueryString["index"]); } SqlConnection conn = new SqlConnection(Connfigger.GetConnectionString()); conn.Open(); SqlCommand command; SqlParameter param; command = new SqlCommand("catalog_item_get", conn); command.CommandType = CommandType.StoredProcedure; param = new SqlParameter(); param.ParameterName = "@id"; param.SqlDbType = SqlDbType.Int; param.Value = this.id; param.Direction = ParameterDirection.Input; command.Parameters.Add(param); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { this.dic.LoadXml((string)reader["Xml"]); } reader.Close(); conn.Close(); this.url = getXmlValue(this.dic, "/dictionary/homepage/text()", ""); if (this.dic.SelectSingleNode("/dictionary/search[" + index + "]") != null) { XmlElement url = (XmlElement)this.dic.SelectSingleNode("/dictionary/search[" + index + "]/searchUrl"); XmlElement el = (XmlElement)url.SelectSingleNode("word"); if (el != null) { XmlText nd = this.dic.CreateTextNode(Server.UrlEncode(this.txt)); el.ParentNode.ReplaceChild(nd, el); } this.url = url.InnerText; foreach (XmlElement pf in this.dic.SelectNodes("/dictionary/search[" + index + "]/postField")) { string name = pf.GetAttribute("name"); string value = pf.GetAttribute("value"); if (!this.postFields.ContainsKey(name)) { this.postFields.Add(name, value); } } } if (this.postFields.Count == 0) //this will be a GET request { Response.Redirect(url); } else //this will be a POST request { this.metadata = new Metadata(this.uilang, Server); } }