sibtracker/system/modules/lastcomments.php

38 lines
2.2 KiB
PHP
Raw Normal View History

2019-05-18 13:46:03 +08:00
<?php
if( ! defined( 'DATALIFEENGINE' ) ) {
die( "Hacking attempt!" );
}
$userid = intval( $_REQUEST['userid'] );
$_SESSION['referrer'] = $_SERVER['REQUEST_URI'];
$allow_list = explode( ',', $user_group[$member_id['user_group']]['allow_cats'] );
$where = array ();
if( $userid ) {
$where[] = PREFIX . "_comments.user_id='$userid'";
$user_query = "do=lastcomments&amp;userid=" . $userid;
} else $user_query = "do=lastcomments";
if( $allow_list[0] != "all" ) {
$join = "LEFT JOIN " . PREFIX . "_post ON " . PREFIX . "_comments.post_id=" . PREFIX . "_post.id ";
if( $config['allow_multi_category'] ) {$where[] = PREFIX . "_post.category regexp '[[:<:]](" . implode( '|', $allow_list ) . ")[[:>:]]'";
} else {$where[] = PREFIX . "_post.category IN ('" . implode( "','", $allow_list ) . "')"; }
} else {$join = "";}
if( count( $where ) ) {
$where = implode( " AND ", $where );
$where = "WHERE " . $where;
} else $where = "";
$sql_count = "SELECT COUNT(*) as count FROM " . PREFIX . "_comments " . $join . $where;
$row_count = $db->super_query( $sql_count );
if( $row_count['count'] ) {
include_once SYSTEM_DIR . '/classes/comments.class.php';
$comments = new Comments( $db, $row_count['count'], $config['comm_nummers'] );
$comments->query = "SELECT " . PREFIX . "_comments.id, post_id, " . PREFIX . "_comments.user_id, " . PREFIX . "_comments.date, " . PREFIX . "_comments.autor as gast_name, " . PREFIX . "_comments.email as gast_email, text, ip, is_register, name, " . PREFIX . "_comments.rating, lastdate, " . USERPREFIX . "_users.email, news_num, " . USERPREFIX . "_users.comm_num, user_group, reg_date, signature, foto, fullname, land, icq, repa, repa_mod, repa_off, " . PREFIX . "_post.title, " . PREFIX . "_post.date as newsdate, " . PREFIX . "_post.alt_name, " . PREFIX . "_post.category FROM " . PREFIX . "_comments LEFT JOIN " . PREFIX . "_post ON " . PREFIX . "_comments.post_id=" . PREFIX . "_post.id LEFT JOIN " . USERPREFIX . "_users ON " . PREFIX . "_comments.user_id=" . USERPREFIX . "_users.user_id " . $where . " ORDER BY date desc";
$comments->build_comments('lastcomments' );
$comments->build_navigation('navigation.tpl', false, $user_query);
} else {msgbox( $lang['all_info'], $lang['err_last'] );}
?>