Hi, Where is the error?
`<?php
class bt_api {
private $BT_KEY = "key"; // API anahtarı
private $BT_PANEL = "ip"; // Panel adresi
public function __construct($bt_panel = null, $bt_key = null){
if($bt_panel) $this->BT_PANEL = $bt_panel;
if($bt_key) $this->BT_KEY = $bt_key;
}
// Yeni site ekleme işlevi
public function AddSite($domain, $ftp, $sql){
$url = $this->BT_PANEL . '/site?action=AddSite';
$ftp_username = str_replace('.', '_', $domain);
$ftp_password = 'WCBZ6cH87raERzXc'; // Güçlü bir şifre oluşturun veya dinamik oluşturun
$datapassword = 'PdbNjJy5hBA346AR'; // Güçlü bir şifre oluşturun veya dinamik oluşturun
$post_data = array(
'webname' => json_encode(['domain' => $domain, 'domainlist' => [], 'count' => 0]),
'path' => '/www/wwwroot/' . $domain,
'type_id' => 0,
'type' => 'PHP',
'version' => '72',
'port' => 80,
'ps' => 'test',
'ftp' => $ftp,
'ftp_username' => $ftp_username,
'ftp_password' => $ftp_password,
'sql' => $sql,
'codeing' => 'utf8',
'datauser' => $ftp_username,
'datapassword' => $datapassword
);
$p_data = $this->GetKeyData(); // İmzayı al
$post_data = array_merge($post_data, $p_data); // İmzayı ekle
$result = $this->HttpPostCookie($url, $post_data);
$data = json_decode($result, true);
return $data;
}
// İmzayı içeren veri oluşturma
private function GetKeyData(){
$now_time = time();
$p_data = array(
'request_token' => md5($now_time . '' . md5($this->BT_KEY)),
'request_time' => $now_time
);
return $p_data;
}
// POST isteği gönderme
private function HttpPostCookie($url, $data, $timeout = 60) {
$cookie_file = './' . md5($this->BT_PANEL) . '.cookie';
if (!file_exists($cookie_file)) {
$fp = fopen($cookie_file, 'w+');
fclose($fp);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
}
// Kullanıcıdan domain adresini al
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$domain = filter_input(INPUT_POST, 'domain', FILTER_SANITIZE_STRING);
if (!empty($domain)) {
$api = new bt_api();
$response_data = $api->AddSite($domain, true, true); // FTP ve SQL oluşturma
// Yanıtı ekrana yazdır
echo "<pre>API Yanıtı: " . htmlspecialchars(json_encode($response_data, JSON_PRETTY_PRINT)) . "</pre>";
// Yanıttaki belirli anahtarların varlığını kontrol et
if (isset($response_data['siteStatus'])) {
if ($response_data['siteStatus'] === true) {
echo "Domain başarıyla eklendi: " . $domain;
if ($response_data['ftpStatus'] === true) {
echo "<br>FTP kullanıcı adı: " . $response_data['ftpUser'];
echo "<br>FTP şifresi: " . $response_data['ftpPass'];
}
if ($response_data['databaseStatus'] === true) {
echo "<br>Veritabanı kullanıcı adı: " . $response_data['databaseUser'];
echo "<br>Veritabanı şifresi: " . $response_data['databasePass'];
}
} else {
echo "Domain eklenemedi: " . $response_data['msg'];
}
} else {
echo "Beklenen yanıt formatı alınamadı. Yanıt: " . htmlspecialchars(json_encode($response_data));
}
} else {
echo "Domain adresi boş olamaz.";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Web Hosting Hesabı Aç</title>
</head>
<body>
<form method="post">
<label for="domain">Domain Adresi:</label>
<input type="text" id="domain" name="domain" required>
<button type="submit">Hesap Aç</button>
</form>
</body>
</html>
`