From brett@roundcubeforum.net Sat Jul 14 15:57:34 2007 From: Brett Patters - Roundcube Forum Admin To: dev@lists.roundcube.net Subject: Re: Patch for login form with users in syntax username@domain Date: Thu, 11 May 2006 14:35:59 -0400 Message-ID: <4463840F.90708@roundcubeforum.net> In-Reply-To: <7c4117404985b11b693c83f59b42c3d9@debian> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8818066833342543844==" --===============8818066833342543844== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Richard Green wrote: > This has been done already, but I guess depending on SourceForge may not be= accessible yet: > > http://sourceforge.net/tracker/index.php?func=3Ddetail&aid=3D1437854&group_= id=3D139281&atid=3D742850 > > -- > Richard Green > > > On Thu, 11 May 2006 18:17:07 +0300, "Todor Dragnev" wrote: > =20 >> Hello list, >> >> Here is a fast solution to avoid writing of "@domain" after username when >> your server hosted virtual domains. >> >> With this patch is enought to write only "john" in login form instead of " >> john(a)virtualdomain.test" >> If $rcmail_config['add_domain2username'] is true RoundCube will strip >> domain name from web addresses like: http://webmail.virtualdomain.test/ or >> http://www.virtualdomain.test/RoundCube/ and add it to username. >> >> Changes in config/main.inc.php: >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> // If this is true will use hostname to get domain name >> $rcmail_config['add_domain2username'] =3D true; >> >> Changes in program/include/main.inc >> >> --- start diff --- >> Index: program/include/main.inc >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> RCS file: /cvsroot/roundcubemail/roundcubemail/program/include/main.inc,v >> retrieving revision 1.48 >> diff -u -p -r1.48 main.inc >> --- program/include/main.inc 23 Mar 2006 22:32:32 -0000 1.48 >> +++ program/include/main.inc 11 May 2006 14:51:57 -0000 >> @@ -366,6 +366,19 @@ function rcmail_set_locale($lang) >> $OUTPUT->set_charset(rcube_language_prop($lang, 'charset')); >> } >> >> +function parse_domain($url) { >> + $domain =3D '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; >> + // Followed by one or max 63 domain characters (dot separated). >> + // Must be followed by one set consisting a period of two >> + $regex =3D '^(' . $domain . '\.)+((' . $domain . '{1,63}\.)'. >> + $domain . '{2,63}'. >> + ')$'; >> + if (ereg( $regex, strtolower($url), $regs)) { >> + return $regs[4]; >> + } >> + return false; >> +} >> + >> >> // perfom login to the IMAP server and to the webmail service >> function rcmail_login($user, $pass, $host=3DNULL) >> @@ -376,6 +389,14 @@ function rcmail_login($user, $pass, $hos >> if (!$host) >> $host =3D $CONFIG['default_host']; >> >> + // parse username for syntax like username(a)domain >> + $have_at =3D explode("@", $user); >> + if ($CONFIG['add_domain2username'] && sizeof($have_at) =3D=3D 1) { >> + if ($domain =3D parse_domain($_SERVER[HTTP_HOST])) { >> + $user =3D $user . '@' . $domain; // add domain from hostname >> + } >> + } >> + >> // parse $host URL >> $a_host =3D parse_url($host); >> if ($a_host['host']) >> @@ -1586,13 +1607,18 @@ function rcmail_login_form($attrib) >> EOF; >> >> $OUTPUT->add_script("$JS_OBJECT_NAME.gui_object('loginform', >> '$form_name');"); >> - >> + $domain =3D strtoupper (parse_domain($_SERVER[HTTP_HOST])) ; >> $out =3D <<> $form_start >> $SESS_HIDDEN_FIELD >> $fields[action] >> >> >> + >> + >> + >> + >> + >> >> >> >> --- end of diff >> >> >> >> =20 > > > > =20 There's also a post about this on the forum :) --=20 ~ Brett Patterson ~ Roundcube Forum Admin www.roundcubeforum.net --===============8818066833342543844==--
Domain$domain
$labels[user]$fields[user]