<?php
/*********************/
/*                   */
/*  Version : 5.1.0  */
/*  Author  : RM     */
/*  Comment : 071223 */
/*                   */
/*********************/

echo "<html>\r\n<body>\r\n";
require( "config.php" );
require_once( "sql_inject.php" );
include_once( "sql_check.php" );
check_inject( );
$bDestroy_session = TRUE;
$url_redirect = "index.php";
$sqlinject = new sql_inject( "./log_file_sql.log", $bDestroy_session, $url_redirect );
if ( !isset( $_COOKIE['login_site'] ) )
{
    exit( "<script>alert('Somente pessoas logadas'); window.parent.location.href='index.php';;</script>" );
}
if ( isset( $_COOKIE['login_site'] ) )
{
    $mid = $_COOKIE['login_site'];
}
$name = stripslashes( $_POST['name'] );
if ( eregi( "[^a-zA-Z0-9_-]", $mid ) || eregi( "[^a-zA-Z0-9_-]", $mpw ) || eregi( "[^a-zA-Z0-9_-]", $character ) )
{
    exit( "What are you trying to pull sucker ?!" );
}
$login = $mid;
$oldpwd = stripslashes( $_POST['oldpwd'] );
$newpwd = stripslashes( $_POST['newpwd'] );
if ( eregi( "[^a-zA-Z0-9_-]", $login ) || eregi( "[^a-zA-Z0-9_-]", $oldpwd ) || eregi( "[^a-zA-Z0-9_-]", $newpwd ) )
{
    echo "SQL Injection Detected";
    exit( );
}
$sql_username_check = mssql_query( "SELECT memb___id FROM MEMB_INFO WHERE memb___id='".$login."'" );
$username_check = mssql_num_rows( $sql_username_check );
$sql_pw_check = mssql_query( "SELECT memb__pwd FROM MEMB_INFO WHERE memb__pwd='".$oldpwd."' and memb___id='{$login}'" );
$pw_check = mssql_num_rows( $sql_pw_check );
if ( empty( $login ) || empty( $newpwd ) || empty( $oldpwd ) )
{
    echo "Error: Some fields were left blank. Please go back and try again.<br>";
}
else if ( $username_check <= 0 )
{
    echo "Error: Your Login does not exist in our database. Please go back and try again.<br>";
}
else if ( $pw_check <= 0 )
{
    echo "Error: Your Old Password does not exist in our database. Please go back and try again.<br>";
}
else if ( $oldpwd == $newpwd )
{
    echo "Error: Your Old and New password are the same, so no change was comited.<br>";
}
else
{
    $msquery = "UPDATE dbo.MEMB_INFO\r\nSET memb__pwd = '".$newpwd."'\r\nWHERE memb___id = '{$login}'\r\nAND memb__pwd = '{$oldpwd}'";
    $sqlinject->test( $msquery );
    $msresults = mssql_query( $msquery );
    setcookie( "pass", $newpwd."", time( ) + 7257600 );
    echo "<font size='1' face='verdana'>Your account's password has been changed \r\n        succesfully. You can now play in our server. Your account is:<p>\r\n        Login ID:<b> ".$login."</b><br>\r\n        Password:<b> {$newpwd} </b></font>";
}
echo "</body>\r\n</html>";
?>
