вопрос
Вот сам код файла top.php - суть в том не выводит не топ 250 и глюки в файле при обращении к нему.
Кто сталкивался - хелп. Возможна причина того -- php версия 5.4.21 .
Кто сталкивался - хелп. Возможна причина того -- php версия 5.4.21 .
<?php
// Извлечь все данные из таблицы post, у который id категории имею parenid основной категории
if (! defined ( 'DATALIFEENGINE' )) {
die ( "Hacking attempt!" );
}
include_once ROOT_DIR . '/engine/data/top_config.php';
$min_votes = intval($min_votes);
function get_top($main_cat)
{
global $db, $config, $min_votes, $film_cat_id, $serial_cat_id, $multfilm_cat_id, $actor_cat_id;
switch($main_cat) {
case $film_cat_id:
$htitle = 'Фильм';
break;
case $serial_cat_id:
$htitle = 'Сериал';
break;
case $multfilm_cat_id:
$htitle = 'Мультфильм';
break;
case $actor_cat_id:
$htitle = 'Актёр';
break;
default:
$htitle = 'Фильм';
break;
}
$tpl2 = new dle_template();
$tpl2->dir = TEMPLATE_DIR;
$tpl2->load_template( 'top.tpl' );
if (is_array($film_cat_id)) {
$arr_cats = array();
foreach($film_cat_id as $cat_id) {
$get_cats = get_sub_cats ( $cat_id );
$arr_cats = array_merge($arr_cats, explode('|', $get_cats));
}
$where_cats = implode(' OR category=', $arr_cats);
} else {
$get_cats = get_sub_cats ( $f );
$arr_cats = explode('|', $get_cats);
$where_cats = implode(' OR category=', $film_cat_id);
}
$row = $db->super_query( "SELECT SUM(rating)/SUM(vote_num) AS rating FROM " . PREFIX . "_post, " . PREFIX . "_post_extras WHERE id = news_id AND (category='$where_cats')" );
$average_rating = ($row['rating']) ? $row['rating'] : 0;
$sql_result = $db->query( "SELECT *, ((vote_num/(vote_num+'$min_votes'))*(rating/vote_num))+(('$min_votes'/(vote_num+'$min_votes'))*'$average_rating') AS top FROM " . PREFIX . "_post, " . PREFIX . "_post_extras WHERE id = news_id AND (category= '$where_cats') ORDER BY top DESC LIMIT 0, 250" );
$list = explode( ",", $member_id['favorites'] );
$i = 1;
while ( $row = $db->get_row( $sql_result ) ) {
$row['date'] = strtotime( $row['date'] );
$tpl2->set( '{id}', $i );
$tpl2->set( '{news_id}', $row['news_id'] );
if($i % 2) {
$tpl2->set( '{bgcolor}', ' ' );
} else {
$tpl2->set( '{bgcolor}', ' bgcolor="#eeeeee" ' );
}
$tpl2->set( '{title}', stripslashes( $row['title'] ) );
if( $config['allow_alt_url'] == "yes" ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
} else {
$full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
}
if( $config['hide_full_link'] == "yes" ) $tpl2->set_block( "'\\[full-link\\](.*?)\\[/full-link\\]'si", "" );
else {
$tpl2->set( '[full-link]', "<a href=\"" . $full_link . "\" class=\"all\">" );
$tpl2->set( '[/full-link]', "</a>" );
}
$tpl2->set( '{full-link}', $full_link );
$tpl2->set( '{favorites-link}', $config['http_home_url']. 'favorites/' );
$tpl2->set( '{rating}', number_format($row['top'], 3) );
$tpl2->set( '{vote_num}', $row['vote_num'] );
if($member_id['user_id'] != 0) {
$fav_exist = 0;
foreach ( $list as $daten ) {
if( $daten == $row['news_id'] ) $fav_exist = 1;
}
if($fav_exist == 1) {
$tpl2->set( '{favorites}', 'class="private-folder fav-'. $row['news_id'] .' slc" value="1" onclick="topDoFavorites('.$row['news_id'].', \'minus\'); return false;"');
} else {
$tpl2->set( '{favorites}', 'class="public-folder fav-'.$row['news_id'].'" value="1" onclick="topDoFavorites('.$row['news_id'].', \'plus\'); return false;"');
}
} else {
$tpl2->set( '{favorites}', 'class="public-folder fav-'.$row['news_id'].'" value="1" onclick="topDoFavorites('.$row['news_id'].', \'plus\'); return false;"');
}
$tpl2->compile( 'content' );
$i++;
}
$tpl2->result['content'] = '
<div class="top250"><table cellspacing="0" cellpadiving="3" width="100%" border="0">
<tbody>
<tr>
<td style="padiving-left:20px">
<table cellspacing="0" cellpadiving="3" width="100%" border="0">
<tbody>
<tr height="25">
<td width="5%" class="th" style="border:none"> </td>
<td class="th">'.$htitle.'</td>
<td class="th"> </td>
<td class="th"> </td>
</tr>
'.$tpl2->result['content'].'
</tbody>
</table>
</td>
</tr>
</tbody>
</table></div><script type="text/javascript">
$(function() {
$(".star").click(function(e) {
$(".rateNow").hide();
$(".list_div").hide();
$id = $(this).attr("id").match(/(\d+)/g)
if ($(".rateNow_"+$id).css("display") != "block") {
$(".rateNow_"+$id).show();
var firstClick = true;
$(document).bind("click.event", function(e) {
if(!firstClick && $(e.target).closest(".rateNow_"+$id).length == 0) {
$(".rateNow_"+$id).hide();
$(document).unbind("click.event");
}
firstClick = false;
});
}
});
$(".filmmenu").click(function(e) {
$(".rateNow").hide();
$(".list_div").hide();
$id = $(this).attr("id").match(/(\d+)/g)
if ($(".list_div_"+$id).css("display") != "block") {
$(".list_div_"+$id).show();
var firstClick = true;
$(document).bind("click.event", function(e) {
if(!firstClick && $(e.target).closest(".list_div_"+$id).length == 0) {
$(".list_div_"+$id).hide();
$(document).unbind("click.event");
}
firstClick = false;
});
}
});
});
</script>';
$top_content = $tpl2->result['content'];
$tpl2->result['content'] = '';
//$tpl2->clear();
return $top_content;
}
function get_top_sideblock_film()
{
global $db, $config, $min_votes, $film_cat_id, $film_sideblock_count, $film_full_link;
if (is_array($film_cat_id)) {
$arr_cats = array();
foreach($film_cat_id as $cat_id) {
$get_cats = get_sub_cats ( $cat_id );
$arr_cats = array_merge($arr_cats, explode('|', $get_cats));
}
$where_cats = implode(' OR category=', $arr_cats);
} else {
$get_cats = get_sub_cats ( $f );
$arr_cats = explode('|', $get_cats);
$where_cats = implode(' OR category=', $film_cat_id);
}
$row = $db->super_query( "SELECT SUM(rating)/SUM(vote_num) AS rating FROM " . PREFIX . "_post, " . PREFIX . "_post_extras WHERE id = news_id AND (category='$where_cats')" );
$average_rating = ($row['rating']) ? $row['rating'] : 0;
$sql_result = $db->query( "SELECT *, ((vote_num/(vote_num+'$min_votes'))*(rating/vote_num))+(('$min_votes'/(vote_num+'$min_votes'))*'$average_rating') AS top FROM " . PREFIX . "_post, " . PREFIX . "_post_extras WHERE id = news_id AND (category= '$where_cats') ORDER BY top DESC LIMIT 0, 10" );
$content .= '<ul class="block_top250">';
$i = 1;
while ( $row = $db->get_row( $sql_result ) ) {
if( $config['allow_alt_url'] == "yes" ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
} else {
$full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
}
$even = ($i % 2) ? '' : ' class="even"';
$content .= '<li'.$even.'> <div class="tlink"><a href="'.$full_link.'">
<b>'.$i.'.</b>
'.stripslashes( $row['title'] ).'
</a></div><div class="r-rating">'.number_format($row['top'], 3, '.', ' ').'</div><div class="clearBoth"></div></li>';
++$i;
}
$content .= '</ul>';
$content .= '<div class="more">
<a href="'.$film_full_link.'">Лучшие фильмы</a>
</div>';
return $content;
}
function get_top_sideblock_serial()
{
global $db, $config, $min_votes, $serial_cat_id, $serial_sideblock_count, $serial_full_link;
$get_cats = get_sub_cats ( $serial_cat_id );
$arr_cats = explode('|', $get_cats);
$where_cats = implode(' OR category=', $arr_cats);
$row = $db->super_query( "SELECT SUM(rating)/SUM(vote_num) AS rating FROM " . PREFIX . "_post, " . PREFIX . "_post_extras WHERE id = news_id AND category=$where_cats" );
$average_rating = ($row['rating']) ? $row['rating'] : 0;
$sql_result = $db->query( "SELECT *, ((vote_num/(vote_num+$min_votes))*(rating/vote_num))+(($min_votes/(vote_num+$min_votes))*$average_rating) AS top FROM " . PREFIX . "_post, " . PREFIX . "_post_extras WHERE id = news_id AND category= $where_cats ORDER BY top DESC LIMIT 0, $serial_sideblock_count" );
$content .= '<ul class="block_top250">';
$i = 1;
while ( $row = $db->get_row( $sql_result ) ) {
if( $config['allow_alt_url'] == "yes" ) {
if( $row['flag'] and $config['seo_type'] ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['news_id'] . "-" . $row['alt_name'] . ".html";
} else {
$full_link = $config['http_home_url'] . $row['news_id'] . "-" . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . "index.php?newsid=" . $row['news_id'];
}
$even = ($i % 2) ? '' : ' class="even"';
$content .= '<li'.$even.'> <div class="tlink"><a href="'.$full_link.'">
<b>'.$i.'.</b>
'.stripslashes( $row['title'] ).'
</a></div><div class="r-rating">'.number_format($row['top'], 3, '.', ' ').'</div><div class="clearBoth"></div></li>';
++$i;
}
$content .= '</ul>';
$content .= '<div class="more">
<a href="'.$serial_full_link.'">Лучшие сериалы</a>
</div>';
return $content;
}
function get_top_sideblock_multfilm()
{
global $db, $config, $min_votes, $multfilm_cat_id, $multfilm_sideblock_count, $multfilm_full_link;
$get_cats = get_sub_cats ( $multfilm_cat_id );
$arr_cats = explode('|', $get_cats);
$where_cats = implode(' OR category=', $arr_cats);
$row = $db->super_query( "SELECT SUM(rating)/SUM(vote_num) AS rating FROM " . PREFIX . "_post, " . PREFIX . "_post_extras WHERE id = news_id AND category=$where_cats" );
$average_rating = ($row['rating']) ? $row['rating'] : 0;
$sql_result = $db->query( "SELECT *, ((vote_num/(vote_num+$min_votes))*(rating/vote_num))+(($min_votes/(vote_num+$min_votes))*$average_rating) AS top FROM " . PREFIX . "_post, " . PREFIX . "_post_extras WHERE id = news_id AND category= $where_cats ORDER BY top DESC LIMIT 0, $multfilm_sideblock_count" );
$content .= '<ul class="block_top250">';
$i = 1;
while ( $row = $db->get_row( $sql_result ) ) {
if( $config['allow_alt_url'] == "yes" ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
} else {
$full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
}
$even = ($i % 2) ? '' : ' class="even"';
$content .= '<li'.$even.'> <div class="tlink"><a href="'.$full_link.'">
<b>'.$i.'.</b>
'.stripslashes( $row['title'] ).'
</a></div><div class="r-rating">'.number_format($row['top'], 3, '.', ' ').'</div><div class="clearBoth"></div></li>';
++$i;
}
$content .= '</ul>';
$content .= '<div class="more">
<a href="'.$multfilm_full_link.'">Лучшие мультфильмы</a>
</div>';
return $content;
}
function get_top_sideblock_actor()
{
global $db, $config, $min_votes, $actor_cat_id, $actor_sideblock_count, $actor_full_link;
$get_cats = get_sub_cats ( $actor_cat_id );
$arr_cats = explode('|', $get_cats);
$where_cats = implode(' OR category=', $arr_cats);
$row = $db->super_query( "SELECT SUM(rating)/SUM(vote_num) AS rating FROM " . PREFIX . "_post, " . PREFIX . "_post_extras WHERE id = news_id AND category=$where_cats" );
$average_rating = ($row['rating']) ? $row['rating'] : 0;
$sql_result = $db->query( "SELECT *, ((vote_num/(vote_num+'$min_votes'))*(rating/vote_num))+(('$min_votes'/(vote_num+'$min_votes'))*'$average_rating') AS top FROM " . PREFIX . "_post, " . PREFIX . "_post_extras WHERE id = news_id AND category= '$where_cats' ORDER BY top DESC LIMIT 0, 10" );
$content .= '<ul class="block_top250">';
$i = 1;
while ( $row = $db->get_row( $sql_result ) ) {
if( $config['allow_alt_url'] == "yes" ) {
if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
} else {
$full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
}
$even = ($i % 2) ? '' : ' class="even"';
$content .= '<li'.$even.'> <div class="tlink"><a href="'.$full_link.'">
<b>'.$i.'.</b>
'.stripslashes( $row['title'] ).'
</a></div><div class="r-rating">'.number_format($row['top'], 3, '.', ' ').'</div><div class="clearBoth"></div></li>';
++$i;
}
$content .= '</ul>';
$content .= '<div class="more">
<a href="'.$actor_full_link.'">Лучшие актёры</a>
</div>';
return $content;
}
?>