MMOCC the isometric world scene, 2006–now
Archive. Archived from the original MMOCC Forum (2006–2010), recovered from the Internet Archive. The forum is read-only history now — the scene talks on Discord. If you posted here and want something removed, get in touch.

Help with php

6 posts · 2012-07-07 · MyBB era
07-07-2012 04:46 AM #1
Hello I am using smart fox bits with smart fox server 2x. I have a swf and im using the LoginBox bit. Under the properties of the login box their is a spot to put what they call a custom server page for access validation. I have no idea how to create such a php file. The only documentation I can find is here: http://bits.smartfoxserver.com/docs/as3Flex_SFS2X/html/com_smartfoxserver_smartfoxbits_bits_LoginBox.html#customLoginPage

From what I read here I am guessing the php file contains users and their passwords. When the swf sends the username and password from the login form the php file checks it against the users already in the php file and then the php file sends the loginbox either "ok" if it matches or "ko" if it doesnt.

07-08-2012 10:21 AM #2
I found a php script that does just this in a smart fox server 1.x documentation. The only problem it does not work. It should work but it says that the credentials are invalid when they are valid. Can anyone help.
Code:
<?php
    // A Simple List of allowed users
    // You could substitute this code with a database connection
    $allowedUsers =  array ("Admin" => "test",
                            "test" => "test",
                            "Moderator" => "test");
    
    // The response variable
    $res = "res=KO";


    // Check incoming data
    if ($_POST['name'] != "" && $_POST['pass'] != "")

    {
        foreach($allowedUsers as $name => $password)
        {
            if ($_POST['name'] == $name && $_POST['pass'] == $password)

            {
                // Ok, user found
                $res = "res=OK";
                break;
            }
        }
    }
    
    print $res;
?>


07-09-2012 06:53 AM #3
Firstly, you're going to want to use a database in the future as I'm sure, you don't want to create each user manually and store them in an array which would eventually turn into spaghetti code. Secondly, is there a particular reason why you're using "KO" as the not valid status code? Thirdly, why are you defining the variable res with "res=" inside the string?

Beware, I'm a little rusty on my PHP and I'm not that great but just a few things I noticed that don't seem spot on.

07-09-2012 07:41 AM #4
(07-09-2012 06:53 AM)killuh Wrote:  Firstly, you're going to want to use a database in the future as I'm sure, you don't want to create each user manually and store them in an array which would eventually turn into spaghetti code. Secondly, is there a particular reason why you're using "KO" as the not valid status code? Thirdly, why are you defining the variable res with "res=" inside the string?

Beware, I'm a little rusty on my PHP and I'm not that great but just a few things I noticed that don't seem spot on.
I do not plan on leaving the user accounts on the php file, It's temporary. I am using res=KO and res=OK because that is what the documentation said to do.

Quote:The custom server-side page url for access credentials validation.
If this property is set, before attempting the SmartFoxServer login, the LoginBox will send the entered username and password to the provided url for validation.
Two parameters are passed to the custom server-side page via POST: name (the entered username) and pass (the entered password). The page must return res=OK if the credentials are valid or res=KO if the credentials are invalid.


07-09-2012 12:00 PM #5
(07-09-2012 07:41 AM)Scoot Wrote:  
(07-09-2012 06:53 AM)killuh Wrote:  Firstly, you're going to want to use a database in the future as I'm sure, you don't want to create each user manually and store them in an array which would eventually turn into spaghetti code. Secondly, is there a particular reason why you're using "KO" as the not valid status code? Thirdly, why are you defining the variable res with "res=" inside the string?

Beware, I'm a little rusty on my PHP and I'm not that great but just a few things I noticed that don't seem spot on.
I do not plan on leaving the user accounts on the php file, It's temporary. I am using res=KO and res=OK because that is what the documentation said to do.

Quote:The custom server-side page url for access credentials validation.
If this property is set, before attempting the SmartFoxServer login, the LoginBox will send the entered username and password to the provided url for validation.
Two parameters are passed to the custom server-side page via POST: name (the entered username) and pass (the entered password). The page must return res=OK if the credentials are valid or res=KO if the credentials are invalid.

Ohhhhhh, I see, I see. I must of been brain dead this morning.

07-09-2012 12:05 PM #6
yeah... thanks for your help.

Recovered from /printthread.php?tid=19162 · captured 2013.