diff --git a/email_verify.check.inc b/email_verify.check.inc index 439370c..48cb315 100644 --- a/email_verify.check.inc +++ b/email_verify.check.inc @@ -16,14 +16,18 @@ function email_verify_checkall() { while ($row = db_fetch_object($result)) { if (email_verify_check($row->mail)) { - $content .= "". check_plain($row->name) ."". check_plain($row->mail); + $content .= "" . check_plain($row->name) . "" . check_plain($row->mail); - if (++$found >= 100) break; + if (++$found >= 100) { + break; + } } } $content .= ""; unset($found, $result, $row); // Destroy variables - print theme("page", $content); -} \ No newline at end of file + // TODO Please change this theme call as discussed at http://drupal.org/node/224333#theme_page. + // print theme("page", $content); + print $content; +} diff --git a/email_verify.inc.php b/email_verify.inc.php index 7e66d41..566f882 100644 --- a/email_verify.inc.php +++ b/email_verify.inc.php @@ -11,7 +11,7 @@ function _email_verify_check($mail) { return; } - include_once dirname(__FILE__) .'/windows_compat.inc'; + include_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'email_verify') . '/windows_compat.inc'); $host = substr(strchr($mail, '@'), 1); @@ -32,7 +32,9 @@ function _email_verify_check($mail) { $connect = @fsockopen($smtp, 25, $errno, $errstr, 15); - if (!$connect) continue; + if (!$connect) { + continue; + } if (ereg("^220", $out = fgets($connect, 1024))) { // OK, we have a SMTP connection @@ -48,8 +50,9 @@ function _email_verify_check($mail) { } } - if (!$connect) + if (!$connect) { return t('Email host %host is invalid, please contact us for clarification.', array('%host' => "$host")); + } $from = variable_get('site_mail', ini_get('sendmail_from')); @@ -59,20 +62,20 @@ function _email_verify_check($mail) { } $localhost = $_SERVER["HTTP_HOST"]; - if (!$localhost) // Happens with HTTP/1.0 - //should be good enough for RFC compliant SMTP servers + if (!$localhost) { //should be good enough for RFC compliant SMTP servers $localhost = 'localhost'; + } fputs($connect, "HELO $localhost\r\n"); - $out = fgets($connect, 1024); + $out = fgets($connect, 1024); fputs($connect, "MAIL FROM: <$from>\r\n"); $from = fgets($connect, 1024); fputs($connect, "RCPT TO: <{$mail}>\r\n"); - $to = fgets($connect, 1024); + $to = fgets($connect, 1024); fputs($connect, "QUIT\r\n"); fclose($connect); - if (!ereg ("^250", $from)) { + if (!ereg("^250", $from)) { // Again, something went wrong before we could really test the address, // be on the safe side and accept it. watchdog('email_verify', "Could not verify email address at host $host: $from"); @@ -94,7 +97,7 @@ function _email_verify_check($mail) { return; } - if (!ereg ("^250", $to)) { + if (!ereg("^250", $to)) { watchdog('email_verify', "Rejected email address: $mail. Reason: $to"); return t('%mail is invalid, please contact us for clarification.', array('%mail' => "$mail")); } diff --git a/email_verify.info b/email_verify.info index 7948520..04b0ffe 100644 --- a/email_verify.info +++ b/email_verify.info @@ -1,5 +1,5 @@ name = "Email verify" description = "Verifies email addresses during registration and account edit." -core = 6.x +core = 7.x package = Registration dependencies[] = user diff --git a/email_verify.install b/email_verify.install index 89ce38b..f9573ef 100644 --- a/email_verify.install +++ b/email_verify.install @@ -5,7 +5,7 @@ */ /** - * Implementation of hook_enable(). + * Implements hook_enable(). */ function email_verify_enable() { // Check that fsockopen() works on port 25. @@ -13,9 +13,9 @@ function email_verify_enable() { // What follows is an adapted version of email_verify_check(). // The documentation http://api.drupal.org/api/5/function/hook_install says: - // "Note that since this function is called from a full bootstrap, all functions - // (including those in modules enabled by the current page request) are available - // when this hook is called. Use cases could be displaying a user message, or + // "Note that since this function is called from a full bootstrap, all functions + // (including those in modules enabled by the current page request) are available + // when this hook is called. Use cases could be displaying a user message, or // calling a module function necessary for initial setup, etc." // However, this does not seem to be the case, so we can't reuse email_verify_check(). @@ -23,7 +23,7 @@ function email_verify_enable() { // What SMTP servers should we contact? $mx_hosts = array(); - include_once dirname(__FILE__) .'/windows_compat.inc'; + include_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'email_verify') . '/windows_compat.inc'); if (!getmxrr($host, $mx_hosts)) { // When there is no MX record, the host itself should be used @@ -46,8 +46,8 @@ function email_verify_enable() { if (!$connect) { $message = t('Email verify has tried contacting the mail host but did not receive a reply.' - .' Check with your hosting provider that the function fsockopen() is properly configured on your server,' - .' and that port 25 is open. The module has been disabled.'); + . ' Check with your hosting provider that the function fsockopen() is properly configured on your server,' + . ' and that port 25 is open. The module has been disabled.'); watchdog('email_verify', $message, WATCHDOG_ERROR); drupal_set_message($message, 'error'); diff --git a/email_verify.module b/email_verify.module index 9e18aeb..79c29d2 100644 --- a/email_verify.module +++ b/email_verify.module @@ -7,32 +7,39 @@ */ /** - * Implementation of hook_help(). - * @return - * Help text for section. + * Implements hook_help(). */ function email_verify_help($path, $arg) { if ($path == 'admin/help#email_verify') { $txt = 'This module verifies that email addresses are valid during account registration or edit.'; - return '

'. t($txt) .'

'; + return '

' . t($txt) . '

'; } } /** - * Implementation of hook_user(). + * Implements hook_form_FORM_ID_alter(). */ -function email_verify_user($op, &$edit, &$account, $category = NULL) { - if ($op == 'validate' && $category == 'account') { - return email_verify_edit_validate(arg(1), $edit); - } +function email_verify_form_user_register_form_alter(&$form, &$form_state, $form_id) { + $form['#validate'][] = 'email_verify_edit_validate'; +} + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function email_verify_form_user_profile_form_alter(&$form, &$form_state, $form_id) { + $form['#validate'][] = 'email_verify_edit_validate'; } -function email_verify_edit_validate($uid, &$edit) { +/** + * @todo Please document this function. + * @see http://drupal.org/node/1354 + */ +//function email_verify_edit_validate($uid, &$edit) { +function email_verify_edit_validate($form, &$form_state) { // Validate the e-mail address: - if ($error = email_verify_check($edit['mail'])) { + if ($error = email_verify_check($form_state['input']['mail'])) { form_set_error('mail', $error); } - return $edit; } /** @@ -43,19 +50,19 @@ function email_verify_edit_validate($uid, &$edit) { * NULL if the address exists, or an error message if we found a problem with the address. */ function email_verify_check($mail) { - include_once dirname(__FILE__) .'/email_verify.inc.php'; + include_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'email_verify') . '/email_verify.inc.php'); return _email_verify_check($mail); } /** - * Implementation of hook_menu(). + * Implements hook_menu(). */ function email_verify_menu() { $items['admin/user/user/email_verify'] = array( 'title' => 'Email Verify', 'page callback' => 'email_verify_checkall', 'access arguments' => array('administer users'), - 'type' => MENU_LOCAL_TASK, + 'type' => MENU_LOCAL_TASK, 'file' => 'email_verify.check.inc', ); return $items; diff --git a/windows_compat.inc b/windows_compat.inc index a573702..ff84df5 100644 --- a/windows_compat.inc +++ b/windows_compat.inc @@ -1,3 +1,4 @@ +