OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
reeliv
/
admin
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
09/04/2024 11:00:16 AM
rwxr-xr-x
📁
assets
-
09/04/2024 10:58:12 AM
rwxr-xr-x
📁
css
-
09/04/2024 10:58:11 AM
rwxr-xr-x
📄
fetch_articles.html
317 bytes
09/04/2024 10:58:07 AM
rw-r--r--
📁
fonts
-
09/04/2024 10:58:08 AM
rwxr-xr-x
📁
images
-
09/04/2024 10:58:09 AM
rwxr-xr-x
📄
index.php
6.04 KB
09/04/2024 10:58:07 AM
rw-r--r--
📁
js
-
09/04/2024 10:58:10 AM
rwxr-xr-x
📄
l2.html
14.08 KB
09/04/2024 10:58:08 AM
rw-r--r--
📄
rss_feed_articles.php
3.19 KB
09/04/2024 10:58:08 AM
rw-r--r--
📄
rss_feed_store.php
3.77 KB
09/04/2024 10:58:08 AM
rw-r--r--
📁
scss
-
09/04/2024 10:58:11 AM
rwxr-xr-x
Editing: rss_feed_articles.php
Close
<?php // Include SimplePie library require_once('/var/www/reader/inc/simplepie/autoloader.php'); // Database connection details $host = '139.59.38.164'; // or your database host $dbname = 'reader'; $username = 'root'; $password = 'newstart'; // Create a mysqli instance for database connection $mysqli = new mysqli($host, $username, $password, $dbname); // Check the connection if ($mysqli->connect_error) { die('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error); } // Fetch RSS feed URLs from the database $sql = 'SELECT rss_id, rss_url FROM rss_feeds_url'; $result = $mysqli->query($sql); // Check if the query was successful if (!$result) { die('Query Error: ' . $mysqli->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 = $mysqli->real_escape_string($item->get_title()); $url = $mysqli->real_escape_string($item->get_permalink()); $description = $mysqli->real_escape_string($item->get_description()); $content = $mysqli->real_escape_string($item->get_content()); $author = $mysqli->real_escape_string($item->get_author() ? $item->get_author()->get_name() : ''); $image = $mysqli->real_escape_string($item->get_enclosure() ? $item->get_enclosure()->get_link() : ''); $date = $mysqli->real_escape_string($item->get_date('Y-m-d H:i:s')); // 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 rss_feeds_articles (feed_id, url, title, description, content, author, image, category, date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'; $stmt = $mysqli->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 $mysqli->close(); echo "Articles Updated Successfully at ". date('Y-m-d H:i:s')."\n";