<?php

  // sample configuration file that has:
  //   - username modifications TURNED OFF
  //   - per-domain settings and modifications TURNED OFF
  //   - per-user settings TURNED ON



  // Global Variables, don't touch these unless you want to break the plugin
  //
  global $notPartOfDomainName, $numberOfDotSections, $useSessionBased,
         $putHostNameOnFrontOfUsername, $checkByExcludeList,
         $at, $dot, $dontUseHostName, $perUserSettingsFile,
         $smHostIsDomainThatUserLoggedInWith, 
         $useDomainFromServerEnvironment, $virtualDomains,
         $sendmailVirtualUserTable, $virtualDomainDataDir,
         $allVirtualDomainsAreUnderOneHost, $vlogin_debug, $removeFromFront,
         $chopOffDotSectionsFromRight, $chopOffDotSectionsFromLeft,
         $translateHostnameTable, $pathToQmail, $atConversion,
         $removeDomainIfGiven, $alwaysAddHostName, $reverseDotSectionOrder,
         $replacements, $usernameReplacements, $forceLowercase,
         $securePort, $useDomainFromVirtDomainsArray,
         $usernameDomainIsHost, $stripDomainFromUserSubstitution,
         $serviceLevelBackend, $internalServiceLevelFile,
         $vlogin_dsn, $sqlServiceLevelQuery, $SQLDatabaseDomainLookup,
         $SQLDatabaseUserLookup, $SQLDatabaseServiceLevelLookup,
         $default_org_logo, $rawLoginIsOutgoingEmailAddress,
         $dontUseHostNameUserList, $always_prepend, $always_append,
         $IMAPServerRules, $SMTPServerRules;



  // should vlogin use session-based methods for storing dynamic
  // configuration settings (faster, but requires one source patch
  // unless you are running SquirrelMail 1.5.2 or greater)?
  // set to 1 for yes, zero for no
  //
  $useSessionBased = 0;



  // List of domain-specific attributes (note that each domain is 
  // specified in this array by any string that is unique to the 
  // virtual host name (not necessarily the whole host name -- 
  // "mydomain" is probably enough to represent "mydomain.com")
  //
  $virtualDomains = array(
  );


  // When turned on, this setting attempts to use the "domain"
  // setting from the $virtualDomains array for the hostname
  // portion of the username instead of using the parsed domain
  // from the URL (which is only used if "domain" is not given
  // in the relevant $virtualDomains section).  This makes most
  // settings below obsolete as long as you always specify a
  // "domain" in all of your $virtualDomain entries.
  //
  $useDomainFromVirtDomainsArray = 0;


  // Similarly, you can choose to use the domain directly from
  // the web server environment as the hostname portion of the
  // username by specifying the name of the server environment
  // variable that should be used.  This setting makes most
  // most of the domain/host rule settings in Vlogin unnecessary.
  //
  // $useDomainFromServerEnvironment = 'SERVER_NAME';
  $useDomainFromServerEnvironment = '';


  // Reverse dot section order allows you to invert a host name
  // from, for example, www.domain.com to com.domain.www (note
  // that this is done before any other changes are made to the
  // host name)
  //
  $reverseDotSectionOrder = 0;


  // $numberOfDotSections setting dictates the size (given in "dot 
  // sections") that the hostname should be, while $removeFromFront
  // determines if, in order to reach that size, "dot sections" will
  // be taken off the beginning of the host name (if set to zero,
  // the host name will be trimmed from the end)
  //
  $numberOfDotSections = 2;
  $removeFromFront = 1;


  // $checkByExcludeList should be set to 1 in order to strip out any
  // "dot sections" that match those found in $notPartOfDomainName
  //
  $checkByExcludeList = 1;
  
  
  // Our "exclude list" of strings that are not usually part of the domain name
  //
  $notPartOfDomainName = array('www'
			       ,'mail'
			       ,'email'
			       ,'webmail');


  // If some text (such as "mail.") should be prepended
  // to all user domains, that value should be given here
  //
  $always_prepend = '';


  // If some text (such as ".mail") should be appended
  // to all user domains, that value should be given here
  //
  $always_append = '';


  // $chopOffDotSectionsFromLeft allows specification of a set number of "dot
  // sections" to be removed from the front of the host name
  //
  $chopOffDotSectionsFromLeft = 0;


  // $chopOffDotSectionsFromRight allows specification of a set number of "dot
  // sections" to be removed from the end of the host name
  //
  $chopOffDotSectionsFromRight = 0;


  // Some mail systems won't take the '@' symbol in the login name for virtual 
  // host setups.  Change that here:
  //
  $at = '@';


  // Also change the '.' symbol if necessary.
  //
  $dot = '.';


  // If your users tend to confuse '@' and '%' in their email
  // addresses, you may specify a list of characters that will,
  // if found in the user name, all be converted to whatever
  // you have specified for the $at setting
  //
  //$atConversion = array('%');
  //$atConversion = array('%', '&');
  $atConversion = array();


  // This will make sure that everything is done in lowercase, 
  // including the host name and the username.  Many IMAP servers 
  // are not case sensitive, so this setting can usually be ignored.  
  // Please do not confuse this with the SquirrelMail 
  // $force_username_lowercase setting, although this setting may 
  // have the same ultimate effect.
  //
  $forceLowercase = 0;


  // Replace or remove all instances of any other character(s)
  // in the host name by using this setting.  Specifying a
  // blank value will result in characters being removed.  Note
  // that these are replaced in the order given.
  //
  $replacements = array(
  //                  '-'  => '_',   // all dashes converted to underscores
  //                  'xx' => '',    // all double xx's removed
                       );


  // Force the host name to be added unconditionally to the 
  // user name, which should be avoided if possible.  Only use
  // this setting if you are converting your '@' sign to a 
  // character that is also part of your usernames (such as '.')
  //
  $alwaysAddHostName = 0;


  // Indicates that username/hostname combination should begin with hostname
  // (such as "domainname.username") instead of typical hostname following the
  // username (such as "username@domain.com")
  //
  $putHostNameOnFrontOfUsername = 0;


  // You can choose not to append the host name to users' login
  // names no matter what by setting this to 1.
  //
  $dontUseHostName = 1;


  // You can specify a list of users for whom you'd like 
  // $dontUseHostName to be turned on; all other users 
  // will get the value as set above.  The username used
  // to log in must exactly match the usernames in this
  // list to activate $dontUseHostName.
  //
  $dontUseHostNameUserList = array(
//     'postmaster',
//     'jose',
  );


  // Additionally, you can make sure your users' outgoing emails
  // come from the domain they used to log in if you set this to 1.  
  // NOTE that you'll typically only need to do this if you are 
  // using $dontUseHostName = 1
  //
  $smHostIsDomainThatUserLoggedInWith = 0;


  // If users log in with a full email address, you can strip
  // off the domain information, leaving just the username.
  // The domain name parsed out of the URL by this plugin
  // will be added back to the username unless you use the
  // $dontUseHostName functionality
  //
  $removeDomainIfGiven = 0;


  // When looking for which domain whose settings should be used,
  // we'll usually use the hostname from the URL.  If you'd rather
  // trust the user (you sure you want to do that?) and use the 
  // hostname part of the login username (if available), set this
  // to 1.
  //
  $usernameDomainIsHost = 0;


  // Use the original raw/unmapped/unmolested login username
  // as the outgoing email address for all users?  Use with
  // care.  Might want to turn off identity editing in main
  // SquirrelMail configuration as well, otherwise, this
  // setting can be overridden by the user.  Other, possibly
  // better ways to manage users' email addresses is with
  // these plugins:
  //   Retrieve User Data
  //   http://www.squirrelmail.org/plugin_view.php?id=11
  //   Ask User Info
  //   http://www.squirrelmail.org/plugin_view.php?id=142
  //   New User Wizard
  //   http://www.squirrelmail.org/plugin_view.php?id=181
  //
  $rawLoginIsOutgoingEmailAddress = 0;


  // Override the SquirrelMail $data_dir here, and optionally
  // include the virtual domain name or user name as part of
  // the path (indicated by the constants "###VIRTUAL_DOMAIN###"
  // and "###USERNAME###" respectively) (you may also do this
  // on a per-host basis in the $virtualDomains array)
  //
  //$virtualDomainDataDir = '/home/squirrelmail/data/';
  //$virtualDomainDataDir = '/home/sites/###VIRTUAL_DOMAIN###/data/';
  //$virtualDomainDataDir = '/home/sites/###VIRTUAL_DOMAIN###/###USERNAME###/data/';
  $virtualDomainDataDir = '';


  // For sites that host all virtual domains off of a single host
  // URL (commonly used for SSL implementations using just one
  // certificate for all hosts), where URLs look like:
  //
  // http://www.onedomain.com/virtualdomain.com/mail
  //
  // or:
  //
  // http://www.onedomain.com/mail/webmail.php?domain=virtualdomain.com
  //
  // set this value to a regular expression that will capture
  // the domain portion of the URI in the first group (set of 
  // parenthesis); otherwise, leave it set to an empty string.
  //
  // The two examples below pick the domain out of the sample
  // URIs given above.
  //
  // $allVirtualDomainsAreUnderOneHost = '/[\/]*(.*?)(\/|$)/';
  // $allVirtualDomainsAreUnderOneHost = '/domain=(.*?)(&|$)/';
  $allVirtualDomainsAreUnderOneHost = '';


  // This is the port that HTTPS is served over.  You should not
  // need to change this value.
  //
  $securePort = 443;


  // Remove the domain portion (if present) of the username given
  // by the user ONLY when replacing values in the $virtualDomains
  // array and $virtualDomainDataDir.  This setting has no effect
  // on how the username is handled anywhere else by this plugin.
  // Set to zero to leave the username as is.
  //
  $stripDomainFromUserSubstitution = 0;


  // Replace or remove all instances of any other character(s)
  // in the user name by using this setting.  Specifying a
  // blank value will result in characters being removed.  Note
  // that these are replaced in the order given.
  //
  $usernameReplacements = array(
  //                  '-'  => '_',   // all dashes converted to underscores
  //                  'xx' => '',    // all double xx's removed
                               );


  // This is the path to the sendmail virtual user table, which 
  // should be empty if you are not using sendmail or such a table
  // to remap user logins
  //
  //$sendmailVirtualUserTable = '/etc/mail/virtusertable';
  $sendmailVirtualUserTable = '';


  // This is the path to the hostname translation table, which
  // should be empty if you do not need to remap the domain
  // host name that your users will be logging in from
  //
  //$translateHostnameTable = '/path/to/squirrelmail/plugins/vlogin/data/hostmap.php';
  $translateHostnameTable = '';


  // This is the path to Qmail.  It should *only* be specified
  // if you are using Qmail/Vpopmail aliased domains and want to 
  // prevent users of aliased domains from logging in to a domain 
  // alias, accidentally creating more than one preferences file 
  // for themselves.  Otherwise, please leave this as an empty string.
  //
  // Also, when using this functionality, please verify that the user
  // you run httpd with is able to read the file ~qmail/users/assign
  //
  //$pathToQmail = '/var/qmail';
  $pathToQmail = '';


  // Define a default org_logo if you want a fallback in case
  // one of your domain org_logo settings points to a missing
  // file.
  //
  $default_org_logo = '';


  // Specify per-user settings in a separate file, if needed - the
  // the path to that file is given here (empty string if not used)
  //
  $perUserSettingsFile = '/path/to/squirrelmail/plugins/vlogin/data/users.php';


  // In some cases, users' IMAP server can be derived from
  // their username.  The rules in this array are applied to
  // the domain portion of the user login to determine the
  // correct IMAP server address.  For a description of what
  // each rule name does, see the same-named setting above
  // Please leave this array completely empty if you do not
  // use this feature.
  //
  $IMAPServerRules = array(
                          );


  // In some cases, users' SMTP server can be derived from
  // their username.  The rules in this array are applied to
  // the domain portion of the user login to determine the
  // correct SMTP server address.  For a description of what
  // each rule name does, see the same-named setting above
  // Please leave this array completely empty if you do not
  // use this feature.
  //
  $SMTPServerRules = array(
                          );


  // When different user classes exist, you can define them using
  // "service levels" and attach different sets of SquirrelMail
  // settings to each one.  The $serviceLevelBackend setting tells
  // where and how to determine what service level group the current
  // user belongs to.  Currently, you may choose from:
  //
  // 0 = off, not in use
  // 1 = internal (use $internalServiceLevelFile below)
  // 2 = SQL (use $sqlServiceLevelDSN and $sqlServiceLevelQuery below)
  //
  $serviceLevelBackend = 0;


  // When using Vlogin's internally supplied service level
  // file, specify the path to it here.  More details about
  // this file are available in the provided sample file
  // "service_levels.sample.php"
  //
  $internalServiceLevelFile = '/path/to/squirrelmail/plugins/vlogin/data/service_levels.php';


  // When using a SQL database to specify user service levels,
  // this must be a valid SQL query that extracts ONLY the
  // service level value for the given user.
  //
  //   %1 in this query will be replaced with the user name
  //
  $sqlServiceLevelQuery = 'SELECT service_level FROM users WHERE username = "%1"';


  // SQL lookups for per-user, per-domain and/or per-service level
  // settings.  If given as empty strings, SQL lookups will not be
  // performed.  If defined, any settings found will override other
  // settings found in any Vlogin configuration files.  Each query
  // must return two-column rows consisting of a setting name and a
  // setting value.
  //
  //   %1 in each query will be replaced with the user name, domain or
  //      service level when looking for per-user, per-domain or per-
  //      service level settings
  //
  // See README for sample DDL and further details.
  //
  //$SQLDatabaseDomainLookup = 'SELECT setting_name, setting_value FROM squirrelmail_settings WHERE username = "%1"';
  //$SQLDatabaseUserLookup = 'SELECT setting_name, setting_value FROM squirrelmail_settings WHERE domain = "%1"';
  //$SQLDatabaseServiceLevelLookup = 'SELECT setting_name, setting_value FROM squirrelmail_settings WHERE service_level = "%1"';
  $SQLDatabaseDomainLookup = '';
  $SQLDatabaseUserLookup = '';
  $SQLDatabaseServiceLevelLookup = '';


  // When using a SQL database to specify user service levels
  // or any other Vlogin settings, this must be a valid DSN 
  // that connects to the database with enough permission to 
  // read the appropriate table.  Theoretically, any SQL 
  // database supported by Pear should be supported here.  A 
  // MySQL example is included below.  For more details about 
  // DSN syntax and list of supported database types, please see:
  //   http://pear.php.net/manual/en/package.database.db.intro-dsn.php
  //
  $vlogin_dsn = 'mysql://user:password@localhost/email_users';


  // Turn this on to test your configuration settings - the final
  // IMAP login value will be presented after all processing has
  // been completed
  //
  $vlogin_debug = 0;


