API: torrents upload/list

This commit is contained in:
xiaomlove
2025-04-17 01:39:40 +07:00
parent 0d3a46231d
commit 2b029eba10
72 changed files with 2332 additions and 507 deletions
+11 -3
View File
@@ -121,7 +121,7 @@ else {
list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, "log.php?action=dailylog&".$addparam);
$res = sql_query("SELECT added, txt FROM sitelog $wherea ORDER BY added DESC $limit") or sqlerr(__FILE__, __LINE__);
$res = sql_query("SELECT * FROM sitelog $wherea ORDER BY added DESC $limit") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) == 0)
print($lang_log['text_log_empty']);
else
@@ -130,7 +130,11 @@ else {
//echo $pagertop;
print("<table width=940 border=1 cellspacing=0 cellpadding=5>\n");
print("<tr><td class=colhead align=center><img class=\"time\" src=\"pic/trans.gif\" alt=\"time\" title=\"".$lang_log['title_time_added']."\" /></td><td class=colhead align=left>".$lang_log['col_event']."</td></tr>\n");
print("<tr><td class=colhead align=center><img class=\"time\" src=\"pic/trans.gif\" alt=\"time\" title=\"".$lang_log['title_time_added']."\" /></td><td class=colhead align=left>".$lang_log['col_event']);
if (user_can('confilog')){
print("<td class=colhead align=left>".$lang_log['col_user']."</td>");
}
print("</td></tr>\n");
while ($arr = mysql_fetch_assoc($res))
{
$color = "";
@@ -139,7 +143,11 @@ else {
if (strpos($arr['txt'],'was added to the Request section')) $color = "purple";
if (strpos($arr['txt'],'was edited by')) $color = "blue";
if (strpos($arr['txt'],'settings updated by')) $color = "darkred";
print("<tr><td class=\"rowfollow nowrap\" align=center>".gettime($arr['added'],true,false)."</td><td class=rowfollow align=left><font color='".$color."'>".htmlspecialchars($arr['txt'])."</font></td></tr>\n");
print("<tr><td class=\"rowfollow nowrap\" align=center>".gettime($arr['added'],true,false)."</td><td class=rowfollow align=left><font color='".$color."'>".htmlspecialchars($arr['txt'])."</font></td>");
if (user_can('confilog')){
print("<td class=rowfollow align=left>".($arr['uid'] > 0 ? get_username($arr['uid']) : "System")."</td>");
}
print("</tr>\n");
}
print("</table>");
+1 -1
View File
@@ -34,7 +34,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST")
failedlogins($lang_recover['std_missing_email_address'],true);
if (!check_email($email))
failedlogins($lang_recover['std_invalid_email_address'],true);
$res = sql_query("SELECT * FROM users WHERE email=" . sqlesc($email) . " LIMIT 1") or sqlerr(__FILE__, __LINE__);
$res = sql_query("SELECT * FROM users WHERE BINARY email=" . sqlesc($email) . " LIMIT 1") or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_assoc($res);
if (!$arr) failedlogins($lang_recover['std_email_not_in_database'],true);
if ($arr['status'] == "pending") failedlogins($lang_recover['std_user_account_unconfirmed'],true);
+1 -1
View File
@@ -746,7 +746,7 @@ elseif ($action == 'torrentsettings')
tr($lang_settings['row_tax_factor'],"<input type='number' name=tax_factor style=\"width: 100px\" value={$TORRENT['tax_factor']}> ".$lang_settings['text_tax_factor_note'], 1);
tr($lang_settings['row_max_price'],"<input type='number' name=max_price style=\"width: 100px\" value={$TORRENT['max_price']}> ".$lang_settings['text_max_price_note'], 1);
yesorno($lang_settings['row_promotion_rules'], 'prorules', $TORRENT["prorules"], $lang_settings['text_promotion_rules_note']);
// yesorno($lang_settings['row_promotion_rules'], 'prorules', $TORRENT["prorules"], $lang_settings['text_promotion_rules_note']);
tr($lang_settings['row_random_promotion'], $lang_settings['text_random_promotion_note_one']."<ul><li><input type='text' style=\"width: 50px\" name=randomhalfleech value='".(isset($TORRENT["randomhalfleech"]) ? $TORRENT["randomhalfleech"] : 5 )."'>".$lang_settings['text_halfleech_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomfree value='".(isset($TORRENT["randomfree"]) ? $TORRENT["randomfree"] : 2 )."'>".$lang_settings['text_free_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwoup value='".(isset($TORRENT["randomtwoup"]) ? $TORRENT["randomtwoup"] : 2 )."'>".$lang_settings['text_twoup_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwoupfree value='".(isset($TORRENT["randomtwoupfree"]) ? $TORRENT["randomtwoupfree"] : 1 )."'>".$lang_settings['text_freetwoup_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwouphalfdown value='".(isset($TORRENT["randomtwouphalfdown"]) ? $TORRENT["randomtwouphalfdown"] : 0 )."'>".$lang_settings['text_twouphalfleech_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomthirtypercentdown value='".(isset($TORRENT["randomthirtypercentdown"]) ? $TORRENT["randomthirtypercentdown"] : 0 )."'>".$lang_settings['text_thirtypercentleech_chance_becoming']."</li></ul>".$lang_settings['text_random_promotion_note_two'], 1);
tr($lang_settings['row_large_torrent_promotion'], $lang_settings['text_torrent_larger_than']."<input type='text' style=\"width: 50px\" name=largesize value='".(isset($TORRENT["largesize"]) ? $TORRENT["largesize"] : 20 )."'>".$lang_settings['text_gb_promoted_to']."<select name=largepro>".promotion_selection((isset($TORRENT['largepro']) ? $TORRENT['largepro'] : 2), 1)."</select>".$lang_settings['text_by_system_upon_uploading']."<br />".$lang_settings['text_large_torrent_promotion_note'], 1);
tr($lang_settings['row_promotion_timeout'], $lang_settings['text_promotion_timeout_note_one']."<ul>
+1 -1
View File
@@ -83,7 +83,7 @@ if ($nfoaction == "update")
$Cache->delete_value('nfo_block_torrent_id_'.$id);
}
elseif ($nfoaction == "remove"){
$updateset[] = "nfo = ''";
$extraUpdate["nfo"] = "";
$Cache->delete_value('nfo_block_torrent_id_'.$id);
}
}
+1 -1
View File
@@ -29,7 +29,7 @@ if ($useChallengeResponse) {
}
}
$res = sql_query("SELECT id, passhash, secret, auth_key, enabled, status, two_step_secret, lang FROM users WHERE username = " . sqlesc($username));
$res = sql_query("SELECT id, passhash, secret, auth_key, enabled, status, two_step_secret, lang FROM users WHERE BINARY username = " . sqlesc($username));
$row = mysql_fetch_array($res);
if (!$row)
+1 -1
View File
@@ -134,7 +134,7 @@ if ($_POST["rulesverify"] != "yes" || $_POST["faqverify"] != "yes" || $_POST["ag
stderr($lang_takesignup['std_signup_failed'], $lang_takesignup['std_unqualified']);
// check if email addy is already in use
$a = (@mysql_fetch_row(@sql_query("select count(*) from users where email='".mysql_real_escape_string($email)."'"))) or sqlerr(__FILE__, __LINE__);
$a = (@mysql_fetch_row(@sql_query("select count(*) from users where BINARY email='".mysql_real_escape_string($email)."'"))) or sqlerr(__FILE__, __LINE__);
if ($a[0] != 0)
bark($lang_takesignup['std_email_address'].$email.$lang_takesignup['std_in_use']);
+33 -33
View File
@@ -275,34 +275,34 @@ else{ //ramdom torrent promotion
else
$sp_state = 1; //normal
}
if ($altname_main == 'yes'){
$cnname_part = unesc(trim($_POST["cnname"]));
$size_part = str_replace(" ", "", mksize($totallen));
$date_part = date("m.d.y");
$category_part = get_single_value("categories","name","WHERE id = ".sqlesc($catid));
$torrent = "".$date_part."".($_POST["name"] ? "[".$_POST["name"]."]" : "").($cnname_part ? "[".$cnname_part."]" : "");
}
//
//if ($altname_main == 'yes'){
//$cnname_part = unesc(trim($_POST["cnname"]));
//$size_part = str_replace(" ", "", mksize($totallen));
//$date_part = date("m.d.y");
//$category_part = get_single_value("categories","name","WHERE id = ".sqlesc($catid));
//$torrent = "【".$date_part."】".($_POST["name"] ? "[".$_POST["name"]."]" : "").($cnname_part ? "[".$cnname_part."]" : "");
//}
// some ugly code of automatically promoting torrents based on some rules
if ($prorules_torrent == 'yes'){
foreach ($promotionrules_torrent as $rule)
{
if (!array_key_exists('catid', $rule) || in_array($catid, $rule['catid']))
if (!array_key_exists('sourceid', $rule) || in_array($sourceid, $rule['sourceid']))
if (!array_key_exists('mediumid', $rule) || in_array($mediumid, $rule['mediumid']))
if (!array_key_exists('codecid', $rule) || in_array($codecid, $rule['codecid']))
if (!array_key_exists('standardid', $rule) || in_array($standardid, $rule['standardid']))
if (!array_key_exists('processingid', $rule) || in_array($processingid, $rule['processingid']))
if (!array_key_exists('teamid', $rule) || in_array($teamid, $rule['teamid']))
if (!array_key_exists('audiocodecid', $rule) || in_array($audiocodecid, $rule['audiocodecid']))
if (!array_key_exists('pattern', $rule) || preg_match($rule['pattern'], $torrent))
if (is_numeric($rule['promotion'])){
$sp_state = $rule['promotion'];
break;
}
}
}
//if ($prorules_torrent == 'yes'){
//foreach ($promotionrules_torrent as $rule)
//{
// if (!array_key_exists('catid', $rule) || in_array($catid, $rule['catid']))
// if (!array_key_exists('sourceid', $rule) || in_array($sourceid, $rule['sourceid']))
// if (!array_key_exists('mediumid', $rule) || in_array($mediumid, $rule['mediumid']))
// if (!array_key_exists('codecid', $rule) || in_array($codecid, $rule['codecid']))
// if (!array_key_exists('standardid', $rule) || in_array($standardid, $rule['standardid']))
// if (!array_key_exists('processingid', $rule) || in_array($processingid, $rule['processingid']))
// if (!array_key_exists('teamid', $rule) || in_array($teamid, $rule['teamid']))
// if (!array_key_exists('audiocodecid', $rule) || in_array($audiocodecid, $rule['audiocodecid']))
// if (!array_key_exists('pattern', $rule) || preg_match($rule['pattern'], $torrent))
// if (is_numeric($rule['promotion'])){
// $sp_state = $rule['promotion'];
// break;
// }
//}
//}
$dateTimeStringNow = \Carbon\Carbon::now()->toDateTimeString();
$torrentSavePath = getFullDirectory($torrent_dir);
@@ -452,15 +452,15 @@ $torrentRep = new \App\Repositories\TorrentRepository();
$torrentRep->addPiecesHashCache($id, $insert['pieces_hash']);
write_log("Torrent $id ($torrent) was uploaded by $anon");
$searchRep = new \App\Repositories\SearchRepository();
$searchRep->addTorrent($id);
$meiliSearch = new \App\Repositories\MeiliSearchRepository();
$meiliSearch->doImportFromDatabase($id);
//move to event listener
//$searchRep = new \App\Repositories\SearchRepository();
//$searchRep->addTorrent($id);
//
//$meiliSearch = new \App\Repositories\MeiliSearchRepository();
//$meiliSearch->doImportFromDatabase($id);
//trigger event
fire_event("torrent_created", \App\Models\Torrent::query()->find($id));
fire_event(\App\Enums\ModelEventEnum::TORRENT_CREATED, \App\Models\Torrent::query()->find($id));
//===notify people who voted on offer thanks CoLdFuSiOn :)
if ($is_offer)
+7 -17
View File
@@ -1150,7 +1150,7 @@ if ($res->count() > 0)
$token .= sprintf('<td>%s</td>', $tokenRecord->name);
$token .= sprintf('<td>%s</td>', $tokenRecord->abilitiesText);
$token .= sprintf('<td>%s</td>', $tokenRecord->created_at);
$token .= sprintf('<td><span style="cursor: pointer;margin-right: 10px" class="token-get" data-id="%s">获取</span><span style="cursor: pointer" title="%s" data-id="%s" class="token-del">删除</span></td>', $tokenRecord->id, $lang_functions['text_delete'], $tokenRecord->id);
$token .= sprintf('<td><img style="cursor: pointer" class="staff_delete token-del" src="pic/trans.gif" alt="D" title="%s" data-id="%s"></td>', $lang_functions['text_delete'], $tokenRecord->id);
$token .= "</tr>";
}
$token .= '</table>';
@@ -1184,13 +1184,16 @@ jQuery('#add-token-box-btn').on('click', function () {
jQuery('body').loading({stoppable: false});
let params = jQuery('#token-box-form').serialize()
jQuery.post('/web/token/add', params, function (response) {
jQuery('body').loading('stop');
console.log(response)
if (response.ret != 0) {
jQuery('body').loading('stop');
layer.alert(response.msg)
return
} else {
layer.alert(response.msg, function(index) {
layer.close(index);
window.location.reload()
})
}
window.location.reload()
}, 'json')
}
})
@@ -1211,19 +1214,6 @@ jQuery('#token-table').on('click', '.token-del', function () {
}, 'json')
})
});
jQuery('#token-table').on('click', '.token-get', function () {
let params = {id: jQuery(this).attr("data-id")}
jQuery('body').loading({stoppable: false});
jQuery.post('/web/token/get-plain', params, function (response) {
console.log(response)
jQuery('body').loading('stop');
if (response.ret != 0) {
layer.alert(response.msg)
} else {
layer.alert(response.data)
}
}, 'json')
});
JS;
\Nexus\Nexus::js($tokenBoxJs, 'footer', false);