$whmcs_identifier,
‘secret’ => $whmcs_secret,
‘responsetype’ => ‘json’
], $params);
$max_attempts = 3;
$backoff = 1;
for ($attempt = 1; $attempt <= $max_attempts; $attempt++) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $whmcs_api_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
curl_close($ch);
if ($curl_errno) {
file_put_contents($logfile, date('c') . " - cURL error ($attempt): $curl_error\n", FILE_APPEND);
if ($attempt < $max_attempts) { sleep($backoff); $backoff *= 2; continue; }
}
if (empty($response)) {
if ($attempt < $max_attempts) { sleep($backoff); $backoff *= 2; continue; }
}
$json = json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE) {
if ($attempt < $max_attempts) { sleep($backoff); $backoff *= 2; continue; }
}
if (isset($json['result']) && $json['result'] === 'success') {
return $json;
} else {
if ($http_code == 429 || $http_code >= 500) {
if ($attempt < $max_attempts) { sleep($backoff); $backoff *= 2; continue; }
}
return $json;
}
}
return ['result' => ‘error’, ‘message’ => ‘Eroare necunoscuta dupa retry-uri multiple’];
}
}
function wp_whmcs_generate_iptv_pass($length = 8){
return substr(str_shuffle(‘0123456789’), 0, (int)$length);
}
// —————————–
// Procesare formular
// —————————–
if ($_SERVER[‘REQUEST_METHOD’] === ‘POST’) {
// PASUL 1: date + aplicatie (fără otp_code)
if (isset($_POST[‘nume’], $_POST[‘telefon’], $_POST[’email’], $_POST[‘macadress’], $_POST[‘aplicatie’]) && !isset($_POST[‘otp_code’])) {
$nume = sanitize_text_field($_POST[‘nume’]);
$telefon = preg_replace(‘/\D+/’, ”, $_POST[‘telefon’]);
$email = sanitize_email($_POST[’email’]);
$password = wp_whmcs_generate_iptv_pass();
$macadress = sanitize_text_field($_POST[‘macadress’]);
$aplicatie = sanitize_text_field($_POST[‘aplicatie’]);
if (empty($nume) || empty($telefon) || empty($email) || empty($aplicatie)) {
$message = ‘
‘;
} elseif (!validate_fullname($nume)) {
$message = ‘
‘;
} elseif (email_exists($email)) {
$message = ‘
‘;
} else {
// toate aplicațiile afișate necesită MAC
$needs_mac = in_array($aplicatie, [‘SMART IPTV’,’NETIPTV’,’MEGAIPTV’,’IBO PLAYER IPTV’,’HOTPLAYER’,’SETIPTV’]);
if ($needs_mac && empty($macadress)) {
$message = ‘
‘;
$show_otp_form = false;
} else {
$otp = rand(100000, 999999);
$transient_data = [
‘nume’ => $nume,
‘telefon’ => $telefon,
’email’ => $email,
‘password’ => $password,
‘macadress’ => $macadress,
‘aplicatie’ => $aplicatie,
‘otp’ => (string)$otp,
‘otp_time’ => time()
];
set_transient($session_key, $transient_data, 5 * MINUTE_IN_SECONDS);
$payload = [
‘instance_id’ => $GLOBALS[‘instance_id’],
‘access_token’ => $GLOBALS[‘access_token’],
‘chatId’ => $telefon . ‘@c.us’,
‘message’ => “Codul tău OTP: $otp (valabil 5 minute)”
];
$resp = wp_remote_post(‘https://wawp.net/wp-json/awp/v1/send’, [
‘headers’ => [‘Content-Type’ => ‘application/json’],
‘body’ => wp_json_encode($payload),
‘timeout’ => 20
]);
if (is_wp_error($resp)) {
error_log(“WhatsApp API error: ” . $resp->get_error_message());
$message = ‘
‘;
} else {
$message = ‘
‘;
}
$show_otp_form = true; // pentru POP-UP OTP
}
}
}
// PASUL 2: verificare OTP (în modal)
if (isset($_POST[‘otp_code’])) {
$otp_code = sanitize_text_field($_POST[‘otp_code’]);
$data = get_transient($session_key);
if (!$data) {
$message = ‘
‘;
} elseif (time() – ($data[‘otp_time’] ?? 0) > 300) {
delete_transient($session_key);
$message = ‘
‘;
} elseif ($otp_code !== ($data[‘otp’] ?? ”)) {
$message = ‘
‘;
$show_otp_form = true;
} else {
$nume = $data[‘nume’];
$telefon = $data[‘telefon’];
$email = $data[’email’];
$password = $data[‘password’];
$macadress = $data[‘macadress’];
$aplicatie = $data[‘aplicatie’];
$parts = preg_split(‘/\s+/’, $nume);
$username = generate_username_from_name($nume);
$iptv_pass = $password;
$customfields_array = [
458 => strtoupper($aplicatie),
398 => $macadress,
427 => $username,
428 => $iptv_pass,
391 => date(‘d-m-Y’),
392 => date(‘d-m-Y’, strtotime(‘+24 hours’)),
394 => ‘TEST 24 ORE GRATIS ( Max 1 Conexiune )’,
395 => ‘1’,
396 => ‘0 EURO’
];
if (email_exists($email)) {
$message = ‘
‘;
$show_otp_form = true;
} else {
$user_id = wp_insert_user([
‘user_login’ => $username,
‘user_pass’ => $password,
‘user_email’ => $email,
‘first_name’ => $parts[0] ?? ”,
‘last_name’ => $parts[1] ?? ”,
‘display_name’ => $nume,
‘role’ => ‘abonat’
]);
if (!is_wp_error($user_id)) {
update_user_meta($user_id, ‘billing_phone’, $telefon);
update_user_meta($user_id, ‘macadress’, $macadress);
update_user_meta($user_id, ‘aplicatie’, $aplicatie);
update_user_meta($user_id, ‘iptv_username’, $username);
update_user_meta($user_id, ‘iptv_password’, $iptv_pass);
foreach ($customfields_array as $k => $v) {
update_user_meta($user_id, ‘whmcs_cf_’ . $k, $v);
}
$whmcs = wp_whmcs_api([
‘action’ => ‘AddClient’,
‘firstname’ => $parts[0] ?? ”,
‘lastname’ => $parts[1] ?? ”,
’email’ => $email,
‘password2’ => $password,
‘address1’ => ‘N/A’,
‘city’ => ‘N/A’,
‘state’ => ‘N/A’,
‘postcode’ => ‘0000’,
‘country’ => ‘RO’,
‘phonenumber’ => $telefon,
‘customfields’=> base64_encode(serialize($customfields_array))
]);
if ($whmcs && isset($whmcs[‘result’]) && $whmcs[‘result’] === ‘success’) {
$client_id = $whmcs[‘clientid’];
update_user_meta($user_id, ‘whmcs_client_id’, $client_id);
$order = wp_whmcs_api([
‘action’ => ‘AddOrder’,
‘clientid’ => $client_id,
‘pid’ => ’48’,
‘billingcycle’ => ‘monthly’,
‘paymentmethod’=> ‘banktransfer’,
‘customfields’ => base64_encode(serialize($customfields_array)),
‘noinvoice’ => true,
‘status’ => ‘Pending’
]);
}
$user_info = get_user_by(‘id’, $user_id);
if ($user_info) {
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id, true);
do_action(‘wp_login’, $user_info->user_login, $user_info);
delete_transient($session_key);
wp_safe_redirect(home_url(‘/my-account’));
exit;
}
}
}
}
}
}
get_header();
?>
Pasul 1: Informații cont
Sumar Test Gratuit
0,00 €
Cum Funcționează?
Durează mai puțin de 60 de secunde.
Un email automat este trimis instant.
Primești datele de acces în max. 24 ore.
Ce Spun Clienții Noștri
‘”Bună ziua, merge și EPG pentru programe. Mulțumesc!”‘, “author” => “- Dan”],
[“text” => ‘”Sunt la voi de ani buni, nu am ce să reproșez. TOP!”‘, “author” => “- Bebe”],
[“text” => ‘”Super calitate, recomand cu încredere!”‘, “author” => “- Marian”],
[“text” => ‘”Merge perfect, suport rapid. Mulțumesc!”‘, “author” => “- Elena”],
[“text” => ‘”Cel mai bun IPTV încercat până acum.”‘, “author” => “- Robert”],
[“text” => ‘”Foarte mulțumit, filme și sport impecabil!”‘, “author” => “- Andrei”],
[“text” => ‘”Instalare rapidă, totul simplu și clar.”‘, “author” => “- Ciprian”],
[“text” => ‘”Funcționează excelent și în străinătate.”‘, “author” => “- Aftode”],
[“text” => ‘”Recomand, stabil și calitate foarte bună.”‘, “author” => “- Sorin”],
[“text” => ‘”Suport răspunde imediat, 10/10.”‘, “author” => “- Luca”],
];
// amestecă și ia doar 2
shuffle($testimonials);
$selected = array_slice($testimonials, 0, 2);
foreach($selected as $t): ?>
Siguranță & suport
- ✓ Test 100% gratuit, fără obligații
- ✓ Datele Tale Sunt în Siguranță
- ✓ Suport prin WhatsApp & email
Confirmare cod OTP
Am trimis un cod prin WhatsApp. Introdu codul mai jos pentru a finaliza crearea contului.