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: rss_feed_articles.php
Close
<? ini_set('display_errors', 1); // Display errors on screen (useful for debugging) ini_set('display_startup_errors', 1); error_reporting(E_ALL); // Report all types of errors // require_once('../inc/simplepie/autoloader.php'); require_once('/var/www/reader/inc/simplepie/autoloader.php'); include 'db_connect.php'; function fetchAndInsertRssFeeds($conn) { // Fetch RSS feed URLs from the database $sql = 'SELECT rss_id, rss_url, rss_publisher FROM rss_feeds_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']; $feedPublisher = $row['rss_publisher']; if ($feedPublisher == "Business Standard") { // Set the headers as an associative array $headers = [ 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7', 'Accept-Encoding: gzip, deflate, br, zstd', 'Accept-Language: en-US,en;q=0.9', 'Cache-Control: no-cache', 'Cookie: userUid=1728537242669-a5ca6796-c750-4a1e-b231-df307fea620e; _sid=MTcyODUzNzI0MjY3MC5icTc%3D; _cc_id=7d478f9881d57419250c84b6018df565; _gcl_au=1.1.1122819885.1728537245; _fbp=fb.1.1728537245555.590394025996360652; _ga=GA1.1.10526761.1728537246; WZRK_G=4a5933c8cab7473ba3140082d01d7953; _scor_uid=7f0388954ab348a4bd3d68ce53392684; panoramaId_expiry=1731320137322; panoramaId=8b90c705acaa6abbb51c0094f1ba4945a702bb8a4200481fafbc12babef0864b; panoramaIdType=panoIndiv; _sharedID=c04f607e-cbea-4db0-978d-d7867018f619; _sharedID_cst=zix7LPQsHA%3D%3D; _au_1d=AU1D-0100-001730715345-MFJ2CWIA-BRP0; _col_uuid=0b6160a5-e60c-4f03-a227-c9cd50d26aba-1sjac; __browsiSessionID=56cd45fe-045c-4f4d-9705-b864948193f0&false&DEFAULT&in&desktop-4.33.528&false; __browsiUID=b3963d2d-0474-4ea3-93f3-d47cf959bf6a; cto_bundle=16U0Xl8xNGhOQTY4azF2bXR6dlQyaGNZSE1BVHJRSnQ1bjZPWnh5TlNFWktobnc1SGxTZ3BRbWlKYzlKUGdNeGY2bWpOc3Qwc2pWUGJva01pbmZhQnNKdkp0RGZicXhQMiUyQmY0TWZrRmZZZ2JIJTJGTDJhSWs2Skg4bTg2bmVXeUp2NlFKbyUyQnI1cSUyQjIxVEwxMVhSUnZ2M0hndVlKSTklMkJUWXlTS1ZnQXBla3VCYkVKOE1JeGU5eThHYkdxRm9CbEQlMkJBYmk5UUwzTXRhZzdSSmtWVFQzZWMlMkZiRzREREpleE1vRzFqMEdYaiUyQk1NbWR5Z3QxcyUzRA; _ga_FVWZ0RM4DH=GS1.1.1730782577.3.0.1730782577.60.0.0; __gads=ID=6a23964e97fec96a:T=1728537244:RT=1730782580:S=ALNI_MZYLRNxbAx_y1QY4uc9UF0EYXaF5w; __gpi=UID=00000f3cbeee4b38:T=1728537244:RT=1730782580:S=ALNI_MYThSwlIGyOu6mp1_oesek2JBWN3Q; __eoi=ID=3ee9373ac52cb278:T=1728537244:RT=1730782580:S=AA-AfjaNuBiiRJNoYjzEjQNcHl1e; _ga_KRGL1M61LX=GS1.1.1730781216.5.1.1730782582.55.0.0', 'Pragma: no-cache', 'Priority: u=0, i', 'Sec-CH-UA: "Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"', 'Sec-CH-UA-Mobile: ?1', 'Sec-CH-UA-Platform: "Android"', 'Sec-Fetch-Dest: document', 'Sec-Fetch-Mode: navigate', 'Sec-Fetch-Site: none', 'Sec-Fetch-User: ?1', 'Upgrade-Insecure-Requests: 1', 'User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36' ]; } else { $headers = []; } // Initialize SimplePie $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 for feed " . $feedUrl . " : " . $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() : ''); $date = $conn->real_escape_string($item->get_date('Y-m-d H:i:s')); if ($item->get_enclosure()) { // Enclosure found, escape and assign the image URL $image = $conn->real_escape_string($item->get_enclosure()->get_link()); } else { // If no enclosure, attempt to fetch an image from another source (e.g., via fetch_article_image) $fetched_image = fetch_article_image($url, $headers); if ($fetched_image !== null) { // Fetched image is valid, escape and assign it $image = $conn->real_escape_string($fetched_image); } else { // No fetched image, check for media:thumbnail within media:group $media_groups = $item->get_item_tags('http://search.yahoo.com/mrss/', 'media:group'); if (!empty($media_groups)) { // Check for media:thumbnail tags within the first media:group $media_thumbnails = $item->get_item_tags('http://search.yahoo.com/mrss/', 'media:thumbnail'); if (!empty($media_thumbnails)) { // Use the first media:thumbnail's URL $image = $conn->real_escape_string($media_thumbnails[0]['attribs']['']['url']); } } } } // 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 = $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; } // echo "Inserted Successfully " . $url . "<br>"; $stmt->close(); } } } function fetch_article_image($url, $headers) { // Set up cURL options $ch = curl_init($url); // Set cURL options curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // To return the response as a string curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // To follow redirects if (!empty($headers)) { curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // Add the headers to the request } curl_setopt($ch, CURLOPT_ENCODING, "gzip"); // Handle gzip encoding (if any) // Execute the cURL request $response = curl_exec($ch); // Check for errors if (curl_errno($ch)) { echo 'cURL Error: ' . curl_error($ch); curl_close($ch); return null; } // Check HTTP status code $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($http_code != 200) { echo "Error: HTTP status code " . $http_code; curl_close($ch); return null; } // Parse the HTML to extract the og:image URL preg_match('/<meta property="og:image" content="([^"]+)"/', $response, $matches); // Check if og:image meta tag was found if (isset($matches[1])) { // Return the image URL from the content attribute $image_url = $matches[1]; curl_close($ch); return $image_url; } else { echo "No og:image meta tag found."; curl_close($ch); return null; } } fetchAndInsertRssFeeds($conn); echo "Articles Updated Successfully at " . date('Y-m-d H:i:s') . "\n";