MyBB Community Forums

Full Version: Board Message, edit Login Box
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi!

We are trying to set in all username (login) boxes the windows useraccount. This is working most of the time, except for the

Board Message
You are either not logged in or do not have permission to view this page. This could be because one of the following reasons:

..... etc etc

On that page you have also a username box and a password box.
I can't get that box filled with the username.

In Global.php I have added

$logon = explode("\\", $_SERVER['AUTH_USER']);
$logonname = $logon[1];
$logonreadonly = 'readonly';

And I changed the template 'error_nopermission', where I changed

<input type="text" class="textbox" name="username" />

to

<input type="text" class="textbox" name="username" value="{$logonname}" {$logonreadonly} />

(NOTE : Readonly variable is a text wich made the box non editable).

Above is as said not working, however when I fill in

<input type="text" class="textbox" name="username" value="TEST" {$logonreadonly} />

I see test, however it still editable.
So it seems that it doesn't pickup my global.php vars.

Anyone an idea ?
"readonly" isn't the correct HTML property in this case. From memory, it should be "disabled".
ZiNgA BuRgA Wrote:"readonly" isn't the correct HTML property in this case. From memory, it should be "disabled".

Thanks for your reply.
Will change the readonly Smile

But the problem still exist that I can't get the user login code on the error message template, I can get it work on member_login template / member.php page.
Are you trying to use $_SERVER['PHP_AUTH_USER']?
Using $logon = explode("\\", $_SERVER['AUTH_USER']);
Working on Members_Login template / member.php not on Global.php and the error login box
What I'm saying is that, are you using the correct variable? There's no $_SERVER['AUTH_USER'] by default.
Yes, this variable exist.
And what I explained, I can used it in the Members template (see code below).

In member_login I changed to the following code

<input type="text" class="textbox" name="username" size="25" maxlength="{$mybb->settings['maxnamelength']}" style="width: 200px;" value="{$logonname}" {$logonreadonly} />

In member_register I changed to the following code

<input type="text" class="textbox" name="username" size="40" value="{$logonname}" readonly />

I added in member.php

$parser = new postParser;

//WINDOWS USERNAME -- ADDED CODE
$logon = explode("\\", $_SERVER['AUTH_USER']);
if (strtolower($logon[1]) == strtolower('User.Admin1') OR strtolower($logon[1]) == strtolower('User.Admin2')) {
             //USER CAN LOGIN WITH MULTI ACCOUNTS
	$logonname = ''; 
	$logonreadonly = '';
}
else {
             // USER LOGS IN WITH HIS / HER WINDOWS ACCOUNT
	$logonname = $logon[1];
	$logonreadonly = 'readonly';
}
//WINDOWS USERNAME -- ADDED CODE

// Load global language phrases
$lang->load("member");

Above is working when I register or push the login link.

However, when you are not logged in and you are trying to create thread with no rights then you will be thrown to a error message starting with

You are either not logged in or do not have permission to view this page. This could be because one of the following reasons: etc etc

This page has also a login box, so I changed the error_nopermission (I assume this is the correct template).

<input type="text" class="textbox" name="username" value="{$logonname}" {$logonreadonly} />

and added to global.php

// Select the board theme to use.
// ... SOME CODE I DON'T DISPLAY

// Set Windows Username
$logon = explode("\\", $_SERVER['AUTH_USER']);
if (strtolower($logon[1]) == strtolower('User.Admin1') OR strtolower($logon[1]) == strtolower('User.Admin2')) {
	$logonname = '';
	$logonreadonly = '';
}
else {
	$logonname = $logon[1];
	$logonreadonly = 'readonly';
}

// This user has a custom theme set in their profile

But this aint working.

PS: readonly attribute is working here, however advised by ZiNgA BuRgA I should change it. Smile