17 May, 2008, 09:16:31 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: We Return!
 

Pages: [1]   Go Down
  Print  
Author Topic: Getting a member's user ID on IF  (Read 6192 times)
0 Members and 1 Guest are viewing this topic.
Bye.

I am no longer a part of this community.


Gold Contribution
*
Elite Member

Karma: 8
Offline Offline

Gender: Male
Posts: 193
729860.80 Secksi Coins

View Inventory
Send Money to pr0nslave

View Profile
« on: 25 February, 2007, 08:58:00 AM »

NOTE: this tutorial will either work in IE, and not FireFox, or in FireFox and not IE. When I get spare time, I will try and fix this, where it'll work in IE and FF! However, until then, remember that this is not cross-browser. Gah.. I hate IE......

This tutorial was created by Klark Kent, aka pr0nslave of http://TheCodingZone.com |
Redistribute only if you've left all content in, and have not edited or added to it.       |
------------------------------------------------------------------------------------------------------

First off, a user ID is the number someone was at registration. For example, say Robert registered, then Kenny and finally Tom. Robert's user ID would be 1, Kenny's would be 2 and Tom's would be 3. Why are some IDs "skipped"? Well, they're not -- it just looks that way because an admin has chosen to delete a member.

For example, say Kenny was being mean -- and Robert (member #1, thus, administrator) decided to delete him -- it would leave only users #1 and #3 left, because #2 had been deleted.

Anyhow, enough with that! Let's get to the code.

First, the user ID is stored in a cookie (to my knowledge). Four+ cookies are set by each board, that are named *boardname*session_id, *boardname*member_id, *boardname*pass_hash, and *boardname*forum_read

Here are their values:
*boardname*session_id is the session ID
*boardname*member_id is the member ID
*boardname*pass_hash is the password hash
*boardname*forum_read tells something about if you've read each post in a forum

This is where *boardname* denotes the name the board was registered under, ie.: not the title -- but hxxp://zX.invisionfree/*BOARDNAME*

Now, the only cookie we need is *boardname*member_id
This cookie holds the user ID of the person currently logged in (ie.: if TCZ was an IF board, my *boardname*member_id value would be 1393, because that's my member ID).

Off to fetch it via JS!
First of all, you should know document.cookie will display all cookies set by that domain, for example, on my test board, putting
Code:
<script>
document.write(document.cookie);
</script
in footers would yield...

Quote
pr0ntestsession_id=189f...2a0319f; pr0ntestmember_id=1; pr0ntestpass_hash=d4bc6f5...ddf05c3; pr0ntestforum_read=a%3A1%3...1717%3B%7D
(note the '...' is for security reasons, as I don't want my password hash or session ID to be cracked [hash] or hijacked [session])

Now, let's split this up to get the cookie we want...

Code:
var cookiez=document.cookie.split('; ');

Which makes the variable cookiez an array, that holds:
cookiez[0] = *boardname*session_id=*session id*
cookiez[1] = *boardname*member_id=*member id*
cookiez[2] = *boardname*pass_hash=*password hash*
cookiez[3] = *boardname*forum_read=*forum read info*

Since we want the value only, and the value of *boardname*member_id only, let's split cookiez[1] up.

Code:
var tehchef=cookiez[1].split('=');

Which makes tehchef an array, that holds:
tehchef[0] = *boardname*member_id
tehchef[1] = *boardname*member_id's value

So, the user ID is now stored in tehchef[1]

Full code:
Code:
<script>
var cookiez=document.cookie.split('; ');
var tehchef=cookiez[1].split('=');
var userid=tehchef[1];
alert(userid);
</script>

Hope I helped, and note that there are other ways of doing this, but imo, this is the simplest way that teaches the most (you could have learned about split, arrays, etc. while reading this, lol)
Logged

Do not PM me or anything. I am NOT a part of this community.
This resource was found useful by 4 out of 4 members. Rate it: [applaud] [smite]
slayer766United States
Long live TCZ

TCZ r0x my s0x

Administrator

Platinum Contribution
*
Conqueror

Karma: 56
Offline Offline

Gender: Male
Posts: 4419
415595.08 Secksi Coins

View Inventory
Send Money to slayer766

View Profile
« Reply #1 on: 25 February, 2007, 02:53:49 PM »
"We know what we are, but know not what we may become." - William Shakespeare

Short and straight to the point, well done. Wink
Logged

Live for nothing or die for something






Coding Team

Silver Contribution
*
Legendary Member

Karma: 19
Offline Offline

Posts: 1223
57168.48 Secksi Coins

View Inventory
Send Money to CodeMaster

View Profile WWW
« Reply #2 on: 26 February, 2007, 02:17:32 AM »

Good tut.

applaud++;
Logged

Bye.

I am no longer a part of this community.


Gold Contribution
*
Elite Member

Karma: 8
Offline Offline

Gender: Male
Posts: 193
729860.80 Secksi Coins

View Inventory
Send Money to pr0nslave

View Profile
« Reply #3 on: 26 February, 2007, 02:52:16 AM »

Yay, thanks guys : )
Logged

Do not PM me or anything. I am NOT a part of this community.
United Kingdom
More metal than thee...

Low-Tech Code Monkey

Administrator

Silver Contribution
*
Conqueror

Karma: 72
Offline Offline

Gender: Female
Posts: 3687
294841.93 Secksi Coins

View Inventory
Send Money to Slaytanist

View Profile WWW
« Reply #4 on: 28 February, 2007, 01:12:51 AM »
Gods of Thunder, of Wind and of Rain, Valkyries my soul is yours should I fail...

This is the best goddamn IF tutorial I have ever seen. Awesome man
Logged


My standard sig is rated 15.
theworldneedsmore.com/puterphobia



I love you, Emz!
Bye.

I am no longer a part of this community.


Gold Contribution
*
Elite Member

Karma: 8
Offline Offline

Gender: Male
Posts: 193
729860.80 Secksi Coins

View Inventory
Send Money to pr0nslave

View Profile
« Reply #5 on: 28 February, 2007, 02:33:12 AM »

Wow! Thanks guys!
Cheesy : D Cheesy : D

lol
Logged

Do not PM me or anything. I am NOT a part of this community.
idk...

dun dun dun!


Bronze Contribution
*
Addict

Karma: 3
Offline Offline

Gender: Male
Posts: 312
203087.67 Secksi Coins

View Inventory
Send Money to GAME OVER

View Profile WWW
« Reply #6 on: 11 March, 2007, 10:32:56 PM »

So it this a way you can grab a user?
Logged

Resaurant's special: OWNAGE
if i dish it out u better eat it, but if u arn't then who is?Huh 0.o
Quote
How can a majority of one be right, and millions wrong?

ok sorry i just copied it form an IF site so i guess it was bigger here than If sites...
(i am talking to codemaster btw)

<_< >_> <_> >_<
Bye.

I am no longer a part of this community.


Gold Contribution
*
Elite Member

Karma: 8
Offline Offline

Gender: Male
Posts: 193
729860.80 Secksi Coins

View Inventory
Send Money to pr0nslave

View Profile
« Reply #7 on: 12 March, 2007, 12:45:47 AM »

What do you mean by "grab a user"? I do believe that'd require physical access to 'em Tongue
Logged

Do not PM me or anything. I am NOT a part of this community.
slayer766United States
Long live TCZ

TCZ r0x my s0x

Administrator

Platinum Contribution
*
Conqueror

Karma: 56
Offline Offline

Gender: Male
Posts: 4419
415595.08 Secksi Coins

View Inventory
Send Money to slayer766

View Profile
« Reply #8 on: 12 March, 2007, 01:09:55 AM »
Take me down to the paradise city where the grass is green and the girls are pretty!

Hahaha, you could get the user by the userlinks. Search that up in the source Gameover. Smiley
Logged

Live for nothing or die for something






idk...

dun dun dun!


Bronze Contribution
*
Addict

Karma: 3
Offline Offline

Gender: Male
Posts: 312
203087.67 Secksi Coins

View Inventory
Send Money to GAME OVER

View Profile WWW
« Reply #9 on: 13 March, 2007, 01:35:18 AM »

hmm ok. Where did you guys learn all this anyways, I read the stuff at w3schools but I still suck at coding. <_<
Logged

Resaurant's special: OWNAGE
if i dish it out u better eat it, but if u arn't then who is?Huh 0.o
Quote
How can a majority of one be right, and millions wrong?

ok sorry i just copied it form an IF site so i guess it was bigger here than If sites...
(i am talking to codemaster btw)

<_< >_> <_> >_<
slayer766United States
Long live TCZ

TCZ r0x my s0x

Administrator

Platinum Contribution
*
Conqueror

Karma: 56
Offline Offline

Gender: Male
Posts: 4419
415595.08 Secksi Coins

View Inventory
Send Money to slayer766

View Profile
« Reply #10 on: 13 March, 2007, 01:39:19 AM »
"We know what we are, but know not what we may become." - William Shakespeare

Yeah w3schools will not really help much for forum coding, just ask questions away here on anything you need to know. Also some of us know most of this because we've been doing it for a bit. Also just view source and type in your username and it will show you its in the class of userlinks. Smiley
Logged

Live for nothing or die for something






rawr


Bronze Contribution
*
Member

Karma: 5
Offline Offline

Gender: Male
Posts: 90
2211.20 Secksi Coins

View Inventory
Send Money to Vitality

View Profile
« Reply #11 on: 05 May, 2008, 09:34:25 PM »

A bit of a late reply, but I found this tutorial really helpful. I've wanted to know this for a while.
Logged

Hey
Pages: [1]   Go Up
  Print  
 
Jump to:  
Sponsored Links:

Powered by MySQL
Powered by PHP
Powered by SMF 1.1.1 | SMF © 2005, Simple Machines LLC
TinyPortal v0.8.6 © Bloc
The rest copyright TCZ you pillocking twat!
Valid XHTML 1.0!
Valid CSS!
Places we'd like you to visit.