Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php // Check if the search parameter is provided in the URL if(isset($_GET['search']) ..

Decoded Output download

<?php 
// Check if the search parameter is provided in the URL 
if(isset($_GET['search']) && !empty($_GET['search'])) { 
    // URL of the webpage to scrape 
    $url = 'https://simdatapakistan.com/search-result.php'; 
 
    // Data to be sent via POST request 
    $data = array( 
        'num' => $_GET['search'] // Use the search parameter from the URL 
    ); 
 
    // Initialize cURL session 
    $curl = curl_init(); 
 
    // Set the cURL options 
    curl_setopt_array($curl, array( 
        CURLOPT_URL => $url, 
        CURLOPT_RETURNTRANSFER => true, 
        CURLOPT_POST => true, 
        CURLOPT_POSTFIELDS => http_build_query($data), 
        CURLOPT_SSL_VERIFYPEER => false // You may remove this line in production 
    )); 
 
    // Execute the cURL request 
    $response = curl_exec($curl); 
 
    // Close cURL session 
    curl_close($curl); 
 
    // Create a new DOMDocument object 
    $dom = new DOMDocument(); 
 
    // Load HTML from the response 
    $dom->loadHTML($response); 
 
    // Create a new DOMXPath object 
    $xpath = new DOMXPath($dom); 
 
    // Find all div elements with class "card-body" 
    $cardBodies = $xpath->query('//div[@class="card-body"]'); 
 
    // Initialize array to store all records 
    $allRecords = array(); 
 
    // Loop through each card-body 
    foreach ($cardBodies as $cardBody) { 
        // Find all tables within the current card-body 
        $tables = $xpath->query('.//table[@class="tg"]', $cardBody); 
 
        // Initialize array to store records for this card-body 
        $records = array(); 
 
        // Loop through each table within the card-body 
        foreach ($tables as $table) { 
            // Initialize array to store data for this table 
            $tableData = array(); 
 
            // Find all rows within the table 
            $rows = $table->getElementsByTagName('tr'); 
 
            // Loop through each row 
            foreach ($rows as $row) { 
                // Initialize array to store cell data for this row 
                $rowData = array(); 
 
                // Find all cells within the row 
                $cells = $row->getElementsByTagName('td'); 
 
                // Loop through each cell 
                foreach ($cells as $cell) { 
                    // Get cell content and remove any HTML tags 
                    $cellContent = trim(strip_tags($cell->nodeValue)); 
 
                    // Add cell content to row data 
                    $rowData[] = $cellContent; 
                } 
 
                // Add row data to table data 
                $tableData[] = $rowData; 
            } 
 
            // Add table data to records for this card-body 
            $records[] = $tableData; 
        } 
 
        // Add records for this card-body to all records 
        $allRecords[] = $records; 
    } 
 
    // Check if any records were found 
    if (!empty($allRecords)) { 
        // Convert all records to JSON 
        $jsonOutput = json_encode($allRecords); 
 
        // Output JSON 
        echo $jsonOutput; 
    } else { 
        // No data found message 
        echo "No data found"; 
    } 
} else { 
    // No search parameter provided message 
    echo "No search parameter provided"; 
} 
?> 

Did this file decode correctly?

Original Code

<?php
// Check if the search parameter is provided in the URL
if(isset($_GET['search']) && !empty($_GET['search'])) {
    // URL of the webpage to scrape
    $url = 'https://simdatapakistan.com/search-result.php';

    // Data to be sent via POST request
    $data = array(
        'num' => $_GET['search'] // Use the search parameter from the URL
    );

    // Initialize cURL session
    $curl = curl_init();

    // Set the cURL options
    curl_setopt_array($curl, array(
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => http_build_query($data),
        CURLOPT_SSL_VERIFYPEER => false // You may remove this line in production
    ));

    // Execute the cURL request
    $response = curl_exec($curl);

    // Close cURL session
    curl_close($curl);

    // Create a new DOMDocument object
    $dom = new DOMDocument();

    // Load HTML from the response
    $dom->loadHTML($response);

    // Create a new DOMXPath object
    $xpath = new DOMXPath($dom);

    // Find all div elements with class "card-body"
    $cardBodies = $xpath->query('//div[@class="card-body"]');

    // Initialize array to store all records
    $allRecords = array();

    // Loop through each card-body
    foreach ($cardBodies as $cardBody) {
        // Find all tables within the current card-body
        $tables = $xpath->query('.//table[@class="tg"]', $cardBody);

        // Initialize array to store records for this card-body
        $records = array();

        // Loop through each table within the card-body
        foreach ($tables as $table) {
            // Initialize array to store data for this table
            $tableData = array();

            // Find all rows within the table
            $rows = $table->getElementsByTagName('tr');

            // Loop through each row
            foreach ($rows as $row) {
                // Initialize array to store cell data for this row
                $rowData = array();

                // Find all cells within the row
                $cells = $row->getElementsByTagName('td');

                // Loop through each cell
                foreach ($cells as $cell) {
                    // Get cell content and remove any HTML tags
                    $cellContent = trim(strip_tags($cell->nodeValue));

                    // Add cell content to row data
                    $rowData[] = $cellContent;
                }

                // Add row data to table data
                $tableData[] = $rowData;
            }

            // Add table data to records for this card-body
            $records[] = $tableData;
        }

        // Add records for this card-body to all records
        $allRecords[] = $records;
    }

    // Check if any records were found
    if (!empty($allRecords)) {
        // Convert all records to JSON
        $jsonOutput = json_encode($allRecords);

        // Output JSON
        echo $jsonOutput;
    } else {
        // No data found message
        echo "No data found";
    }
} else {
    // No search parameter provided message
    echo "No search parameter provided";
}
?>

Function Calls

None

Variables

None

Stats

MD5 fe6fd103f9ad2b4b5e4a883794fcf9e1
Eval Count 0
Decode Time 52 ms