changed: user can not delete torrent

This commit is contained in:
xiaomlove
2022-08-24 14:31:34 +08:00
parent f91a7597bd
commit ec5de07c42
8 changed files with 35 additions and 28 deletions
+3 -5
View File
@@ -977,7 +977,7 @@ function clear_staff_message_cache()
\App\Repositories\MessageRepository::updateStaffMessageCountCache(false); \App\Repositories\MessageRepository::updateStaffMessageCountCache(false);
} }
function user_can($permission, $fail = false, $uid = 0, $class = null): bool function user_can($permission, $fail = false, $uid = 0): bool
{ {
$log = "permission: $permission, fail: $fail, user: $uid"; $log = "permission: $permission, fail: $fail, user: $uid";
static $userCanCached = []; static $userCanCached = [];
@@ -993,10 +993,8 @@ function user_can($permission, $fail = false, $uid = 0, $class = null): bool
if (!$fail && isset($userCanCached[$permission][$uid])) { if (!$fail && isset($userCanCached[$permission][$uid])) {
return $userCanCached[$permission][$uid]; return $userCanCached[$permission][$uid];
} }
if ($class === null) { $userInfo = get_user_row($uid);
$userInfo = get_user_row($uid); $class = $userInfo['class'];
$class = $userInfo['class'];
}
$log .= ", userClass: $class"; $log .= ", userClass: $class";
if ($class == \App\Models\User::CLASS_STAFF_LEADER) { if ($class == \App\Models\User::CLASS_STAFF_LEADER) {
do_log("$log, CLASS_STAFF_LEADER, true"); do_log("$log, CLASS_STAFF_LEADER, true");
+2 -1
View File
@@ -111,7 +111,8 @@ $lang_details = array
'text_dead' => "断种", 'text_dead' => "断种",
'row_health' => "活力度", 'row_health' => "活力度",
'text_anonymous' => "匿名", 'text_anonymous' => "匿名",
'text_edit_torrent' => "编辑/刪除", 'text_edit_torrent' => "编辑",
'text_edit_and_delete_torrent' => "编辑/刪除",
'title_edit_torrent' => "点击编辑或删除本种子", 'title_edit_torrent' => "点击编辑或删除本种子",
'row_upped_by' => "", 'row_upped_by' => "",
'text_click' => "点击", 'text_click' => "点击",
+2 -1
View File
@@ -111,7 +111,8 @@ $lang_details = array
'text_dead' => "斷種", 'text_dead' => "斷種",
'row_health' => "活力度", 'row_health' => "活力度",
'text_anonymous' => "匿名", 'text_anonymous' => "匿名",
'text_edit_torrent' => "編輯/刪除", 'text_edit_torrent' => "編輯",
'text_edit_and_delete_torrent' => "編輯/刪除",
'title_edit_torrent' => "點擊編輯或移除本種子", 'title_edit_torrent' => "點擊編輯或移除本種子",
'row_upped_by' => "", 'row_upped_by' => "",
'text_click' => "點擊", 'text_click' => "點擊",
+2 -1
View File
@@ -110,7 +110,8 @@ $lang_details = array
'text_dead' => "dead", 'text_dead' => "dead",
'row_health' => "Health", 'row_health' => "Health",
'text_anonymous' => "Anonymous", 'text_anonymous' => "Anonymous",
'text_edit_torrent' => "Edit/Delete", 'text_edit_torrent' => "Edit",
'text_edit_and_delete_torrent' => "Edit/Delete",
'title_edit_torrent' => "Click to Edit or Delete this torrent", 'title_edit_torrent' => "Click to Edit or Delete this torrent",
'row_upped_by' => "Uploaded by", 'row_upped_by' => "Uploaded by",
'text_click' => "Click ", 'text_click' => "Click ",
+7 -3
View File
@@ -173,13 +173,17 @@ if (!$torrent) {
err("torrent not registered with this tracker"); err("torrent not registered with this tracker");
} }
if (!user_can('seebanned', false, $az['id'], $az['class'])) { if ($torrent['banned'] == 'yes') {
if ($torrent['banned'] == 'yes') { if (!user_can('seebanned', false, $az['id'])) {
err("torrent banned"); err("torrent banned");
} elseif ($torrent['approval_status'] != \App\Models\Torrent::APPROVAL_STATUS_ALLOW && get_setting('torrent.approval_status_none_visible') == 'no') { }
}
if ($torrent['approval_status'] != \App\Models\Torrent::APPROVAL_STATUS_ALLOW && get_setting('torrent.approval_status_none_visible') == 'no') {
if (!user_can('seebanned', false, $az['id'])) {
err("torrent review not approved"); err("torrent review not approved");
} }
} }
// select peers info from peers table for this torrent // select peers info from peers table for this torrent
$torrentid = $torrent["id"]; $torrentid = $torrent["id"];
$numpeers = $torrent["seeders"]+$torrent["leechers"]; $numpeers = $torrent["seeders"]+$torrent["leechers"];
+1 -1
View File
@@ -4,7 +4,7 @@ dbconn();
require_once(get_langfile_path()); require_once(get_langfile_path());
require_once(get_langfile_path("",true)); require_once(get_langfile_path("",true));
loggedinorreturn(); loggedinorreturn();
user_can('torrentmanage', true);
function bark($msg) { function bark($msg) {
global $lang_delete; global $lang_delete;
stdhead(); stdhead();
+1 -1
View File
@@ -151,7 +151,7 @@ if (!$row) {
$actions[] = "<a title=\"".$lang_details['title_download_torrent']."\" href=\"download.php?id=".$id."\"><img class=\"dt_download\" src=\"pic/trans.gif\" alt=\"download\" />&nbsp;<b><font class=\"small\">".$lang_details['text_download_torrent']."</font></b></a>"; $actions[] = "<a title=\"".$lang_details['title_download_torrent']."\" href=\"download.php?id=".$id."\"><img class=\"dt_download\" src=\"pic/trans.gif\" alt=\"download\" />&nbsp;<b><font class=\"small\">".$lang_details['text_download_torrent']."</font></b></a>";
} }
if ($owned == 1) { if ($owned == 1) {
$actions[] = "<$editlink><img class=\"dt_edit\" src=\"pic/trans.gif\" alt=\"edit\" />&nbsp;<b><font class=\"small\">".$lang_details['text_edit_torrent'] . "</font></b></a>"; $actions[] = "<$editlink><img class=\"dt_edit\" src=\"pic/trans.gif\" alt=\"edit\" />&nbsp;<b><font class=\"small\">".(user_can('torrentmanage') ? $lang_details['text_edit_and_delete_torrent'] : $lang_details['text_edit_torrent']). "</font></b></a>";
} }
if (user_can('askreseed') && $row['seeders'] == 0) { if (user_can('askreseed') && $row['seeders'] == 0) {
$actions[] = "<a title=\"".$lang_details['title_ask_for_reseed']."\" href=\"takereseed.php?reseedid=$id\"><img class=\"dt_reseed\" src=\"pic/trans.gif\" alt=\"reseed\">&nbsp;<b><font class=\"small\">".$lang_details['text_ask_for_reseed'] ."</font></b></a>"; $actions[] = "<a title=\"".$lang_details['title_ask_for_reseed']."\" href=\"takereseed.php?reseedid=$id\"><img class=\"dt_reseed\" src=\"pic/trans.gif\" alt=\"reseed\">&nbsp;<b><font class=\"small\">".$lang_details['text_ask_for_reseed'] ."</font></b></a>";
+17 -15
View File
@@ -205,21 +205,23 @@ else {
print("<tr><td class=\"toolbox\" colspan=\"2\" align=\"center\"><input id=\"qr\" type=\"submit\" value=\"".$lang_edit['submit_edit_it']."\" /> <input type=\"reset\" value=\"".$lang_edit['submit_revert_changes']."\" /></td></tr>\n"); print("<tr><td class=\"toolbox\" colspan=\"2\" align=\"center\"><input id=\"qr\" type=\"submit\" value=\"".$lang_edit['submit_edit_it']."\" /> <input type=\"reset\" value=\"".$lang_edit['submit_revert_changes']."\" /></td></tr>\n");
print("</table>\n"); print("</table>\n");
print("</form>\n"); print("</form>\n");
print("<br /><br />"); if (user_can('torrentmanage')) {
print("<form method=\"post\" action=\"delete.php\">\n"); print("<br /><br />");
print("<input type=\"hidden\" name=\"id\" value=\"$id\" />\n"); print("<form method=\"post\" action=\"delete.php\">\n");
if (isset($_GET["returnto"])) print("<input type=\"hidden\" name=\"id\" value=\"$id\" />\n");
print("<input type=\"hidden\" name=\"returnto\" value=\"" . htmlspecialchars($_GET["returnto"]) . "\" />\n"); if (isset($_GET["returnto"]))
print("<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n"); print("<input type=\"hidden\" name=\"returnto\" value=\"" . htmlspecialchars($_GET["returnto"]) . "\" />\n");
print("<tr><td class=\"colhead\" align=\"left\" style='padding-bottom: 3px' colspan=\"2\">".$lang_edit['text_delete_torrent']."</td></tr>"); print("<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n");
tr("<input name=\"reasontype\" type=\"radio\" value=\"1\" />&nbsp;".$lang_edit['radio_dead'], $lang_edit['text_dead_note'], 1); print("<tr><td class=\"colhead\" align=\"left\" style='padding-bottom: 3px' colspan=\"2\">".$lang_edit['text_delete_torrent']."</td></tr>");
tr("<input name=\"reasontype\" type=\"radio\" value=\"2\" />&nbsp;".$lang_edit['radio_dupe'], "<input type=\"text\" style=\"width: 200px\" name=\"reason[]\" />", 1); tr("<input name=\"reasontype\" type=\"radio\" value=\"1\" />&nbsp;".$lang_edit['radio_dead'], $lang_edit['text_dead_note'], 1);
tr("<input name=\"reasontype\" type=\"radio\" value=\"3\" />&nbsp;".$lang_edit['radio_nuked'], "<input type=\"text\" style=\"width: 200px\" name=\"reason[]\" />", 1); tr("<input name=\"reasontype\" type=\"radio\" value=\"2\" />&nbsp;".$lang_edit['radio_dupe'], "<input type=\"text\" style=\"width: 200px\" name=\"reason[]\" />", 1);
tr("<input name=\"reasontype\" type=\"radio\" value=\"4\" />&nbsp;".$lang_edit['radio_rules'], "<input type=\"text\" style=\"width: 200px\" name=\"reason[]\" />".$lang_edit['text_req'], 1); tr("<input name=\"reasontype\" type=\"radio\" value=\"3\" />&nbsp;".$lang_edit['radio_nuked'], "<input type=\"text\" style=\"width: 200px\" name=\"reason[]\" />", 1);
tr("<input name=\"reasontype\" type=\"radio\" value=\"5\" checked=\"checked\" />&nbsp;".$lang_edit['radio_other'], "<input type=\"text\" style=\"width: 200px\" name=\"reason[]\" />".$lang_edit['text_req'], 1); tr("<input name=\"reasontype\" type=\"radio\" value=\"4\" />&nbsp;".$lang_edit['radio_rules'], "<input type=\"text\" style=\"width: 200px\" name=\"reason[]\" />".$lang_edit['text_req'], 1);
print("<tr><td class=\"toolbox\" colspan=\"2\" align=\"center\"><input type=\"submit\" style='height: 25px' value=\"".$lang_edit['submit_delete_it']."\" /></td></tr>\n"); tr("<input name=\"reasontype\" type=\"radio\" value=\"5\" checked=\"checked\" />&nbsp;".$lang_edit['radio_other'], "<input type=\"text\" style=\"width: 200px\" name=\"reason[]\" />".$lang_edit['text_req'], 1);
print("</table>"); print("<tr><td class=\"toolbox\" colspan=\"2\" align=\"center\"><input type=\"submit\" style='height: 25px' value=\"".$lang_edit['submit_delete_it']."\" /></td></tr>\n");
print("</form>\n"); print("</table>");
print("</form>\n");
}
$json_sticky_series = json_encode(array(4, 6, 12, 24, 36, 48, 72, 168, 360)); $json_sticky_series = json_encode(array(4, 6, 12, 24, 36, 48, 72, 168, 360));
echo <<<EOT echo <<<EOT
<script> <script>