Что нового

Как упростить работу с массивом через цикл

Yura-H2O

Новичок
Сообщения
35
Репутация
0
Можно как-то упростить это через цикл?
Код:
$log_array = StringRegExp($oHTML, 'name="f.{6}',3)
$login_name0 = StringSplit($log_array[0], '"')
$login_name1 = StringSplit($log_array[1], '"')
$login_name2 = StringSplit($log_array[2], '"')

$logselect = _IEFormGetObjByName ($oIE, "rform")
$login = _IEFormElementGetObjByName ($logselect, $login_name0[2])
_IEFormElementSetValue ($login, "MyLogin")
$login = _IEFormElementGetObjByName ($logselect, $login_name1[2])
_IEFormElementSetValue ($login, "MyLogin")
$login = _IEFormElementGetObjByName ($logselect, $login_name2[2])
_IEFormElementSetValue ($login, "MyLogin")
 

joiner

Модератор
Локальный модератор
Сообщения
3,556
Репутация
628
Код:
$log_array = StringRegExp($oHTML, 'name="f.{6}',3)

For $i = 0 To UBound($log_array) -1
 $login_name = StringSplit($log_array[$i], '"')
$logselect = _IEFormGetObjByName ($oIE, "rform")
$login = _IEFormElementGetObjByName ($logselect,  $login_name[2])
_IEFormElementSetValue ($login, "MyLogin")
Next
 
Автор
Y

Yura-H2O

Новичок
Сообщения
35
Репутация
0
не совсем понял, для чего тут Ubound -1
 

DarWiM

Продвинутый
Сообщения
527
Репутация
90
Yura-H2O
Код:
UBound() ;тыкните на название этой функции и найдите в открывшейся странице следующий текст

Помните, что значение, возвращаемое функций UBound, на 1 больше, чем номер последнего элемента в измерении массива!!
 
Автор
Y

Yura-H2O

Новичок
Сообщения
35
Репутация
0
Код:
C:\Documents and Settings\Admin\??????? ????\??????? ??????\script(??????).au3 (90) : ==> Subscript used with non-Array variable.:
$login_name0 = StringSplit($log_array[$i], '"')
$login_name0 = StringSplit($log_array^ ERROR


В IE9 на Win7 работает, а в IE6 выдает вот такую ошибку:( почему?
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,671
Репутация
2,481
Yura-H2O [?]
в IE6 выдает вот такую ошибку:( почему?
Видимо потому что $log_array не является массивом, чтобы сказать более точно, нужно видеть весь скрипт.
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,671
Репутация
2,481
Yura-H2O
Ошибка в определении цикла:
Код:
$log_array = StringRegExp($oHTML, 'name="f.{6}',3)
For $i = 9 To 11

Ведь не факт что StringRegExp вернёт 11 элементов.
 
Автор
Y

Yura-H2O

Новичок
Сообщения
35
Репутация
0
Вот код страницы
Код:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Паспорт - I.UA </title>
<meta http-equiv="content-type" content="text/html; charset=windows-1251" />
<link rel="icon" href="/css/i2/favicon_16.ico" type="image/x-icon">
<link rel="shortcut icon" href="/css/i2/favicon_16.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" media="all" href="/css/i2/blue/ssl/login.y7516ff74.css" />
<!--[if IE]>
<link rel="stylesheet" type="text/css" media="all" href="/css/i2/ie/ssl/login.y7516ff74.css" />
<![endif]-->
<script type="text/javascript">
<!--
var lmJsVersion = 1.690;
var lmJsPath = '/js/';
var JS_LANG_ID = 0;
var I_VER2 = true;
var I_SSL = true;
//-->
</script>
<script type="text/javascript" src="/js/util.yf6c799f6.js"></script>
<script type="text/javascript" src="/js/JSHttpRequest.y9ae7bfa1.js"></script>
<script type="text/javascript" src="/js/i/global.y4e63db47.js"></script>
<script type="text/javascript" src="/js/i/autoload.y2f06a401.js"></script>
<script type="text/javascript" src="/js/form.y5b5b4ba3.js"></script>
<script type="text/javascript" src="/js/i/form.yab1d854f.js"></script>
<script type="text/javascript">
<!--
if (window.frPr)
	window.frPr();
//-->
</script>
</head>
<body>
<div class="logo_container"><a href="http://www.i.ua/" title="I.UA"><img src="/v2/logo/logo_new.png" alt="I.UA" /></a></div>
<!-- }}} HEADER -->
<div class="Body clear">

