<?
//подключение новостей
mysqli_set_charset($link, 'utf8');
$sql = mysqli_query($link, 'SELECT `id`, `name`, `title`, `content`, `created_at` FROM `news` ORDER BY created_at DESC LIMIT 4');
while ($result = mysqli_fetch_array($sql))
{
if(strlen($result['content'])>$numchar) $srttmpend = "...";
echo "<div class='news-item'><img class='news-img' src='/images/news_img_1.png'><div class='news-area'><div class='date'>{$result['created_at']}</div>";
echo "<a target='_blank' href=news/".$result['name'].".html class='title'>{$result['title']}</a>";
echo "<div class='text'>".substr($result['content'], 0, $numchar).$srttmpend;
echo "</div></div></div>";
}
?>
<?php
if (!file_exists(dirname(__FILE__) . '/system.php')) {
echo '<pre>';
echo 'Ошибка! Файл system.php не найден!';
echo '</pre>';
die;
}
define('TKM', true);
require_once dirname(__FILE__) . '/system.php';
if (!$config['main']['installed']) {
header('Location: install.php');
die;
}
if (isset($_GET['pstatus'])) {
switch ($_GET['pstatus']) {
case 'success':
MessageSend(3, 'Оплата успешно завершена, спасибо за покупку!', 'index.php');
break;
case 'waiting':
MessageSend(2, 'Оплата не завершена, ожидание платежа...', 'index.php');
break;
case 'fail':
MessageSend(1, 'Платёж отменён.', 'index.php');
break;
}
}
$pageData = [
// Admin button link in navigation menu
'adminButton' => isset($_SESSION['authsession']) ? '<li><a href="cpanel.php">Админ-панель</a></li>' : '',
// Modules blocks
'lastNews' => false,
'hideLastNews' => false,
'lastBuyers' => false,
'hideLastBuyers' => false,
'advert' => false,
'hideAdvert' => false,
'content' => false,
// Links on page (header|footer)
'links' => [
'footer' => false,
'header' => false,
],
];
// Fill links
foreach ($config['links'] as $links) {
if ($links['footer'] === true) {
$pageData['links']['footer'] .= loadTpl('/links/footer.html', $links);
} else {
$pageData['links']['header'] .= loadTpl('/links/header.html', $links);
}
}
if (@$config['main']['last_news'] === true && $pageData['hideLastNews'] === false) {
$lastNewsList = false;
$NewsQuery = $link->query("SELECT `id`, `name`, `title`, `content`, `created_at` FROM `mcraft_news` ORDER BY created_at DESC LIMIT 4");
while ($newsItem = $NewsQuery->fetch()) {
$lastNewsList .= loadTpl('/last_news/news.html', $newsItem);
}
if (empty($lastNewsList)) {
$data = loadTpl("/last_news/none.html");
} else {
$data = $lastNewsList;
}
$pageData['lastNews'] = loadTpl("/last_news/parent.html", $data);
}
$page = 'main';
if (!empty($_GET['mod']) && $mod = $_GET['mod']) {
$modFile = LD_ROOT_DIR . '/pages/' . $mod . '.php';
if (file_exists($modFile)) {
$page = $mod;
}
}
ob_start();
include(LD_ROOT_DIR . '/pages/' . $page . '.php');
$pageData['content'] = ob_get_clean();
if (@$config['main']['last_buyers'] === true && $pageData['hideLastBuyers'] === false)
{
$lastBuyerList = false;
$buyersQuery = $link->query("SELECT `username`, `data`, `time` FROM `AD_PAYMENTS` WHERE `status` = '1' ORDER BY `time` DESC LIMIT 6");
while ($buyer = $buyersQuery->fetch())
{
$goods_name = json_decode($buyer['data'], true)['goods_name'];
$lastBuyerList .= loadTpl("/last_buyers/buyer.html", [
'buyer' => $buyer,
'name' => $goods_name,
]);
}
if (empty($lastBuyerList)) {
$data = loadTpl("/last_buyers/none.html");
} else {
$data = $lastBuyerList;
}
$pageData['lastBuyers'] = loadTpl("/last_buyers/parent.html", $data);
}
echo loadTpl('/index.html', $pageData);
if (@$config['main']['last_news'] === true && $pageData['hideLastNews'] === false) {
$lastNewsList = false;
$NewsQuery = $link->query("SELECT `id`, `name`, `title`, `content`, `created_at` FROM `mcraft_news` ORDER BY created_at DESC LIMIT 4");
while ($newsItem = $NewsQuery->fetch()) {
$lastNewsList .= loadTpl('/last_news/news.html', $newsItem);
}
if (empty($lastNewsList)) {
$data = loadTpl("/last_news/none.html");
} else {
$data = $lastNewsList;
}
$pageData['lastNews'] = loadTpl("/last_news/parent.html", $data);
}
// Setting advert block (if isset)
if (!empty($config['advert']['text']) && $advertData = $config['advert']) {
$advertData['button'] = false;
if (!empty($advertData['button_name'])) {
$advertData['button'] = loadTpl('/advert_button.html', $advertData);
}
$pageData['advert'] = loadTpl('/advert.html', $advertData);
}
<?php echo $data["created_at"] ?></div>
<?php echo $data['title'] ?>
<?php echo $data['content'] ?>
<?php
include 'safemysql.class.php';
$db = new safeMysql();
$per_page = 10;
//получаем номер страницы и значение для лимита
$cur_page = 1;
if (isset($_GET['page']) && $_GET['page'] > 0)
{
$cur_page = $_GET['page'];
}
$start = ($cur_page - 1) * $per_page;
//выполняем запрос и получаем данные для вывода
$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM mcraft_news ORDER BY created_at DESC LIMIT ?i, ?i";
$data = $db->getAll($sql, $start, $per_page);
$rows = $db->getOne("SELECT FOUND_ROWS()");
//узнаем общее количество страниц и заполняем массив со ссылками
$num_pages = ceil($rows / $per_page);
// зададим переменную, которую будем использовать для вывода номеров страниц
$page = 0;
//а дальше выводим в шаблоне днные и навигацию:
?>
Найдено сообщений: <b><?=$rows?></b><br><br>
<? foreach ($data as $row): ?>
<a href="?id=<?=$row['id']?>"><?=$row['title']?><?=$row['content']?></a><br>
<? endforeach ?>
<br>
Страницы:
<? while ($page++ < $num_pages): ?>
<? if ($page == $cur_page): ?>
<b><?=$page?></b>
<? else: ?>
<a href="?page=<?=$page?>"><?=$page?></a>
<? endif ?>
<? endwhile ?>
<a href="?id=<?=$row['id']?>">
вывести полную новость по id?