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 session_start(); // Include database credentials from a separate configuration f..
Decoded Output download
<?php
session_start();
// Include database credentials from a separate configuration file
require_once 'includes/config.php';
// Database connection using credentials
$connection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if ($connection->connect_error) {
die("Connection failed: " . $connection->connect_error);
}
// Retrieve all categories from the category table
$category_sql = "SELECT id, name FROM category";
$category_result = $connection->query($category_sql);
// Check if a category_id is passed and fetch the videos for that category using prepared statements
$category_id = isset($_GET['category_id']) ? intval($_GET['category_id']) : 0;
$search_term = isset($_GET['search_term']) ? $connection->real_escape_string($_GET['search_term']) : '';
if ($category_id > 0) {
$video_sql = $connection->prepare("SELECT id, title, image_url, video_url, category_id, keyId, `key`, is_mpd FROM videos WHERE category_id = ? AND title LIKE ?");
$search_term_param = "%$search_term%";
$video_sql->bind_param("is", $category_id, $search_term_param);
} else {
$video_sql = $connection->prepare("SELECT id, title, image_url, video_url, category_id, keyId, `key`, is_mpd FROM videos WHERE title LIKE ?");
$search_term_param = "%$search_term%";
$video_sql->bind_param("s", $search_term_param);
}
$video_sql->execute();
$video_result = $video_sql->get_result();
// User subscription expiration date
$user_id = $_SESSION['user_id'] ?? 0;
$user_sql = $connection->prepare("SELECT scadenza FROM users WHERE id = ?");
$user_sql->bind_param("i", $user_id);
$user_sql->execute();
$user_result = $user_sql->get_result();
$user = $user_result->fetch_assoc();
$expiration_date = new DateTime($user['scadenza'] ?? 'now');
$formatted_expiration = $expiration_date->format('d/m/y');
$user_sql->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Page</title>
<link rel="stylesheet" href="asset/css/style.css">
<script src="https://kit.fontawesome.com/d6e55bb259.js" crossorigin="anonymous"></script>
<style>
.video-item img {
width: 130px;
height: 130px;
}
.video-item p {
font-size: 2.3em;
}
.logo img {
width: 75px;
}
.search-box {
display: none;
position: absolute;
top: 50px;
left: 50%;
transform: translateX(-50%);
background: white;
padding: 20px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.5);
z-index: 1000;
}
.search-box input[type="text"] {
width: 300px;
font-size: 1.2em;
}
.search-box input[type="submit"] {
font-size: 1.2em;
padding: 5px 10px;
}
.user-popup {
display: none;
position: absolute;
top: 50px;
right: 10px;
background: white;
padding: 10px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.5);
z-index: 1000;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="top_navbar">
<div class="hamburger">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</div>
<div class="top_menu">
<div class="logo">
<img src="images/logo.png" alt="Logo">
</div>
<ul>
<li><a href="#" id="search-button"><i class="fas fa-search"></i></a></li>
<li><a href="#" id="user-button"><i class="fas fa-user"></i></a></li>
</ul>
</div>
</div>
<div class="search-box">
<form method="GET" action="">
<input type="text" name="search_term" placeholder="Search videos..." value="<?php echo htmlspecialchars($search_term); ?>" autofocus>
<input type="submit" value="Search">
</form>
</div>
<div class="user-popup">
<p>Subscription expires on: <?php echo htmlspecialchars($formatted_expiration); ?></p>
</div>
<div class="sidebar">
<ul>
<li>
<a href="?" <?php echo $category_id == 0 ? 'class="active"' : ''; ?>>
<span class="icon"><i class="fas fa-list"></i></span>
<span class="title">TUTTI</span>
</a>
</li>
<?php
if ($category_result->num_rows > 0) {
while($category = $category_result->fetch_assoc()) {
echo '<li>';
echo '<a href="?category_id=' . htmlspecialchars($category["id"]) . '" ' . ($category_id == $category["id"] ? 'class="active"' : '') . '>';
echo '<span class="icon"><i class="fas fa-book"></i></span>';
echo '<span class="title">' . htmlspecialchars($category["name"]) . '</span>';
echo '</a>';
echo '</li>';
}
} else {
echo '<li>No categories found</li>';
}
?>
</ul>
</div>
<div class="main_container">
<?php
if ($video_result->num_rows > 0) {
while($video = $video_result->fetch_assoc()) {
if ($video['is_mpd']) {
echo '<div class="item video-item">';
echo '<p>' . htmlspecialchars($video["title"]) . '</p>';
echo '<div id="player' . htmlspecialchars($video["id"]) . '"></div>';
echo '<script>
var playerInstance = jwplayer("player' . htmlspecialchars($video["id"]) . '");
playerInstance.setup({
playlist: [{
"title": "' . htmlspecialchars($video["title"]) . '",
"description": "LIVE",
"sources": [
{
"default": false,
"type": "dash",
"file": "' . htmlspecialchars($video["video_url"]) . '",
"drm": {
"clearkey": {
"keyId": "' . htmlspecialchars($video["keyId"]) . '",
"key": "' . htmlspecialchars($video["key"]) . '"
}
},
"label": "0"
}
]
}],
width: "100%",
height: "100%",
aspectratio: "16:9",
allowfullscreen: true,
autostart: false,
skin: {
name: "black",
active: "RED",
inactive: "GOLD",
background: "black"
}
});
</script>';
echo '</div>';
} else {
echo '<div class="item video-item">';
echo '<a href="' . htmlspecialchars($video["video_url"]) . '" target="_blank">';
echo '<img src="' . htmlspecialchars($video["image_url"]) . '" alt="' . htmlspecialchars($video["title"]) . '"><br>';
echo '<p>' . htmlspecialchars($video["title"]) . '</p>';
echo '</a>';
echo '</div>';
}
}
} else {
echo '<p>No videos found</p>';
}
?>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script>
$("#search-button").click(function() {
$(".search-box").toggle();
$(".search-box input[name='search_term']").focus();
});
$("#user-button").click(function() {
$(".user-popup").show();
setTimeout(function() {
$(".user-popup").fadeOut();
}, 5000);
});
$(".hamburger").click(function() {
$(".sidebar").toggle(50);
if ($(".main_container").css("margin-left") == "0px") {
$(".main_container").css("width", "calc(100% - 240px)");
$(".main_container").css("margin-left", "240px");
} else {
$(".main_container").css("width", "100%");
$(".main_container").css("margin-left", "0");
}
});
</script>
</body>
</html>
<?php
$video_sql->close();
$connection->close();
?>
Did this file decode correctly?
Original Code
<?php
session_start();
// Include database credentials from a separate configuration file
require_once 'includes/config.php';
// Database connection using credentials
$connection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if ($connection->connect_error) {
die("Connection failed: " . $connection->connect_error);
}
// Retrieve all categories from the category table
$category_sql = "SELECT id, name FROM category";
$category_result = $connection->query($category_sql);
// Check if a category_id is passed and fetch the videos for that category using prepared statements
$category_id = isset($_GET['category_id']) ? intval($_GET['category_id']) : 0;
$search_term = isset($_GET['search_term']) ? $connection->real_escape_string($_GET['search_term']) : '';
if ($category_id > 0) {
$video_sql = $connection->prepare("SELECT id, title, image_url, video_url, category_id, keyId, `key`, is_mpd FROM videos WHERE category_id = ? AND title LIKE ?");
$search_term_param = "%$search_term%";
$video_sql->bind_param("is", $category_id, $search_term_param);
} else {
$video_sql = $connection->prepare("SELECT id, title, image_url, video_url, category_id, keyId, `key`, is_mpd FROM videos WHERE title LIKE ?");
$search_term_param = "%$search_term%";
$video_sql->bind_param("s", $search_term_param);
}
$video_sql->execute();
$video_result = $video_sql->get_result();
// User subscription expiration date
$user_id = $_SESSION['user_id'] ?? 0;
$user_sql = $connection->prepare("SELECT scadenza FROM users WHERE id = ?");
$user_sql->bind_param("i", $user_id);
$user_sql->execute();
$user_result = $user_sql->get_result();
$user = $user_result->fetch_assoc();
$expiration_date = new DateTime($user['scadenza'] ?? 'now');
$formatted_expiration = $expiration_date->format('d/m/y');
$user_sql->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Page</title>
<link rel="stylesheet" href="asset/css/style.css">
<script src="https://kit.fontawesome.com/d6e55bb259.js" crossorigin="anonymous"></script>
<style>
.video-item img {
width: 130px;
height: 130px;
}
.video-item p {
font-size: 2.3em;
}
.logo img {
width: 75px;
}
.search-box {
display: none;
position: absolute;
top: 50px;
left: 50%;
transform: translateX(-50%);
background: white;
padding: 20px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.5);
z-index: 1000;
}
.search-box input[type="text"] {
width: 300px;
font-size: 1.2em;
}
.search-box input[type="submit"] {
font-size: 1.2em;
padding: 5px 10px;
}
.user-popup {
display: none;
position: absolute;
top: 50px;
right: 10px;
background: white;
padding: 10px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.5);
z-index: 1000;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="top_navbar">
<div class="hamburger">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</div>
<div class="top_menu">
<div class="logo">
<img src="images/logo.png" alt="Logo">
</div>
<ul>
<li><a href="#" id="search-button"><i class="fas fa-search"></i></a></li>
<li><a href="#" id="user-button"><i class="fas fa-user"></i></a></li>
</ul>
</div>
</div>
<div class="search-box">
<form method="GET" action="">
<input type="text" name="search_term" placeholder="Search videos..." value="<?php echo htmlspecialchars($search_term); ?>" autofocus>
<input type="submit" value="Search">
</form>
</div>
<div class="user-popup">
<p>Subscription expires on: <?php echo htmlspecialchars($formatted_expiration); ?></p>
</div>
<div class="sidebar">
<ul>
<li>
<a href="?" <?php echo $category_id == 0 ? 'class="active"' : ''; ?>>
<span class="icon"><i class="fas fa-list"></i></span>
<span class="title">TUTTI</span>
</a>
</li>
<?php
if ($category_result->num_rows > 0) {
while($category = $category_result->fetch_assoc()) {
echo '<li>';
echo '<a href="?category_id=' . htmlspecialchars($category["id"]) . '" ' . ($category_id == $category["id"] ? 'class="active"' : '') . '>';
echo '<span class="icon"><i class="fas fa-book"></i></span>';
echo '<span class="title">' . htmlspecialchars($category["name"]) . '</span>';
echo '</a>';
echo '</li>';
}
} else {
echo '<li>No categories found</li>';
}
?>
</ul>
</div>
<div class="main_container">
<?php
if ($video_result->num_rows > 0) {
while($video = $video_result->fetch_assoc()) {
if ($video['is_mpd']) {
echo '<div class="item video-item">';
echo '<p>' . htmlspecialchars($video["title"]) . '</p>';
echo '<div id="player' . htmlspecialchars($video["id"]) . '"></div>';
echo '<script>
var playerInstance = jwplayer("player' . htmlspecialchars($video["id"]) . '");
playerInstance.setup({
playlist: [{
"title": "' . htmlspecialchars($video["title"]) . '",
"description": "LIVE",
"sources": [
{
"default": false,
"type": "dash",
"file": "' . htmlspecialchars($video["video_url"]) . '",
"drm": {
"clearkey": {
"keyId": "' . htmlspecialchars($video["keyId"]) . '",
"key": "' . htmlspecialchars($video["key"]) . '"
}
},
"label": "0"
}
]
}],
width: "100%",
height: "100%",
aspectratio: "16:9",
allowfullscreen: true,
autostart: false,
skin: {
name: "black",
active: "RED",
inactive: "GOLD",
background: "black"
}
});
</script>';
echo '</div>';
} else {
echo '<div class="item video-item">';
echo '<a href="' . htmlspecialchars($video["video_url"]) . '" target="_blank">';
echo '<img src="' . htmlspecialchars($video["image_url"]) . '" alt="' . htmlspecialchars($video["title"]) . '"><br>';
echo '<p>' . htmlspecialchars($video["title"]) . '</p>';
echo '</a>';
echo '</div>';
}
}
} else {
echo '<p>No videos found</p>';
}
?>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script>
$("#search-button").click(function() {
$(".search-box").toggle();
$(".search-box input[name='search_term']").focus();
});
$("#user-button").click(function() {
$(".user-popup").show();
setTimeout(function() {
$(".user-popup").fadeOut();
}, 5000);
});
$(".hamburger").click(function() {
$(".sidebar").toggle(50);
if ($(".main_container").css("margin-left") == "0px") {
$(".main_container").css("width", "calc(100% - 240px)");
$(".main_container").css("margin-left", "240px");
} else {
$(".main_container").css("width", "100%");
$(".main_container").css("margin-left", "0");
}
});
</script>
</body>
</html>
<?php
$video_sql->close();
$connection->close();
?>
Function Calls
None |
Stats
MD5 | f4e46f1e6169468996b55eb934a557c7 |
Eval Count | 0 |
Decode Time | 53 ms |