Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-25-2010, 11:23 PM
BigJohnny's Avatar
BigJohnny BigJohnny is offline
 
Join Date: Jun 2006
Location: Canada
Posts: 500
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Can anyone see why this script might not work?

My PHP skills aren't so hot, and this script that USED TO work, but has not ever been changed, no longer works now.

This is for Live Feedback Registration and vB 3.8.3. It's the email verification function. It always ends up failing to connect to legitimate email address'.

If anyone could just look over the code real quick and see if anything stands out I'd really appreciate it. I'd like to get this working.

Everything else but the email check works just fine.

email_check.php
PHP Code:
<?php
define
('NO_REGISTER_GLOBALS'1);
define('SKIP_SESSIONCREATE'1);
define('NOCOOKIES'1);
define('DIE_QUIETLY'1);
//define('SKIP_DEFAULTDATASTORE', 1);
define('DIR'dirname(__FILE__));
require_once 
'./global.php';
$vbulletin->input->clean_array_gpc('p', array('email' => TYPE_STR));
if(
$vbulletin->GPC['email'] != '')
{
    
$email htmlspecialchars_uni(trim(convert_urlencoded_unicode($vbulletin->GPC['email'])));
    
$verify = (!ini_get('safe_mode')) ? verifyMailAddy($email) : 0;
    
header('Content-Type: text/plain;');
    require_once(
DIR '/includes/functions_user.php');
    switch(
true)
    {
        case 
is_banned_email($email) == 1:
            echo 
2;
            break;
        case 
$verify != 0;
            echo 
$verify;
            break;
        case 
$vbulletin->options['requireuniqueemail'] &&
            
$existingemail $db->query_first("
                SELECT
                    email
                FROM
                    " 
TABLE_PREFIX "user
                WHERE
                    email = '" 
$db->escape_string($email) . "'
                "
)
            :
            echo 
1;
            break;
        default;
            echo 
0;
    }
}

function 
verifyMailAddy($email)
{
    list(
$user_name$domain) = split('@',$email);
    if(
function_exists('getmxrr'))
    {
        
$mail_exchanger = (getmxrr($domain$mx)) ? $mx[0] : $domain;
    }
    else
    {
        
$mx windoz_getmxrr($domain);
        
$mail_exchanger = (!$mx) ? $domain $mx;
    }
    if(
$connect = @fsockopen($mail_exchanger25$errno$errstr15))
    {
        
$receive fgets($connect128);
        if(
substr($receive03) == '220')
        {
            
fputs($connect"HELO ".$_SERVER['HTTP_HOST']."\r\n");
            
$receive fgets($connect128);
            if(
substr($receive03) == '554')
            {
                
//Server rejected query.
                
fputs($connect"QUIT\r\n");
                
fclose($connect);
                return 
3;
            }
            
fputs($connect"MAIL FROM: <{$email}>\r\n");
            
$mail_from fgets$connect128 );
            
fputs($connect"RCPT TO: <{$email}>\r\n");
            
$mail_to fgets($connect128);
            
fputs($connect"QUIT\r\n");
            
fclose($connect);
            if(
substr($mail_to03) != '250')
            {
                
//Server rejected address
                
return 5;
            }
        }
        else
        {
            
//No response from server
            
return 4;
        }
    }
    else
    {
        
//Can not connect E-Mail server.
        
return 3;
    }
    
//Good, but no guarantee that they don't have an accept all email addy.
    
return 0;
}

