Exemplo n.º 1
0
    protected void Submit_Click(object sender, EventArgs e)
    {
        //IP Kontrolü
        string _ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

        if (_ip == null)
        {
            _ip = Request.UserHostAddress;
            _ip = _ip.Replace("::1", "127.0.0.1");
        }



        try
        {
            var           sqlString = "SELECT * FROM musteri WHERE hno = '" + login_id.Text + "' and sifre='" + login_password.Text + "'";
            veritabani    vt        = new veritabani();
            SqlDataReader rd        = vt.GetDataReader(sqlString);
            Cookie        cookie    = new Cookie();
            if (rd.Read())
            {
                /*Session.Add("mid", rd["mid"].ToString());
                 * Session.Add("hno", rd["hno"].ToString());
                 * Session.Add("AdSoyad", rd["ad"].ToString() + " " + rd["soyad"].ToString());*/
                cookie.cookie_olustur("email", rd["email"].ToString());
                cookie.cookie_olustur("hno", rd["hno"].ToString());
                cookie.cookie_olustur("adsoyad", rd["ad"].ToString() + " " + rd["soyad"].ToString());
            }
            else
            {
                throw new Exception("Hatalı giriş");
            }

            //Bu kontrol yapısı linqn try catch yoksa hata döndermesi üzerine güvenli sayfaların güvensizlerle benzer kod yapısını içermesi için tasarlandı.
            string kontrol = "0";//Veri tabanındaki ayarlar tablosunda kullanıcının IP kontrolü ya da mail kontrolü yoksa sisteme giriş yapması için eklendi
            try
            {
                //string sorgu = "SELECT * from IP as c inner join ayarlar as o on o.hno=c.hno where c.hno=" + login_id.Text + " and o.hno=" + login_id.Text;
                string        sorgu   = "Select * from IP where hno=" + login_id.Text;
                SqlDataReader veri_IP = vt.GetDataReader(sorgu);
                sorgu = "Select * from ayarlar where hno=" + login_id.Text;
                DataRow veri_ayar = vt.GetDataRow(sorgu);
                while (veri_IP.Read())
                {
                    if (veri_ayar["ip_dogrula"].ToString() == "1")
                    {
                        if (_ip == veri_IP["IP"].ToString())
                        {
                            if (veri_ayar["mail_dogrula"].ToString() == "1")
                            {
                                Server.Transfer("g_mail_dogrulama.aspx");
                                throw new Exception("Mail doğrulama");
                            }
                            string tarayici_bilgi = Request.UserAgent;
                            string tarih          = DateTime.Now.ToString("dd'/'MM'/'yyyy HH:mm:ss");

                            sorgu = "INSERT INTO girisler(hno, tarih, tarayici_bilgisi, IP) VALUES(" + cookie.oku("hno") + ", '" + tarih + "', '" + tarayici_bilgi.Substring(0, 50) + "', '" + _ip + "')";
                            vt.Command(sorgu);

                            Server.Transfer("g_giris.aspx");
                        }
                        else
                        {
                            kontrol = "1";                //kullanıcının IP ve ayarlar tablosunda verisi var fakat ordaki veri şuanki IP adresiyle uyuşmuyor. Bu durumda
                            //Kullanıcının sisteme girişi engellenmesi için kontrol 1 yapılır
                        }
                    }
                    else
                    {
                        if (veri_ayar["mail_dogrula"].ToString() == "1")
                        {
                            Server.Transfer("g_mail_dogrulama.aspx");
                            throw new Exception("Mail doğrulama");
                        }
                    }
                }
            }

            catch
            {
            }
            if (kontrol != "1")             //Kullanıcının IP değeri yanlış ise yukarıdada açıklandığı gibi girişi engellenir.
            {
                string tarayici_bilgi = Request.UserAgent;
                string tarih          = DateTime.Now.ToString("dd'/'MM'/'yyyy HH:mm:ss");
                int    boyut          = tarayici_bilgi.Length;
                string sorgu          = "INSERT INTO girisler(hno, tarih, tarayici_bilgisi, IP) VALUES(" + cookie.oku("hno") + ", '" + tarih + "', '" + tarayici_bilgi.Substring(0, 50) + "', '" + _ip + "')";
                vt.Command(sorgu);
                Response.Redirect("g_giris.aspx");
                Response.Redirect("g_giris.aspx");
            }
        }
        catch (Exception ex)
        {
            LabelBilgi.Visible = true;
            LabelBilgi.Text    = "Müsteri Numaranız ya da şifreniz yanlış. Lütfen tekrar deneyin.";
        }
        finally
        {
        }
    }
