PastonBin/feed/rss.class.php

78 lines
1.7 KiB
PHP
Raw Permalink Normal View History

2017-06-17 19:22:17 +02:00
<?php
class rss
{
public $conn;
public function __construct()
{
if(!$this->conn())
{
die('Failed to connect with MySQL');
self::close();
}
}
public function conn()
{
$host = "localhost";
2017-06-17 19:28:26 +02:00
$user = "";
$pass = "";
$name = "";
2017-06-17 19:22:17 +02:00
$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());
}
}
?>