function 
windoz_getmxrr($domain)
{
    if(!empty(
$domain))
    {
        
$domain escapeshellcmd($domain); 
        
exec("nslookup -type=MX $domain",$receive_data);
        foreach(
$receive_data as $data_line)
        {
            if(
preg_match("#^$domain#"$data_line))
            {
                if(
preg_match('#^.*MX preference = (\d{1,10}), mail exchanger = (.*)$#siU'$data_line$match))
                {
                    return 
$match[2];
                }
            }
        }
        return 
false;
    }
    return 
false;
}
?>
live_feedback_system.js
Code:
//Live Feedback Registration 1.31
var currentSelect = '';
function _loadTextDoc(url, query_string, callback) {
	entry_check = new vB_AJAX_Handler(true);
	entry_check.onreadystatechange(callback);
	entry_check.send(url, query_string);
}
function _processNameInput() {
	if(entry_check.handler.readyState == 4) {
		if(entry_check.handler.status == 200) {
			liveCheck('', entry_check.handler.responseText);
		}
	}
}
function liveCheck(input, response, min_user_length) {
	var namecheck	 = fetch_object('nameCheck');
	if(response != ''){
		switch (response){
			case '3':_replaceText(namecheck, lfsr_username_invalid_semicolon, 'namebad');break;
			case '2':_replaceText(namecheck, lfsr_username_invalid_censored, 'namebad');break;
			case '1':_replaceText(namecheck, lfsr_username_not_available, 'namebad');break;
			case '0':_replaceText(namecheck, lfsr_username_available, 'namegood');break;
		}
	} else {
		if(input.length >= parseInt(min_user_length, '10')){
			_loadTextDoc('username_check.php', 'username='+PHP.urlencode(input), _processNameInput);
		} else {
			if(input.length >= 1){
				_replaceText(namecheck, lfsr_username_too_short, 'nametooshort');
			} else {
				_replaceText(namecheck, lfsr_username_choose, 'namechoose');
			}
		}
	}
}

