View file wu-engine/wu-actions/acc_message_load.php

File size: 3.85Kb
<?php
require_once('../wu_init.php');
if (!wu_token()) { exit('wu-error'); }
if (!USER_LOGGED) { exit('wu-error'); }
require('../wu-functions/wu_functions.php');
require('../wu-functions/bbdecoder/Parser.php');

if(isset($_POST['usr']) && isset($_POST['last'])){
$usr = intval($_POST['usr']);

//Создание аватаров
if (empty($_POST['av'])) { $ava_link_thumb_u = '/wu-static/img/avatar_default.png'; $ava_link_full_u = '/wu-static/img/avatar_default.png'; } else { $ava_link_thumb_u = '/wu-uploads/avatars/thumbs/'.$_POST['av']; $ava_link_full_u = '/wu-uploads/avatars/full/'.$_POST['av']; }
if (empty($nowuser['av'])) { $ava_link_thumb_my = '/wu-static/img/avatar_default.png'; $ava_link_full_my = '/wu-static/img/avatar_default.png'; } else { $ava_link_thumb_my = '/wu-uploads/avatars/thumbs/'.$nowuser['av']; $ava_link_full_my = '/wu-uploads/avatars/full/'.$nowuser['av']; }

//Запуск парсера
$parser = new JBBCode\Parser();
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());

//Вывод сообщений
$last = $_POST['last'];
$last = str_replace('m_', '', $last);
$last = intval($last);
$qm = mysqli_query($connect_db, "SELECT * from (SELECT id,fr,msg,files,dt FROM ".DB_PREFIX."_messages WHERE (`fr` = '$u_id' AND `tou` = '$usr') OR (`fr` = '$usr' AND `tou` = '$u_id') AND id > '$last' ORDER BY id DESC) AS te ORDER BY te.id ASC");
$qh = mysqli_num_rows($qm);
if ($qh > 0) {
mysqli_query($connect_db, "UPDATE ".DB_PREFIX."_messages SET new = '0' WHERE fr='$usr' AND tou='$u_id' AND new = '1'");
while($row = mysqli_fetch_assoc($qm)) {

//Вывод прикреплений
if (!empty($row['files'])) {
$images = array('gif','jpg', 'png', 'jpeg');
$files_e = '';
$files = explode('|', $row['files']);
foreach ($files as $file) {
$expl = explode(':', $file);
$ifile = $expl[0];
$iname = $expl[1];
$exp = explode('.', $ifile);
$exp_e = strtolower($exp[1]);
if (!empty($file)){
if (in_array($exp_e, $images)) {
$files_e .= '<div class="border-thumbnail-preview tip lightgallerys" data-placement="bottom" title="'.$iname.'"><a href="/wu-uploads/attach/full/'.$ifile.'"><img class="img-thumbnail-preview" src="/wu-uploads/attach/thumbs/'.$ifile.'" alt="'.$iname.'" /></a></div>';
} else {
if ($row['fr'] == $u_id) { $txti = ''; } else { $txti = ' text-info'; }
$files_e .= '<a href="/wu-engine/wu-actions/attach_download/'.strrev(base64_encode($ifile.'|'.$iname)).'" class="icon-thumbnail-preview tip" data-placement="bottom" title="'.$iname.'"><i class="icon-file6'.$txti.'"></i></a>';
}
}
}
} else { $files_e = ''; }
?>
<div class="mc_<?php echo $row['id']; ?> message<?php if ($row['fr'] != $u_id) { echo ' reversed'; } ?>" id="m_<?php echo $row['id']; ?>">
<div class="lightgallerys <?php if ($row['fr'] == $u_id) { echo 'flleft'; } else { echo 'flright'; } ?>">
<a href="<?php if ($row['fr'] == $u_id) { echo $ava_link_full_my; } else { echo $ava_link_full_u; } ?>"><img src="<?php if ($row['fr'] == $u_id) { echo $ava_link_thumb_my; } else { echo $ava_link_thumb_u; } ?>" class="media-object" /></a>
</div>
<div class="message-body<?php if ($row['fr'] == $u_id) { echo ' msg-link'; } ?>">
<?php
$parser->parse(htmlentities($row['msg']));
$parsered = $parser->getAsHtml();
echo wu_smile(nl2br($parsered));
if (!empty($row['files'])) {
if (!empty($row['msg'])) { echo '<br />'; }
echo '<div>Прикреплённые файлы:<br />'.$files_e.'</div>';
}
?>
<span class="attribution"><?php echo wudatenorm($row['dt']); ?><?php if ($row['fr'] == $u_id) { echo '<i class="icon-pencil msg_control" onclick="msg_edit(\''.$row['id'].'\');"></i><i class="icon-remove msg_control" onclick="msg_del(\''.$row['id'].'\');"></i>'; } ?></span>
</div>
</div>
<?php
}
} else { echo '<div class="alert alert-info fade in msgnone" id="m_1"><i class="icon-info"></i> У Вас с этим пользователем пока что нет сообщений</div>'; }
} else { exit('wu-error'); }
?>