Esempio n. 1
0
$complete = intval($data->complete);
$queryHandle = mysql_query("SELECT count(fileid) as incomplete from bittorrent_peers where fileid = '" . $infoHashObject->id . "' and status!='completed'");
$data = mysql_fetch_object($queryHandle);
$incomplete = intval($data->incomplete);
$peersElement = new BElement(BList::toEncoded($peerList));
$out = BDictionary::toEncoded(array("interval" => DEFAULT_CONNECTION_INTERVAL, "complete" => $complete, "incomplete" => $incomplete, "peers" => $peersElement));
// Echo the answer to stdout
echo $out;
$fh = fopen(TRACKER_LOGFILE, "a");
fputs($fh, date(DATE_ATOM, time()) . " " . $_SERVER["REMOTE_ADDR"] . " - " . $event . "\n");
fclose($fh);
// ------------------------------------------------------
// Check if the database needs cleaning
$cache_args = "tracker_timer";
$cacheddata = get_cached_data(DB_CLEAN_TTL, $cache_args);
if ($cacheddata) {
    //If we have got the timer in cache
    // Do nothing
} else {
    //if not do queries etc to clean DB
    // TODO: update the bittorrent_statistics table here before deleting entries
    mysql_query("DELETE from bittorrent_files where timestamp<" . (time() - TORRENT_TTL));
    echo mysql_error();
    mysql_query("DELETE from bittorrent_peers where timestamp<" . (time() - PEER_TTL));
    echo mysql_error();
    mysql_query("DELETE from bittorrent_ipbans where timestamp<" . time());
    echo mysql_error();
    // And reset the timer in the cache
    set_cache_data(serialize(time()), $cache_args);
    //save data in cache
}
Esempio n. 2
0
 $cache_args = "userid=" . $id;
 $cached_data = get_cached_data(USER_PAGE_TTL, $cache_args);
 if ($cached_data) {
     // We found some old but non-stale data, let's use it
     $data = unserialize($cached_data);
     $user = $data->user;
     $community_links = $data->clo;
 } else {
     // No data was found, generate new data for the cache and store it
     $user = lookup_user_id($id);
     BoincForumPrefs::lookup($user);
     $user = @get_other_projects($user);
     $community_links = get_community_links_object($user);
     $data->user = $user;
     $data->clo = $community_links;
     set_cache_data(serialize($data), $cache_args);
 }
 if (!$user->id) {
     error_page("No such user found - please check the ID and try again.");
 }
 $logged_in_user = get_logged_in_user(false);
 page_head(tra("Account data for %1", $user->name));
 start_table();
 echo '<tr><td valign="top">';
 start_table();
 show_user_summary_public($user);
 end_table();
 project_user_summary($user);
 show_other_projects($user, false);
 echo '<tr><td valign="top">';
 start_table();
Esempio n. 3
0
}
if ($user->id == $team->ping_user) {
    $get_from_db = true;
}
// Cache the team record, its forum record, its new members,
// its admins, and its member counts
$cache_args = "teamid={$teamid}";
if (!$get_from_db) {
    $cached_data = get_cached_data(TEAM_PAGE_TTL, $cache_args);
    if ($cached_data) {
        // We found some old but non-stale data, let's use it
        $team = unserialize($cached_data);
    } else {
        $get_from_db = true;
    }
}
if ($get_from_db) {
    $team->nusers = BoincUser::count("teamid={$teamid}");
    $team->nusers_worked = BoincUser::count("teamid={$teamid} and total_credit>0");
    $team->nusers_active = BoincUser::count("teamid={$teamid} and expavg_credit>0.1");
    $team->forum = BoincForum::lookup("parent_type=1 and category={$team->id}");
    $team->new_members = new_member_list($teamid);
    $team->admins = admin_list($teamid);
    $team->founder = BoincUser::lookup_id($team->userid);
    set_cache_data(serialize($team), $cache_args);
}
if (!$team) {
    error_page("No such team");
}
display_team_page($team, $user);
page_tail(true);
        } else {
            $file = substr($file, $pos);
        }
    }
}
$file = $fileDirectory . $file;
if (!$fileFilter->isValid($file)) {
    throw new IllegalArgumentException("File was not accepted by the server for tracking.");
}
// Everything's fine let's lookup the .torrent in the cache if needed:
$cache_args = "file=" . $file . "&modtime=" . $fileModTime;
$cacheddata = get_cached_data(TORRENT_CACHE_TTL, $cache_args);
if ($cacheddata) {
    //If we have got the data in cache
    $torrent = unserialize($cacheddata);
    // use the cached data
} else {
    //if not do queries etc to generate new data
    for ($i = 0; $i < sizeof($webseeds); $i++) {
        $realWebseeds[] = $webseeds[$i] . substr($file, strlen($fileDirectory));
    }
    $torrent = new Torrent($file, $trackerURL, $realWebseeds);
    $torrent->ensureSHA1Loaded();
    db_init();
    $torrent->register();
    set_cache_data(serialize($torrent), $cache_args);
    //save data in cache
}
header("Content-type: application/x-bittorrent");
header("Content-Disposition: attachment; filename=\"" . basename($file) . ".torrent\"");
echo $torrent->toEncoded();
Esempio n. 5
0
    error_page(tra("No such user"));
}
if (!$user->has_profile) {
    error_page(tra("This user has no profile"));
}
$logged_in_user = get_logged_in_user(false);
check_whether_to_show_profile($user, $logged_in_user);
$cache_args = "userid={$userid}";
$cacheddata = get_cached_data(USER_PROFILE_TTL, $cache_args);
if ($cacheddata) {
    // Already got a cached version of the information
    $community_links_object = unserialize($cacheddata);
} else {
    // Need to generate a new bunch of data
    $community_links_object = get_community_links_object($user);
    set_cache_data(serialize($community_links_object), $cache_args);
}
page_head("Profile: {$user->name}");
start_table();
echo "<tr><td valign=\"top\">";
start_table();
show_profile($user, $logged_in_user);
end_table();
echo "</td><td valign=\"top\">";
start_table();
row2(tra("Account data"), "<a href=\"show_user.php?userid=" . $userid . "\">" . tra("View") . "</a>");
community_links($community_links_object, $logged_in_user);
end_table();
echo "</td></tr>";
end_table();
page_tail();