<?php
require_once("WebsenderAPI.php");
if(isset($_POST["komut-gonder"])){
if ($_POST['sunucu'] != "Sunucu Yok!") {
$sunucu = $_POST["sunucu"];
$komut = $_POST["komut"];
$sec = $db->prepare("SELECT * FROM Sunucular WHERE sunucu = ?");
$sec->execute(array($sunucu));
$oku = $sec->fetch();
$wsr = new WebsenderAPI($oku["ip"], $oku["sunucu_sifre"], $oku["port"]);
if($wsr->connect()){
$wsr->sendCommand($komut);
echo '<div class="alert bg-success" role="alert">Komut başarıyla gönderildi!</div>';
}else{
echo '<div class="alert bg-danger" role="alert">Sunucuya bağlanılamadı!</div>';
}
} else {
echo '<div class="alert bg-danger" role="alert"> Bir sunucu seçmediniz!</div>';
}
}
?>
<br>
<form action="" method="post">
<div class="form-group">
<select class="form-control" name="sunucu" style="width: 100%; height: 45px;">
<?php
$sunucu_cek = $db->query("SELECT * FROM Sunucular ORDER BY id");
$sunucu_cek->execute();
if($sunucu_cek->rowCount() != 0){
foreach ($sunucu_cek as $sunucu_oku) {
?>
<option name="sunucu" value="<?php echo $sunucu_oku['sunucu'] ?>"><?php echo $sunucu_oku['sunucu'] ?></option>
<?php
}
}else{
echo '<option>Sunucu Yok!</option>';
}
?>
</select>
</div>
<input type="text" required name="komut" style="width: 100%; height: 45px;" class="form-control" placeholder="Sunucuyu seçin ve göndermek istediğiniz komutu '/' olmadan yazın!" />
<button name="komut-gonder" class="btn btn-success" style="width: 25%; margin-top: 8px; height: 45px; float: right;">Komut Gönder</button>
</form>
<br>
</center>