All pastes #2051021 Raw Edit

Miscellany

public text v1 · immutable
#2051021 ·published 2011-04-26 21:56 UTC
rendered paste body
//---------------------------------------------------------------------------------------------------------------------------------------------------------------
//==Disabled inactive users Added on 19-04-11 so it'd work from now this date onwards.The rest of the acounts had to be disabled with a query with no modcomment.//=30 days old Only kicks in for last login 30days ago...
//---------------------------------------------------------------------------------------------------------------------------------------------------------------
    $days = 90; //==days of inactivity
          $dt= time() - ($days * 86400);
    $res = mysql_query("SELECT id, modcomment, last_access FROM users WHERE last_access < $dt AND enabled='yes' AND status='confirmed' AND donor='no' AND last_access NOT LIKE '0000-00-00 00:00:00'") or sqlerr(__FILE__, __LINE__);
    if (mysql_num_rows($res) > 0) {
        while ($arr = mysql_fetch_assoc($res)) {
            $modcomment = sqlesc(gmdate("Y-m-d") . " - Auto-disabled for inactivity By System\n");
            $users_buffer[] = '(' . $arr['id'] . ', \'no\', ' . $modcomment . ')';
        }
        if (sizeof($users_buffer) > 0) {
            @mysql_query("INSERT INTO users (id, enabled, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE enabled=values(enabled),
            modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__);
            $count = mysql_affected_rows();
            write_log("Cleanup:  Disabled " . $count . " Member(s) for inactivity");
        }
        unset ($users_buffer);
    }
    //==End