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 // Koneksi ke database menggunakan PDO $servername = "localhost"; $username = "ro..

Decoded Output download

<?php 
// Koneksi ke database menggunakan PDO 
$servername = "localhost"; 
$username = "root"; 
$password = "dbdev"; 
$dbname = "iac"; 
 
try { 
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); 
    // Set mode error PDO ke exception 
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
 
    if ($_POST['method'] == "saveData") { 
        // Tangkap data dari Ajax 
        $tanggal = $_POST['date']; 
        // Split the date string into an array of components 
        $dateComponents = explode('-', $tanggal); 
        $year = $dateComponents[0]; 
        // Format the month and day with leading zeros removed 
        $formattedMonth = ltrim($dateComponents[1], '0'); 
        $formattedDay = ltrim($dateComponents[2], '0'); 
 
 
        $curl = curl_init(); 
        curl_setopt_array($curl, array( 
        CURLOPT_URL => 'https://json.freeastrologyapi.com/planets', 
        CURLOPT_RETURNTRANSFER => true, 
        CURLOPT_ENCODING => '', 
        CURLOPT_MAXREDIRS => 10, 
        CURLOPT_TIMEOUT => 0, 
        CURLOPT_FOLLOWLOCATION => true, 
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, 
        CURLOPT_CUSTOMREQUEST => 'POST', 
        CURLOPT_POSTFIELDS =>'{ 
            "year": '.$year.', 
            "month": '.$formattedMonth.', 
            "date": '.$formattedDay.', 
            "hours": 19, 
            "minutes": 45, 
            "seconds": 0, 
            "latitude": -6.2146, 
            "longitude": 106.8451, 
            "timezone": 7, 
            "settings": { 
                "observation_point": "geocentric", 
                "ayanamsha": "sayana" 
            } 
        }', 
        CURLOPT_HTTPHEADER => array( 
            'Content-Type: application/json', 
            'x-api-key: pAcs1giICg8nFfk2SwjfL4hOHNVKqFJA39KrT1FJ' 
        ), 
        )); 
 
        $response = curl_exec($curl); 
 
        curl_close($curl); 
        $nRespon = json_decode($response, JSON_FORCE_OBJECT); 
        $planetary = $nRespon['output'][0]; 
        $detPlanet = ""; 
        $zodiacs = [ 
            1 => "Aries", 2 => "Taurus", 3 => "Gemini", 4 => "Cancer", 
            5 => "Leo", 6 => "Virgo", 7 => "Libra", 8 => "Scorpio", 
            9 => "Sagitarius", 10 => "Capricorn", 11 => "Aquarius", 12 => "Pisces" 
        ]; 
         
        $excludedNames = ["Ascendant", "Rahu", "Ketu", "ayanamsa", ""]; 
         
        foreach($planetary as $key => $value) { 
            $name = $value['name']; 
            $current_sign = $value['current_sign']; 
         
            if(!in_array($name, $excludedNames)) { 
                // Tentukan zodiak 
                $zodiac = $zodiacs[$current_sign] ?? ""; 
         
                // Terjemahkan nama planet 
                if($name == "Sun"){ 
                    $newName = "Matahari"; 
                } else if($name == "Moon"){ 
                    $newName = "Bulan"; 
                } else if($name == "Mercury"){ 
                    $newName = "Merkurius"; 
                } else if($name == "Neptune"){ 
                    $newName = "Neptunus"; 
                } else if($name == "Saturn"){ 
                    $newName = "Saturnus"; 
                } else { 
                    $newName = $name; 
                } 
         
                // Tambahkan informasi planet ke $detPlanet 
                $detPlanet .= $newName . " Berada di " . $zodiac . ", "; 
            } 
        } 
         
        // Hapus koma terakhir dan ganti dengan titik 
        $detPlanet = rtrim($detPlanet, ", ") . "."; 
         
        try { 
            // Pengecekan duplikasi tanggal 
            $sql = "SELECT COUNT(*) FROM dailyastro WHERE dateastro = :tanggal"; 
            $stmt = $conn->prepare($sql); 
            $stmt->bindParam(':tanggal', $tanggal); 
            $stmt->execute(); 
            $count = $stmt->fetchColumn(); 
         
            if($count > 0) { 
                // Tanggal sudah ada 
                $response = [ 
                    'status' => 'error', 
                    'message' => 'Tanggal untuk konstelasi '.date("d M Y", strtotime($tanggal)).' sudah ada di database.' 
                ]; 
            } else { 
                // SQL untuk memasukkan data ke dalam tabel dailyastro 
                $sql = "INSERT INTO dailyastro (dateastro, planetary) VALUES (:tanggal, :planetary)"; 
                $stmt = $conn->prepare($sql); 
         
                // Bind parameter ke statement 
                $stmt->bindParam(':tanggal', $tanggal); 
                $stmt->bindParam(':planetary', $detPlanet); 
         
                // Eksekusi statement 
                $stmt->execute(); 
         
                $response = [ 
                    'status' => 'success', 
                    'message' => 'Data berhasil disimpan!' 
                ]; 
            } 
        } catch (Exception $e) { 
            $response = [ 
                'status' => 'error', 
                'message' => 'Terjadi kesalahan: ' . $e->getMessage() 
            ]; 
        } 
         
        // Mengirimkan respons dalam format JSON 
        header('Content-Type: application/json'); 
        echo json_encode($response); 
 
    } else if ($_POST['method'] == "loadData") { 
        // SQL untuk mengambil data dari tabel dailyastro 
        $sql = "SELECT * FROM dailyastro ORDER BY dateastro DESC"; 
        $stmt = $conn->prepare($sql); 
        $stmt->execute(); 
 
        // Mendapatkan hasil query 
        $result = $stmt->fetchAll(PDO::FETCH_ASSOC); 
 
        // Mengirimkan hasil dalam format JSON 
        echo json_encode($result); 
    } 
} catch (PDOException $e) { 
    echo "Error: " . $e->getMessage(); 
} 
 
