<?php
$dir='./news/';
$app[feed][config][newslimit]=5;
$app[feed][title]='Блог';
$app[server][host]=$_SERVER[HTTP_HOST];
$app[server][get]=$_GET;
$app[system][quotestart]='<div class="quote">'."\n";
$app[system][quotestop]='</div>'."\n";
function panelbar($name=false, $variable=false, $right=false, $nocut=false, $html=false){
global $app;
if(strlen($variable) > 55 & !$nocut){
$variable=substr($variable, 0, 55);
$variable.="...";
}
if(!$html){
$variable=htmlspecialchars($variable);
$variable=str_replace("\n", "<br>", $variable);
}
$return='<div class="frame">'."\n";
if($right){
$return.='<div class="onestr, clearfix">
<div class="leftstr">'.$name.'</div>
<div class="rightstr">'.$right."</div>
</div>\n";
}else
$return.=$name."<br>\n";
$return.=$app[system][quotestart].$variable.$app[system][quotestop]."\n";
$return.="</div>\n";
return $return;
}
$page=(float)$app[server][get][page];
if(!$page or $page<1) $page=1;
if($page>1)
$app[feed][display].=panelbar('<a href="http://'.$app[server][host].'/?page='.($page-1).'">Предыдущие ></a>').'<br>';
$i=(count(scandir($dir))-2);
$i-=(($page-1)*$app[feed][config][newslimit]);
$a=($i-$app[feed][config][newslimit]);
while(true){
if($i<=$a or !file_exists($dir.$i)) break;
list($name, $date, $preview, $text)=explode("\n", file_get_contents($dir.$i));
$app[feed][display].=panelbar('<h1>'.$name.'</h1>', $preview, $date, true, true);
$app[feed][display].=panelbar('<a href="http://'.$app[server][host].'/?id='.$i.'">Просмотреть полностью</a>', '');
$app[feed][display].='<br>';
$i--;
}
if(file_exists($dir.($i-1)))
$app[feed][display].=panelbar('<a href="http://'.$app[server][host].'/?page='.($page+1).'">Следующие ></a>');
if($app[server][get][id]){
list($name, $date, $preview, $text)=explode("\n", file_get_contents($dir.(float)$app[server][get][id]));
$app[feed][title]=$name.' - '.$app[feed][title];
$app[feed][description]=strip_tags($preview);
$app[feed][display]=panelbar('<h1>'.$name.'</h1>', $text, $date, true, true);
$app[feed][display].=panelbar('Поделиться', '', '<script type="text/javascript" src="//yastatic.net/share/share.js" charset="utf-8"></script><div class="yashare-auto-init" data-yashareL10n="ru" data-yashareType="small" data-yashareQuickServices="vkontakte,facebook,twitter,odnoklassniki,moimir,lj,gplus" data-yashareTheme="counter"></div>', true, true);
}
if(!$app[feed][display])
$app[feed][display]='Нет новостей.';
$page='feed';
?><!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, user-scalable=no">
<link rel="icon" href="http://<?=$app[server][host]?>/favicon.ico">
<meta name="description" content="<?=$app[feed][description]?>">
<meta charset="utf-8">
<meta name="Document-state" content="Dynamic">
<meta name="revisit-after" content="3 days">
<title><?=$app[$page][title]?></title>
<style>
@import url(https://fonts.googleapis.com/css?family=Roboto:400,300,700&subset=latin,cyrillic);
*{
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body{
font-weight: 400;
font-family: 'Roboto', sans-serif;
font-size: 16px;
line-height: 23px;
word-wrap: break-word;
margin: 0;
}
h1{
color: #08f;
font-size: 22px;
margin: 0;
margin-bottom: 4px;
}
h1, h2, h3, h4, h5{ font-weight: 300; }
a{
margin: 0;
color: #08f;
text-decoration: none;
}
a:hover{ color: #058; }
.button{
white-space: nowrap;
margin: 0;
margin-top: 1px;
border: 1px solid #08f;
background: #08f;
padding: 9px;
color: #fff !important;
text-decoration: none !important;
}
a[class="button"]{
line-height: 48px !important;
}
.button:hover{
background: #06d;
}
.frame{
border: 1px solid #ddd;
padding: 8px;
padding-top: 7px;
}
.header{
position: fixed;
left: 0;
top: 0;
font-weight: 400;
font-size: 16px;
color: #ffffff;
width: 100%;
background-color: rgba(20, 20, 20, 0.7);
padding: 16px;
padding-left: 32px;
text-align: center;
}
.fat{
display: inline-block;
width: 100%;
max-width: 800px;
font-weight: 700;
font-size: 26px;
text-align: left;
color: #ffffff !important;
}
.block{
max-width: 800px;
text-align: left;
width: 100%;
height: 100%;
padding: 16px;
padding-top: 68px;
padding-bottom: 68px;
}
.onestr{
display: inline-block;
float: left;
width: 100%;
}
.leftstr, .rightstr{
float: left;
display: inline-block;
margin: 0;
padding: 0;
}
.rightstr{
margin-left: 5px;
float: right;
}
.clearfix{
*zoom: 1;
}
.clearfix:after{
content: "";
display: table;
clear: both;
}
.quote{
vertical-align: text-top;
line-height: 22px;
border-left: 4px solid #08f;
padding-left: 5px;
margin: 0;
text-align: left;
display: block;
}
</style>
</head>
<body>
<div class="header">
<a class="fat" href="http://<?=$app[server][host]?>">Blog</a>
</div>
<center>
<div class="block">
<?=$app[$page][display]?>
</div>
</center>
</body>
</html>