Sunda Cyber Army


* Sunda Cyber Army 2k17 *
Indonesia Defacer ~


Path : /home/dent/public_html/exams/christian/
File Upload :
Current File : /home/dent/public_html/exams/christian/details.php

<?php

// disclosure: LLMs used to debug & clean up certain code snippets

$host = "webdev.iyaserver.com";
$userid = "dent_test";
$password = "Acad276_Ttrojan_Dev2Ex@m";
$db = "dent_exam";

$mysql = new mysqli($host, $userid, $password, $db);
if ($mysql->connect_errno) {
    echo "Connection failed: " . $mysql->connect_error;
    exit();
}

$device_id = $_GET['id'] ?? '';

if (empty($device_id)) {
    header("Location: search.php");
    exit();
}

$device_id = (int)$device_id;
$sql = "SELECT d.device_id, d.name, d.price, d.img_url, m.manufacturer, o.system, dt.type 
        FROM `device` d 
        JOIN `make` m ON d.manufacturer_id = m.manufacturer_id 
        JOIN `os` o ON d.system_id = o.system_id 
        JOIN `devicetype` dt ON d.type_id = dt.type_id 
        WHERE d.device_id = $device_id";

$results = $mysql->query($sql);
if (!$results) {
    echo "SQL error: " . $mysql->error;
    exit();
}

$device = $results->fetch_assoc();
if (!$device) {
    header("Location: search.php");
    exit();
}
?>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Acad276 Practical Exam: Details</title>
    <style>
        .container {
            width:  800px;
            margin: auto;
        }
        h1 {
            margin: auto;
            text-align: center;
            background-color:   #900;
            color:  #FC0;
            height: 60px;
            line-height: 60px;
        }
        .details {
            border:     1px solid #990000;
            width:      600px;
            margin:     auto;
            margin-top: 20px;
            padding:    20px;
        }
        table {
            height: 300px;
            width:      100%;
        }
        table img {
            height: 300px;

        }
        img {
            width: 300px;

        }
        .label {
            text-align: right;
            width:      20%;
            padding:    3px 10px 3px;
        }
        .data {
            width: 40%;
        }
        .input>input, .input>select {
            width:  100%;
        }
        .nav-link{
            margin: 10px 0px;
            font-size: 14px;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>Mobile Device Database: Details Page</h1>
    <div class="nav-link">
        <a href="search.php"><< Back to Search Page</a>
    </div>

    <div class="details">
        <table>
            <tr>
                <td rowspan="5" class="img">
                    <?php if (!empty($device['img_url'])): ?>
                        <img src="<?php echo htmlspecialchars($device['img_url']); ?>" class="img">
                    <?php else: ?>
                        <img src="https://image.shutterstock.com/image-vector/vector-sketch-illustration-human-hand-260nw-605728496.jpg" class="img">
                    <?php endif; ?>
                </td>
                <td class="label">Name:</td>
                <td class="data"><strong><em><?php echo htmlspecialchars($device['name']); ?></em></strong></td>
            </tr>
            <tr>
                <td class="label">Price:</td>
                <td><strong><?php echo number_format($device['price'], 2); ?></strong></td>
            </tr>
            <tr>
                <td class="label">Manufacturer:</td>
                <td><?php echo htmlspecialchars($device['manufacturer']); ?></td>
            </tr>
            <tr>
                <td class="label">System:</td>
                <td><?php echo htmlspecialchars($device['system']); ?></td>
            </tr>
            <tr>
                <td class="label">Type:</td>
                <td><?php echo htmlspecialchars($device['type']); ?></td>
            </tr>
        </table>
    </div>

</div>
</body>
</html>