Exemplo n.º 1
0
function DNS_validate_email($email)
{
    $validator = new email_validation_class();
    if (!function_exists("GetMXRR")) {
        /*
         * If possible specify in this array the address of at least on local
         * DNS that may be queried from your network.
         */
        $_NAMESERVERS = array();
        include "getmxrr.php";
    }
    $validator->timeout = 10;
    $validator->data_timeout = 0;
    $validator->localuser = "******";
    $validator->localhost = "activasistemas.com";
    $validator->debug = 1;
    $validator->html_debug = 0;
    $validator->exclude_address = "";
    if (($result = $validator->ValidateEmailBox($email)) < 0) {
        return 3;
    } else {
        if ($result) {
            return 1;
        } else {
            return 0;
        }
    }
}
Exemplo n.º 2
0
 public static function dbValidateArray(&$targetData, &$definitions, $targetTable, $userID = 0)
 {
     global $pref;
     $u_sql = new db();
     $allOK = TRUE;
     $userID = intval($userID);
     // Precautionary
     $errMsg = '';
     if (!$targetTable) {
         return FALSE;
     }
     foreach ($targetData['data'] as $f => $v) {
         $errMsg = '';
         if (isset($definitions[$f])) {
             $options = $definitions[$f];
             // Validation options to use
             if (!vartrue($options['fieldOptional']) || $v != '') {
                 $toDo = explode(',', $options['vetMethod']);
                 foreach ($toDo as $vm) {
                     switch ($vm) {
                         case 0:
                             // Shouldn't get this - just do nothing if we do
                             break;
                         case 1:
                             // Check for duplicates.
                             if ($v == '') {
                                 $errMsg = ERR_MISSING_VALUE;
                                 break;
                             }
                             $field = varset($options['dbFieldName'], $f);
                             if ($temp = $u_sql->db_Count($targetTable, "(*)", "WHERE `{$f}`='" . $v . "' AND `user_id` != " . $userID)) {
                                 $errMsg = ERR_DUPLICATE;
                             }
                             //								echo "Duplicate check: {$f} = {$v} Result: {$temp}<br />";
                             break;
                         case 2:
                             // Check against $pref
                             if (isset($options['vetParam']) && isset($pref[$options['vetParam']])) {
                                 $tmp = explode(",", $pref[$options['vetParam']]);
                                 foreach ($tmp as $disallow) {
                                     if ('!' == substr(trim($disallow), -1) && $v == str_replace('!', '', $disallow)) {
                                         // Exact match search (noticed with exclamation mark in the end of the word)
                                         $errMsg = ERR_DISALLOWED_TEXT_EXACT_MATCH;
                                     } elseif (stristr($v, trim($disallow))) {
                                         // Wild card search
                                         $errMsg = ERR_DISALLOWED_TEXT;
                                     }
                                 }
                                 unset($tmp);
                             }
                             break;
                         case 3:
                             // Check email address against remote server
                             if (vartrue($pref['signup_remote_emailcheck'])) {
                                 require_once e_HANDLER . "mail_validation_class.php";
                                 list($adminuser, $adminhost) = split("@", SITEADMINEMAIL);
                                 $validator = new email_validation_class();
                                 $validator->localuser = $adminuser;
                                 $validator->localhost = $adminhost;
                                 $validator->timeout = 3;
                                 //	$validator->debug=1;
                                 //	$validator->html_debug=1;
                                 if ($validator->ValidateEmailBox(trim($v)) != 1) {
                                     $errMsg = ERR_INVALID_EMAIL;
                                 }
                             }
                             break;
                         default:
                             echo 'Invalid vetMethod: ' . $options['vetMethod'] . '<br />';
                             // Really a debug aid - should never get here
                     }
                     if ($errMsg) {
                         break;
                     }
                     // Just trap first error
                 }
                 // Add in other validation methods here
             }
         }
         if ($errMsg) {
             // Update the error
             $targetData['errors'][$f] = $errMsg;
             $targetData['failed'][$f] = $v;
             unset($targetData['data'][$f]);
             // Remove the valid entry
             $allOK = FALSE;
         }
     }
     return $allOK;
 }
