예제 #1
0
파일: info.php 프로젝트: ErR163/torrentpier
        $info['src'] = 'advert.html';
        break;
    case 'copyright_holders':
        $info['title'] = $lang['COPYRIGHT_HOLDERS'];
        $info['src'] = 'copyright_holders.html';
        break;
    case 'not_found':
        $info['title'] = $lang['NOT_FOUND'];
        $info['src'] = 'not_found.html';
        break;
    case 'user_agreement':
        $info['title'] = $lang['USER_AGREEMENT'];
        $info['src'] = 'user_agreement.html';
        break;
    default:
        bb_simple_die('Invalid request');
}
$require = file_exists($html_dir . $info['src']) ? $html_dir . $info['src'] : $html_dir . 'not_found.html';
?>
<!DOCTYPE html>
<html dir="ltr">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="Content-Style-Type" content="text/css" />
	<link rel="stylesheet" href="styles/templates/default/css/main.css" type="text/css">
</head>
<body>
<style type="text/css">
#infobox-wrap { width: 760px; }
#infobox-body {
	background: #FFFFFF; color: #000000; padding: 1em;
예제 #2
0
function bb_captcha($mode, $callback = '')
{
    global $bb_cfg, $userdata;
    require_once CLASS_DIR . 'recaptcha.php';
    $secret = $bb_cfg['captcha']['secret_key'];
    $public = $bb_cfg['captcha']['public_key'];
    $theme = $bb_cfg['captcha']['theme'];
    $lang = $bb_cfg['lang'][$userdata['user_lang']]['captcha'];
    $reCaptcha = new ReCaptcha($secret);
    switch ($mode) {
        case 'get':
            return "\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\tvar onloadCallback = function() {\n\t\t\t\t\t\tgrecaptcha.render('tp-captcha', {\n\t\t\t\t\t\t\t'sitekey'  : '" . $public . "',\n\t\t\t\t\t\t\t'theme'    : '" . $theme . "',\n\t\t\t\t\t\t\t'callback' : '" . $callback . "'\n\t\t\t\t\t\t});\n\t\t\t\t\t};\n\t\t\t\t</script>\n\t\t\t\t<div id=\"tp-captcha\"></div>\n\t\t\t\t<script src=\"https://www.google.com/recaptcha/api.js?onload=onloadCallback&hl=" . $lang . "&render=explicit\" async defer></script>";
            break;
        case 'check':
            $resp = null;
            $error = null;
            $g_resp = request_var('g-recaptcha-response', '');
            if ($g_resp) {
                $resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $g_resp);
            }
            if ($resp != null && $resp->success) {
                return true;
            } else {
                return false;
            }
            break;
        default:
            bb_simple_die(__FUNCTION__ . ": invalid mode '{$mode}'");
    }
    return false;
}
예제 #3
0
파일: feed.php 프로젝트: ErR163/torrentpier
        } else {
            require_once INC_DIR . 'functions_atom.php';
            if (update_forum_feed($id, $forum_data)) {
                redirect($bb_cfg['atom']['url'] . '/f/' . $id . '.atom');
            } else {
                bb_simple_die($lang['ATOM_NO_FORUM']);
            }
        }
    }
    if ($type == 'u') {
        // Check if the user has actually sent a user ID
        if ($id < 1) {
            bb_simple_die($lang['ATOM_ERROR'] . ' #2');
        }
        if (!($username = get_username($id))) {
            bb_simple_die($lang['ATOM_ERROR'] . ' #3');
        }
        if (file_exists($bb_cfg['atom']['path'] . '/u/' . floor($id / 5000) . '/' . $id % 100 . '/' . $id . '.atom') && filemtime($bb_cfg['atom']['path'] . '/u/' . floor($id / 5000) . '/' . $id % 100 . '/' . $id . '.atom') > $timecheck) {
            redirect($bb_cfg['atom']['url'] . '/u/' . floor($id / 5000) . '/' . $id % 100 . '/' . $id . '.atom');
        } else {
            require_once INC_DIR . 'functions_atom.php';
            if (update_user_feed($id, $username)) {
                redirect($bb_cfg['atom']['url'] . '/u/' . floor($id / 5000) . '/' . $id % 100 . '/' . $id . '.atom');
            } else {
                bb_simple_die($lang['ATOM_NO_USER']);
            }
        }
    }
} else {
    bb_simple_die($lang['ATOM_ERROR'] . ' #4');
}
예제 #4
0
function send_torrent_with_passkey($filename)
{
    global $attachment, $auth_pages, $userdata, $bb_cfg, $tr_cfg, $lang;
    if (!$bb_cfg['bt_add_auth_key'] || $attachment['extension'] !== TORRENT_EXT || !($size = @filesize($filename))) {
        return;
    }
    $post_id = $poster_id = $passkey_val = '';
    $user_id = $userdata['user_id'];
    $attach_id = $attachment['attach_id'];
    if (!($passkey_key = $bb_cfg['passkey_key'])) {
        bb_die('Could not add passkey (wrong config $bb_cfg[\'passkey_key\'])');
    }
    // Get $post_id & $poster_id
    foreach ($auth_pages as $rid => $row) {
        if ($row['attach_id'] == $attach_id) {
            $post_id = $row['post_id'];
            $poster_id = $row['user_id_1'];
            break;
        }
    }
    // Get $topic_id
    $topic_id_sql = 'SELECT topic_id FROM ' . BB_POSTS . ' WHERE post_id = ' . (int) $post_id;
    if (!($topic_id_result = DB()->sql_query($topic_id_sql))) {
        bb_die('Could not query post information');
    }
    $topic_id_row = DB()->sql_fetchrow($topic_id_result);
    $topic_id = $topic_id_row['topic_id'];
    if (!$attachment['tracker_status']) {
        bb_die($lang['PASSKEY_ERR_TOR_NOT_REG']);
    }
    if (bf($userdata['user_opt'], 'user_opt', 'dis_passkey') && !IS_GUEST) {
        bb_die('Could not add passkey');
    }
    if ($bt_userdata = get_bt_userdata($user_id)) {
        $passkey_val = $bt_userdata['auth_key'];
    }
    if (!$passkey_val) {
        if (!($passkey_val = generate_passkey($user_id))) {
            bb_simple_die('Could not generate passkey');
        } elseif ($bb_cfg['ocelot']['enabled']) {
            ocelot_update_tracker('add_user', array('id' => $user_id, 'passkey' => $passkey_val));
        }
    }
    // Ratio limits
    $min_ratio = $bb_cfg['bt_min_ratio_allow_dl_tor'];
    if ($min_ratio && $user_id != $poster_id && ($user_ratio = get_bt_ratio($bt_userdata)) !== null) {
        if ($user_ratio < $min_ratio && $post_id) {
            $dl = DB()->fetch_row("\n\t\t\t\tSELECT dl.user_status\n\t\t\t\tFROM " . BB_POSTS . " p\n\t\t\t\tLEFT JOIN " . BB_BT_DLSTATUS . " dl ON dl.topic_id = p.topic_id AND dl.user_id = {$user_id}\n\t\t\t\tWHERE p.post_id = {$post_id}\n\t\t\t\tLIMIT 1\n\t\t\t");
            if (!isset($dl['user_status']) || $dl['user_status'] != DL_STATUS_COMPLETE) {
                bb_die(sprintf($lang['BT_LOW_RATIO_FOR_DL'], round($user_ratio, 2), "search.php?dlu={$user_id}&amp;dlc=1"));
            }
        }
    }
    // Announce URL
    $ann_url = $bb_cfg['bt_announce_url'];
    if (!($tor = bdecode_file($filename))) {
        bb_die('This is not a bencoded file');
    }
    $announce = $bb_cfg['ocelot']['enabled'] ? strval($bb_cfg['ocelot']['url'] . $passkey_val . "/announce") : strval($ann_url . "?{$passkey_key}={$passkey_val}");
    // Replace original announce url with tracker default
    if ($bb_cfg['bt_replace_ann_url'] || !isset($tor['announce'])) {
        $tor['announce'] = $announce;
    }
    // Delete all additional urls
    if ($bb_cfg['bt_del_addit_ann_urls'] || $bb_cfg['bt_disable_dht']) {
        unset($tor['announce-list']);
    } elseif (isset($tor['announce-list'])) {
        $tor['announce-list'] = array_merge($tor['announce-list'], array(array($announce)));
    }
    // Add retracker
    if (isset($tr_cfg['retracker']) && $tr_cfg['retracker']) {
        if (bf($userdata['user_opt'], 'user_opt', 'user_retracker') || IS_GUEST) {
            if (!isset($tor['announce-list'])) {
                $tor['announce-list'] = array(array($announce), array($tr_cfg['retracker_host']));
            } else {
                $tor['announce-list'] = array_merge($tor['announce-list'], array(array($tr_cfg['retracker_host'])));
            }
        }
    }
    // Add publisher & topic url
    $publisher_name = $bb_cfg['server_name'];
    $publisher_url = make_url(TOPIC_URL . $topic_id);
    $tor['publisher'] = strval($publisher_name);
    unset($tor['publisher.utf-8']);
    $tor['publisher-url'] = strval($publisher_url);
    unset($tor['publisher-url.utf-8']);
    $tor['comment'] = strval($publisher_url);
    unset($tor['comment.utf-8']);
    // Send torrent
    $output = bencode($tor);
    $dl_fname = $bb_cfg['torrent_name_style'] ? '[' . $bb_cfg['server_name'] . '].t' . $topic_id . '.torrent' : clean_filename(basename($attachment['real_filename']));
    if (!empty($_COOKIE['explain'])) {
        $out = "attach path: {$filename}<br /><br />";
        $tor['info']['pieces'] = '[...] ' . strlen($tor['info']['pieces']) . ' bytes';
        $out .= print_r($tor, true);
        bb_die("<pre>{$out}</pre>");
    }
    header("Content-Type: application/x-bittorrent; name=\"{$dl_fname}\"");
    header("Content-Disposition: attachment; filename=\"{$dl_fname}\"");
    bb_exit($output);
}