INIT
This commit is contained in:
155
index.php
Executable file
155
index.php
Executable file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
$months = array("1" => "Januar", "2" => "Februar", "3" => "März", "4" => "April", "5" => "Mai", "6" => "Juni", "7" => "Juli", "8" => "August", "9" => "September", "10" => "Oktober", "11" => "November", "12" => "Dezember");
|
||||
|
||||
$url = "http://preetzer-ruderclub.de/wordpress/feed/";
|
||||
|
||||
$xmlString = file_get_contents($url);
|
||||
$xmlString = str_replace("<content:encoded>", "<content>", $xmlString); //make element accessable for simplexml
|
||||
$xmlString = str_replace("</content:encoded>", "</content>", $xmlString);
|
||||
$xmlString = str_replace("http:", "https:", $xmlString); //security fix
|
||||
|
||||
// Feed einlesen
|
||||
if( !$xml = simplexml_load_string($xmlString, null, LIBXML_NOCDATA)) {
|
||||
echo '<h2>Fehler beim lesen des RSS-Feeds!</h2>';
|
||||
}
|
||||
|
||||
// Items vorhanden?
|
||||
if( !isset($xml->channel[0]->item) ) {
|
||||
echo '<h2>Keine Einträge gefunden.</h2>';
|
||||
}
|
||||
|
||||
$title = "";
|
||||
$image = "";
|
||||
if(isset($xml->channel->image)){
|
||||
$title = $xml->channel->image->title;
|
||||
$image = $xml->channel->image->url;
|
||||
}
|
||||
|
||||
// Item holen
|
||||
$request = explode("/", $_SERVER["REQUEST_URI"]);
|
||||
$id = empty($request[1]) ? 0 : $request[1];
|
||||
|
||||
foreach($xml->channel[0]->item as $item){
|
||||
$feed[] = array(
|
||||
"title" => (string) $item->title,
|
||||
"content" => (string) $item->content,
|
||||
"link" => (string) $item->guid,
|
||||
"date" => strtotime((string) $item->pubDate),
|
||||
);
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<!--
|
||||
Striped by HTML5 UP
|
||||
html5up.net | @ajlkn
|
||||
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo $title; ?></title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<!--[if lte IE 8]><script src="assets/js/ie/html5shiv.js"></script><![endif]-->
|
||||
<link rel="stylesheet" href="assets/css/main.css" />
|
||||
<!--[if lte IE 8]><link rel="stylesheet" href="assets/css/ie8.css" /><![endif]-->
|
||||
|
||||
<!-- Add to homescreen for Chrome on Android -->
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<link rel="icon" sizes="192x192" href="<?php echo $image; ?>">
|
||||
|
||||
<!-- Add to homescreen for Safari on iOS -->
|
||||
<meta name="apple-mobile-web-app-title" content="Push Messaging and Notifications Sample">
|
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" href="<?php echo $image; ?>">
|
||||
<link rel="apple-touch-startup-image" href="<?php echo $image; ?>" >
|
||||
|
||||
<!-- Tile icon for Win8 (144x144 + tile color) -->
|
||||
<meta name="msapplication-TileImage" content="<?php echo $image; ?>">
|
||||
<meta name="msapplication-TileColor" content="#3372DF">
|
||||
|
||||
<link rel="icon" href="<?php echo $image; ?>">
|
||||
|
||||
<!-- Include manifest file in the page -->
|
||||
<link rel="manifest" href="manifest.json">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Content -->
|
||||
<div id="content">
|
||||
<div class="inner">
|
||||
<?php if(array_key_exists($id, $feed)){ ?>
|
||||
<article class="box post post-excerpt">
|
||||
<header>
|
||||
<h2><a href="<?php echo $feed[$id]['link']; ?>"><?php echo $feed[$id]['title']; ?></a></h2>
|
||||
</header>
|
||||
<div class="info">
|
||||
<span class="date">
|
||||
<?php
|
||||
$day_short = substr($months[date('n', $feed[$id]['date'])], 0, 3);
|
||||
$day_end = str_replace($day_short, "", $months[date('n', $feed[$id]['date'])]);
|
||||
?>
|
||||
<span class="month"><?php echo $day_short; ?><span><?php echo $day_end; ?></span></span>
|
||||
<span class="day"><?php echo date('j', $feed[$id]['date']); ?></span>
|
||||
<span class="year">, <?php echo date('Y', $feed[$id]['date']); ?></span>
|
||||
</span>
|
||||
</div>
|
||||
<?php echo $feed[$id]['content']; ?>
|
||||
</article>
|
||||
|
||||
<?php
|
||||
}else{
|
||||
echo '<h2>Eintrag wurde nicht gefunden!</h2>';
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Pagination -->
|
||||
<div class="pagination">
|
||||
<?php
|
||||
|
||||
if($id > 0){
|
||||
echo '<a href="/'.($id - 1).'" class="button previous">Vorheriger Artikel</a>';
|
||||
}
|
||||
if($id < count($feed) - 1){
|
||||
echo '<a href="/'.($id + 1).'" class="button next" style="margin-left: 10px;">Nächster Artikel</a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sidebar -->
|
||||
<div id="sidebar">
|
||||
|
||||
<!-- Logo -->
|
||||
<h1 id="logo"><a href="/">PRC</a></h1>
|
||||
|
||||
<!-- Nav -->
|
||||
<nav id="nav">
|
||||
<ul>
|
||||
<?php
|
||||
for($i=0; $i < count($feed); $i++){
|
||||
echo '<li'.($i == $id? ' class="current"' : '').'><a href="/'.$i.'">'.$feed[$i]['title'].'</a></li>';
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<!-- Copyright -->
|
||||
<ul id="copyright">
|
||||
<li>© <?php echo $title; ?>.</li><li>Design: <a href="http://html5up.net">HTML5 UP</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="assets/js/jquery.min.js"></script>
|
||||
<script src="assets/js/skel.min.js"></script>
|
||||
<script src="assets/js/util.js"></script>
|
||||
<!--[if lte IE 8]><script src="assets/js/ie/respond.min.js"></script><![endif]-->
|
||||
<script src="assets/js/main.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user