rem: new_server.finalize_server_connect("TS"); 
add: new_server.finalize_server_connect("TS",this.sendps); 
context: function Unregistered_Commands() {	var cmdline;	var cmd;	var command;	if (!this.socket.is_connected) {		this.quit();		return 0;	}	cmdline=this.socket.recvline(4096,0);	Global_CommandLine = cmdline;	if (!cmdline)		return 0;	// Only accept up to 512 bytes from unregistered clients.	cmdline = cmdline.slice(0,512);	// Kludge for broken clients.	if ((cmdline[0] == "\r") || (cmdline[0] == "\n"))		cmdline = cmdline.slice(1);	if (debug)		log(LOG_DEBUG,"[UNREG]: " + cmdline);	cmd = cmdline.split(" ");	if (cmdline[0] == ":") {		// Silently ignore NULL originator commands.		if (!cmd[1])			return 0;		// We allow non-matching :<origin> commands through FOR NOW,		// since some *broken* IRC clients use this in the unreg stage.		command = cmd[1].toUpperCase();		cmdline = cmdline.slice(cmdline.indexOf(" ")+1);	} else {		command = cmd[0].toUpperCase();	}	// we ignore all numerics from unregistered clients.	if (command.match(/^[0-9]+/))		return 0;		switch(command) {		case "PING":			if (!cmd[1]) {				this.numeric(409,":No origin specified.");				break;			}			this.rawout("PONG " + servername + " :" + IRC_string(cmdline));			break;		case "CAPAB":			break; // Silently ignore, for now.		case "NICK":			if (!cmd[1]) {				this.numeric(431, ":No nickname given.");				break;			}			var the_nick = IRC_string(cmd[1]).slice(0,max_nicklen);			if (this.check_nickname(the_nick))				this.nick = the_nick;			break;		case "PASS":			if (!cmd[1] || this.password)				break;			this.password = cmd[1];			break;		case "PONG":			this.pinged = false;			break;		case "SERVER":			if ((this.nick != "*") || this.criteria_met) {				this.numeric462();				break;			}			if (!cmd[3]) {				this.numeric461("SERVER");				break;			}			if (Servers[cmd[1].toLowerCase()]) {				this.quit("Server already exists.");				return 0;			}			var this_nline = 0;			var qwk_slave = false;			var qwkid = cmd[1].slice(0,cmd[1].indexOf(".")).toUpperCase();			for (nl in NLines) {				if ((NLines[nl].flags&NLINE_CHECK_QWKPASSWD) &&				    IRC_match(cmd[1],NLines[nl].servername)) {					if (check_qwk_passwd(qwkid,this.password)) {						this_nline = NLines[nl];						break;					}				} else if ((NLines[nl].flags&NLINE_CHECK_WITH_QWKMASTER) &&					   IRC_match(cmd[1],NLines[nl].servername)) {						for (qwkm_nl in NLines) {							if (NLines[qwkm_nl].flags&NLINE_IS_QWKMASTER) {								var qwk_master = searchbyserver(NLines[qwkm_nl].servername);								if (!qwk_master) {									this.quit("No QWK master available for authorization.");									return 0;								} else {									qwk_master.rawout(":" + servername + " PASS " + this.password + " :" + qwkid + " QWK");									qwk_slave = true;								}							}						}				} else if ((NLines[nl].password == this.password) &&					   (IRC_match(cmd[1],NLines[nl].servername))					  ) {						this_nline = NLines[nl];						break;				}			}			if ( (!this_nline ||			      ( (this_nline.password == "*") && !this.sentps &&				!(this_nline.flags&NLINE_CHECK_QWKPASSWD) )			     ) && !qwk_slave) {				this.quit("Server not configured.");				return 0;			}			// Take care of registration right now.			Servers[cmd[1].toLowerCase()] = new IRC_Server;			var new_server = Servers[cmd[1].toLowerCase()];			Local_Servers[this.id] = new_server;			Local_Sockets_Map[this.id] = new_server;			rebuild_socksel_array = true;			new_server.socket = this.socket;			new_server.hops = cmd[2];			new_server.info = IRC_string(cmdline);			new_server.parent = cmd[1];			new_server.linkparent = servername;			new_server.id = this.id;			new_server.flags = this_nline.flags;			new_server.nick = cmd[1];			new_server.hostname = this.hostname;			new_server.recvq = this.recvq;			new_server.sendq = this.sendq;			if (!qwk_slave) { // qwk slaves should never be hubs.				for (hl in HLines) {					if (HLines[hl].servername.toLowerCase()					    == cmd[1].toLowerCase()) {						new_server.hub = true;						break;					}				}				// nor should they be ulined.				for (u in ULines) {					if (ULines[u] == cmd[1]) {						new_server.uline = true;						break;					}				}			}			new_server.finalize_server_connect("TS");			break;		case "USER":			if (this.uprefix)				break;			if (!cmd[4]) {				this.numeric461("USER");				break;			}			this.realname = IRC_string(cmdline).slice(0,50);			this.uprefix = parse_username(cmd[1]);			break;		case "QUIT":			this.quit();			return 0;		case "NOTICE":			break; // drop silently		default:			this.numeric451();			break;	}	if (!this.criteria_met && this.uprefix && (this.nick != "*") ) {		var usernum;		if (this.password) {			usernum = system.matchuser(this.uprefix);			if (!usernum)				usernum = system.matchuser(this.nick);			if (usernum) {				var bbsuser = new User(usernum);				if (this.password.toUpperCase() == bbsuser.security.password)					this.uprefix = parse_username(bbsuser.handle).toLowerCase().slice(0,10);			}		}		if (!usernum)			this.uprefix = "~" + this.uprefix;		this.criteria_met = true;		if (this.hostname && !this.pending_resolve_time)			this.welcome();	}}
meta: 9592	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9592/5ba03c6eb6bbc4183b83bc4c04000dd2ef0bd7e0/ircd_unreg.js/buggy/load/ircd_unreg.js