protected void Page_Load(object sender, EventArgs e) { Response.Write("<html><head><meta name=\"txtweb-appkey\" content=\"9cf923ac-53bd-4388-85fa-f75bd432ba68\" /></head><body>"); try { hashcode = Request.QueryString["txtweb-mobile"]; Response.Write("Welcome to \"@txtforum\" where you can ask any type of technical/non-technical questions regarding txtweb.<br /><br />" + "<a href='./login.aspx?txtweb-mobile=" + hashcode + "'>@txtforum.login</a> : For login<br /><br />" + "<a href='./new_que.aspx?txtweb-mobile=" + hashcode + "'>@txtforum.ask</a> : For ask new question<br /><br />" + "<a href='./get_que_list.aspx?txtweb-mobile=" + hashcode + "'>@txtforum.que</a> : Get recent questions list<br /><br />" + "<a href='./get_quelist_me.aspx?txtweb-mobile=" + hashcode + "'>@txtforum.my.que</a> : Get questions asked by you<br /><br />" + "<a href='./quelist_myans.aspx?txtweb-mobile=" + hashcode + "'>@txtforum.my.ans</a> : Get questions list in which you gave the answers<br /><br />"); } catch { //display error message Blogic ob = new Blogic(); Response.Write(ob.error_msg()); ob.CloseConnection(); } Response.Write("</body></html>"); }
protected void Page_Load(object sender, EventArgs e) { Response.Write("<html><head><meta name=\"txtweb-appkey\" content=\"9cf923ac-53bd-4388-85fa-f75bd432ba68\" /></head><body>"); try { string query, hashcode, name; hashcode = Request.QueryString["hashcode"]; name = Request.QueryString["txtweb-message"]; if (Request.QueryString["type"] == "firstTime") //for first time user.... { query = string.Format("insert into user_info (hashcode,name) values (@hashcode,@name)"); Blogic ob = new Blogic(); SqlCommand cmd = ob.getCMD(query); cmd.Parameters.AddWithValue("@hashcode", hashcode); cmd.Parameters.AddWithValue("@name", name); cmd.ExecuteNonQuery(); Response.Write("Congratulation, you are successfully logged in..."); } else // if user is already exist, so update his/her name { query = string.Format("update user_info set name=@name where hashcode=@hashcode"); Blogic ob = new Blogic(); SqlCommand cmd = ob.getCMD(query); cmd.Parameters.AddWithValue("@name", name); cmd.Parameters.AddWithValue("@hashcode", hashcode); cmd.ExecuteNonQuery(); Response.Write("Your name is successfully updated..."); } //provide links for different pages..... Response.Write("<br /><br />Enjoy @txtforum....<br />" + "<a href='./login.aspx?txtweb-mobile=" + hashcode + "'>@txtforum.login</a> : For login<br />" + "<a href='./new_que.aspx?txtweb-mobile=" + hashcode + "'>@txtforum.ask</a> : For ask new question<br />" + "<a href='./get_que_list.aspx?txtweb-mobile=" + hashcode + "'>@txtforum.que</a> : Get recent questions list<br />" + "<a href='./get_quelist_me.aspx?txtweb-mobile=" + hashcode + "'>@txtforum.que.me</a> : Get questions asked by you<br />" + "<a href='./quelist_myans.aspx?txtweb-mobile=" + hashcode + "'>@txtforum.ans.me</a> : Get questions list in which you gave the answers<br /><br />"); } catch { Blogic ob = new Blogic(); Response.Write(ob.error_msg()); //error message... ob.CloseConnection(); } Response.Write("</body></html>"); }
protected void Page_Load(object sender, EventArgs e) { Response.Write("<html><head><meta name=\"txtweb-appkey\" content=\"9cf923ac-53bd-4388-85fa-f75bd432ba68\" /></head><body>"); try { que_id = int.Parse(Request.QueryString["que_id"]); hashcode = Request.QueryString["hashcode"]; type = Request.QueryString["type"]; // vote/spam query_type = Request.QueryString["query_type"]; // insert/update switch (query_type) { //execute query according to the condition.... case "insert": query = string.Format("insert into vote_spam (que_id,hashcode,{0}) values ({1},'{2}','{3}')", type, que_id, hashcode, "True"); break; case "update": query = string.Format("update vote_spam set {0}='True' where que_id={1} and hashcode='{2}'", type, que_id, hashcode); break; } ob = new Blogic(); cmd = ob.getCMD(query); cmd.ExecuteNonQuery(); //increase vote/spam by 1, in que_list table in db.... query = string.Format("update que_list set {0}={0}+1 where que_id={1}", type, que_id); cmd = ob.getCMD(query); cmd.ExecuteNonQuery(); if (type == "vote") { Response.Write("Thank you, your vote is successfully submitted.... :)"); } else { Response.Write("Thank you, your spam is considered...."); } } catch { ob = new Blogic(); Response.Write(ob.error_msg()); ob.CloseConnection(); } Response.Write("</body></html>"); }
protected void Page_Load(object sender, EventArgs e) { Response.Write("<html><head><meta name=\"txtweb-appkey\" content=\"9cf923ac-53bd-4388-85fa-f75bd432ba68\" /></head><body>"); try { string hashcode = Request.QueryString["txtweb-mobile"]; query = string.Format("select name from user_info where hashcode=@hashcode"); Blogic ob = new Blogic(); SqlCommand cmd = ob.getCMD(query); cmd.Parameters.AddWithValue("@hashcode", hashcode); SqlDataReader dr = cmd.ExecuteReader(); if (!dr.Read()) //first time user { Response.Write("Create your account.....<br /><br />" +"<form action='./login2.aspx' class='txtweb-form' method='get'>" + "<input type='hidden' name='type' value='firstTime' />" + "<input type='hidden' name='hashcode' value='" + hashcode + "' />" + "Your name<input type='text' name='txtweb-message' />" + "<input type='submit' value='submit' /></form><br /><br />" +"Note: Your mobile hashcode is considered as password, so you don't need any password."); } else //if user is already register, so update his/her name.... { Response.Write("Welcome " + dr.GetValue(0).ToString() + ",<br /><br />" + "For change your name<br /><br />" + " <form action='./login2.aspx' class='txtweb-form' method='get'>" + "<input type='hidden' name='hashcode' value='" + hashcode + "' />" + "Your name<input type='text' name='txtweb-message' />" + "<input type='submit' value='submit' /></form> "); } } catch { Blogic ob = new Blogic(); Response.Write(ob.error_msg()); //print error_message... ob.CloseConnection(); } Response.Write("</body></html>"); }
protected void Page_Load(object sender, EventArgs e) { Response.Write("<html><head><meta name=\"txtweb-appkey\" content=\"9cf923ac-53bd-4388-85fa-f75bd432ba68\" /></head><body>"); try { string hashcode = Request.QueryString["txtweb-mobile"]; query = string.Format("select name from user_info where hashcode=@hashcode"); Blogic ob = new Blogic(); SqlCommand cmd = ob.getCMD(query); cmd.Parameters.AddWithValue("@hashcode", hashcode); SqlDataReader dr = cmd.ExecuteReader(); if (!dr.Read()) //first time user { Response.Write("Create your account.....<br /><br />" + "<form action='./login2.aspx' class='txtweb-form' method='get'>" + "<input type='hidden' name='type' value='firstTime' />" + "<input type='hidden' name='hashcode' value='" + hashcode + "' />" + "Your name<input type='text' name='txtweb-message' />" + "<input type='submit' value='submit' /></form><br /><br />" + "Note: Your mobile hashcode is considered as password, so you don't need any password."); } else //if user is already register, so update his/her name.... { Response.Write("Welcome " + dr.GetValue(0).ToString() + ",<br /><br />" + "For change your name<br /><br />" + " <form action='./login2.aspx' class='txtweb-form' method='get'>" + "<input type='hidden' name='hashcode' value='" + hashcode + "' />" + "Your name<input type='text' name='txtweb-message' />" + "<input type='submit' value='submit' /></form> "); } } catch { Blogic ob = new Blogic(); Response.Write(ob.error_msg()); //print error_message... ob.CloseConnection(); } Response.Write("</body></html>"); }
protected void Page_Load(object sender, EventArgs e) { Response.Write("<html><head><meta name=\"txtweb-appkey\" content=\"9cf923ac-53bd-4388-85fa-f75bd432ba68\" /></head><body>"); try { string hashcode = Request.QueryString["txtweb-mobile"]; //query for check user is exist or not.. query = string.Format("select name from user_info where hashcode=@hashcode"); ob = new Blogic(); SqlCommand cmd = ob.getCMD(query); cmd.Parameters.AddWithValue("@hashcode", hashcode); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) //if user is exist in database then proceed him/her to ask a question { Response.Write("Ask a new question....<br /><br />" + "Type, #t \"your que title\" #d \"your que description\"<br />" //<your que title> print ni ho rha h + "Use, #e For line break or enter<br />" + "Note: #t and #d both are very important, you can't submit question without it.<br /><br />"); Response.Write("For asking a new question....<br /><br />" + "<form action='./new_que2.aspx' method='get' class='txtweb-form'>" + "<input type='hidden' name='hashcode' value='" + hashcode + "' />" + "Title and Description<input type='text' name='txtweb-message' />" + "<input type='submit' value='Submit' />"); } else //if user is not exist in database, then redirect him/her to login.aspx { Response.Redirect("./login.aspx?txtweb-mobile=" + hashcode); } } catch { ob = new Blogic(); Response.Write(ob.error_msg()); ob.CloseConnection(); } Response.Write("</body></html>"); }
protected void Page_Load(object sender, EventArgs e) { Response.Write("<html><head><meta name=\"txtweb-appkey\" content=\"9cf923ac-53bd-4388-85fa-f75bd432ba68\" /></head><body>"); try { //get answer from que_desc.aspx... ans = Request.QueryString["txtweb-message"]; ans = ans.Replace("#E", "#e"); ans = ans.Replace("#e", "<br />"); que_id = int.Parse(Request.QueryString["que_id"]); hashcode = Request.QueryString["hashcode"]; //get date & time, according to India.. TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"); DateTime dt = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, tzi); //query for insert answer in our database.. query = string.Format("insert into ans_list (que_id,ans_desc,sub_by,date) values ({0},@answer,'{1}','{2}')", que_id, hashcode, dt); ob = new Blogic(); SqlCommand cmd = ob.getCMD(query); cmd.Parameters.AddWithValue("@answer", ans); cmd.ExecuteNonQuery(); Response.Redirect("que_desc.aspx?que_id=" + que_id + "&hashcode=" + hashcode); ob.CloseConnection(); } catch { ob = new Blogic(); Response.Write(ob.error_msg()); ob.CloseConnection(); } Response.Write("</body></html>"); }
Blogic ob; //declare an object "ob" of Blogic class, //which define in Blogin.cs file protected void Page_Load(object sender, EventArgs e) { Response.Write("<html><head><meta name=\"txtweb-appkey\" content=\"9cf923ac-53bd-4388-85fa-f75bd432ba68\" /></head><body>"); try { if (Request.QueryString["next_index"] == null) { hashcode = Request.QueryString["txtweb-mobile"]; } else //execute when user click on "More" link.. { hashcode = Request.QueryString["hashcode"]; } //check either user is already exist or not, if he/she is not exist so redirect to him/her to login.aspx.... query = string.Format("select name from user_info where hashcode=@hashcode"); //initialize an object "ob" of Blogic class, which //we declare in Blogic.cs file ob = new Blogic(); cmd = ob.getCMD(query); cmd.Parameters.AddWithValue("@hashcode", hashcode); dr = cmd.ExecuteReader(); if (dr.Read()) //if user is exist, display the que_list to him/her { if (Request.QueryString["next_index"] == null) { hashcode = Request.QueryString["txtweb-mobile"]; index = 1; } else { hashcode = Request.QueryString["hashcode"]; index = int.Parse(Request.QueryString["next_index"]); } //query for select recent que_list..... query = string.Format("select * from (select row_number() over(order by sub_date desc) as row_num,que_id,title,vote,spam from que_list) as list where row_num>={0} and row_num<={1}", index, index + 4); ob = new Blogic(); cmd = ob.getCMD(query); dr = cmd.ExecuteReader(); while (dr.Read()) { Response.Write("<a href='./que_desc.aspx?que_id=" + dr.GetValue(1).ToString() + "&hashcode=" + hashcode + "' >" + dr.GetValue(2).ToString() + "</a><br />" //que. title + dr.GetValue(3).ToString() + " votes, " //number of votes + dr.GetValue(4).ToString() + " spam<br /><br />"); //number of spam } next_index = index + 5; Response.Write("<a href='./get_que_list.aspx?next_index=" + next_index + "&hashcode=" + hashcode + "' class='txtweb-menu-for' accesskey='M' '>More</a>"); } else { Response.Redirect("./login.aspx?txtweb-mobile=" + hashcode); } } catch { //display error message... Response.Write(ob.error_msg()); } //close the connection ob.CloseConnection(); Response.Write("</body></html>"); }
protected void Page_Load(object sender, EventArgs e) { Response.Write("<html><head><meta name=\"txtweb-appkey\" content=\"9cf923ac-53bd-4388-85fa-f75bd432ba68\" /></head><body>"); try { hashcode = Request.QueryString["hashcode"]; que_id = int.Parse(Request.QueryString["que_id"]); /**** PART-1 ****/ //query for que_description.... query = string.Format("select que_list.title,que_list.que_desc,user_info.name from que_list join user_info on que_list.sub_by=user_info.hashcode where que_list.que_id={0}", que_id); ob = new Blogic(); cmd = ob.getCMD(query); dr = cmd.ExecuteReader(); if (dr.Read()) { //print que_description... Response.Write("Title: " + dr.GetValue(0).ToString() + "<br /><br />Description: " + dr.GetValue(1).ToString() + "<br />By: " + dr.GetValue(2).ToString()+"<br /><br />"); } /***********************/ /**** PART-2 ****/ //query for check vote/spam...... query_for_vs = string.Format("select vote,spam from vote_spam where que_id={0} and hashcode='{1}'", que_id, hashcode); Blogic ob_vs = new Blogic(); SqlCommand command = ob_vs.getCMD(query_for_vs); SqlDataReader reader = command.ExecuteReader(); //print link for vote/spam..... if (reader.Read()) { if (reader.GetValue(0).ToString() == "False") { Response.Write("<a href='./vote_spam.aspx?que_id=" + que_id + "&hashcode=" + hashcode + "&query_type=update&type=vote' >Vote up this question<br /></a>"); } if (reader.GetValue(1).ToString() == "False") { Response.Write("<a href='./vote_spam.aspx?que_id=" + que_id + "&hashcode=" + hashcode + "&query_type=update&type=spam'>Spam this question</a>"); } } else { Response.Write("<a href='./vote_spam.aspx?que_id="+que_id+"&hashcode="+hashcode+"&query_type=insert&type=vote'>Vote up this question<br /></a>"); Response.Write("<a href='./vote_spam.aspx?que_id=" + que_id + "&hashcode=" + hashcode + "&query_type=insert&type=spam'>Spam this question</a>"); } Response.Write("<br />*****"); ob_vs.CloseConnection(); ob.CloseConnection(); /***********************/ /**** PART-3 ****/ //query for print answers....... query = string.Format("select ans_list.ans_desc,user_info.name from ans_list join user_info on ans_list.sub_by=user_info.hashcode where que_id={0} order by ans_list.date", que_id); cmd = ob.getCMD(query); dr = cmd.ExecuteReader(); Response.Write("<br /><br />Answers....<br /><br />"); while (dr.Read()) { //print answers Response.Write(dr.GetValue(0).ToString() +"<br />By: "+dr.GetValue(1).ToString()+"<br /><br />"); } ob.CloseConnection(); /***********************/ /**** PART-4 ****/ //Take input for answer.... Response.Write("<br /><br />Give your answer....<br />(Use #e for line break or enter)<br />" + "<form action='./que_desc2.aspx' class='txtweb-form' method='get'>" + "Your answer<input type='text' name='txtweb-message' />" + "<input type='hidden' name='hashcode' value='" + hashcode + "' />" + "<input type='hidden' name='que_id' value='" + que_id + "' />" + "<input type='submit' value='submit' /></form>"); } /***********************/ catch { ob = new Blogic(); Response.Write(ob.error_msg()); //error msg.... ob.CloseConnection(); } Response.Write("</body></html>"); }
protected void Page_Load(object sender, EventArgs e) { Response.Write("<html><head><meta name=\"txtweb-appkey\" content=\"9cf923ac-53bd-4388-85fa-f75bd432ba68\" /></head><body>"); try { if (Request.QueryString["next_index"] == null) { hashcode = Request.QueryString["txtweb-mobile"]; } else { hashcode = Request.QueryString["hashcode"]; } //check either user is already exist or not, if he/she is not exist so redirect to him/her to login.aspx.... query = string.Format("select name from user_info where hashcode=@hashcode"); ob = new Blogic(); cmd = ob.getCMD(query); cmd.Parameters.AddWithValue("@hashcode", hashcode); dr = cmd.ExecuteReader(); if (dr.Read()) //if user is exist, display the que_list to him/her { if (Request.QueryString["next_index"] == null) { hashcode = Request.QueryString["txtweb-mobile"]; index = 1; } else { hashcode = Request.QueryString["hashcode"]; index = int.Parse(Request.QueryString["next_index"]); } //query for display recent questions in which user gave the answers..... query = string.Format("select * from (select row_number() over(order by ans_list.date desc) as row_num,ans_list.que_id,que_list.title,que_list.vote,que_list.spam from ans_list join que_list on ans_list.que_id=que_list.que_id where ans_list.sub_by='{0}') as list where row_num>={1} and row_num<={2}", hashcode, index, index + 4); ob = new Blogic(); cmd = ob.getCMD(query); dr = cmd.ExecuteReader(); while (dr.Read()) { Response.Write("<a href='./que_desc.aspx?que_id=" + dr.GetValue(1).ToString() + "&hashcode=" + hashcode + "' >" + dr.GetValue(2).ToString() + "</a><br />" //que_title + dr.GetValue(3).ToString() + " votes, " //number of votes + dr.GetValue(4).ToString() + " spam<br /><br />"); //number of spam } next_index = index + 5; Response.Write("<a href='./quelist_myans.aspx?next_index=" + next_index + "&hashcode=" + hashcode + "' class='txtweb-menu-for' accesskey='M''>More</a>"); } else { Response.Redirect("./login.aspx?txtweb-mobile=" + hashcode); } } catch { ob = new Blogic(); Response.Write(ob.error_msg()); //error msg... ob.CloseConnection(); } Response.Write("</body></html>"); }
protected void Page_Load(object sender, EventArgs e) { Response.Write("<html><head><meta name=\"txtweb-appkey\" content=\"9cf923ac-53bd-4388-85fa-f75bd432ba68\" /></head><body>"); try { hashcode = Request.QueryString["hashcode"]; full_msg = Request.QueryString["txtweb-message"]; full_msg = full_msg.Replace("#T", "#t"); full_msg = full_msg.Replace("#D", "#d"); full_msg = full_msg.Replace("#E", "#e"); //separate the question title from full_msg.... title = full_msg.Substring(full_msg.IndexOf("#t") + 2, full_msg.IndexOf("#d") - (full_msg.IndexOf("#t") + 2)); //get title of the que. title = title.Replace("#e", " "); //separate the question description from full_msg.... desc = full_msg.Substring(full_msg.IndexOf("#d") + 2); // get description of the que. desc = desc.Replace("#e", "<br />"); //insert current date & time according to India... TimeZoneInfo tji = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"); DateTime dt = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, tji); //insert question in db..... query = string.Format("insert into que_list (title,que_desc,sub_by,sub_date) values (@title,@desc,@hashcode,'{0}')", dt); ob = new Blogic(); cmd = ob.getCMD(query); cmd.Parameters.AddWithValue("@title", title); cmd.Parameters.AddWithValue("@desc", desc); cmd.Parameters.AddWithValue("@hashcode", hashcode); cmd.ExecuteNonQuery(); ob.CloseConnection(); //print the question description query = string.Format("select top 1 que_id from que_list where sub_by='{0}' order by sub_date desc", hashcode); //query for select latest question ob = new Blogic(); //asked by user.... cmd = ob.getCMD(query); dr = cmd.ExecuteReader(); if (dr.Read()) { Response.Redirect("./que_desc.aspx?que_id=" + dr.GetValue(0).ToString() + "&hashcode=" + hashcode); } ob.CloseConnection(); } catch { //error message, if user doesn't ask question in a proper format... Response.Write("Please type in a proper format....<br /><br />" + "Type, #t \"your que title\" #d \"your que description\"<br />" + "Use, #e For line break or enter<br />" + "Note: #t and #d both are very important, you can't submit question without it.<br /><br />"); Response.Write("For asking a new question....<br /><br />" + "<form action='./new_que2.aspx' method='get' class='txtweb-form'>" + "<input type='hidden' name='hashcode' value='" + hashcode + "' />" + "Title and Description<input type='text' name='txtweb-message' />" + "<input type='submit' value='Submit' />"); } Response.Write("</body></html>"); }
protected void Page_Load(object sender, EventArgs e) { Response.Write("<html><head><meta name=\"txtweb-appkey\" content=\"9cf923ac-53bd-4388-85fa-f75bd432ba68\" /></head><body>"); try { hashcode = Request.QueryString["hashcode"]; que_id = int.Parse(Request.QueryString["que_id"]); /**** PART-1 ****/ //query for que_description.... query = string.Format("select que_list.title,que_list.que_desc,user_info.name from que_list join user_info on que_list.sub_by=user_info.hashcode where que_list.que_id={0}", que_id); ob = new Blogic(); cmd = ob.getCMD(query); dr = cmd.ExecuteReader(); if (dr.Read()) { //print que_description... Response.Write("Title: " + dr.GetValue(0).ToString() + "<br /><br />Description: " + dr.GetValue(1).ToString() + "<br />By: " + dr.GetValue(2).ToString() + "<br /><br />"); } /***********************/ /**** PART-2 ****/ //query for check vote/spam...... query_for_vs = string.Format("select vote,spam from vote_spam where que_id={0} and hashcode='{1}'", que_id, hashcode); Blogic ob_vs = new Blogic(); SqlCommand command = ob_vs.getCMD(query_for_vs); SqlDataReader reader = command.ExecuteReader(); //print link for vote/spam..... if (reader.Read()) { if (reader.GetValue(0).ToString() == "False") { Response.Write("<a href='./vote_spam.aspx?que_id=" + que_id + "&hashcode=" + hashcode + "&query_type=update&type=vote' >Vote up this question<br /></a>"); } if (reader.GetValue(1).ToString() == "False") { Response.Write("<a href='./vote_spam.aspx?que_id=" + que_id + "&hashcode=" + hashcode + "&query_type=update&type=spam'>Spam this question</a>"); } } else { Response.Write("<a href='./vote_spam.aspx?que_id=" + que_id + "&hashcode=" + hashcode + "&query_type=insert&type=vote'>Vote up this question<br /></a>"); Response.Write("<a href='./vote_spam.aspx?que_id=" + que_id + "&hashcode=" + hashcode + "&query_type=insert&type=spam'>Spam this question</a>"); } Response.Write("<br />*****"); ob_vs.CloseConnection(); ob.CloseConnection(); /***********************/ /**** PART-3 ****/ //query for print answers....... query = string.Format("select ans_list.ans_desc,user_info.name from ans_list join user_info on ans_list.sub_by=user_info.hashcode where que_id={0} order by ans_list.date", que_id); cmd = ob.getCMD(query); dr = cmd.ExecuteReader(); Response.Write("<br /><br />Answers....<br /><br />"); while (dr.Read()) { //print answers Response.Write(dr.GetValue(0).ToString() + "<br />By: " + dr.GetValue(1).ToString() + "<br /><br />"); } ob.CloseConnection(); /***********************/ /**** PART-4 ****/ //Take input for answer.... Response.Write("<br /><br />Give your answer....<br />(Use #e for line break or enter)<br />" + "<form action='./que_desc2.aspx' class='txtweb-form' method='get'>" + "Your answer<input type='text' name='txtweb-message' />" + "<input type='hidden' name='hashcode' value='" + hashcode + "' />" + "<input type='hidden' name='que_id' value='" + que_id + "' />" + "<input type='submit' value='submit' /></form>"); } /***********************/ catch { ob = new Blogic(); Response.Write(ob.error_msg()); //error msg.... ob.CloseConnection(); } Response.Write("</body></html>"); }