• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.
  • Chevereto Support CLST

    Support response

    Support checklist

    • ⚠️ Got a Something went wrong message? Read this guide and provide the actual error. Do not skip this.
    • ✅ Confirm that the server meets the System Requirements
    • 🔥 Check for any available Hotfix - your issue could be already reported/fixed
    • 📚 Read documentation - It will be required to Debug and understand Errors for a faster support response

Need help finishing: RSS Feeds

sonontse

Chevereto Member
Hey Rodolfo,

I got most of the RSS feed information pulled from my SQL table. I am however stuck on getting the image link since I am not familiar with G and the image page link is not in the database. Can you please help with the image link that gives a link to the image page? Thanks.

RSS.class.php
PHP:
<?php

class RSS
{
public function RSS()
{
DEFINE ('SITE_TITLE', 'Cheverto');
DEFINE ('SITE_DESCRIPTION', 'Cheverto Hosting Script');
DEFINE ('SITE_URL', 'http://www.cheverto.com');
}

public function GetFeed()
{
return $this->getItems();
}

private function dbConnect()
{
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', 'password');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'cheverto');
DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD));
}


private function getItems()
{

$items = '';
$items .= '<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<description>'. SITE_DESCRIPTION. '</description>
<title>'. SITE_TITLE. '</title>
<link>'. SITE_URL .'/explore/</link>';

$itemsTable = "chv_images";
$this->dbConnect($itemsTable);
$query = "SELECT * FROM chv_images ORDER BY image_id DESC LIMIT 50";
mysql_query("SET NAMES 'utf8'", LINK);
$result = mysql_db_query (DB_NAME, $query, LINK);
while($row = mysql_fetch_array($result))
{
$d = $row["image_date_gmt"];
$items .= '
<item>
<title>'. $row["image_description"] .'</title>
<description>
&lt;img src="'. SITE_URL .'/images/'. $row["image_name"] .'.md.'. $row["image_extension"] .'"/&gt;
</description>
<pubDate>'. gmdate(DATE_RSS, strtotime($d)) .'</pubDate>
<link></link>
<guid></guid>
</item>';
}
$items .= '</channel>
</rss>';
return $items;
}

}

?>

rss.php
PHP:
<?php
header("Content-Type: application/xml; charset=UTF-8");
include("RSS.class.php");
$rss = new RSS();
echo $rss->GetFeed();
?>
 
Last edited:
There are several baddies in your code. For instance, you are connecting to the database and having trouble to get the image info because you are doing the code from scratch. You should use the routes override and create your own route.rss.php file and use all the functions of the CHV and G namespace.

More info here: http://chevereto.com/docs/routes

Also, you should cache the rss to an static file. Is just insane to run it on the fly.
 
Get the public ID and viewer is quite easy... But you need to rely on the system libraries, if you do it on your own you will need to code a lot of stuff.

PHP:
$id_encoded = CHV\encodeID($id);
$viewer_url = CHV\Image::getUrlViewer($id_encoded);
 
Last edited:
Back
Top