Esempio n. 1
0
    $sql = <<<SQL
SELECT seed_id FROM {$tbl} WHERE tid={$tid};
SQL;
    $seed = DB::fetch_first($sql);
    $reason = $_POST['reason'];
    $penalty = $_POST['penalty'];
    if (empty($seed) || empty($seed['seed_id'])) {
        deleteThreadAndSeed($tid);
        $seed_not_exists++;
        continue;
    }
    if (strlen($reason) <= 0) {
        $reason = '未写明理由';
    }
    $data = ['penalty' => $penalty, 'reason' => $reason, 'seed_id' => $seed['seed_id']];
    $res = PTHelper::getApiCurl("seed/delete", $data);
    if ($res['result'] != 'success') {
        if ($res['reason'] == 'not exists') {
            deleteThreadAndSeed($tid);
            $seed_not_exists++;
            continue;
        } else {
            throw new Exception("删除seed_id : {$seed['seed_id']} 失败" . $res['extra']);
        }
    } else {
        $seed_info = $res['extra'];
        $threadinfo = DB::query("SELECT tid FROM " . DB::table('forum_thread') . " WHERE tid='{$tid}' LIMIT 1;");
        $threadnum = DB::num_rows($threadinfo);
        DB::free_result($threadinfo);
        // 如果帖子未删除
        if ($threadnum <= 0) {
Esempio n. 2
0
            $form['upcoe_max'] = $upcoe * 100;
        }
        if ($onlyblue) {
            $form['downcoe_min'] = 0;
            $form['downcoe_max'] = 0;
        } else {
            if ($downcoelarger) {
                $form['downcoe_min'] = $downcoe * 100;
            } else {
                $form['downcoe_max'] = $downcoe * 100;
            }
        }
        if ($nodead) {
            $form['nodead'] = true;
        }
        $api = PTHelper::getApiCurl('seed/search', http_build_query($form), true);
        if (empty($api) || $api['result'] != 'succeed') {
            throw new Exception('搜索失败,请检查种子服务器配置');
        }
        $seed_ids = $api['extra'];
        //获取所有的种子对应的tid
        $tbl = DB::table("ngpt_seed");
        $ids = implode(',', $seed_ids);
        $res = [];
        if (!empty($ids)) {
            $sql = <<<SQL
SELECT seed_id,tid FROM {$tbl} WHERE seed_id IN ({$ids});
SQL;
            $res = DB::fetch_all($sql);
        }
        //上面查到的是乱序的,必须重新排一遍序。
Esempio n. 3
0
    $tbl = DB::table("ngpt_seed");
    $sql = <<<SQL
SELECT seed_id FROM {$tbl} WHERE tid={$tid};
SQL;
    $seed = DB::fetch_first($sql);
    if (empty($seed) || empty($seed['seed_id'])) {
        $seed_not_exists++;
    }
    if (!isset($_POST['downcoe'])) {
        $_POST['downcoe'] = -1;
    }
    if (!isset($_POST['upcoe'])) {
        $_POST['upcoe'] = -1;
    }
    $data = ['seed_id' => $seed['seed_id'], 'upcoe' => $_POST['upcoe'], 'downcoe' => $_POST['downcoe'], 'replace' => $_POST['replace'], 'duration' => intval($_POST['duration']) * 3600 * 24, 'reason' => $reason];
    $res = PTHelper::getApiCurl("seed/set-coef", $data);
    if ($res['result'] != 'success') {
        if ($res['reason'] == 'not exists') {
            $seed_not_exists++;
        } else {
            throw new Exception("修改seed_id : {$seed['seed_id']} 失败" . $res['extra']);
        }
    } else {
        $seed_info = $res['extra'];
        $threadinfo = DB::query("SELECT tid FROM " . DB::table('forum_thread') . " WHERE tid='{$tid}' LIMIT 1;");
        $threadnum = DB::num_rows($threadinfo);
        DB::free_result($threadinfo);
        // 如果帖子未删除
        if ($threadnum <= 0) {
            $thread_not_exists++;
        }
Esempio n. 4
0
    public static function getUserInfo($uid)
    {
        $key_u = 'ui' . $uid;
        $key_t = 'uitime' . $uid;
        loadcache([$key_t, $key_u]);
        $user_info = null;
        if (!empty($_G['cache'][$key_t]) && !empty($_G['cache'][$key_u])) {
            $user_info = json_decode($_G['cache'][$key_u], true);
            $time = intval($_G['cache'][$key_t]);
            if ($time < time()) {
                $user_info = null;
            }
        }
        if (empty($user_info)) {
            $user_info = PTHelper::getApiCurl('user/info', ['detail' => true]);
            savecache($key_u, json_encode($user_info));
            savecache($key_t, time() + 120);
            $tbl = DB::table('common_member_count');
            $up = $user_info['stat_up'] >> 20;
            $down = $user_info['stat_down'] >> 20;
            $sql = <<<EOF
UPDATE {$tbl} SET
  extcredits2='{$up}',
  extcredits3='{$down}'
  WHERE uid='{$uid}';
EOF;
            $ret = DB::query($sql);
        }
        return $user_info;
    }
Esempio n. 5
0
            $picroot = $_G['siteurl'] . 'source/plugin/ngpt/static/image/';
            $picrootvar = '\'' . $picroot . '\'';
        } else {
            $floatwindowid = 'resinfodisplay_file';
            $ok = false;
            include template('ngpt:err/err-infloat');
        }
        break;
    case 'labelinfo':
        $info = PTHelper::getApiCurl('seed/info', ['query_json' => json_encode([$_POST['seed_id'] => 0])], true)['extra'];
        $fields = json_decode($info[0]['detail_info'], true);
        $labels = ['infohash' => $info[0]['info_hash'], 'threadtype' => '', 'fields' => $fields];
        break;
    case 'peerinfo':
        global $_G;
        $info = PTHelper::getApiCurl('seed/peer-info', ['seed_id' => $_POST['seed_id']])['extra'];
        $all = json_encode($info['all']);
        $leechers = json_encode($info['leechers']);
        $seeders = json_encode($info['seeders']);
        $history = '';
        if ($_G['adminid'] == 1) {
            //TODO 种子下载历史
        }
        break;
    default:
        showmessage('你在干嘛?');
}
if ($ok) {
    include template("ngpt:resinfodisplay/resinfodisplay-{$_POST['op']}");
}
echo <<<XML
if (empty($arr_thread_ids)) {
    return;
}
$str_thread_ids = implode(',', $arr_thread_ids);
$dztbl_ngpt_seeds = DB::table("ngpt_seed");
$sql = <<<EOF
        SELECT {$dztbl_ngpt_seeds}.seed_id, {$dztbl_ngpt_seeds}.tid, {$dztbl_ngpt_seeds}.fid
        FROM `{$dztbl_ngpt_seeds}` WHERE {$dztbl_ngpt_seeds}.tid IN ({$str_thread_ids});
