Example #1
0
             $mail->send();
             unset($mail);
             $message = array('success' => $PMF_LANG['msgAskThx4Mail']);
         }
     } else {
         $message = array('error' => $PMF_LANG['err_SaveQuestion']);
     }
     break;
 case 'saveregistration':
     $realname = PMF_Filter::filterInput(INPUT_POST, 'realname', FILTER_SANITIZE_STRING);
     $loginname = PMF_Filter::filterInput(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
     $email = PMF_Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
     if (!is_null($loginname) && !empty($loginname) && !is_null($email) && !empty($email) && !is_null($realname) && !empty($realname)) {
         $message = array();
         $user = new PMF_User();
         $user->setLoginMinLength(4);
         // Create user account (login and password)
         // Note: password be automatically generated and sent by email as soon if admin switch user to "active"
         if (!$user->createUser($loginname, '')) {
             $message = array('error' => $user->error());
         } else {
             $user->userdata->set(array('display_name', 'email'), array($realname, $email));
             // set user status
             $user->setStatus('blocked');
             $text = sprintf("New user has been registrated:\n\nUsername: %s\nLoginname: %s\n\n" . "To activate this user do please use the administration interface at %s.", $realname, $loginname, $faqconfig->get('main.referenceURL'));
             $mail = new PMF_Mail();
             $mail->setReplyTo($email, $realname);
             $mail->addTo($faqconfig->get('main.administrationMail'));
             $mail->subject = PMF_Utils::resolveMarkers($PMF_LANG['emailRegSubject']);
             $mail->message = $text;
             $result = $mail->send();
Example #2
0
$email = PMF_Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
$code = PMF_Filter::filterInput(INPUT_POST, 'captcha', FILTER_SANITIZE_STRING);
if (!$captcha->checkCaptchaCode($code)) {
    $captchaError = $PMF_LANG['captchaError'];
}
if (!is_null($loginname) && !is_null($lastname) && !is_null($email) && !isset($captchaError)) {
    $user = new PMF_User();
    $message = '';
    $messages = array();
    // check input data
    $user_name = $loginname;
    $user_realname = $lastname;
    $user_password = '';
    $user_email = $email;
    // check login name
    $user->setLoginMinLength($loginMinLength);
    $user->setLoginInvalidRegExp($loginInvalidRegExp);
    if (!$user->isValidLogin($user_name)) {
        $user_name = '';
        $messages[] = $errorMessages['addUser_loginInvalid'];
    }
    if ($user->getUserByLogin($user_name)) {
        $user_name = '';
        $messages[] = $errorMessages['addUser_loginExists'];
    }
    // check realname
    if ($user_realname == '') {
        $user_realname = '';
        $messages[] = $errorMessages['addUser_noRealName'];
    }
    // ok, let's go
Example #3
0
 /**
  * Adds a new user account to the authentication table.
  * Returns true on success, otherwise false.
  *
  * @param  string $login Login name
  * @param  string $pass  Password
  *
  * @return boolean
  */
 public function add($login, $pass)
 {
     $user = new PMF_User();
     $user->setLoginMinLength(2);
     // LDAP user names can be very short!
     $result = $user->createUser($login, null);
     $user->setStatus('active');
     // Update user information from LDAP
     $user->setUserData(array('display_name' => $this->ldap->getCompleteName($login), 'email' => $this->ldap->getMail($login)));
     return $result;
 }