Having just posted that, I had a brainwave...
In
program/include/main.inc, the
$user variable was changed to the POST variable again.
$user = $_POST['_user'].'@'.substr($_SERVER['HTTP_HOST'], 5);If you put this:
// domain name hack
$user .= '@'.substr($_SERVER['HTTP_HOST'], 5);above this:
// query if user already registered
$sql_result = $DB->query("SELECT user_id, username, language, preferences
FROM ".get_table_name('users')."
WHERE mail_host=? AND (username=? OR alias=?)",
$host,
$user,
$user);instead, it works a treat. It merely adds the relevant domain to the end of the
$user string, then checks to see if the user is new or not.
I tied this in with Insanity5902's hack slightly modified shown below to put the "@domain.tld" on the login screen to avoid confusion:
$domain_lizzie = substr($_SERVER['HTTP_HOST'], 5);
$out = <<<EOF
$form_start
$SESS_HIDDEN_FIELD
$fields[action]
<table><tr>
<td class=title"><label for="rcmloginuser">$labels[user]</label></td>
<td>$fields[user]</td>
<td></td>
<td style="text-align:right;letter-spacing:1px;">@$domain_lizzie</td>
</tr><tr>
<td class="title"><label for="rcmloginpwd">$labels[pass]</label></td>
<td>$fields[pass]</td>
$form_host
</tr></table>
$form_end
EOF;The bits you need to add are line 1 of the above and lines 12 + 13.
Also,
[quote="bigpaw ]
Hmm..... so you'd want something like:
$user = $_POST['_user'].'@'.substr($_SERVER['HTTP_HOST'], 5);
right?
Bret, this is may cause some trouble.....using substr() the way you have chops off the first five characters of HTTP_HOST, if someone has a domain name that is not of the form mail.domain.tld then he is in trouble e.g if i had webmail.domain.tld, i would get il.domain.tld instead of the desired domain.tld. using explode and reversing the array as Insanity said would also work...
[/quote]
Regarding this, if you change the highlighted number to 8 for webmail.domain.tld - the number of characters leading up to the bit you want. You can use the .htaccess file to ensure that the www. is omitted so as to avoid user input errors.
The
$_SERVER['HTTP_HOST'] string is more reliable than some of the
explode() methods which don't work for mail.domain.co.uk for example... I have both on my server.
Hope this helps someone.