Exemplo n.º 3
0
     $error .= LANCONTACT_13 . "\\n";
 }
 if (!strpos(trim($_POST['email_send']), "@")) {
     $error .= LANCONTACT_11 . "\\n";
 }
 // Check email address on remote server (if enabled).
 if ($pref['signup_remote_emailcheck'] && $error == '') {
     require_once e_HANDLER . "mail_validation_class.php";
     list($adminuser, $adminhost) = explode('@', SITEADMINEMAIL, 2);
     $validator = new email_validation_class();
     $validator->localuser = $adminuser;
     $validator->localhost = $adminhost;
     $validator->timeout = 3;
     //	$validator->debug=1;
     //	$validator->html_debug=1;
     if ($validator->ValidateEmailBox($sender) != 1) {
         $error .= LANCONTACT_11 . "\\n";
     }
 }
 // No errors - so proceed to email the admin and the user (if selected).
 if (!$error) {
     $body .= "\n\nIP:\t" . USERIP . "\n";
     if (USER) {
         $body .= "User:\t#" . USERID . " " . USERNAME . "\n";
     }
     if (!$_POST['contact_person'] && isset($pref['sitecontacts'])) {
         if ($pref['sitecontacts'] == e_UC_MAINADMIN) {
             $query = "user_perms = '0' OR user_perms = '0.' ";
         } elseif ($pref['sitecontacts'] == e_UC_ADMIN) {
             $query = "user_admin = 1 ";
         } else {
Exemplo n.º 4
0
 /**
  * Test user email helper
  */
 protected function testEmail($email)
 {
     list($adminuser, $adminhost) = explode('@', SITEADMINEMAIL, 2);
     $validator = new email_validation_class();
     $validator->localuser = $adminuser;
     $validator->localhost = $adminhost;
     $validator->timeout = 5;
     $validator->debug = 1;
     $validator->html_debug = 0;
     ob_start();
     $email_status = $validator->ValidateEmailBox($email);
     $text = ob_get_contents();
     ob_end_clean();
     if ($email_status == 1) {
         return $text;
     }
     return false;
 }
Exemplo n.º 5
0
 /**
  * @return bool|string
  */
 function auth_doregister()
 {
     global $_language_path;
     $this->error_msg = "";
     // check for direct link to register2.php
     if (!$_SESSION['_language'] || $_SESSION['_language'] == "") {
         $_SESSION['_language'] = get_accepted_languages();
     }
     $_language_path = init_i18n($_SESSION['_language']);
     $this->auth["uname"] = Request::username('username');
     // This provides access for "crcregister.ihtml"
     $validator = new email_validation_class();
     // Klasse zum Ueberpruefen der Eingaben
     $validator->timeout = 10;
     // Wie lange warten wir auf eine Antwort des Mailservers?
     if (!Seminar_Session::check_ticket(Request::option('login_ticket'))) {
         return false;
     }
     $username = trim(Request::get('username'));
     $Vorname = trim(Request::get('Vorname'));
     $Nachname = trim(Request::get('Nachname'));
     // accept only registered domains if set
     $cfg = Config::GetInstance();
     $email_restriction = $cfg->getValue('EMAIL_DOMAIN_RESTRICTION');
     if ($email_restriction) {
         $Email = trim(Request::get('Email')) . '@' . trim(Request::get('emaildomain'));
     } else {
         $Email = trim(Request::get('Email'));
     }
     if (!$validator->ValidateUsername($username)) {
         $this->error_msg = $this->error_msg . _("Der gewählte Benutzername ist zu kurz!") . "<br>";
         return false;
     }
     // username syntaktisch falsch oder zu kurz
     // auf doppelte Vergabe wird weiter unten getestet.
     if (!$validator->ValidatePassword(Request::quoted('password'))) {
         $this->error_msg = $this->error_msg . _("Das Passwort ist zu kurz!") . "<br>";
         return false;
     }
     if (!$validator->ValidateName($Vorname)) {
         $this->error_msg = $this->error_msg . _("Der Vorname fehlt oder ist unsinnig!") . "<br>";
         return false;
     }
     // Vorname nicht korrekt oder fehlend
     if (!$validator->ValidateName($Nachname)) {
         $this->error_msg = $this->error_msg . _("Der Nachname fehlt oder ist unsinnig!") . "<br>";
         return false;
         // Nachname nicht korrekt oder fehlend
     }
     if (!$validator->ValidateEmailAddress($Email)) {
         $this->error_msg = $this->error_msg . _("Die E-Mail-Adresse fehlt oder ist falsch geschrieben!") . "<br>";
         return false;
     }
     // E-Mail syntaktisch nicht korrekt oder fehlend
     $REMOTE_ADDR = $_SERVER["REMOTE_ADDR"];
     $Zeit = date("H:i:s, d.m.Y", time());
     if (!$validator->ValidateEmailHost($Email)) {
         // Mailserver nicht erreichbar, ablehnen
         $this->error_msg = $this->error_msg . _("Der Mailserver ist nicht erreichbar, bitte überprüfen Sie, ob Sie E-Mails mit der angegebenen Adresse verschicken und empfangen können!") . "<br>";
         return false;
     } else {
         // Server ereichbar
         if (!$validator->ValidateEmailBox($Email)) {
             // aber user unbekannt. Mail an abuse!
             StudipMail::sendAbuseMessage("Register", "Emailbox unbekannt\n\nUser: {$username}\nEmail: {$Email}\n\nIP: {$REMOTE_ADDR}\nZeit: {$Zeit}\n");
             $this->error_msg = $this->error_msg . _("Die angegebene E-Mail-Adresse ist nicht erreichbar, bitte überprüfen Sie Ihre Angaben!") . "<br>";
             return false;
         } else {
             // Alles paletti, jetzt kommen die Checks gegen die Datenbank...
         }
     }
     $check_uname = StudipAuthAbstract::CheckUsername($username);
     if ($check_uname['found']) {
         //   error_log("username schon vorhanden", 0);
         $this->error_msg = $this->error_msg . _("Der gewählte Benutzername ist bereits vorhanden!") . "<br>";
         return false;
         // username schon vorhanden
     }
     if (count(User::findBySQL("Email LIKE " . DbManager::get()->quote($Email)))) {
         $this->error_msg = $this->error_msg . _("Die angegebene E-Mail-Adresse wird bereits von einem anderen Benutzer verwendet. Sie müssen eine andere E-Mail-Adresse angeben!") . "<br>";
         return false;
         // Email schon vorhanden
     }
     // alle Checks ok, Benutzer registrieren...
     $hasher = UserManagement::getPwdHasher();
     $new_user = new User();
     $new_user->username = $username;
     $new_user->perms = 'user';
     $new_user->password = $hasher->HashPassword(Request::get('password'));
     $new_user->vorname = $Vorname;
     $new_user->nachname = $Nachname;
     $new_user->email = $Email;
     $new_user->geschlecht = Request::int('geschlecht');
     $new_user->title_front = trim(Request::get('title_front', Request::get('title_front_chooser')));
     $new_user->title_rear = trim(Request::get('title_rear', Request::get('title_rear_chooser')));
     $new_user->auth_plugin = 'standard';
     $new_user->store();
     if ($new_user->user_id) {
         self::sendValidationMail($new_user);
         $this->auth["perm"] = $new_user->perms;
         return $new_user->user_id;
     }
 }
Exemplo n.º 6
0
// {
// $user->process_batch();
// }
// ------- Test Email. --------------
if (isset($_POST['test_mail'])) {
    require_once e_HANDLER . 'mail_validation_class.php';
    list($adminuser, $adminhost) = explode('@', SITEADMINEMAIL, 2);
    $validator = new email_validation_class();
    $validator->localuser = $adminuser;
    $validator->localhost = $adminhost;
    $validator->timeout = 5;
    $validator->debug = 1;
    $validator->html_debug = 1;
    $text = "<div style='" . ADMIN_WIDTH . "'>";
    ob_start();
    $email_status = $validator->ValidateEmailBox($_POST['test_email']);
    $text .= ob_get_contents();
    ob_end_clean();
    $text .= "</div>";
    $caption = $_POST['test_email'] . " - ";
    $caption .= $email_status == 1 ? "Valid" : "Invalid";
    if ($email_status == 1) {
        $text .= "<form method='post' action='" . e_SELF . $qry . "'>\r\n\t\t<div style='text-align:left'>\r\n\t\t<input type='hidden' name='useraction' value='resend' />\n\r\n\t\t<input type='hidden' name='userid' value='" . $_POST['test_id'] . "' />\n\r\n\t\t<input class='button' type='submit' name='resend_' value='" . USRLAN_112 . "' />\n</div></form>\n";
        $text .= "<div>";
    }
    $ns->tablerender($caption, $text);
    unset($id, $action, $sub_cation);
}
// ------- Update Options. --------------
if (isset($_POST['update_options'])) {
    $mes = e107::getMessage();
Exemplo n.º 7
0
function edit_email($user, $email, $force = False)
{
    $msg = '';
    $query = "SELECT email, username, auth_plugin\n              FROM auth_user_md5\n              WHERE user_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($user->user_id));
    $row = $statement->fetch(PDO::FETCH_ASSOC);
    $email_cur = $row['email'];
    $username = $row['username'];
    $auth_plugin = $row['auth_plugin'];
    if ($email_cur == $email && !$force) {
        return array(True, $msg);
    }
    if (StudipAuthAbstract::CheckField("auth_user_md5.Email", $auth_plugin) || LockRules::check($user->user_id, 'email')) {
        return array(False, $msg);
    }
    if (!$GLOBALS['ALLOW_CHANGE_EMAIL']) {
        return array(False, $msg);
    }
    $validator = new email_validation_class();
    ## Klasse zum Ueberpruefen der Eingaben
    $validator->timeout = 10;
    $REMOTE_ADDR = $_SERVER["REMOTE_ADDR"];
    $Zeit = date("H:i:s, d.m.Y", time());
    // accept only registered domains if set
    $email_restriction = trim(get_config('EMAIL_DOMAIN_RESTRICTION'));
    if (!$validator->ValidateEmailAddress($email, $email_restriction)) {
        if ($email_restriction) {
            $email_restriction_msg_part = '';
            $email_restriction_parts = explode(',', $email_restriction);
            for ($email_restriction_count = 0; $email_restriction_count < count($email_restriction_parts); $email_restriction_count++) {
                if ($email_restriction_count == count($email_restriction_parts) - 1) {
                    $email_restriction_msg_part .= '@' . trim($email_restriction_parts[$email_restriction_count]) . '<br>';
                } else {
                    if (($email_restriction_count + 1) % 3) {
                        $email_restriction_msg_part .= '@' . trim($email_restriction_parts[$email_restriction_count]) . ', ';
                    } else {
                        $email_restriction_msg_part .= '@' . trim($email_restriction_parts[$email_restriction_count]) . ',<br>';
                    }
                }
            }
            $msg .= 'error§' . sprintf(_("Die E-Mail-Adresse fehlt, ist falsch geschrieben oder gehört nicht zu folgenden Domains:%s"), '<br>' . $email_restriction_msg_part);
        } else {
            $msg .= "error§" . _("Die E-Mail-Adresse fehlt oder ist falsch geschrieben!") . "§";
        }
        return array(False, $msg);
        // E-Mail syntaktisch nicht korrekt oder fehlend
    }
    if (!$validator->ValidateEmailHost($email)) {
        // Mailserver nicht erreichbar, ablehnen
        $msg .= "error§" . _("Der Mailserver ist nicht erreichbar. Bitte überprüfen Sie, ob Sie E-Mails mit der angegebenen Adresse verschicken können!") . "§";
        return array(False, $msg);
    } else {
        // Server ereichbar
        if (!$validator->ValidateEmailBox($email)) {
            // aber user unbekannt. Mail an abuse!
            StudipMail::sendAbuseMessage("edit_about", "Emailbox unbekannt\n\nUser: "******"\nEmail: {$email}\n\nIP: {$REMOTE_ADDR}\nZeit: {$Zeit}\n");
            $msg .= "error§" . _("Die angegebene E-Mail-Adresse ist nicht erreichbar. Bitte überprüfen Sie Ihre Angaben!") . "§";
            return array(False, $msg);
        }
    }
    $query = "SELECT Vorname, Nachname\n              FROM auth_user_md5\n              WHERE Email = ? AND user_id != ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($email, $user->user_id));
    $row = $statement->fetch(PDO::FETCH_ASSOC);
    if ($row) {
        $msg .= "error§" . sprintf(_("Die angegebene E-Mail-Adresse wird bereits von einem anderen Benutzer (%s %s) verwendet. Bitte geben Sie eine andere E-Mail-Adresse an."), htmlReady($row['Vorname']), htmlReady($row['Nachname'])) . "§";
        return array(False, $msg);
    }
    // This already moved to the controller
    //    $query = "UPDATE auth_user_md5 SET Email = ? WHERE user_id = ?";
    //    $statement = DBManager::get()->prepare($query);
    //    $statement->execute(array($email, $uid));
    if (StudipAuthAbstract::CheckField("auth_user_md5.validation_key", $auth_plugin)) {
        $msg .= "msg§" . _("Ihre E-Mail-Adresse wurde geändert!") . "§";
        return array(True, $msg);
    } else {
        // auth_plugin does not map validation_key (what if...?)
        // generate 10 char activation key
        $key = '';
        mt_srand((double) microtime() * 1000000);
        for ($i = 1; $i <= 10; $i++) {
            $temp = mt_rand() % 36;
            if ($temp < 10) {
                $temp += 48;
            } else {
                $temp += 87;
            }
            // a = chr(97), z = chr(122)
            $key .= chr($temp);
        }
        $user->validation_key = $key;
        $activatation_url = $GLOBALS['ABSOLUTE_URI_STUDIP'] . 'activate_email.php?uid=' . $user->user_id . '&key=' . $user->validation_key;
        // include language-specific subject and mailbody with fallback to german
        $lang = $GLOBALS['_language_path'];
        // workaround
        if ($lang == '') {
            $lang = 'de';
        }
        include_once "locale/{$lang}/LC_MAILS/change_self_mail.inc.php";
        $mail = StudipMail::sendMessage($email, $subject, $mailbody);
        if (!$mail) {
            return array(True, $msg);
        }
        $query = "UPDATE auth_user_md5 SET validation_key = ? WHERE user_id = ?";
        $statement = DBManager::get()->prepare($query);
        $statement->execute(array($user->validation_key, $user->user_id));
        $msg .= "info§<b>" . sprintf(_('An Ihre neue E-Mail-Adresse <b>%s</b> wurde ein Aktivierungslink geschickt, dem Sie folgen müssen bevor Sie sich das nächste mal einloggen können.'), $email) . '</b>§';
        log_event("USER_NEWPWD", $user->user_id);
        // logging
    }
    return array(True, $msg);
}
Exemplo n.º 8
0
 flush();
 if (isset($_POST['chk_unsublink'])) {
     $serverInfo = $_SERVER['PHP_SELF'];
     $serverInfoArray = explode("/", $serverInfo);
     unset($serverInfoArray[count($serverInfoArray) - 1]);
     $unLink = $_SERVER['HTTP_HOST'] . implode("/", $serverInfoArray) . "/unsubscribe.php?email=" . $to;
     if ($contenttype == 'plain') {
         $unLink = "To Unsubscribe, please click here\n" . $unLink;
     } else {
         $unLink = "To unsubscribe, please <a href='" . $unLink . "'>click here</a>";
     }
     $message = $message . "\n\n" . $unLink;
 }
 if ($unsubLinkFlag === false) {
     if (isset($_POST['chk_emailexists'])) {
         $result = $validator->ValidateEmailBox(trim($to));
         if ($result == 0) {
             print "<br><font size='5' color='#FF0000'>The Email address {$to} may not be valid and may be undeliverable.</font><br>";
             flush();
             continue;
         } else {
             if ($result == 1) {
                 print "<br><font size='5' color='#008000'>Email Address {$to} is valid and deliverable.</font><br>";
             } else {
                 print "<br><font size='5' style='color:#FF0000'>The Email address {$to} may not be valid and may be undeliverable.</font><br>";
             }
         }
         flush();
     }
     print "&nbsp;&nbsp;&nbsp;&nbsp;Sending mail to {$to} ...";
 }