OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
reeliv
/
process
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
09/04/2024 11:00:16 AM
rwxr-xr-x
📄
b.get.section.curated.php
17.96 KB
09/04/2024 11:00:14 AM
rw-r--r--
📄
b.get.section.newsletter.php
18.39 KB
09/04/2024 11:00:14 AM
rw-r--r--
📄
bchk.login.php
1.84 KB
09/04/2024 11:00:14 AM
rw-r--r--
📄
chk.logged.in.php
1.16 KB
09/04/2024 11:00:14 AM
rw-r--r--
📄
chk.login.php
1.84 KB
09/04/2024 11:00:15 AM
rw-r--r--
📁
eyecandy
-
09/04/2024 11:00:16 AM
rwxr-xr-x
📄
get.section.account.php
8.47 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.admin.php
16.74 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.analytics.php
11.45 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.collection.php
58.52 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.community.php
6.8 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.create.php
22.41 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.curated.php
36.3 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.dashboard.php
3.31 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.feed.php
7.42 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.genai.php
12.72 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.genaicreative.php
12.74 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.general.php
9.31 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.newsletter.php
18.42 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.request.article.php
5.82 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.settings.php
21.15 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.team.php
6.73 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.testing.php
18.2 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.utils.php
4.1 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
get.section.video.php
37.7 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
logout.php
428 bytes
09/04/2024 11:00:15 AM
rw-r--r--
📄
output.txt
17.79 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
sendgrid.php
3.62 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
upload.php
2.4 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
zget.section.curated.php
21.2 KB
09/04/2024 11:00:15 AM
rw-r--r--
📄
zzget.section.curated.php
23.64 KB
09/04/2024 11:00:15 AM
rw-r--r--
Editing: get.section.video.php
Close
<? // Cream: Cream Curated require_once '../inc/validate.logged.php'; require_once '../inc/config.php'; include '../newReader/inc/db.php'; include '../newReader/inc/function.php'; function extractThumbnailUrl($xmlContent) { // Define a regular expression pattern to match the media:thumbnail tag and extract the URL $pattern = '/<media:thumbnail\s+url="([^"]+)"\s+width="\d+"\s+height="\d+"\/>/'; // Perform the regular expression match if (preg_match($pattern, $xmlContent, $matches)) { // $matches[1] contains the URL $thumbnailUrl = $matches[1]; return htmlspecialchars($thumbnailUrl); } else { return null; } } function extractVideoIdFromXml($inputString) { // Define a regular expression pattern to match and extract the videoId from <yt:videoId> $pattern = '/<yt:videoId>([^<]+)<\/yt:videoId>/'; // Perform the regular expression match if (preg_match($pattern, $inputString, $matches)) { // $matches[1] contains the videoId return $matches[1]; } else { return 'Video ID not found.'; } } function printRssFeedData($feedUrl) { $return = []; // Fetch the feed content $feedContent = @file_get_contents($feedUrl); // Handle errors if the content could not be fetched if ($feedContent === FALSE) { echo 'Error fetching the RSS feed.'; return; } // Parse the XML data $xml = new SimpleXMLElement($feedContent); // Register namespaces for use with SimpleXMLElement $namespaces = $xml->getNamespaces(true); $mediaNamespace = $namespaces['media']; $channelTitle = htmlspecialchars($xml->title); // Loop through each entry in the feed foreach ($xml->entry as $entry) { $videoId = extractVideoIdFromXml($entry->asXML()); $title = (string) $entry->title; $link = (string) $entry->link['href']; $description = ''; $thumbnailUrl = ''; // Access media namespace elements $mediaGroup = $entry->children($mediaNamespace)->group; if ($mediaGroup) { // Access media namespace elements $descriptionElement = $mediaGroup->children($mediaNamespace)->description; $thumbnailElement = $mediaGroup->children($mediaNamespace)->thumbnail; // Get values from media elements $description = (string) $descriptionElement; // Access attributes in namespaced elements $thumbnailUrl = extractThumbnailUrl($thumbnailElement->asXML()); } $publishedDate = (string) $entry->published; $return[] = [ "id" => $videoId, "channel" => $channelTitle, "title" => $title, "link" => $link, "description" => $description, "publishedDate" => $publishedDate, "thumbnail" => $thumbnailUrl, "embed" => htmlspecialchars(generate_embedded_code($videoId, $title)) ]; } return $return; } function generate_embedded_code($videoCode, $title) { $url = '<iframe width="480" height="270" src="https://www.youtube.com/embed/' . urlencode($videoCode) . '" title="' . $title . '" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen> </iframe>'; return $url; } function fetch_messages($conn, $feedId) { $chat = []; $message_id = ''; $userId = ''; $userName = ''; $comment = ''; $posted_on = ''; $edited_on = ''; $deleted_on = ''; try { // SQL query with placeholders $sql = "SELECT rc.id, rc.feedId, rc.userId, u.full_name, rc.comment, rc.posted_on, rc.edited_on, rc.deleted_on FROM reader.reader_comments rc JOIN cream.user u ON rc.userId = u.id WHERE rc.feedId = ?"; $stmt = $conn->prepare($sql); if ($stmt === false) { throw new Exception("Failed to prepare statement: " . $conn->error); } $stmt->bind_param('i', $feedId); // 'i' indicates the type of the parameter (integer) // Execute query $stmt->execute(); // Bind result variables $stmt->bind_result($message_id, $feedId, $userId, $userName, $comment, $posted_on, $edited_on, $deleted_on); // Fetch data while ($stmt->fetch()) { $chat[] = [ 'message_id' => $message_id, 'article_id' => $feedId, 'user_id' => $userId, 'user_name' => $userName, 'message' => $comment, 'posted_on' => $posted_on, 'edited_on' => $edited_on, 'deleted_on' => $deleted_on ]; } // Close statement $stmt->close(); } catch (mysqli_sql_exception $e) { echo "Error: " . $e->getMessage(); } catch (Exception $e) { echo "Error: " . $e->getMessage(); } return $chat; } function display_comments($chat) { if (empty($chat)) { ?> <div> Be the first one to comment.. </div><br> <? } else { // Sample messages array (could be fetched from database or API) foreach ($chat as $message) { $messageText = htmlspecialchars($message['message']); $time = htmlspecialchars($message['posted_on']); $user = htmlspecialchars($message['user_name']); ?> <div class='comment'> <div class='text'> <? echo $messageText ?> </div> <div class='author' style="display: flex; gap:5px"> <div class="sendername"> <? echo $user ?> </div> <span class="datewithtime"> <? echo $time ?> </span> </div> </div> <? } } } // Check if it's an AJAX request to handle comments if (isset($_POST['action'])) { if ($_POST['action'] === 'getComments') { $chat = fetch_messages($db, $_POST['articleId']); ?> <div id="comments" class="mx-0"> <? display_comments($chat); ?> </div> <? exit(); // Stop further execution } else if ($_POST['action'] === 'postComment') { sendMessage($db, $_POST['feedId'], $gUserId, $_POST['comment'], date('Y-m-d H:i:s')); exit(); } } function sendMessage($conn, $feedId, $userId, $comment, $posted_on) { $sql = "INSERT INTO reader.reader_comments(feedId, userId , comment, posted_on) VALUES ('$feedId', '$userId', '$comment', '$posted_on')"; if ($conn->query($sql) === TRUE) { echo "Review given successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } } function checkSave($url) { global $db; global $gUserId; $sql = "SELECT COUNT(*) AS count FROM user_collection WHERE url = ? AND user_id = ?"; $stmt = $db->prepare($sql); if ($stmt === false) { die("Prepare failed: " . $db->error); } $stmt->bind_param("si", $url, $gUserId); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); $count = isset($row['count']) ? (int)$row['count'] : 0; if ($count === 0) { return "far fa-bookmark"; } else { return "fas fa-bookmark"; } } ?> <ol class="breadcrumb my-3"> <li class="breadcrumb-item w-100" style="display:flex; justify-content:space-between;"> <div class="text-left "> <h4 class="mt-1" style="font-size: 1.25rem;">Curated For You</h4> </div> </li> </ol> <style> </style> <div class="panelFeeds pr-2"> <?php $rssFeedUrls = [ 'https://www.youtube.com/feeds/videos.xml?channel_id=UCLtCejNl8eAg4PO_9lf2TIg', 'https://www.youtube.com/feeds/videos.xml?channel_id=UCnSqxrSfo1sK4WZ7nBpYW1Q', 'https://www.youtube.com/feeds/videos.xml?channel_id=UCyvSN-Hw7dQ3IwV_w9NL5RA' ]; foreach ($rssFeedUrls as $rss) { $data = printRssFeedData($rss); foreach ($data as $ele) { $feedId = $ele['id']; $feedTitle = $ele['title']; $feedURL = $ele['link']; $feedPublisher = $ele['channel']; $feedDesc = $ele['description']; $feedDate = $ele['publishedDate']; $feedImg = $ele['thumbnail']; $embed = htmlspecialchars_decode($ele['embed']); $randomNumber = rand(1, 13); if (!isValidImageUrl($feedImg)) { $feedImg = "http://knoblyreader.com/process/eyecandy/" . $randomNumber . ".jpeg"; } ?> <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-items-start"> <div class="col-auto"> <img src="<?= $feedImg ?>" alt="" class="img-fluid" style="max-width: 100px; height: auto; cursor: pointer;" data-toggle="modal" data-target="#feedModal<?= $feedId ?>"> </div> <div class="col pl-1"> <h4 class="m-0" style="font-size: 1.25rem;"> <a id="<?= $feedTitle ?>" href="<?= $feedURL ?>" target="_blank" style="color:#f26522"> <?= $feedTitle ?> <br> <span style="position: absolute; top: -9999px; left: -9999px"><?= $feedURL ?></span> </a> </h4> </div> </div> <div class="row no-gutters mt-2"> <div class="col-12"> <p class="m-0" style="color:#7d7d7d; font-size: 1rem;"><?= strlen($feedDesc) >300 ? substr($feedDesc, 0, 300) . '...' : $feedDesc; ?></p> </div> </div> <div class="row no-gutters mt-2"> <div class="col-12 col-md-6 text-center text-md-left"><?= $feedPublisher ?> • <?= $feedDate ?></div> <div class="data col-12 col-md-6 text-center text-md-right mt-2 mt-md-0 d-flex justify-content-end align-items-center"> <div class="mr-2"> <button class="btn btn-outline-secondary mic-button play-button" data-title="<?= urlencode($feedTitle ?? " ") ?>" data-description="<?= urlencode($feedDesc ?? " ") ?>"> <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> </div> <button class="btn btn-outline-secondary mic-button likeButton" style="margin-bottom: 0px;margin-right: 7px; display: flex;"> <i id="thumbsUp" class="<?= checkLike($feedId) ?>" style="padding-right: 4px; padding-top: 2px;"></i> <div id="likeCount"><?= likeCount($feedId) ?></div> <input type="hidden" id="likeData" data-article="<?= $feedId ?>"> </button> <button class="btn btn-outline-secondary mic-button comments" onclick="showComments('<?= $feedId ?>')" style="margin-bottom: 0px;margin-right: 7px; display: flex;"> <i class="fa-regular fa-comments"></i> <input type="hidden" id="commentSection" data-article=<?= $feedId ?>> </button> <label class="btn btn-outline-secondary mic-button icon-container" style="margin-bottom: 0px;margin-right: 7px;"> <i class="far fa-bookmark" id="bookmarkIcon"></i> <input type="hidden" id="metadata" data-title="<?= $feedTitle ?>" data-url="<?= $feedURL ?>" description="<?= htmlspecialchars($feedDesc) ?>"> </label> <button class="btn btn-outline-secondary mic-button" onclick="CopyToClipboards('<?= $feedURL ?>')"> <i class="fa-solid fa-arrow-up-from-bracket"></i> </button> </div> </div> <!-- Modal for Feed Item --> <div class="modal fade" id="feedModal<?= $feedId ?>" tabindex="-1" aria-labelledby="feedModalLabel<?= $feedId ?>"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="feedModalLabel<?= $feedId ?>"><?= $feedTitle ?></h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <!-- <img src="<?= $feedImg ?>" alt="" class="img-fluid mb-3" style="max-width: 100%;"> --> <?=$embed?> <p><?= strlen($feedDesc) > 500 ? substr($feedDesc, 0, 500) . '...' : $feedDesc; ?></p> <div class="d-flex justify-content-end align-items-center"> <div class="mr-2"> <button class="btn btn-primary ml-auto" onclick="window.location.href='<?= $feedURL ?>'"> Read More </button> <button class="btn btn-outline-secondary mic-button play-button" data-title="<?= urlencode($feedTitle ?? " ") ?>" data-description="<?= urlencode($feedDesc ?? " ") ?>"> <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> </div> <button class="btn btn-outline-secondary mic-button likeButton" style="margin-bottom: 0px;margin-right: 7px; display: flex;"> <i id="thumbsUp" class="<?= checkLike($feedId) ?>" style="padding-right: 4px; padding-top: 2px;"></i> <div id="likeCount"><?= likeCount($feedId) ?></div> <input type="hidden" id="likeData" data-article="<?= $feedId ?>"> </button> <button class="btn btn-outline-secondary mic-button comments" onclick="showComments('<?= $feedId ?>')" style="margin-bottom: 0px;margin-right: 7px; display: flex;"> <i class="fa-regular fa-comments"></i> <input type="hidden" id="commentSection" data-article=<?= $feedId ?>> </button> <label class="btn btn-outline-secondary mic-button icon-container" style="margin-bottom: 0px;margin-right: 7px;"> <i class="far fa-bookmark" id="bookmarkIcon"></i> <input type="hidden" id="metadata" data-title="<?= $feedTitle ?>" data-url="<?= $feedURL ?>" description="<?= $feedDesc ?>"> </label> <button class="btn btn-outline-secondary mic-button" onclick="CopyToClipboards('<?= $feedURL ?>')"> <i class="fa-solid fa-arrow-up-from-bracket"></i> </button> </div> </div> </div> </div> </div> </div> </div> <? } } ?> <!-- Modal Structure --> <!-- Modal Structure --> <div class="modal fade" id="commentModal" tabindex="-1" role="dialog" aria-labelledby="commentModalLabel" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable" role="document"> <div class="modal-content"> <div class="modal-header border-bottom-0"> <h5 class="modal-title" id="commentModalLabel">Comments</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body p-3"> <!-- Comments Section --> <div id="commentsSection" class="mb-3"> <!-- Existing comments will be loaded here --> </div> </div> <div class="modal-footer border-top-0" style="justify-content:space-around !important"> <!-- Input Field --> <div class="d-flex align-items-center"> <textarea id="myComment" class="form-control" rows="2" placeholder="Add a comment..." aria-label="Add a comment"></textarea> <button id="sendMyComment" class="btn btn-primary ml-2" onclick="sendComment()"> <i class="fas fa-paper-plane"></i> </button> </div> <!-- <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> --> </div> </div> </div> </div> <!-- Optional: Include Font Awesome for the icon --> <script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script> <!-- Optional: JavaScript for handling comment submission --> <script> function sendComment() { var comment = document.getElementById('myComment').value; if (comment.trim() === '') { alert('Please write a comment before sending.'); return; } // Assuming you have a function to handle the comment submission // Replace this with your actual comment submission logic var commentsSection = document.getElementById('commentsSection'); var newComment = document.createElement('div'); newComment.classList.add('comment'); newComment.textContent = comment; commentsSection.appendChild(newComment); // Clear the input field document.getElementById('myComment').value = ''; } </script> <!-- Optional: CSS for styling comments and modal --> <style> /* Overall Modal Styling */ .modal-content { border-radius: 10px; width: 100%; max-width: 500px; } /* Header Styling */ .modal-header { border-bottom: none; padding: 1rem; } .modal-title { font-size: 1.5rem; font-weight: bold; } /* Body Styling */ .modal-body { padding: 15px; display: flex; flex-direction: column; } /* Comments Section */ #commentsSection { max-height: 400px; overflow-y: auto; margin-bottom: 1rem; } /* Comment Bubble Styling */ .comment { background-color: #f5f5f5; border-radius: 15px; padding: 10px 15px; margin-bottom: 10px; font-size: 0.875rem; line-height: 1.5; max-width: 80%; } /* Input Field Styling */ .form-control { border: 1px solid #dbdbdb; border-radius: 20px; padding: 10px; font-size: 0.875rem; box-shadow: none; resize: none; } .form-control:focus { border-color: #0095f6; box-shadow: none; } /* Send Button Styling */ .btn-primary { background-color: #0095f6; border-color: #0095f6; border-radius: 20px; padding: 8px 16px; color: white; font-size: 0.875rem; } .btn-primary:hover { background-color: #007bb5; border-color: #007bb5; } /* Footer Styling */ .modal-footer { border-top: none; padding: 1rem; justify-content: flex-end; } .close { font-size: 1.5rem; } </style> </div> <script> function openCommentModal(feedId) { document.getElementById('commentModal' + feedId).style.display = 'flex'; } function closeCommentModal(feedId) { document.getElementById('commentModal' + feedId).style.display = 'none'; } </script> <script type="text/javascript"> $(function() { generateSM(); }); </script> <script> var isPlaying = false; $(document).ready(function() { // Play button click handler $('.play-button').on('click', function() { var title = decodeURIComponent($(this).data('title')); var desc = decodeURIComponent($(this).data('description')); playAudio(title, desc, $(this)); }); // Function to play audio function playAudio(title, desc, button) { var audio = new Audio(); if (isPlaying) { console.log("Audio is already playing. Cannot start another instance."); return; } console.log("Starting audio playback..."); isPlaying = true; // Set flag to true to indicate audio playback has started // Ajax call to get audio file URL $.ajax({ url: '../texttovoice/processvoice.php', type: 'POST', data: { title: title, description: desc }, success: function(response) { audio.src = response; audio.play(); // Update button visibility button.hide(); button.siblings('.pause-button').show(); button.siblings('.stop-button').show(); // Pause button click handler button.siblings('.pause-button').on('click', function() { audio.pause(); $(this).hide(); $(this).siblings('.resume-button').show(); }); // Resume button click handler button.siblings('.resume-button').on('click', function() { audio.play(); $(this).hide(); $(this).siblings('.pause-button').show(); }); button.siblings('.stop-button').on('click', function() { audio.pause(); // Pause the audio (assuming this stops playback) audio.currentTime = 0; // Reset audio playback to the beginning button.siblings('.resume-button').hide(); // Hide resume button if shown button.siblings('.stop-button').hide(); button.siblings('.pause-button').hide(); button.show(); isPlaying = false; }); // Reset when audio ends audio.onended = function() { isPlaying = false; button.show(); button.siblings('.pause-button').hide(); button.siblings('.resume-button').hide(); button.siblings('.stop-button').hide(); }; }, error: function(xhr, status, error) { console.error("Error playing audio:", error); } }); } }); function broadcast(link) { if (isPlaying) { console.log("Audio is already playing. Cannot start another instance."); return; } console.log("Starting audio playback..."); isPlaying = true; // Set flag to true to indicate audio playback has started var braudio = new Audio(); console.log(link); braudio.src = link; braudio.play(); $('.broadcast-pause').show(); $('.broadcast-stop').show(); $('.broadcast-pause').on('click', function() { braudio.pause(); $('.broadcast-pause').hide(); $('.broadcast-resume').show(); }); $('.broadcast-resume').on('click', function() { braudio.play(); $('.broadcast-resume').hide(); $('.broadcast-pause').show(); }); $('.broadcast-stop').on('click', function() { braudio.pause(); braudio.currentTime = 0; $('.broadcast-pause').hide(); $('.broadcast-resume').hide(); $('.broadcast-stop').hide(); isPlaying = false; }); braudio.onended = function() { isPlaying = false; $('.broadcast-pause').hide(); $('.broadcast-resume').hide(); $('.broadcast-stop').hide(); }; } </script> <script> $(document).ready(function() { // Use event delegation or direct binding if relevant $('.icon-container').each(function() { var userId = <?= $gUserId ?>; var $container = $(this); var url = $container.find('#metadata').data('url'); // Extract URL from hidden input var $icon = $container.find('#bookmarkIcon'); // Find the icon within the current container // Trigger the check collection function checkCollection(userId, url, $icon); }); $(document).on('click', '.icon-container', function() { var userId = <?= $gUserId ?>; var $icon = $(this).find('#bookmarkIcon'); var metadata = $(this).find('#metadata'); // Extract data from the hidden input var feedTitle = metadata.data('title'); var feedUrl = metadata.data('url'); var feedDesc = metadata.attr('description'); var feedImg = metadata.data('image'); var feedPublisher = metadata.data('publisher'); var feedDate = metadata.data('date'); // // Log the current state of the icon // console.log('Current icon classes:', $icon.attr('class')); // Determine the current state of the icon if ($icon.hasClass('far fa-bookmark')) { // // If the icon is inactive (outline), make it active (filled) // console.log('Icon is inactive, changing to active.'); addToCollection(userId, feedTitle, feedUrl, feedDesc); $icon.removeClass('far fa-bookmark').addClass('fas fa-bookmark'); } else { // // If the icon is active (filled), make it inactive (outline) // console.log('Icon is active, changing to inactive.'); removeFromCollection(userId, feedUrl); $icon.removeClass('fas fa-bookmark').addClass('far fa-bookmark'); } }); }); function checkCollection(userId, url, iconElement) { var $icon = $(iconElement); // Use the passed icon element $.ajax({ url: 'inc/hhandler.php', type: 'POST', contentType: 'application/json', data: JSON.stringify({ action: 'checkColl', file: 'curated', userId: userId, url: url }), success: function(response) { var result = JSON.parse(response); if (result.status === 'success') { if (result.count > 0) { $icon.removeClass('far fa-bookmark').addClass('fas fa-bookmark'); } } else { console.error('Failed to check collection: ' + result.message); } }, error: function(xhr, status, error) { console.error('AJAX request failed: ' + error); } }); } function addToCollection(userId, title, url, description) { $.ajax({ url: 'inc/hhandler.php', type: 'POST', contentType: 'application/json', data: JSON.stringify({ action: 'add', file: 'curated', userId: userId, title: title, url: url, description: description }), success: function(response) { var result = JSON.parse(response); if (result.status === 'success') { console.log('Added to collection: ' + result.message); } else { console.error('Failed to add to collection: ' + result.message); } }, error: function(xhr, status, error) { console.error('AJAX request failed: ' + error); } }); } function removeFromCollection(userId, url) { $.ajax({ url: 'inc/hhandler.php', type: 'POST', contentType: 'application/json', data: JSON.stringify({ action: 'remove', userId: userId, url: url }), success: function(response) { var result = JSON.parse(response); if (result.status === 'success') { console.log('Removed from collection: ' + result.message); } else { console.error('Failed to remove from collection: ' + result.message); } }, error: function(xhr, status, error) { console.error('AJAX request failed: ' + error); } }); } </script> <script> function addLike(articleId, callback) { $.ajax({ url: 'thumbsUp/handler.php', type: 'POST', data: { action: 'addLike', articleId: articleId, userId: <?= $gUserId ?> }, success: function(response) { if (response === "Ok") { callback(true); } else { console.log("Failed to add like: " + response); callback(false); } }, error: function(xhr, status, error) { console.error('AJAX request failed: ' + error); callback(false); } }); } function removeLike(articleId, callback) { $.ajax({ url: 'thumbsUp/handler.php', type: 'POST', data: { action: 'removeLike', articleId: articleId, userId: <?= $gUserId ?> }, success: function(response) { if (response === "Ok") { callback(true); } else { console.log("Failed to remove like: " + response); callback(false); } }, error: function(xhr, status, error) { console.error('AJAX request failed: ' + error); callback(false); } }); } $(document).ready(function() { // Select all elements with the class 'likeButtonContainer' $('.likeButtonContainer').each(function() { var likeCount = parseInt($(this).find('#likeCount').html(), 10); if (likeCount === 0) { $(this).find('#likeCount').html(''); } }); }); $(document).on('click', '.likeButton', function() { // Preserve the original context var $this = $(this); var likeStatus = $this.find('#thumbsUp'); var articleId = $this.find('#likeData').data('article'); var likeCountHtml = $this.find('#likeCount').html(); var likeCount = likeCountHtml == '' ? 0 : parseInt(likeCountHtml, 10); console.log("count before: " + likeCount); if (likeStatus.hasClass("fa-solid fa-thumbs-up") && (likeCount > 0)) { removeLike(articleId, function(success) { if (success) { likeStatus.removeClass("fa-solid fa-thumbs-up").addClass("fa-regular fa-thumbs-up"); likeCount -= 1; if (likeCount === 0) { likeCount = ''; } $this.find('#likeCount').html(likeCount); } }); } else if (likeStatus.hasClass("fa-regular fa-thumbs-up")) { addLike(articleId, function(success) { if (success) { likeStatus.removeClass("fa-regular fa-thumbs-up").addClass("fa-solid fa-thumbs-up"); likeCount += 1; $this.find('#likeCount').html(likeCount); console.log("count: " + likeCount); } }); } }); </script> <style> .mic-button { transition: transform 0.3s ease; /* Example transition */ } .mic-button:hover { transform: scale(1.1); /* Example transform on hover */ } </style> <script> function showComments(articleId) { const $commentsSection = $('#commentsSection'); var data = "<input id=\"commentArticle\" type=\"hidden\" data-article=\"" + articleId + "\">"; $.ajax({ url: 'process/get.section.curated.php', // URL to the PHP script type: 'POST', // HTTP method data: ({ action: "getComments", articleId: articleId }), success: function(comments) { $commentsSection.html(data); $commentsSection.append(comments); $('#commentModal').modal('show'); }, error: function(xhr, status, error) { console.error('Error fetching comments:', status, error); $('#commentsSection').html('<p>Error loading comments. Please try again later.</p>'); } }); } function sendComment() { var feedId = $("#commentArticle").data('article'); var comment = $('#myComment').val(); $.ajax({ url: 'process/get.section.curated.php', type: 'POST', data: ({ action: "postComment", feedId: feedId, comment: comment }), success: function(response) { showComments(feedId); console.log(response); }, error: function(xhr, status, error) { console.error('Error fetching comments:', status, error); } }); } </script>