• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ Contributions (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

A (dirty) way to get the users name from your db

Post a bug fix, a new feature, a theme ...

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
8 posts • Page 1 of 1

Postby Tribalx » Mon Apr 16, 2007 4:25 pm

I tried to get a username into a session and call it whitin the chat, with alot of errors and 3 hours of pain (yeah it still hurts ffs :| )
On a diffrent approach (using the hot mysql database ;) ) i have found a simple solution to fix it all. (we overrule some shiznit :cool: )

Q: How did i do it?
A: Simple wiseguy, yust with my fingers and a keyboard ;)

Q: Can i modify the source?
A: It was 2 minutes work, so why shouldnt you :D

Q: Can i be your girlfriend?
A: No im sorry, i dont do E-dating, maybe next time ;)

Enough bullsh!t, here is the source, with some explanation and guide lines ;)

find: pfcuserconfig and scroll down to
$this->nickid = session_id();

// user parameters are cached in sessions

$this->_getParam("nick");

(somewhere around line 20-30)

paste this code under that line

Code: Select all
      
      $user = "";//username
      $pass = "";//password
      $host = "";//ussaly localhost
      $db = "";//database

      mysql_connect($host,$user,$pass)or die ("error"); // the connection
      mysql_select_db($db); // select your db
            
      $select = mysql_query("SELECT  the_user_name FROM a_table WHERE some_session_ip = '".$_SERVER['REMOTE_ADDR']."'"); // select the user
      $name = mysql_fetch_assoc($select);
      $nick = $name['player']; // now the username is located in $nick

1 line below your copied/pasted code you see this line
if (!isset($this->nick)) $this->_setParam("nick",""); // setup a blank nick if it is not yet in session

change that into:
Code: Select all
if (!isset($this->nick)) $this->_setParam("nick",$nick); // setup a blank nick if it is not yet in session

Now you might want to run some extra checks, so do it, no dont wait, why are you still reading?
aaarghhhhhh...

Have a nice day :cool:
Last edited by Tribalx on Mon Apr 16, 2007 4:37 pm, edited 1 time in total.
watsup doc? :mad:
Tribalx
Member
 
Posts: 13
Joined: Sat Apr 14, 2007 9:54 pm
Top

Postby datacompboy » Wed Apr 18, 2007 2:05 pm

I think, you do lot of strage things.
For show popup with user real name from info, just set up in chat-init script
$sql = "select nick, realname from users where id = ".$_SESSION['userid'];
$res = db_selectrow($sql);
$params['frozen_nick'] = true;
$params['nick'] = $res['nick'];
$params['nickmeta']['realname'] = $res['realname'];
... other parameters
$chat = new phpFreeChat($params);

that's all: user will have in chat his nick on site, and in user popup will be his real name.
-- suicide proc nearn call deathn suicide endp
datacompboy
Member
 
Posts: 74
Joined: Thu Jan 18, 2007 9:10 pm
Location: Novosibirsk
  • Website
  • ICQ
Top

Postby Tribalx » Wed Apr 18, 2007 9:28 pm

and your not getting errors with that code?
becaus i have tried the exact same thing and it told me i had session errors
watsup doc? :mad:
Tribalx
Member
 
Posts: 13
Joined: Sat Apr 14, 2007 9:54 pm
Top

Postby datacompboy » Fri Apr 20, 2007 3:53 am

It works for me.
-- suicide proc nearn call deathn suicide endp
datacompboy
Member
 
Posts: 74
Joined: Thu Jan 18, 2007 9:10 pm
Location: Novosibirsk
  • Website
  • ICQ
Top

Postby KDB9000 » Wed May 30, 2007 6:24 pm

Do you know if there is away I can set phpfreechat's user ID to the user ID for my CMS system? I am making a plugin for e107 to use this system an would like it if you click on a users name and it pulls up their profile but the profile is uses the CMS's ID system. So I need a way for it to link the to together and if i can get phpfreechat's user ID to match the user ID of my CMS then I should be able to get it to work.
KDB9000
Member
 
Posts: 13
Joined: Tue May 15, 2007 4:46 pm
Top

Postby roberte » Wed Oct 31, 2007 4:06 pm

How do I use this one?

$sql = "select nick, realname from users where id = ".$_SESSION['userid'];
$res = db_selectrow($sql);
$params['frozen_nick'] = true;
$params['nick'] = $res['nick'];
$params['nickmeta']['realname'] = $res['realname'];
... other parameters
$chat = new phpFreeChat($params);


-------------------------------------------------------------------------------------------
Or This one?

$user = "";//username
$pass = "";//password
$host = "";//ussaly localhost
$db = "";//database

mysql_connect($host,$user,$pass)or die ("error"); // the connection
mysql_select_db($db); // select your db

$select = mysql_query("SELECT the_user_name FROM a_table WHERE some_session_ip = '".$_SERVER['REMOTE_ADDR']."'"); // select the user
$name = mysql_fetch_assoc($select);
$nick = $name['player']; // now the username is located in $nick

-------------------------------------------------------------------------------------------

I really need some help with this part. I must have my users' data in the chat. Which of these two are best and how do I do it step by step? Pleeeeeeaaaaaassssse help me!
roberte
New member
 
Posts: 2
Joined: Wed Oct 31, 2007 3:47 pm
Top

Postby OldWolf » Wed Oct 31, 2007 11:04 pm

What kind of system are you working with? It really depends on what your basing it from. If, for example, you were using phpbb, I'd suggest the integration already written for it. If you're using your own system, you should be able to figure out your own sessions. So, what sort of session system are you using?
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top

Postby roberte » Thu Nov 01, 2007 4:29 am

I am working with PHPizabi. I am not much of a programmer by any means, but I love this chat application. Adding it to my site would make for a boost to my sites' use.
roberte
New member
 
Posts: 2
Joined: Wed Oct 31, 2007 3:47 pm
Top


Post a reply
8 posts • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 4 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub