~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to html/ops/autolock.php

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env php
 
2
<?php
 
3
// This file is part of BOINC.
 
4
// http://boinc.berkeley.edu
 
5
// Copyright (C) 2008 University of California
 
6
//
 
7
// BOINC is free software; you can redistribute it and/or modify it
 
8
// under the terms of the GNU Lesser General Public License
 
9
// as published by the Free Software Foundation,
 
10
// either version 3 of the License, or (at your option) any later version.
 
11
//
 
12
// BOINC is distributed in the hope that it will be useful,
 
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
15
// See the GNU Lesser General Public License for more details.
 
16
//
 
17
// You should have received a copy of the GNU Lesser General Public License
 
18
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
 
19
 
 
20
// lock all threads older than N days
 
21
 
 
22
$cli_only = true;
 
23
require_once("../inc/util_ops.inc");
 
24
 
 
25
$max_age_days = 90;     // lock threads older than this
 
26
if ($argc > 2) {
 
27
    if ($argv[1] == "--ndays") {
 
28
        $max_age_days = $argv[2];
 
29
    }
 
30
}
 
31
 
 
32
$t = time_str(time());
 
33
echo "starting at $t\n";
 
34
$t = time() - $max_age_days*86400;
 
35
$db = BoincDb::get();
 
36
if (!$db) die("can't open DB\n");
 
37
$db->do_query("update DBNAME.thread, DBNAME.forum set DBNAME.thread.locked=1 where DBNAME.thread.forum=DBNAME.forum.id and DBNAME.forum.parent_type=0 and DBNAME.thread.timestamp<$t and DBNAME.thread.locked=0 and DBNAME.thread.sticky=0");
 
38
$n = $db->affected_rows();
 
39
$t = time_str(time());
 
40
echo "finished at $t; locked $n threads\n";
 
41
?>