<!-- CENTER {{{ -->
<script type="text/javascript">
<!--
function chType(type, elem)
{
	var form = document.forms.rform;
	form.type.value = type;
	var pass = form.f573a37;

	if (elem) {
		var li = elem.parentNode.getElementsByTagName('LI');
		for (var i = 0; i < li.length; i++)
			li[i].className = (li[i] == elem ? 'current' : '');
	}

	switch (type) {
	case 2:
	{
		disp('reg_soc_btn', false);
		disp('reg_radio', false);
		disp('reg_form', true);
		disp('reg_login', false, true);
		disp('reg_email', true, true);
		disp('reg_bot', true, true);
		disp('reg_genpass', false);
		pass.disabled = false;
		disp('reg_pconf', true, true);
		break;
	}
	case 3:
	{
		if (!form.socialUserInfo.value) {
			disp('reg_soc_btn', true);
			disp('reg_radio', false);
			disp('reg_form', false);
			disp('reg_login', false);
			break;
		}

		disp('reg_soc_btn', false);
		disp('reg_radio', true);

		var passGen = form.pass_gen;
		var alternate = form.login_alternate;
		var subType = 0;
		for (var i = 0; i < alternate.length; i++) {
			if (alternate[i].checked)
				subType = parseInt(alternate[i].value);
		}
		switch (subType) {
		case 2:
			disp('reg_form', true);
			disp('reg_login', false, true);
			disp('reg_email', true, true);
			//disp('reg_bot', true);
			disp('reg_genpass', true);
			pass.disabled = !!passGen.checked;
			disp('reg_pconf', !passGen.checked, true);
			break;
		case 3:
			disp('reg_form', true);
			disp('reg_login', false, true);
			disp('reg_email', false, true);
			//disp('reg_bot', true);
			disp('reg_genpass', true);
			pass.disabled = !!passGen.checked;
			disp('reg_pconf', !passGen.checked, true);
			break;
		case 1:
		default:
			disp('reg_form', !dge('reg_login').getAttribute('blocked'));
			disp('reg_login', true, true);
			disp('reg_email', false, true);
			//disp('reg_bot', true);
			disp('reg_genpass', false);
			pass.disabled = false;
			disp('reg_pconf', true, true);
			break;
		}

		break;
	}
	case 1:
	default:
	{
		disp('reg_soc_btn', false);
		disp('reg_radio', false);
		disp('reg_form', !dge('reg_login').getAttribute('blocked'));
		disp('reg_login', true, true);
		disp('reg_email', false, true);
		disp('reg_bot', true, true);
		disp('reg_genpass', false);
		pass.disabled = false;
		disp('reg_pconf', true, true);
		break;
	}
	}
}

function disp(elem, disp, disbl)
{
	elem = dge(elem);
	elem.style.display = disp ? '' : 'none';

	if (disbl) {
		var cntrl;
		cntrl = elem.getElementsByTagName('INPUT');
		for (var i = 0; i < cntrl.length; i++)
			cntrl[i].disabled = !disp;
		cntrl = elem.getElementsByTagName('SELECT');
		for (var i = 0; i < cntrl.length; i++)
			cntrl[i].disabled = !disp;
	}
}


var timeOut;
var req;
function doLoad()
{
	if (!req)
		req = new Subsys_JsHttpRequest_Js();
	if (timeOut)
		clearTimeout(timeOut);

	var form = document.forms.rform;
	var eCtrl = document.getElementById('fcf2acc_errCtrl');form.crg.value = form.elements.length;
	var e,n,d,t;

	try{n='domn';
d='Домен';
t=1;
e=0;
if(!form.domn)throw 1;if(form.domn.disabled)throw 0;var domn=form.domn.options[form.domn.selectedIndex].value;validateStr(domn,1,0,0,0);}catch(ce){
		if(typeof ce == 'number' && ce){
			PROJ_showVarError(form,n,d,t,ce,e);
			return;
		}
	}
	var short_email = document.getElementById('short_email');
	short_email.style.display = 'none';
	try{n='fcf2acc';
d='Логин';
t=1;
e=new Array();
e[3]='Логин зарезервирован';
e[7]='Логин уже занят';
if(!form.fcf2acc)throw 1;if(form.fcf2acc.disabled)throw 0;var fcf2acc=form.fcf2acc.value;fcf2acc=trim(fcf2acc);validateStr(fcf2acc,1,20,4,/^[a-z0-9][a-z0-9_.-]*[a-z0-9]$/i);}catch(ce){
		if(typeof ce == 'number' && ce){
			PROJ_showVarError(form,n,d,t,ce,e);
			if (ce == 3) {
				var tmp = short_email.getElementsByTagName('A')[0];
				tmp.href = '/short/?fcf2acc=' + fcf2acc + '&domn=' + domn;
				short_email.style.display = '';
			}
			return;
		}
	}

	var tmp = document.getElementById('sms_email');
	if (fcf2acc.match(/^(38|8)?0\d{9}$/)) {
		PROJ_showVarError(form, 'fcf2acc', d, t, 7, { '7': 'Логин <b>' + fcf2acc + '</b> зарезервирован' });
		tmp.style.display = '';
		return;
	} else {
		tmp.style.display = 'none';
	}

	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			try {
				if (!req.responseJS.error) {
					if (req.responseJS.free) {
						eCtrl.getElementsByTagName('SPAN')[0].innerHTML = 'Логин <b>' + req.responseJS.login + '</b> свободен';
						eCtrl.className = 'message';
						eCtrl.style.display = 'block';
					} else {
						PROJ_showVarError(form, 'fcf2acc', d, t, 7, { '7': 'Логин <b>' + req.responseJS.login + '</b> занят' });
					}
				}
			} catch (e) {}
		}
	}
	req.caching = true;
	req.open('POST', '/js/free.js', true);
	req.send({ login: fcf2acc + '@' + domn });
}

function doLoadUp()
{
	var form = document.forms.rform;
	var beMail = document.getElementById('beMail');
	var login = form.fcf2acc.value ? form.fcf2acc.value : 'ваш логин';
	var domain = form.domn.options[form.domn.selectedIndex].value;

	form.crg.value = form.elements.length;
	beMail.innerHTML = login + '@' + domain;

	if (timeOut)
		clearTimeout(timeOut);
	timeOut = setTimeout(doLoad, 1000);
}

function doLoad2()
{
	if (!req)
		req = new Subsys_JsHttpRequest_Js();
	if (timeOut)
		clearTimeout(timeOut);

	var form = document.forms.rform;
	var eCtrl = document.getElementById('f573a37_f43d71c_errCtrl');
	var e,n,d,t;

//	if (!form.f573a37.value.length)
//		return;
	dge('f573a37_errCtrl').style.display = 'none';
	try{n='f573a37';
d='Пароль';
t=1;
e=new Array();
e[6]='недопустимые символы в пароле';
if(!form.f573a37)throw 1;if(form.f573a37.disabled)throw 0;var f573a37=form.f573a37.value;validateStr(f573a37,1,32,6,/^[a-z0-9~!@#$%^*()_+=\[\]{};:\|,.>\/?-]+$/i);}catch(ce){
		if(typeof ce == 'number' && ce){
			PROJ_showVarError(form,n,d,t,ce,e);
			return;
		}
	}
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			try {
				var passwordStatus = document.getElementById('passwordStatus');
				if (req.responseJS.ok > 0) {
//					eCtrl.getElementsByTagName('SPAN')[0].innerHTML = 'Логин <b>' + req.responseJS.login + '</b> свободен';
					if (req.responseJS.ok == 1)
					{
						passwordStatus.className = "status_normal";
						passwordStatus.innerHTML = "<i></i>Слабый пароль";
					}
					else
					{
						passwordStatus.className = "status_ok";
						passwordStatus.innerHTML = "<i></i>Надежный пароль";
					}
					eCtrl.style.display = 'none';
				} else {
					passwordStatus.className = "status_bad";
					passwordStatus.innerHTML = "<i></i>Неподходящий пароль";
					if (form.f43d71c.value.length)
						PROJ_showVarError(form, 'f573a37_f43d71c', d, t, 7, { '7': 'Вы выбрали слишком простой пароль' });
				}
				passwordStatus.style.display = '';

			} catch (e) {}
		}
	}
	req.caching = true;
	req.open('POST', '/js/pass.js', true);
	req.send({ pass: form.f573a37.value });
}

function doLoadUp2()
{
	if (timeOut)
		clearTimeout(timeOut);
	timeOut = setTimeout(doLoad2, 1000);
}


function socialClick(key, url)
{
	document.forms.rform.socialKey.value = key;

//	receiveFromSocial(key + '[email protected]', 'asdasdsa', true);
//	return;

	window.open(url, '_blank', 'width=1024,height=400,resizable=yes,scrollbars=yes,status=yes');
}

function receiveFromSocial(email, json, skipCaptcha)
{
	var form = document.forms.rform;

	form.socialUserInfo.value = json;
	form.soc_email.value = email;

	var subType = 0;
	if (email) {
		subType = 3;
	} else if (dge('reg_login').getAttribute('blocked')) {
		subType = 2;
	} else {
		subType = 1;
	}

	var alternate = form.login_alternate;
	for (var i = 0; i < alternate.length; i++) {
		alternate[i].checked = (alternate[i].value == subType);
		if (alternate[i].value == 3) {
			alternate[i].parentNode.style.display = (email ? '' : 'none');

			var b = alternate[i].parentNode.getElementsByTagName('B')[0];
			b.innerHTML = '';
			b.appendChild(dct(email));
		}
	}

	chType(3);

//	if (skipCaptcha)
//		disp('reg_bot', false, true);
}

//-->
</script>
<h1>Регистрация пользователя</h1>
<script type="text/javascript">
<!--
function rform_validate(form)
{
	var err,foc,e,n,d,t,eStr='';
	PROJ_clearError(form);
	try{try{n='f573a37';
d='Пароль';
t=1;
e=new Array();
e[6]='недопустимые символы в пароле';
if(!form.f573a37)throw 1;if(form.f573a37.disabled)throw 0;var f573a37=form.f573a37.value;validateStr(f573a37,1,32,6,/^[a-z0-9~!@#$%^*()_+=\[\]{};:\|,.>\/?-]+$/i);}catch(ce){if(typeof ce!='number'||ce)throw ce;}
try{n='f43d71c';
d='Подтверждение пароля';
t=1;
e=new Array();
e[6]='недопустимые символы в пароле';
if(!form.f43d71c)throw 1;if(form.f43d71c.disabled)throw 0;var f43d71c=form.f43d71c.value;validateStr(f43d71c,1,32,6,/^[a-z0-9~!@#$%^*()_+=\[\]{};:\|,.>\/?-]+$/i);}catch(ce){if(typeof ce!='number'||ce)throw ce;}
n='f573a37_f43d71c';
d='Пароли';
t=1;
e=new Array();
e[7]='Пароли не совпадают';
e[17]='слишком простой пароль';
if(f573a37!=f43d71c)throw 7;
}catch(ce){
		if(typeof ce == 'number' && ce){
			err=1;eStr+=PROJ_showVarError(form, n, d, t, ce, e);if(!foc && form.elements[n] && form.elements[n].focus)foc=form.elements[n];
		} else if (window.formManagerLog) {
			formManagerLog(ce);
		}
	}
	try{n='fcf2acc';
d='Логин';
t=1;
e=new Array();
e[3]='Логин зарезервирован';
e[7]='Логин уже занят';
if(!form.fcf2acc)throw 1;if(form.fcf2acc.disabled)throw 0;var fcf2acc=form.fcf2acc.value;fcf2acc=trim(fcf2acc);validateStr(fcf2acc,1,20,4,/^[a-z0-9][a-z0-9_.-]*[a-z0-9]$/i);}catch(ce){
		if(typeof ce == 'number' && ce){
			err=1;eStr+=PROJ_showVarError(form, n, d, t, ce, e);if(!foc && form.elements[n] && form.elements[n].focus)foc=form.elements[n];
		} else if (window.formManagerLog) {
			formManagerLog(ce);
		}
	}
	try{n='domn';
d='Домен';
t=1;
e=0;
if(!form.domn)throw 1;if(form.domn.disabled)throw 0;var domn=form.domn.options[form.domn.selectedIndex].value;validateStr(domn,1,0,0,0);}catch(ce){
		if(typeof ce == 'number' && ce){
			err=1;eStr+=PROJ_showVarError(form, n, d, t, ce, e);if(!foc && form.elements[n] && form.elements[n].focus)foc=form.elements[n];
		} else if (window.formManagerLog) {
			formManagerLog(ce);
		}
	}
	try{n='f2544a1';
d='Email';
t=1;
e=0;
if(!form.f2544a1)throw 1;if(form.f2544a1.disabled)throw 0;var f2544a1=form.f2544a1.value;f2544a1=trim(f2544a1);validateStr(f2544a1,1,64,6,/^\s*([a-z0-9_.+&=|-]+)@(([a-z0-9-]+\.)+[a-z]{2,4})\s*$/i);}catch(ce){
		if(typeof ce == 'number' && ce){
			err=1;eStr+=PROJ_showVarError(form, n, d, t, ce, e);if(!foc && form.elements[n] && form.elements[n].focus)foc=form.elements[n];
		} else if (window.formManagerLog) {
			formManagerLog(ce);
		}
	}
	try{n='type';
d='Выбор логина';
t=2;
e=0;
if(!form.type)throw 1;if(form.type.disabled)throw 0;var type = 0;
if (form.type.length) {
	for (i = 0; i < form.type.length; i++) {
		if (form.type[i].checked) {
			type = form.type[i].value;
			break;
		}
	}
} else if (form.type.checked) {
	type = form.type.value;
}
type=parseInt(type,10);validateVal(type,1,0,0);}catch(ce){
		if(typeof ce == 'number' && ce){
			err=1;eStr+=PROJ_showVarError(form, n, d, t, ce, e);if(!foc && form.elements[n] && form.elements[n].focus)foc=form.elements[n];
		} else if (window.formManagerLog) {
			formManagerLog(ce);
		}
	}
	try{n='f7dcc7d';
d='Код';
t=1;
e=new Array();
e[7]='Неверно введена строка';
if(!form.f7dcc7d)throw 1;if(form.f7dcc7d.disabled)throw 0;var f7dcc7d=form.f7dcc7d.value;validateStr(f7dcc7d,1,6,5,0);}catch(ce){
		if(typeof ce == 'number' && ce){
			err=1;eStr+=PROJ_showVarError(form, n, d, t, ce, e);if(!foc && form.elements[n] && form.elements[n].focus)foc=form.elements[n];
		} else if (window.formManagerLog) {
			formManagerLog(ce);
		}
	}
	if (err) {
		eStr = 'При заполнении формы были допущены ошибки!';
		PROJ_showFormError('rform', eStr);
		if (eStr.length)
			alert(eStr);
		if (foc) {
			try {
				foc.focus();
			} catch (e) {

			}
		}
		return false;
	}
	return true;
}
//-->
</script>
<form name="rform" method="post" onsubmit="return rform_validate(this);"><input type="hidden" name="_subm" value="rform" /><input type="radio" name="type" value="1" checked="checked" style="display: none;" /><input type="hidden" name="socialUserInfo" value="" /><input type="hidden" name="socialKey" value="" /><input type="hidden" name="soc_email" value="" /><input type="hidden" name="crg" value="" /><input type="hidden" name="ppc" value="2006392507" /><input type="hidden" name="ct" value="1362329250.52b5e98caf005d9a5b3bdc7dff96bb40" /><ul class="navigation_tabs clear">
	<li onclick="chType(1, this);" class="current">
		<span>Зарегистрировать
почтовый ящик:
<b class="mail">@i.ua</b>, <b class="mail">@ua.fm</b>, <b class="mail">@email.ua</b></span>
	</li>
	<li onclick="chType(2, this);">
		<span>Использовать
имеющийся e-mail
<img src="/v2/ico/share/share_mailru_24.png" /><img src="/v2/ico/share/share_gmail_24.png" /><img src="/v2/ico/share/share_yandex_24.png" /><img src="/v2/ico/share/share_email_24.png" /></span>
	</li>
	<li onclick="chType(3, this);">
		<span>Зарегистрироваться
через соцсеть

<img src="/v2/ico/share/share_facebook_24.png" title="Facebook" /><img src="/v2/ico/share/share_vkontakte_24.png" title="Vkontakte" /><img src="/v2/ico/share/share_twitter_24.png" title="Twitter" /><img src="/v2/ico/share/share_googleplus_24.png" title="Google+" /><img src="/v2/ico/share/share_yandex_24.png" title="Yandex" />		</span>
	</li>
</ul>

<div class="block_alert" id="rform_errCtrl" style="display: none"><div class="content clear"></div><div class="tl"></div><div class="tr"></div><div class="br"></div><div class="bl"></div></div><p id="type_errCtrl" style="display: none" class="error"><span></span></p>
<table class="form">

<tr id="reg_soc_btn" style="display: none;">
	<td class="field_title"></td>
	<td>
		<p>Если Вы зарегистрированы в одной из социальных сетей, кнопочки которых Вы видите ниже, то нажмите на нее.</p>
		<p>
<span class="facebook_connect" onclick="socialClick(1, 'https://graph.facebook.com/oauth/authorize?client_id=370687779622642&redirect_uri=https%3A%2F%2Fpassport.i.ua%2FsocialRedirectPoint%2F1%2FprocessAuth%2FforRegistration%2F&scope=email%2Cuser_birthday&response_type=code&state=---84f6b725');"></span><span class="vkontakte_connect" onclick="socialClick(2, 'https://oauth.vk.com/authorize?client_id=2891619&redirect_uri=https%3A%2F%2Fpassport.i.ua%2FsocialRedirectPoint%2F2%2FprocessAuth%2FforRegistration%2F&scope=friends%2Cwall&response_type=code&state=---84f6b725');"></span><span class="twitter_connect" onclick="socialClick(3, 'https://passport.i.ua/socialRedirectPoint/3/redirectToAuth?_redirectTo=https%3A%2F%2Fpassport.i.ua%2FsocialRedirectPoint%2F3%2FprocessAuth%2FforRegistration%2F');"></span><span class="googleplus_connect" onclick="socialClick(4, 'https://accounts.google.com/o/oauth2/auth?client_id=136453988744.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fpassport.i.ua%2FsocialRedirectPoint%2F4%2FprocessAuth%2FforRegistration%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fplus.me+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&response_type=code&state=---84f6b725');"></span><span class="yandex_connect" onclick="socialClick(6, 'https://oauth.yandex.ru/authorize?client_id=002976a796d64538b9f162e9779747d8&redirect_uri=https%3A%2F%2Fpassport.i.ua%2FsocialRedirectPoint%2F6%2FprocessAuth%2FforRegistration%2F&scope=&response_type=code&state=---84f6b725');"></span>		</p>
	</td>
</tr>

<tr id="reg_radio" style="display: none;">
	<td class="field_title"></td>
	<td>
				<fieldset class="navigation_tabs">
			<h4>Регистрация через Соцсеть</h4>
			<big>
				<label style="display: none;"><input type="radio" name="login_alternate" value="3" onclick="chType(3);" id="label_login_alternate_3" /> использовать <b></b>
</label>
				<label><input type="radio" name="login_alternate" value="1" checked="checked" onclick="chType(3);" id="label_login_alternate_1" /> зарегистрировать короткий ящик <b>@i.ua</b></label>

				<label><input type="radio" name="login_alternate" value="2" onclick="chType(3);" id="label_login_alternate_2" /> использовать имеющийся e-mail</label>
			</big>
		</fieldset>
	</td>
</tr>

<tbody id="reg_form">
<tr id="reg_login">
	<td class="field_title">Ваш логин</td>
	<td>
		<p id="fcf2acc_errCtrl" style="display: none" class="error"><span></span></p><p id="domn_errCtrl" style="display: none" class="error"><span></span></p>		<div class="necessary"><input type="text" name="fe5e09f" value="" onkeyup="doLoadUp();" class="width_25" style="display:none" maxlength="20" /><input type="text" name="f2c528f" value="" onkeyup="doLoadUp();" class="width_25" style="display:none" maxlength="20" /><input type="text" name="fcf2acc" value="" onkeyup="doLoadUp();" class="width_25" style="display:none" maxlength="20" /><select name="domn" onchange="doLoadUp();"><option value="i.ua">i.ua</option><option value="ua.fm">ua.fm</option><option value="email.ua">email.ua</option></select></div>
		<p class="field_description">максимальная длина: 20 символов ("a&ndash;z", "A&ndash;Z", "0&ndash;9", "-", "_", "."), должен начинаться и заканчиваться буквой или цифрой</p>

		<p>Ваш электронный адрес будет выглядеть так:</p>
		<h4 class="title"><big id="beMail">ваш логин@i.ua</big> <span id="sms_email" style="display: none;">&mdash; <a href="http://mail.i.ua/mobile/">хотите занять этот e-mail?</a></span><span id="short_email" style="display: none;">&mdash; <a href="http://mail.i.ua/short/">хотите занять этот e-mail?</a></span></h4>
	</td>
</tr>
<tr id="reg_email" style="display: none;">
	<td class="field_title">Ваш e-mail</td>
	<td>
		<p id="f2544a1_errCtrl" style="display: none" class="error"><span></span></p>		<div class="necessary"><input type="text" name="f2544a1" value="" class="width_50" disabled style="display:none" maxlength="64" /><input type="text" name="ffd6556" value="" class="width_50" disabled style="display:none" maxlength="64" /><input type="text" name="faed49b" value="" class="width_50" disabled style="display:none" maxlength="64" /><input type="text" name="email" value="" size="7" style="display: none" /></div>
		<div class="field_description">указывайте действующий e-mail, так как на него придет письмо с кодом активации паспорта</div>
	</td>
</tr>

<tr id="reg_bot">
	<td class="field_title">Бот-защита</td>
	<td>
		<p id="f7dcc7d_errCtrl" style="display: none" class="error"><span></span></p>		<div class="necessary">
<p>Введите символы, указанные на картинке</p>
<input type="text" name="user" value="" size="7" style="display: none" /><p class="capture">
	<input type="text" name="f7dcc7d" value="" class="width_25"  /><img src="/js/rnd_dm/edf5c11b526eea77132d52069e571561.jpg" style="width: 120px; height: 60px;" name="f7dcc7d_img" /><span class="link" title="Если Вы не можете прочитать код на картинке, то кликните здесь" onclick="regenerateRndImage('f7dcc7d', '/js/regen_captcha.js')">другую картинку</span><input type="hidden" name="f7dcc7d_rndSeq" value="95" /></p>
<input type="text" name="login" value="" size="7" style="display: none" />		</div>
	</td>
</tr>
<tr>
	<td class="field_title">Придумайте пароль</td>
	<td>
		<p id="f573a37_errCtrl" style="display: none" class="error"><span></span></p><p id="f573a37_f43d71c_errCtrl" style="display: none" class="error"><span></span></p>		<div class="necessary"><input type="password" name="f573a37" class="width_50" onkeyup="doLoadUp2();" style="display:none" maxlength="32" /><input type="password" name="fddcc28" class="width_50" onkeyup="doLoadUp2();" style="display:none" maxlength="32" /><input type="password" name="f3396ba" class="width_50" onkeyup="doLoadUp2();" style="display:none" maxlength="32" />		<span id="passwordStatus" style="display: none"></span>
		</div>
		<p class="field_description" rowspan="2">минимальная длина: 6 символов ("a&ndash;z", "A&ndash;Z", "0&ndash;9")</p>
		<label id="reg_genpass" style="display: none;"><input type="checkbox" name="pass_gen" value="1" onclick="chType(3);" id="label_pass_gen" /> придумайте мне пароль и отправьте его на e-mail</label>
	</td>
</tr>

<tr id="reg_pconf">
	<td class="field_title">Подтвердите пароль</td>
	<td>
		<p id="f43d71c_errCtrl" style="display: none" class="error"><span></span></p>		<div class="necessary"><input type="password" name="feafa3b" class="width_50" onkeyup="doLoadUp2();" style="display:none" maxlength="32" /><input type="password" name="f43d71c" class="width_50" onkeyup="doLoadUp2();" style="display:none" maxlength="32" /><input type="password" name="fd9f49c" class="width_50" onkeyup="doLoadUp2();" style="display:none" maxlength="32" /><span class="link" onclick="Autoload.call('I_Popup.showSimple', this, 'info_password', { className: 'popup popup_large' });">как выбирать пароль?</span>
<div id="info_password" style="display: none;">
	<h2>Как выбирать пароль?</h2>
	<p>Не делайте простых паролей. Мы со своей стороны ограничили возможность быстрого подбора паролей, но это не дает гарантии, что пароль типа 1111 нельзя будет подобрать. Поэтому, рекомендуем использовать более сложные для подбора пароли.</p>
	<p>Самый надежный пароль должен состоять из минимум шести-семи символов, с использованием букв, цифр и символов. Например, kjf4k5j-4jg. Конечно, такой пароль Вам будет сложно запомнить, поэтому можно использовать в качестве пароля одно или два русских слова, которые Вы точно не забудете, при этом сделать их набор не в русской раскладке, а в английской раскладке набирать слово нажимая на русские буквы.</p>
Например, берем слова "кошка мурка", набираем их латинскими буквами по русским клавишам, получаем "rjirf vehrf", вместо пробела вставляем какую-либо цифру, или символ минуса. Таким образом получится пароль "rjirf-vehrf", который будет фактически нереально подобрать, при этом Вы, имея сложный пароль, вряд ли его забудете.
</div>
	</td>
</tr>

<tr>
	<td></td>
	<td><input type="hidden" name="subm" value="1" /><input type="submit" value="Продолжить" /></td>
</tr>

</tbody>

</table>
</form>
<script type="text/javascript" language="JavaScript">
	var names = new Array('7dcc7d', '43d71c', '573a37', 'cf2acc', '2544a1');
	for (i in names) {
		tmp = document.getElementsByName('f' + names[i])[0];
		if (tmp)
			tmp.style.display='';
	}
</script>
<!-- }}} CENTER -->
</div>
<!-- FOOTER {{{ -->
<div class="clear Branding_footer">
<div class="clear Footer">
<div class="copyright clear">
	<p class="float_left">
		&copy; I.UA, 2006-2013.

		<a href="http://help.i.ua/section/10/">Обратная связь</a>
	</p>
	<p class="float_right">
				<a href="http://www.i.ua/" target="_blank" onclick="this.href='http://i.ua/r.php?1';" title="Каталог сайтов, поиск в Украине"><img src="/r/3_1_2.png" border="0" width="88" height="31" /></a>			</p>
</div>
</div>
</div>

</body>
</html>

Как видно с кода на странице name у inputoв каждый раз случайный 7-ми значный набор символ начинающийся с f
Код:
$log_array = StringRegExp($oHTML, 'name="f.{6}',3)
всегда выдает мне вот такой массив из 14 рядов

С 9 по 11 name всегда отвечают за первое поле с мейлом.
Активный инпут всегда случайный с 9 по 11, потому я и перебираю циклом их.

Вопрос в том, что работает мой скрипт только на Win7 в IE9. В Maxthonе на Win7 уже не работает и в WinXP на IE6 тоже не работает. Не пойму, почему так?
 

AZJIO

Меценат
Меценат
Сообщения
2,879
Репутация
1,194
Код:
$log_array = StringRegExp($oHTML, 'name="f(.{6})', 3)
If @error Then Exit MsgBox(0, 'Сообщение', 'Не найдено') ; проверка, оно может ничего не вернуть
$logselect = _IEFormGetObjByName($oIE, "rform")
If @error Then Exit MsgBox(0, 'Сообщение', 'Объект не найден')
$sErrorLog = ''
For $i = 0 To UBound($log_array) - 1
	$login = _IEFormElementGetObjByName($logselect, $log_array[$i])
	If @error Then
		$sErrorLog = 'Получение элемента неудачно, ' & $log_array[$i] & ', ' & $i & @LF
		ContinueLoop
	EndIf
	_IEFormElementSetValue($login, "MyLogin")
	If @error Then
		$sErrorLog = 'Установка значения неудачно, ' & $login & ', ' & $log_array[$i] & ', ' & $i & @LF
		ContinueLoop
	EndIf
Next
If $sErrorLog Then MsgBox(0, 'Вот они, ошибки', $sErrorLog)


Код:
$log_array = StringRegExp($oHTML, 'name="f(.{6})', 3)
If @error Then Exit MsgBox(0, 'Сообщение', 'Не найдено') ; проверка, оно может ничего не вернуть
$logselect = _IEFormGetObjByName($oIE, "rform")
If @error Then Exit MsgBox(0, 'Сообщение', 'Объект не найден')
$sErrorLog = ''
If UBound($log_array) < 12 Then Exit MsgBox(0, 'Незадача', 'Массив меньше чем ожидалось/хотелось')
For $i = 9 To 11
	$login = _IEFormElementGetObjByName($logselect, $log_array[$i])
	If @error Then
		$sErrorLog = 'Получение элемента неудачно, ' & $log_array[$i] & ', ' & $i & @LF
		ContinueLoop
	EndIf
	_IEFormElementSetValue($login, "MyLogin")
	If @error Then
		$sErrorLog = 'Установка значения неудачно, ' & $login & ', ' & $log_array[$i] & ', ' & $i & @LF
		ContinueLoop
	EndIf
Next
If $sErrorLog Then MsgBox(0, 'Вот они, ошибки', $sErrorLog)
 
Автор
Y

Yura-H2O

Новичок
Сообщения
35
Репутация
0
В WinXP IE6 выдает вот это. Не пойму почему?
Код:
If @error Then Exit MsgBox(0, 'Сообщение', 'Не найдено') ; проверка, оно может ничего не вернуть


а в Win7 IE9 получаю MsgBox "Получение элемента неудачно, 11 елемент"

Не пойму почему так? :( Особо меня интересует WinXP IE6
 

AZJIO

Меценат
Меценат
Сообщения
2,879
Репутация
1,194
Yura-H2O [?]
Особо меня интересует WinXP IE6
Вы не пытались сохранить $oHTML в файл чтобы посмотреть что там? Может там ничего нет. Это же логически ясно, если алгоритм не возвращает результат, то проверять результат каждого шага алгоритма, пока не дойдёшь до валидного результата, после которого начинается невалидный результат. В лучшем случае проверяют всредине, метод деления последовательной цепочки операторов на 2 сокращает нахождение ошибочной операции в разы.
 
Верх