OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
breader
/
admin
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
11/07/2024 07:55:42 AM
rwxr-xr-x
📁
assets
-
08/15/2024 03:38:36 AM
rwxr-xr-x
📄
bbrss_feed_articles.php
4.58 KB
11/04/2024 12:39:16 PM
rw-r--r--
📁
css
-
08/15/2024 03:38:35 AM
rwxr-xr-x
📄
db_connect.php
261 bytes
11/06/2024 10:21:02 AM
rw-r--r--
📄
eSamudaay_rss_feed_articles.php
4.37 KB
10/01/2024 06:24:41 AM
rw-r--r--
📄
fetch_articles.html
317 bytes
08/15/2024 03:38:31 AM
rw-r--r--
📁
fonts
-
08/15/2024 03:38:32 AM
rwxr-xr-x
📁
images
-
08/15/2024 03:38:33 AM
rwxr-xr-x
📄
index.php
6.04 KB
08/15/2024 03:47:03 AM
rw-r--r--
📁
js
-
09/26/2024 05:03:24 AM
rwxr-xr-x
📄
l2.html
14.08 KB
08/15/2024 03:38:31 AM
rw-r--r--
📄
rss_feed_articles.php
8.54 KB
11/06/2024 10:45:28 AM
rw-r--r--
📄
rss_feed_store.php
3.77 KB
08/15/2024 03:38:31 AM
rw-r--r--
📁
scss
-
08/15/2024 03:38:35 AM
rwxr-xr-x
📄
test4.php
7.03 KB
11/06/2024 11:07:16 AM
rw-r--r--
📄
test5.php
4.6 KB
11/06/2024 10:03:04 AM
rw-r--r--
Editing: eSamudaay_rss_feed_articles.php
Close
<?php // Include SimplePie library // require_once('/var/www/eSamudaay/newUI/inc/vendor/autoload.php'); // include '/var/www/eSamudaay/newUI/inc/db_connect.php'; require_once('/var/www/reader/inc/simplepie/autoloader.php'); // include '../inc/db_connect.php'; // Database configuration $servername = "139.59.41.116"; $username = "root"; $password = "newstart"; $dbname = "esamudaay"; // Create a mysqli instance for database connection $conn = new mysqli($servername, $username, $password, $dbname); // Check the connection if ($conn->connect_error) { die('Connect Error (' . $conn->connect_errno . ') ' . $conn->connect_error); } // Set the character set to UTF-8 if (!$conn->set_charset("utf8mb4")) { die('Error loading character set utf8: ' . $conn->error); } function fetch_html($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $html = curl_exec($ch); curl_close($ch); // echo "<pre>".htmlspecialchars($html)."</pre><br>"; return $html; } function extract_og_image($html) { // Use regex to find the og:image meta tag if (preg_match('/<meta\s+property=["\']?og:image["\']?\s+[^>]*content=["\']([^"\']+)["\']/i', $html, $matches)) { // echo "Image found link: ".$matches[1]."<br>"; return $matches[1]; // Return the URL found } // echo "Image not found !!"; return null; // Return null if no image found } // Fetch RSS feed URLs from the database $sql = 'SELECT rss_id, rss_url FROM article_url'; $result = $conn->query($sql); // Check if the query was successful if (!$result) { die('Query Error: ' . $conn->error); } // Loop through each RSS feed URL while ($row = $result->fetch_assoc()) { $feedUrl = $row['rss_url']; $feedId = $row['rss_id']; // // Initialize SimplePie // $rss = new SimplePie\SimplePie(); // $rss->set_feed_url($feedUrl); // $rss->init(); // $rss->handle_content_type(); // // Disable caching // $rss->enable_cache(false); $rss = new SimplePie(); $rss->set_feed_url($feedUrl); $rss->enable_cache(false); $rss->init(); $rss->handle_content_type(); // Check for errors if ($rss->error()) { echo "Error fetching feed: " . $rss->error(); continue; } // Loop through each item in the RSS feed foreach ($rss->get_items() as $item) { $title = $conn->real_escape_string($item->get_title()); $url = $conn->real_escape_string($item->get_permalink()); $description = $conn->real_escape_string($item->get_description()); $content = $conn->real_escape_string($item->get_content()); $author = $conn->real_escape_string($item->get_author() ? $item->get_author()->get_name() : ''); $image = $conn->real_escape_string($item->get_enclosure() ? $item->get_enclosure()->get_link() : ''); $date = $conn->real_escape_string($item->get_date('Y-m-d H:i:s')); // If image is empty if (empty($image)) { // echo "image is empty!!<br>"; $html = fetch_html($url); $image = extract_og_image($html); } // Process categories $categories = $item->get_categories(); if ($categories && is_array($categories)) { $categoryNames = array_map(function ($cat) { return htmlspecialchars($cat->get_label()); }, $categories); $categoryString = implode(', ', $categoryNames); } else { $categoryString = ''; // Or you can set it to an empty string '' } // Prepare SQL to insert article into the database $sql = 'INSERT IGNORE INTO articles (feed_id, url, title, description, content, author, image, category, date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'; $stmt = $conn->prepare($sql); $stmt->bind_param('issssssis', $feedId, $url, $title, $description, $content, $author, $image, $categoryString, $date); // Execute the query if (!$stmt->execute()) { echo "Error inserting article: " . $stmt->error; } $stmt->close(); } } // Close the database connection $conn->close(); echo "Articles Updated Successfully at ". date('Y-m-d H:i:s')."\n";