// Tutup koneksi 
$conn = null; 
?> 

Did this file decode correctly?

Original Code

<?php
// Koneksi ke database menggunakan PDO
$servername = "localhost";
$username = "root";
$password = "dbdev";
$dbname = "iac";

try {
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    // Set mode error PDO ke exception
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    if ($_POST['method'] == "saveData") {
        // Tangkap data dari Ajax
        $tanggal = $_POST['date'];
        // Split the date string into an array of components
        $dateComponents = explode('-', $tanggal);
        $year = $dateComponents[0];
        // Format the month and day with leading zeros removed
        $formattedMonth = ltrim($dateComponents[1], '0');
        $formattedDay = ltrim($dateComponents[2], '0');


        $curl = curl_init();
        curl_setopt_array($curl, array(
        CURLOPT_URL => 'https://json.freeastrologyapi.com/planets',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS =>'{
            "year": '.$year.',
            "month": '.$formattedMonth.',
            "date": '.$formattedDay.',
            "hours": 19,
            "minutes": 45,
            "seconds": 0,
            "latitude": -6.2146,
            "longitude": 106.8451,
            "timezone": 7,
            "settings": {
                "observation_point": "geocentric",
                "ayanamsha": "sayana"
            }
        }',
        CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json',
            'x-api-key: pAcs1giICg8nFfk2SwjfL4hOHNVKqFJA39KrT1FJ'
        ),
        ));

        $response = curl_exec($curl);

        curl_close($curl);
        $nRespon = json_decode($response, JSON_FORCE_OBJECT);
        $planetary = $nRespon['output'][0];
        $detPlanet = "";
        $zodiacs = [
            1 => "Aries", 2 => "Taurus", 3 => "Gemini", 4 => "Cancer",
            5 => "Leo", 6 => "Virgo", 7 => "Libra", 8 => "Scorpio",
            9 => "Sagitarius", 10 => "Capricorn", 11 => "Aquarius", 12 => "Pisces"
        ];
        
        $excludedNames = ["Ascendant", "Rahu", "Ketu", "ayanamsa", ""];
        
        foreach($planetary as $key => $value) {
            $name = $value['name'];
            $current_sign = $value['current_sign'];
        
            if(!in_array($name, $excludedNames)) {
                // Tentukan zodiak
                $zodiac = $zodiacs[$current_sign] ?? "";
        
                // Terjemahkan nama planet
                if($name == "Sun"){
                    $newName = "Matahari";
                } else if($name == "Moon"){
                    $newName = "Bulan";
                } else if($name == "Mercury"){
                    $newName = "Merkurius";
                } else if($name == "Neptune"){
                    $newName = "Neptunus";
                } else if($name == "Saturn"){
                    $newName = "Saturnus";
                } else {
                    $newName = $name;
                }
        
                // Tambahkan informasi planet ke $detPlanet
                $detPlanet .= $newName . " Berada di " . $zodiac . ", ";
            }
        }
        
        // Hapus koma terakhir dan ganti dengan titik
        $detPlanet = rtrim($detPlanet, ", ") . ".";
        
        try {
            // Pengecekan duplikasi tanggal
            $sql = "SELECT COUNT(*) FROM dailyastro WHERE dateastro = :tanggal";
            $stmt = $conn->prepare($sql);
            $stmt->bindParam(':tanggal', $tanggal);
            $stmt->execute();
            $count = $stmt->fetchColumn();
        
            if($count > 0) {
                // Tanggal sudah ada
                $response = [
                    'status' => 'error',
                    'message' => 'Tanggal untuk konstelasi '.date("d M Y", strtotime($tanggal)).' sudah ada di database.'
                ];
            } else {
                // SQL untuk memasukkan data ke dalam tabel dailyastro
                $sql = "INSERT INTO dailyastro (dateastro, planetary) VALUES (:tanggal, :planetary)";
                $stmt = $conn->prepare($sql);
        
                // Bind parameter ke statement
                $stmt->bindParam(':tanggal', $tanggal);
                $stmt->bindParam(':planetary', $detPlanet);
        
                // Eksekusi statement
                $stmt->execute();
        
                $response = [
                    'status' => 'success',
                    'message' => 'Data berhasil disimpan!'
                ];
            }
        } catch (Exception $e) {
            $response = [
                'status' => 'error',
                'message' => 'Terjadi kesalahan: ' . $e->getMessage()
            ];
        }
        
        // Mengirimkan respons dalam format JSON
        header('Content-Type: application/json');
        echo json_encode($response);

    } else if ($_POST['method'] == "loadData") {
        // SQL untuk mengambil data dari tabel dailyastro
        $sql = "SELECT * FROM dailyastro ORDER BY dateastro DESC";
        $stmt = $conn->prepare($sql);
        $stmt->execute();

        // Mendapatkan hasil query
        $result = $stmt->fetchAll(PDO::FETCH_ASSOC);

        // Mengirimkan hasil dalam format JSON
        echo json_encode($result);
    }
} catch (PDOException $e) {
    echo "Error: " . $e->getMessage();
}

// Tutup koneksi
$conn = null;
?>

Function Calls

None

Variables

None

Stats

MD5 8c141027df941dbdf12c2dd1a3202e9f
Eval Count 0
Decode Time 56 ms