Blame Scripts/Php/Newbb2Phpbb/classes/mail.php

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

Mail Notification:

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