Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

script change password??

Junior Spellweaver
Joined
Oct 28, 2012
Messages
109
Reaction score
3
any one have this script for change password?

i already try this script

$fp = fopen("C:/Server/Unity/Share/Serv00/new/$UserID.txt","w");
fwrite($fp,$UserID."\r\n");
fwrite($fp,$password."\r\n");
fwrite($fp,"000000\r\n");
fwrite($fp,$userkey."\r\n");
@fclose($fp);


$userid = $_SESSION['username'];
$password2 = strtoupper(md5($newpass));
$initial=substr($userid,0,1);
if (ereg("^[a-zA-Z]$",$initial))
{
$initial=strtoupper($initial);
}
else
{
$initial="etc";
}
$accdir=("C:\Server\Unity\DBSRV\Account");
$f=fopen("./inc/sample.tad", "r");
$f=@fopen($accdir."".$initial."".$userid.".TAD",r) or die("Error");
$acc = fread($f,7124);
$demopass=substr($acc,52,32);
$acc = str_replace($demopass,$password2,$acc);
$f2=@fopen($accdir."".$initial."".$userid.".TAD",w);
@fwrite($f2,$acc) or die("Error");
@fclose($f2);
@fclose($f);

mssql_query("UPDATE Account SET Password = '$password' WHERE UserID='".$_SESSION['username']."'");
$result = "Your password has been changed successfully.";

but in MSSQL Password or login website already changed.. but in game not changed still use old password and .tad not updated...

what wrong in my case?

thanks in advanced
 
Skilled Illusionist
Joined
Mar 31, 2011
Messages
382
Reaction score
48
Test this code.

Code:
<?php
$accdir = 'C:\\Server';
$userid = $_SESSION['username'];

