PHP-യിലെ ഒരു വെബ് പ്രോക്‌സി/അജ്ഞാതമാക്കലിൻ്റെ അടിസ്ഥാന നിർവ്വഹണം ചുവടെ:

<?php

// Function to fetch the content from the target URL and return it
function fetchURL($url, $headers, $method, $data = null) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    
    // Set method and data for POST requests
    if ($method === 'POST') {
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    }
    
    $response = curl_exec($ch);
    curl_close($ch);
    return $response;
}

// Check if URL parameter is provided
if (isset($_GET['url'])) {
    $url = $_GET['url'];

    // Forward request headers
    $headers = getallheaders();
    
    // Forward request method
    $method = $_SERVER['REQUEST_METHOD'];

    // Forward request data for POST requests
    $data = null;
    if ($method === 'POST') {
        $data = file_get_contents('php://input');
    }

    // Fetch content from the target URL
    $targetResponse = fetchURL($url, $headers, $method, $data);

    // Extract response headers and content
    list($targetHeaders, $targetContent) = explode("\r\n\r\n", $targetResponse, 2);

    // Forward response headers to the client
    $headerLines = explode("\r\n", $targetHeaders);
    foreach ($headerLines as $header) {
        header($header);
    }

    // Output the content to the client
    echo $targetContent;
} else {
    // URL parameter is missing
    http_response_code(400);
    echo "Missing URL parameter";
}

?>

ഈ PHP സ്ക്രിപ്റ്റ് ഒരു അടിസ്ഥാന വെബ് പ്രോക്സി/അജ്ഞാതമാക്കൽ ആയി പ്രവർത്തിക്കുന്നു. ഇത് അഭ്യർത്ഥനകൾ ശ്രദ്ധിക്കുകയും നിർദ്ദിഷ്ട URL-ലേക്ക് കൈമാറുകയും ചെയ്യുന്നു. അഭ്യർത്ഥിച്ച URL ഒരു ചോദ്യ പാരാമീറ്ററായി നൽകണം url.

ഈ പ്രോക്സി ഉപയോഗിക്കുന്നതിന്, നിങ്ങളുടെ സെർവറിൽ സ്‌ക്രിപ്റ്റ് സംരക്ഷിച്ച് ബ്രൗസർ വഴി ആക്‌സസ് ചെയ്യുക അല്ലെങ്കിൽ പ്രോഗ്രമാറ്റിക്കായി HTTP അഭ്യർത്ഥനകൾ അയയ്‌ക്കുക. ഉദാഹരണത്തിന്:

GET http://example.com/proxy.php?url=https://example.com

ഇതിൽ നിന്ന് ഉള്ളടക്കം വീണ്ടെടുക്കും https://example.com പ്രോക്സി വഴി. ഇതൊരു ലളിതമായ നടപ്പാക്കലാണെന്നും എല്ലാത്തരം അഭ്യർത്ഥനകളും പ്രതികരണങ്ങളും കൈകാര്യം ചെയ്യണമെന്നില്ലെന്നും ശ്രദ്ധിക്കുക. കൂടാതെ, കാഷിംഗ് അല്ലെങ്കിൽ അജ്ഞാതമാക്കൽ പോലുള്ള സവിശേഷതകൾ ഇതിൽ ഉൾപ്പെടുന്നില്ല.

നിങ്ങൾക്ക് PHP പ്രോക്സി സ്ക്രിപ്റ്റിലേക്ക് അടിസ്ഥാന കാഷിംഗ്, അജ്ഞാതമാക്കൽ സവിശേഷതകൾ ചേർക്കാൻ കഴിയും. പുതുക്കിയ പതിപ്പ് ഇതാ:

<?php

// Function to fetch the content from the target URL and return it
function fetchURL($url, $headers, $method, $data = null) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    
    // Set method and data for POST requests
    if ($method === 'POST') {
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    }
    
    $response = curl_exec($ch);
    curl_close($ch);
    return $response;
}

// Function to cache response content
function cacheContent($url, $content) {
    // Implement caching logic here
    // For simplicity, you can use file-based caching
    $cacheFileName = md5($url) . '.cache';
    file_put_contents($cacheFileName, $content);
}

