XF 2.1 Пропала форма ответов в темах и личных сообщениях

Статус
В этой теме нельзя размещать новые ответы.
Версия XenForo
2.1.7

ФАКЕР

Проверенные
Сообщения
831
Решения
9
Реакции
83
Баллы
730
Здравствуйте.

Вобщем ничего не трогал, никакие настройки не менял, плагины не ставил. Сегодня зашел на форум и увидел, что формы ответов в темах исчезли, но осталась кнопка ОТВЕТИТЬ. При нажатии на неё, формы всё равно нет. Чудеса. Тоже самое в личных сообщениях.

В журнале ошибок сервера следующее:
OSHIBKA.png

Код:
Трассировка стека
#0 [internal function]: XF\Template\Templater->handleTemplateError(512, 'Template public...', '/home/c/cy60461...', 618, Array)
#1 src/XF/Template/Templater.php(618): trigger_error('Template public...', 512)
#2 src/XF/Template/Templater.php(566): XF\Template\Templater->getTemplateData('public', 'xtr_statistics')
#3 src/XF/Template/Templater.php(1314): XF\Template\Templater->getTemplateCode('public', 'xtr_statistics')
#4 src/XF/Template/Templater.php(1388): XF\Template\Templater->renderTemplate('xtr_statistics', Array)
#5 internal_data/code_cache/templates/l2/s26/public/PAGE_CONTAINER.php(1801): XF\Template\Templater->includeTemplate('public:xtr_stat...', Array)
#6 src/XF/Template/Templater.php(1315): XF\Template\Templater->{closure}(Object(ThemeHouse\UIX\XF\Template\Templater), Array)
#7 src/XF/Pub/App.php(547): XF\Template\Templater->renderTemplate('PAGE_CONTAINER', Array)
#8 src/XF/App.php(1995): XF\Pub\App->renderPageHtml('<div class="blo...', Array, Object(XF\Mvc\Reply\Message), Object(XF\Mvc\Renderer\Html))
#9 src/XF/Mvc/Dispatcher.php(402): XF\App->renderPage('<div class="blo...', Object(XF\Mvc\Reply\Message), Object(XF\Mvc\Renderer\Html))
#10 src/XF/Mvc/Dispatcher.php(58): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\Message), 'html')
#11 src/XF/App.php(2184): XF\Mvc\Dispatcher->run()
#12 src/XF.php(391): XF\App->run()
#13 index.php(20): XF::runApp('XF\\Pub\\App')
#14 {main}