function match_fields(id,type){
	fieldcheck = fetch_object(id);
	if(type == 'password'){
		field1 = document.forms.register.password;
		field2 = document.forms.register.passwordconfirm;
		matchAllow = false; //temp
	}else{
		field1 = document.forms.register.email;
		field2 = document.forms.register.emailconfirm;
	}
	if(!matchAllow){
		switch (true){
			case field1.value == '' || field2.value == '':
				_replaceText(fieldcheck, lfsr_match_fill_both, 'nametooshort');
				break;
			case field1.value != field2.value:
				_replaceText(fieldcheck, lfsr_match_false, 'namebad');
				break;
			default:_replaceText(fieldcheck, lfsr_match_true, 'namegood');break;
		}
	}
}
function _processRefererInput() {
	if(entry_check.handler.readyState == 4) {
		if(entry_check.handler.status == 200) {
			checkReferer('', entry_check.handler.responseText);
		}
	}
}
function checkReferer(input, response, min_user_length){
	referer_check = fetch_object('lfsreferer');
	var field1 = document.forms.register.referrername;
	if(response != ''){
		switch (response){
			case '1':_replaceText(referer_check, lfsr_username_member_true, 'namegood');break;
			default:_replaceText(referer_check, lfsr_username_member_false, 'namebad');;break;
		}
	} else {
		switch (true){
			case input.length >= parseInt(min_user_length, '10'):
				_loadTextDoc('username_check.php', 'username='+PHP.urlencode(input), _processRefererInput);
				break;
			case input.length >= 1:
				_replaceText(referer_check, lfsr_username_member_false, 'namebad');
				break;
		}
	}
}
function _processEmailInput(){
	if(entry_check.handler.readyState == 4) {
		if(entry_check.handler.status == 200) {
			checkEmail('', entry_check.handler.responseText);
		}
	}
}
function checkEmail(input, response){
	email_check = fetch_object('lfseconfirm');
	matchAllow = true;
	switch(true){
		case response == '':
			if(currentSelect != input){
				if(email_check.firstChild != lfsr_email_validation_progress && input != ''){
					_replaceText(email_check, lfsr_email_validation_progress, 'emailtooshort');
				}
				switch (true){
					case /^[A-z0-9\.!#\$%&\'\*\+-\/=\?\{|}~]+@([0-9.]+|([^\s]+\.+[A-z]{2,6}))$/.test(input):
						_loadTextDoc('email_check.php', 'email='+PHP.urlencode(input), _processEmailInput);
						currentSelect = input;
						break;
					case input.length >= 1:
						_replaceText(email_check, lfsr_email_invalid, 'emailbad');
						break;
				}
			}
			break;
		case response != '':
			switch (response){
				case '5':_replaceText(email_check, lfsr_email_reject+' '+lfsr_email_submit_valid, 'emailbad');break;
				case '4':_replaceText(email_check, lfsr_email_no_responce, 'emailbad');break;
				case '3':_replaceText(email_check, lfsr_email_no_connect+' '+lfsr_email_submit_valid, 'emailbad');;break;
				case '2':_replaceText(email_check, lfsr_email_banned, 'emailbad');break;
				case '1':_replaceText(email_check, lfsr_email_exists, 'emailbad');break;
				case '0':_replaceText(email_check, lfsr_email_valid, 'emailgood');matchAllow = false;break;
			}
			break;
	}
}
function pwSuggest(){
	var email_check_on = fetch_object('lfseconfirm');
	if (email_check_on.className == 'warning'){
		_replaceText(email_check_on, '', '');
	}
	suggest = fetch_object('pw_suggest');
	suggestText = fetch_object('pw_suggest_text');
	var pwsize=Math.floor(Math.random()*8)+7;
	chars = '+-*abcdefghijklmn!op$qrst~uvwxyz@;ABCDEFGHIJ^KLMNOP_QRSTUV#&WXYZ1234.567890%';
	pass = '';
	for(x=0;x<pwsize;x++){
		pass += chars.charAt(Math.floor(Math.random() * 72));
	}
	_replaceText(suggestText, lfsr_password_suggest, 'pwsuggest');
	_replaceText(suggest, pass, 'pwsuggest');
}
function livePassCheck(pw, pwsug){
	var pwlength = pw.length;
	if (pwlength == 1){
		//_replaceText(fetch_object('pw_strength_title'), 'Password Strength:', '');
		_replaceText(fetch_object('pw_guideline'), lfsr_password_guid, 'pwwarning');
		suggest = fetch_object('pw_suggest');
	}
	if (pwlength == 0){
		if(pwsug != 0){
			pwSuggest();
		}
		//_replaceText(fetch_object('pw_strength_title'), 'Password Strength:', '');
		_replaceText(fetch_object('pw_guideline'), '', '');
	}
	if(pwlength > 0){
		var boost = 0;
		if(pwlength > 9){pwlength = 9;}
		var numnum = pw.replace (/[\d]/g,'');
		var num = (pw.length - numnum.length);
		if(num > 3){num = 3;}
		if(num == 2){num = 3;}else if(num == 3){num = 4;}
		var symbols = pw.replace (/\W/g,'');
		var symb = (pw.length - symbols.length);
		if(symb > 3){symb = 3;}
		if(symb == 2){symb = 4;}else if(symb == 3){symb = 6;}
		var numup = pw.replace (/[A-Z]/g,'');
		var up = (pw.length - numup.length);
		if(up > 3){up = 3;}
		if(up == 2){up = 3;
		} else if(up == 3){up = 4;}

		
		var numlow = pw.replace (/[A-Z]/g,'');
		var low = (pw.length - numlow.length);
		if(low > 3){low = 3;}
		if(low == 2){low = 3;
		} else if(low == 3){low = 4;}

		if(num >= 1 && symb >= 1 && up >= 1 && low >= 1){boost+=2;}
		if(num >= 3 && symb >= 4 && up >= 3 && low >= 3){boost+=4;}
		if(num >= 4 && symb >= 6 && up >= 4 && low >= 4){boost+=6;}
		var pwstr = pwlength + num + symb + up + low + boost;
		if(pwstr < 0){pwstr = 0;}
		if(pwstr > 100){pwstr = 100;}
		switch(true){
			case pwstr < 10:_replaceText(fetch_object('lfspwconfirm'), lfsr_password_strength_very_weak, 'pw_veryweak');break;
			case pwstr < 15:_replaceText(fetch_object('lfspwconfirm'), lfsr_password_strength_weak, 'pw_weak');break;
			case pwstr < 20:_replaceText(fetch_object('lfspwconfirm'), lfsr_password_strength_mediocre, 'pw_mediocre');break;
			case pwstr < 27:_replaceText(fetch_object('lfspwconfirm'), lfsr_password_strength_strong, 'pw_strong');break;
			case pwstr > 26:_replaceText(fetch_object('lfspwconfirm'), lfsr_password_strength_verystrong, 'pw_verystrong');break;
		}
	}else{
		_replaceText(fetch_object('lfspwconfirm'), '', '');
	}
}
function _replaceText(el, text, class_name, colspan, width) {
	if(el.firstChild){
		el.removeChild(el.firstChild);
		if(el.firstChild){
			el.removeChild(el.firstChild);
		}
	}
	el.appendChild(document.createTextNode(text));
	el.className = class_name;
}
function loadDefault(){_replaceText(fetch_object('lfseconfirm'), lfsr_email_default, 'warning');}
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:05 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03488 seconds
  • Memory Usage 2,222KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete