<?php
$pasaran = 'HK';
setlocale(LC_TIME, 'id_ID.UTF-8'); 
$host = 'localhost';
$db = 'u822461919_live_draw'; // Ganti dengan nama database Anda
$user = 'u822461919_live_draw'; // Ganti dengan username database Anda
$pass = 'Kelentit123@'; // Ganti dengan password database Anda

$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");



$result = $conn->query("SELECT draw_date FROM live_chn WHERE id = 1");
if ($row = $result->fetch_assoc()) {
    $draw_date = $row['draw_date'];
}

// Fungsi untuk mengubah tanggal ke dalam format bahasa Indonesia
function formatTanggalIndonesia($date) {
    $hari = array("Sunday" => "Minggu", "Monday" => "Senin", "Tuesday" => "Selasa", "Wednesday" => "Rabu", "Thursday" => "Kamis", "Friday" => "Jumat", "Saturday" => "Sabtu");
    $bulan = array("January" => "Januari", "February" => "Februari", "March" => "Maret", "April" => "April", "May" => "Mei", "June" => "Juni", "July" => "Juli", "August" => "Agustus", "September" => "September", "October" => "Oktober", "November" => "November", "December" => "Desember");
    
    $day = date("l", strtotime($date));
    $month = date("F", strtotime($date));
    $formatted_date = date("d", strtotime($date));
    $year = date("Y", strtotime($date));

    // Mengganti nama hari dan bulan ke bahasa Indonesia
    $day_in_indonesia = $hari[$day];
    $month_in_indonesia = $bulan[$month];
    
    // Mengembalikan tanggal dalam format bahasa Indonesia
    return $day_in_indonesia . ", " . $formatted_date . " " . $month_in_indonesia . " " . $year;
}

// Ambil data dari database
// Ambil data dari database
$result = $conn->query("SELECT prize_type, number, draw_date FROM live_chn");
$numbers = [];

while ($row = $result->fetch_assoc()) {
    $numbers[$row['prize_type']][] = $row['number']; // Simpan nomor dalam array berdasarkan jenis hadiah
}
$sql = "UPDATE live_chn SET draw_date = ? WHERE id = 1"; 
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $draw_date);


// Tutup koneksi
$conn->close();
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Live Draw Results</title>
</head>
<Style>
div {
	box-sizing: border-box;
	
}


body {
    background: transparent; 
    font-family: 'Oswald', sans-serif;
}

a {
  color: white;
  text-decoration: none;
}

.space {
	width: 100%;
	height: 150px;
}

.container2 {
	width: 60%;
	margin: auto;
		
}

.banner-float {
	position: fixed;
	width: 100%;
	text-align: center;
	bottom: 0px;
	z-index: 9999;
}

.banner-float img {
	width: 728px;
	
}

.banner1 img {
	display: inline-block;
	width: 49%;
}

.floating-top {
	background: transfarant; top: 0; height: auto; left: 0; padding: 0px; position: fixed; text-align: center; width: 100%; z-index: 1001;
}
.floating-bottom {
	background: transfarant; bottom: 0; height: auto; left: 0; padding: 0px; position: fixed; text-align: center; width: 100%; z-index: 1001;
}

.floating-top img {
	width: 49%;
}
.floating-bottom img {
	width: 49%;
}
.headerbanner{
text-align:center;
}
.headerbanner img {
	width:49%;
}

.banner-top img {
	width: 728px;
	
}

.headd {
	background: linear-gradient(135deg, #000b9a 0%, #030af5 50%, #000c9a 51%, #18009a 100%); !important;
  	color: white;
}

.head {
	width: 100%;
	padding: 20px;
	background: #fff;
	border: 1px solid #ee0202;
	
}

.logo {
  display: block;
  width: 500px;
  height: 180px;
  background: url("") center no-repeat;
  background-size: 100% 100%;
  margin: auto;
}

.menu {
	display: block;
	width: 100%;
	text-align: center;
    background: linear-gradient(135deg, #b91299, #c90000 50%, #9a0000 51%, #ffc300 100%);
}
    
.menu a {
	display: inline-block;
	padding: 10px 20px;
	text-decoration: none;
	color: white;
	margin: 0px;
	font-size: 18px;
}

.menu a:hover {
	color: black;
}

.content {
	width: 100%;
	border: 1px solid #ee0202;
}

h1, h2, h3 {
	text-align: center;
	
}

h3 {
	font-family: arial;
	margin: 40px 0px;
	color: black;
	font-size: 28px;
}

.title-head {
	font-size: 24px;
	text-decoration: none;
	color: black;
	
}

.title-footer {
	font-size: 28px;
	text-decoration: none;
	color: black;
}

.content p {
	text-align: left;
	font-size: 16px;
	color: #000;
	margin: 10px;
}

.iklan {
	width: 100%;
	
}

.iklan img {
	width: 100%;
	
	
}


.t1 {
	width: 40%;
	padding: 5px 0px 5px 10px;
	border: 1px solid #989898;
	background: white;
	font-size: 16px;
}

.t2 {
	width: 30%;
	padding: 5px 0px 5px 10px;
	border: 1px solid #989898;
	background: white;
	font-size: 16px;
}

.t3 {
	width: 30%;
	padding: 5px 0px 5px 10px;
	border: 1px solid #989898;
	background: white;
	font-size: 16px;
}

.lassres {
	width: 70%;
	margin: auto;
	box-sizing: border-box;
}

.lassres table {
	width: 100%;
	border: 1px solid #e8e4e7;	
}

.lassres img{
	max-width: 100%;
	height: auto;
	padding: 1px 0 0 0;
	
}

.out-link {
	list-style-type: square;
	margin:  0px 35px;
	color: white;
}

.out-link a {
	text-decoration: none;
	color: white;
}


a:hover {
    color: #ffffff;
}



@media only screen and (max-device-width: 1000px) {
	
  .floating-top img {
width:100%
}
.floating-bottom img {
width:100%
}
  .headerbanner img{
  width:100%;
  }
  .container2 {
		width: 100%;
		
		
	}
	
	.logo {
	width: 280px;	
	height: 80px;
	margin: auto;
	}
	
	.menu a {
		display: block;
		font-size: 16px;
		border: 1px solid white;
	}
	
	.banner1 {
		display: block;
		
	}
	
	.banner1 img {
		display: block;
		width: 100%;
	}
	
	.lassres {
	width: 100%;
	margin: auto;
	
    }

    .lassres tableresult {
	width: 100%;
	padding: 0 0 0 0;
	border: 1px solid white;	
    }

    .lassres img {
    width: 100%;
    height: auto;
    padding: 1px 0 0 0;
    }
	
	
	.banner2 {
		display: block;
		
	}
	
	.banner2 img {
		display: block;
		width: 100%;
	}
	
	.banner {
	width: 100%;
	box-sizing: border-box;
	text-align: center;
	background: #3a3a3a;
}

.banner img {
	display: inline-block;
	width: 48%;
	box-sizing: border-box;
	margin: 5px;
}
.banner-float {
	position: fixed;
	width: 100%;
	text-align: center;
	bottom: 1px;
	z-index: 9999;
}

.banner-float img {
	width: 728px;
	
}
  
	h3 {
		font-size: 14px;
		
	}
	
	.title-footer {
		font-size: 14px;
		
	}
	
	.banner-float {
		width: 100%;
		
	}

	.banner-top {
		width: 100%;
		
	}
	
	.banner-float img {
		width: 100%;
		
	}

	.banner-top img {
		width: 100%;
		
	}
	

}
@media only screen and (max-device-width: 550px) {
	.logo {
	width: 240px;
    margin: auto;        
	} 
  .banner1 img {
		display: inline-block;
		width: 100%;
	}
}  
.banner1 {
		display: block;
		text-align:center;
	}
	
.banner img {
		display: block;
		width: 100%;
		margin: 0px;
	}
	.banner-float {
		width: 100%;
		
	}
	
	.banner-float img {
		width: 100%;
		
	}
.othernum {
  width:50%;
  height:40px;
  text-align:center;
  background:#fff;
  font-size:18px;
  vertical-align:middle;
  border:1px solid #989898
}


</Style>
<body>

<body onload=refresh()>
    <div class="entry-ld-container">
        <table class="entry-ld-table">
            <thead class="china">
                <tr>
                    <th colspan="4" class="entry-ld-title fz-20"><a href="" style="color: #FFF;">Live Draw China Pools, <?php echo formatTanggalIndonesia($draw_date); ?></a>                 </th>
                </tr>
            </thead>
            <tbody class="entry-ld-body">
                <tr>
                    <td colspan="2" class="china">1ST PRIZE</td>
                    <td colspan="2"><span style="font-weight:bold;font-size:18px;"><a href="https://luckyboxernita4d.fun/live-draw/tunggu.php" target="_blank" style="color:gold;font-size:35px;text-decoration:none;">        <?php 
        if (filter_var($numbers['PRIZE 1'][0] ?? '', FILTER_VALIDATE_URL)): 
        ?>
            <img src="<?php echo htmlspecialchars($numbers['PRIZE 1'][0]); ?>" alt="Hasil Undian">
        <?php else: ?>
            <span><?php echo htmlspecialchars($numbers['PRIZE 1'][0] ?? ''); ?></span>
        <?php endif; ?>
</span>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="china">2ND PRIZE</td>
                    <td colspan="2">
                        <span>        <?php 
        if (filter_var($numbers['PRIZE 2'][0] ?? '', FILTER_VALIDATE_URL)): 
        ?>
            <img src="<?php echo htmlspecialchars($numbers['PRIZE 2'][0]); ?>" alt="Hasil Undian">
        <?php else: ?>
            <span><?php echo htmlspecialchars($numbers['PRIZE 2'][0] ?? ''); ?></span>
        <?php endif; ?>
</span>                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="china">3RD PRIZE</td>
                    <td colspan="2">
                        <span>        <?php 
        if (filter_var($numbers['PRIZE 3'][0] ?? '', FILTER_VALIDATE_URL)): 
        ?>
            <img src="<?php echo htmlspecialchars($numbers['PRIZE 3'][0]); ?>" alt="Hasil Undian">
        <?php else: ?>
            <span><?php echo htmlspecialchars($numbers['PRIZE 3'][0] ?? ''); ?></span>
        <?php endif; ?>
</span>                    </td>
                </tr>
            </tbody>
        </table>
        <table class="entry-ld-table">
            <tbody class="entry-ld-body">
                <tr>
                    <th colspan="5" class="entry-ld-subtitle china">STARTER</th>
                </tr>
                <tr>
                    <td><span>        <?php 
        if (filter_var($numbers['STARTER'][0] ?? '', FILTER_VALIDATE_URL)): 
        ?>
            <img src="<?php echo htmlspecialchars($numbers['STARTER'][0]); ?>" alt="Hasil Undian">
        <?php else: ?>
            <span><?php echo htmlspecialchars($numbers['STARTER'][0] ?? ''); ?></span>
        <?php endif; ?>
</span>
                    <td><span><?php 
        if (filter_var($numbers['STARTER'][1] ?? '', FILTER_VALIDATE_URL)): 
        ?>
            <img src="<?php echo htmlspecialchars($numbers['STARTER'][1]); ?>" alt="Hasil Undian">
        <?php else: ?>
            <span><?php echo htmlspecialchars($numbers['STARTER'][1] ?? ''); ?></span>
        <?php endif; ?></span>                    </td>
                    <td><span><?php 
        if (filter_var($numbers['STARTER'][2] ?? '', FILTER_VALIDATE_URL)): 
        ?>
            <img src="<?php echo htmlspecialchars($numbers['STARTER'][2]); ?>" alt="Hasil Undian">
        <?php else: ?>
            <span><?php echo htmlspecialchars($numbers['STARTER'][2] ?? ''); ?></span>
        <?php endif; ?></span>                    </td>
                    <td><span><?php 
        if (filter_var($numbers['STARTER'][3] ?? '', FILTER_VALIDATE_URL)): 
        ?>
            <img src="<?php echo htmlspecialchars($numbers['STARTER'][3]); ?>" alt="Hasil Undian">
        <?php else: ?>
            <span><?php echo htmlspecialchars($numbers['STARTER'][3] ?? ''); ?></span>
        <?php endif; ?></span>                   </td>
                    <td><span><?php 
        if (filter_var($numbers['STARTER'][4] ?? '', FILTER_VALIDATE_URL)): 
        ?>
            <img src="<?php echo htmlspecialchars($numbers['STARTER'][4]); ?>" alt="Hasil Undian">
        <?php else: ?>
            <span><?php echo htmlspecialchars($numbers['STARTER'][4] ?? ''); ?></span>
        <?php endif; ?></span>                    </td>
                </tr>
                <tr>
                    <th colspan="5" class="entry-ld-subtitle china">CONSOLATION</th>
                </tr>
                <tr>
                    <td><span><?php 
        if (filter_var($numbers['CONSOLATION'][0] ?? '', FILTER_VALIDATE_URL)): 
        ?>
            <img src="<?php echo htmlspecialchars($numbers['CONSOLATION'][0]); ?>" alt="Hasil Undian">
        <?php else: ?>
            <span><?php echo htmlspecialchars($numbers['CONSOLATION'][0] ?? ''); ?></span>
        <?php endif; ?></span>                    </td>
                    <td><span><?php 
        if (filter_var($numbers['CONSOLATION'][1] ?? '', FILTER_VALIDATE_URL)): 
        ?>
            <img src="<?php echo htmlspecialchars($numbers['CONSOLATION'][1]); ?>" alt="Hasil Undian">
        <?php else: ?>
            <span><?php echo htmlspecialchars($numbers['CONSOLATION'][1] ?? ''); ?></span>
        <?php endif; ?></span>                    </td>
                    <td><span><?php 
        if (filter_var($numbers['CONSOLATION'][2] ?? '', FILTER_VALIDATE_URL)): 
        ?>
            <img src="<?php echo htmlspecialchars($numbers['CONSOLATION'][2]); ?>" alt="Hasil Undian">
        <?php else: ?>
            <span><?php echo htmlspecialchars($numbers['CONSOLATION'][2] ?? ''); ?></span>
        <?php endif; ?></span>                    </td>
                    <td><span><?php 
        if (filter_var($numbers['CONSOLATION'][3] ?? '', FILTER_VALIDATE_URL)): 
        ?>
            <img src="<?php echo htmlspecialchars($numbers['CONSOLATION'][3]); ?>" alt="Hasil Undian">
        <?php else: ?>
            <span><?php echo htmlspecialchars($numbers['CONSOLATION'][3] ?? ''); ?></span>
        <?php endif; ?></span>                  </td>
                    <td><span><?php 
        if (filter_var($numbers['CONSOLATION'][4] ?? '', FILTER_VALIDATE_URL)): 
        ?>
            <img src="<?php echo htmlspecialchars($numbers['CONSOLATION'][4]); ?>" alt="Hasil Undian">
        <?php else: ?>
            <span><?php echo htmlspecialchars($numbers['CONSOLATION'][4] ?? ''); ?></span>
        <?php endif; ?></span>                </td>
                </tr>
            </tbody>
        </table>
    </div>
</body>
</html>