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

Frozen nick aaarrggghhh!

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

Post a reply
4 posts • Page 1 of 1

Postby micksalerno » Mon Jan 24, 2011 1:17 pm

I've intergrated chat into my site. It's all going swimmingly, except, I want registered usernames displayed and random ones for guests. As soon as someone logs in I would like there guest name to change immediately. Honestly I'm a bit lost. Frozen nick seems to be the way except, once logged out it changes with every request by phpfreechat.
My code:

Code: Select all
require_once dirname(__FILE__)."/src/phpfreechat.class.php";
$params = array();
$params["server_script_url"] = "http://" . $_SERVER['HTTP_HOST']  . $_SERVER['REQUEST_URI'] ;
$params["data_private_path"]   = Yii::app()->request->baseUrl."./vendors/chat/data/private";
$params["data_public_url"]   = Yii::app()->request->baseUrl."./vendors/chat/data/public";
$params["title"] = "DnB Central Chat";
$params["frozen_nick"]    = true;
$params["nick"] = (!Yii::app()->user->isGuest) ? CHtml::encode(Yii::app()->user->name) : 'guest'.rand(1,1000);
$params['firstisadmin'] = true;
$params["isadmin"] = true; // makes everybody admin: do not use it on production servers ;)
$params["serverid"] = md5(__FILE__); // calculate a unique id for this chat
$params["debug"] = false;
$params["container_type"] = "mysql";
$params["container_cfg_mysql_host"] = "localhost";
$params["container_cfg_mysql_port"] = 3306;
$params["container_cfg_mysql_database"] = "chat";
$params["container_cfg_mysql_table"] = "chat";
$params["container_cfg_mysql_username"] = "root";
$params["container_cfg_mysql_password"] = "******";
$chat = new phpFreeChat( $params );
micksalerno
New member
 
Posts: 3
Joined: Sun Nov 07, 2010 6:51 pm
Top

Postby re*s.t.a.r.s.*2 » Mon Jan 24, 2011 5:02 pm

every time a 2 seconds request is done, it checks the ran() code and give you a different number, in order to stop this, you need to disable frozen_nick or do a nick based on the user's IP hashing it then using that as guest nick..

Code: Select all
$ip = $_SERVER['REMOTE_ADDR'];
$desc = md5($ip);
$preview = substr($desc, 3, 6);
$preview = preg_replace("/[^0-9]/", '', $preview);
$params["nick"] =  "guest".$preview;

put that code instead of the rand() function and the loop will end ...

Dont forget to "/rehash"..
regards.
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top

Postby micksalerno » Mon Jan 24, 2011 5:30 pm

THanks for that sorted. Co-incidently. Going from guest to logged in the room doesn't appear. I need to refresh for this to become visible any ideas?
micksalerno
New member
 
Posts: 3
Joined: Sun Nov 07, 2010 6:51 pm
Top

Postby re*s.t.a.r.s.*2 » Mon Jan 24, 2011 6:04 pm

That's the session going nuts, you need to have a link to the login page in the chat room, at that page destroy the old session that held the old guest nick and re initiate a new session with the logged in nick then redirect to the chat page..

that will make sure the old nick is destroy and that you get the registered nick instead old one..
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top


Post a reply
4 posts • Page 1 of 1

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 5 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