Skip to content

Commit d2e04ee

Browse files
authored
Merge pull request #6702 from BOINC/dpa_stats
web: get cross-project stats from free-dc.org rather than netsoft-online.com
2 parents 7ce2563 + 61c6a5d commit d2e04ee

File tree

6 files changed

+63
-57
lines changed

6 files changed

+63
-57
lines changed

html/inc/stats_sites.inc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ $cpid_stats_sites = array(
2626
array("BOINCstats",
2727
"http://boincstats.com/en/stats/-1/user/detail/%s"
2828
),
29-
array("BOINC Combined Statistics",
30-
"http://boinc.netsoft-online.com/e107_plugins/boinc/get_user.php?cpid=%s&html=1"
31-
),
3229
);
3330

3431
$stats_sites = array(
@@ -51,10 +48,6 @@ $stats_sites = array(
5148
""
5249
),
5350
*/
54-
array("http://boinc.netsoft-online.com/",
55-
"BOINC Combined Statistics",
56-
"developed by James Drews"
57-
),
5851
array("http://boincstats.com/",
5952
"BOINCstats",
6053
"by Willy de Zutter"

html/inc/user.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if (!defined('REMOTE_PROJECTS_TTL')) {
3434
//
3535
function get_other_projects($user) {
3636
$cpid = md5($user->cross_project_id . $user->email_addr);
37-
$url = "http://boinc.netsoft-online.com/get_user.php?cpid=".$cpid;
37+
$url = "https://api.free-dc.org/get_user.php?cpid=$cpid";
3838

3939
// Check the cache for that URL
4040
//

html/inc/util.inc

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,6 @@ $caching = false;
138138
// if set, we're writing to a file rather than to client
139139
$did_page_head = false;
140140

141-
define('KILO', 1024);
142-
define('MEGA', 1024*KILO);
143-
define('GIGA', 1024*MEGA);
144-
define('TERA', 1024*GIGA);
145-
146141
// return true if this page is HTTPS
147142
//
148143
function is_https() {
@@ -420,32 +415,6 @@ function error_page($msg) {
420415
exit();
421416
}
422417

423-
// convert time interval in seconds to a string of the form
424-
// 'D days h hours m min s sec'.
425-
426-
function time_diff($x, $res=3) {
427-
$x = (int)$x;
428-
$days = (int)($x/86400);
429-
$hours = (int)(($x-$days*86400)/3600);
430-
$minutes = (int)(($x-$days*86400-$hours*3600)/60);
431-
$seconds = $x % 60;
432-
433-
$s = "";
434-
if ($days) {
435-
$s .= "$days ".tra("days")." ";
436-
}
437-
if ($res>0 && ($hours || strlen($s))) {
438-
$s .= "$hours ".tra("hours")." ";
439-
}
440-
if ($res>1 && ($minutes || strlen($s))) {
441-
$s .= "$minutes ".tra("min")." ";
442-
}
443-
if ($res>2) {
444-
$s .= "$seconds ".tra("sec")." ";
445-
}
446-
return $s;
447-
}
448-
449418
function start_table_str($class="", $style="") {
450419
$s = $style?'style="'.$style.'"':'';
451420
return '<div class="table">

html/inc/util_basic.inc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// Doesn't contain web-specific stuff like translation.inc
2222

2323
require_once("../inc/random_compat/random.inc");
24+
// for random_bytes()
2425

2526
// show PHP errors in output (e.g. web pages).
2627
// Call this from your project.inc if you want.
@@ -215,6 +216,33 @@ function pretty_time_str($x) {
215216
return time_str($x);
216217
}
217218

219+
// convert time interval in seconds to a string of the form
220+
// 'D days h hours m min s sec'.
221+
222+
function time_diff($x, $res=3) {
223+
$x = (int)$x;
224+
$days = (int)($x/86400);
225+
$hours = (int)(($x-$days*86400)/3600);
226+
$minutes = (int)(($x-$days*86400-$hours*3600)/60);
227+
$seconds = $x % 60;
228+
229+
$s = "";
230+
if ($days) {
231+
$s .= "$days ".tra("days")." ";
232+
}
233+
if ($res>0 && ($hours || strlen($s))) {
234+
$s .= "$hours ".tra("hours")." ";
235+
}
236+
if ($res>1 && ($minutes || strlen($s))) {
237+
$s .= "$minutes ".tra("min")." ";
238+
}
239+
if ($res>2) {
240+
$s .= "$seconds ".tra("sec")." ";
241+
}
242+
return $s;
243+
}
244+
245+
218246
// security vulnerabilities and user-supplied strings:
219247
// sources:
220248
// GET and POST arguments
@@ -250,4 +278,9 @@ function filename_rules() {
250278
return 'Names can contain only A-Z a-z 0-9 . - _ space';
251279
}
252280

281+
define('KILO', 1024);
282+
define('MEGA', 1024*KILO);
283+
define('GIGA', 1024*MEGA);
284+
define('TERA', 1024*GIGA);
285+
253286
?>

html/ops/clean_cache.php

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,35 @@
1717
// You should have received a copy of the GNU Lesser General Public License
1818
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
1919

20+
// delete files from the web cache until free-space criteria are met
21+
2022
$cli_only = true;
2123
require_once("../inc/cache.inc");
2224
require_once("../inc/util_ops.inc");
2325

2426
set_time_limit(0);
2527

26-
function cache_check_diskspace2(){
27-
$too_old = 86400;
28-
while (1) {
29-
$f = disk_free_space("../cache");
30-
$u = disk_usage("../cache");
31-
echo "free: $f used: $u\n";
32-
if ($f > MIN_FREE_SPACE && $u < MAX_CACHE_USAGE) {
33-
break;
34-
}
35-
clean_cache($too_old, "../cache");
36-
$too_old/=2;
37-
}
28+
function main(){
29+
echo "------- Starting at ".time_str(time())."-------\n";
30+
31+
echo sprintf("max cache usage: %s\n", size_string(MAX_CACHE_USAGE));
32+
$too_old = 86400*7;
33+
while (1) {
34+
$u = disk_usage("../cache");
35+
echo sprintf("cache usage: %s\n", size_string($u));
36+
if ($u < MAX_CACHE_USAGE) {
37+
echo "criteria met; quitting\n";
38+
break;
39+
}
40+
echo sprintf("deleting files older than %s\n", time_diff($too_old));
41+
clean_cache($too_old, "../cache");
42+
$too_old /= 2;
43+
if ($too_old < 60) {
44+
break;
45+
}
46+
}
47+
echo "------- Finished at ".time_str(time())."-------\n";
3848
}
3949

40-
cache_check_diskspace2();
50+
main();
4151
?>

html/project.sample/cache_parameters.inc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
//
1010
// TTL = 0 means don't cache that type of page
1111

12+
require_once('../inc/util_basic.inc');
13+
1214
define('TEAM_PAGE_TTL', 3600);
1315
define('USER_PAGE_TTL', 3600);
1416
define('USER_PROFILE_TTL', 3600);
@@ -19,13 +21,12 @@ define('INDEX_PAGE_TTL', 3600);
1921
define('STATUS_PAGE_TTL', 3600);
2022
define('REMOTE_PROJECTS_TTL', 86400);
2123

22-
// max allowed cache usage, bytes
24+
// max cache usage, bytes
2325
//
24-
define('MAX_CACHE_USAGE', 1e9);
26+
define('MAX_CACHE_USAGE', 10*MEGA);
2527

26-
// the cache can grow without bound,
27-
// so every so often we need to check its size and
28-
// delete old entries.
28+
// the cache can grow without bound;
29+
// every so often we need to check its size and delete old entries.
2930
// We do this randomly, on average every N page views
3031

3132
define('CACHE_SIZE_CHECK_FREQ', 1000);

0 commit comments

Comments
 (0)