تصحيح كود الدخول للموقع بالكوكيز - bidaya - 09-01-17
السلام عليكم ورحمة الله نعالى وبركاته
وجدة هذا الكود مع الشرح في المنتدى لكن لم اتمكن من تطبيقه
كود :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static string MD5(string STR)
{
ASCIIEncoding encoding = new ASCIIEncoding();
string str = string.Empty;
byte[] bytes = encoding.GetBytes(STR);
byte[] buffer2 = new MD5CryptoServiceProvider().ComputeHash(bytes);
foreach (byte num in buffer2)
{
str = str + num.ToString("x2");
}
return str;
}
public Encoding getEncoding(string url)
{
HttpWebRequest rq = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse rs = (HttpWebResponse)rq.GetResponse();
return Encoding.GetEncoding(rs.CharacterSet);
}
CookieContainer _cookies = new CookieContainer();
private void button1_Click(object sender, EventArgs e)
{
Encoding charset = getEncoding("http://vb4arb.com/vb");
string Password = MD5("8798797");
string stringData = string.Format("vb_login_username={0}&vb_login_password=&vb_login_password_hint=%DF%E1%E3%C9+%C7%E1%E3%D1%E6%D1&cookieuser=1&s=&securitytoken=guest&do=login&vb_login_md5password={1}&vb_login_md5password_utf={1}",
"شكشوك", Password);
byte[] postData = charset.GetBytes(stringData);
HttpWebRequest LoginRequset = (HttpWebRequest)WebRequest.Create("http://vb4arb.com/vb/login.php?do=login");
LoginRequset.ContentType = "application/x-www-form-urlencoded";
LoginRequset.Method = WebRequestMethods.Http.Post;
LoginRequset.ContentLength = postData.Length;
LoginRequset.CookieContainer = _cookies; //مهم
LoginRequset.KeepAlive = true;
System.IO.Stream wr = LoginRequset.GetRequestStream();
wr.Write(postData, 0, postData.Length);
wr.Close();
using (HttpWebResponse LoginResponse = (HttpWebResponse)LoginRequset.GetResponse())
{
_cookies.Add(LoginResponse.Cookies);
}
//GET
//المتواجدون الان
HttpWebRequest onlineRequset = (HttpWebRequest)WebRequest.Create("http://vb4arb.com/vb/online.php");
onlineRequset.Method = "GET";
onlineRequset.CookieContainer = _cookies; //مهم
HttpWebResponse onlineResponse = (HttpWebResponse)onlineRequset.GetResponse();
webBrowser1.DocumentStream = onlineResponse.GetResponseStream();
}
}
}
هذا الكود تقوم بالدخول للموقع هذا عن طريق الكوكيز ارجو من لديه الخبرة في اللغة ان يعمل لنا مشروع مع الشرح وشكرا
RE: تصحيح كود الدخول للموقع بالكوكيز - LoveVb - 09-01-17
هذا الكود يقوم بجلب المتواجدون الان
وصفحة المتواجدون الان لن تستطيع الدخول اليها الا بعد تسجيل الدخول
لم افهم " لم اتمكن من تطبيقه " ؟
RE: تصحيح كود الدخول للموقع بالكوكيز - bidaya - 09-01-17
اخي هذا المشروع ارجو ان تصحح عليه
RE: تصحيح كود الدخول للموقع بالكوكيز - LoveVb - 09-01-17
بعد التجربة
يمكن معرفة المتواجدين الان بدون تسجيل دخول
هل تريد اظهارهم في البرنامج؟
RE: تصحيح كود الدخول للموقع بالكوكيز - bidaya - 09-01-17
(09-01-17, 06:29 PM)LoveVb كتب : بعد التجربة
يمكن معرفة المتواجدين الان بدون تسجيل دخول
هل تريد اظهارهم في البرنامج؟
اخي الكريم اريد تنفيذ الدخول بالكوكيز للموقع
وعندما وجدة هذا الكود في المنتدى ظهر لي به اخطاء
اريد تصحيح الاخطاء اذ امكن
وشكرا
RE: تصحيح كود الدخول للموقع بالكوكيز - LoveVb - 09-01-17
تفضل
كود :
System.Net.CookieContainer Cookie = new System.Net.CookieContainer();
public void Login(string Username, string Password)
{
string Data = string.Format("action=do_login&url=http%3A%2F%2Fvb4arb.com%2Fvb%2Findex.php&quick_login=1&quick_username={0}&quick_password={1}&quick_remember=yes&submit=%D8%AF%D8%AE%D9%88%D9%84", Username, Password);
byte[] PostData = Encoding.UTF8.GetBytes(Data);
System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://vb4arb.com/vb/member.php");
var _with1 = req;
_with1.Method = "Post";
_with1.ContentLength = PostData.Length;
_with1.ContentType = "application/x-www-form-urlencoded";
_with1.CookieContainer = Cookie;
System.IO.Stream sw = req.GetRequestStream();
sw.Write(PostData, 0, PostData.Length);
sw.Close();
req.GetResponse();
}
وبعد ذلك ستستخدم الكوكيز في الصفحات للتعرف على المستخدم انه عضو
RE: تصحيح كود الدخول للموقع بالكوكيز - bidaya - 09-01-17
(09-01-17, 07:10 PM)LoveVb كتب : تفضل
كود :
System.Net.CookieContainer Cookie = new System.Net.CookieContainer();
public void Login(string Username, string Password)
{
string Data = string.Format("action=do_login&url=http%3A%2F%2Fvb4arb.com%2Fvb%2Findex.php&quick_login=1&quick_username={0}&quick_password={1}&quick_remember=yes&submit=%D8%AF%D8%AE%D9%88%D9%84", Username, Password);
byte[] PostData = Encoding.UTF8.GetBytes(Data);
System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://vb4arb.com/vb/member.php");
var _with1 = req;
_with1.Method = "Post";
_with1.ContentLength = PostData.Length;
_with1.ContentType = "application/x-www-form-urlencoded";
_with1.CookieContainer = Cookie;
System.IO.Stream sw = req.GetRequestStream();
sw.Write(PostData, 0, PostData.Length);
sw.Close();
req.GetResponse();
}
وبعد ذلك ستستخدم الكوكيز في الصفحات للتعرف على المستخدم انه عضو
اخي ان كان الكود الاول شغال عندك من فظلك ارفع المشروع لانه يظهر عندي اخطاء
RE: تصحيح كود الدخول للموقع بالكوكيز - LoveVb - 09-01-17
اكواد المشروع الاول لن تنفع
المنتدى الان مختلف عن السابق وسيرفض الطلب
|