Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ET chat login problem
#1
Hi, I have installed ET chat and edited as the tutorial states (I think) but the one problem i have is correcting the code so that users cant use new chat names. For example, I can access it as 'admin' but then change my name to 'steve'. How do I code it so that users are brought straight to chat using their myBB usernames and privelages? Here is my code:

<?php
session_start();
define("IN_MYBB", 1);
require_once "../global.php";
$group_ids = array(8, 9, 3, 4, 6);
$cur_gid = $mybb->user['usergroup'];
if (in_array($cur_gid, $group_ids)) // Group Member
{
$username = $chatusername;
}
else
{
die("Sorry, you aren't allowed to chat. Please contact for more information.");
}

//*****************************************************************************
// Für die Realisierung der Anbindung des Chats an Ihr Userverwaltungssystem aus einem
// Forum, CMS, usw. müssen Sie lediglich die unten stehenden Sessionvariablen
// in Ihrem System mit dem Usernamen belegen und den User mit einem
// Link auf diese Datei führen. Beachten Sie dass dabei der Username ohne Passwort übertragen wird.
// Sie dürfen also in Chat keine Passwörter für Admins und Mods anlegen. Für einen Chatbenutzer ist die
// Übergabe des Usernamen über die Sessionvar. $_SESSION['etchat_username'] aus Ihrem
// System ausreichend.

//$username = $_SESSION['etchat_username'];
//$gender = $_SESSION['etchat_gender']; //[optional] 'f' or 'm' system default 'n' if unset

// Die Admins und Mods sollen ohne PW im Chat angelegt werden!
// Die class/Index.class.php soll gelöscht werden, damit niemand unbefugt als Afmin rein kann!

//---------------------------------------------------------------------------
// oder als GET oder POST Übergabe, jedoch unsicher und sollte kodiert werden
// $username = $_REQUEST['etchat_username'];
// $gender = $_REQUEST['etchat_gender'];
//---------------------------------------------------------------------------

// Weiterleitung nach dem Logout(die Session bleibt bestehen,
// da sonst der User aus Ihrem System rausfliegt.)
$_SESSION['etchat_v3_logout_url']="../index.php";

##############################################################
# DO NOT EDIT BELOW ###############################################
##############################################################

function __autoload($class_name) {
if (substr($class_name, 0, 5)=="Admin")
require_once ('class/admin/'.$class_name.'.class.php');
else
require_once ('class/'.$class_name.'.class.php');
}

$get_var = array_keys($_GET);
$init_class = (!empty($get_var[0])) ? $get_var[0] : "Index";

// initialise
new $init_class;

?>
Reply
#2
$chatusername is not defined in your script and so is $username.

Kind regards
Lennart Sauter
Forum Admin
Reply
#3
Thanks, what or how do I do this? Sorry but Im only learning as I go along. What piece of code should be inserted and where?
Reply
#4
instead of:
You are not allowed to see php code.use:
You are not allowed to see php code.
Should work.
Forum Admin
Reply
#5
I changed that and it did nothing. The exact same options still apear, username and sex then if I use a random name like 'Steve' I get straight in. If I use my admin username it asks for a password which I enter.

Also, my mods are still being told they dont have access rights.
Reply
Register (for free) to hide the ads.
#6
Did you rename the file properly? The above file has to be saved as index.php overwriting the old one.

Please read the instructions carefully.
Forum Admin
Reply
#7
Yes. I redid everything again using your script and all I kept getting were 'invisible' errors but when I use the script by itmanvn I can get chat but it allows the selection of a random 'chat' name. In other words it recognises myBB username but still allows me to pick another name. If I can remove this option I think Im ok. Heres he index script as it stands;

<?php
session_start();
define("IN_MYBB", 1);
require_once "../global.php";
$group_ids = array(8, 9, 3, 4, 6, 1, 2, 5, 7);
$cur_gid = $mybb->user['usergroup'];
if (in_array($cur_gid, $group_ids)) // Group Member
{
$username = "".$mybb->user['username']; // match logged in user
$_SESSION['etchat_username'] = $username;
$_SESSION['etchat_v3_username'] = $username;
}
else
{
die("Sorry, you aren't allowed to chat. Please contact for more information.");
}

//*****************************************************************************
// Für die Realisierung der Anbindung des Chats an Ihr Userverwaltungssystem aus einem
// Forum, CMS, usw. müssen Sie lediglich die unten stehenden Sessionvariablen
// in Ihrem System mit dem Usernamen belegen und den User mit einem
// Link auf diese Datei führen. Beachten Sie dass dabei der Username ohne Passwort übertragen wird.
// Sie dürfen also in Chat keine Passwörter für Admins und Mods anlegen. Für einen Chatbenutzer ist die
// Übergabe des Usernamen über die Sessionvar. $_SESSION['etchat_username'] aus Ihrem
// System ausreichend.

// Die Admins und Mods sollen ohne PW im Chat angelegt werden!
// Die class/Index.class.php soll gelöscht werden, damit niemand unbefugt als Afmin rein kann!

//---------------------------------------------------------------------------
// oder als GET oder POST Übergabe, jedoch unsicher und sollte kodiert werden
// $username = $_REQUEST['etchat_username'];
// $gender = $_REQUEST['etchat_gender'];
//---------------------------------------------------------------------------

// Weiterleitung nach dem Logout(die Session bleibt bestehen,
// da sonst der User aus Ihrem System rausfliegt.)
$_SESSION['etchat_v3_logout_url']="../index.php";

##############################################################
# DO NOT EDIT BELOW ###############################################
##############################################################

function __autoload($class_name) {
if (substr($class_name, 0, 5)=="Admin")
require_once ('class/admin/'.$class_name.'.class.php');
else
require_once ('class/'.$class_name.'.class.php');
}

$get_var = array_keys($_GET);
$init_class = (!empty($get_var[0])) ? $get_var[0] : "Index";

// initialise
new $init_class;

?>
Reply
#8
The functions inside the chat are out of my control, sorry.
Forum Admin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)