[imp] How to use imp_get_vinfo

eculp at encontacto.net eculp at encontacto.net
Thu May 1 18:54:52 PDT 2003


Quoting Thomas O'Brien <thomas at creativebusinessystems.com>:

| Ed,
|
| Here's the section from my conf.php.dist
|
| // If this is set to a function name, that function will be used to
| // set the $imp['user'] at login time; See the 'imp_get_vinfo'
| // function below for an example.
| $conf['hooks']['vinfo'] = '';
|
| /* Here is an example imp_get_vinfo function. If $type == 'vdomain',
|  * this function returns the HTTP_HOST variable after removing the
|  * 'mail.' subdomain.
|  *
|  * If $type == 'username', this function returns a unique username
|  * composed of $imp['user'] + vdomain.
|  *
|  * ex. $HTTP_HOST = 'mail.mydomain.com', $imp['user'] = 'myname'
|  *   $vdomain  = 'mydomain.com'
|  *   $username = 'myname_mydomain_com'
|  */
| // if (!function_exists('imp_get_vinfo')) {
| //     function imp_get_vinfo ($type = 'username') {
| //         global $conf, $imp;
| //
| //         $vdomain = getenv('HTTP_HOST');
| //         $vdomain = preg_replace('|^mail\.|i', '', $vdomain);
| //         $vdomain = strtolower($vdomain);
| //
| //         if ($type == 'username') {
| //             return preg_replace('|\.|', '_', $imp['user'] . '_' .
| $vdomain);
| //         } elseif ($type == "vdomain") {
| //             return $vdomain;
| //         } else {
| //             return new PEAR_Error('invalid type: ' . $type);
| //         }
| //     }
| // }
|
| It's in /horde/imp/conf.php
|
| I've tried what you suggested and here's the results:
| Notice: Undefined index: imp in
| c:\inetpub\wwwroot\horde\imp\config\conf.php on line 367
Thomas,

What specifically in on line 367 in your conf.php ?

You have changed

$conf['hooks']['vinfo'] = '_imp_hook_vinfo';

back to

$conf['hooks']['vinfo'] = 'imp_get_vinfo';

Right?

|
| Warning: Cannot add header information - headers already sent by (output
| started at c:\inetpub\wwwroot\horde\imp\config\conf.php:367) in
| c:\inetpub\wwwroot\horde\imp\redirect.php on line 106
|
| Notice: invalid user or password (errflg=1) in Unknown on line 0
|
| Notice: invalid user or password (errflg=1) in Unknown on line 0
|
| Notice: invalid user or password (errflg=1) in Unknown on line 0
|
| Notice: Too many login failures (errflg=2) in Unknown on line 0
|
| Again it looks like the user info passed to imap is in the form user
| name '@sk82win.com' Also this version will only correctly pars the
| hostname for www.domain.com it doesn't work when browsing to
| mail.domain.com. I wish I had a better uinderstanding of preg_replace
| commands

The first eregi one i sent would work for www.domain.com, mail.domain.com and
www.mail.domain.com.  To use preg_replace rather than eregi the following
should work:

$vdomain = strtolower(preg_replace('/^mail\.|^www\.|^www\.mail\./i', '',
$_SERVER['HTTP_HOST']));

All on one line

Let me know especially about line 367.

ed


-------------------------------------------------



More information about the imp mailing list