TechEthical CEHP

Current Path : G:/PleskVhosts/megamind.net.in/careercentre360.com/admin/
Upload File :
Current File : G:/PleskVhosts/megamind.net.in/careercentre360.com/admin/ForgotPassword.aspx.cs

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Bathuasoft.admin
{
	public partial class ForgotPassword : System.Web.UI.Page
{
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn_ConnectionString"].ConnectionString);
        protected void Page_Load(object sender, EventArgs e)
    {
            if (!IsPostBack)
            {
                Session["Name"] = txtUserName.Text;
            }
        }

      

        protected void btnGetOtp_Click(object sender, EventArgs e)
        {
            Panel2.Visible = true;
            string mobileno = string.Empty;

            string constr = ConfigurationManager.ConnectionStrings["conn_ConnectionString"].ConnectionString;
            using (SqlConnection con = new SqlConnection(constr))
            {
                using (SqlCommand cmd = new SqlCommand("SELECT MobileNo FROM Login WHERE Name = @Name"))
                {
                    cmd.Parameters.AddWithValue("@Name", txtUserName.Text.Trim());

                    cmd.Connection = con;
                    con.Open();
                    using (SqlDataReader sdr = cmd.ExecuteReader())
                    {
                        if (sdr.Read())
                        {
                            mobileno = sdr["MobileNo"].ToString();

                        }
                    }
                    Session["Name"] = txtUserName.Text;
                    con.Close();
                }
            }
            if (!string.IsNullOrEmpty(mobileno))
            {
                Random r = new Random();

                Session["OTP"] = r.Next(1000, 9999);
                SendSMS_ForEnquiry(mobileno, "Your OTP is " + Session["OTP"].ToString() + " Please don't share with anyone");
            }
        }

        public void SendSMS_ForEnquiry(string mobile, string msg)
        {
            if (mobile != "" && msg != "")
            {
                var msg1 = msg;
                string url = "";

                url = "http://hindit.co.in/API/pushsms.aspx?loginID=T1DelhiNEETAcademy&password=123654789&mobile="
                + mobile + "&text=" + msg
                + "&senderid=BTSOFT&route_id=2&Unicode=0&IP=x.x.x.x";
                bool success = false;

                try
                {
                    var outn = 0;
                    WebRequest request = WebRequest.Create(url);

                    using (WebResponse response = (HttpWebResponse)request.GetResponse())
                    {
                        Stream receiveStream = response.GetResponseStream();

                        using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8))
                        {
                            string line = readStream.ReadToEnd().Trim();
                            //success = Int32.TryParse(line, ref outn);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("Your OTP is send to your registered number");
                    //success = false;
                }
            }
            else
            {
                //Response.Redirect("home_CompanyRegistration.aspx");
            }



        }

        

        protected void btnVerifyOtp_Click1(object sender, EventArgs e)
        {
            Panel1.Visible = false;
            Panel2.Visible = false;
            Panel3.Visible = true;
            if (Session["OTP"].ToString() == txtVerifyOtp.Text)
            {
                lblMessage.Text = "You have enter correct OTP.";
                Session["OTP"] = null;
            }
            else
            {
                lblMessage.Text = "Pleae enter correct OTP.";
            }

           // btnSave_Click(Session["Name"], e);
        }

        protected void btnSave_Click(object sender, EventArgs e)
            {
            Panel1.Visible = false;
            Panel2.Visible = false;
            Panel3.Visible = true;

            con.Open();
            SqlCommand cmd = new SqlCommand("usp_update_password", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Password", txtNewPassword.Text);
            cmd.Parameters.AddWithValue("@Name", txtUserName.Text);
            cmd.ExecuteNonQuery();
            con.Close();
            lbl3.Text = "Your Password has been chnaged successfully";
        }
    }
}

TechEthical Mini WebShell Version 1.0, Coded By The_M@T3