Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
<?php
$mydb = mysql_connect(localhost,root,);
if(!mydb) die("<hr />Keine Verbindung zu MYSQL!<hr />");
mysql_select_db(nbz,$mydb) or die("<hr />Keine Verbindung zur Datenbank: nbz!<hr />");
?>
<?php
/*
rss2.class.php
Version 1.0
Part of the PHP class collection
http://www.sourceforge.net/projects/php-classes/
Written by: Dennis Wronka
License: LGPL
*/
$timestamp = time();
$t = date("j");
$m = date("n");
$j = date("Y");
$bday = "SELECT * FROM kalender WHERE tag=$t and monat=$m ORDER BY nachname ASC" ;
$birthday = mysql_query($bday);
if(mysql_num_rows($birthday) == 0){
echo "<item><title>Heute hat kein Mitarbeiter Geburtstag!</title></item>";}
else {
while($row = mysql_fetch_object($birthday)){
$title = $row -> titel;
$vorname = $row -> vorname;
$nachname = $row -> nachname;
$jahr = $row -> jahr;
$bild = $row -> bild;
$alter = $j-$jahr ;
}
}
class rss2
{
private $title;
private $link;
private $description;
private $language;
private $generator;
private $ttl;
private $sendheader;
private $items;
public function __construct($title,$link,$description='',$language='en',$generator='PHP/ReptilerRSS2Class',$ttl=60,$sendheader=true)
{
$this->title=$title;
$this->link=$link;
$this->description=$description;
$this->language=$language;
$this->generator=$generator;
$this->ttl=$ttl;
$this->sendheader=$sendheader;
$this->items=array();
}
public function additem($title,$description,$content,$url='',$pubdate='',$domain='',$category='',$author='')
{
$this->items[]=array('title'=>$title,'url'=>$url,'pubdate'=>$pubdate,'description'=>$description,'content'=>$content,'domain'=>$domain,'category'=>$category,'author'=>$author);
}
public function getfeed()
{
$feed='<?xml version="1.0" encoding="ISO-8859-1"?>';
$feed.='<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">';
$feed.='<channel>';
$feed.='<title>'.$this->title.'</title>';
$feed.='<link>'.$this->link.'</link>';
if (!empty($this->description))
{
$feed.='<description>'.$this->description.'</description>';
}
if (!empty($this->language))
{
$feed.='<language>'.$this->language.'</language>';
}
$feed.='<lastBuildDate>'.date('D, d M Y H:i:s T',time()).'</lastBuildDate>';
if (!empty($this->generator))
{
$feed.='<generator>'.$this->generator.'</generator>';
}
if (!empty($this->ttl))
{
$feed.='<ttl>'.$this->ttl.'</ttl>';
}
for ($x=0;$x<count($this->items);$x++)
{
$feed.='<item>';
$feed.='<title>'.$this->items[$x]['title'].'</title>';
$feed.='<link>'.$this->items[$x]['url'].'</link>';
if (!empty($this->items[$x]['pubdate']))
{
$feed.='<pubDate>'.$this->items[$x]['pubdate'].'</pubDate>';
}
$feed.='<description>'.$this->items[$x]['description'].'</description>';
$feed.='<content:encoded><![CDATA['.$this->items[$x]['content'].']]></content:encoded>';
if ((!empty($this->items[$x]['domain'])) && (!empty($this->items[$x]['category'])))
{
$feed.='<category domain="'.$this->items[$x]['domain'].'">'.$this->items[$x]['category'].'</category>';
}
if (!empty($this->items[$x]['author']))
{
$feed.='<author>'.$this->items[$x]['author'].'</author>';
}
$feed.='</item>';
}
$feed.='</channel>';
$feed.='</rss>';
return $feed;
}
public function output()
{
if ($this->sendheader==true)
{
header('Content-Type: application/rss+xml');
}
echo $this->getfeed();
}
}
?>
<?php
require('../classes/rss2.class.php');
$feed=new rss2('TestFeed','http://localhost/classtest/rss2feed.php');
$feed->additem('TestItem1','Only a test - Part 1','This is only a test.');
$feed->additem('TestItem2','Only a test - Part 2','Also this is only a test.');
$feed->additem('TestItem3','Only a test - Part 3','Yes, right. Just another test.');
$feed->output();
unset($feed);
?>