-
Notifications
You must be signed in to change notification settings - Fork 0
/
friendlist.aspx.cs
70 lines (67 loc) · 2.53 KB
/
friendlist.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net.Mail;
using System.ServiceModel.Security;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using com.KatomBook;
public partial class Default2 : System.Web.UI.Page
{
public string id = "";
public string fullName, bio, desc, email, website, lastSeen, address, profilePic;
public bool own, logged;
public int[] friends;
public DataTable[] friendsTable;
protected void Page_Load(object sender, EventArgs e)
{
logged = true;
if (Session.Count < 2)
{
logged = false;
Response.Redirect("/Login.aspx", false);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
if (logged)
{
if (string.IsNullOrEmpty(Request.Params["id"]))
{
id = Session["index"].ToString();
}
else
{
id = Request.QueryString["id"].ToString();
}
DataTable userInfo = MyAdoHelper.ExecuteDataTable("Select * FROM `tblUsers` WHERE `fldIndex` = " + id + ";");
fullName = userInfo.Rows[0]["fldFullName"].ToString();
bio = userInfo.Rows[0]["fldBio"].ToString();
desc = userInfo.Rows[0]["fldDescription"].ToString();
email = userInfo.Rows[0]["fldEmail"].ToString();
website = userInfo.Rows[0]["fldWebsite"].ToString();
lastSeen = userInfo.Rows[0]["fldLastSeen"].ToString();
address = userInfo.Rows[0]["fldAddress"].ToString();
profilePic = userInfo.Rows[0]["fldProfilePic"].ToString();
own = Session["index"].ToString() == id;
friends = GetFriends(id);
friendsTable = new DataTable[friends.Length];
for (int i = 0; i < friendsTable.Length; i++)
{
friendsTable[i] = MyAdoHelper.ExecuteDataTable("SELECT * FROM `tblUsers` WHERE `fldIndex` = " + friends[i] + ";");
}
}
}
public int[] GetFriends(string id)
{
DataTable friendsTable = MyAdoHelper.ExecuteDataTable("SELECT * FROM `tblFriends` WHERE `user1_id` = " + int.Parse(id) + ";");
int[] friends = new int[friendsTable.Rows.Count];
for (int i = 0; i < friends.Length; i++)
friends[i] = 0;
for (int i = 0; i < friendsTable.Rows.Count; i++)
{
friends[i] = int.Parse(friendsTable.Rows[i]["user2_id"].ToString());
}
return friends;
}
}