Файл: hostbiter.ru/theme/charset.php
Строк: 93
<?
require ($_SERVER['DOCUMENT_ROOT'].'/Core/core.php');
require ($_SERVER['DOCUMENT_ROOT'].'/Core/fmhead.php');
if(!empty($_GET['dir']) AND $_GET['dir'] != encode('www')){
$dir = htmlspecialchars(trim($_GET['dir']));
}else{
$dir = encode('www');
}
$fileinfo = pathinfo(decode($dir));
$connect_ftp = ftp_connect($config['FTPHost'],21,300);
$ftp = $db->prepare("SELECT * FROM `ftp_users` WHERE `user` = ? LIMIT 1");
$ftp->execute([$user['id']]);
$ftp = $ftp->fetch();
ftp_login($connect_ftp,$ftp['login'],$ftp['password']);
$tmp_name = 'tmp_'.$fileinfo['basename'];
$dirname_tmp = $_SERVER['DOCUMENT_ROOT'].'/tmp_ftp/'.$tmp_name;
ftp_get($connect_ftp,$dirname_tmp,'/'.decode($dir),FTP_ASCII);
$text_file = file_get_contents($dirname_tmp);
$used_charset = mb_detect_encoding($text_file);
if(isset($_GET['iconv']))
{
$new_charset = htmlspecialchars(trim($_POST['new']));
$encoded_file = iconv(strtoupper($used_charset),strtoupper($new_charset).'//TRANSLIT',$text_file);
file_put_contents($dirname_tmp,$encoded_file);
if($_POST['type'] == 1)
{
ftp_chdir($connect_ftp,'/'.dirname(decode($dir)));
ftp_put($connect_ftp,$fileinfo['basename'],$dirname_tmp,FTP_ASCII);
ftp_close($connect_ftp);
unlink($dirname_tmp);
}
else
{
ftp_chdir($connect_ftp,'/'.dirname(decode($dir)));
ftp_put($connect_ftp,$fileinfo['basename'].'.ftp',$dirname_tmp,FTP_ASCII);
unlink($dirname_tmp);
}
$_SESSION['message'] = 'Файл успешно перекодирован!';
header("Location: /explode?dir=".encode($fileinfo['dirname'])."");
exit;
}
?>
<form action="/explode/view/charset.php?dir=<?=$dir?>&iconv" method="post">
Кодировка оригинала:<br/>
<select name="used" disabled>
<option value="<?=$used_charset?>"><?=strtolower($used_charset)?></option>
</select><br/>
Новая кодировка:<br/>
<select name="new">
<option value="utf-8">utf-8</option>
<option value="windows-1251">windows-1251</option>
<option value="koi8-r">koi8-r</option>
<option value="cp866">cp866</option>
<option value="cp1251">cp1251</option>
<option value="iso-8859-1">iso-8859-1</option>
</select><br/>
Тип перекодировки:<br/>
<input type="radio" name="type" value="1">Перезаписать файл<br/>
<input type="radio" name="type" value="2">Сохранить в новый файл.ftp<br/>
<input type="submit" name="iconv" value="Перекодировать">
</form><br/>
<?
require ($_SERVER['DOCUMENT_ROOT'].'/Core/fmfoot.php');
?>