Exemplo n.º 2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        veritabani    vt   = new veritabani();
        SqlConnection conn = new SqlConnection();


        conn = vt.Connection();
        String sorgu1 = "INSERT INTO musteri (hno, ad,soyad,sifre,hesap,email,adres,tel,musteri_tipi) VALUES (@hno, @ad, @soyad, @sifre,@hesap,@email,@adres,@tel,@musteri_tipi)";

        String sorgu2 = "SELECT hno FROM musteri ORDER BY hno DESC";

        SqlCommand cmd = new SqlCommand(sorgu1, conn);
        DataRow    row = vt.GetDataRow(sorgu2);


        int yeni_hsno = Convert.ToInt32(row["hno"].ToString()) + 1;

        Random randoms = new Random();
        int    sifre   = randoms.Next(1000, 10000);



        try
        {
            cmd.Parameters.AddWithValue("hno", yeni_hsno);
            cmd.Parameters.AddWithValue("ad", UserName.Text);
            cmd.Parameters.AddWithValue("soyad", soyad.Text);
            cmd.Parameters.AddWithValue("sifre", sifre);
            cmd.Parameters.AddWithValue("hesap", 1000000);
            cmd.Parameters.AddWithValue("email", email.Text);
            cmd.Parameters.AddWithValue("tel", tel.Text);
            cmd.Parameters.AddWithValue("adres", Adres.Text);
            cmd.Parameters.AddWithValue("musteri_tipi", bireyselkurumsal.SelectedIndex);
            cmd.ExecuteNonQuery();



            //mail yollama


            string icerik = "BGABANK Ultimate Kullanıcı Bilgileriniz <br/><br/>" + "Ad Soyad:" + UserName.Text +
                            " " + soyad.Text + "<br/>Müşteri numarası: " + yeni_hsno + "<br/>" + "Şifre: " + sifre;


            Mail mail = new Mail();

            mail.hesapbilgi_gonder(icerik, email.Text);

            Label1.Text = yeni_hsno.ToString();
            Metotlar metot  = new Metotlar();
            int      sonuc1 = 0;
            sonuc1 = metot.hareket_olustur("1000000", "Hesap Açma", yeni_hsno.ToString(), "1000000");
        }
        catch
        {
            Label1.Text = "Başvuru alınamadı..";
        }

        finally
        {
            Response.Redirect("kayitalindi.aspx");
        }
    }
Exemplo n.º 3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string _ip = TextBox1.Text;

        try
        {
            string  genel_sorgu = "Select * from IP where hno=" + cookie.oku("hno") + "AND IP='" + _ip + "'";
            DataRow genl_sonuc  = vt.GetDataRow(genel_sorgu);
            if (genl_sonuc["IP"] != null)
            {
                Literal2.Text = "Bu IP sistemde kayıtlıdır....";
            }
        }
        catch (Exception)
        {
            string sorgu = "INSERT INTO IP (hno,IP) VALUES ('" + cookie.oku("hno") + "','" + _ip + "');";
            int    sonuc = vt.Command(sorgu);

            if (sonuc != 0)
            {
                Literal2.Text = "Kayıt başarı ile tamamlandı.";
            }
        }


        try
        {
            string  genel_ip = "Select * from ayarlar where hno=" + cookie.oku("hno");
            DataRow sonuc_ip = vt.GetDataRow(genel_ip);
            if (sonuc_ip["hno"] != null)
            {
                int ip_dogrula = 0;
                if (CheckBox1.Checked == true)
                {
                    ip_dogrula = 1;
                }
                else if (CheckBox1.Checked == false)
                {
                    ip_dogrula = 0;
                }


                genel_ip = "UPDATE ayarlar SET ip_dogrula=" + ip_dogrula + "where hno=" + cookie.oku("hno") + ";";
                int sonuc = vt.Command(genel_ip);
                if (sonuc != 0)
                {
                    Literal2.Text = "Güncelleme başarılı.";
                }
            }
        }
        catch (Exception)
        {
            int ip_dogrula = 0;
            if (CheckBox1.Checked == true)
            {
                ip_dogrula = 1;
            }
            else if (CheckBox1.Checked == false)
            {
                ip_dogrula = 0;
            }

            string genel_ip = "INSERT INTO ayarlar (hno,ip_dogrula) VALUES (" + cookie.oku("hno") + "," + ip_dogrula + ");";
            int    sonuc    = vt.Command(genel_ip);
            if (sonuc != 0)
            {
                Literal2.Text = "Kayıt başarı ile tamamlandı.";
            }
        }
    }