Example #1
0
            $hashes[] = urldecode(substr($request_var, 10));
        }
    }
    if (count($hashes[0]) == 0) {
        bt_message('Please supply an info_hash', BITTORRENT_MESSAGE_ERROR);
    }
    foreach ($hashes as $info_hash) {
        $info_hash;
        $valid = db_result(db_query("SELECT nid FROM {bt_torrents} WHERE info_hash = %b", $info_hash));
        if ($valid) {
            if (variable_get('bt_tracker_scrape_scope', 0) == 0) {
                $response['files'][$info_hash] = db_fetch_array(db_query("SELECT bt.seeders AS complete, bt.leechers AS incomplete, bt.downloaded FROM {bt_torrents} bt WHERE bt.info_hash = %b", $info_hash));
            } else {
                $response['files'][$info_hash]['complete'] = db_result(db_query("SELECT COUNT(btau.ip) FROM {bt_tracker_active_users} btau WHERE btau.bytes_left = 0 AND btau.info_hash = %b", $info_hash));
                $response['files'][$info_hash]['incomplete'] = db_result(db_query("SELECT COUNT(btau.ip) FROM {bt_tracker_active_users} btau WHERE (NOT btau.bytes_left = 0) AND btau.info_hash = %b", $info_hash));
                $response['files'][$info_hash]['completed'] = db_result(db_query("SELECT bt.downloaded FROM {bt_torrents} bt WHERE bt.info_hash = %b", $info_hash));
            }
            $struct = strip_excess(bdecode(db_result(db_query('SELECT metadata FROM {bt_torrents} WHERE info_hash = %b', $info_hash))));
            $response['files'][$info_hash]['name'] = $struct['info']['name'];
        }
    }
    if (count($response['files']) == 0) {
        bt_message('Invalid info hash(s)', BITTORRENT_MESSAGE_ERROR);
    }
    $response['flags'] = array();
    $response['flags']['min_request_interval'] = variable_get('bt_tracker_scrape_interval', 900);
    bencode_response_raw(bencode($response));
} else {
    // Let the client know that the tracker is offline.
    bt_message('Tracker is Offline', BITTORRENT_MESSAGE_ERROR);
}
 $email = $validate->email(Input::get('email'));
 //make sure $validation is the last validation check because it makes sure there are no errors in total(including image errors.)
 $validation = $validate->check($_POST, array('username' => ['fieldname' => 'Username', 'required' => true, 'min' => 3, 'max' => 20, 'unique' => 'users', 'contains' => 'alnum(m:letters)'], 'password' => ['fieldname' => 'Password', 'required' => true, 'min' => 6], 'name' => ['fieldname' => 'Name', 'required' => true, 'min' => 2, 'max' => 50], 'email' => ['fieldname' => 'Email', 'min' => 3, 'max' => 320, 'unique' => 'users']));
 if ($validation->passed()) {
     if ($profile_pic_check === false) {
         $profilePicDest = 'images/default_profile_pic.jpg';
     } else {
         $image = new ImageManipulation(Input::get('profile_pic'));
         $image->moveTo('images/uploads/');
         $profilePicDest = $image->getNewDest();
     }
     $user = new User();
     $salt = Hash::salt(32);
     $email_code = md5(Input::get('username') . microtime());
     try {
         $user->create(['username' => Input::get('username'), 'password' => Hash::make(Input::get('password'), $salt), 'salt' => $salt, 'fullname' => strip_excess(Input::get('name')), 'email' => $email, 'profile_pic' => $profilePicDest]);
         /*
          * TODO: Email Activation Up and Running. V(1.0)
          * $mail = new Email;
          * $mail->sendGmailActivation(BASE_URL . 'activate/' . $email_code );
          * */
         Session::flash('success', 'You registered successfully!');
         Redirect::to(BASE_URL);
     } catch (Exception $e) {
         die($e->getMessage());
     }
 } else {
     foreach ($validate->getErrors() as $error) {
         echo $error . '<br>';
     }
 }
Example #3
0
    }
}
foreach ($_optional_keys as $key) {
    if (array_key_exists($key, $_GET)) {
        $request[$key] = $_GET[$key];
    }
}
/**
 * Lookup the info_hash and verify that we are indeed tracking it and it supports web seeding. Retrieve the torrent file should all criteria be met.
 */
$result = db_result(db_query("SELECT web_seed FROM {bt_torrents} btt WHERE btt.info_hash = %b", $request['info_hash']));
if (isset($result) || $result == 0) {
    seed_message(400, 'Tracker is currently not tracking that torrent or the torrent does not support web seeding.', TRUE);
}
// TODO: Add server control settings
$torrent = strip_excess(bdecode(db_result(db_query("SELECT metadata FROM {bt_torrents} btt WHERE info_hash = %b", $request['info_hash']))));
if (array_key_exists('length', $torrent['info'])) {
    // Single file torrent
    $torrent_length = $torrent['info']['length'];
} else {
    // Multiple file torrent
    $torrent_length = 0;
    foreach ($torrent['info']['files'] as $file) {
        $torrent_length += $file['length'];
    }
}
/**
 * Verify that the piece exists within the torrent
 */
if ($request['piece'] != 0) {
    $piece_count = $torrent_length / $torrent['info']['piece length'];