<?php
$news_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `news`"),0);
$user_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `user`"),0);
$user_countn = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `time_reg` > ". (time()-43200) .""),0);
$user_on = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `time_last` > ". (time()-600) .""), 0);
?>
<div class="card"><div class="card__header">
<h2>Наши услуги<small>Закажи и для себя чего-нибудь)</small></h2> </div>

<div class="list-group">
                            <a href="/scripts/tarifs.php?dir=1" class="list-group-item media">
                                <div class="pull-left">
                                    <img class="avatar-img" src="/avatar/noavatar.png" alt="">
                                </div>

                                <div class="media-body">
                                    <div class="list-group__heading">Виртуальный хостинг</div>
                                    <small class="list-group__text">Создай свой сайт на PHP</small>
                                </div>
                            </a>

                           </div>
                    </div>


<div class="card widget-contacts">					
<? $query = mysql_query("SELECT * FROM `news` WHERE `time` > '". (time()-60 * 60 * 24 * 30) ."' ORDER BY `time` DESC LIMIT 1");
while ($newsone = mysql_fetch_assoc($query)){

$k_komm = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_comments` WHERE `news_id` = '$newsone[id]'"),0);
$knew_komm = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_comments` WHERE `news_id` = '$newsone[id]' AND `time` > ". (time()-86400) .""),0);

if (string($newsone['txt']) <= 500) $news_msg = output($newsone['txt']);
else $news_msg = output(cut($newsone['txt'], 500)) .'... <a href="/scripts/news.php?komm='.$newsone['id'].'" title="Читать дальше"><b>»</b></a>';

echo '<div class="post">';
echo ' <div class="card__header card__header--highlight">
<h2>'.htmlspecialchars($newsone['name']).'<small>'.ptime($newsone['time']).' </small></h2></div>
                        <div class="card__body"> '.$news_msg.''; 

echo '<br><a href="/scripts/news.php?komm='.$newsone['id'].'">Комментарии</a> ['.$k_komm.''.($knew_komm > 0? ' / <font color="red">+'.$knew_komm.'</font>' : '').']';
echo '</div></div>';
} ?>
			</div>


		</div>

