1<?php
2
3
4  // Global Variables, don't touch these unless you want to break the plugin
5  //
6  global $notPartOfDomainName, $numberOfDotSections, $useSessionBased,
7         $putHostNameOnFrontOfUsername, $checkByExcludeList,
8         $at, $dot, $dontUseHostName, $perUserSettingsFile,
9         $smHostIsDomainThatUserLoggedInWith,
10         $useDomainFromServerEnvironment, $virtualDomains,
11         $sendmailVirtualUserTable, $virtualDomainDataDir,
12         $allVirtualDomainsAreUnderOneHost, $vlogin_debug, $removeFromFront,
13         $chopOffDotSectionsFromRight, $chopOffDotSectionsFromLeft,
14         $translateHostnameTable, $pathToQmail, $atConversion,
15         $removeDomainIfGiven, $alwaysAddHostName, $reverseDotSectionOrder,
16         $replacements, $usernameReplacements, $forceLowercase,
17         $securePort, $useDomainFromVirtDomainsArray,
18         $usernameDomainIsHost, $stripDomainFromUserSubstitution,
19         $serviceLevelBackend, $internalServiceLevelFile,
20         $vlogin_dsn, $sqlServiceLevelQuery, $SQLDatabaseDomainLookup,
21         $SQLDatabaseUserLookup, $SQLDatabaseServiceLevelLookup,
22         $default_org_logo, $rawLoginIsOutgoingEmailAddress,
23         $dontUseHostNameUserList, $always_prepend, $always_append,
24         $IMAPServerRules, $SMTPServerRules, $postProcessingPattern,
25         $postProcessingReplacement, $virtualUserTableDBFlavor,
26         $override_config_during_login, $appendDomainToOutgoingEmailAddress;
27
28
29
30  // should vlogin use session-based methods for storing dynamic
31  // configuration settings (faster, but requires one source patch
32  // unless you are running SquirrelMail 1.5.2 or greater)?
33  // set to 1 for yes, zero for no
34  //
35  $useSessionBased = 0;
36
37
38
39  // List of domain-specific attributes (note that each domain is
40  // specified in this array by any string that is unique to the
41  // virtual host name (not necessarily the whole host name --
42  // "mydomain" is probably enough to represent "mydomain.com")
43  //
44  $virtualDomains = array(
45
46      // URL for this one might be "mypersonaldomain.net"
47      //
48      'mypersonaldomain' => array(
49          'domain'     => 'mypersonaldomain.net',
50          'org_name'   => 'My Own Personal Domain',
51          'org_logo'   => '../images/myface.gif',
52          'org_title'  => '(isset($_SESSION["username"]) ? $_SESSION["username"] . " - Mail" : "Mail")',
53          'settingsWithEmbeddedPHP' => array(
54                                           'org_title',
55                                      ),
56      ),
57
58      // URL for this one might be "www.oneofmyclientsdomain.com"
59      //
60      'oneofmyclientsdomain' => array(
61          'domain'     => 'oneofmyclientsdomain.com',
62          'org_name'   => 'One Very Important Client Email',
63          'org_logo'   => '../images/spacer.gif',  // no logo
64          'org_title'  => '(isset($_SESSION["username"]) ? $_SESSION["username"] . " - Mail" : "Mail")',
65          'settingsWithEmbeddedPHP' => array(
66                                           'org_title',
67                                      ),
68      ),
69
70  );
71
72
73  // When turned on, this setting attempts to use the "domain"
74  // setting from the $virtualDomains array for the hostname
75  // portion of the username instead of using the parsed domain
76  // from the URL (which is only used if "domain" is not given
77  // in the relevant $virtualDomains section).  This makes most
78  // settings below obsolete as long as you always specify a
79  // "domain" in all of your $virtualDomain entries.
80  //
81  $useDomainFromVirtDomainsArray = 1;
82
83
84  // Similarly, you can choose to use the domain directly from
85  // the web server environment as the hostname portion of the
86  // username by specifying the name of the server environment
87  // variable that should be used.  This setting makes most
88  // most of the domain/host rule settings in Vlogin unnecessary.
89  //
90  // $useDomainFromServerEnvironment = 'SERVER_NAME';
91  $useDomainFromServerEnvironment = '';
92
93
94  // Reverse dot section order allows you to invert a host name
95  // from, for example, www.domain.com to com.domain.www (note
96  // that this is done before any other changes are made to the
97  // host name)
98  //
99  $reverseDotSectionOrder = 0;
100
101
102  // $numberOfDotSections setting dictates the size (given in "dot
103  // sections") that the hostname should be, while $removeFromFront
104  // determines if, in order to reach that size, "dot sections" will
105  // be taken off the beginning of the host name (if set to zero,
106  // the host name will be trimmed from the end)
107  //
108  $numberOfDotSections = 2;
109  $removeFromFront = 1;
110
111
112  // $checkByExcludeList should be set to 1 in order to strip out any
113  // "dot sections" that match those found in $notPartOfDomainName
114  //
115  $checkByExcludeList = 1;
116
117
118  // Our "exclude list" of strings that are not usually part of the domain name
119  //
120  $notPartOfDomainName = array('www'
121			       ,'mail'
122			       ,'email'
123			       ,'webmail');
124
125
126  // If some text (such as "mail.") should be prepended
127  // to all user domains, that value should be given here
128  //
129  $always_prepend = '';
130
131
132  // If some text (such as ".mail") should be appended
133  // to all user domains, that value should be given here
134  //
135  $always_append = '';
136
137
138  // $chopOffDotSectionsFromLeft allows specification of a set number of "dot
139  // sections" to be removed from the front of the host name
140  //
141  $chopOffDotSectionsFromLeft = 0;
142
143
144  // $chopOffDotSectionsFromRight allows specification of a set number of "dot
145  // sections" to be removed from the end of the host name
146  //
147  $chopOffDotSectionsFromRight = 0;
148
149
150  // Some mail systems won't take the '@' symbol in the login name for virtual
151  // host setups.  Change that here:
152  //
153  $at = '@';
154
155
156  // Also change the '.' symbol if necessary.
157  //
158  $dot = '.';
159
160
161  // If your users tend to confuse '@' and '%' in their email
162  // addresses, you may specify a list of characters that will,
163  // if found in the user name, all be converted to whatever
164  // you have specified for the $at setting
165  //
166  //$atConversion = array('%');
167  //$atConversion = array('%', '&');
168  $atConversion = array();
169
170
171  // This will make sure that everything is done in lowercase,
172  // including the host name and the username.  Many IMAP servers
173  // are not case sensitive, so this setting can usually be ignored.
174  // Please do not confuse this with the SquirrelMail
175  // $force_username_lowercase setting, although this setting may
176  // have the same ultimate effect.
177  //
178  $forceLowercase = 0;
179
180
181  // Replace or remove all instances of any other character(s)
182  // in the host name by using this setting.  Specifying a
183  // blank value will result in characters being removed.  Note
184  // that these are replaced in the order given.
185  //
186  $replacements = array(
187  //                  '-'  => '_',   // all dashes converted to underscores
188  //                  'xx' => '',    // all double xx's removed
189                       );
190
191
192  // Force the host name to be added unconditionally to the
193  // user name, which should be avoided if possible.  Only use
194  // this setting if you are converting your '@' sign to a
195  // character that is also part of your usernames (such as '.')
196  //
197  $alwaysAddHostName = 0;
198
199
200  // Indicates that username/hostname combination should begin with hostname
201  // (such as "domainname.username") instead of typical hostname following the
202  // username (such as "username@domain.com")
203  //
204  $putHostNameOnFrontOfUsername = 0;
205
206
207  // You can choose not to append the host name to users' login
208  // names no matter what by setting this to 1.
209  //
210  $dontUseHostName = 0;
211
212
213  // You can specify a list of users for whom you'd like
214  // $dontUseHostName to be turned on; all other users
215  // will get the value as set above.  The username used
216  // to log in must exactly match the usernames in this
217  // list to activate $dontUseHostName.
218  //
219  $dontUseHostNameUserList = array(
220//     'postmaster',
221//     'jose',
222  );
223
224
225  // Additionally, you can make sure your users' outgoing emails
226  // come from the domain they used to log in if you set this to 1.
227  // NOTE that you'll typically only need to do this if you are
228  // using $dontUseHostName = 1, although it will also help fill
229  // in the right domain name when users send messages to users
230  // on the same system without putting a domain name after the
231  // destination address
232  //
233  $smHostIsDomainThatUserLoggedInWith = 1;
234
235
236  // If users log in with a full email address, you can strip
237  // off the domain information, leaving just the username.
238  // The domain name parsed out of the URL by this plugin
239  // will be added back to the username unless you use the
240  // $dontUseHostName functionality
241  //
242  $removeDomainIfGiven = 0;
243
244
245  // When looking for which domain whose settings should be used,
246  // we'll usually use the hostname from the URL.  If you'd rather
247  // trust the user (you sure you want to do that?) and use the
248  // hostname part of the login username (if available), set this
249  // to 1.
250  //
251  $usernameDomainIsHost = 0;
252
253
254  // Use the original raw/unmapped/unmolested login username
255  // as the outgoing email address for all users?  Use with
256  // care.  Might want to turn off identity editing in main
257  // SquirrelMail configuration as well, otherwise, this
258  // setting can be overridden by the user.  Other, possibly
259  // better ways to manage users' email addresses is with
260  // these plugins:
261  //   Retrieve User Data
262  //   http://www.squirrelmail.org/plugin_view.php?id=11
263  //   Ask User Info
264  //   http://www.squirrelmail.org/plugin_view.php?id=142
265  //   New User Wizard
266  //   http://www.squirrelmail.org/plugin_view.php?id=181
267  //
268  $rawLoginIsOutgoingEmailAddress = 0;
269
270
271  // When using $rawLoginIsOutgoingEmailAddress, should the
272  // user's domain be added to the new outgoing email address?
273  // The value for $at (usually "@") will be added between
274  // the two if this is turned on.
275  //
276  $appendDomainToOutgoingEmailAddress = 0;
277
278
279  // Override the SquirrelMail $data_dir here, and optionally
280  // include the virtual domain name or user name as part of
281  // the path (indicated by the constants "###VIRTUAL_DOMAIN###"
282  // and "###USERNAME###" respectively) (you may also do this
283  // on a per-host basis in the $virtualDomains array)
284  //
285  //$virtualDomainDataDir = '/home/squirrelmail/data/';
286  //$virtualDomainDataDir = '/home/sites/###VIRTUAL_DOMAIN###/data/';
287  //$virtualDomainDataDir = '/home/sites/###VIRTUAL_DOMAIN###/###USERNAME###/data/';
288  $virtualDomainDataDir = '';
289
290
291  // For sites that host all virtual domains off of a single host
292  // URL (commonly used for SSL implementations using just one
293  // certificate for all hosts), where URLs look like:
294  //
295  // http://www.onedomain.com/virtualdomain.com/mail
296  //
297  // or:
298  //
299  // http://www.onedomain.com/mail/webmail.php?domain=virtualdomain.com
300  //
301  // set this value to a regular expression that will capture
302  // the domain portion of the URI in the first group (set of
303  // parenthesis); otherwise, leave it set to an empty string.
304  //
305  // The two examples below pick the domain out of the sample
306  // URIs given above.
307  //
308  // $allVirtualDomainsAreUnderOneHost = '/[\/]+(.*?)(\/|$)/';
309  // $allVirtualDomainsAreUnderOneHost = '/domain=(.*?)(&|$)/';
310  $allVirtualDomainsAreUnderOneHost = '';
311
312
313  // This is the port that HTTPS is served over.  You should not
314  // need to change this value.
315  //
316  $securePort = 443;
317
318
319  // Remove the domain portion (if present) of the username given
320  // by the user ONLY when replacing values in the $virtualDomains
321  // array and $virtualDomainDataDir.  This setting has no effect
322  // on how the username is handled anywhere else by this plugin.
323  // Set to zero to leave the username as is.
324  //
325  $stripDomainFromUserSubstitution = 0;
326
327
328  // Replace or remove all instances of any other character(s)
329  // in the user name by using this setting.  Specifying a
330  // blank value will result in characters being removed.  Note
331  // that these are replaced in the order given.
332  //
333  $usernameReplacements = array(
334  //                  '-'  => '_',   // all dashes converted to underscores
335  //                  'xx' => '',    // all double xx's removed
336                               );
337
338
339  // This is the path to the sendmail virtual user table, which
340  // should be empty if you are not using sendmail or such a table
341  // to remap user logins
342  //
343  //$sendmailVirtualUserTable = '/etc/mail/virtusertable';
344  $sendmailVirtualUserTable = '';
345
346
347  // You can access a virtual user table in database (Berkeley/dbm
348  // style) with $sendmailVirtualUserTable above by setting this to
349  // the correct DB type.  For exmaple, Postfix files such as
350  // aliases.db might be in "db4" format, or Qmail might use "cdb"
351  // database files.  If the plugin does not correctly access keys
352  // and values in the database, a NULL character might need to be
353  // manually added to keys and values - to force this functionality,
354  // append ":null" to the end of this setting - for example, "db4:null".
355  //
356  // Make sure to leave this empty when using a plain text virtual
357  // user table.
358  //
359  // NOTE: to use this feature, you must have the dba extension
360  // compiled into PHP (--enable-dba) and the database type you
361  // specify here must also be one of the available handlers.
362  // See: http://php.net/manual/ref.dba.php
363  //
364  //$virtualUserTableDBFlavor = 'db4';
365  $virtualUserTableDBFlavor = '';
366
367
368  // Final arbitrary replacements may be done on the full IMAP
369  // username, after all other username processing is complete.
370  //
371  // The $postProcessingPattern must specify a full regular
372  // expression pattern (including delimiters and modifiers),
373  // or an array thereof.  $postProcessingReplacement should
374  // specify a replacement string or array thereof, or be left
375  // blank, in which case all patterns will be removed.  These
376  // two values are plugged directly into preg_replace(), so
377  // the documentation here applies:
378  // http://www.php.net/manual/function.preg-replace.php
379  //
380  // Exaples:
381  //
382  //$postProcessingPattern = '/@/';
383  //$postProcessingReplacement = '.';
384  //
385  //$postProcessingPattern = '/@/';
386  //$postProcessingReplacement = '';
387  //
388  //$postProcessingPattern = array('/jack/i', '/jill/i');
389  //$postProcessingReplacement = 'spot';
390  //
391  //$postProcessingPattern = array('/jack/i', '/jill/i');
392  //$postProcessingReplacement = array('jill', 'jack');
393  //
394  //$postProcessingPattern = array('/jack/i', '/jill/i');
395  //$postProcessingReplacement = '';
396  //
397  $postProcessingPattern = '';
398  $postProcessingReplacement = '';
399
400
401  // This is the path to the hostname translation table, which
402  // should be empty if you do not need to remap the domain
403  // host name that your users will be logging in from
404  //
405  //$translateHostnameTable = '/path/to/squirrelmail/plugins/vlogin/data/hostmap.php';
406  $translateHostnameTable = '';
407
408
409  // This is the path to Qmail.  It should *only* be specified
410  // if you are using Qmail/Vpopmail aliased domains and want to
411  // prevent users of aliased domains from logging in to a domain
412  // alias, accidentally creating more than one preferences file
413  // for themselves.  Otherwise, please leave this as an empty string.
414  //
415  // Also, when using this functionality, please verify that the user
416  // you run httpd with is able to read the file ~qmail/users/assign
417  //
418  //$pathToQmail = '/var/qmail';
419  $pathToQmail = '';
420
421
422  // Define a default org_logo if you want a fallback in case
423  // one of your domain org_logo settings points to a missing
424  // file.
425  //
426  $default_org_logo = '';
427
428
429  // Specify per-user settings in a separate file, if needed - the
430  // the path to that file is given here (empty string if not used)
431  //
432  //$perUserSettingsFile = '/path/to/squirrelmail/plugins/vlogin/data/users.php';
433  $perUserSettingsFile = '';
434
435
436  // In some cases, users' IMAP server can be derived from
437  // their username.  The rules in this array are applied to
438  // the domain portion of the user login to determine the
439  // correct IMAP server address.  For a description of what
440  // each rule name does, see the same-named setting above
441  // Please leave this array completely empty if you do not
442  // use this feature.
443  //
444  $IMAPServerRules = array(
445                          );
446
447
448  // In some cases, users' SMTP server can be derived from
449  // their username.  The rules in this array are applied to
450  // the domain portion of the user login to determine the
451  // correct SMTP server address.  For a description of what
452  // each rule name does, see the same-named setting above
453  // Please leave this array completely empty if you do not
454  // use this feature.
455  //
456  $SMTPServerRules = array(
457                          );
458
459
460  // When different user classes exist, you can define them using
461  // "service levels" and attach different sets of SquirrelMail
462  // settings to each one.  The $serviceLevelBackend setting tells
463  // where and how to determine what service level group the current
464  // user belongs to.  Currently, you may choose from:
465  //
466  // 0 = off, not in use
467  // 1 = internal (use $internalServiceLevelFile below)
468  // 2 = SQL (use $sqlServiceLevelDSN and $sqlServiceLevelQuery below)
469  //
470  $serviceLevelBackend = 0;
471
472
473  // When using Vlogin's internally supplied service level
474  // file, specify the path to it here.  More details about
475  // this file are available in the provided sample file
476  // "service_levels_example.php"
477  //
478  $internalServiceLevelFile = '/path/to/squirrelmail/plugins/vlogin/data/service_levels.php';
479
480
481  // When using a SQL database to specify user service levels,
482  // this must be a valid SQL query that extracts ONLY the
483  // service level value for the given user.
484  //
485  //   %1 in this query will be replaced with the user name
486  //
487  $sqlServiceLevelQuery = 'SELECT service_level FROM users WHERE username = "%1"';
488
489
490  // SQL lookups for per-user, per-domain and/or per-service level
491  // settings.  If given as empty strings, SQL lookups will not be
492  // performed.  If defined, any settings found will override other
493  // settings found in any Vlogin configuration files.  Each query
494  // must return two-column rows consisting of a setting name and a
495  // setting value.
496  //
497  //   %1 in each query will be replaced with the user name, domain or
498  //      service level when looking for per-user, per-domain or per-
499  //      service level settings
500  //
501  // See README for sample DDL and further details.
502  //
503  //$SQLDatabaseDomainLookup = 'SELECT setting_name, setting_value FROM squirrelmail_settings WHERE username = "%1"';
504  //$SQLDatabaseUserLookup = 'SELECT setting_name, setting_value FROM squirrelmail_settings WHERE domain = "%1"';
505  //$SQLDatabaseServiceLevelLookup = 'SELECT setting_name, setting_value FROM squirrelmail_settings WHERE service_level = "%1"';
506  $SQLDatabaseDomainLookup = '';
507  $SQLDatabaseUserLookup = '';
508  $SQLDatabaseServiceLevelLookup = '';
509
510
511  // When using a SQL database to specify user service levels
512  // or any other Vlogin settings, this must be a valid DSN
513  // that connects to the database with enough permission to
514  // read the appropriate table.  Theoretically, any SQL
515  // database supported by Pear should be supported here.  A
516  // MySQL example is included below.  For more details about
517  // DSN syntax and list of supported database types, please see:
518  //   http://pear.php.net/manual/en/package.database.db.intro-dsn.php
519  //
520  $vlogin_dsn = 'mysql://user:password@localhost/email_users';
521
522
523  // During the login process (when the username the user has
524  // given is possibly adjusted by Vlogin to the correct
525  // IMAP format), the Vlogin and main SquirrelMail
526  // configuration settings are overridden a second time,
527  // possibly just duplicating previous efforts.  The second
528  // override can be turned off with this setting.  That is,
529  // you can try to turn this off to boost performance during
530  // login.  This is a somewhat experimental setting and may
531  // only increase performance a miniscule amount.  If you
532  // try this setting, please send feedback regarding its
533  // results, whether positive, negative or indeterminate.
534  //
535  $override_config_during_login = 1;
536
537
538  // Turn this on to test your configuration settings - the final
539  // IMAP login value will be presented after all processing has
540  // been completed
541  //
542  $vlogin_debug = 0;
543
544
545