OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
eSamudaay
/
newReader
/
inc
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/29/2024 12:17:22 PM
rwxr-xr-x
📄
db.php
334 bytes
08/29/2024 12:17:22 PM
rw-r--r--
📄
function.php
7.89 KB
08/29/2024 12:17:22 PM
rw-r--r--
Editing: function.php
Close
<? function isValidImageUrl($url) { if ($url === '') { return false; } $headers = @get_headers($url); if ($headers && strpos($headers[0], '200') !== false) { // Get the content type from headers $contentType = ''; foreach ($headers as $header) { if (strpos($header, 'Content-Type:') !== false) { $contentType = trim(substr($header, 13)); break; } } // Check if the content type is an image return in_array($contentType, ['image/jpeg', 'image/png', 'image/gif']) ? $url : false; } return false; } function filter_desc(&$img, $html) { // Regular expression to match <img> tags $pattern = '/<img[^>]*>/i'; // Array to store matched <img> tags $descImg = []; // Callback function to capture the <img> tags and remove them $callback = function ($matches) use (&$descImg) { $descImg[] = $matches[0]; // Add the matched <img> tag to the array return ''; // Replace the <img> tag with an empty string }; // Perform the regex replacement with the callback function $cleaned_html = preg_replace_callback($pattern, $callback, $html); if ($descImg) { $img = getImgSrc($descImg[0]); } return $cleaned_html; } function getImgSrc($imgTag) { // Define the regular expression pattern to match the src attribute $pattern = '/<img\s+[^>]*src=["\']([^"\']+)["\'][^>]*>/i'; // Perform the regular expression match if (preg_match($pattern, $imgTag, $matches)) { // Return the src value found return $matches[1]; } // Return false if no src attribute is found return false; } function display_rss_articles($mysqli, $category) { $sql = 'SELECT a.title, a.url, a.description, a.image, a.date FROM rss_feeds_articles a INNER JOIN rss_feeds_url u ON a.feed_id = u.rss_id WHERE u.rss_category=' . $category . ' ORDER BY DATE desc LIMIT 50'; $result = $mysqli->query($sql); // Check if the query was successful if (!$result) { die('Query Error: ' . $mysqli->error); } while ($row = $result->fetch_assoc()) { $title = stripslashes($row['title']); $url = stripslashes($row['url']); $img = stripslashes($row['image']); $desc = filter_desc($img, stripslashes($row['description'])); if (!isValidImageUrl($img)) { $img = "https://th.bing.com/th/id/OIP.TPlSRAtpxf7Y2EQ4pkty_wHaFb?rs=1&pid=ImgDetMain"; } $date = stripslashes($row['date']); $publisher = substr($url, strpos($url, ".") + 1); $publisher = ucfirst(strtok($publisher, '.')); ?> <div class="card p-0 mb-3 border-0" style="background-color:#f5ede7"> <div class="panelFeed card-body p-2"> <div class="row no-gutters align-self-start"> <div class="col 1" style="max-width: 240px; height: auto;"> <img src="<?= $img ?>" alt="" class="img-fluid" style="width: 240px; height: auto;"> </div> <div class="col 2"> <div class="row 1" style="padding-left: 2vw;"> <h4 class="m-0 align-self-start" style="font-size: 1.25rem;"> <a href="<?= $url ?>" target="_blank" style="color:#f26522"> <?= $title ?> <br> <span style="position: absolute; top: -9999px; left: -9999px"><?= $url ?></span> </a> </h4> </div> <div class="row 2" style="padding-left: 2vw;"> <p class="m-0" style="color:#7d7d7d; font-size: 1rem;"><?= $desc ?></p> </div> <div class="row 3"> <div class="col text-center text-md-left" style="padding-left: 2vw; bottom: -15px; position: relative;"><?= $publisher ?> • <?= $date ?></div> <div class="col data text-center text-md-right justify-content-end align-items-center" data-feed-title="<? htmlspecialchars($title, ENT_QUOTES, 'UTF-8') ?>" data-feed-url="<? htmlspecialchars($url, ENT_QUOTES, 'UTF-8') ?>" data-feed-publisher="<?= htmlspecialchars($publisher, ENT_QUOTES, 'UTF-8') ?>" data-feed-desc="<?= htmlspecialchars($desc, ENT_QUOTES, 'UTF-8') ?>"> <button class="btn btn-outline-secondary mic-button play-button" data-title="<?= $title ?>" data-description="<?= htmlspecialchars($desc, ENT_QUOTES, 'UTF-8') ?>"> <i class="fas fa-volume-up"></i> </button> <button class="btn btn-outline-secondary mic-button pause-button" style="display:none;"> <i class="fas fa-pause"></i> </button> <button class="btn btn-outline-secondary mic-button resume-button" style="display:none;"> <i class="fas fa-play"></i> </button> <button class="btn btn-outline-secondary mic-button stop-button" style="display:none;"> <i class="fas fa-stop"></i> </button> <button class="btn btn-outline-secondary mic-button icon-container"> <input type="hidden" id="metadata" data-title="<?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8') ?>" data-url="<?= htmlspecialchars($url, ENT_QUOTES, 'UTF-8') ?>" description="<?= htmlspecialchars($desc, ENT_QUOTES, 'UTF-8') ?>"> <i class="far fa-bookmark" id="bookmarkIcon"></i></button> <button class="btn btn-outline-secondary mic-button" onclick="CopyToClipboards('<?= $url ?>')"> <i class="fa-solid fa-arrow-up-from-bracket"></i> </button> </div> </div> </div> </div> </div> </div> <? } } function checkLike($articleId) { global $gUserId; global $mysqli; $sql = "SELECT COUNT(*) as count FROM reader_thumbs_up WHERE articleId = ? AND userId = ?"; $stmt = $mysqli->prepare($sql); if ($stmt === false) { die("Prepare failed: " . $mysqli->error); } $stmt->bind_param("ii", $articleId, $gUserId); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); $count = $row['count']; if ($count == 1) { return "fa-solid fa-thumbs-up"; } else { return "fa-regular fa-thumbs-up"; } } function likeCount($articleId) { global $mysqli; $sql = "SELECT COUNT(*) as count FROM reader_thumbs_up WHERE articleId = ?"; $stmt = $mysqli->prepare($sql); if ($stmt === false) { die("Prepare failed: " . $mysqli->error); } $stmt->bind_param("i", $articleId); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); if($row['count'] === 0){ return ''; } return $row['count']; } ?>