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