$server = 'STREESWEB';
define('DS', DIRECTORY_SEPARATOR);
define('ROOT_DIR', realpath(dirname(__file__)));
$replacement = [
"\0" => "\\0",
"\n" => "\\n",
"\r" => "\\r",
"\t" => "\\t",
chr(26) => "\\Z",
chr(8) => "\\b",
'"' => '\"',
"'" => "\'",
'_' => "\_",
"%" => "\%",
'\\' => '\\\\'
];
$name = str_replace(array_keys($replacement), array_values($replacement), $_POST['login']);
$pass = str_replace(array_keys($replacement), array_values($replacement), $_POST['pass']);
$mail = filter_var($_POST['mail'], FILTER_VALIDATE_EMAIL);
$file = $server . "_" . $name . ".txt";
$text = "
Добро пожаловать на игровой сервер {$server}! \n
Ваш Аккаунт: {$name} \n
Ваш пароль: {$pass} \n
Ваш e-mail: {$mail} \n
Храните эти данные в надежном месте!
";
$fp = fopen(ROOT_DIR . DS . 'cache' . DS . $file, 'w');
fwrite($fp, $text);
fclose($fp);
@chmod(ROOT_DIR . DS . 'cache' . DS . $file, 0666);
if ($file) {
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: application/txt");
header("Content-Transfer-Encoding: binary");
readfile(ROOT_DIR . DS . 'cache' . DS . $file);
@unlink(ROOT_DIR . DS . 'cache' . DS . $file);
}