Example #1
0
function lxpackage_main()
{
    global $argv;
    $list = lfile_get_unserialize("__path_package_root/pkglist.lst");
    $pkg = $list['pkg'];
    //$ver = $pkg[$argv[1]);
}
Example #2
0
function collect_traffic()
{
    $flfile = "__path_program_etc/last_sisinfoc";
    $ret = lfile_get_unserialize($flfile);
    $ret['time'] = time();
    lfile_put_serialize($flfile, $ret);
}
Example #3
0
function get_total($list, &$total)
{
    $lxgpath = "__path_home_root/lxguard";
    $rmt = lfile_get_unserialize("{$lxgpath}/hitlist.info");
    if ($rmt) {
        $total = $rmt->hl;
    }
    foreach ($list as $k => $v) {
        if (!isset($total[$k])) {
            $total[$k] = 0;
        }
        $c = count_fail($v);
        $total[$k] += $c;
    }
}
Example #4
0
function collect_traffic()
{
    $flfile = "__path_program_etc/last_sisinfoc";
    $ret = lfile_get_unserialize($flfile);
    $interval = 20 * 60;
    //$interval = 2;
    if (time() - $ret['time'] < $interval) {
        //return;
    }
    $oldtime = $ret['time'];
    //if (!$oldtime) { $oldtime = time() - 20 * 60 ; }
    if (!$oldtime) {
        $oldtime = time() - 5 * 60;
    }
    $newtime = time();
    $ret['time'] = time();
    lfile_put_serialize($flfile, $ret);
    //mailtraffic:generateGraph($oldtime, $newtime);
    //webtraffic::generateGraph($oldtime, $newtime);
}
Example #5
0
function save_slave_name($o)
{
    if (!lxfile_exists("__path_slave_db")) {
        return;
    }
    $rmt = lfile_get_unserialize("__path_slave_db");
    if ($o->machine && $rmt->myname !== $o->machine || $o->master_c && $rmt->master_c !== $o->master_c) {
        dprint("Saving slave info..\n");
        $rmt->myname = $o->machine;
        $rmt->master_c = $o->master_c;
        lfile_put_serialize("__path_slave_db", $rmt);
    }
}
Example #6
0
function lxguard_main($clearflag = false)
{
    include_once "htmllib/lib/lxguardincludelib.php";
    lxfile_mkdir("__path_home_root/lxguard");
    $lxgpath = "__path_home_root/lxguard";
    $file = "/var/log/secure";
    $fp = fopen($file, "r");
    $fsize = filesize($file);
    $newtime = time();
    $oldtime = time() - 60 * 10;
    $rmt = lfile_get_unserialize("{$lxgpath}/hitlist.info");
    if ($rmt) {
        $oldtime = max((int) $oldtime, (int) $rmt->ddate);
    }
    $ret = FindRightPosition($fp, $fsize, $oldtime, $newtime, "getTimeFromSysLogString");
    $list = lfile_get_unserialize("{$lxgpath}/access.info");
    if ($ret) {
        parse_sshd_and_ftpd($fp, $list);
        lfile_put_serialize("{$lxgpath}/access.info", $list);
    }
    get_total($list, $total);
    //dprintr($list['192.168.1.11']);
    dprintr($total);
    $deny = get_deny_list($total);
    $hdn = lfile_get_unserialize("{$lxgpath}/hostdeny.info");
    $deny = lx_array_merge(array($deny, $hdn));
    $string = null;
    foreach ($deny as $k => $v) {
        if (csb($k, "127")) {
            continue;
        }
        $string .= "ALL : {$k}\n";
    }
    dprint($string);
    $stlist[] = "###Start Program Hostdeny config Area";
    $stlist[] = "###Start Lxdmin Area";
    $stlist[] = "###Start Kloxo Area";
    $stlist[] = "###Start Lxadmin Area";
    $endlist[] = "###End Program HostDeny config Area";
    $endlist[] = "###End Kloxo Area";
    $endlist[] = "###End Lxadmin Area";
    $startstring = $stlist[0];
    $endstring = $endlist[0];
    file_put_between_comments($stlist, $endlist, $startstring, $endstring, "/etc/hosts.deny", $string);
    if ($clearflag) {
        lxfile_rm("{$lxgpath}/access.info");
        $rmt = new Remote();
        $rmt->hl = $total;
        $rmt->ddate = time();
        lfile_put_serialize("{$lxgpath}/hitlist.info", $rmt);
    }
    return $list;
}
Example #7
0
 function importHypervmVPS()
 {
     $vpsdata = lfile_get_unserialize("/home/hypervm/data/complete");
     foreach ($vpsdata as $k => $v) {
         $v->syncserver = $this->main->nname;
     }
     return $vpsdata;
 }
Example #8
0
<?php

include_once "htmllib/lib/include.php";
if (!isset($argv[1])) {
    print "Need file name\n";
    exit;
}
$file = $argv[1];
$opt = parse_opt($argv);
$slave = null;
if (isset($opt["slave-id"])) {
    $slave = $opt["slave-id"];
}
$sq = new Sqlite(null, "vps");
$res = $sq->getTable();
$nlist = lfile_get_unserialize($file);
if (!$nlist) {
    print "Could not read file {$file}\n";
    exit;
}
if (!$nlist) {
    print "Cannot read db file..... Exiting..\n";
    exit;
}
//dprintr($nlist);
foreach ($res as $r) {
    if ($slave) {
        if ($r['syncserver'] !== $slave) {
            continue;
        }
    } else {