safe_mode = true;
include(SYSTEM_DIR.'/data/chat.config.php');
if ($action == "mess_del") {
$db->query("DELETE FROM " . PREFIX . "_chat WHERE id = '$id'");
msgbox ($lang['all_info'], "Выбранное сообщение было успешно удалено. Вернуться назад...");
} else {
$tpl->load_template('chat/message.tpl');
$limit = intval($chatconfig['messlimit']);
$sql_count = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_chat");
$count_all = $sql_count['count'];
$page = intval( $_REQUEST['cstart'] );
$total = intval( ( ( $count_all - 1 ) / $limit ) + 1 );
if( $page <= 0 ) $page = 1;
if( $page > $total ) $page = $total;
$start = $page * $limit - $limit;
$i = $start; $s = 0;
$result = $db->query("SELECT id, name as gast_name, message, date, ip, user_id, mgroup FROM " . PREFIX . "_chat ORDER BY date DESC LIMIT $start,".$limit);
while($row = $db->get_array($result)){ $i++;$s++;
$row['date'] = strtotime($row['date']);
$row['name'] = stripslashes($row['gast_name']);
$tpl->set('{author}', "".$row['name']."");
if ($is_logged AND $member_id['user_group'] == '1')
$tpl->set('{ip}', "IP: {$row['ip']} ::");
else
$tpl->set('{ip}', '');
if ($config['comm_msort'] == "ASC")
$tpl->set('{mess-id}', $cstart+$i);
else
$tpl->set('{mess-id}', $comments_num-$cstart-$i+1);
if (($is_logged AND ($member_id['user_id'] == $row['userid'] AND ($row['is_reg'] == 1) AND $user_group[$member_id['user_group']]['allow_editc'])) OR $user_group[$member_id['user_group']]['edit_allc']){
$tpl->set('[mes-edit]',"");
$tpl->set('[/mes-edit]',"");
} else $tpl->set_block("'\\[mes-edit\\](.*?)\\[/mes-edit\\]'si","");
if ($is_logged AND (($member_id['user_id'] == $row['userid'] AND ($row['is_reg'] == 1) AND $user_group[$member_id['user_group']]['allow_delc'] AND ($row['date'] == $date_max['MAX(date)'])) OR $member_id['user_group'] == '1' OR $user_group[$member_id['user_group']]['del_allc'])){
$tpl->set('[mes-del]',"");
$tpl->set('[/mes-del]',"");
} else $tpl->set_block("'\\[mes-del\\](.*?)\\[/mes-del\\]'si","");
$message = stripslashes($row['message']);
if (date(Ymd, $row['date']) == date(Ymd, $_TIME)) {
$tpl->set('{date}', $lang['time_heute'].langdate(", H:i", $row['date']));
} elseif (date(Ymd, $row['date']) == date(Ymd, ($_TIME - 86400))) {
$tpl->set('{date}', $lang['time_gestern'].langdate(", H:i", $row['date']));
} else {
$tpl->set('{date}', langdate($config['timestamp_comment'], $row['date']));
}
$tpl->set('{message}', $message);
$tpl->compile('content');
}
$nav = "/chat/history/page/{page}/";
CreateNavigation( $nav, $page, $total );
};
?>