Şu kodu:
<?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();
$ws = new Websend("".$oku["ip"]."");
$ws->password = "".$oku["sunucu_sifre"]."";
$ws->port = "".$oku["port"]."";
if($ws->connect()){
$ws->doCommandAsConsole($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>Bu koda çevirmek istiyorum;
<?php
if(isset($_POST['inputCommand'])){
$command = $_POST['inputCommand'];
if($command == null) die("Please write a comm");
$host = "127.0.0.1";
$password = "123qwe";
$port = 9876;
require_once("WebsenderAPI.php"); // Load Library
$wsr = new WebsenderAPI($host,$password,$port); // HOST , PASSWORD , PORT
if($wsr->connect()){ //Open Connect
$wsr->sendCommand($command /* "ýnputCommand" here! */);
}else{
die("Connection error! Check ip, pass and port.");
}
$wsr->disconnect(); //Close connection.
}
?>
<center>
<br><br><br>
<form method="POST">
<input type="text" name="inputCommand" placeholder="Write a command!">
<input type="submit" value="Send!">
</form>
</center>