71 lines
1.3 KiB
Plaintext
71 lines
1.3 KiB
Plaintext
<?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 = "paste";
|
|
$pass = "no*aksp1";
|
|
$name = "paste";
|
|
$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 xmlns:atom="http://www.w3.org/2005/Atom">';
|
|
echo '<channel>';
|
|
echo '<title>'.$title.'</title>';
|
|
echo '<link>'.$siteurl.'</link>';
|
|
echo '<description>'.$content.'</description>';
|
|
echo '<language>en-us</language>';
|
|
echo '<atom:link href="'.$siteurl.'/rss.xml" rel="self" type="application/rss+xml"/>';
|
|
|
|
}
|
|
public function feed($member,$url,$content,$publish)
|
|
{
|
|
echo '
|
|
<item>
|
|
<title>'.$member.'</title>
|
|
<link>'.$url.'</link>
|
|
<description>'.$content.'</description>
|
|
<pubDate>'.$publish.'</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());
|
|
}
|
|
}
|
|
|
|
?>
|