$registered_ip) {
if ($registered_ip === $ip) {
$user_subs[] = $sub;
}
}
return $user_subs;
}
$my_exclusive_subdomains = get_subdomains_by_ip($user_ip);
// ফাইল ম্যানেজারের সেশন ট্র্যাকিং কনফিগারেশন
$active_fm_sub = $_SESSION['active_fm_sub'] ?? '';
// ==========================================
// ২. অ্যাকশন প্রসেসর (POST API Requests)
// ==========================================
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// রোবট সাবডোমেইন ক্রিয়েটর
if (isset($_POST['secure_token_action']) && $_POST['secure_token_action'] === 'api_robot_create_subdomain') {
$input_sub = $_POST['subdomain_raw_input'] ?? '';
$sanitized_sub = strtolower(trim(preg_replace('/[^a-z0-9\-]/', '', $input_sub)));
if (!empty($sanitized_sub)) {
$registry_db = load_ip_registry_database();
if (array_key_exists($sanitized_sub, $registry_db)) {
$system_message = "⚠ এই সাবডোমেইনটি ইতিমধ্যে ডাটাবেসে তৈরি করা আছে!";
$system_status = "warning";
$current_active_tab = "robot";
} else {
$api_url = "https://" . CPANEL_HOST . ":2083/execute/SubDomain/addsubdomain";
$query_params = ["domain" => $sanitized_sub, "rootdomain" => ROOT_DOMAIN, "dir" => "public_html/" . $sanitized_sub];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $api_url . '?' . http_build_query($query_params));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_HTTPHEADER, ["Authorization: cpanel " . CPANEL_USER . ":" . CPANEL_TOKEN]);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$dir_path = ROOT_DIR . "/" . $sanitized_sub;
if (!file_exists($dir_path)) {
mkdir($dir_path, 0755, true);
}
$boilerplate = "\n\n
\n\nLive Site\n\n🌐 " . strtoupper($sanitized_sub) . " লাইভ প্রিভিউ!
\n";
file_put_contents($dir_path . "/index.html", $boilerplate);
register_subdomain_to_ip($sanitized_sub, $user_ip);
$newly_created_subdomain_link = "https://" . $sanitized_sub . "." . ROOT_DOMAIN;
$system_message = "✅ সাবডোমেইন " . $sanitized_sub . "." . ROOT_DOMAIN . " তৈরি সফল!";
$system_status = "success";
$current_active_tab = "robot";
$my_exclusive_subdomains = get_subdomains_by_ip($user_ip);
}
}
}
// কোড ইনজেক্টর প্রসেসর
if (isset($_POST['secure_token_action']) && $_POST['secure_token_action'] === 'api_save_injected_code') {
$target_subdomain = $_POST['target_subdomain_select'] ?? '';
$raw_code_buffer = $_POST['html_code_buffer'] ?? '';
if (!empty($target_subdomain) && in_array($target_subdomain, $my_exclusive_subdomains)) {
$file_destination = ROOT_DIR . "/" . $target_subdomain . "/index.html";
// ডিরেক্টরি কোনো কারণে মুছে গেলে অটো জেনারেট ব্যাকআপ
if(!is_dir(ROOT_DIR . "/" . $target_subdomain)){
mkdir(ROOT_DIR . "/" . $target_subdomain, 0755, true);
}
file_put_contents($file_destination, $raw_code_buffer);
$system_message = "💾 " . htmlspecialchars($target_subdomain) . " সোর্স কোড আপডেট করা হয়েছে!";
$system_status = "success";
} else {
$system_message = "❌ অননুমোদিত অ্যাক্সেস বা ত্রুটি!";
$system_status = "danger";
}
$current_active_tab = "code";
}
// ফাইল ম্যানেজার: সাবডোমেইন সিলেকশন হ্যান্ডলার
if (isset($_POST['secure_token_action']) && $_POST['secure_token_action'] === 'fm_enter_subdomain') {
$target_sub = $_POST['fm_subdomain_choice'] ?? '';
if (in_array($target_sub, $my_exclusive_subdomains)) {
$_SESSION['active_fm_sub'] = $target_sub;
$active_fm_sub = $target_sub;
}
$current_active_tab = "script";
}
// ফাইল ম্যানেজার: নতুন ফাইল ক্রিয়েশন সিস্টেম
if (isset($_POST['secure_token_action']) && $_POST['secure_token_action'] === 'fm_create_new_file') {
$new_file = trim($_POST['fm_new_file_name'] ?? '');
$new_file = preg_replace('/[^a-zA-Z0-9\.\-_]/', '', $new_file);
if (!empty($active_fm_sub) && !empty($new_file)) {
if(!is_dir(ROOT_DIR . "/" . $active_fm_sub)){
mkdir(ROOT_DIR . "/" . $active_fm_sub, 0755, true);
}
$file_path = ROOT_DIR . "/" . $active_fm_sub . "/" . $new_file;
if (!file_exists($file_path)) {
file_put_contents($file_path, "");
$system_message = "📄 ফাইল সফলভাবে তৈরি হয়েছে: " . htmlspecialchars($new_file);
$system_status = "success";
} else {
$system_message = "⚠ এই নামের ফাইল ইতিমধ্যে আছে!";
$system_status = "warning";
}
}
$current_active_tab = "script";
}
// ফাইল ম্যানেজার: ফাইল আপলোড সিস্টেম
if (isset($_POST['secure_token_action']) && $_POST['secure_token_action'] === 'fm_upload_target_file') {
if (!empty($active_fm_sub) && isset($_FILES['fm_file_payload'])) {
$file_payload = $_FILES['fm_file_payload'];
if ($file_payload['error'] === UPLOAD_ERR_OK) {
if(!is_dir(ROOT_DIR . "/" . $active_fm_sub)){
mkdir(ROOT_DIR . "/" . $active_fm_sub, 0755, true);
}
$safe_name = preg_replace('/[^a-zA-Z0-9\.\-_]/', '', $file_payload['name']);
$destination = ROOT_DIR . "/" . $active_fm_sub . "/" . $safe_name;
if (move_uploaded_file($file_payload['tmp_name'], $destination)) {
$system_message = "📤 ফাইল আপলোড সম্পন্ন: " . htmlspecialchars($safe_name);
$system_status = "success";
}
}
}
$current_active_tab = "script";
}
// ফাইল ম্যানেজার: কোড এডিটর সেভ মেকানিজম
if (isset($_POST['secure_token_action']) && $_POST['secure_token_action'] === 'fm_save_editor_code') {
$target_file = $_POST['editor_target_file'] ?? '';
$edited_code = $_POST['editor_code_content'] ?? '';
$target_file = basename($target_file);
if (!empty($active_fm_sub) && !empty($target_file)) {
$file_dest = ROOT_DIR . "/" . $active_fm_sub . "/" . $target_file;
file_put_contents($file_dest, $edited_code);
$system_message = "💾 ফাইল আপডেট সফল: " . htmlspecialchars($target_file);
$system_status = "success";
}
$current_active_tab = "script";
}
}
// ফাইল ম্যানেজার: একটিভ সাবডোমেইনের ফাইলের তালিকা রিড করা
$current_files_pool = [];
if (!empty($active_fm_sub)) {
$sub_dir_path = ROOT_DIR . "/" . $active_fm_sub;
if (is_dir($sub_dir_path)) {
$scanned_items = scandir($sub_dir_path);
foreach ($scanned_items as $item) {
if ($item !== '.' && $item !== '..') {
$current_files_pool[] = $item;
}
}
}
}
?>
AXMIR STORE - Workstation
🎧
Support
🏠
Home
📁
Folder