[Release] Simple registration page for official server files (php)

Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1

    [Release] Simple registration page for official server files (php)

    index.php

    PHP Code:
    <?php
    /* Simple registration page for silkroad server, by Chernobyl
     * Settings are at _inc/config.php
     * If you get an mssql connection error, while defining totally correct data
     * Just use older ntwdblib.dll for your webserver
    */
    require_once('_inc/security.class.php');
    require_once(
    '_inc/config.php');

    if(!isset(
    $_POST['submit']))
        {
            echo 
    "<table border='1'>
            <form method='post'>
            <td>Username</td><td><input type='text' name='username' maxlength='16'></td><tr/>
            <td>Password[1]</td><td><input type='password' name='pw1' maxlength='32'></td><tr/>
            <td>Password[2]</td><td><input type='password' name='pw2' maxlength='32'></td><tr/>
            <td></td><td><input type='submit' name='submit' value='Register'></td>
            </form>
                    </table>"
    ;
        }
        else
        {
                    if(
    is_array($user) == true$err[] = "Username is array, n00p";
            if(
    is_array($pass1) == true$err[] = "Pw1 is array, n00p";
            if(
    is_array($pass2) == true$err[] = "Pw2 is array, n00p";
            if(
    strlen($_POST['username']) < 3$msg[] = "Username too short";
            if(
    strlen($_POST['username']) > 16)$msg[] = "Username too long";
            if(
    strlen($_POST['pw1']) < 6$msg[] = "Password [1] too short";
            if(
    strlen($_POST['pw1']) > 32)$msg[] = "Password [1] too long";
            if(
    strlen($_POST['pw2']) < 6$msg[] = "Password [2] too short";
            if(
    strlen($_POST['pw']) > 32$msg[] = "Password [2] too long";
            if(
    $_POST['pw1'] != $_POST['pw2']) $msg[] = "Passwords are not the same";
            
                
    $sec = new security();
                
                if(
    $sec->is_secure($_POST['username']) == false$msg[] = "Username contains forbidden symbols";
                if(
    $sec->is_secure($_POST['pw1']) == false$msg[] = "Password [1] contains forbidden symbols";
                if(
    $sec->is_secure($_POST['pw2']) == false$msg[] = "Password [2] contains forbidden symbols";
                
                if(
    count($msg) > 0)
                    {
                        for(
    $i 0$i count($msg); $i++)
                            {
                                echo 
    $msg[$i]."<br/>";
                            }
                            return;
                    }
                    else
                        {
                            
    //checking damn mssql stuff
                            
    $accountExists mssql_num_rows(mssql_query("select StrUserID from TB_User where StrUserID='$_POST[username]'"));
                                if(
    $accountExists 0) echo "Account with such username already exists<br/>";
                                    else
                                    {
                                        
    $pwd md5($_POST['pw1']);
                                        
    mssql_query("insert into TB_User(StrUserID,password,sec_primary,sec_content) values('$_POST[username]','$pwd','3','3')");
                                            echo 
    "Account successfully created<br/>";
                                    }
                        }

        }
    ?>
    _inc/security.class.php

    PHP Code:
    <?php
    class security
    {
    function 
    is_secure($string)
                {
                
    $pattern "#[^a-zA-Z0-9_\-]#";
                    if(
    preg_match($pattern,$string)==true)return false;
                            else
                            return 
    true;
                    }            
    }
    ?>

    _inc/config.php

    PHP Code:
    <?php

    $cfg
    ['sql_host'] = ".\SQLEXPRESS";
    $cfg['sql_user'] = "sa";
    $cfg['sql_pass'] = "1234";
    $cfg['sql_db'] = "SRO_VT_ACCOUNT";


    $sqlLink mssql_connect($cfg[sql_host],$cfg[sql_user],$cfg[sql_pass]);
        if(!
    $sqlLink) die("MSSQL server is not accessable, why should we try to select database ?");
            else
            {
                
    mssql_select_db($cfg[sql_db],$sqlLink);
            }
    ?>
    Last edited by Chern0byl; 24-09-11 at 01:14 AM.


  2. #2
    Member Vovi is offline
    MemberRank
    Apr 2008 Join Date
    GdyniaLocation
    92Posts

    Re: Simple registration page for official server files (php)

    This will help much in a short future, thanks for release.

  3. #3
    Account Upgraded | Title Enabled! MarcoTozzi is offline
    MemberRank
    Nov 2009 Join Date
    276Posts

    Re: Simple registration page for official server files (php)

    Thx! and looking forward for Silk releases >:)

  4. #4
    Valued Member hatibudak is offline
    MemberRank
    Sep 2011 Join Date
    103Posts

    Re: Simple registration page for official server files (php)

    nice releases.. i still waiting for email registration too.. for more security feature..

  5. #5
    Valued Member badibatu is offline
    MemberRank
    Sep 2011 Join Date
    122Posts

    Re: Simple registration page for official server files (php)

    Thx for relase :)

  6. #6
    Account Upgraded | Title Enabled! AngelShade is offline
    MemberRank
    Feb 2007 Join Date
    RomaniaLocation
    413Posts

    Re: Simple registration page for official server files (php)

    Hope to see these files put in function. Thanks for the release its more then enough.

  7. #7
    King Canadian whhacker93 is offline
    MemberRank
    Apr 2008 Join Date
    CanadaLocation
    926Posts

    Re: Simple registration page for official server files (php)

    Yeah, thanks alot. You're a legend xD

  8. #8
    Account Upgraded | Title Enabled! versacebg is offline
    MemberRank
    Sep 2006 Join Date
    BulgariaLocation
    516Posts

    Re: [Release] Simple registration page for official server files (php)

    Not working blank page .... bug ??? hm ?

  9. #9
    Account Upgraded | Title Enabled! RevoLand is offline
    MemberRank
    Jan 2009 Join Date
    117Posts

    Re: [Release] Simple registration page for official server files (php)

    Quote Originally Posted by versacebg View Post
    Not working blank page .... bug ??? hm ?
    there is no bug, you can't use mssql_connect with iis server so you need appserv or etc.

  10. #10
    Account Upgraded | Title Enabled! versacebg is offline
    MemberRank
    Sep 2006 Join Date
    BulgariaLocation
    516Posts

    thumbs up Re: [Release] Simple registration page for official server files (php)

    Quote Originally Posted by CEZALAND View Post
    there is no bug, you can't use mssql_connect with iis server so you need appserv or etc.
    Aha :D oki doki i will try fix soon :)

  11. #11
    Proficient Member sLiM_XaDy is offline
    MemberRank
    Sep 2004 Join Date
    154Posts

    Re: [Release] Simple registration page for official server files (php)

    Guys use Xamp 1.71 bundle, and download the ntwdblib.dll that Chernobyl uploaded to your apache/bin folder and php folder, it will work correctly, then you can do whatever you want, add more queries to those pages and a template etc...

  12. #12
    Valued Member Maecko is offline
    MemberRank
    Mar 2008 Join Date
    119Posts

    Re: [Release] Simple registration page for official server files (php)

    the page itself works but if i create a account via that page i cant create a character with that account ingame :D S1030 error

  13. #13
    Apprentice Unif is offline
    MemberRank
    Sep 2011 Join Date
    5Posts

    Re: [Release] Simple registration page for official server files (php)

    i edit code for work with IIS7+PHP+MSSQL 2008

    First : install PHP for IIS 7 from this link
    Windows Web App Gallery - Install an App

    Second : Download SQL Driver for PHP (Works with apache as well) from this link
    Download Details - Microsoft Download Center - Microsoft Drivers for PHP for SQL Server

    Once installed and configured correctly...

    try to use this

    config.php
    PHP Code:
    <?php

    $cfg
    ['sql_host'] = "(local)";
    $cfg['sql_user'] = "sa";
    $cfg['sql_pass'] = "123456";
    $cfg['sql_db'] = "SRO_VT_ACCOUNT";
    $cfg ['connInfo'] = array("UID"=>$cfg['sql_user'], 
                        
    "PWD"=>$cfg['sql_pass'],
                        
    "Database"=>$cfg['sql_db']);

    $sqlLink sqlsrv_connect($cfg[sql_host], $cfg ['connInfo']);
        if(
    $sqlLink === false)
        {
            die(
    "MSSQL server is not accessable, why should we try to select database ?");
        }
    ?>
    index.php
    PHP Code:
    <?php
    /* Simple registration page for silkroad server, by Chernobyl
     * Settings are at _inc/config.php
     * If you get an mssql connection error, while defining totally correct data
     * Just use older ntwdblib.dll for your webserver
    */
    require_once('_inc/security.class.php');
    require_once(
    '_inc/config.php');

    if(!isset(
    $_POST['submit']))
        {
            echo 
    "<table border='1'>
            <form method='post'>
            <td>Username</td><td><input type='text' name='username' maxlength='16'></td><tr/>
            <td>Password[1]</td><td><input type='password' name='pw1' maxlength='32'></td><tr/>
            <td>Password[2]</td><td><input type='password' name='pw2' maxlength='32'></td><tr/>
            <td></td><td><input type='submit' name='submit' value='Register'></td>
            </form>
                    </table>"
    ;
        }
        else
        {
            if(
    strlen($_POST['username']) < 3$msg[] = "Username too short";
            if(
    strlen($_POST['username']) > 16)$msg[] = "Username too long";
            if(
    strlen($_POST['pw1']) < 6$msg[] = "Password [1] too short";
            if(
    strlen($_POST['pw1']) > 32)$msg[] = "Password [1] too long";
            if(
    strlen($_POST['pw2']) < 6$msg[] = "Password [2] too short";
            if(
    strlen($_POST['pw']) > 32$msg[] = "Password [2] too long";
            if(
    $_POST['pw1'] != $_POST['pw2']) $msg[] = "Passwords are not the same";
            
                
    $sec = new security();
                
                if(
    $sec->is_secure($_POST['username']) == false$msg[] = "Username contains forbidden symbols";
                if(
    $sec->is_secure($_POST['pw1']) == false$msg[] = "Password [1] contains forbidden symbols";
                if(
    $sec->is_secure($_POST['pw2']) == false$msg[] = "Password [2] contains forbidden symbols";
                
                if(
    count($msg) > 0)
                    {
                        for(
    $i 0$i count($msg); $i++)
                            {
                                echo 
    $msg[$i]."<br/>";
                            }
                            return;
                    }
                    else
                        {
                            
    //checking damn mssql stuff
                            
    $accountExists =  sqlsrv_num_rows(sqlsrv_query$sqlLink"select StrUserID from TB_User where  StrUserID='$_POST[username]'"));
                                if(
    $accountExists 0) echo "Account with such username already exists<br/>";
                                    else
                                    {
                                        
    $pwd md5($_POST['pw1']);

                                        
    // Setup the parameter
                                        
    $sql_params "INSERT INTO TB_User(StrUserID,password,sec_primary,sec_content)VALUES(?, ?, ?, ?)";

                                        
    // Set parameter values.
                                        
    $params = array($_POST[username], $pwd33);

                                        
    // Execute the query.
                                        
    $query sqlsrv_query($sqlLink$sql_params$params);
                                        if(
    $query)
                                        {
                                            echo 
    "Account successfully created<br />";
                                        }
                                        else
                                        {
                                            echo 
    "Account can not create!<br />";
                                            die( 
    print_rsqlsrv_errors(), true));
                                        }

                                        
    // Release resources.
                                        
    sqlsrv_free_stmt($query);
                                        
    sqlsrv_close($sqlLink);
                                    }
                        }
        }

    sorry for my english grammar. :)

  14. #14
    { print }' /etc*/passwd str8killa is offline
    MemberRank
    Feb 2007 Join Date
    369Posts

    Re: [Release] Simple registration page for official server files (php)

    can you add email 2 this so people can reset there accounts?

  15. #15
    Member Cha0sBG is offline
    MemberRank
    Mar 2009 Join Date
    BulgariaLocation
    57Posts

    Re: [Release] Simple registration page for official server files (php)

    nevermind i found the error
    Last edited by Cha0sBG; 20-09-11 at 06:25 PM.



Page 1 of 2 12 LastLast

Advertisement