0) {
header('Location: /fbattle.php');
die();
}
use Krugozor\Database\Mysql\Mysql as Mysql;
$db = Mysql::create("192.168.20.100", "battles", "bottle-neck-horse")
->setDatabaseName("battles")
->setCharset("utf8");
$name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
$oldpsw = filter_input(INPUT_POST, 'oldpsw', FILTER_SANITIZE_SPECIAL_CHARS);
$newpsw = filter_input(INPUT_POST, 'newpsw', FILTER_SANITIZE_SPECIAL_CHARS);
$color = filter_input(INPUT_POST, 'color', FILTER_VALIDATE_INT);
$hobbie = filter_input(INPUT_POST, 'hobbie', FILTER_SANITIZE_STRING);
$hobbie = str_replace("\\n", "
", $hobbie);
$hobbie = str_replace("\\r", "", $hobbie);
$hobbie = str_replace("<br />", "
", $hobbie);
if ($name || $color || $hobbie) {
$simbolcount = strlen($hobbie);
switch ($color) {
case 1: $color = 'blue'; break;
case 2: $color = 'green'; break;
default: $color = 'black'; break;
}
if ($simbolcount > 1500) {
err('Максимальная длинна поля Хобби: 1500 символов!');
} else {
//db::c()->query('UPDATE `users` SET `realname` = "?s", `color` = "?s", `info` = "?s" WHERE `id` = ?i', $name, $color, $hobbie, $user['id']);
$values = ['realname'=>$name, 'color'=>$color, 'info'=>$hobbie];
$db->query('UPDATE users SET ?As WHERE id = ?i', $values, $user['id']);
}
}
if ($oldpsw && $newpsw){
if (password_verify($oldpsw, $user['pass'])){
db::c()->query('UPDATE `users` SET `pass` = "?s" WHERE `id` = ?i', password_hash($newpsw,PASSWORD_DEFAULT), $user['id']);
} else err('Неверный текущий пароль!');
}
?>