Пример #1
0
function compile_databases()
{
    $users = new usersMenus();
    $squid = new squidbee();
    $array = $squid->SquidGuardDatabasesStatus();
    $verb = " -d";
    $array = $squid->SquidGuardDatabasesStatus(0);
    if (count($array) > 0) {
        while (list($index, $file) = each($array)) {
            echo "Starting......: squidGuard compiling " . count($array) . " databases\n";
            $file = str_replace(".db", '', $file);
            $textfile = str_replace("/var/lib/squidguard/", "", $file);
            echo "Starting......: squidGuard compiling {$textfile} database " . ($index + 1) . "/" . count($array) . "\n";
            if ($GLOBALS["VERBOSE"]) {
                $verb = " -d";
                echo $users->SQUIDGUARD_BIN_PATH . " {$verb} -C {$file}\n";
            }
            system($users->SQUIDGUARD_BIN_PATH . " -P{$verb} -C {$file}");
        }
    } else {
        echo "Starting......: squidGuard compiling all databases\n";
        if ($GLOBALS["VERBOSE"]) {
            $verb = " -d";
            echo $users->SQUIDGUARD_BIN_PATH . " {$verb} -C all\n";
        }
        system($users->SQUIDGUARD_BIN_PATH . " -P{$verb} -C all");
    }
    $user = GetSquidUser();
    $unix = new unix();
    $chown = $unix->find_program("chown");
    $chmod = $unix->find_program("chmod");
    shell_exec("{$chown} -R {$user} /var/lib/squidguard/*");
    shell_exec("{$chmod} -R 755 /var/lib/squidguard/*");
    system(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --build");
    build();
    KillSquidGuardInstances();
}