new feature: complain

This commit is contained in:
xiaomlove
2022-05-06 17:42:18 +08:00
parent f64834b594
commit 585e2ccfc3
15 changed files with 327 additions and 4 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ class Kernel extends ConsoleKernel
$schedule->command('hr:update_status --ignore_time=1')->hourly()->withoutOverlapping();
$schedule->command('user:delete_expired_token')->dailyAt('04:00');
$schedule->command('claim:settle')->hourly()->between("00:00", "12:00")
->when(function () {Carbon::now()->format('d') == '01';})->withoutOverlapping();
->when(function () {return Carbon::now()->format('d') == '01';})->withoutOverlapping();
}
/**
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('complains', function (Blueprint $table) {
$table->id();
$table->char('uuid', 36);
$table->string('email');
$table->text('body');
$table->dateTime('added');
$table->smallInteger('answered')->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('complains');
}
};
@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('complain_replies', function (Blueprint $table) {
$table->id();
$table->integer('complain');
$table->integer('userid')->default(0);
$table->dateTime('added');
$table->text('body');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('complain_replies');
}
};
+20 -3
View File
@@ -455,7 +455,7 @@ function highlight($search,$subject,$hlstart='<b><font class="striking">',$hlend
function get_user_class()
{
global $CURUSER;
return $CURUSER["class"];
return $CURUSER["class"] ?? '';
}
function get_user_class_name($class, $compact = false, $b_colored = false, $I18N = false)
@@ -1692,7 +1692,7 @@ function check_code ($imagehash, $imagestring, $where = 'signup.php',$maxattempt
mysql_real_escape_string($imagehash));
sql_query($delete);
if (!$maxattemptlog)
bark($lang_functions['std_invalid_image_code']."<a href=\"".htmlspecialchars($where)."\">".$lang_functions['std_here_to_request_new']);
stderr('Error',$lang_functions['std_invalid_image_code']."<a href=\"".htmlspecialchars($where)."\">".$lang_functions['std_here_to_request_new'], false);
else
failedlogins($lang_functions['std_invalid_image_code']."<a href=\"".htmlspecialchars($where)."\">".$lang_functions['std_here_to_request_new'],true,$head);
}else{
@@ -2706,6 +2706,12 @@ if ($msgalert)
if (get_user_class() >= $staffmem_class)
{
if(($complaints = $Cache->get_value('COMPLAINTS_COUNT_CACHE')) === false){
$complaints = get_row_count('complains', 'WHERE answered = 0');
$Cache->cache_value('COMPLAINTS_COUNT_CACHE', $complaints, 600);
}
if($complaints) msgalert('complains.php?action=list', sprintf($lang_functions['text_complains'], is_or_are($complaints), $complaints, add_s($complaints)), 'darkred');
$numreports = $Cache->get_value('staff_new_report_count');
if ($numreports == ""){
$numreports = get_row_count("reports","WHERE dealtwith=0");
@@ -3970,7 +3976,7 @@ function permissiondenied(){
function gettime($time, $withago = true, $twoline = false, $forceago = false, $oneunit = false, $isfuturetime = false){
global $lang_functions, $CURUSER;
if ($CURUSER['timetype'] != 'timealive' && !$forceago){
if (isset($CURUSER) && $CURUSER['timetype'] != 'timealive' && !$forceago){
$newtime = $time;
if ($twoline){
$newtime = str_replace(" ", "<br />", $newtime);
@@ -5370,6 +5376,17 @@ function get_share_ratio($uploaded, $downloaded)
return $ratio;
}
function EchoRow($class = ''){
if(func_num_args() < 2) return '<tr></tr>';
$args = func_get_args();
$cells = array_splice($args, 1);
$class = empty($class) ? '' : sprintf(' class="%s"', $class);
$s = '<tr>';
foreach($cells as $cell) $s .= sprintf('<td%s>%s</td>', $class, $cell);
$s .= "</tr>\n";
return $s;
}
function list_require_search_box_id()
{
$setting = get_setting('main');
+29
View File
@@ -0,0 +1,29 @@
<?php
$lang_complains = [
'text_complain' => '申诉区',
'text_new_complain' => '提交申诉内容',
'text_new_email' => '账号邮箱:',
'text_new_body' => '申诉内容:',
'text_new_body_placeholder' => "申诉问题:\n相关证据:可使用标签[img=URL]外链图片",
'text_new_submit' => '提交申诉',
'text_new_failure' => '邮箱填写错误或申诉内容为空',
'text_created_title' => '申诉已创建',
'text_created_note' => '请将本页加入书签,以便查看后续更新。切勿将网址发给他人,以免影响申诉过程!',
'text_search_account' => '搜索该账号',
'text_reply' => '回复申诉',
'text_replies' => '申诉处理',
'text_complainer' => '申诉者',
'text_added' => '申诉时间',
'text_no_replies' => '当前暂无申诉跟踪内容',
'text_closed' => '该申诉已处理完毕,不能回复',
'text_answer_it' => '关闭该申述',
'text_unanswer_it' => '重开该申述',
'th_complain_at' => '申诉时间',
'th_complain_account' => '申诉账号',
'th_action_view' => '查看',
'pending_complaints' => '待处理申诉',
'no_pending_complaints' => '暂无待处理的申诉',
'complaints_processed' => '已处理申诉',
'no_complaints_have_been_processed' => '暂无已处理的申诉',
];
+1
View File
@@ -317,6 +317,7 @@ $lang_functions = array
'spoiler_expand_collapse' => '点击展开/收缩',
'spoiler_default_title' => '折叠内容',
'menu_claim' => '认领: ',
'text_complains' => '有%s%u个待处理的申述%s',
);
?>
+1
View File
@@ -34,5 +34,6 @@ $lang_login = array
'head_login' => "登录",
'rowhead_two_step_code' => '两步验证',
'two_step_code_tooltip' => '如有设置必须填写',
'text_complain' => '申诉通道',
);
?>
+29
View File
@@ -0,0 +1,29 @@
<?php
$lang_complains = [
'text_complain' => '申訴區',
'text_new_complain' => '提交申訴內容',
'text_new_email' => '帳號郵箱:',
'text_new_body' => '申訴內容:',
'text_new_body_placeholder' => "申訴問題:\n相關證據:可使用標籤[img=URL]外鏈圖片",
'text_new_submit' => '提交申訴',
'text_new_failure' => '郵箱填寫錯誤或申訴內容為空',
'text_created_title' => '申訴已創建',
'text_created_note' => '請將本頁加入書簽,以便查看後續更新。切勿將網址發給他人,以免影響申訴過程!',
'text_search_account' => '搜索該帳號',
'text_reply' => '回復申訴',
'text_replies' => '申訴處理',
'text_complainer' => '申訴者',
'text_added' => '申訴時間',
'text_no_replies' => '當前暫無申訴跟蹤內容',
'text_closed' => '該申訴已處理完畢,不能回復',
'text_answer_it' => '關閉該申述',
'text_unanswer_it' => '重開該申述',
'th_complain_at' => '申訴時間',
'th_complain_account' => '申訴賬號',
'th_action_view' => '查看',
'pending_complaints' => '待處理申訴',
'no_pending_complaints' => '暫無待處理的申訴',
'complaints_processed' => '已處理申訴',
'no_complaints_have_been_processed' => '暫無已處理的申訴',
];
+1
View File
@@ -324,6 +324,7 @@ $lang_functions = array
'spoiler_expand_collapse' => '點擊展開/收縮',
'spoiler_default_title' => '折疊內容',
'menu_claim' => '認領: ',
'text_complains' => '有%s%u個待處理的申述%s',
);
?>
+1
View File
@@ -34,5 +34,6 @@ $lang_login = array
'head_login' => "登錄",
'rowhead_two_step_code' => '兩步驗證',
'two_step_code_tooltip' => '如有設置必須填寫',
'text_complain' => '申訴通道',
);
?>
+29
View File
@@ -0,0 +1,29 @@
<?php
$lang_complains = [
'text_complain' => 'Complain account issue',
'text_new_complain' => 'New complain',
'text_new_email' => 'Account Email',
'text_new_body' => 'Complain Detail',
'text_new_body_placeholder' => "Describe issue here:\nRelated proof is applicable: Images are shown in form of [img=URL]",
'text_new_submit' => 'Submit',
'text_new_failure' => 'Bad email or empty complain entered.',
'text_created_title' => 'Complain created',
'text_created_note' => 'Please bookmark this page so that you can check its updates later. DO NOT REVEAL THIS URL TO ANYBODY! Otherwise your complaint would not be dealt with.',
'text_search_account' => 'Search account with this email',
'text_reply' => 'Reply',
'text_replies' => 'Following up messages',
'text_complainer' => 'Complainer',
'text_added' => 'Time added',
'text_no_replies' => 'No messages now',
'text_closed' => 'This complaint has been answered and locked for new replies.',
'text_answer_it' => 'CLOSE',
'text_unanswer_it' => 'REOPEN',
'th_complain_at' => 'Complain at',
'th_complain_account' => 'Complain account',
'th_action_view' => 'View',
'pending_complaints' => 'Pending complaints',
'no_pending_complaints' => 'No pending complaints',
'complaints_processed' => 'Complaints processed',
'no_complaints_have_been_processed' => 'No complaints have been processed',
];
+1
View File
@@ -325,6 +325,7 @@ $lang_functions = array
'spoiler_expand_collapse' => 'Click to expand/collapse',
'spoiler_default_title' => 'Collapse content',
'menu_claim' => 'Claim: ',
'text_complains' => 'There %s %u pending complaint%s.',
);
?>
+1
View File
@@ -34,6 +34,7 @@ $lang_login = array
'head_login' => "Login",
'rowhead_two_step_code' => 'Two-Factor Authentication',
'two_step_code_tooltip' => 'If enabled must be filled in',
'text_complain' => 'Complaint Channel',
);
?>
+143
View File
@@ -0,0 +1,143 @@
<?php
require '../include/bittorrent.php';
dbconn();
require get_langfile_path();
$isLogin = isset($CURUSER['id']);
$isAdmin = get_user_class() >= $staffmem_class;
if($isLogin && !$isAdmin) permissiondenied();
if($_SERVER['REQUEST_METHOD'] === 'POST'){
switch($action = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_FULL_SPECIAL_CHARS)){
case 'new':
cur_user_check();
check_code ($_POST['imagehash'], $_POST['imagestring'],'complains.php');
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
$body = filter_input(INPUT_POST, 'body', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if(empty($email) || empty($body)) stderr($lang_functions['std_error'], $lang_complains['text_new_failure']);
sql_query(sprintf('INSERT INTO complains (uuid, email, body, added) VALUES (UUID(), %s, %s, NOW())', sqlesc($email), sqlesc($body))) or sqlerr(__FILE__, __LINE__);
$Cache->delete_value('COMPLAINTS_COUNT_CACHE');
nexus_redirect(sprintf('complains.php?action=view&id=%s', get_single_value('complains', 'uuid', 'WHERE id = ' . mysql_insert_id())));
break;
case 'reply':
$id = filter_input(INPUT_POST, 'id', FILTER_VALIDATE_INT);
$body = filter_input(INPUT_POST, 'body', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if(empty($id) || empty($body)) stderr($lang_functions['std_error'], $lang_complains['text_new_failure']);
sql_query(sprintf('INSERT INTO complain_replies (complain, userid, added, body) VALUES (%u, %u, NOW(), %s)', $id, isset($CURUSER['id']) ? $CURUSER['id'] : 0, sqlesc($body))) or sqlerr(__FILE__, __LINE__);
nexus_redirect($_SERVER['HTTP_REFERER']);
break;
case 'answered':
case 'unanswered':
if(!$isAdmin) permissiondenied();
$id = filter_input(INPUT_POST, 'id', FILTER_VALIDATE_INT);
if(!$id) permissiondenied();
sql_query(sprintf('UPDATE complains SET answered = %u WHERE id = %u', $action == 'answered' ? 1 : 0, $id)) or sqlerr(__FILE__, __LINE__);
$Cache->delete_value('COMPLAINTS_COUNT_CACHE');
nexus_redirect($_SERVER['HTTP_REFERER']);
break;
default:
permissiondenied();
}
}else{
switch (filter_input(INPUT_GET, 'action', FILTER_SANITIZE_FULL_SPECIAL_CHARS)){
case 'list':
if(!$isAdmin) permissiondenied();
$showTable = function($res){
global $lang_complains;
echo '<table width="100%">';
echo EchoRow('colhead', $lang_complains['th_complain_at'], $lang_complains['th_complain_account'], $lang_complains['th_action_view']);
while($row = mysql_fetch_assoc($res)){
echo EchoRow('rowfollow', gettime($row['added']), htmlspecialchars($row['email']), sprintf('<a href="?action=view&id=%s" class="faqlink">%s</a>', $row['uuid'], $lang_complains['th_action_view']));
}
echo '</table>';
};
stdhead($lang_complains['text_complain']);
begin_main_frame();
if(!isset($_GET['page'])){
$res = sql_query('SELECT added, uuid, email FROM complains WHERE answered = 0 ORDER BY id DESC') or sqlerr(__FILE__, __LINE__);
begin_frame($lang_complains['pending_complaints']);
if(mysql_num_rows($res)){
$showTable($res);
}else{
echo $lang_complains['no_pending_complaints'];
}
end_frame();
}
begin_frame($lang_complains['complaints_processed']);
list($pagertop, $pagerbottom, $limit) = pager(20, get_row_count('complains', 'WHERE answered = 1'), '?action=list&');
$res = sql_query('SELECT added, uuid, email FROM complains WHERE answered = 1 ORDER BY id DESC ' . $limit) or sqlerr(__FILE__, __LINE__);
if(mysql_num_rows($res)){
echo $pagertop;
$showTable($res);
echo $pagerbottom;
}else{
echo $lang_complains['no_complaints_have_been_processed'];
}
end_frame();
end_main_frame();
stdfoot();
break;
case 'view':
$uuid = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if(strlen($uuid) != 36) permissiondenied();
$res = sql_query(sprintf('SELECT * FROM complains WHERE uuid = %s', sqlesc($uuid))) or sqlerr(__FILE__, __LINE__);
$complain = mysql_fetch_assoc($res);
if(!$complain) permissiondenied();
stdhead($lang_complains['text_complain']);
begin_main_frame();
if(!$isLogin){
begin_frame($lang_complains['text_created_title']);
printf('<p style="font-weight: bold; color: red">%s</p>', $lang_complains['text_created_note']);
end_frame();
}
begin_frame($lang_complains['text_new_body']);
printf('%s%s<br />%s %s', $lang_complains['text_added'], gettime($complain['added']), $lang_complains['text_new_email'], htmlspecialchars($complain['email']));
if($isAdmin) printf(' [<a href="usersearch.php?em=%s" class="faqlink">%s</a>]', urlencode($complain['email']), $lang_complains['text_search_account']);
echo '<hr />', format_comment($complain['body']);
end_frame();
// REPLIES
begin_frame($lang_complains['text_replies']);
$res = sql_query(sprintf('SELECT * FROM `complain_replies` WHERE complain = %u ORDER BY id DESC', $complain['id'])) or sqlerr(__FILE__, __LINE__);
if(mysql_num_rows($res)){
while($row = mysql_fetch_assoc($res)){
printf('<b>%s @ %s</b>: ', $row['userid'] ? get_plain_username($row['userid']) : $lang_complains['text_complainer'], gettime($row['added']));
echo format_comment($row['body']) . '<hr />';
}
}else{
printf('<p align="center">%s</p>', $lang_complains['text_no_replies']);
}
end_frame();
// NEW REPLY
if($complain['answered']){
printf('<p align="center">%s</p>', $lang_complains['text_closed']);
}else{
printf('<br /><br /><table style="border:1px solid #000000;" align="center"><tr><td class="text" align="center"><b>%s</b><br /><br /><form id="reply" method="post" action="" onsubmit="return postvalid(this);"><input type="hidden" name="action" value="reply" /><input type="hidden" name="id" value="%u" /><br />', $lang_complains['text_reply'], $complain['id']);
quickreply('reply', 'body', $lang_complains['text_reply']);
echo '</form></td></tr></table>';
}
if($isAdmin){
printf('<form action="" method="post" style="text-align: center; margin-top: 2em"><input type="hidden" name="action" value="%s" /><input type="hidden" name="id" value="%u" /><button>%s</button></form>', $complain['answered'] ? 'unanswered' : 'answered', $complain['id'],$complain['answered'] ? $lang_complains['text_unanswer_it'] : $lang_complains['text_answer_it']);
}
end_main_frame();
stdfoot();
break;
case 'compose':
default:
cur_user_check();
stdhead($lang_complains['text_complain']);
?>
<h2><?= $lang_complains['text_new_complain'] ?></h2>
<form action="" method="post">
<input type="hidden" name="action" value="new" />
<table border="0" cellpadding="5">
<tr><td class="rowhead"><?php echo $lang_complains['text_new_email']?></td><td class="rowfollow" align="left"><input type="email" name="email" style="width: 180px; border: 1px solid gray" /></td></tr>
<tr><td class="rowhead"><?php echo $lang_complains['text_new_body']?></td><td class="rowfollow" align="left"><textarea name="body" style="width: 200px; height: 250px" placeholder="<?= $lang_complains['text_new_body_placeholder'] ?>"></textarea></td></tr>
<?php show_image_code (); ?>
<tr><td class="toolbox" colspan="2" align="right"><input type="submit" value="<?= $lang_complains['text_new_submit']?>" class="btn" /></td></tr>
</table>
</form>
<?php
stdfoot();
}
}
+1
View File
@@ -86,6 +86,7 @@ if (isset($returnto))
?>
</form>
<p>[<b><a href="complains.php"><?= $lang_login['text_complain'] ?></a></b>]</p>
<p><?php echo $lang_login['p_no_account_signup']?></p>
<?php
if ($smtptype != 'none'){