EOF;
$seeds = DB::fetch_all($sql);
$req_json = [];
foreach ($seeds as $seed) {
    $req_json[$seed['seed_id']] = $seed['tid'];
}
$data = ['query_json' => json_encode($req_json)];
$res = PTHelper::getApiCurl("seed/info", $data, true);
if (empty($res) || $res['result'] == 'failed') {
    return;
    throw new Exception("种子服务器返回错误");
} else {
    $_G['threads_seeds'] = $res['extra'];
    foreach ($_G['threads_seeds'] as &$s) {
        $tmp = $s['coef_expire_time'];
        if ($tmp != 0) {
            $s['coef_expire_time'] = "剩余" . PTHelper::getReadableTimeFromMinutes($tmp / 60);
        } else {
            if (!($s['up_coef'] == 100 && $s['down_coef'] == 100)) {
                $s['coef_expire_time'] = '永久';
            } else {
                $s['coef_expire_time'] = '';
            }
Esempio n. 7
0
    /**
     * 处理编辑资源帖逻辑,并返回一个 Discuz 模板,该模板会被加入到编辑框前
     * 例:
     * return template("common/header");
     * @param int $fid 论坛ID
     * @param int $tid 正在编辑的帖子ID
     * @return string
     */
    function editpost($fid, $tid)
    {
        global $_G;
        /**
         * @var string $return
         * @var string $return_prepare
         */
        $seed = PTHelper::getSeedInfoBy('tid', $tid);
        $detail_info = json_decode($seed['detail_info'], true);
        $type_id = $seed['sub_type_id'];
        $fields = array_values($detail_info);
        $form_json = PTHelper::getApiCurl("seed/get-form-json", ['fid' => $fid]);
        $types_js = $this->getThreadTypes();
        // JavaScript 中的 fields 从0开始
        $return_prepare_fields = 'var fields = [];';
        foreach ($fields as $fieldkey => $fieldvalue) {
            $fieldvalue = addslashes($fieldvalue);
            $return_prepare_fields .= "fields[{$fieldkey}] = '{$fieldvalue}';";
        }
        return <<<HTML
<script>
var editmode = true;
var formjson = {$form_json['json']};
{$return_prepare_fields}
{$types_js}
</script>
<div class="exfm cl">
    <div class="sinf sppoll z" id="post_seed_form">
    </div>
</div>
<script src="./source/plugin/ngpt/static/js/post-seed.js"></script>
HTML;
    }
Esempio n. 8
0
 * @var string $s_down_str
 * @var float $s_share_ratio
 * @var string $s_share_ratio_str
 * @var string $s_share_ratio_color_str
 * @var string $candownloadstatus See viewresthead.php
 * @var string $passkey
 * @var string $fulltracker
 * @var int $numuploadingseeds 上传种子数
 * @var int $numdownloadingseeds 下载种子数
 * @var int $numdownloadedseeds 下载完成数
 * @var int $numpublishedseeds 发布种子数
 * @var int $numuploadingpeers 正在上传的总peer数(同一个种子不同IP算不同peer)
 * @var int $numuploadingpeers 正在上传的总peer数(同一个种子不同IP算不同peer)
 */
$uid = $_G['uid'];
$detail_info = PTHelper::getApiCurl('user/info', ['detail' => true]);
// 这些字段只有用户开启了PT功能才有意义
$t_cdstate_b = !empty($detail_info);
if ($t_cdstate_b) {
    $candownloadstatus = $detail_info['is_valid'];
    if ($candownloadstatus) {
        $candownloadstatus = 'normal';
    } else {
        $candownloadstatus = 'banned';
    }
} else {
    $candownloadstatus = 'notenabled';
}
$numuploadingseeds = 0;
$numdownloadingseeds = 0;
$numdownloadedseeds = 0;