$query = "
SELECT
COUNT(*)
FROM
" . $CFG["DB_INC"] . "materials MT
WHERE
(
MT.author_id = '" . mysqli_real_escape_string($link, $_GET["id"]) . "'
OR MT.author1_id = '" . mysqli_real_escape_string($link, $_GET["id"]) . "'
OR MT.author2_id = '" . mysqli_real_escape_string($link, $_GET["id"]) . "'
)
AND MT.published = '1'
AND MT.deleted <> '1'
";
$result = db_query($link, $query);
$row = mysqli_fetch_row($result);
$total = $row[0];
mysqli_free_result($result);
$CFG['NEWS_PER_PAGE'] = 15;
$query = "
SELECT
MT.id
,DATE_FORMAT(MT.dt_publish, '%d.%m.%Y') AS d
,DATE_FORMAT(MT.dt_publish, '%H:%i') AS t
,MT.title
,MT.subtitle
,MT.anons
,MT.image_small
,MT.increment_for_small
,MT.image_title
,MT.type
,MT.exclusive
,MT.author_id
,MT.author1_id
,MT.author2_id
,MT.super_counter
,A.fname AS a_fname
,A.lname AS a_lname
,A1.fname AS a1_fname
,A1.lname AS a1_lname
,A2.fname AS a2_fname
,A2.lname AS a2_lname
FROM
" . $CFG["DB_INC"] . "materials MT use index(dt_publish)
LEFT JOIN
" . $CFG["DB_INC"] . "authors A
ON
MT.author_id = A.id
LEFT JOIN
" . $CFG["DB_INC"] . "authors A1
ON
MT.author1_id = A1.id
LEFT JOIN
" . $CFG["DB_INC"] . "authors A2
ON
MT.author2_id = A2.id
WHERE
(
MT.author_id = '" . mysqli_real_escape_string($link, $_GET["id"]) . "'
OR MT.author1_id = '" . mysqli_real_escape_string($link, $_GET["id"]) . "'
OR MT.author2_id = '" . mysqli_real_escape_string($link, $_GET["id"]) . "'
)
AND MT.published = 1
AND MT.deleted = 0
ORDER BY
MT.dt_publish DESC
LIMIT " . ($page-1) * $CFG['NEWS_PER_PAGE'] . ", " . $CFG['NEWS_PER_PAGE'];
$result_section = db_query($link, $query);
$rows_section = mysqli_num_rows($result_section);
if ($rows_section != 0) {
for ($h = 0; $h < $rows_section; $h++) {
$row_section = mysqli_fetch_assoc($result_section);
$material_id = $row_section["id"];
$d = $row_section["d"];
$t = $row_section["t"];
$title = $row_section["title"];
$subtitle = $row_section["subtitle"];
$anons = $row_section["anons"];
$image_small = $row_section["image_small"];
$increment_for_small = $row_section["increment_for_small"];
$image_title = $row_section["image_title"];
$MT = $row_section["type"];
$counter = $row_section["super_counter"];
$author_id = $row_section["author_id"];
$author1_id = $row_section["author1_id"];
$author2_id = $row_section["author2_id"];
$author = $row_section["a_fname"] . " " . $row_section["a_lname"];
$author1 = $row_section["a1_fname"] . " " . $row_section["a1_lname"];
$author2 = $row_section["a2_fname"] . " " . $row_section["a2_lname"];
$print_ico = ( $row_section["exclusive"] ? ' ' . $CFG['EXCLUSIVE_ICO'] : '' );
if (!$h){
?>
$query = "
SELECT
FR.material_id
,DATE_FORMAT(MT.dt_publish, '%d.%m.%Y')
,DATE_FORMAT(MT.dt_publish, '%H:%i')
,MT.subtitle
,MT.exclusive
,TIMESTAMPDIFF(MINUTE,MT.dt_update,NOW())
,DATE_FORMAT(MT.dt_publish, '%e')
,FR.type
FROM
" . $CFG["DB_INC"] . "front FR
LEFT JOIN
" . $CFG["DB_INC"] . "materials MT use index(dt_publish)
ON
FR.material_id = MT.id
WHERE
FR.material_id <> '" . mysqli_real_escape_string($link, $_GET["id"]) . "'
AND FR.type IN ('MAIN','OTHER')
AND MT.published = 1
AND MT.deleted = 0
ORDER BY
MT.dt_publish DESC
LIMIT 10";
$result = db_query($link, $query);
$rows = mysqli_num_rows($result);
if ($rows != 0) {
for ($i = 0; $i < $rows; $i++) {
$row = mysqli_fetch_row($result);
if ($row[5] > 59) $pass_time = 0; else $pass_time = $row[5]+1;
$print_ico = '';
if ($row[4]) $print_ico .= ' ' . $CFG['EXCLUSIVE_ICO'];
if ((int)$row[6] == (int)date('j',time()) || $row[7] == 'MAIN'){
$dt_news = $row[2];
}else{
$dt_news = $row[2] . ' ' . $row[1] . '';
}
if ($row[7] == 'MAIN'){
?>
Новость дня
}
?>
if ($row[7] == 'MAIN'){
?>
}
if ($i && ($i+1)%5 == 0 && isset($adv_print[1][++$adv_count]['text'])){
?>
}
mysqli_free_result($result);
}
if($h < 5){
if(!$h){
$adv_count = 0;
if(isset($adv_print[2][++$adv_count]['text'])){
?>
}
?>
Материалы
}
if ($h > 0) {
?>
}
?>
- 3
if ($MT > 3){
?>
//li class="conmmentsIco">13
}
?>
if ($author_id != ''){
?>
Автор:
}
?>
}
if($h >= 5){
if($h == 5 && isset($adv_print[2][++$adv_count]['text'])){
?>
}
?>
- 3
if ($MT > 3){
?>
//li class="conmmentsIco">13
}
?>
Виталий Черкасов
if ($author_id != ''){
?>
Автор:
}
?>
}
}
}
mysqli_free_result($result_section);
if ($CFG['NEWS_PER_PAGE'] < $total) { // output pagination links
?>
$total_pages = ceil($total/$CFG['NEWS_PER_PAGE']);
if ($page != 1) echo "
«« "; else echo " ";
if ($page != 1) echo "
« ";
for ($i = ($page - 5); $i < ($page + 6); $i++) {
if ($i > 0 && $i <= $total_pages) {
if ($i != $page) {
echo "
" . $i . " ";
} else {
echo "
" . $i . " ";
}
}
}
if ($page != $total_pages) echo "
»";
if ($page != $total_pages) echo "
»»";
?>
}
if(isset($adv_print[2][++$adv_count]['text'])){
?>
}
?>