Load_Template( 'comments/info.tpl' ); $tpl->set( "{title}", stripslashes( $title ) ); $tpl->set( "{error}", stripslashes( $info ) ); $tpl->copy_template = "".$tpl->copy_template.""; $tpl->compile( "content" ); $tpl->clear(); } function Comments( $db, $total_comments, $comments_per_pages ) { global $allow_comments; $this->db = $db; $this->CountCom = $total_comments; $this->LimitCom = $comments_per_pages; $this->AllowCom = $allow_comments; if ( isset( $_GET['cstart'] ) ) $this->cstart = intval( $_GET['cstart'] ); else $this->cstart = 0; if( $this->cstart > 0) { $this->cstart = $this->cstart - 1; $this->cstart = $this->cstart * $comments_per_pages; } else $this->cstart = 0; } //Отображение комментариев function build_comments($area, $allow_cache = false ) { global $config, $tpl, $cache, $user_group, $member_id; if($this->CountCom > 0){ $rows = false; if($allow_cache) $rows = $cache->open( "comm_".$allow_cache, $this->query . " LIMIT " . $this->cstart . "," . $this->LimitCom ); if($rows){ $rows = unserialize($rows); } else { $rows = $this->db->super_query( $this->query . " LIMIT " . $this->cstart . "," . $this->LimitCom, true ); if($allow_cache) $cache->save( "comm_".$allow_cache, serialize($rows), $this->query . " LIMIT " . $this->cstart . "," . $this->LimitCom ); } if(count ($rows)) foreach ($rows as $row){ $this->Row[ $row['id'] ] = $row; $this->Echo_Comm($row['id']); } } elseif ($user_group[$member_id['user_group']]['allow_addc'] && $this->AllowCom){ $this->EchoInfo("Комментарии отсутствуют", "Но вы можете добавить первый...."); } if ($area != 'ajax' AND $config['comm_msort'] == "ASC") $tpl->result['content'] .= "\n
\n"; } private function Echo_Comm($id){ global $config, $tpl, $is_logged, $member_id, $user_group, $lang, $dle_login_hash, $_TIME; $row = $this->Row[ $id ]; $id = $row['id']; $tpl->Load_Template( 'comments/comments.tpl' ); $tpl->copy_template = "
" . $tpl->copy_template . "
"; $tpl->template = "
" . $tpl->template . "
"; $UserName = stripslashes( $row['name'] ); $date = strtotime( $row['date'] ); $ComAutor = htmlspecialchars( stripslashes( $row['gast_name'] ) ); $text = stripslashes( $row['text'] ); $is_register = intval( $row['is_register'] ); $UserFoto = stripslashes( $row['foto'] ); //Цвет пользовательской группы (пользователя) if ($user_group[$row['user_group']]['colour']){ $group_span = $user_group[$row['user_group']]['colour']; $user = "".$UserName.""; }else{ $user = $UserName; } //Ссылка на автора комментария if( !$is_register || $UserName == '' ) { $tpl->set( '{author}', $ComAutor ); } else { $tpl->set( '{author}', "{$user}" ); } //Дата добавления комментария if( date( Ymd, $date ) == date( Ymd, $_TIME ) ) $tpl->set( "{date}", $lang['time_heute'].langdate( ", H:i", $date ) ); elseif( date( Ymd, $date ) == date( Ymd, ($_TIME - 86400) ) ) $tpl->set( "{date}", $lang['time_gestern'].langdate( ", H:i", $date )); else $tpl->set( "{date}", langdate( $config['timestamp_comment'], $date ) ); //Ссылка на новость if(!$this->nid){ $link = $config['http_home_url'] . $row['post_id'] . "-" . $row['alt_name'] . ".html"; $tpl->set_block( "'\[news](.*?)\[/news\]'si", "".$row['title']."" ); } else { $tpl->set( "[news]", "" ); $tpl->set( "[/news]", "" ); } //Ссылка на комментарий $tpl->set( '[com-href]', ""); $tpl->set( '[/com-href]', ""); // Аватар пользователя if( $UserFoto ) $tpl->set( '{foto}', "" ); else $tpl->set( '{foto}', "" ); if ( ($row['lastdate'] + $config['user_online']*60) > $_TIME ) $tpl->set('{status}', "Online"); else $tpl->set('{status}', "Offline"); if( $is_logged and ($member_id['name'] == $ComAutor) )$tpl->set('{rate}',CommRating ($row['id'], $row['rating'], 0)); else $tpl->set('{rate}',CommRating ($row['id'], $row['rating'], $user_group[$member_id['user_group']]['allow_rating'])); @include (SYSTEM_DIR.'/modules/reputation.php'); if( $is_logged && ( ( $member_id['name'] == $UserName && $is_register && $user_group[$member_id['user_group']]['allow_editc']) or $user_group[$member_id['user_group']]['edit_allc']) ) { $tpl->set( '[com-edit]', "" ); $tpl->set( '[/com-edit]', "" ); } else $tpl->set_block( "'\\[com-edit\\](.*?)\\[/com-edit\\]'si", "" ); if( $is_logged && (($member_id['name'] == $UserName && $is_register && $user_group[$member_id['user_group']]['allow_delc']) or $member_id['user_group'] == '1' or $user_group[$member_id['user_group']]['del_allc']) ) { $tpl->set('[com-del]',""); $tpl->set('[/com-del]',""); }else $tpl->set_block("'\\[com-del\\](.*?)\\[/com-del\\]'si",""); if( ($user_group[$member_id['user_group']]['allow_addc'])) { if( !$is_register or $UserName == '' ) $UserName = $ComAutor; else $UserName = $UserName; $tpl->set( '[fast]', "" ); $tpl->set( '[/fast]', "" ); } else $tpl->set_block( "'\\[fast\\](.*?)\\[/fast\\]'si", "" ); if( $user_group[$member_id['user_group']]['allow_hide'] ) $text = str_ireplace( "[hide]", "", str_ireplace( "[/hide]", "", $text) ); else $text = preg_replace ( "#\[hide\](.+?)\[/hide\]#is", "
" . $lang['news_regus'] . "
", $text ); $tpl->set( "{comment-id}", $id ); $tpl->set( "{comment}", "
{$text}
" ); $tpl->compile( "content" ); $tpl->clear(); } //Навигация function build_navigation( $template, $alternative_link, $link ) { global $tpl, $config, $lang; if( $this->CountCom < $this->LimitCom ) return; if( isset( $_GET['cstart'] ) ) $this->cstart = intval( $_GET['cstart'] ); if( !$this->cstart OR $this->cstart < 0 ) $this->cstart = 1; $tpl->load_template( $template ); if( $this->cstart > 1 ) { $prev = $this->cstart - 1; if( $alternative_link ) { $url = str_replace ("{page}", $prev, $alternative_link ); $tpl->set_block( "'\[prev-link\](.*?)\[/prev-link\]'si", "\\1" ); } else $tpl->set_block( "'\[prev-link\](.*?)\[/prev-link\]'si", "\\1" ); } else { $tpl->set_block( "'\[prev-link\](.*?)\[/prev-link\]'si", "\\1" ); $no_prev = TRUE; } if( $this->LimitCom ) { $enpages_count = @ceil( $this->CountCom / $this->LimitCom ); $pages = ""; if( $enpages_count <= 10 ) { for($j = 1; $j <= $enpages_count; $j ++) { if( $j != $this->cstart ) { if( $alternative_link ) { $url = str_replace ("{page}", $j, $alternative_link ); $pages .= "$j "; } else $pages .= "$j "; } else {$pages .= "$j ";} }} else { $start = 1; $end = 10; $nav_prefix = "{$lang['nav_trennen']} "; if( $this->cstart > 0 ) { if( $this->cstart > 6 ) { $start = $this->cstart - 4; $end = $start + 8; if( $end >= $enpages_count ) { $start = $enpages_count - 9; $end = $enpages_count - 1; $nav_prefix = ""; } else $nav_prefix = "{$lang['nav_trennen']} "; }} if( $start >= 2 ) { if($alternative_link) { $url = str_replace ("{page}", "1", $alternative_link ); $pages .= "1 {$lang['nav_trennen']} "; } else $pages .= "1 {$lang['nav_trennen']} "; } for($j = $start; $j <= $end; $j ++) { if( $j != $this->cstart ) { if( $alternative_link) { $url = str_replace ("{page}", $j, $alternative_link ); $pages .= "$j "; } else $pages .= "$j "; } else {$pages .= "$j "; }} if( $this->cstart != $enpages_count ) { if($alternative_link) { $url = str_replace ("{page}", $enpages_count, $alternative_link ); $pages .= $nav_prefix . "{$enpages_count}"; } else $pages .= $nav_prefix . "{$enpages_count}"; } else $pages .= "{$enpages_count} "; }$tpl->set( '{pages}', $pages ); } if( $this->cstart < $enpages_count ) { $next_page = $this->cstart + 1; if( $alternative_link ) { $url = str_replace ("{page}", $next_page, $alternative_link ); $tpl->set_block( "'\[next-link\](.*?)\[/next-link\]'si", "\\1" ); } else $tpl->set_block( "'\[next-link\](.*?)\[/next-link\]'si", "\\1" ); } else { $tpl->set_block( "'\[next-link\](.*?)\[/next-link\]'si", "\\1" ); $no_next = TRUE; } if( ! $no_prev or ! $no_next ) {$tpl->compile( 'content' );} $tpl->clear(); } //Показываем форму добавления коомента function build_comm_form(){ global $allow_add, $tpl, $is_logged, $user_group, $member_id, $lang, $bb_code, $news_id; if($this->AllowCom){ if($user_group[$member_id['user_group']]['allow_addc'] && $allow_add){ if(!$this->CountCom) $tpl->result['content'] .= "\n\n"; $tpl->load_template('comments/addcomments.tpl'); include_once SYSTEM_DIR . '/modules/bbcode.php'; $tpl->set( '{editor}', $bb_code ); $tpl->set( '{text}', '' ); $tpl->set( '{title}', $lang['news_addcom'] ); if( ! $is_logged ) { $tpl->set( '[not-logged]', '' ); $tpl->set( '[/not-logged]', '' ); } else $tpl->set_block( "'\\[not-logged\\](.*?)\\[/not-logged\\]'si", "" ); if( $is_logged ) $hidden = ""; else $hidden = ""; $tpl->copy_template = "
" . $tpl->copy_template . " {$hidden}
"; $tpl->compile( 'content' ); $tpl->clear(); } else $this->EchoInfo($lang['all_info'], "Только Зарегистрированные пользователи могут оставлять комментарии."); } else $this->EchoInfo($lang['all_info'], "Комментирвание новости отключено."); } } ?>