Файл: hostbiter.ru/Modules/mgr/ftp.php
Строк: 42
<?
require ($_SERVER['DOCUMENT_ROOT'].'/Core/core.php');
$title = 'FTP пользователи';
require ($_SERVER['DOCUMENT_ROOT'].'/Core/myhead.php');
switch($_GET['list']){
default:
$max = 10;
$checkss = $db->prepare("SELECT * FROM `ftp_users` WHERE `user` = ?");
$checkss->execute([$user['id']]);
$k_post = $checkss->rowCount();
$k_page = k_page($k_post,$max);
$page = page($k_page);
$start = $max*$page-$max;
$all = $db->prepare("SELECT * FROM `ftp_users` WHERE `user` = ? LIMIT $start,$max");
$all -> execute([$user['id']]);
$all = $all -> fetchAll();
foreach($all as $row){
?>
<div class="border2">
<span style="float:right;"><a href="/mgr/ftp.php?list=drop&id=<?=$row['id']?>"><img src="/image/delete.png" alt="" title="Удалить" /></a></span>
ftp хост: <b><?=$config['FTPHost']?></b><br/>
ftp логин: <b><?=$row['login']?></b><br/>
ftp пароль: <b>****</b></div>
<?
}
if($k_page >1){
echo str('?',$k_page,$page);
}
echo '<img src="/image/edits.png" alt="" /> <a href="/mgr/ftp.php?list=create">Создать ftp</a>';
break;
case 'create':
if(isset($_GET['create'])){
$login = 'a'.rand(1,214748364);
$password = htmlspecialchars(trim($_POST['password']));
$tar = $db->prepare("SELECT * FROM `tarifs` WHERE `id` = ?");
$tar->execute([$user['tarif']]);
$tar = $tar->fetch();
if($user['ftps'] >= $tar['ftps']) $err = 'Слишком много FTP пользователей!';
if(!$err){
$api = file_get_contents($config['PanelUrl']."/ispmgr?authinfo=".$user['login'].":".decode($user['password'])."&out=xml&func=ftp.user.edit&sok=ok&name=".$login."&owner=".$user['login']."&passwd=".$password."&confirm=".$password."");
$sql1 = $db->prepare("INSERT INTO `ftp_users` (`user`,`login`,`password`) VALUES (?,?,?)");
$sql1->execute([$user['id'],$login,$password]);
$sql2 = $db->prepare("UPDATE `users` SET `ftps` = `ftps` + ? WHERE `id` = ?");
$sql2->execute([1,$user['id']]);
$_SESSION['message'] = 'FTP пользователь добавлен!';
header("Location: /mgr/ftp.php");
exit;
}else{
$_SESSION['message'] = $err;
header("Location: /mgr/ftp.php?list=create");
exit;
}
}
?>
<form action="ftp.php?list=create&create" method="post">
Пароль:<br />
<input name="password" type="password" required/><br />
<div><input type="submit" class="gtab" name="create" value="Создать" /></div>
</form><img src="/image/back.gif" alt="" /> <a href="/mgr/ftp.php">Назад</a>
<?
break;
case 'drop':
$id = abs(intval($_GET['id']));
$ftp = $db->prepare("SELECT * FROM `ftp_users` WHERE `id` = ?");
$ftp->execute([$id]);
$ftp = $ftp->fetch();
if($ftp['user'] != $user['id']) $err = 'FTP пользователь не принадлежит вам!';
if(!$err){
$api2 = file_get_contents($config['PanelUrl']."/ispmgr?authinfo=".$user['login'].":".decode($user['password'])."&out=xml&func=ftp.user.delete&elid=".$ftp['login']."");
$sql3 = $db->prepare("DELETE FROM `ftp_users` WHERE `id` = ?");
$sql3->execute([$id]);
$sql4 = $db->prepare("UPDATE `users` SET `ftps` = `ftps` - ? WHERE `id` = ?");
$sql4->execute([1,$user['id']]);
$_SESSION['message'] = 'FTP пользователь удалён!';
header("Location: /mgr/ftp.php");
exit;
}else{
$_SESSION['message'] = $err;
header("Location: /mgr/ftp.php");
exit;
}
break;
}
require ($_SERVER['DOCUMENT_ROOT'].'/Core/myfoot.php');
?>