sibtracker/system/modules/chat/modules.php
2019-05-18 13:46:03 +08:00

78 lines
3.4 KiB
PHP

<?php
if(!defined('DATALIFEENGINE')) { die("Hacking Attempt!"); }
require_once SYSTEM_DIR.'/classes/parse.class.php';
$parse = new ParseFilter();
$parse->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'], "Âûáðàííîå ñîîáùåíèå áûëî óñïåøíî óäàëåíî. <a href=\"$PHP_SELF?do=chat_history\">Âåðíóòüñÿ íàçàä...</a>");
} 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}', "<a href=\"".$config['http_home_url']."user/".urlencode($row['name'])."/\">".$row['name']."</a>");
if ($is_logged AND $member_id['user_group'] == '1')
$tpl->set('{ip}', "IP: <a onClick=\"return dropdownmenu(this, event, IPMenu('".$row['ip']."', '".$lang['ip_info']."', '".$lang['ip_tools']."', '".$lang['ip_ban']."'), '190px')\" onMouseout=\"delayhidemenu()\" href=\"http://www.nic.ru/whois/?ip={$row['ip']}\" target=\"_blank\">{$row['ip']}</a> ::");
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]',"<a href=\"".$config['http_home_url']."admin.php?mod=chat&action=messedit&id=".$row['id']."\" target=\"_blank\">");
$tpl->set('[/mes-edit]',"</a>");
} 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]',"<a href=\"javascript:confirmDelete('".$config['http_home_url']."?do=chat_history&action=mess_del&id=".$row['id']."')\">");
$tpl->set('[/mes-del]',"</a>");
} 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 );
};
?>