PastonBin/feed/rss.class.php

78 lines
1.7 KiB
PHP

<?php
class rss
{
public $conn;
public function __construct()
{
if(!$this->conn())
{
die('Failed to connect with MySQL');
self::close();
}
}
public function conn()
{
$host = "localhost";
$user = "";
$pass = "";
$name = "";
$conn = mysqli_connect($host,$user,$pass,$name);
if (mysqli_connect_errno())
{
die("Failed to connect with MySQL: ".mysqli_connect_error());
}
else
{
return $this->conn = $conn;
}
}
public function head($title,$content,$siteurl)
{
echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
echo '<channel>';
echo '<title>'.$title.'</title>';
echo '<link>'.$siteurl.'</link>';
echo '<image><url>https://pastebin.echosystem.fr/theme/blue/img/favicon.ico</url><link>https://pastebin.echosystem.fr</link></image>';
echo '<description>'.$content.'</description>';
echo '<language>en-us</language>';
//echo '<atom:link href="'.$siteurl.'/feed/rss.xml" rel="self" type="application/rss+xml"/>';
echo '<atom:link href="https://pastebin.echosystem.fr/feed/rss.xml" rel="self" type="application/rss+xml"/>';
}
//public function feed($title,$url,$content,$publish)
//$date= date('d M Y H:i:s', $row['now_time']);
//$date2=date("D, d M Y H:i:s", strtotime($date));
public function feed($title,$url,$content,$now_time)
{
echo '
<item>
<title>'.$title.'</title>
<link>'.$url.'</link>
<description>'.$content.'</description>
<pubDate>'.$now_time.'</pubDate>
</item>
';
}
public function foot()
{
echo '</channel>';
echo '</rss>';
}
public function clean($string) {
$string = strtolower( preg_replace('@[\W_]+@', '-', $string) );
$string = rtrim($string,'-');
$string = strtolower($string);
return $string;
}
public function close()
{
mysqli_close(self::conn());
}
}
?>