$fp = fopen("$accdir."\\Share\\Serv00\\new\\".$userid.".txt",w);
fwrite($fp,$UserID."\r\n");
fwrite($fp,$password."\r\n");
fwrite($fp,"000000\r\n");
fwrite($fp,$userkey."\r\n");
@fclose($fp);

$password2 = strtoupper(md5($newpass));
$initial=substr($userid,0,1);
if (ereg("^[a-zA-Z]$",$initial)){$initial=strtoupper($initial);} else {$initial="etc";}
$f=fopen($accdir."\\DBSRV\\Account\\".$initial."\\".$userid.".TAD",r) or die("Error 1");
$acc = @[I][B][URL="https://forum.ragezone.com/members/2000164264.html"]fre[/URL][/B][/I]ad($f,7124);
$demopass=substr($acc,52,32);
$acc = str_replace($demopass,$password2,$acc); 
$f2=fopen($accdir."\\DBSRV\\Account".$initial."".$userid.".TAD",w);
fwrite($f2,$acc) or die("Error 2");
@fclose($f);

mssql_query("UPDATE ACCOUNT SET Password = '$password' WHERE UserID='" . $userid . "'");
$result = "Your password has been changed successfully.";
?>
 
Last edited:
Junior Spellweaver
Joined
Oct 28, 2012
Messages
109
Reaction score
3
@John thanks for reply ... but im try to replace your scipt and your scipt didn't work
 
Skilled Illusionist
Joined
Mar 31, 2011
Messages
382
Reaction score
48
¿some error?, paste here your full file code.
 
Junior Spellweaver
Joined
Oct 28, 2012
Messages
109
Reaction score
3
<?php
global $link;
mssql_select_db("UserLogin",$link);

if ($_POST['action'] == 'submitted')
{

$UserId= trim($_SESSION['username']);
$oldpass=trim($_POST['oldpass']);
$password=trim($_POST['password']);
$password2=trim($_POST['password2']);
$initial=substr($UserId,0,1);
$querys = mssql_query("SELECT * FROM Account WHERE UserID='".$_SESSION['username']."'");
$QRow = mssql_fetch_array($querys);
$num_rows = $QRow['Password'];
$zgsend=trim($_POST['zgcode']);
$zgcode = $QRow['ZGCode'];
$userkey = $QRow['UserKey'];

$error = "";
function AllOK()
{

global $error, $num_rows, $oldpass, $password, $password2, $zgcode, $zgsend ;

if ($num_rows != $oldpass)
{
$error .= "<p>The old password is incorrect. <a href=javascript:history.go(-1)>Back</a></p>";
return 0;
}
if ($password == "")
{
$error .= "<p>Failure to place the new password. <a href=javascript:history.go(-1)>Back</a></p>";
return 0;
}
if(!ereg("^[0-9a-zA-Z]{4,12}$",$password))
{
$error .= "<p>Only letters or numbers are allowed, from 4 to 12 characters. <a href=javascript:history.go(-1)>Back</a></p>";
return 0;
}
if ($password != $password2)
{
$error .= "<p>The password do not match. <a href=javascript:history.go(-1)>Back</a></p>";
return 0;
}
if ($num_rows == $password)
{
$error .= "<p>The old password and the new password are the same. <a href=javascript:history.go(-1)>Back</a></p>";
return 0;
}
if ($zgsend != $zgcode)
{
$error .= "<p>Your Tantra Zone Code is incorrect. <a href=javascript:history.go(-1)>Back</a></p>";
return 0;
}

return 1;
}

if (!AllOK())
{
$result = $error;
}
else
{



$accdir = 'C:\\ServerZone';
$userid = $_SESSION['username'];

$fp = fopen("$accdir."\\Share\\Serv00\\new".$userid.".txt",w);
fwrite($fp,$UserID."\r\n");
fwrite($fp,$password."\r\n");
fwrite($fp,"000000\r\n");
fwrite($fp,$userkey."\r\n");
@fclose($fp);

$password2 = strtoupper(md5($newpass));
$initial=substr($userid,0,1);
if (ereg("^[a-zA-Z]$",$initial)){$initial=strtoupper($initial);} else {$initial="etc";}
$f=fopen($accdir."\\DBSRV\\Account".$initial."".$userid.".TAD",r) or die("Error 1");
$acc = fread($f,7124);
$demopass=substr($acc,52,32);
$acc = str_replace($demopass,$password2,$acc);
$f2=fopen($accdir."\\DBSRV\\Account".$initial."".$userid.".TAD",w);
fwrite($f2,$acc) or die("Error 2");
@fclose($f);

mssql_query("UPDATE ACCOUNT SET Password = '$password' WHERE UserID='" . $userid . "'");
$result = "Your password has been changed successfully.";

}
echo $result;
}
else
{
?>
 
Skilled Illusionist
Joined
Mar 31, 2011
Messages
382
Reaction score
48
Code:
<?php
global $link;
mssql_select_db("UserLogin",$link);

if ($_POST['action'] == 'submitted')
{
    
        $UserId= trim($_SESSION['username']);
        $oldpass=trim($_POST['oldpass']);
        $password=trim($_POST['password']);
        $password2=trim($_POST['password2']);
        $initial=substr($UserId,0,1);
        $querys = mssql_query("SELECT * FROM Account WHERE UserID='".$_SESSION['username']."'");
        $QRow = mssql_fetch_array($querys);
        $num_rows = $QRow['Password'];
        $zgsend=trim($_POST['zgcode']);
        $zgcode = $QRow['ZGCode'];
        $userkey = $QRow['UserKey'];

    $error = "";
    function AllOK()
    {

        global $error, $num_rows, $oldpass, $password, $password2, $zgcode, $zgsend ;

        if ($num_rows != $oldpass)
        {
            $error .= "<p>The old password is incorrect. <a href=javascript:history.go(-1)>Back</a></p>";
            return 0;
        }
        if ($password == "")
        {
            $error .= "<p>Failure to place the new password. <a href=javascript:history.go(-1)>Back</a></p>";
            return 0;
        }
        if(!ereg("^[0-9a-zA-Z]{4,12}$",$password))
        {
            $error .= "<p>Only letters or numbers are allowed, from 4 to 12 characters. <a href=javascript:history.go(-1)>Back</a></p>";
            return 0;
        }
        if ($password != $password2)
        {
            $error .= "<p>The password do not match. <a href=javascript:history.go(-1)>Back</a></p>";
            return 0;
        }
        if ($num_rows == $password)
        {
            $error .= "<p>The old password and the new password are the same. <a href=javascript:history.go(-1)>Back</a></p>";
            return 0;
        }
        if ($zgsend != $zgcode)
        {
            $error .= "<p>Your Tantra Zone Code is incorrect. <a href=javascript:history.go(-1)>Back</a></p>";
            return 0;
        }

    return 1;
    }

    if (!AllOK())
    {
        $result = $error;
    }
    else
    {
        
        

$accdir = 'C:\\ServerZone';
$userid = $_SESSION['username'];

$fp = fopen("$accdir."\\Share\\Serv00\\new".$userid.".txt",w);
fwrite($fp,$UserID."\r\n");
fwrite($fp,$password."\r\n");
fwrite($fp,"000000\r\n");
fwrite($fp,$userkey."\r\n");
@fclose($fp);

$password2 = strtoupper(md5($newpass));
$initial=substr($userid,0,1);
if (ereg("^[a-zA-Z]$",$initial)){$initial=strtoupper($initial);} else {$initial="etc";}
$f=fopen($accdir."\\DBSRV\\Account".$initial."".$userid.".TAD",r) or die("Error 1");
$acc = @[I][B][URL="https://forum.ragezone.com/members/2000164264.html"]fre[/URL][/B][/I]ad($f,7124);
$demopass=substr($acc,52,32);
$acc = str_replace($demopass,$password2,$acc); 
$f2=fopen($accdir."\\DBSRV\\Account".$initial."".$userid.".TAD",w);
fwrite($f2,$acc) or die("Error 2");
@fclose($f);

mssql_query("UPDATE ACCOUNT SET Password = '$password' WHERE UserID='" . $userid . "'");
$result = "Your password has been changed successfully.";

    }
    echo $result;
}
else
{
?>

Not return any error?
 

Attachments

You must be registered for see attachments list
Last edited:
Junior Spellweaver
Joined
Oct 28, 2012
Messages
109
Reaction score
3
sql server update > success

.tad update > success (but im check using pspad password not updated

and im try login in game in choose server >> Sorry connectio to server failed xD
 
Skilled Illusionist
Joined
Mar 31, 2011
Messages
382
Reaction score
48
DBSRV daemon should update TAD file if the php script not does o_O
 
Tantra Freelancer
Joined
Apr 9, 2014
Messages
541
Reaction score
23
Hi John,

Is there a way we could change the code and not set the username to a session but to a post value wherein only adminsitrators can change the password without logging in the account of the player?
 
Skilled Illusionist
Joined
Mar 31, 2011
Messages
382
Reaction score
48
Hi John,

Is there a way we could change the code and not set the username to a session but to a post value wherein only adminsitrators can change the password without logging in the account of the player?

You want choice the user at he will change the values?, if so, you only need to change the value of the variable for the user's name
Code:
/* Username received at a session */
$UserId = $_SESSION['username']; // ( username is a sessión variable )

/* Username received per post method */
$UserId = $_POST['username']; // ( username is a post variable )

/* Username received per get method */
$UserId = $_GET['username']; // ( username is a get variable )

/* Username as a fixed value */
$UserId = 'Amir'; // ( Amir is a username in this example )

POST and GET be are formulary send methods. In html something like this:
Code:
<!-- POST METHOD -->
<form method="post" action="">
      <label>Enter the username</label><br>
      <input type="text" name="username" /><br>

      <button>Send</button>
</form>

<!-- GET METHOD -->
<form method="get" action="">
      <label>Enter the username</label><br>
      <input type="text" name="username" /><br>

      <button>Send</button>
</form>

You can also receive values from the url with the GET method, something like:
Code:
http://localhost/changepass.php?username=Amir

Username is the get variable:
Code:
$UserId = $_GET['username'];

And "Amir" the value.
 
Tantra Freelancer
Joined
Apr 9, 2014
Messages
541
Reaction score
23
Sorry, what about allowing any characters (special characters) in the password?
 
Skilled Illusionist
Joined
Mar 31, 2011
Messages
382
Reaction score
48
I hardly remember anything about tantra (server side), the game does not allow these characters in the password?, TAD file contain password in md5, "$#Haw_()A:" in md5 is: CC2ACEA65C7E8564395FCEAB454712F1, login reads the text password and converts in md5 to compare with the md5 in the TAD file.
 

Attachments

You must be registered for see attachments list
Custom Title Activated
Loyal Member
Joined
Mar 26, 2012
Messages
1,465
Reaction score
131
John is correct in the password but, it is also for another reason that it doesn't allow special characters. This is a security flaw that must remain secure. If you allow use of special characters you also allow for intrusion in your server side scripting. Best to keep it simple.
 
Tantra Freelancer
Joined
Apr 9, 2014
Messages
541
Reaction score
23
John is correct in the password but, it is also for another reason that it doesn't allow special characters. This is a security flaw that must remain secure. If you allow use of special characters you also allow for intrusion in your server side scripting. Best to keep it simple.

I am completely aware of those special characters that should not be utilize in-game.
 
Skilled Illusionist
Joined
Mar 31, 2011
Messages
382
Reaction score
48
John is correct in the password but, it is also for another reason that it doesn't allow special characters. This is a security flaw that must remain secure. If you allow use of special characters you also allow for intrusion in your server side scripting. Best to keep it simple.

I am completely aware of those special characters that should not be utilize in-game.

I just responded where my knowledge and my memories have allowed. So that, then if not have another query for here, i retreat.

Any other query about web development (about or not with tantra) tell me.
 
Back
Top