Код:
Содержимое запроса
array(4) {
  ["url"] => string(1) "/"
  ["referrer"] => string(19) "https://сайт.ru/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 

Вложения

  • SCRRRNNN.png
    SCRRRNNN.png
    22.6 KB · Просмотры: 12
Замени ConversationView.php на этот:
<?php

namespace Andy\ConversationView\Pub\Controller;

use XF\Pub\Controller\AbstractController;

class ConversationView extends AbstractController
{
public function actionIndex()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Limit
$limit = $options->conversationViewLimit;

// get username
$username = $this->filter('username', 'str');

// get db
$db = \XF::db();

if ($username == '')
{
// run query
$results = $db->fetchAll("
SELECT conversation_id,
title,
user_id,
username,
last_message_date,
reply_count,
recipients
FROM xf_conversation_master
ORDER BY last_message_date DESC
LIMIT ?
", $limit);
}

if ($username != '')
{
// run query
$results = $db->fetchAll("
SELECT conversation_id,
title,
user_id,
username,
last_message_date,
reply_count,
recipients
FROM xf_conversation_master
WHERE username = ?
ORDER BY last_message_date DESC
LIMIT ?
", array($username, $limit));
}

if (!empty($results))
{
// get users
foreach ($results as $k => $v)
{
// get user
$user = array(
'user_id' => $v['user_id'],
'username' => $v['username']
);

//########################################
// get recipients

// define variable
$recipients = '';

$var = $v['recipients'];

if ($var != '')
{
// unserialize blob data
$varArray = json_decode($var, true);

foreach ($varArray AS $value)
{
$recipients = $recipients . ', ' . $value['username'];
}

$recipients = ltrim($recipients, ',');
}

// create resultsNew array
$resultsNew[] = array(
'conversation_id' => $v['conversation_id'],
'title' => $v['title'],
'user' => $user,
'recipients' => $recipients,
'last_message_date' => $v['last_message_date'],
'reply_count' => $v['reply_count']
);
}

// rename variable
$results = $resultsNew;
}

// prepare viewParams
$viewParams = [
'username' => $username,
'limit' => $limit,
'results' => $results
];

// send to template
return $this->view('Andy\ConversationView:Index', 'andy_conversationview', $viewParams);
}

public function actionConversation()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get conversationId
$conversationId = $this->filter('conversation_id', 'uint');

// verify conversationId
if ($conversationId == '')
{
return $this->error(\XF::phrase('conversationview_conversation_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Limit
$limit = $options->conversationViewLimit;

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT title,
username,
recipients
FROM xf_conversation_master
WHERE conversation_id = ?
", $conversationId);

if (empty($data))
{
return $this->error(\XF::phrase('conversationview_conversation_id_not_found'));
}

// get title
$conversationTitle = $data['title'];

// get starter
$starter = $data['username'];

//########################################
// get recipients

// define variable
$recipients = '';

$var = $data['recipients'];

if ($var != '')
{
// unserialize blob data
$varArray = json_decode($var, true);

foreach ($varArray AS $value)
{
$recipients = $recipients . ', ' . $value['username'];
}

$recipients = ltrim($recipients, ',');
}

//########################################
// get messages

$messageFinder = $this->finder('XF:ConversationMessage');

$messages = $messageFinder
->with('Conversation')
->with('User')
->where('Conversation.conversation_id', '=', $conversationId)
->order('message_date', 'ASC')
->fetch();

// prepare viewParams
$viewParams = [
'conversationId' => $conversationId,
'conversationTitle' => $conversationTitle,
'starter' => $starter,
'recipients' => $recipients,
'messages' => $messages
];

// send to template
return $this->view('Andy\ConversationSearch:Conversation', 'andy_conversationview_conversation', $viewParams);
}

public function actionViewAttachments()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get messageId
$messageId = $this->filter('message_id', 'uint');

// verify messageId
if ($messageId == '')
{
return $this->error(\XF::phrase('conversationview_message_id_missing'));
}

// get db
$db = \XF::db();

// run query
$attachmentIds = $db->fetchAll("
SELECT xf_attachment.attachment_id,
xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash,
xf_attachment_data.thumbnail_width
FROM xf_attachment_data
INNER JOIN xf_attachment ON xf_attachment.data_id = xf_attachment_data.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.content_id = ?
", array('conversation_message', $messageId));

$results = array();

foreach ($attachmentIds as $value)
{
if ($value['thumbnail_width'] > 0)
{
// get dataId
$dataId = $value['data_id'];

// get path
$path = sprintf('attachments/%d/%d-%s.jpg',
floor($dataId / 1000),
$dataId,
$value['file_hash']
);

// get $thumbUrl
$thumbUrl = $this->app()->applyExternalDataUrl($path);

// get dataId
$dataId = $value['data_id'];

// get fileHash
$fileHash = $value['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = 'internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Basic board information -> Board Url
$boardUrl = $options->boardUrl;

// get results
$results[] = '<a href="' . $boardUrl . '/conversationview/image/?attachment_id=' . $value['attachment_id'] . '">' . $value['filename'] . '</a>' . '<br /><br />' . '<img src="' . $thumbUrl . '">' . '<br />';

}

if ($value['thumbnail_width'] == 0)
{
// get dataId
$dataId = $value['data_id'];

// get fileHash
$fileHash = $value['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = 'internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Basic board information -> Board Url
$boardUrl = $options->boardUrl;

// get results
$results[] = '<a href="' . $boardUrl . '/conversationview/download/?attachment_id=' . $value['attachment_id'] . '">' . $value['filename'] . '</a>' . '<br />';
}
}

// prepare viewParams
$viewParams = [
'messageId' => $messageId,
'results' => $results
];

// send to template
return $this->view('Andy\ConversationSearch:View', 'andy_conversationview_attachments', $viewParams);
}

public function actionDownload()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get attachmentId
$attachmentId = $this->filter('attachment_id', 'uint');

// verify messageId
if ($attachmentId == '')
{
return $this->error(\XF::phrase('conversationview_attachment_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Board path
$boardPath = $options->conversationViewBoardPath;

// verify boardPath
if ($boardPath == '')
{
return $this->error(\XF::phrase('conversationview_board_path_missing_in_options_page'));
}

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash
FROM xf_attachment
INNER JOIN xf_attachment_data ON xf_attachment_data.data_id = xf_attachment.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.attachment_id = ?
", array('conversation_message', $attachmentId));

// get dataId
$dataId = $data['data_id'];

// get fileHash
$fileHash = $data['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = '/internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get filePath
$filePath = $boardPath . $attachmentPath;

// set content-type
header("Content-type:application/octet-stream");

// get fileName
$fileName = str_replace(' ', '-', $data['filename']);

// set content-disposition
header('Content-Disposition: attachment; filename=' . $fileName);

// read file
readfile($filePath);

// exit
exit();
}

public function actionImage()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get attachmentId
$attachmentId = $this->filter('attachment_id', 'uint');

// verify messageId
if ($attachmentId == '')
{
return $this->error(\XF::phrase('conversationview_attachment_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Board path
$boardPath = $options->conversationViewBoardPath;

// verify boardPath
if ($boardPath == '')
{
return $this->error(\XF::phrase('conversationview_board_path_error_in_options_page'));
}

if (!file_exists($boardPath))
{
return $this->error(\XF::phrase('conversationview_board_path_error_in_options_page'));
}

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash
FROM xf_attachment
INNER JOIN xf_attachment_data ON xf_attachment_data.data_id = xf_attachment.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.attachment_id = ?
", array('conversation_message', $attachmentId));

// get dataId
$dataId = $data['data_id'];

// get fileHash
$fileHash = $data['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = '/internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get filePath
$filePath = $boardPath . $attachmentPath;

// get extension
$extension = \XF\Util\File::getFileExtension($data['filename']);

// set header
if ($extension == 'jpg')
{
header("Content-type:image/jpg");
}

// set header
if ($extension == 'jpeg')
{
header("Content-type:image/jpeg");
}

// set header
if ($extension == 'gif')
{
header("Content-type:image/gif");
}

// set header
if ($extension == 'png')
{
header("Content-type:image/png");
}

// get fileName
$fileName = str_replace(' ', '-', $data['filename']);

// display image
echo file_get_contents($filePath);

// exit
exit();
}

public function actionFilter()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// send to template
return $this->view('Andy\ConversationView:Filter', 'andy_conversationview_filter');
}

public function actionDelete()
{
// get visitor
$visitor = \XF::visitor();

// check for user group permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get conversationId
$conversationId = $this->filter('conversation_id', 'uint');

// verify conversationId
if ($conversationId == '')
{
return $this->error(\XF::phrase('conversationview_conversation_id_missing'));
}

// get db
$db = \XF::db();

//########################################
// delete attachments
//########################################

$messageIds = $db->fetchAllColumn("
SELECT message_id
FROM xf_conversation_message
WHERE conversation_id = ?
", $conversationId);

if (!empty($messageIds))
{
// create whereclause
$whereclause = 'AND (content_id = ' . implode(' OR content_id = ', $messageIds);
$whereclause = $whereclause . ')';

// delete row
$db->query("
DELETE FROM xf_attachment
WHERE content_type = ?
$whereclause
", 'conversation_message');
}

//########################################
// delete conversations
//########################################

// delete row
$db->query("
DELETE FROM xf_conversation_master
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_message
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_recipient
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_user
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_user_alert
WHERE content_type = ?
AND content_id = ?
", array('conversation_message', $conversationId));

// return redirect
return $this->redirect($this->buildLink('conversationview'));
}
}
 
Замени ConversationView.php на этот:
<?php

namespace Andy\ConversationView\Pub\Controller;

use XF\Pub\Controller\AbstractController;

class ConversationView extends AbstractController
{
public function actionIndex()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Limit
$limit = $options->conversationViewLimit;

// get username
$username = $this->filter('username', 'str');

// get db
$db = \XF::db();

if ($username == '')
{
// run query
$results = $db->fetchAll("
SELECT conversation_id,
title,
user_id,
username,
last_message_date,
reply_count,
recipients
FROM xf_conversation_master
ORDER BY last_message_date DESC
LIMIT ?
", $limit);
}

if ($username != '')
{
// run query
$results = $db->fetchAll("
SELECT conversation_id,
title,
user_id,
username,
last_message_date,
reply_count,
recipients
FROM xf_conversation_master
WHERE username = ?
ORDER BY last_message_date DESC
LIMIT ?
", array($username, $limit));
}

if (!empty($results))
{
// get users
foreach ($results as $k => $v)
{
// get user
$user = array(
'user_id' => $v['user_id'],
'username' => $v['username']
);

//########################################
// get recipients

// define variable
$recipients = '';

$var = $v['recipients'];

if ($var != '')
{
// unserialize blob data
$varArray = json_decode($var, true);

foreach ($varArray AS $value)
{
$recipients = $recipients . ', ' . $value['username'];
}

$recipients = ltrim($recipients, ',');
}

// create resultsNew array
$resultsNew[] = array(
'conversation_id' => $v['conversation_id'],
'title' => $v['title'],
'user' => $user,
'recipients' => $recipients,
'last_message_date' => $v['last_message_date'],
'reply_count' => $v['reply_count']
);
}

// rename variable
$results = $resultsNew;
}

// prepare viewParams
$viewParams = [
'username' => $username,
'limit' => $limit,
'results' => $results
];

// send to template
return $this->view('Andy\ConversationView:Index', 'andy_conversationview', $viewParams);
}

public function actionConversation()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get conversationId
$conversationId = $this->filter('conversation_id', 'uint');

// verify conversationId
if ($conversationId == '')
{
return $this->error(\XF::phrase('conversationview_conversation_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Limit
$limit = $options->conversationViewLimit;

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT title,
username,
recipients
FROM xf_conversation_master
WHERE conversation_id = ?
", $conversationId);

if (empty($data))
{
return $this->error(\XF::phrase('conversationview_conversation_id_not_found'));
}

// get title
$conversationTitle = $data['title'];

// get starter
$starter = $data['username'];

//########################################
// get recipients

// define variable
$recipients = '';

$var = $data['recipients'];

if ($var != '')
{
// unserialize blob data
$varArray = json_decode($var, true);

foreach ($varArray AS $value)
{
$recipients = $recipients . ', ' . $value['username'];
}

$recipients = ltrim($recipients, ',');
}

//########################################
// get messages

$messageFinder = $this->finder('XF:ConversationMessage');

$messages = $messageFinder
->with('Conversation')
->with('User')
->where('Conversation.conversation_id', '=', $conversationId)
->order('message_date', 'ASC')
->fetch();

// prepare viewParams
$viewParams = [
'conversationId' => $conversationId,
'conversationTitle' => $conversationTitle,
'starter' => $starter,
'recipients' => $recipients,
'messages' => $messages
];

// send to template
return $this->view('Andy\ConversationSearch:Conversation', 'andy_conversationview_conversation', $viewParams);
}

public function actionViewAttachments()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get messageId
$messageId = $this->filter('message_id', 'uint');

// verify messageId
if ($messageId == '')
{
return $this->error(\XF::phrase('conversationview_message_id_missing'));
}

// get db
$db = \XF::db();

// run query
$attachmentIds = $db->fetchAll("
SELECT xf_attachment.attachment_id,
xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash,
xf_attachment_data.thumbnail_width
FROM xf_attachment_data
INNER JOIN xf_attachment ON xf_attachment.data_id = xf_attachment_data.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.content_id = ?
", array('conversation_message', $messageId));

$results = array();

foreach ($attachmentIds as $value)
{
if ($value['thumbnail_width'] > 0)
{
// get dataId
$dataId = $value['data_id'];

// get path
$path = sprintf('attachments/%d/%d-%s.jpg',
floor($dataId / 1000),
$dataId,
$value['file_hash']
);

// get $thumbUrl
$thumbUrl = $this->app()->applyExternalDataUrl($path);

// get dataId
$dataId = $value['data_id'];

// get fileHash
$fileHash = $value['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = 'internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Basic board information -> Board Url
$boardUrl = $options->boardUrl;

// get results
$results[] = '<a href="' . $boardUrl . '/conversationview/image/?attachment_id=' . $value['attachment_id'] . '">' . $value['filename'] . '</a>' . '<br /><br />' . '<img src="' . $thumbUrl . '">' . '<br />';

}

if ($value['thumbnail_width'] == 0)
{
// get dataId
$dataId = $value['data_id'];

// get fileHash
$fileHash = $value['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = 'internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Basic board information -> Board Url
$boardUrl = $options->boardUrl;

// get results
$results[] = '<a href="' . $boardUrl . '/conversationview/download/?attachment_id=' . $value['attachment_id'] . '">' . $value['filename'] . '</a>' . '<br />';
}
}

// prepare viewParams
$viewParams = [
'messageId' => $messageId,
'results' => $results
];

// send to template
return $this->view('Andy\ConversationSearch:View', 'andy_conversationview_attachments', $viewParams);
}

public function actionDownload()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get attachmentId
$attachmentId = $this->filter('attachment_id', 'uint');

// verify messageId
if ($attachmentId == '')
{
return $this->error(\XF::phrase('conversationview_attachment_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Board path
$boardPath = $options->conversationViewBoardPath;

// verify boardPath
if ($boardPath == '')
{
return $this->error(\XF::phrase('conversationview_board_path_missing_in_options_page'));
}

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash
FROM xf_attachment
INNER JOIN xf_attachment_data ON xf_attachment_data.data_id = xf_attachment.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.attachment_id = ?
", array('conversation_message', $attachmentId));

// get dataId
$dataId = $data['data_id'];

// get fileHash
$fileHash = $data['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = '/internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get filePath
$filePath = $boardPath . $attachmentPath;

// set content-type
header("Content-type:application/octet-stream");

// get fileName
$fileName = str_replace(' ', '-', $data['filename']);

// set content-disposition
header('Content-Disposition: attachment; filename=' . $fileName);

// read file
readfile($filePath);

// exit
exit();
}

public function actionImage()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get attachmentId
$attachmentId = $this->filter('attachment_id', 'uint');

// verify messageId
if ($attachmentId == '')
{
return $this->error(\XF::phrase('conversationview_attachment_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Board path
$boardPath = $options->conversationViewBoardPath;

// verify boardPath
if ($boardPath == '')
{
return $this->error(\XF::phrase('conversationview_board_path_error_in_options_page'));
}

if (!file_exists($boardPath))
{
return $this->error(\XF::phrase('conversationview_board_path_error_in_options_page'));
}

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash
FROM xf_attachment
INNER JOIN xf_attachment_data ON xf_attachment_data.data_id = xf_attachment.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.attachment_id = ?
", array('conversation_message', $attachmentId));

// get dataId
$dataId = $data['data_id'];

// get fileHash
$fileHash = $data['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = '/internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get filePath
$filePath = $boardPath . $attachmentPath;

// get extension
$extension = \XF\Util\File::getFileExtension($data['filename']);

// set header
if ($extension == 'jpg')
{
header("Content-type:image/jpg");
}

// set header
if ($extension == 'jpeg')
{
header("Content-type:image/jpeg");
}

// set header
if ($extension == 'gif')
{
header("Content-type:image/gif");
}

// set header
if ($extension == 'png')
{
header("Content-type:image/png");
}

// get fileName
$fileName = str_replace(' ', '-', $data['filename']);

// display image
echo file_get_contents($filePath);

// exit
exit();
}

public function actionFilter()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// send to template
return $this->view('Andy\ConversationView:Filter', 'andy_conversationview_filter');
}

public function actionDelete()
{
// get visitor
$visitor = \XF::visitor();

// check for user group permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get conversationId
$conversationId = $this->filter('conversation_id', 'uint');

// verify conversationId
if ($conversationId == '')
{
return $this->error(\XF::phrase('conversationview_conversation_id_missing'));
}

// get db
$db = \XF::db();

//########################################
// delete attachments
//########################################

$messageIds = $db->fetchAllColumn("
SELECT message_id
FROM xf_conversation_message
WHERE conversation_id = ?
", $conversationId);

if (!empty($messageIds))
{
// create whereclause
$whereclause = 'AND (content_id = ' . implode(' OR content_id = ', $messageIds);
$whereclause = $whereclause . ')';

// delete row
$db->query("
DELETE FROM xf_attachment
WHERE content_type = ?
$whereclause
", 'conversation_message');
}

//########################################
// delete conversations
//########################################

// delete row
$db->query("
DELETE FROM xf_conversation_master
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_message
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_recipient
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_user
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_user_alert
WHERE content_type = ?
AND content_id = ?
", array('conversation_message', $conversationId));

// return redirect
return $this->redirect($this->buildLink('conversationview'));
}
}

заменил /сайт.ru/public_html/src/addons/Andy/ConversationView/Pub/Controller/ConversationView.php
содержимое ConversationView.php
ничего не изменилось
 
заменил /сайт.ru/public_html/src/addons/Andy/ConversationView/Pub/Controller/ConversationView.php
содержимое ConversationView.php
ничего не изменилось
секунду, перепроверю у себя.

Замените на этот код:
<?php

namespace Andy\ConversationView\Pub\Controller;

use XF\Pub\Controller\AbstractController;

class ConversationView extends AbstractController
{
public function actionIndex()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Limit
$limit = $options->conversationViewLimit;

// get username
$username = $this->filter('username', 'str');

// get db
$db = \XF::db();

if ($username == '')
{
// run query
$results = $db->fetchAll("
SELECT conversation_id,
title,
user_id,
username,
last_message_date,
reply_count,
recipients
FROM xf_conversation_master
ORDER BY last_message_date DESC
LIMIT ?
", $limit);
}

if ($username != '')
{
// run query
$results = $db->fetchAll("
SELECT conversation_id,
title,
user_id,
username,
last_message_date,
reply_count,
recipients
FROM xf_conversation_master
WHERE username = ?
ORDER BY last_message_date DESC
LIMIT ?
", array($username, $limit));
}

if (!empty($results))
{
// get users
foreach ($results as $k => $v)
{
// get user
$user = array(
'user_id' => $v['user_id'],
'username' => $v['username']
);

//########################################
// get recipients

// define variable
$recipients = '';

$var = $v['recipients'];

if ($var != '')
{
// unserialize blob data
$varArray = json_decode($var, true);

foreach ($varArray AS $value)
{
$recipients = $recipients . ', ' . $value['username'];
}

$recipients = ltrim($recipients, ',');
}

// create resultsNew array
$resultsNew[] = array(
'conversation_id' => $v['conversation_id'],
'title' => $v['title'],
'user' => $user,
'recipients' => $recipients,
'last_message_date' => $v['last_message_date'],
'reply_count' => $v['reply_count']
);
}

// rename variable
$results = $resultsNew;
}

// prepare viewParams
$viewParams = [
'username' => $username,
'limit' => $limit,
'results' => $results
];

// send to template
return $this->view('Andy\ConversationView:Index', 'andy_conversationview', $viewParams);
}

public function actionConversation()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get conversationId
$conversationId = $this->filter('conversation_id', 'uint');

// verify conversationId
if ($conversationId == '')
{
return $this->error(\XF::phrase('conversationview_conversation_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Limit
$limit = $options->conversationViewLimit;

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT title,
username,
recipients
FROM xf_conversation_master
WHERE conversation_id = ?
", $conversationId);

if (empty($data))
{
return $this->error(\XF::phrase('conversationview_conversation_id_not_found'));
}

// get title
$conversationTitle = $data['title'];

// get starter
$starter = $data['username'];

//########################################
// get recipients

// define variable
$recipients = '';

$var = $data['recipients'];

if ($var != '')
{
// unserialize blob data
$varArray = json_decode($var, true);

foreach ($varArray AS $value)
{
$recipients = $recipients . ', ' . $value['username'];
}

$recipients = ltrim($recipients, ',');
}

//########################################
// get messages

$messageFinder = $this->finder('XF:ConversationMessage');

$messages = $messageFinder
->with('Conversation')
->with('User')
->where('Conversation.conversation_id', '=', $conversationId)
->order('message_date', 'ASC')
->fetch();

// prepare viewParams
$viewParams = [
'conversationId' => $conversationId,
'conversationTitle' => $conversationTitle,
'starter' => $starter,
'recipients' => $recipients,
'messages' => $messages
];

// send to template
return $this->view('Andy\ConversationSearch:Conversation', 'andy_conversationview_conversation', $viewParams);
}

public function actionViewAttachments()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get messageId
$messageId = $this->filter('message_id', 'uint');

// verify messageId
if ($messageId == '')
{
return $this->error(\XF::phrase('conversationview_message_id_missing'));
}

// get db
$db = \XF::db();

// run query
$attachmentIds = $db->fetchAll("
SELECT xf_attachment.attachment_id,
xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash,
xf_attachment_data.thumbnail_width
FROM xf_attachment_data
INNER JOIN xf_attachment ON xf_attachment.data_id = xf_attachment_data.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.content_id = ?
", array('conversation_message', $messageId));

$results = array();

foreach ($attachmentIds as $value)
{
if ($value['thumbnail_width'] > 0)
{
// get dataId
$dataId = $value['data_id'];

// get path
$path = sprintf('attachments/%d/%d-%s.jpg',
floor($dataId / 1000),
$dataId,
$value['file_hash']
);

// get $thumbUrl
$thumbUrl = $this->app()->applyExternalDataUrl($path);

// get dataId
$dataId = $value['data_id'];

// get fileHash
$fileHash = $value['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = 'internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Basic board information -> Board Url
$boardUrl = $options->boardUrl;

// get results
$results[] = '<a href="' . $boardUrl . '/conversationview/image/?attachment_id=' . $value['attachment_id'] . '">' . $value['filename'] . '</a>' . '<br /><br />' . '<img src="' . $thumbUrl . '">' . '<br />';

}

if ($value['thumbnail_width'] == 0)
{
// get dataId
$dataId = $value['data_id'];

// get fileHash
$fileHash = $value['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = 'internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Basic board information -> Board Url
$boardUrl = $options->boardUrl;

// get results
$results[] = '<a href="' . $boardUrl . '/conversationview/download/?attachment_id=' . $value['attachment_id'] . '">' . $value['filename'] . '</a>' . '<br />';
}
}

// prepare viewParams
$viewParams = [
'messageId' => $messageId,
'results' => $results
];

// send to template
return $this->view('Andy\ConversationSearch:View', 'andy_conversationview_attachments', $viewParams);
}

public function actionDownload()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get attachmentId
$attachmentId = $this->filter('attachment_id', 'uint');

// verify messageId
if ($attachmentId == '')
{
return $this->error(\XF::phrase('conversationview_attachment_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Board path
$boardPath = $options->conversationViewBoardPath;

// verify boardPath
if ($boardPath == '')
{
return $this->error(\XF::phrase('conversationview_board_path_missing_in_options_page'));
}

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash
FROM xf_attachment
INNER JOIN xf_attachment_data ON xf_attachment_data.data_id = xf_attachment.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.attachment_id = ?
", array('conversation_message', $attachmentId));

// get dataId
$dataId = $data['data_id'];

// get fileHash
$fileHash = $data['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = '/internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get filePath
$filePath = $boardPath . $attachmentPath;

// set content-type
header("Content-type:application/octet-stream");

// get fileName
$fileName = str_replace(' ', '-', $data['filename']);

// set content-disposition
header('Content-Disposition: attachment; filename=' . $fileName);

// read file
readfile($filePath);

// exit
exit();
}

public function actionImage()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get attachmentId
$attachmentId = $this->filter('attachment_id', 'uint');

// verify messageId
if ($attachmentId == '')
{
return $this->error(\XF::phrase('conversationview_attachment_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Board path
$boardPath = $options->conversationViewBoardPath;

// verify boardPath
if ($boardPath == '')
{
return $this->error(\XF::phrase('conversationview_board_path_error_in_options_page'));
}

if (!file_exists($boardPath))
{
return $this->error(\XF::phrase('conversationview_board_path_error_in_options_page'));
}

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash
FROM xf_attachment
INNER JOIN xf_attachment_data ON xf_attachment_data.data_id = xf_attachment.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.attachment_id = ?
", array('conversation_message', $attachmentId));

// get dataId
$dataId = $data['data_id'];

// get fileHash
$fileHash = $data['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = '/internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get filePath
$filePath = $boardPath . $attachmentPath;

// get extension
$extension = \XF\Util\File::getFileExtension($data['filename']);

// set header
if ($extension == 'jpg')
{
header("Content-type:image/jpg");
}

// set header
if ($extension == 'jpeg')
{
header("Content-type:image/jpeg");
}

// set header
if ($extension == 'gif')
{
header("Content-type:image/gif");
}

// set header
if ($extension == 'png')
{
header("Content-type:image/png");
}

// get fileName
$fileName = str_replace(' ', '-', $data['filename']);

// display image
echo file_get_contents($filePath);

// exit
exit();
}

public function actionFilter()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// send to template
return $this->view('Andy\ConversationView:Filter', 'andy_conversationview_filter');
}

public function actionDelete()
{
// get visitor
$visitor = \XF::visitor();

// check for user group permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get conversationId
$conversationId = $this->filter('conversation_id', 'uint');

// verify conversationId
if ($conversationId == '')
{
return $this->error(\XF::phrase('conversationview_conversation_id_missing'));
}

// get db
$db = \XF::db();

//########################################
// delete attachments
//########################################

$messageIds = $db->fetchAllColumn("
SELECT message_id
FROM xf_conversation_message
WHERE conversation_id = ?
", $conversationId);

if (!empty($messageIds))
{
// create whereclause
$whereclause = 'AND (content_id = ' . implode(' OR content_id = ', $messageIds);
$whereclause = $whereclause . ')';

// delete row
$db->query("
DELETE FROM xf_attachment
WHERE content_type = ?
$whereclause
", 'conversation_message');
}

//########################################
// delete conversations
//########################################

// delete row
$db->query("
DELETE FROM xf_conversation_master
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_message
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_recipient
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_user
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_user_alert
WHERE content_type = ?
AND content_id = ?
", array('conversation_message', $conversationId));

// return redirect
return $this->redirect($this->buildLink('conversationview'));
}
}
 
Последнее редактирование модератором:
Замените на этот код:
<?php

namespace Andy\ConversationView\Pub\Controller;

use XF\Pub\Controller\AbstractController;

class ConversationView extends AbstractController
{
public function actionIndex()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Limit
$limit = $options->conversationViewLimit;

// get username
$username = $this->filter('username', 'str');

// get db
$db = \XF::db();

if ($username == '')
{
// run query
$results = $db->fetchAll("
SELECT conversation_id,
title,
user_id,
username,
last_message_date,
reply_count,
recipients
FROM xf_conversation_master
ORDER BY last_message_date DESC
LIMIT ?
", $limit);
}

if ($username != '')
{
// run query
$results = $db->fetchAll("
SELECT conversation_id,
title,
user_id,
username,
last_message_date,
reply_count,
recipients
FROM xf_conversation_master
WHERE username = ?
ORDER BY last_message_date DESC
LIMIT ?
", array($username, $limit));
}

if (!empty($results))
{
// get users
foreach ($results as $k => $v)
{
// get user
$user = array(
'user_id' => $v['user_id'],
'username' => $v['username']
);

//########################################
// get recipients

// define variable
$recipients = '';

$var = $v['recipients'];

if ($var != '')
{
// unserialize blob data
$varArray = json_decode($var, true);

foreach ($varArray AS $value)
{
$recipients = $recipients . ', ' . $value['username'];
}

$recipients = ltrim($recipients, ',');
}

// create resultsNew array
$resultsNew[] = array(
'conversation_id' => $v['conversation_id'],
'title' => $v['title'],
'user' => $user,
'recipients' => $recipients,
'last_message_date' => $v['last_message_date'],
'reply_count' => $v['reply_count']
);
}

// rename variable
$results = $resultsNew;
}

// prepare viewParams
$viewParams = [
'username' => $username,
'limit' => $limit,
'results' => $results
];

// send to template
return $this->view('Andy\ConversationView:Index', 'andy_conversationview', $viewParams);
}

public function actionConversation()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get conversationId
$conversationId = $this->filter('conversation_id', 'uint');

// verify conversationId
if ($conversationId == '')
{
return $this->error(\XF::phrase('conversationview_conversation_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Limit
$limit = $options->conversationViewLimit;

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT title,
username,
recipients
FROM xf_conversation_master
WHERE conversation_id = ?
", $conversationId);

if (empty($data))
{
return $this->error(\XF::phrase('conversationview_conversation_id_not_found'));
}

// get title
$conversationTitle = $data['title'];

// get starter
$starter = $data['username'];

//########################################
// get recipients

// define variable
$recipients = '';

$var = $data['recipients'];

if ($var != '')
{
// unserialize blob data
$varArray = json_decode($var, true);

foreach ($varArray AS $value)
{
$recipients = $recipients . ', ' . $value['username'];
}

$recipients = ltrim($recipients, ',');
}

//########################################
// get messages

$messageFinder = $this->finder('XF:ConversationMessage');

$messages = $messageFinder
->with('Conversation')
->with('User')
->where('Conversation.conversation_id', '=', $conversationId)
->order('message_date', 'ASC')
->fetch();

// prepare viewParams
$viewParams = [
'conversationId' => $conversationId,
'conversationTitle' => $conversationTitle,
'starter' => $starter,
'recipients' => $recipients,
'messages' => $messages
];

// send to template
return $this->view('Andy\ConversationSearch:Conversation', 'andy_conversationview_conversation', $viewParams);
}

public function actionViewAttachments()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get messageId
$messageId = $this->filter('message_id', 'uint');

// verify messageId
if ($messageId == '')
{
return $this->error(\XF::phrase('conversationview_message_id_missing'));
}

// get db
$db = \XF::db();

// run query
$attachmentIds = $db->fetchAll("
SELECT xf_attachment.attachment_id,
xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash,
xf_attachment_data.thumbnail_width
FROM xf_attachment_data
INNER JOIN xf_attachment ON xf_attachment.data_id = xf_attachment_data.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.content_id = ?
", array('conversation_message', $messageId));

$results = array();

foreach ($attachmentIds as $value)
{
if ($value['thumbnail_width'] > 0)
{
// get dataId
$dataId = $value['data_id'];

// get path
$path = sprintf('attachments/%d/%d-%s.jpg',
floor($dataId / 1000),
$dataId,
$value['file_hash']
);

// get $thumbUrl
$thumbUrl = $this->app()->applyExternalDataUrl($path);

// get dataId
$dataId = $value['data_id'];

// get fileHash
$fileHash = $value['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = 'internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Basic board information -> Board Url
$boardUrl = $options->boardUrl;

// get results
$results[] = '<a href="' . $boardUrl . '/conversationview/image/?attachment_id=' . $value['attachment_id'] . '">' . $value['filename'] . '</a>' . '<br /><br />' . '<img src="' . $thumbUrl . '">' . '<br />';

}

if ($value['thumbnail_width'] == 0)
{
// get dataId
$dataId = $value['data_id'];

// get fileHash
$fileHash = $value['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = 'internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Basic board information -> Board Url
$boardUrl = $options->boardUrl;

// get results
$results[] = '<a href="' . $boardUrl . '/conversationview/download/?attachment_id=' . $value['attachment_id'] . '">' . $value['filename'] . '</a>' . '<br />';
}
}

// prepare viewParams
$viewParams = [
'messageId' => $messageId,
'results' => $results
];

// send to template
return $this->view('Andy\ConversationSearch:View', 'andy_conversationview_attachments', $viewParams);
}

public function actionDownload()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get attachmentId
$attachmentId = $this->filter('attachment_id', 'uint');

// verify messageId
if ($attachmentId == '')
{
return $this->error(\XF::phrase('conversationview_attachment_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Board path
$boardPath = $options->conversationViewBoardPath;

// verify boardPath
if ($boardPath == '')
{
return $this->error(\XF::phrase('conversationview_board_path_missing_in_options_page'));
}

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash
FROM xf_attachment
INNER JOIN xf_attachment_data ON xf_attachment_data.data_id = xf_attachment.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.attachment_id = ?
", array('conversation_message', $attachmentId));

// get dataId
$dataId = $data['data_id'];

// get fileHash
$fileHash = $data['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = '/internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get filePath
$filePath = $boardPath . $attachmentPath;

// set content-type
header("Content-type:application/octet-stream");

// get fileName
$fileName = str_replace(' ', '-', $data['filename']);

// set content-disposition
header('Content-Disposition: attachment; filename=' . $fileName);

// read file
readfile($filePath);

// exit
exit();
}

public function actionImage()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get attachmentId
$attachmentId = $this->filter('attachment_id', 'uint');

// verify messageId
if ($attachmentId == '')
{
return $this->error(\XF::phrase('conversationview_attachment_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Board path
$boardPath = $options->conversationViewBoardPath;

// verify boardPath
if ($boardPath == '')
{
return $this->error(\XF::phrase('conversationview_board_path_error_in_options_page'));
}

if (!file_exists($boardPath))
{
return $this->error(\XF::phrase('conversationview_board_path_error_in_options_page'));
}

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash
FROM xf_attachment
INNER JOIN xf_attachment_data ON xf_attachment_data.data_id = xf_attachment.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.attachment_id = ?
", array('conversation_message', $attachmentId));

// get dataId
$dataId = $data['data_id'];

// get fileHash
$fileHash = $data['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = '/internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get filePath
$filePath = $boardPath . $attachmentPath;

// get extension
$extension = \XF\Util\File::getFileExtension($data['filename']);

// set header
if ($extension == 'jpg')
{
header("Content-type:image/jpg");
}

// set header
if ($extension == 'jpeg')
{
header("Content-type:image/jpeg");
}

// set header
if ($extension == 'gif')
{
header("Content-type:image/gif");
}

// set header
if ($extension == 'png')
{
header("Content-type:image/png");
}

// get fileName
$fileName = str_replace(' ', '-', $data['filename']);

// display image
echo file_get_contents($filePath);

// exit
exit();
}

public function actionFilter()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// send to template
return $this->view('Andy\ConversationView:Filter', 'andy_conversationview_filter');
}

public function actionDelete()
{
// get visitor
$visitor = \XF::visitor();

// check for user group permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get conversationId
$conversationId = $this->filter('conversation_id', 'uint');

// verify conversationId
if ($conversationId == '')
{
return $this->error(\XF::phrase('conversationview_conversation_id_missing'));
}

// get db
$db = \XF::db();

//########################################
// delete attachments
//########################################

$messageIds = $db->fetchAllColumn("
SELECT message_id
FROM xf_conversation_message
WHERE conversation_id = ?
", $conversationId);

if (!empty($messageIds))
{
// create whereclause
$whereclause = 'AND (content_id = ' . implode(' OR content_id = ', $messageIds);
$whereclause = $whereclause . ')';

// delete row
$db->query("
DELETE FROM xf_attachment
WHERE content_type = ?
$whereclause
", 'conversation_message');
}

//########################################
// delete conversations
//########################################

// delete row
$db->query("
DELETE FROM xf_conversation_master
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_message
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_recipient
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_user
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_user_alert
WHERE content_type = ?
AND content_id = ?
", array('conversation_message', $conversationId));

// return redirect
return $this->redirect($this->buildLink('conversationview'));
}
}
Ничего не изменилось.
 
а без плагина работала форма ответов?
В самом сообщении темы я написал:
Что никакие плагины я не ставил.
Форум работает 3 года.
Сейчас зашел - формы ответов нет, некоторые кнопки в админке и на самом форуме не нажимаются.
 

Вложения

  • 1111112222222222222222333333333333333333333333.png
    1111112222222222222222333333333333333333333333.png
    51.2 KB · Просмотры: 11
возможно стоит обновить движок?
не думаю, что в этом дело

Хотел попробовать отключить плагины, не даёт.
Жму на кнопку, ничего не происходит. Ощущение что что то с javascript

аааааааааааааааааааааааааа.png
 
Последнее редактирование модератором:
Замени ConversationView.php на этот:
<?php

namespace Andy\ConversationView\Pub\Controller;

use XF\Pub\Controller\AbstractController;

class ConversationView extends AbstractController
{
public function actionIndex()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Limit
$limit = $options->conversationViewLimit;

// get username
$username = $this->filter('username', 'str');

// get db
$db = \XF::db();

if ($username == '')
{
// run query
$results = $db->fetchAll("
SELECT conversation_id,
title,
user_id,
username,
last_message_date,
reply_count,
recipients
FROM xf_conversation_master
ORDER BY last_message_date DESC
LIMIT ?
", $limit);
}

if ($username != '')
{
// run query
$results = $db->fetchAll("
SELECT conversation_id,
title,
user_id,
username,
last_message_date,
reply_count,
recipients
FROM xf_conversation_master
WHERE username = ?
ORDER BY last_message_date DESC
LIMIT ?
", array($username, $limit));
}

if (!empty($results))
{
// get users
foreach ($results as $k => $v)
{
// get user
$user = array(
'user_id' => $v['user_id'],
'username' => $v['username']
);

//########################################
// get recipients

// define variable
$recipients = '';

$var = $v['recipients'];

if ($var != '')
{
// unserialize blob data
$varArray = json_decode($var, true);

foreach ($varArray AS $value)
{
$recipients = $recipients . ', ' . $value['username'];
}

$recipients = ltrim($recipients, ',');
}

// create resultsNew array
$resultsNew[] = array(
'conversation_id' => $v['conversation_id'],
'title' => $v['title'],
'user' => $user,
'recipients' => $recipients,
'last_message_date' => $v['last_message_date'],
'reply_count' => $v['reply_count']
);
}

// rename variable
$results = $resultsNew;
}

// prepare viewParams
$viewParams = [
'username' => $username,
'limit' => $limit,
'results' => $results
];

// send to template
return $this->view('Andy\ConversationView:Index', 'andy_conversationview', $viewParams);
}

public function actionConversation()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get conversationId
$conversationId = $this->filter('conversation_id', 'uint');

// verify conversationId
if ($conversationId == '')
{
return $this->error(\XF::phrase('conversationview_conversation_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Limit
$limit = $options->conversationViewLimit;

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT title,
username,
recipients
FROM xf_conversation_master
WHERE conversation_id = ?
", $conversationId);

if (empty($data))
{
return $this->error(\XF::phrase('conversationview_conversation_id_not_found'));
}

// get title
$conversationTitle = $data['title'];

// get starter
$starter = $data['username'];

//########################################
// get recipients

// define variable
$recipients = '';

$var = $data['recipients'];

if ($var != '')
{
// unserialize blob data
$varArray = json_decode($var, true);

foreach ($varArray AS $value)
{
$recipients = $recipients . ', ' . $value['username'];
}

$recipients = ltrim($recipients, ',');
}

//########################################
// get messages

$messageFinder = $this->finder('XF:ConversationMessage');

$messages = $messageFinder
->with('Conversation')
->with('User')
->where('Conversation.conversation_id', '=', $conversationId)
->order('message_date', 'ASC')
->fetch();

// prepare viewParams
$viewParams = [
'conversationId' => $conversationId,
'conversationTitle' => $conversationTitle,
'starter' => $starter,
'recipients' => $recipients,
'messages' => $messages
];

// send to template
return $this->view('Andy\ConversationSearch:Conversation', 'andy_conversationview_conversation', $viewParams);
}

public function actionViewAttachments()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get messageId
$messageId = $this->filter('message_id', 'uint');

// verify messageId
if ($messageId == '')
{
return $this->error(\XF::phrase('conversationview_message_id_missing'));
}

// get db
$db = \XF::db();

// run query
$attachmentIds = $db->fetchAll("
SELECT xf_attachment.attachment_id,
xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash,
xf_attachment_data.thumbnail_width
FROM xf_attachment_data
INNER JOIN xf_attachment ON xf_attachment.data_id = xf_attachment_data.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.content_id = ?
", array('conversation_message', $messageId));

$results = array();

foreach ($attachmentIds as $value)
{
if ($value['thumbnail_width'] > 0)
{
// get dataId
$dataId = $value['data_id'];

// get path
$path = sprintf('attachments/%d/%d-%s.jpg',
floor($dataId / 1000),
$dataId,
$value['file_hash']
);

// get $thumbUrl
$thumbUrl = $this->app()->applyExternalDataUrl($path);

// get dataId
$dataId = $value['data_id'];

// get fileHash
$fileHash = $value['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = 'internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Basic board information -> Board Url
$boardUrl = $options->boardUrl;

// get results
$results[] = '<a href="' . $boardUrl . '/conversationview/image/?attachment_id=' . $value['attachment_id'] . '">' . $value['filename'] . '</a>' . '<br /><br />' . '<img src="' . $thumbUrl . '">' . '<br />';

}

if ($value['thumbnail_width'] == 0)
{
// get dataId
$dataId = $value['data_id'];

// get fileHash
$fileHash = $value['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = 'internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Basic board information -> Board Url
$boardUrl = $options->boardUrl;

// get results
$results[] = '<a href="' . $boardUrl . '/conversationview/download/?attachment_id=' . $value['attachment_id'] . '">' . $value['filename'] . '</a>' . '<br />';
}
}

// prepare viewParams
$viewParams = [
'messageId' => $messageId,
'results' => $results
];

// send to template
return $this->view('Andy\ConversationSearch:View', 'andy_conversationview_attachments', $viewParams);
}

public function actionDownload()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get attachmentId
$attachmentId = $this->filter('attachment_id', 'uint');

// verify messageId
if ($attachmentId == '')
{
return $this->error(\XF::phrase('conversationview_attachment_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Board path
$boardPath = $options->conversationViewBoardPath;

// verify boardPath
if ($boardPath == '')
{
return $this->error(\XF::phrase('conversationview_board_path_missing_in_options_page'));
}

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash
FROM xf_attachment
INNER JOIN xf_attachment_data ON xf_attachment_data.data_id = xf_attachment.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.attachment_id = ?
", array('conversation_message', $attachmentId));

// get dataId
$dataId = $data['data_id'];

// get fileHash
$fileHash = $data['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = '/internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get filePath
$filePath = $boardPath . $attachmentPath;

// set content-type
header("Content-type:application/octet-stream");

// get fileName
$fileName = str_replace(' ', '-', $data['filename']);

// set content-disposition
header('Content-Disposition: attachment; filename=' . $fileName);

// read file
readfile($filePath);

// exit
exit();
}

public function actionImage()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get attachmentId
$attachmentId = $this->filter('attachment_id', 'uint');

// verify messageId
if ($attachmentId == '')
{
return $this->error(\XF::phrase('conversationview_attachment_id_missing'));
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Conversation view -> Board path
$boardPath = $options->conversationViewBoardPath;

// verify boardPath
if ($boardPath == '')
{
return $this->error(\XF::phrase('conversationview_board_path_error_in_options_page'));
}

if (!file_exists($boardPath))
{
return $this->error(\XF::phrase('conversationview_board_path_error_in_options_page'));
}

// get db
$db = \XF::db();

// run query
$data = $db->fetchRow("
SELECT xf_attachment_data.data_id,
xf_attachment_data.filename,
xf_attachment_data.file_hash
FROM xf_attachment
INNER JOIN xf_attachment_data ON xf_attachment_data.data_id = xf_attachment.data_id
WHERE xf_attachment.content_type = ?
AND xf_attachment.attachment_id = ?
", array('conversation_message', $attachmentId));

// get dataId
$dataId = $data['data_id'];

// get fileHash
$fileHash = $data['file_hash'];

// get last folder
$lastFolder = floor($dataId / 1000);

// define full attachment file path
$attachmentPath = '/internal_data/attachments/' . $lastFolder . '/' . $dataId . '-' . $fileHash . '.data';

// get filePath
$filePath = $boardPath . $attachmentPath;

// get extension
$extension = \XF\Util\File::getFileExtension($data['filename']);

// set header
if ($extension == 'jpg')
{
header("Content-type:image/jpg");
}

// set header
if ($extension == 'jpeg')
{
header("Content-type:image/jpeg");
}

// set header
if ($extension == 'gif')
{
header("Content-type:image/gif");
}

// set header
if ($extension == 'png')
{
header("Content-type:image/png");
}

// get fileName
$fileName = str_replace(' ', '-', $data['filename']);

// display image
echo file_get_contents($filePath);

// exit
exit();
}

public function actionFilter()
{
// get visitor
$visitor = \XF::visitor();

// get permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// send to template
return $this->view('Andy\ConversationView:Filter', 'andy_conversationview_filter');
}

public function actionDelete()
{
// get visitor
$visitor = \XF::visitor();

// check for user group permission
if (!$visitor->hasPermission('conversationView', 'view'))
{
return $this->noPermission();
}

// get conversationId
$conversationId = $this->filter('conversation_id', 'uint');

// verify conversationId
if ($conversationId == '')
{
return $this->error(\XF::phrase('conversationview_conversation_id_missing'));
}

// get db
$db = \XF::db();

//########################################
// delete attachments
//########################################

$messageIds = $db->fetchAllColumn("
SELECT message_id
FROM xf_conversation_message
WHERE conversation_id = ?
", $conversationId);

if (!empty($messageIds))
{
// create whereclause
$whereclause = 'AND (content_id = ' . implode(' OR content_id = ', $messageIds);
$whereclause = $whereclause . ')';

// delete row
$db->query("
DELETE FROM xf_attachment
WHERE content_type = ?
$whereclause
", 'conversation_message');
}

//########################################
// delete conversations
//########################################

// delete row
$db->query("
DELETE FROM xf_conversation_master
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_message
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_recipient
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_conversation_user
WHERE conversation_id = ?
", $conversationId);

// delete row
$db->query("
DELETE FROM xf_user_alert
WHERE content_type = ?
AND content_id = ?
", array('conversation_message', $conversationId));

// return redirect
return $this->redirect($this->buildLink('conversationview'));
}
}
У меня вопрос, каким образом это относится к ошибке, если там ясно видно, что проблема в инклюде шаблона от турецкого либо дополнения, либо стиль в целом сам такой.
 
Статус
В этой теме нельзя размещать новые ответы.
Современный облачный хостинг провайдер | Aéza
Назад
Сверху Снизу