Re: Launcher UPDATES Section
Hey guys, I just setup my server to test my launcher and I got wamp installed with mssql extensions and all but when I press the play now button nothing happens. Also when I go to the login.php (127.0.0.1:9090/login.php) I get this error:
Code:
Notice: Undefined index: Username in C:\Users\Farbod\Desktop\WAMP\www\Login.php on line 8
Notice: Undefined index: Password in C:\Users\Farbod\Desktop\WAMP\www\Login.php on line 9
Warning: mssql_query() [function.mssql-query]: message: Invalid object name 'tUser'. (severity 16) in C:\Users\Farbod\Desktop\WAMP\www\Login.php on line 14
Warning: mssql_query() [function.mssql-query]: Query failed in C:\Users\Farbod\Desktop\WAMP\www\Login.php on line 14
Query Failed
I think this is the thing causing the problem. I don't think there is a tUser table? Is it just me or is it the login.php?
This is the code for login.php:
Code:
<?php
$conf['db_host'] = "FARBOD-PC\SQLEXPRESS";
$conf['db_user'] = "raye";
$conf['db_pass'] = "...";
$conf['db_name'] = "OdinAccounts";
$user = sql_clean($_GET['Username']);
$passhash = sql_clean($_GET['Password']);
$con = mssql_connect($conf['db_host'],$conf['db_user'],$conf['db_pass']) or die('Database connect Fail.');
$db = mssql_select_db($conf['db_name'], $con) or die('Database Init Fail.');
$exec = mssql_query("SELECT sUserPW FROM tUser where sUserID = '$user'");
if($exec)
{
if(mssql_num_rows($exec) != 1)
{
die('Account Not Found.');
}
$AccountData = mssql_fetch_assoc($exec);
$PlaintxtPass = $AccountData['sUserPW'];
if (MD5($PlaintxtPass) == $passhash)
{
die('OK');
}
else
{
die('Wrong Password.');
}
}
else
{
die('Query Failed');
}
mssql_close();
function sql_clean($str)
{
$search=array("\\","\0","\n","\r","\x1a","'",'"');
$replace=array("","","","","","","");
return str_replace($search,$replace,$str);
}
?>
Thanks for any help in advance :)
EDIT: Would it been tAccounts instead of tUser?
EDIT2: Okay I managed to sort out the invalid object name and query fail by changing it to this:
Code:
$exec = mssql_query("SELECT sUserPass FROM tAccounts where sUsername = '$user'");
But I still get the undefined username and password problem. How can I define them?
Re: Launcher UPDATES Section
login.php?Username=user&Password=pass
Re: Launcher UPDATES Section
I don't understand? i still get the undefined error.
Re: Launcher UPDATES Section
Then read more about "php GET".
Re: Launcher UPDATES Section
Holy mother of lord, it works! IT WORKS! YES :DDDD
Thank you very much. :)
Now onto updating, registering, ui and other stuff.
Re: Launcher UPDATES Section
Re: Launcher UPDATES Section
Thank you Myth ^^
I read up on it.
PHP $_GET Variable
EDIT: Never mind what I said before. After I click play the client loads and all but it says authentication failed? I don't know where to go with this.
EDIT2: I think it is because I am using this code to start the client.exe
Code:
Client.exe", "-osk_server 127.0.0.1 -osk_token -osk_store Google
But the problem is it doesn't make the token. :S and insert it into the above code.
EDIT3:
I have a code which generates the token now in the Login.php and I have changed the launcher to start as follows:
Code:
Client.exe", "-osk_server 127.0.0.1 -osk_token +RandomToken+ -osk_store Google
But the problem is that when I click play I get this error:
http://puu.sh/1NijL
I've looked at it and apparently it says undefined variable: PlaintxtnEMID
Then it has the token at the bottom.
This is the part where it generates the token:
Code:
$Token = RandomToken(25);
$setToken = null;
if (mssql_num_rows(mssql_query("SELECT * FROM tTokens WHERE nEMID = '".$PlaintxtnEMID."'")) >= 1)
{
mssql_query("DELETE FROM tTokens WHERE nEMID = '".$PlaintxtnEMID."'");
$setToken = mssql_query("INSERT INTO tTokens (nEMID, sToken) VALUES('".$PlaintxtnEMID."', '".$Token."')");
}
else
$setToken = mssql_query("INSERT INTO tTokens (nEMID, sToken) VALUES('".$PlaintxtnEMID."', '".$Token."')");
if ($setToken)
die('OK'.$Token);
else
die('SetToken Error');
Re: Launcher UPDATES Section
Error says what's wrong, fix it.
I suggest you to add very important parts to your code:
Error checking!
Re: Launcher UPDATES Section
That's the thing T.T I don't know how to fix it else I would. :( Any tips, hints on how I could fix that? Like I have said before I don't know any PHP or VB lol. I've never ran a Fiesta server before.
I found the code in another thread. :D
I think there is already error checking because that's how I found the error?
EDIT: I've looked at this: http://www.w3schools.com/php/php_variables.asp
Yet no fix still comes to mind.
EDIT: I WILL DEFINITELY FIX THIS ONE DAY! IDK WHEN BUT ONE DAY! I WILL! :)
Re: Launcher UPDATES Section
And the page has an answer:
Code:
PHP has no command for declaring a variable.
A variable is created the moment you first assign a value to it:
Error Handling would be correct (Not Error Checking).
In your case, you have used nesting:
Code:
mssql_num_rows(mssql_query("..."))
But can you guarantee that 'mssql_query("...")' returns resource?
Code:
mssql_query:
Returns a MS SQL result resource on success, TRUE if no rows were returned, or FALSE on error.
But 'mssql_num_rows' expects resource. But if boolean is given then you get yet another error.
Code:
mssql_num_rows — Gets the number of rows in result
Re: Launcher UPDATES Section
Take some advice, code all this from scratch yourself rather than using another persons code/source.
Use it as a guideline at the least, but before going further its best you learn/understand what's happening with the script itself, and what you're intending to do will become much more easier to achieve, thus far, you've lacking knowledge and you're lost with whats happening/the script is doing, just my two cents.
Re: Launcher UPDATES Section
Myth thanks for the advice. I would create it myself from the start but I don't want to spend 1/2 years learning php ^^ but I will try my best to make it my original code. I just need to get the basics first then in the future I will start to create my own content hopefully any way.
NextIdea, I understand what you are saying kind of. The code seems to work by generating a random token and inserting it into the tTokens table but the client isn't able to link that token and the account that is being logged in with. That's the problem with this code. Wouldn't it be easier for a token to be created when someone signs up instead of creating a token for when they login and then making the launcher grab the correct token linked to the account being logged in with then using it?
Or is this something different from what I am thinking?
EDIT: Oh never mind what I said before. It's because the launcher doesn't grab the key. How can I make the launcher get the key from the mssql database via visual basics? Or would I have to tell the launcher to look at the login.php to then get the token and return it to the launcher?
EDIT2: Basically the web server generates the token and adds it into the database table but how do I make the web server send the token to the launcher where it will then receive it and put it into the appropriate place? I've tried searching on google but I couldn't find anything.
EDIT3: There was a few things being over looked in my coding before. With more research I was able to fix the error and the login.php should work now. But the only problem I now face is that I need to send make it send the token to the launcher and make something so that the launcher know's that it the token and inserts it into the token part.
I don't know how to do that though. D:
Re: Launcher UPDATES Section
You don't directly send it to launcher.
Launcher asks for login.php which does everything to get the token ready and as result it echo-s it.
And in launcher you parse the "html" you got as result.
Re: Launcher UPDATES Section
Quote:
Originally Posted by
NextIdea
You don't directly send it to launcher.
Launcher asks for login.php which does everything to get the token ready and as result it echo-s it.
And in launcher you parse the "html" you got as result.
Dunno why you would use HTML. A simple JSON string should be fine.
Re: Launcher UPDATES Section
Hmm, I did a bit of searching on HTML parsing and JSON string but I couldn't get anywhere after trying a few different methods. Is it possible for a basic idea of how the code would look or something? That would help me.
First I tried this:
Code:
Dim lonPos As Long, lonEnd As Long
Dim strStart As String, strEnd As String
Dim strEmail As String
'The start string.
strStart = "$Token"
strEnd = "$Token"
'Find the start string.
lonPos = InStr(1, HTML, strStart, vbTextCompare)
If lonPos > 0 Then
'Move to the end of the start string
'which happens to be the beginning of what we're looking for. :)
lonPos = lonPos + Len(strStart)
'Find the end string starting from where we found the start.
lonEnd = InStr(lonPos, HTML, strEnd, vbTextCompare)
If lonEnd > 0 Then
'Now, we have the starting and ending position.
'What we do is extract the information between them.
'The length of data (e-mail address) will be:
'lonEnd - lonPos
strToken = Mid$(HTML, lonPos, lonEnd - lonPos)
End If
End If
Then I tried this:
Else
' MsgBox("Welcome!")
Static launcherparams As String = "-osk_server 127.0.0.1 -osk_token %token% -osk_store Google"
Dim token As String = LoginResponse.Substring(10, LoginResponse.Length - 25)
Dim param As String = launcherparams.Replace("%token%", token)
LaunchOfficial(param)
' Process.Start("Client.exe", "-osk_server 127.0.0.1 -osk_token +token+ -osk_store Google")
' Application.Exit()
End If
End Sub
Private Shared Sub LaunchOfficial(param As String)
Process.Start("Client.exe")
Application.Exit()
End Sub