Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-27-2012, 01:58 AM   #1
Registered User
Join Date: Apr 2012
Posts: 1
Unhappy [AS2] SmartFoxServer AvatarChat/CustomLogin, Flash CS5

Hello, I am new here.

First of all, I was asking around on smartfoxserver.com forums, but no help at all! Now time to explain my situation...

I am using a VPS and have installed smartfoxserver 1.6.6 PRO on it. I have edited avatarchat.fla flash file to my customization for now, and everything else. I have edited the chat frames, to my liking for now, just server side for now, not client side.

No port forwarding is needed because this is a VPS. Because this is a VPS, all ports are opened by default if I am not mistaking.

Well, I configured my smartfoxserver code, and stuff, made a zone for the game called "gamelogin" and created a login extension.

I have looked at sfs-tutor.blogspot.com which is Rjgtav's blog (a global moderator on smartfoxserver.com forum).

If you need the smartfoxserver code, please message me for it!!! *****

The above is the code for the smartfoxserver connect frame. Now, that's running smoothly, it connects, and everything.

Next is the zone, because I have made a zone called "gamelogin" that has a login extension, thats called mylogin.as

The zone code is below:
ActionScript Code:
<Zone name="gamelogin" uCountUpdate="true" buddyList="20" maxUsers="4000" customLogin="true">             <Rooms>                 <Room name="The Hall" maxUsers="50" isPrivate="false" isTemp="false" autoJoin="true" uCountUpdate="true" />                   <Room name="The Kitchen" maxUsers="50" isPrivate="false" isGame="false" isTemp="false" />                 <Room name="The Garden" maxUsers="50" isPrivate="false" isTemp="false" />                 <Room name="The Bathroom" maxUsers="50" isPrivate="false" isTemp="false" />                 <Room name="The Garage" maxUsers="50" isPrivate="false" isTemp="false" />                 <Room name="The Living Room" maxUsers="50" isPrivate="true" isTemp="false" pwd="test" />             </Rooms>                         <Extensions>                 <extension name="mylogin" className="mylogin.as" type="script" />             </Extensions>                         <DatabaseManager active="true">                                 <Driver>org.gjt.mm.mysql.Driver</Driver>                 <ConnectionString>jdbc:mysql://</ConnectionString>                                                 <UserName>root</UserName>                 <Password>******</Password>                                 <TestSQL><![CDATA[SELECT COUNT(*) FROM users]]></TestSQL>                                 <MaxActive>10</MaxActive>                 <MaxIdle>10</MaxIdle>                                 <OnExhaustedPool>fail</OnExhaustedPool>                 <BlockTime>5000</BlockTime>                                 </DatabaseManager>                         <Moderators status="on">                 <Mod name="modName" pwd="modPass" />             </Moderators>         </Zone>

I have Starred out the password In that code. That works fine. As you can see, I have the moderator status on, the mysql connection is enabled, and yes it does connect successfully, and yes I have installed the jdbc driver for mysql. Then as you can also see, the zone is called gamelogin, and I call to my extension named mylogin.as

The code for the extension is below:
ActionScript Code:
var dbase var login_txt; var password; var SocketChannel;   function init(){  dbase = _server.getDatabaseManager() }   function destroy(){  delete dbase  delete login_txt;  delete password;  delete SocketChannel; }   function handleInternalEvent(evt) {  if(evt.name == "loginRequest"){    var error = "";       login_txt = evt["nick"];         password = evt["pass"];         SocketChannel = evt["chan"];       var sql = "SELECT * FROM users WHERE username='"+login_txt+"' AND password='"+password+"'";   var queryRes = dbase.executeQuery(sql)       var response = {}       if (queryRes != null){    var Row = queryRes.get(0)    var count = Row.getItem("COUNT(*)");          if(count == 1){     trace("SUCCESSFULL LOGIN")     var obj = _server.loginUser(login_txt, password, SocketChannel)           if(obj.success){      response._cmd = "logOK";      response.name = login_txt;     }else{      error = obj.error;      response._cmd = "logKO";     }    }else if(count == 0){     trace("FAILED LOGIN")     response._cmd = "logKO";     error = "Wrong username or password";    }   }else{    response._cmd = "logKO";    error = "Error connecting to the database"   }       response.error = error;   _server.sendResponse(response, -1, null, SocketChannel)  } }

As you can see, I call out to authenticate what the user enters in the username and password fields, and the errors are wrong username or password, and error connecting to the database. The line where it says "SELECT * FROM users , etc." where it says +login_txt+ and +password+ is calling the text field names to see what the user entered in those fields.

I use to have the error connecting to the database, but I fixed that by changing the code to what currently says "SELECT * FROM users, etc"
when before it said SELECT COUNT(*). SELECT means to SELECT the usernames, COUNT means to COUNT the number of users in the database, and * means to select ALL, so I changed it to SELECT * FROM users WHERE username= etc etc, and all that works and doesn't give me an error connecting to database, but now I have a problem.

I enter the correct username and password, and I press the button LOGIN. I have a popup that says Error: undefined. What does this mean? Can someone help me decipher what I have done wrong and help me fix it? Please?

I don't know where else to look!


Last edited by smartredfox; 04-27-2012 at 02:04 AM. Reason: Edit
smartredfox is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off

Forum Jump

All times are GMT. The time now is 04:52 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.