View file pages/main/index.php

File size: 1.32Kb
<?

$LinkCheck =  strpos($urlPage, '/main') !== false;
if ($LinkCheck || $urlPage == '/index.php') {
	Redirection('/');
}

$count_max = 27;
$count = $sql->rowCount("SELECT * FROM `news` WHERE `act` = '1'");
$page_num = (!empty($_GET['page']) ? (int) $_GET['page'] : 1); 
$page = page('?page=',  $page_num , $count , $count_max);
$page['count'] = $count;
$page['page_num'] = $page_num;
$page['count_max'] = $count_max;

$PageConfig = [
	'title' => 'Новости '. $system['urlHost'] .', страница №'. $page_num,
	'keywords' => $set['default_keywords'] ,
	'description' => $set['default_description'] ,	
];
PageConfig($PageConfig);

$news = [];
$query = $sql->fetchAll("SELECT * FROM `news` where `act` = '1' ORDER BY `date_public` DESC LIMIT {$page['start']} , {$page['num']};");
foreach ($query AS $p) {
	if (FileSystem::TextStrlen($p['title']) > 79) {
		$p['title'] = FileSystem::TextCut($p['title'] , 80);
	}
	$p['text'] = output($p['text']);
	$news[] = $p;
}
$t->assign('page', $page);
$t->assign('news', $news);
echo $t->fetch('main');


/*
$query = $sql->fetchAll("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 999");
foreach ($query AS $p) {
	$sql->query("UPDATE `news` SET `date_public` = '". (time() + mt_rand(1,999999))."' WHERE `id` = ". $p['id']);
}
UPDATE `news` SET `act` = '1'
*/