SysMgr.blockPrivateSites ()
function blocks private sites that are offline for too long if enabled and configured properly in app.properties

Sourcecode in SysMgr/cleanupFunctions.js:
1:   function blockPrivateSites() {
2:      var enable = root.sys_blockPrivateSites;
3:      var blockWarningAfter = root.sys_blockWarningAfter;
4:      var blockAfterWarning = root.sys_blockAfterWarning;
5:      if (!enable) {
6:         // blocking of private sites is disabled
7:         return;
8:      } else if (!blockWarningAfter || !blockAfterWarning) {
9:         // something is fishy with blocking properties
10:        this.syslogs.add (new SysLog("system", null, "blocking of private sites cancelled", null));
11:        return;
12:     }
13:     var size = this.privateSites.size();
14:     this.syslogs.add (new SysLog("system", null, "checking " + size + " private site(s) ...", null));
15:  
16:     // get thresholds in millis
17:     warnThreshold = blockWarningAfter*1000*60*60*24;
18:     blockThreshold = blockAfterWarning*1000*60*60*24;
19:  
20:     for (var i=0;i<size;i++) {
21:        var site = this.privateSites.get(i);
22:        // if site is trusted, we do nothing
23:        if (site.trusted)
24:           continue;
25:  
26:        var privateFor = new Date() - site.lastoffline;
27:        var timeSinceWarning = new Date() - site.lastblockwarn;
28:        if (privateFor >= warnThreshold) {
29:           // check if site-admins have been warned already
30:           var alreadyWarned = false;
31:           if (site.lastblockwarn > site.lastoffline)
32:              alreadyWarned = true;
33:           // check whether warn admins or block site
34:           if (!alreadyWarned) {
35:              // admins of site haven't been warned about upcoming block, so do it now
36:              var warning = new Mail;
37:              var recipient = site.email ? site.email : site.creator.email;
38:              warning.addTo(recipient);
39:              warning.setFrom(root.sys_email);
40:              warning.setSubject(getMessage("mail.blockWarning", site.title));
41:              var sp = new Object();
42:              sp.site = site.alias;
43:              sp.url = site.href();
44:              sp.privatetime = blockWarningAfter;
45:              sp.daysleft = blockAfterWarning;
46:              sp.contact = root.sys_email;
47:              warning.addText(this.renderSkinAsString("blockwarnmail", sp));
48:              warning.send();
49:              this.syslogs.add (new SysLog("site", site.alias, "site is private for more than " + blockWarningAfter + " days, sent warning to " + recipient, null));
50:              site.lastblockwarn = new Date();
51:           } else if (timeSinceWarning >= blockThreshold) {
52:              // site is offline for too long, so block it
53:              site.blocked = 1;
54:              this.syslogs.add (new SysLog("site", site.alias, "blocked site", null));
55:           }
56:        } else
57:           break;
58:     }   
59:     this.syslogs.add (new SysLog("system", null, "finished checking for private sites", null));
60:     return true;
61:  }