php file for creating a token

Results 1 to 16 of 16
  1. #1
    Member bennetcat is offline
    MemberRank
    Feb 2011 Join Date
    60Posts

    php file for creating a token

    Hi,
    could someone please post a code for creating a random 25char long token?
    Ty


  2. #2
    Account Upgraded | Title Enabled! Charisma Doll is offline
    MemberRank
    Oct 2012 Join Date
    Wonderland.Location
    256Posts

    Re: php file for creating a token

    &createrandom25chartoken

  3. #3
    Valued Member Black12 is offline
    MemberRank
    Feb 2012 Join Date
    JapanLocation
    119Posts

    Re: php file for creating a token

    PHP Code:
    <?php
    $conf
    ['db_host'] = ".\SQLEXPRESS";
    $conf['db_user'] = "sa";
    $conf['db_pass'] = "sapw";
    $conf['db_name'] = "OdinAccount";

    $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 nEMID, sUserPass FROM tAccounts where sUsername = '$user'");

    if(
    $exec)
    {
        if(
    mssql_num_rows($exec) != 1)
        {
            die(
    'Account Not Found.');
        }
        
    $AccountData mssql_fetch_assoc($exec);
        
    $PlaintxtPass $AccountData['sUserPass'];
        
    $PlaintxtnEMID $AccountData['nEMID'];
        if (
    MD5($PlaintxtPass) == $passhash)
        {
            
    $Token RandomToken(50);

            
    $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');
        }
        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);
    }

    function 
    RandomToken$length )
    {
        
    $chars "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            
    $str "";
        
    $size strlen$chars );
        for( 
    $i 0$i $length$i++ ) {
            
    $str .= $charsrand0$size ) ];
        }

        return 
    $str;
    }
    ?>

  4. #4
    Proficient Member xWhiteCore is offline
    MemberRank
    Jun 2012 Join Date
    193Posts

    Re: php file for creating a token

    Quote Originally Posted by Black12 View Post
    PHP Code:
    <?php
    $conf
    ['db_host'] = ".\SQLEXPRESS";
    $conf['db_user'] = "sa";
    $conf['db_pass'] = "sapw";
    $conf['db_name'] = "OdinAccount";

    $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 nEMID, sUserPass FROM tAccounts where sUsername = '$user'");

    if(
    $exec)
    {
        if(
    mssql_num_rows($exec) != 1)
        {
            die(
    'Account Not Found.');
        }
        
    $AccountData mssql_fetch_assoc($exec);
        
    $PlaintxtPass $AccountData['sUserPass'];
        
    $PlaintxtnEMID $AccountData['nEMID'];
        if (
    MD5($PlaintxtPass) == $passhash)
        {
            
    $Token RandomToken(50);

            
    $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');
        }
        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);
    }

    function 
    RandomToken$length )
    {
        
    $chars "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            
    $str "";
        
    $size strlen$chars );
        for( 
    $i 0$i $length$i++ ) {
            
    $str .= $charsrand0$size ) ];
        }

        return 
    $str;
    }
    ?>

    From iStu....

  5. #5
    ExtrinsicStudio™ Myth is offline
    MemberRank
    Jan 2012 Join Date
    367Posts

    Re: php file for creating a token

    Id laugh if Stu left a little surprise in his OdinRest, then a few months later he just buttfucks every server using his REST.

    Has anyone re-done their REST instead of using the Odin one? Or is this an Odin section now?

  6. #6
    Alpha Member Cyndaquil is offline
    MemberRank
    Mar 2012 Join Date
    EnglandLocation
    2,137Posts

    Re: php file for creating a token

    Odin section.

  7. #7
    Account Upgraded | Title Enabled! Crystalz is offline
    MemberRank
    Aug 2012 Join Date
    212Posts

    Re: php file for creating a token

    Quote Originally Posted by Myth View Post
    Id laugh if Stu left a little surprise in his OdinRest, then a few months later he just buttfucks every server using his REST.

    Has anyone re-done their REST instead of using the Odin one? Or is this an Odin section now?
    Nah I know a guy who remade it.

  8. #8
    Gruntilda Gruntilda is offline
    MemberRank
    Apr 2010 Join Date
    468Posts

    Re: php file for creating a token

    Quote Originally Posted by Myth View Post
    Id laugh if Stu left a little surprise in his OdinRest, then a few months later he just buttfucks every server using his REST.

    Has anyone re-done their REST instead of using the Odin one? Or is this an Odin section now?
    Using any program out there, you could just listen an see that it only has one open tcp connection, and that should be on 127.0.0.1:80. So unless I invented a way to connect to everyone's localhost, you sir, are an idiot.

    Quote Originally Posted by Crystalz View Post
    Nah I know a guy who remade it.
    Goodbye item mall bag.

  9. #9
    Account Upgraded | Title Enabled! Crystalz is offline
    MemberRank
    Aug 2012 Join Date
    212Posts

    Re: php file for creating a token

    Quote Originally Posted by iStu;


    Goodbye item mall bag.
    Actually item mall bag works.

  10. #10
    Gruntilda Gruntilda is offline
    MemberRank
    Apr 2010 Join Date
    468Posts

    Re: php file for creating a token

    We'll see c:

  11. #11
    Account Upgraded | Title Enabled! Kreain is offline
    MemberRank
    May 2008 Join Date
    679Posts

    Re: php file for creating a token

    Quote Originally Posted by iStu View Post
    Using any program out there, you could just listen an see that it only has one open tcp connection, and that should be on 127.0.0.1:80. So unless I invented a way to connect to everyone's localhost, you sir, are an idiot.
    Not if a token would cause it from the inside...

  12. #12
    Gruntilda Gruntilda is offline
    MemberRank
    Apr 2010 Join Date
    468Posts

    Re: php file for creating a token

    Never even that of that...hey look you finally had a good idea.

  13. #13
    ExtrinsicStudio™ Myth is offline
    MemberRank
    Jan 2012 Join Date
    367Posts

    Re: php file for creating a token

    Quote Originally Posted by iStu View Post
    Using any program out there, you could just listen an see that it only has one open tcp connection, and that should be on 127.0.0.1:80. So unless I invented a way to connect to everyone's localhost, you sir, are an idiot.
    "Id laugh" is common to suggest something sarcastic, in a sense that the chances of it happening are slimmer than that of the gap between your ass cheeks.. but its cool, a person who quit still has the attitude of a full-blown developer, seems your Fiesta-ego still didn't die yet, 4lyfe reppin'.

  14. #14
    Gruntilda Gruntilda is offline
    MemberRank
    Apr 2010 Join Date
    468Posts

    Re: php file for creating a token

    I'd laugh if you learned how to dev anything.

    Am I doing it right?

  15. #15
    ExtrinsicStudio™ Myth is offline
    MemberRank
    Jan 2012 Join Date
    367Posts

    Re: php file for creating a token

    Guess your salty-ass is full of laughter then.

  16. #16
    Member ThePunisher is offline
    MemberRank
    Aug 2011 Join Date
    91Posts

    Re: php file for creating a token

    I was beginning to wonder if this section's 'reputation' had vanished but never mind.



Advertisement