Blame Scripts/newbb2phpbb/classes/mail.php

62b044
62b044
/***
62b044
 * Mail
62b044
 */
62b044
62b044
class MAIL
62b044
{
62b044
62b044
    public $notification; 
62b044
    public $notification_subject;
62b044
    public $notification_message;
62b044
62b044
   /***
62b044
    * Class constructor
62b044
    */
62b044
62b044
    function __construct()
62b044
    {
62b044
        // Initialize variables with default values
62b044
        $this->notification = 'NO';
62b044
        $this->notification_subject         = '[CentOS Forum] User account notification.';
62b044
        $this->notification_message         = "Dear =USER_FIRST_NAME=,
62b044
62b044
The CentOS Forums (http://centos.org/forums/) were migrated from
62b044
Xoops+CBB(newbb) to phpBB3 and the user accounts were moved to an LDAP
62b044
server. As consequence your user account is now on that LDAP server.
62b044
62b044
In order to make this happen, it was needed to reset your account
62b044
password. Your password(userPassword) is here with the rest of your
62b044
user account information.
62b044
62b044
The following LDAP entry has the information of your user account:
62b044
62b044
               dn: =DN=
62b044
              uid: =UID1=
62b044
              uid: =UID2=
62b044
     userPassword: =PASS=
62b044
             mail: =MAIL=
62b044
               cn: =CN=
62b044
               sn: =SN=
62b044
     employeeType: =TYPE=
62b044
preferredLanguage: =LANG=
62b044
      displayName: =DISPLAYNAME=
62b044
62b044
With this migration we are preparing the ground to unify all CentOS
62b044
user accounts into a common place. If you need to authenticate
62b044
somewhere under centos.org domain use any of your uids and the
62b044
password provided above.
62b044
62b044
Best Regards,
62b044
--
62b044
The CentOS Team";
62b044
62b044
        // Reinitialize variables with form values
62b044
        $config = array('notification', 'notification_subject', 'notification_message');
62b044
        foreach ( $config as $param )
62b044
        {
62b044
            if ( ! isset($_SESSION[$param]))
62b044
            {
62b044
                $_SESSION[$param] = $this->$param;
62b044
            }   
62b044
62b044
            $_SESSION[$param] = isset($_POST[$param])?$_POST[$param]:$_SESSION[$param];
62b044
62b044
            $this->$param = $_SESSION[$param];
62b044
        }
62b044
    }
62b044
    
62b044
   /***
62b044
    * Send
62b044
    * -------
62b044
    * $info is an array with the following indexes:
62b044
    *  - mailto
62b044
    *  - name
62b044
    *  - dn
62b044
    *  - newpass
62b044
    */
62b044
62b044
    function send( $info )
62b044
    {
62b044
        // Do replacements in message template
62b044
        $this->notification_message = preg_replace('/=MAIL=/',  $info['mailto'],$this->notification_message);
62b044
        $this->notification_message = preg_replace('/=DN=/',    $info['dn'],$this->notification_message);
62b044
        $this->notification_message = preg_replace('/=UID1=/',  $info['uid1'],$this->notification_message);
62b044
        $this->notification_message = preg_replace('/=UID2=/',  $info['uid2'],$this->notification_message);
62b044
        $this->notification_message = preg_replace('/=PASS=/',  $info['userpassword'],$this->notification_message);
62b044
        $this->notification_message = preg_replace('/=CN=/',    $info['cn'],$this->notification_message);
62b044
        $this->notification_message = preg_replace('/=SN=/',    $info['sn'],$this->notification_message);
62b044
        $this->notification_message = preg_replace('/=TYPE=/',  $info['employeetype'],$this->notification_message);
62b044
        $this->notification_message = preg_replace('/=LANG=/',  $info['preferredlanguage'],$this->notification_message);
62b044
        $this->notification_message = preg_replace('/=DISPLAYNAME=/',$info['displayname'],$this->notification_message);
62b044
        $this->notification_message = preg_replace('/=USER_FIRST_NAME=/', preg_replace('/ .+$/','',$info['cn']), $this->notification_message);
62b044
62b044
        $to              = $info['mailto'];
62b044
        $subject         = $this->notification_subject;
62b044
        $message         = $this->notification_message;
62b044
        $headers         = 'From: webmaster';
62b044
        $extra_params    = '-fwebmaster';
62b044
        if ( $this->notification == 'YES' )
62b044
        {
62b044
            return mail( $to, $subject, $message, $headers, $extra_params );
62b044
        }
62b044
    }
62b044
62b044
   /***
62b044
    * Send notification ?
62b044
    * Show form selector
62b044
    */
62b044
62b044
    function get_configForm( $disabled = '' )
62b044
    {
62b044
        $htmlblock = array('

Mail Notification:

','
');
62b044
62b044
        // Mail template
62b044
        array_push($htmlblock, 
62b044
62b044
        '
Subject:
',
62b044
        '
<input name="notification_subject" size="70" '.$disabled.' value="'.$this->notification_subject.'" />
',
62b044
                               
62b044
       '
Message:
',
62b044
       '
<textarea name="notification_message" cols="70" rows="15" '.$disabled.'>'.$this->notification_message.'</textarea>
',
62b044
62b044
        '
Send notifications ?:
',
62b044
        '
<select name="notification" '.$disabled.'>');
62b044
62b044
        if ( $this->notification == 'YES' )
62b044
        {
62b044
            array_push($htmlblock,
62b044
                '<option value="NO">NO</option>',
62b044
                '<option value="YES" selected="selected">YES</option>');
62b044
        }
62b044
        else
62b044
        {
62b044
            array_push ( $htmlblock, 
62b044
                '<option value="NO" selected="selected">NO</option>',
62b044
                '<option value="YES">YES</option>');
62b044
        }
62b044
62b044
        array_push($htmlblock, '</select>Use it with care!');
62b044
62b044
        array_push($htmlblock, '');
62b044
62b044
        return $htmlblock;
62b044
    }
62b044
62b044
   /***
62b044
    * Class destructor
62b044
    */
62b044
62b044
    function __destruct()
62b044
    {
62b044
    
62b044
    }
62b044
}
62b044
62b044
$mail = new MAIL;
62b044
?>