From richard@burninghorizons.net Sat Jul 14 15:57:34 2007 From: Richard Green To: dev@lists.roundcube.net Subject: Re: Patch for login form with users in syntax username@domain Date: Thu, 11 May 2006 17:12:59 +0100 Message-ID: <7c4117404985b11b693c83f59b42c3d9@debian> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8472070625575637630==" --===============8472070625575637630== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This has been done already, but I guess depending on SourceForge may not be a= ccessible 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: > Hello list, >=20 > Here is a fast solution to avoid writing of "@domain" after username when > your server hosted virtual domains. >=20 > 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. >=20 > 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; >=20 > Changes in program/include/main.inc >=20 > --- 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')); > } >=20 > +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; > +} > + >=20 > // 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']; >=20 > + // 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; >=20 > $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] > >=20 > + > + > + > + > + > > >=20 > --- end of diff >=20 >=20 > --===============8472070625575637630==--
Domain$domain
$labels[user]$fields[user]