function table(){
$tpl=new templates();	
$page=CurrentPageName();

$zdate=$tpl->javascript_parse_text("{time}");
$ipaddr=$tpl->javascript_parse_text("{ipaddr}");
$mac=$tpl->javascript_parse_text("{MAC}");
$familysite=$tpl->javascript_parse_text("{familysite}");
$uid=$tpl->javascript_parse_text("{uid}");
$size=$tpl->javascript_parse_text("{size}");
// ipaddr        | familysite            | servername                                | uid               | MAC               | size
$t=time();	
$servername=null;
$uuid=urlencode($_GET["uuid"]);
if($_GET["uuid"]<>null){
	$q=new mysql_meta();
	$servername=" ".$q->uuid_to_host($_GET["uuid"])." - ".$q->uuid_to_tag($_GET["uuid"]);
}
$title=$tpl->javascript_parse_text("{cached_websites}::{this_week}$servername");
$html="
<table class='flexRT$t' style='display:none' id='flexRT$t'></table>
<script>
function StartLogsSquidTable$t(){
	
	$('#flexRT$t').flexigrid({
		url: '$page?list=yes&uuid=$uuid',
		dataType: 'json',
		colModel : [
			{display: '$familysite', name : 'familysite', width : 504, sortable : true, align: 'left'},
			{display: '$size', name : 'size', width : 142, sortable : true, align: 'right'},
			],
	
		searchitems : [
			
			{display: '$familysite', name : 'familysite'},
			
			],
		sortname: 'size',
		sortorder: 'desc',
		usepager: true,
		title: '<span style=font-size:20px>$title</span>',
		useRp: true,
		rp: 50,
		showTableToggleBtn: false,
		width: '99%',
		height: 450,
		singleSelect: true,
		rpOptions: [10, 20, 30, 50,100,200,500,1000,1500]
		
		});   

}

StartLogsSquidTable$t();
</script>			
";
echo $html;	
}
function js()
{
    header("content-type: application/x-javascript");
    $tpl = new templates();
    $title = $tpl->_ENGINE_parse_body("{events}");
    $page = CurrentPageName();
    $artica_meta = new mysql_meta();
    if (isset($_GET["uuid"])) {
        $hostname = $artica_meta->uuid_to_host($_GET["uuid"]);
        $tag = $artica_meta->uuid_to_tag($_GET["uuid"]);
    }
    echo "YahooWin4('770','{$page}?popup=yes&gpid={$_GET["gpid"]}&uuid=" . urlencode($_GET["uuid"]) . "','{$hostname} - {$tag}')";
}
function js()
{
    header("content-type: application/x-javascript");
    $page = CurrentPageName();
    $tpl = new templates();
    $uuid = $_GET["uuid"];
    $q = new mysql_meta();
    $hostname = $q->uuid_to_host($uuid);
    $uuid = urlencode($uuid);
    $tag = $q->uuid_to_tag($_GET["uuid"]);
    $title = $tpl->javascript_parse_text("{orders}::{$hostname} - {$tag}");
    $html = "RTMMail(990,'{$page}?popup=yes&uuid={$uuid}&t={$_GET["t"]}','{$title}');";
    echo $html;
}
function table()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $zdate = $tpl->javascript_parse_text("{time}");
    $ipaddr = $tpl->javascript_parse_text("{ipaddr}");
    $mac = $tpl->javascript_parse_text("{MAC}");
    $familysite = $tpl->javascript_parse_text("{familysite}");
    $members = $tpl->javascript_parse_text("{members}");
    $size = $tpl->javascript_parse_text("{size}");
    // ipaddr        | familysite            | servername                                | uid               | MAC               | size
    $t = time();
    $servername = null;
    $uuid = urlencode($_GET["uuid"]);
    if ($_GET["uuid"] != null) {
        $q = new mysql_meta();
        $servername = " " . $q->uuid_to_host($_GET["uuid"]) . " - " . $q->uuid_to_tag($_GET["uuid"]);
    }
    $title = $tpl->javascript_parse_text("{downloaded_size}::{websites} {this_week}{$servername}");
    $html = "\n<table class='flexRT{$t}' style='display:none' id='flexRT{$t}'></table>\n<script>\nfunction StartLogsSquidTable{$t}(){\n\t\n\t\$('#flexRT{$t}').flexigrid({\n\t\turl: '{$page}?list=yes&uuid={$uuid}',\n\t\tdataType: 'json',\n\t\tcolModel : [\n\t\t\t{display: '{$familysite}', name : 'familysite', width : 716, sortable : true, align: 'left'},\n\t\t\t{display: '{$members}', name : 'members', width : 143, sortable : true, align: 'right'},\n\t\t\t{display: '{$size}', name : 'size', width : 202, sortable : true, align: 'right'},\n\t\t\t],\n\t\n\t\tsearchitems : [\n\t\t\t\n\t\t\t{display: '{$familysite}', name : 'familysite'},\n\t\t\t\n\t\t\t],\n\t\tsortname: 'size',\n\t\tsortorder: 'desc',\n\t\tusepager: true,\n\t\ttitle: '{$title}',\n\t\tuseRp: true,\n\t\trp: 50,\n\t\tshowTableToggleBtn: false,\n\t\twidth: '99%',\n\t\theight: 450,\n\t\tsingleSelect: true,\n\t\trpOptions: [10, 20, 30, 50,100,200,500,1000,1500]\n\t\t\n\t\t});   \n\n}\n\nStartLogsSquidTable{$t}();\n</script>\t\t\t\n";
    echo $html;
}
function sysalerts_smtp_client_scan($uuid)
{
    $unix = new unix();
    $sock = new sockets();
    $q = new mysql();
    if (!$q->test_mysql_connection()) {
        return;
    }
    $meta = new mysql_meta();
    $hostname = $meta->uuid_to_host($uuid);
    $tag = $meta->uuid_to_tag($uuid);
    if ($tag != null) {
        $hostname = "{$hostname}/{$tag}";
    }
    $severityT[0] = "Alert";
    $severityT[1] = "Warning";
    $ArticaMetaStorage = $sock->GET_INFO("ArticaMetaStorage");
    if ($ArticaMetaStorage == null) {
        $ArticaMetaStorage = "/home/artica-meta";
    }
    $destdir = "{$ArticaMetaStorage}/{$uuid}/SMTP_NOTIF";
    $files = $unix->DirFiles($destdir);
    while (list($filename, $ARRAY) = each($files)) {
        $sourcefile = "{$destdir}/{$filename}";
        $filetime = $unix->file_time_min($sourcefile);
        if ($filetime > 240) {
            @unlink($sourcefile);
            continue;
        }
        $array = unserialize(@file_get_contents($sourcefile));
        if (!is_array($array)) {
            meta_events("{$sourcefile} no such array");
            @unlink($sourcefile);
            continue;
        }
        $zdate = $array["zdate"];
        $subject = $array["subject"];
        $text = $array["text"];
        $severity = $array["severity"];
        $function = $array["function"];
        $file = $array["file"];
        $line = $array["line"];
        $md5 = md5("{$uuid}{$subject}");
        if (isset($GLOBALS["NOTIFS"][$md5])) {
            @unlink($sourcefile);
            continue;
        }
        $GLOBALS["NOTIFS"][$md5] = true;
        $subject = "[{$hostname}]:{$severityT[$severity]} {$subject}";
        $content = "Operation created by {$hostname} on {$zdate} by {$file} ({$function} in line:{$line})\nuuid:{$uuid}\n{$text}\n";
        if (!send_notifications($subject, $content)) {
            continue;
        }
        @unlink($sourcefile);
    }
}
示例#6
0
function menu_system()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $artica_meta = new mysql_meta();
    $sock = new sockets();
    $ArticaMetaUseSendClient = intval($sock->GET_INFO("ArticaMetaUseSendClient"));
    $gpid = $_GET["gpid"];
    if ($gpid == 0) {
        $hostname = $artica_meta->uuid_to_host($_GET["uuid"]);
        $tag = $artica_meta->uuid_to_tag($_GET["uuid"]);
    } else {
        $hostname = $artica_meta->gpid_to_name($_GET["gpid"]);
        $tag = $artica_meta->group_count($_GET["gpid"]) . " " . $tpl->javascript_parse_text("{computers}");
    }
    if ($ArticaMetaUseSendClient == 1) {
        $tr[] = paragrapheFleche("{send_ping}", "Loadjs('{$page}?send-ping-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    }
    if ($gpid == 0) {
        $tr[] = paragrapheFleche("{change_hostname}", "Loadjs('{$page}?change-hostname-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    }
    if ($gpid == 0) {
        $tr[] = paragrapheFleche("{add_tag}", "Loadjs('{$page}?add-tag-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    }
    if ($gpid == 0) {
        if (intval($artica_meta->GET_CONFIG("EnableKerbAuth", $_GET["uuid"]))) {
            $tr[] = paragrapheFleche("{activedirectroy_reconnection}", "Loadjs('{$page}?activedirectory-reconnect-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
        }
    }
    if ($gpid > 0) {
        if ($artica_meta->group_is_ad_inside($gpid)) {
            $tr[] = paragrapheFleche("{activedirectroy_reconnection}", "Loadjs('{$page}?activedirectory-reconnect-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
        }
    }
    $tr[] = paragrapheFleche("{reboot}", "Loadjs('{$page}?reboot-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    $tr[] = paragrapheFleche("{root_password2}", "Loadjs('{$page}?root-password-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    $tr[] = paragrapheFleche("{global_admin_account}", "Loadjs('{$page}?manager-password-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    $tr[] = paragrapheFleche("{install_package}", "Loadjs('artica-meta.packages.php?uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    $tr[] = paragrapheFleche("{update_artica}", "Loadjs('artica-meta.update.artica.php?uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    $tr[] = paragrapheFleche("{directories_monitor}", "Loadjs('{$page}?philesight-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    $tr[] = paragrapheFleche("{create_a_snapshot}", "Loadjs('{$page}?snapshot-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    $tr[] = paragrapheFleche("{restore_a_snapshot}", "Loadjs('artica-meta.snapshots.browse.php?uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    if ($gpid == 0) {
        $tr[] = paragrapheFleche("{delete}", "Loadjs('{$page}?delete-js=yes&uuid=" . urlencode($_GET["uuid"]) . "')");
    }
    $html = "<div style='font-size:18px;margin-bottom:20px'>{$hostname} - {$tag} - {$_GET["uuid"]}</div>" . CompileTr3($tr);
    echo $tpl->_ENGINE_parse_body($html);
}
示例#7
0
function showlist()
{
    $page = 1;
    $q = new mysql_meta();
    $type = $_GET["type"];
    if ($type == "hour") {
        $tablename = "metastats_size_" . date("YmdH");
        $table = "(SELECT COUNT(zmd5) as hits,SUM(size) as size,uuid FROM `{$tablename}` GROUP BY `uuid` ) as t";
    }
    if ($type == "day") {
        $tablename = "metastats_sized_" . date("Ymd");
        $table = "(SELECT SUM(hits) as hits,SUM(size) as size,uuid FROM `{$tablename}` GROUP BY `uuid` ) as t";
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $searchstring = string_to_flexquery();
    if ($searchstring != null) {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    if (!is_numeric($rp)) {
        $rp = 50;
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}";
    if (isset($_GET["verbose"])) {
        echo "<hr><code>{$sql}</code></hr>";
    }
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        json_error_show($q->mysql_error, 0);
    }
    if (mysql_num_rows($results) == 0) {
        if (!$q->TABLE_EXISTS($table)) {
            $add = " no table!";
        }
        json_error_show("no data {$add} <i>{$sql}</i>", 1);
    }
    $data = array();
    $data['page'] = 1;
    $data['total'] = mysql_num_rows($results);
    $data['rows'] = array();
    while ($ligne = mysql_fetch_assoc($results)) {
        $ipaddr = $ligne["ipaddr"];
        $uuid = $ligne["uuid"];
        $hostname = $q->uuid_to_host($uuid);
        $tag = $q->uuid_to_tag($uuid);
        $size = FormatBytes($ligne["size"] / 1024);
        $hits = FormatNumber($ligne["hits"]);
        $ipaddr_enc = urlencode($ipaddr);
        $loupe_mac = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.access.log.php?js=yes&SearchString={$ipaddr}&data=&minsize=1')\">\n\t\t<img src='img/loupe-32.png' style='float:right'>\n\t\t</a>";
        $data['rows'][] = array('id' => md5(serialize($ligne)), 'cell' => array("<span style='font-size:18px'>{$hostname}</span>", "<span style='font-size:18px'>{$tag}</a></span>", "<span style='font-size:18px'>{$hits}</a></span>", "<span style='font-size:18px'>{$size}</span>"));
    }
    echo json_encode($data);
}
示例#8
0
function menu_system()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $artica_meta = new mysql_meta();
    $sock = new sockets();
    $ArticaMetaUseSendClient = intval($sock->GET_INFO("ArticaMetaUseSendClient"));
    $gpid = $_GET["gpid"];
    $LicenseText = null;
    if ($gpid == 0) {
        $hostname = $artica_meta->uuid_to_host($_GET["uuid"]);
        $ArticaVersion = $artica_meta->ArticaVersion($_GET["uuid"]);
        $tag = $artica_meta->uuid_to_tag($_GET["uuid"]);
        $LicenseInfos = $artica_meta->LicenseInfos($_GET["uuid"]);
        $LicenseJs = "OnClick=\"javascript:Loadjs('artica-meta.host.license.php?uuid={$_GET["uuid"]}')\"";
        $LICT = " Community Edition";
        if ($LicenseInfos["CORP_LICENSE"]) {
            $LICT = " Entreprise Edition";
        }
        if ($LicenseInfos["ExpiresSoon"] > 0) {
            if ($LicenseInfos["ExpiresSoon"] < 31) {
                $LICT = "<span style='color:red'>{trial_mode}</span>";
            }
        }
        $LicenseText = "<div style='text-align:right;margin-top:-30px;margin-bottom:30px'><i><a href=\"javascript:blur();\" {$LicenseJs} style='font-size:14px;text-decoration:underline'>v{$ArticaVersion} - {$LICT} - {company}:{$LicenseInfos["COMPANY"]}</a></i></div>";
    } else {
        $hostname = $artica_meta->gpid_to_name($_GET["gpid"]);
        $tag = $artica_meta->group_count($_GET["gpid"]) . " " . $tpl->javascript_parse_text("{computers}");
    }
    if ($ArticaMetaUseSendClient == 1) {
        $tr[] = paragrapheFleche("{send_ping}", "Loadjs('{$page}?send-ping-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    }
    if ($gpid == 0) {
        $tr[] = paragrapheFleche("{change_hostname}", "Loadjs('{$page}?change-hostname-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    }
    if ($gpid == 0) {
        $tr[] = paragrapheFleche("{add_tag}", "Loadjs('{$page}?add-tag-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    }
    if ($gpid == 0) {
        if (intval($artica_meta->IsAD($_GET["uuid"]))) {
            $tr[] = paragrapheFleche("{activedirectroy_reconnection}", "Loadjs('{$page}?activedirectory-reconnect-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
            $tr[] = paragrapheFleche("{enable_emergency_mode} (Active directory)", "Loadjs('{$page}?activedirectory-emergency-enable-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
            $tr[] = paragrapheFleche("{disable_emergency_mode} (Active directory)", "Loadjs('{$page}?activedirectory-emergency-disable-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
        }
    }
    if ($gpid > 0) {
        if ($artica_meta->group_is_ad_inside($gpid)) {
            $tr[] = paragrapheFleche("{activedirectroy_reconnection}", "Loadjs('{$page}?activedirectory-reconnect-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
            $tr[] = paragrapheFleche("{enable_emergency_mode} (Active directory)", "Loadjs('{$page}?activedirectory-emergency-enable-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
            $tr[] = paragrapheFleche("{disable_emergency_mode} (Active directory)", "Loadjs('{$page}?activedirectory-emergency-disable-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
        } else {
            if ($GLOBALS["VERBOSE"]) {
                echo "<H1>AD = FALSE</H1>";
            }
        }
    }
    $tr[] = paragrapheFleche("{reboot}", "Loadjs('{$page}?reboot-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    $tr[] = paragrapheFleche("{root_password2}", "Loadjs('{$page}?root-password-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    $tr[] = paragrapheFleche("{global_admin_account}", "Loadjs('{$page}?manager-password-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    $tr[] = paragrapheFleche("{install_package}", "Loadjs('artica-meta.packages.php?uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    $tr[] = paragrapheFleche("{update_artica}", "Loadjs('artica-meta.update.artica.php?uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    $tr[] = paragrapheFleche("{directories_monitor}", "Loadjs('{$page}?philesight-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    $tr[] = paragrapheFleche("{create_a_snapshot}", "Loadjs('{$page}?snapshot-js=yes&uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    $tr[] = paragrapheFleche("{restore_a_snapshot}", "Loadjs('artica-meta.snapshots.browse.php?uuid=" . urlencode($_GET["uuid"]) . "&gpid={$_GET["gpid"]}')");
    if ($gpid == 0) {
        $tr[] = paragrapheFleche("{delete}", "Loadjs('{$page}?delete-js=yes&uuid=" . urlencode($_GET["uuid"]) . "')");
    }
    $html = "<div style='font-size:26px;margin-bottom:20px'>{$hostname} - {$tag} - {$_GET["uuid"]}</div>{$LicenseText}" . CompileTr3($tr);
    echo $tpl->_ENGINE_parse_body($html);
}