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

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

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

$now_ticket = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT id,log,av FROM `".DB_PREFIX."_tickets_main` INNER JOIN ".DB_PREFIX."_users ON ".DB_PREFIX."_tickets_main.usr = ".DB_PREFIX."_users.uid WHERE id='$id' LIMIT 1"));

//Создание аватаров
$ava_link_thumb_u = '/wu-static/img/avatar_default_adm.png'; $ava_link_full_u = '/wu-static/img/avatar_default_adm.png';
if (empty($now_ticket['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/'.$now_ticket['av']; $ava_link_full_my = '/wu-uploads/avatars/full/'.$now_ticket['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,msg,files,frm,bb,sm,dt FROM `".DB_PREFIX."_tickets_msg` WHERE tid = '$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."_tickets_main` SET new_a = '0' WHERE id='$id' AND new_a = '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['frm'] == 0) { $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['frm'] == 0) { echo ' reversed'; } ?>" id="m_<?php echo $row['id']; ?>">
<div class="lightgallerys <?php if ($row['frm'] == 1) { echo 'flleft'; } else { echo 'flright'; } ?>">
<a href="<?php if ($row['frm'] == 0) { echo $ava_link_full_my; } else { echo $ava_link_full_u; } ?>"><img src="<?php if ($row['frm'] == 0) { echo $ava_link_thumb_my; } else { echo $ava_link_thumb_u; } ?>" class="media-object" /></a>
</div>
<div class="message-body<?php if ($row['frm'] == 1) { 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']); 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 { exit('wu-error'); }
?>