Nukemods Forum  
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Online Users: 88
3 members and 85 guests
celedxebritwb9b, lowsad4erback5s, pai5drdnters6sa
Most users ever online was 611, 03-21-2008 at 10:10 PM.
» .::.
» .:.

Go Back   Nukemods Forum > PHP-Nuke 7.x > Nuke 7.x - General

Reply
 
LinkBack Thread Tools Display Modes
Username set in cookie from database with correct caps.
Old
  (#1 (permalink))
Junior Member
 
Status: Offline
Posts: 15
Join Date: Sep 2004
Username set in cookie from database with correct caps. - 10-19-2004, 10:29 AM

Here's my issue. I would like my submitted news, welcome block, etc to display the correct formatting of username caps as registered in my database. I've looked through the code and it looks like all these functions are getting the username from the cookie. What I need to know is where is the cookie getting set so I can do a call to the database to get the correct username formatting and set that in the cookie.

Thanks guys.
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old
  (#2 (permalink))
Moderator
 
Status: Offline
Posts: 260
Join Date: Oct 2004
10-19-2004, 10:39 AM

try this
Code:
getusrinfo($user);
$theuser = $userinfo['username'];
that way is getting the username directly from the db.
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old
  (#3 (permalink))
Junior Member
 
Status: Offline
Posts: 15
Join Date: Sep 2004
10-19-2004, 10:54 AM

Thanks for the reply.

In the Who's Online block, I replaced this:
Code:
$uname = $cookie[1];
with this:
Code:
getusrinfo($cookie[1]);
$uname = $userinfo['username'];
With the same results. I looked at the code, it seemed like it should do what I want, but didn't. Also, I'd rather set the cookie to the correct username instead of querying the database everytime I want to use the username. Just easier on the database and I only have to edit one block of code, not everywhere it's used.

Thanks, keep the ideas coming.
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old
  (#4 (permalink))
Moderator
 
Status: Offline
Posts: 260
Join Date: Oct 2004
10-19-2004, 11:44 AM

thats not right.
try
Code:
getusrinfo($user);
$uname = $userinfo['username'];
Make sure to put global $userinfo;
cookies are encoded and sent to the storage pc in lower case, that's the reason you see it like that.
The way i told u is getting the username like IT IS in the users table. Yes it does an extra query but i don't see any other solution.
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old
  (#5 (permalink))
Junior Member
 
Status: Offline
Posts: 15
Join Date: Sep 2004
10-19-2004, 03:12 PM

Quote:
Originally Posted by genoxide
thats not right.
try
Code:
getusrinfo($user);
$uname = $userinfo['username'];
Make sure to put global $userinfo;
Thanks, I tried that the first time and still didn't work. I put it in the Who's Online block right below the cookiedecode($user); line. That's why I used the $cookie[1] array to get the username. I also tried adding your code above the getusrinfo call to no avail.

Quote:
Originally Posted by genoxide
cookies are encoded and sent to the storage pc in lower case, that's the reason you see it like that.
If that's the case, why is it when I log in with all caps, it shows up that way in the Who's Online block? If it's not stored in the cookie case sensitive, then where does it store it. That's where I need to change it.

Quote:
Originally Posted by genoxide
The way i told u is getting the username like IT IS in the users table. Yes it does an extra query but i don't see any other solution.
Yeah, I see getusrinfo does a query but I theorize that somewhere when you log in, nuke sets your cookie to your username because all these other blocks (who's online) are pulling that username from the cookie. So, if we set it correctly in the cookie in the first place, we should have no more problems. I just can't find where that is. I checked include/sessions.php and couldn't find where it would set the username. Maybe someone has a suggestion for this.

Thanks guys, keep the ideas coming.
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old
  (#6 (permalink))
Moderator
 
Status: Offline
Posts: 260
Join Date: Oct 2004
10-19-2004, 03:22 PM

wait, i thought u were talking about the 'hello _nick_!' in themes, can u post the code of the whos online block u are using?
btw the function to set cookies is in the YA module
Code:
function docookie($setuid, $setusername, $setpass, $setstorynum, $setumode, $setuorder, $setthold, $setnoscore, $setublockon, $settheme, $setcommentmax) {
    $info = base64_encode("$setuid:$setusername:$setpass:$setstorynum:$setumode:$setuorder:$setthold:$setnoscore:$setublockon:$settheme:$setcommentmax");
    setcookie("user","$info",time()+2592000);
}
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old
  (#7 (permalink))
Junior Member
 
Status: Offline
Posts: 15
Join Date: Sep 2004
10-19-2004, 03:35 PM

THERE IT IS! So, what if I put
Code:
getusrinfo($setusername); 
$uname = $userinfo['username'];
in the first line of that function and encoded $uname instead of $setusername? Would that do it you think? No time to try, must run. BBL

Thanks again.
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old
  (#8 (permalink))
Moderator
 
Status: Offline
Posts: 260
Join Date: Oct 2004
10-19-2004, 04:22 PM

um, $setusername is a var given by a textbox when u login.
The code u posted is the same of the one i gave u and this will do one more query.
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old
  (#9 (permalink))
Junior Member
 
Status: Offline
Posts: 15
Join Date: Sep 2004
10-19-2004, 06:05 PM

Interesting, the code I posted returned a blank variable, so I wrote the query myself:
Code:
function docookie($setuid, $setusername, $setpass, $setstorynum, $setumode, $setuorder, $setthold, $setnoscore, $setublockon, $settheme, $setcommentmax) { 
    global $user_prefix, $db;
	$result = $db->sql_query("SELECT * FROM ".$user_prefix."_users WHERE username='$setusername' AND user_password='$setpass'");
    if ($db->sql_numrows($result) == 1) {
    	$userinfo = $db->sql_fetchrow($result);
    }
    $uname = $userinfo['username'];
    $info = base64_encode("$setuid:$uname:$setpass:$setstorynum:$setumode:$setuorder:$setthold:$setnoscore:$setublockon:$settheme:$setcommentmax");
    setcookie("user","$info",time()+2592000);
}
This did what I wanted, but when the YA page prints on login, it uses the active variable instead of the cookie variable. But, if I go to the home page and then back to YA, the name is displayed correctly. So, is YA using the current variable from the login when it first displays then gets the name from the cookie the following times?
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old
  (#10 (permalink))
Junior Member
 
Status: Offline
Posts: 15
Join Date: Sep 2004
10-19-2004, 06:25 PM

Ahh, figured it out. When you first log in, nuke sends you to
http://www.site.com/modules.php?name...ername=mauldus

That's why it's not using the cookie. That's not such a big deal. My biggest reason for doing this is to get the proper formatting when a user submits news. I want the submitted by caption to look correct and I think I've done that. Thanks for your help genoxide.
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cookie lammat Nuke 7.x - General 1 12-01-2004 11:19 AM
How to use cookie data in a custom module? kiltannen Nuke 7.x - Modules 4 11-05-2004 05:05 PM
phpbb database converter to Nukemods database palooka Open topics 3 06-15-2003 10:57 AM
Cookies - Looking for a way to drop cookie. exxxpress Purged Topics 0 06-12-2003 10:32 AM
Cookie Names....Maybe they are just a little important. Dauthus Open topics 0 05-05-2003 07:49 PM




vBulletin Skin developed by: vBStyles.com


LinkBacks Enabled by vBSEO 3.3.0

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