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 function getTrainData() { $curl = curl_init(); curl_setopt_array($curl..

Decoded Output download

<?php 
function getTrainData() 
{ 
    $curl = curl_init(); 
 
    curl_setopt_array($curl, array( 
        CURLOPT_URL => 'https://enquiry.indianrail.gov.in/ntessrvc/LiveStation', 
        CURLOPT_RETURNTRANSFER => true, 
        CURLOPT_ENCODING => '', 
        CURLOPT_MAXREDIRS => 10, 
        CURLOPT_TIMEOUT => 0, 
        CURLOPT_FOLLOWLOCATION => true, 
        CURLOPT_SSL_VERIFYPEER => false, 
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, 
        CURLOPT_CUSTOMREQUEST => 'POST', 
        CURLOPT_POSTFIELDS => '{"station":"SVDK","nextMins":480}', 
        CURLOPT_HTTPHEADER => array( 
            'authToken: fc1404963e7f75a49a205b95fbbbe1bf', 
            'Content-Type: application/json', 
            'Cookie: Cookie_1=value; SERVERID=cchv7sfs230P10080; TS0109848f=01ea7166bc80f93862dd869cea185403544c8be1db92e3a811c4f9138cfc63a99f9efa7b2af4e0fbf528b2cce9d6072cd56a323cf9' 
        ), 
    )); 
 
    $response = curl_exec($curl); 
    if ($response === false) { 
        echo json_encode(["error" => "Curl error: " . curl_error($curl)]); 
        curl_close($curl); 
        exit; 
    } 
    curl_close($curl); 
 
    $response = json_decode($response, true); 
 
    if (!isset($response['vTrainList']) || !is_array($response['vTrainList'])) { 
        echo json_encode(["error" => "No train data available."]); 
        exit; 
    } 
 
    $trainData = [ 
        "ENG" => [], 
        "HiN" => [] 
    ]; 
 
    foreach ($response['vTrainList'] as $trainInfo) { 
        $trainData['ENG'][] = [ 
            "trainNo" => $trainInfo['trainNo'], 
            "trainName" => $trainInfo['trainName'], 
            "dstn" => $trainInfo['dstn'], 
            "ADFlag" => $trainInfo['ADFlag'], 
            "expectedTime" => $trainInfo['expectedTime'], 
            "expectedDelay" => $trainInfo['expectedDelay'], 
            "platformNo" => $trainInfo['platformNo'], 
            "ADStatus" => $trainInfo['ADFlag'] == 'A' ? 'Arrived' : 'Departed' 
        ]; 
 
        $trainData['HiN'][] = [ 
            "trainNo" => $trainInfo['trainNo'], 
            "trainName" => $trainInfo['trainNameHindi'] ?? $trainInfo['trainName'], 
            "dstn" => $trainInfo['dstnNameHindi'] ?? $trainInfo['dstn'], 
            "ADFlag" => $trainInfo['ADFlag'], 
            "expectedTime" => $trainInfo['expectedTime'], 
            "expectedDelay" => $trainInfo['expectedDelay'], 
            "platformNo" => $trainInfo['platformNo'], 
            "ADStatus" => $trainInfo['ADFlag'] == 'A' ? 'Arrived' : 'Departed' 
        ]; 
    } 
 
    return json_encode(["data" => $trainData]); 
} 
 
if (isset($_POST['getData'])) { 
    echo getTrainData(); 
    exit; 
} 
?> 
 
<!DOCTYPE html> 
<html lang="en"> 
 
<head> 
    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <title>Train Status</title> 
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> 
    <style> 
        th, 
        td { 
            border: 2px solid white; 
        } 
 
        .bgc { 
            background-color: rgb(162, 229, 255); 
            color: black; 
        } 
 
        table { 
            width: 100%; 
            background-color: black; 
            color: white; 
        } 
 
        .on-time { 
            color: green; 
            font-weight: bold; 
        } 
 
        .delayed { 
            color: red; 
            font-weight: bold; 
        } 
 
        .timecolor { 
            color: yellow; 
        } 
 
        .departed-color { 
            color: skyblue; 
        } 
 
        .arrived-color { 
            color: yellow; 
        } 
    </style> 
</head> 
 
<body> 
 
    <table class="text-center"> 
        <thead> 
            <tr class="bgc"> 
                <th colspan="7"> 
                    <h2>SVDK TRAIN STATUS</h2> 
                </th> 
                <th></th> 
            </tr> 
            <tr> 
                <th>Train No.</th> 
                <th>Name</th> 
                <th>Destination</th> 
                <th>A/D</th> 
                <th>Exp. Time</th> 
                <th>Delay (HH:mm)</th> 
                <th>PF</th> 
                <th>Status</th> 
            </tr> 
        </thead> 
        <tbody id="data"> 
        </tbody> 
    </table> 
 
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> 
 
    <script> 
        setInterval(getData, 1000 * 10); 
 
        getData(); 
 
        var isHin = false; 
 
        function getData() { 
            $.post("", { 
                getData: true 
            }, function(data) { 
                if (data.error) { 
                    alert(data.error); 
                    return; 
                } 
 
                var trainData = isHin ? data.data["HiN"] : data.data["ENG"]; 
 
                var tableContent = ''; 
                trainData.forEach(function(train) { 
                    var adClass = (train.ADFlag === 'A') ? 'arrived-color' : 'departed-color'; 
                    var delayClass = (train.expectedDelay === 'On Time') ? 'on-time' : 'delayed'; 
 
                    tableContent += `<tr class="trainRow"> 
                        <td class="${delayClass}">${train.trainNo}</td> 
                        <td class="${delayClass}">${train.trainName}</td> 
                        <td class="${delayClass}">${train.dstn}</td> 
                        <td class="${delayClass}">${train.ADFlag}</td> 
                        <td class="timecolor">${train.expectedTime}</td> 
                        <td class="${delayClass}">${train.expectedDelay}</td> 
                        <td class="${delayClass}">${train.platformNo}</td> 
                        <td class="${adClass}">${train.ADStatus}</td> 
                    </tr>`; 
                }); 
 
                $("#data").html(tableContent); 
 
                isHin = !isHin; 
            }, 'json'); 
        } 
    </script> 
 
</body> 
 
</html>

Did this file decode correctly?

Original Code

<?php
function getTrainData()
{
    $curl = curl_init();

    curl_setopt_array($curl, array(
        CURLOPT_URL => 'https://enquiry.indianrail.gov.in/ntessrvc/LiveStation',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => '{"station":"SVDK","nextMins":480}',
        CURLOPT_HTTPHEADER => array(
            'authToken: fc1404963e7f75a49a205b95fbbbe1bf',
            'Content-Type: application/json',
            'Cookie: Cookie_1=value; SERVERID=cchv7sfs230P10080; TS0109848f=01ea7166bc80f93862dd869cea185403544c8be1db92e3a811c4f9138cfc63a99f9efa7b2af4e0fbf528b2cce9d6072cd56a323cf9'
        ),
    ));

    $response = curl_exec($curl);
    if ($response === false) {
        echo json_encode(["error" => "Curl error: " . curl_error($curl)]);
        curl_close($curl);
        exit;
    }
    curl_close($curl);

    $response = json_decode($response, true);

    if (!isset($response['vTrainList']) || !is_array($response['vTrainList'])) {
        echo json_encode(["error" => "No train data available."]);
        exit;
    }

    $trainData = [
        "ENG" => [],
        "HiN" => []
    ];

    foreach ($response['vTrainList'] as $trainInfo) {
        $trainData['ENG'][] = [
            "trainNo" => $trainInfo['trainNo'],
            "trainName" => $trainInfo['trainName'],
            "dstn" => $trainInfo['dstn'],
            "ADFlag" => $trainInfo['ADFlag'],
            "expectedTime" => $trainInfo['expectedTime'],
            "expectedDelay" => $trainInfo['expectedDelay'],
            "platformNo" => $trainInfo['platformNo'],
            "ADStatus" => $trainInfo['ADFlag'] == 'A' ? 'Arrived' : 'Departed'
        ];

        $trainData['HiN'][] = [
            "trainNo" => $trainInfo['trainNo'],
            "trainName" => $trainInfo['trainNameHindi'] ?? $trainInfo['trainName'],
            "dstn" => $trainInfo['dstnNameHindi'] ?? $trainInfo['dstn'],
            "ADFlag" => $trainInfo['ADFlag'],
            "expectedTime" => $trainInfo['expectedTime'],
            "expectedDelay" => $trainInfo['expectedDelay'],
            "platformNo" => $trainInfo['platformNo'],
            "ADStatus" => $trainInfo['ADFlag'] == 'A' ? 'Arrived' : 'Departed'
        ];
    }

    return json_encode(["data" => $trainData]);
}

if (isset($_POST['getData'])) {
    echo getTrainData();
    exit;
}
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Train Status</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <style>
        th,
        td {
            border: 2px solid white;
        }

        .bgc {
            background-color: rgb(162, 229, 255);
            color: black;
        }

        table {
            width: 100%;
            background-color: black;
            color: white;
        }

        .on-time {
            color: green;
            font-weight: bold;
        }

        .delayed {
            color: red;
            font-weight: bold;
        }

        .timecolor {
            color: yellow;
        }

        .departed-color {
            color: skyblue;
        }

        .arrived-color {
            color: yellow;
        }
    </style>
</head>

<body>

    <table class="text-center">
        <thead>
            <tr class="bgc">
                <th colspan="7">
                    <h2>SVDK TRAIN STATUS</h2>
                </th>
                <th></th>
            </tr>
            <tr>
                <th>Train No.</th>
                <th>Name</th>
                <th>Destination</th>
                <th>A/D</th>
                <th>Exp. Time</th>
                <th>Delay (HH:mm)</th>
                <th>PF</th>
                <th>Status</th>
            </tr>
        </thead>
        <tbody id="data">
        </tbody>
    </table>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

    <script>
        setInterval(getData, 1000 * 10);

        getData();

        var isHin = false;

        function getData() {
            $.post("", {
                getData: true
            }, function(data) {
                if (data.error) {
                    alert(data.error);
                    return;
                }

                var trainData = isHin ? data.data["HiN"] : data.data["ENG"];

                var tableContent = '';
                trainData.forEach(function(train) {
                    var adClass = (train.ADFlag === 'A') ? 'arrived-color' : 'departed-color';
                    var delayClass = (train.expectedDelay === 'On Time') ? 'on-time' : 'delayed';

                    tableContent += `<tr class="trainRow">
                        <td class="${delayClass}">${train.trainNo}</td>
                        <td class="${delayClass}">${train.trainName}</td>
                        <td class="${delayClass}">${train.dstn}</td>
                        <td class="${delayClass}">${train.ADFlag}</td>
                        <td class="timecolor">${train.expectedTime}</td>
                        <td class="${delayClass}">${train.expectedDelay}</td>
                        <td class="${delayClass}">${train.platformNo}</td>
                        <td class="${adClass}">${train.ADStatus}</td>
                    </tr>`;
                });

                $("#data").html(tableContent);

                isHin = !isHin;
            }, 'json');
        }
    </script>

</body>

</html>

Function Calls

None

Variables

None

Stats

MD5 b9246cd561bb0390cf61c2b4245327c0
Eval Count 0
Decode Time 63 ms