Forum Discussion

ncase's avatar
ncase
Visitor
15 years ago

Anyone willing to share reg code creation PHP/XML script?

We have a channel running but now need to link it to our existing website:

1. Users are shown the reg screen with a registration code (we have regscreen.brs but need to know how to generate a code)
2. Users go to our website, login
3. Our site checks if he is a member or not, if so, proceed to show him/her the registration code input box
4. Then we check if the code is valid, if so, activate the token + add this code to the database
5. Then the user can watch their Roku channels during their membership period with the above method
6. If whenever the user's membership expires, we need to unregister the code

It's really steps 1 & 6 we need help with, does anyone have any experience doing this?

Many thanks!
Casey

1 Reply

  • 1) A simple way pseudo code to generate regCodes:


    for (i=0; i<5;i++)
    {
    string code = Rand.String(Rand.Next(4, 7)).ToUpper();
    // Replace O and I with characters that aren't so confusing
    code = code.Replace("O", "X");
    code = code.Replace("I", "Y");

    bool found = dbLookup("select "+code+" from registeringCodes")
    if (!found)
    {
    dbInsert("insert into registeringCodes set regCode="+code)
    break;
    }
    }
    return code


    6) When membership expires remove the Device Service Token associated with the users account from the "valid DST tokens" table used for authentication. This is the table that associates that DST with a user account.