/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk

« back to all changes in this revision

Viewing changes to system/drop_inactive.php

  • Committer: Suren A. Chilingaryan
  • Date: 2018-04-13 03:36:27 UTC
  • Revision ID: csa@suren.me-20180413033627-hezwtouu6ro2cr7u
System script to drop innactive databases (BEWARE of multi-setup configurations)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
$curdir = getcwd();
 
4
if (preg_match("/(.*)cache.php$/", $_SERVER['SCRIPT_FILENAME'], $m)) @chdir($m[1]);
 
5
require("../adei.php");
 
6
 
 
7
 
 
8
try {
 
9
    $flags = REQUEST::NEED_ITEMINFO|REQUEST::NEED_INFO|CACHE::TABLE_INFO|CACHE::NEED_REQUESTS|CACHE::FIND_BROKEN|REQUEST::LIST_WILDCARDED;
 
10
 
 
11
    $cache = new CACHEDB();
 
12
    $list = $cache->GetCacheList($flags);
 
13
 
 
14
    foreach ($list as $id => &$info) {
 
15
        if ($info['req']) continue;
 
16
        if ($info['disconnected']) continue;
 
17
        if ($info['db_server'] == 'logs') continue;
 
18
 
 
19
        echo translate("Dropping %s", $info['postfix']);
 
20
        if (preg_match("/^__md5_(.*)$/", $info['postfix'], $m)) {
 
21
            echo " (" . $info['db_server'] . "__" . $info['db_name'] . "__" . $info['db_group'] . ")";
 
22
        }
 
23
        echo ": ";
 
24
        $cache->Drop($info['postfix']);
 
25
        echo "done\n";
 
26
    }
 
27
} catch (ADEIException $ae) {
 
28
    throw $ae;
 
29
}
 
30
 
 
31
?>