sibtracker/system/modules/favorites.php

75 lines
3.9 KiB
PHP
Raw Normal View History

2019-05-18 13:46:03 +08:00
<?php
if( ! defined( 'DATALIFEENGINE' ) ) {die( "Hacking attempt!" );}
$limit = $config['newslist_num'];
$word = 50;
$list = explode( ",", $member_id['favorites'] );
foreach ( $list as $daten ) {$fav_list[] = "'" . intval($daten) . "'";}
$list = implode( ",", $fav_list );
$favorites = "(" . $list . ")";
$allow_list = explode( ',', $user_group[$member_id['user_group']]['allow_cats'] );
if( $allow_list[0] != "all" ) {
if( $config['allow_multi_category'] ) {$stop_list = "category regexp '[[:<:]](" . implode( '|', $allow_list ) . ")[[:>:]]' AND ";
} else {$stop_list = "category IN ('" . implode( "','", $allow_list ) . "') AND ";}
} else
$stop_list = "";
if( $user_group[$member_id['user_group']]['allow_short'] ) $stop_list = "";
if (isset ( $_SESSION['dle_sort_favorites'] )) $news_sort_by = $_SESSION['dle_sort_favorites']; else $news_sort_by = $config['news_sort'];
if (isset ( $_SESSION['dle_direction_favorites'] )) $news_direction_by = $_SESSION['dle_direction_favorites']; else $news_direction_by = $config['news_msort'];
$sql_count = "SELECT COUNT(*) as count FROM " . PREFIX . "_post where {$stop_list}id in {$favorites}";
$temp = $db->super_query($sql_count);
$posts = $temp['count'];
if($posts){
$page = intval( $cstart );
$total = intval( ( ( $posts - 1 ) / $limit ) + 1 );
if( $page <= 0 ) $page = 1;
if( $page > $total ) $page = $total;
$start = $page * $limit - $limit;
$i = $start;
$sql_select = "SELECT id, autor, date, title, category, alt_name, comm_num, rating, news_read FROM " . PREFIX . "_post where {$stop_list}id in $favorites ORDER BY " . $news_sort_by . " " . $news_direction_by . " LIMIT " . $start . "," . $limit;
$result = $db->query($sql_select);
$tpl->load_template('fav/news.tpl');
while($row = $db->get_row($result)){
$i++;
if (strlen($row['title']) > $word) $title = stripcslashes(substr ($row['title'], 0, $word))." ..."; else $title = stripcslashes($row['title']);
$fav_arr = explode( ',', $member_id['favorites'] );
if( ! in_array( $row['id'], $fav_arr ) or $config['allow_cache'] == "yes" ) $tpl->set( '{favorites}', "<a id=\"fav-id-" . $row['id'] . "\" href=\"$PHP_SELF?do=favorites&amp;doaction=add&amp;id=" . $row['id'] . "\"><img src=\"" . $config['http_home_url'] . "templates/{$config['skin']}/images/add_fav.png\" onclick=\"doFavorites('" . $row['id'] . "', 'plus'); return false;\" title=\"" . $lang['news_addfav'] . "\" style=\"vertical-align: middle;border: none;\" alt=\"\" /></a>" );
else $tpl->set( '{favorites}', "<a id=\"fav-id-" . $row['id'] . "\" href=\"$PHP_SELF?do=favorites&amp;doaction=del&amp;id=" . $row['id'] . "\"><img src=\"" . $config['http_home_url'] . "templates/{$config['skin']}/images/del_fav.png\" onclick=\"doFavorites('" . $row['id'] . "', 'minus'); return false;\" title=\"" . $lang['news_minfav'] . "\" style=\"vertical-align: middle;border: none;\" alt=\"\" /></a>" );
$set = array(
'{category}' => "<a href=\"" . $config['http_home_url'] . get_url($row['category']) . "/\">".$cat_info[$row['category']]['name']."</a>",
'{date}' => date("d.m.Y",strtotime($row['date'])),
'{title}' => $title,
'{link}' => $config['http_home_url'].$row['id']."-".$row['alt_name'].".html",
'{id}' => $row['id'],
);
$tpl->set('', $set);
$tpl->compile('fileslist');
}
$list = $tpl->result['fileslist'];
$tpl->load_template('fav/favorites.tpl');
$tpl->set('{list}', $list);
$tpl->set ( '{sort}', news_sort ( $do ) );
$tpl->compile('content');
$tpl->clear();
$nav = "/favorites/page/{page}/";
CreateNavigation( $nav, $page, $total );
} else {
$tpl->load_template('info.tpl');
$tpl->set('{error}', "<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.");
$tpl->set('{title}', "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
$tpl->compile('content');
$tpl->clear();
}
?>