
<?php
    include('config.php');
    $current_path = $_SERVER['REQUEST_URI'];
    $current_path = rtrim($current_path, '/');

    $base_url = $proxy_url;
    $url = $base_url . $resturant;
    $headers = getallheaders();
    $cookies = $headers['Cookie'];

   
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_TIMEOUT, 100);
    curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: " . $cookies));


    $cookie = isset($headers['Cookie']) ? $headers['Cookie'] : '';
  

    $data = curl_exec($ch);
    curl_close($ch);
$data = preg_replace('/(<head>)(.*?)(<\/head>)/s', '$1<link rel="stylesheet" href="icons.css">' . '$2' . '$3', $data);

    $data = str_replace('href="/', 'href="' . $base_url, $data);
    $data = str_replace('src="/', 'src="' . $base_url, $data);

    $head_start = strpos($data, '<head>');
    $head_end = strpos($data, '</head>');
    $head = substr($data, $head_start, $head_end - $head_start + 7);
    $head = str_replace('<head>', '', $head);
    $head = str_replace('</head>', '', $head);
    $head = preg_replace('/<meta[^>]*>/i', '', $head);
    $head = preg_replace('/<title[^>]*>.*?<\/title>/i', '', $head);
    
    $head = preg_replace('/\s+/', ' ', $head);


    $body_start = strpos($data, '<body');
    $body_end = strpos($data, '</body>');
    $body = substr($data, $body_start, $body_end - $body_start + 7);
    
    $body = preg_replace('/<body[^>]*>/i', '', $body);
    $body = str_replace('</body>', '', $body);
    if ($linkgizle == 0)
    {
    $body = str_replace('<a href="https://menum.co/"', '<a style="display:none;" href="https://menum.co/"', $body);
    }

    include('template/index.php'); 


    exit;
    

    if (strpos($current_path, $site_path) === 0) {
        $current_path = substr($current_path, strlen($site_path));
    }
    
    if ($current_path == '') {
        

    }else{
        
        $headers = getallheaders();
        $cookies = $headers['Cookie'];
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $proxy_url . $current_path);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
        curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
        curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);

        curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: " . $cookies));
        $data = curl_exec($ch);
        
        curl_close($ch);

        
        echo $data;
    }