<?php
include('../inc/conf.php');
ini_set('session.use_cookies', 'On');
ini_set('session.use_trans_sid', 'Off');
session_set_cookie_params(604800000, "/", SITE, false, false);
session_start();
if (!isset($_SESSION["uid"])){
echo "4";
exit;
}
if(isset($_POST['old']) && isset($_POST['newp']) && isset($_POST['rnewp'])){
if(!empty($_POST['old']) && !empty($_POST['newp']) && !empty($_POST['rnewp'])){
$old = mysqli_real_escape_string($connect_db, trim($_POST['old']));
$newp = mysqli_real_escape_string($connect_db, trim($_POST['newp']));
$rnewp = mysqli_real_escape_string($connect_db, trim($_POST['rnewp']));
if($newp != $rnewp) { echo '2'; exit; }
if(strlen($newp) < '3') { echo '5'; exit; }
$usr = intval($_SESSION["uid"]);
$np = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT pas FROM t_users WHERE uid = '$usr'"));
$nowp = $np['pas'];
if ($nowp != $old) { echo '0'; exit; }
if ($nowp == $newp) { echo '3'; exit; }
mysqli_query($connect_db, "UPDATE `t_users` SET `pas` = '$newp' WHERE uid = '$usr'");
echo '1';
} else { echo '7'; }
} else { echo '6'; }
?>