// Function to retrieve cached content
function getCachedContent($url) {
    // Implement caching logic here
    $cacheFileName = md5($url) . '.cache';
    if (file_exists($cacheFileName)) {
        return file_get_contents($cacheFileName);
    }
    return null;
}

// Check if URL parameter is provided
if (isset($_GET['url'])) {
    $url = $_GET['url'];

    // Check if content is cached
    $cachedContent = getCachedContent($url);
    if ($cachedContent !== null) {
        // Output cached content
        echo $cachedContent;
        exit();
    }

    // Forward request headers
    $headers = getallheaders();
    
    // Forward request method
    $method = $_SERVER['REQUEST_METHOD'];

    // Forward request data for POST requests
    $data = null;
    if ($method === 'POST') {
        $data = file_get_contents('php://input');
    }

    // Fetch content from the target URL
    $targetResponse = fetchURL($url, $headers, $method, $data);

    // Extract response headers and content
    list($targetHeaders, $targetContent) = explode("\r\n\r\n", $targetResponse, 2);

    // Forward response headers to the client
    $headerLines = explode("\r\n", $targetHeaders);
    foreach ($headerLines as $header) {
        header($header);
    }

    // Output the content to the client
    echo $targetContent;

    // Cache the response content
    cacheContent($url, $targetContent);
} else {
    // URL parameter is missing
    http_response_code(400);
    echo "Missing URL parameter";
}

?>

ഈ അപ്‌ഡേറ്റ് ചെയ്ത പതിപ്പിൽ, ഫയൽ അടിസ്ഥാനമാക്കിയുള്ള കാഷിംഗ് ഉപയോഗിച്ച് ഞാൻ അടിസ്ഥാന കാഷിംഗ് പ്രവർത്തനം ചേർത്തിട്ടുണ്ട്. കാഷെ ചെയ്ത പ്രതികരണങ്ങൾ URL-ൻ്റെ MD5 ഹാഷിൻ്റെ പേരിലുള്ള ഫയലുകളിൽ സംഭരിച്ചിരിക്കുന്നു. കൂടാതെ, ടാർഗെറ്റ് URL-ൽ നിന്ന് കാഷെ ചെയ്‌ത ഉള്ളടക്കം ലഭ്യമാക്കുന്നതിന് മുമ്പ് സ്‌ക്രിപ്റ്റ് പരിശോധിക്കുന്നു, കൂടാതെ ഉള്ളടക്കം കാഷെയിൽ കണ്ടെത്തിയാൽ, അത് നേരിട്ട് ക്ലയൻ്റിലേക്ക് നൽകും.

നിങ്ങളുടെ സൗജന്യ ട്രയൽ പ്രോക്സി ഇപ്പോൾ നേടൂ!

സമീപകാല പോസ്റ്റുകൾ

അഭിപ്രായങ്ങൾ (0)

ഇവിടെ ഇതുവരെ അഭിപ്രായങ്ങളൊന്നുമില്ല, നിങ്ങൾക്ക് ആദ്യത്തെയാളാകാം!

മറുപടി രേഖപ്പെടുത്തുക

താങ്കളുടെ ഇമെയില്‍ വിലാസം പ്രസിദ്ധപ്പെടുത്തുകയില്ല. അവശ്യമായ ഫീല്‍ഡുകള്‍ * ആയി രേഖപ്പെടുത്തിയിരിക്കുന്നു


പ്രോക്സി തിരഞ്ഞെടുത്ത് വാങ്ങുക

ഡാറ്റാസെന്റർ പ്രോക്സികൾ

ഭ്രമണം ചെയ്യുന്ന പ്രോക്സികൾ

UDP പ്രോക്സികൾ

ലോകമെമ്പാടുമുള്ള 10000+ ഉപഭോക്താക്കൾ വിശ്വസിച്ചു

പ്രോക്സി കസ്റ്റമർ
പ്രോക്സി കസ്റ്റമർ
പ്രോക്സി ഉപഭോക്താവ് flowch.ai
പ്രോക്സി കസ്റ്റമർ
പ്രോക്സി കസ്റ്റമർ
പ്രോക്സി കസ്റ്റമർ