Файл: магазин/e-proger/modules/message/mread.php
Строк: 97
<?
if ( $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) {
define( 'ROOT', 'http://'.$_SERVER['HTTP_HOST'] );
define( 'ROOT_DIR', $_SERVER['DOCUMENT_ROOT'] );
session_start();
include_once ROOT_DIR . '/engine/config.php';
include_once ROOT_DIR . '/engine/func.php';
}
if ( !isset( $_SESSION['id'] ) ) {
echo '<div class="error" style="width: 90%; margin: 10px auto; text-align: center"><b>Ошибка!</b> Вы не авторизированы.<br />Пожалуйста, воспользуйтесь формой авторизации.</div>';
} else {
$config_user = $pdo->Query("SELECT * from php_user WHERE id = '" . $_SESSION['id'] . "'")->fetch(PDO::FETCH_BOTH);
/*---Обрезаем email для защиты---*/
$start_end_email = preg_match( "/^([a-z0-9-._]+)(@[a-z0-9]+(?:.?[a-z0-9]+)?.[a-z]{2,5})/is", $config_user['email'], $outemail );
$sec_email_user = substr( $outemail[1], 0, 1 ) . '*******' . substr( $outemail[1], -1) . $outemail[2];
/*---Дата последнего входа---*/
$month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
if ( date( 'd.m.Y', $config_user['regdata'] ) == date( 'd.m.Y', time() ) ) {
$frd_logindate = 'сегодня в ' . date( 'H:i', $config_user['regdata'] ) . '';
} else {
$frd_logindate = '' . ( int ) date( 'd', $config_user['regdata'] ) . ' ' . $month[( int ) date( 'm', $config_user['regdata'] ) - 1] . ' ' . date( 'Y', $config_user['regdata'] ) . '';
}
$user_set = $pdo->Query("SELECT * from php_user WHERE id = '" . $_SESSION['id'] . "'")->fetch(PDO::FETCH_BOTH);
?>
<div class="big_topics bor_top round3 FFF hr">
<div class="wrap_user_r">
<?
include_once ROOT_DIR . '/modules/message/menu.php';
$check_read = mysql_query( "SELECT * FROM php_messages WHERE (from_id = '" . ( int ) $_GET['id'] . "' and to_id = '" . $_SESSION['id'] . "' and m_state = 'inbox' and to_del = 0) or (from_id = '" . $_SESSION['id'] . "' and to_id = '" . ( int ) $_GET['id'] . "' and m_state = 'outbox' and from_del = 0) ORDER BY data ASC" );
if ( mysql_num_rows( $check_read ) > 0 ) {
?>
<script type="text/javascript">
$(document).ready(function() {
$('.wrap_read_mess').scrollTop(10000);
$('#msgtext').focus();
reloadpage.leftprofiles();
});
var setIid;
setIid = setInterval('msgread()', 2000);
function msgread() {
$.post('modules/message/ajax_read.php', {
id: <?=( int ) $_GET['id']?>
}, function(data) {
if (data.ok == 1) {
$('body').append('<audio autoplay="" class="qplay"><source src="theme/sound/newmsg.ogg" ><source src="theme/sound/newmsg.mp3" ></audio>');
for(var i = 0; i <= data.mread.length - 1; i++) {
$('.wrap_read_mess').append('<div class="wrap_in_mess"><div class="in_mess_text"><div class="us_name_mess">'+data.mread[i].username+'</div>'+data.mread[i].text+'<div class="time_mess">'+data.mread[i].data+'</div></div></div>');
}
$('.wrap_read_mess').scrollTop(10000);
}
}, "json");
$('.qplay').remove();
}
</script>
<div class="wrap_read_mess">
<?
while ( $get_mess_row = mysql_fetch_array( $check_read ) ) {
$info_from_id = mysql_fetch_array( mysql_query( "SELECT login, id FROM php_user WHERE id = '" . $get_mess_row['from_id'] . "' LIMIT 1" ) );
mysql_query( "UPDATE php_messages SET m_type = 1 WHERE id = '" . $get_mess_row['id'] . "' and m_state = 'inbox' and m_type = 0" );
/*---формируем дату сообщения---*/
$month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
if ( date( 'd.m.Y', $get_mess_row['data'] ) == date( 'd.m.Y', time() ) ) {
$mess_time = 'сегодня в ' . date( 'H:i', $get_mess_row['data'] );
} else
if ( date( 'd.m.Y', $get_mess_row['data'] ) == date( 'd.m.Y', time() - 86400 ) ) {
$mess_time = 'вчера в ' . date( 'H:i', $get_mess_row['data'] );
} else {
$mess_time = ( int ) date( 'd', $get_mess_row['data'] ) . ' ' . $month[( int ) date( 'm', $get_mess_row['data'] ) - 1] . ' ' . date( 'Y', $get_mess_row['data'] ) . ' в ' . date( 'H:i', $get_mess_row['data'] );
}
?>
<div class="wrap_in_mess"><div class="in_mess_text"><div class="us_name_mess"><?=$info_from_id['login']?></div><?=$get_mess_row['text']?><div class="time_mess"><?=$mess_time?></div></div></div>
<?
}
?>
</div>
<div style="background: #f0f1f2; padding: 10px; border-bottom: 1px solid #E3E6E9;"><textarea class="val" id="msgtext" style="height: 62px; width: 100%; float: right;"></textarea><div style="padding: 10px 10px 0 10px; text-align: right; clear: both; position: relative;"><?=$mo?><div class="preload_msg"></div><a href="#" onclick="Send_d(<?=( int ) $_GET['id']?>, $('#msgtext').val(), '<?=substr( md5( $message_md5 . ( int ) $_GET['id'] ), 0, 22 )?>'); return false;" class="btn_box" id="sendMsg">Отправить</a></div></div>
<?
} else {
echo '<div style="text-align:center; margin-top:56px; padding:20px 10px; font-weight:bold; color:#999999;">Сообщений не найдено.</div>';
}
}
?>
</div>
</div>