mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-19 21:03:54 -07:00
Vote button and v2 file list topic url display (#1138)
This commit is contained in:
parent
70988814c5
commit
3dedb7e33d
8 changed files with 163 additions and 2 deletions
|
@ -1467,6 +1467,24 @@ CREATE TABLE IF NOT EXISTS `buf_last_seeder`
|
||||||
-- Records of buf_last_seeder
|
-- Records of buf_last_seeder
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for `bb_thx`
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `bb_thx`;
|
||||||
|
CREATE TABLE IF NOT EXISTS `bb_thx`
|
||||||
|
(
|
||||||
|
`topic_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',
|
||||||
|
`user_id` MEDIUMINT(8) NOT NULL DEFAULT '0',
|
||||||
|
`time` INT(11) NOT NULL DEFAULT '0',
|
||||||
|
PRIMARY KEY (`topic_id`)
|
||||||
|
)
|
||||||
|
ENGINE = MyISAM
|
||||||
|
DEFAULT CHARSET = utf8;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of bb_thx
|
||||||
|
-- ----------------------------
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for `buf_topic_view`
|
-- Table structure for `buf_topic_view`
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|
|
@ -505,6 +505,9 @@ $bb_cfg['color_nick'] = true; // Colour user names in accordance with user_rank
|
||||||
$bb_cfg['user_not_activated_days_keep'] = 7; // "not activated" == "not finished registration"
|
$bb_cfg['user_not_activated_days_keep'] = 7; // "not activated" == "not finished registration"
|
||||||
$bb_cfg['user_not_active_days_keep'] = 180; // inactive users but only with no posts
|
$bb_cfg['user_not_active_days_keep'] = 180; // inactive users but only with no posts
|
||||||
|
|
||||||
|
// Vote for torrents
|
||||||
|
$bb_cfg['tor_thank'] = true;
|
||||||
|
|
||||||
// Groups
|
// Groups
|
||||||
$bb_cfg['group_members_per_page'] = 50; // How many groups will be displayed in a page
|
$bb_cfg['group_members_per_page'] = 50; // How many groups will be displayed in a page
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,19 @@ if ($delete_dlstat_sql = implode(') OR (', $delete_dlstat_sql)) {
|
||||||
DB()->query("DELETE QUICK FROM " . BB_BT_DLSTATUS . " WHERE ($delete_dlstat_sql)");
|
DB()->query("DELETE QUICK FROM " . BB_BT_DLSTATUS . " WHERE ($delete_dlstat_sql)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save the last 50 votes for topics
|
||||||
|
DB()->query('
|
||||||
|
DELETE t1
|
||||||
|
FROM' . BB_THX . ' t1
|
||||||
|
JOIN (
|
||||||
|
SELECT topic_id, MAX(time) as max_time
|
||||||
|
FROM ' . BB_THX . '
|
||||||
|
GROUP BY topic_id
|
||||||
|
HAVING COUNT(*) > 50
|
||||||
|
) t2
|
||||||
|
ON t1.topic_id = t2.topic_id AND t1.time = t2.max_time;
|
||||||
|
');
|
||||||
|
|
||||||
// Delete orphans
|
// Delete orphans
|
||||||
DB()->query("
|
DB()->query("
|
||||||
DELETE QUICK dl
|
DELETE QUICK dl
|
||||||
|
|
|
@ -66,7 +66,6 @@ $data = [
|
||||||
'name' => htmlCHR($tor['info']['name'] ?? ''),
|
'name' => htmlCHR($tor['info']['name'] ?? ''),
|
||||||
'client' => htmlCHR(substr($tor['created by'] ?? 'unknown client', 0, 20)),
|
'client' => htmlCHR(substr($tor['created by'] ?? 'unknown client', 0, 20)),
|
||||||
'size' => humn_size($files['size']),
|
'size' => humn_size($files['size']),
|
||||||
'hash' => bin2hex($row['info_hash_v2']),
|
|
||||||
'date' => (isset($tor['creation date']) && is_numeric($tor['creation date'])) ? delta_time($tor['creation date']) : 'unknown',
|
'date' => (isset($tor['creation date']) && is_numeric($tor['creation date'])) ? delta_time($tor['creation date']) : 'unknown',
|
||||||
'site_url' => FULL_URL
|
'site_url' => FULL_URL
|
||||||
];
|
];
|
||||||
|
@ -81,7 +80,7 @@ echo <<<EOF
|
||||||
<meta name="description" content="File listing for topic - $topic_id | {$data['name']} ({$data['size']})">
|
<meta name="description" content="File listing for topic - $topic_id | {$data['name']} ({$data['size']})">
|
||||||
<link rel="shortcut icon" href="{$data['site_url']}favicon.png" type="image/x-icon">
|
<link rel="shortcut icon" href="{$data['site_url']}favicon.png" type="image/x-icon">
|
||||||
|
|
||||||
<title>{$data['name']} ({$data['size']}) | {$data['hash']} | {$bb_cfg['sitename']}</title>
|
<title>{$data['name']} ({$data['size']}) | {$bb_cfg['sitename']}</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<style>
|
<style>
|
||||||
|
@ -150,6 +149,7 @@ sup {
|
||||||
opacity: 0.97;
|
opacity: 0.97;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<a href = "{$data['site_url']}viewtopic.php?t={$topic_id}" style = "font-family: Monospace; color: #569904;">🠔 Back to the topic</a>
|
||||||
<center>
|
<center>
|
||||||
<h2 style="color: #b3b3b3; font-family: Monospace;">Name: {$data['name']} | Age: ({$data['date']}) | Size: {$data['size']}</h2>
|
<h2 style="color: #b3b3b3; font-family: Monospace;">Name: {$data['name']} | Age: ({$data['date']}) | Size: {$data['size']}</h2>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -251,6 +251,7 @@ define('BB_TOPICS_WATCH', 'bb_topics_watch');
|
||||||
define('BB_USER_GROUP', 'bb_user_group');
|
define('BB_USER_GROUP', 'bb_user_group');
|
||||||
define('BB_USERS', 'bb_users');
|
define('BB_USERS', 'bb_users');
|
||||||
define('BB_WORDS', 'bb_words');
|
define('BB_WORDS', 'bb_words');
|
||||||
|
define('BB_THX', 'bb_thx');
|
||||||
|
|
||||||
define('TORRENT_EXT', 'torrent');
|
define('TORRENT_EXT', 'torrent');
|
||||||
|
|
||||||
|
|
|
@ -680,6 +680,14 @@ $lang['ASC'] = 'Ascending';
|
||||||
$lang['DESC'] = 'Descending';
|
$lang['DESC'] = 'Descending';
|
||||||
$lang['ORDER'] = 'Order';
|
$lang['ORDER'] = 'Order';
|
||||||
|
|
||||||
|
// Thanks
|
||||||
|
$lang['THANK_TOPIC'] = 'Vote for this topic';
|
||||||
|
$lang['THANKS_GRATITUDE'] = 'We appreciate your gratitude';
|
||||||
|
$lang['LAST_LIKES'] = 'Last votes';
|
||||||
|
$lang['LIKE_OWN_POST'] = 'You can\'t vote for your own topic';
|
||||||
|
$lang['NO_LIKES'] = 'Nobody gave a vote yet';
|
||||||
|
$lang['LIKE_ALREADY'] = 'You already voted this topic';
|
||||||
|
|
||||||
// Group control panel
|
// Group control panel
|
||||||
$lang['GROUP_CONTROL_PANEL'] = 'User Groups';
|
$lang['GROUP_CONTROL_PANEL'] = 'User Groups';
|
||||||
$lang['GROUP_CONFIGURATION'] = 'Group Configuration';
|
$lang['GROUP_CONFIGURATION'] = 'Group Configuration';
|
||||||
|
|
48
src/Ajax.php
48
src/Ajax.php
|
@ -38,6 +38,7 @@ class Ajax
|
||||||
'passkey' => ['user'],
|
'passkey' => ['user'],
|
||||||
'change_torrent' => ['user'],
|
'change_torrent' => ['user'],
|
||||||
'change_tor_status' => ['user'],
|
'change_tor_status' => ['user'],
|
||||||
|
'thx' => ['user'],
|
||||||
'manage_group' => ['user'],
|
'manage_group' => ['user'],
|
||||||
'callseed' => ['user'],
|
'callseed' => ['user'],
|
||||||
|
|
||||||
|
@ -515,4 +516,51 @@ class Ajax
|
||||||
{
|
{
|
||||||
require AJAX_DIR . '/callseed.php';
|
require AJAX_DIR . '/callseed.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get / Set votes
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function thx()
|
||||||
|
{
|
||||||
|
global $bb_cfg, $lang, $userdata;
|
||||||
|
|
||||||
|
if (!$bb_cfg['tor_thank']) $this->ajax_die($lang['DISABLED']);
|
||||||
|
|
||||||
|
$mode = (string) $this->request['mode'];
|
||||||
|
$topic_id = (int) $this->request['topic_id'];
|
||||||
|
|
||||||
|
switch($mode)
|
||||||
|
{
|
||||||
|
case 'add':
|
||||||
|
$row = DB()->fetch_row('SELECT * FROM '. BB_THX ." WHERE topic_id = $topic_id AND user_id = ". $userdata['user_id']);
|
||||||
|
|
||||||
|
if ($row) {
|
||||||
|
$this->ajax_die($lang['LIKE_ALREADY']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DB()->fetch_row('SELECT poster_id FROM ' . BB_BT_TORRENTS . " WHERE topic_id = $topic_id AND poster_id = " . $userdata['user_id'])) {
|
||||||
|
$this->ajax_die($lang['LIKE_OWN_POST']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$columns = 'topic_id, user_id, time';
|
||||||
|
$values = "$topic_id, {$userdata['user_id']}, " . TIMENOW;
|
||||||
|
DB()->query('INSERT IGNORE INTO ' . BB_THX . " ($columns) VALUES ($values)");
|
||||||
|
$this->response['html'] = '<b>' . profile_url($userdata) . ' <i>('. bb_date(TIMENOW) . ')</i></b>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'get':
|
||||||
|
$sql = DB()->fetch_rowset('SELECT u.username, u.user_rank, u.user_id, t.* FROM ' . BB_THX . ' t, '. BB_USERS . " u WHERE t.topic_id = $topic_id AND t.user_id = u.user_id");
|
||||||
|
$user_list = [];
|
||||||
|
foreach ($sql as $row) {
|
||||||
|
$user_list[] = '<b>' . profile_url($row) . ' <i>(' . bb_date($row['time']) . ')</i></b>';
|
||||||
|
}
|
||||||
|
$thx_list = join(' ', $user_list);
|
||||||
|
$this->response['html'] = ($thx_list) ? $thx_list : $lang['NO_LIKES'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,6 +364,76 @@ $('#tor-filelist-btn').click(function(){
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- IF $bb_cfg['tor_thank'] -->
|
||||||
|
<style type="text/css">
|
||||||
|
#thx-block { width: 95%; margin: 12px auto 0; }
|
||||||
|
#thx-block .sp-wrap { width: 100% !important; }
|
||||||
|
#thx-btn-div { text-align: center; margin: 0 0 12px; }
|
||||||
|
#thx-list a { text-decoration: none; }
|
||||||
|
#thx-list b { font-size: 11px; color: #2E2E2E; white-space: nowrap; }
|
||||||
|
#thx-list i { font-weight: normal; color: #000000; }
|
||||||
|
#thx-list u { display: none; }
|
||||||
|
</style>
|
||||||
|
<script type="text/javascript">
|
||||||
|
BB.thx_btn_clicked = false;
|
||||||
|
|
||||||
|
ajax.thx = function(mode) {
|
||||||
|
ajax.exec({
|
||||||
|
action : 'thx',
|
||||||
|
mode : mode,
|
||||||
|
topic_id : {TOPIC_ID}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ajax.callback.thx = function(data) {
|
||||||
|
if (data.mode == 'add') {
|
||||||
|
$('#thx-btn').hide().after('<h2 style="color: green;">{$lang['THANKS_GRATITUDE']}!<h2>');
|
||||||
|
BB.thx_btn_clicked = true;
|
||||||
|
}
|
||||||
|
$('#thx-list').html(data.html);
|
||||||
|
$('#thx-list b').after(' ');
|
||||||
|
open_thx_list();
|
||||||
|
$('#thx-list b').each(function(){
|
||||||
|
var uid = $(this).find('u').text();
|
||||||
|
if (uid > 0) {
|
||||||
|
$(this).wrap('<a href="./profile.php?mode=viewprofile&u='+ uid +'"></a>');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$(function(){
|
||||||
|
$thx_head = $('#thx-block').find('.sp-head');
|
||||||
|
close_thx_list();
|
||||||
|
$('#thx-btn').one('click', function(){
|
||||||
|
$(this).prop({disabled: true});
|
||||||
|
ajax.thx('add');
|
||||||
|
});
|
||||||
|
$thx_head.one('click', function(){
|
||||||
|
if (!BB.thx_btn_clicked) {
|
||||||
|
ajax.thx('get');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
function thx_is_visible () {
|
||||||
|
return $('#thx-list').is(':visible');
|
||||||
|
}
|
||||||
|
function open_thx_list () {
|
||||||
|
if (!thx_is_visible()){ $thx_head.click(); }
|
||||||
|
}
|
||||||
|
function close_thx_list () {
|
||||||
|
if (thx_is_visible()){ $thx_head.click(); }
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div id="thx-block">
|
||||||
|
<div id="thx-btn-div">
|
||||||
|
<input id="thx-btn" type="button" class="bold" style="width: 200px;" value='{$lang['THANK_TOPIC']}' />
|
||||||
|
</div>
|
||||||
|
<div class="sp-wrap">
|
||||||
|
<div id="thx-list" class="sp-body" title="{$lang['LAST_LIKES']}"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- ENDIF -->
|
||||||
|
|
||||||
|
|
||||||
<div class="spacer_12"></div>
|
<div class="spacer_12"></div>
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
<!-- END tor_reged -->
|
<!-- END tor_reged -->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue