/************************************
Author		: carl
Time		: 4 23, 2010
Version		: V1.0.0
Description : 
************************************/

import win;
import win.ui; 
import win.ui.menu
import win.ole.image
import web.form;
/*DSG{{*/
var winform = win.form(parent=...; bgcolor=13160660;bottom=636;right=575;left=0;style=0;min=1;exmode="";title="AAuto Form";text="SoHu邮箱半自动注册机";frame=1;top=0 )
winform.add( 
password={ bgcolor=16777215;bottom=46;color=0;text="";left=86;multiline=1;top=24;acceptfiles=1;tabstop=1;right=179;z=0;edge=1;cls="edit" };
static3={ bgcolor=13160660;bottom=45;color=0;right=85;left=22;transparent=1;top=30;acceptfiles=1;tabstop=1;align="";text="邮件密码:";z=5;cls="static" };
answer={ bgcolor=16777215;bottom=46;color=0;text="";left=276;multiline=1;top=24;acceptfiles=1;tabstop=1;right=369;z=1;edge=1;cls="edit" };
static={ bottom=630;text="static";left=9;top=61;font=LOGFONT( name="宋体";h=-12 );z=4;transparent=1;right=565;cls="static" };
button={ bgcolor=13160660;bottom=47;color=0;right=486;left=421;multiline=1;top=19;acceptfiles=1;z=2;tabstop=1;text="开始";transparent=1;cls="button" };
static2={ bgcolor=13160660;bottom=46;align="";text="密码问题答案:";left=194;z=3;top=31;acceptfiles=1;tabstop=1;color=0;right=273;transparent=1;cls="static" }
)
/*}}*/

tabemail={"able";"about";"above";"abuse";"ache";"acid";"acre";"guard";"guess";"guest";"guide";"gulf";
"gum";"gun";"habit";"hair";"half";"hall";"halt";"hand";"handy";"hang";"happy";"hard";"hare";
"harm";"huge";"human";"humid";"hunt";"hurry";"hurt";"hut";"ice";"idea";"ideal";"idiom";"idle";
"if";"ill";"image";"imply";"in";"inch";"index";"India";"infer";"ink";"inn";"inner";"input";"into";"iron";
"issue";"it";"item";"its";"jail";"jam";"Japan";"jar";"jaw";"jazz";"youth";"zeal";"zebra";"zero";"zone";"zoo"}

_Title="注册机";
_SohuUrl="https://passport.sohu.com/web/dispatchAction.action?appid=1000&ru=http://mail.sohu.com/reg/signup_success.jsp";

function GetEmailName(){//随机获取注册名
	n=table.count(tabemail)
	n1=math.random(1,n);
	win.delay(1000);
	n2=math.random(1,n);
	return tabemail[n1] + tabemail[n2];		
}
winform.button.oncommand = function(id,event){
	password=winform.password.text;
	if(#password<6 || #password>16)
	{
		win.msgbox("密码长度应为6-16位",_Title);
		return ; 
	}
	answer=winform.answer.text;
	if(#answer<5)
	{
		win.msgbox("答案至少5个字符",_Title);
		return ; 
	}
	wb.go(_SohuUrl);	//打开sohu邮箱注册页面
	for(i=1;60;1){
		win.delay(1000)
		ele=wb.getEle("validate");
		if(ele){break ;}			//等待网页全部打开
	}	
	name=string.lower(GetEmailName());//随机获取注册名
	ele=wb.getEle("shortname")
	if(ele){
		ele.setAttribute("value",name)//设置用户账号
	}
	ele=wb.getEle("password")
	if(ele){
		ele.setAttribute("value",password)//密码
	};
	ele=wb.getEle("password2")
	if(ele){
		ele.setAttribute("value",password)//密码确认
	};
	ele=wb.getEle("answer")
	if(ele){
		ele.setAttribute("value",answer)//密码问题答案
	};
	win.delay(1000)
	//执行网页脚本
	wb.doScript("showdesc('shortnamedesc');");
	wb.doScript("checkUserName('" + name + "','sohu.com');");
	wb.doScript("showdesc('passworddesc');");
	wb.doScript("checkPassword('" + password + "');");
	wb.doScript("showdesc('password2desc')");
	wb.doScript("checkConfirmPassword('" + password + "');");
	wb.doScript("showdesc('answerdesc')");
	wb.doScript("checkAnswer('" + answer + "');");
	win.delay(1000);
	ele=wb.getEle("validate");
	ele.focus();				//设置验证码框为当前焦点
	for(i=1;60;1){				//用一分钟时间等待手动输入验证码,
		win.delay(1000);
		html=wb.body ? wb.body.outerHTML : "";		//读取网页body源码
		if(html){
			if(string.find(html,"暂时不能注册")){
				win.msgbox("暂时不能注册,请更换IP!",_Title);
				break;
			}
			if(string.find(html,"已经成功注册搜狐通行证")){
				email=string.match(html,"\>(\w+\@sohu\.com)\<") or "";
				win.msgbox("注册成功!" ++ '\n' ++ "Email地址:" ++ email,_Title);
				break ;
			}
		}
	}
}//endproc
math.randomize(tonumber(time()));		//改变随时种子
wb=web.form(winform.static);			//用static控件创建一个web对像
wb.go(_SohuUrl);
winform.show(true) 
win.loopMessage();
