function search() { $MyPage = CurrentPageName(); $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $q = new mysql_meta(); $ArticaMetaPooling = intval($sock->GET_INFO("ArticaMetaPooling")); $ArticaMetaUseSendClient = intval($sock->GET_INFO("ArticaMetaUseSendClient")); $ArticaLinkAutoconnect = intval($sock->GET_INFO("ArticaLinkAutoconnect")); $MetaUfdbArticaVer = intval($sock->GET_INFO("MetaUfdbArticaVer")); if ($ArticaMetaPooling == 0) { $ArticaMetaPooling = 15; } $switch = intval($_GET["switch"]); $table = "metahosts"; if (isset($_POST["qtype"])) { if (preg_match("#prxy([0-9\\.]+)#", $_POST["qtype"], $re)) { $_POST["query"] = $re[1]; $_POST["qtype"] = "squidver"; } if (preg_match("#^([0-9\\.]+)#", $_POST["qtype"])) { $_POST["query"] = $_POST["qtype"]; $_POST["qtype"] = "version"; } } $searchstring = string_to_flexquery(); $page = 1; if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY `{$_POST["sortname"]}` {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } if ($searchstring != null) { $sql = "SELECT COUNT( * ) AS tcount FROM {$table} WHERE 1 {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); if (!$q->ok) { json_error_show("Mysql Error [" . __LINE__ . "]: <br>{$q->mysql_error}.<br>{$sql}", 1); } $total = $ligne["tcount"]; } else { $total = $q->COUNT_ROWS($table); } 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} "; $results = $q->QUERY_SQL($sql); if (!$q->ok) { if ($q->mysql_error != null) { json_error_show(date("H:i:s") . "<br>SORT:{$_POST["sortname"]}:<br>Mysql Error [L." . __LINE__ . "]: {$q->mysql_error}<br>{$sql}", 1); } } if (mysql_num_rows($results) == 0) { json_error_show("no data", 1); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $fontsize = "18"; if ($switch == 1) { $fontsize = 12; } $style = "<span style='font-size:{$fontsize}px'>"; $free_text = $tpl->javascript_parse_text("{free}"); $computers = $tpl->javascript_parse_text("{computers}"); $overloaded_text = $tpl->javascript_parse_text("{overloaded}"); $orders_text = $tpl->javascript_parse_text("{orders}"); $policies_text = $tpl->javascript_parse_text("{policies}"); $directories_monitor = $tpl->javascript_parse_text("{directories_monitor}"); $proxy_statistics = $tpl->javascript_parse_text("{SQUID_STATS1}"); $cache_rate = $tpl->javascript_parse_text("{cache_rate}"); $clone_of_text = $tpl->javascript_parse_text("{clone_of}"); $proxy_in_emergency_mode = $tpl->javascript_parse_text("{proxy_in_emergency_mode}"); $webfiltering = $tpl->javascript_parse_text("{webfiltering}"); $activedirectory_emergency_mode = $tpl->javascript_parse_text("{activedirectory_emergency_mode}"); $NeCommuniquePlus_text = "<br><span style='font-size:14px;font-weight:bold;color:d32d2d'>" . $tpl->_ENGINE_parse_body("{did_not_talk_with_meta}") . "</span>"; $memory_exceed_80 = $tpl->javascript_parse_text("{memory_exceed_80}"); $memory_exceed_90 = $tpl->javascript_parse_text("{memory_exceed_90}"); while ($ligne = mysql_fetch_assoc($results)) { $LOGSWHY = array(); $overloaded = null; $cloneFrom = $ligne["cloneFrom"]; $loadcolor = "black"; $StatHourColor = "black"; $uuid = $ligne["uuid"]; $hostname = $ligne["hostname"]; $public_ip = $ligne["public_ip"]; $updated = $ligne["updated"]; $version = $ligne["version"]; $ColorTime = "black"; $CPU_NUMBER = $ligne["CPU_NUMBER"]; $CPU_NUMBER_MAX = $ligne["CPU_NUMBER"] + 1.5; $load = $ligne["load"]; $mem_perc = $ligne["mem_perc"]; $mem_total = FormatBytes($ligne["mem_total"]); $proxyversion = null; $CountdeComputers_text = null; $policies_text_line = null; $CountdeComputers = $q->network_hosts_count($uuid); $icon_warning_32 = "warning32.png"; $icon_red_32 = "32-red.png"; $icon = "ok-32.png"; $icon_panneau_32 = "warning-panneau-32.png"; $BANDWIDTH = $ligne["BANDWIDTH"]; $TaskPercent = intval($ligne["TaskPercent"]); $BANDWIDTH_text = null; $hostag_switch = null; $uuidenc = urlencode($uuid); $PING_URI_SWITCH = null; $PROXY_PERFS = null; $END_PROXY = null; $PROXY_LINE = null; $PROXYEMERG = $ligne["PROXYEMERG"]; $webfiltering_version = null; $UFDBARTICA = intval($ligne["UFDBARTICA"]); $UFDB_ENABLED = intval($ligne["UFDB_ENABLED"]); $WINDOWSAD = intval($ligne["WINDOWSAD"]); $ADEMERG = intval($ligne["ADEMERG"]); $PROXYEMERG_ICON = 0; $link_ip = null; $secondincon = null; $NeCommuniquePlus = null; $MemoryColor = null; $Loadbr = "<br>"; $StyleLoad = "font-size:30px;font-weight:bold"; if (preg_match("#^([0-9\\.]+)-#", $ligne["squidver"], $rz)) { $ligne["squidver"] = $rz[1]; } if ($ArticaMetaUseSendClient == 1) { $PING_URI = " <a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:Loadjs('artica-meta.menus.php?send-ping-js=yes&uuid={$uuidenc}&gpid=0');\"\n\t\t\tstyle='font-size:12px;text-decoration:underline;color:#0021C6'\n\t\t\t>Ping</a>"; } if ($UFDB_ENABLED == 1) { if ($UFDBARTICA > 0) { $UFDBARTICAT = date("Y-m-d H:i:s", $UFDBARTICA); $webfiltering_version = "<br>{$webfiltering} {$UFDBARTICAT}"; } } if ($BANDWIDTH > 0) { $BANDWIDTH_text = " (" . FormatBytes($BANDWIDTH / 1024) . ")"; } if ($switch == 1) { $icon_warning_32 = "22-warn.png"; $icon_red_32 = "22-red.png"; $icon = "ok22.png"; $icon_panneau_32 = "warning-panneau-24.png"; $StyleLoad = "font-size:14px;"; $Loadbr = null; } if ($load > $CPU_NUMBER_MAX) { $overloaded = "<br><strong style='color:#d32d2d'>{$overloaded_text}</strong>"; $icon = $icon_warning_32; $loadcolor = "#d32d2d"; $LOGSWHY[] = "{$overloaded_text} {$load}>{$CPU_NUMBER_MAX}"; } $xtime = strtotime($updated); $diff = time_diff_min($xtime); $Difftext = distanceOfTimeInWords($xtime, time(), true); if ($diff > $ArticaMetaPooling * 1.5) { $icon = $icon_warning_32; $ColorTime = "#d32d2d"; $LOGSWHY[] = $Difftext . "/{$ArticaMetaPooling}Mn"; $loadcolor = $ColorTime; } if ($diff > $ArticaMetaPooling * 4) { $icon = $icon_red_32; $ColorTime = "#d32d2d"; $LOGSWHY[] = $Difftext . "/{$ArticaMetaPooling}Mn"; $NeCommuniquePlus = $NeCommuniquePlus_text; } if ($PROXYEMERG == 1) { $icon = $icon_panneau_32; $ColorTime = "#d32d2d"; $loadcolor = $ColorTime; $LOGSWHY[] = "<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:Loadjs('artica-meta.urgency.php?uuid={$uuid}');\" style='color:{$ColorTime};text-decoration:underline'>{$proxy_in_emergency_mode}</a>"; } if ($WINDOWSAD == 1) { $secondincon = "windows-server-32.png"; if ($ADEMERG == 1) { $icon = $icon_warning_32; $ColorTime = "#d32d2d"; $secondincon = "windows-server-32-red.png"; $LOGSWHY[] = $activedirectory_emergency_mode; $loadcolor = $ColorTime; } } if ($MetaUfdbArticaVer > 0) { if ($UFDB_ENABLED == 1) { if ($UFDBARTICA < $MetaUfdbArticaVer) { $LOGSWHY[] = "{$webfiltering} < " . date("Y-m-d H:i:s", $MetaUfdbArticaVer); } } } if ($mem_perc > 80) { $MemoryColor = "#f59c44"; $icon = $icon_panneau_32; $LOGSWHY[] = "<span style='color:{$MemoryColor}'>{$memory_exceed_80}</span>"; } if ($mem_perc > 90) { $icon = $icon_red_32; $MemoryColor = "#d32d2d"; $icon = $icon_panneau_32; $LOGSWHY[] = "{$memory_exceed_90}"; } $disks = unserialize($ligne["disks"]); $SIZE = 0; $USED = 0; $infodisk = null; $DISKS_TEXT = array(); $squid_db = "squid_{$uuid}"; if ($q->DATABASE_EXISTS($squid_db)) { $DISKS_TEXT[] = "<ul><li><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.hosts.squid.stats.php?uuid={$uuid}')\"\n\t\t\tstyle='font-size:14px;font-weight:bold;text-decoration:underline'>{$proxy_statistics}</a></li>"; } if ($q->philesight_count($uuid) > 0) { if (count($DISKS_TEXT) == 0) { $DISKS_TEXT[] = "<ul>"; } $DISKS_TEXT[] = "<li><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.hosts.philesight.php?uuid={$uuid}')\"\n\t\t\tstyle='font-size:14px;font-weight:bold;text-decoration:underline'>{$directories_monitor}</a></li>"; } if (count($DISKS_TEXT) > 0) { $DISKS_TEXT[] = "</ul>"; } // -------------------------------------------- DISKS INFOS if (is_array($disks)) { if (count($disks) > 0) { $DISKS_TEXT[] = "<ul>"; while (@(list($disks, $mainarray) = each($disks))) { $SIZE = FormatBytes(intval($mainarray["SIZE"]) / 1024); $DISKS_TEXT[] = "<li style='font-weight:bold;font-size:14px'>{$disks} {$SIZE}</li>"; $DISKS_TEXT[] = "<ul>"; while (list($part, $partArray) = each($mainarray["PARTS"])) { $color_disk = "black"; $POURC = $partArray["POURC"]; if ($POURC > 95) { $color_disk = "red"; $icon = $icon_red_32; $LOGSWHY[] = "{$part} {used}:{$POURC}%"; } $TOT = FormatBytes($partArray["TOT"] / 1024); $AIV = FormatBytes($partArray["AIV"] / 1024); $DISKS_TEXT[] = "<li style='color:{$color_disk}'>{$part} {$TOT} - {used}:{$POURC}% {free}: {$AIV}</li>"; } $DISKS_TEXT[] = "</ul>"; } $DISKS_TEXT[] = "</ul>"; $infodisk = $tpl->_ENGINE_parse_body(@implode("", $DISKS_TEXT)); } } // -------------------------------------------- -------------------------------------------------------------------- if ($switch == 1) { $infodisk = null; } $info = $tpl->_ENGINE_parse_body("<br>{last_status}: <span style='color:{$ColorTime}'>{$Difftext}</span><br><span style='font-size:12px'>{$CPU_NUMBER} CPU(s), {memory}:{$mem_total}{$overloaded}</span>"); $cell = array(); $linkver = "<a href=\"javascript:Loadjs('artica-meta.update.artica.php?uuid={$uuid}');\" \n\t\tstyle='text-decoration:underline'>"; if ($q->isOrder($uuid, "UPDATE_ARTICA")) { $version = "<center style='margin:10px'><img src='img/preloader.gif'></center>"; } if ($ligne["PROXY"] == 1) { $proxyuri = "<br><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.squid.watchdog-events.php?js=yes&uuid={$uuid}');\"\n\t\tstyle='text-decoration:underline'>"; $proxyversion = "<br><span style='font-size:12px'>{$proxyuri}Proxy: {$ligne["squidver"]}</a>{$webfiltering_version} {$BANDWIDTH_text}</span>"; $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM squid_perfs_gb WHERE uuid='{$uuid}'")); $client_http_hits = $ligne2["client_http_hits"]; $client_http_requests = round($ligne2["client_http_requests"], 2); $client_http_kbytes_out = round($ligne2["client_http_kbytes_out"]); $TOTALS_NOT_CACHED = $ligne2["TOTALS_NOT_CACHED"]; $TOTALS_CACHED = $ligne2["TOTALS_CACHED"]; $TOTALS_CACHED_AVG = round($ligne2["TOTALS_CACHED_AVG"], 2); $END_PROXY = "</span><br>"; if ($ligne2["uuid"] != null) { $PROXY_PERFS = "<br><span style='font-size:12px'>{$client_http_requests}Req/s, {$client_http_kbytes_out}KB/s\n\t\t\t\t<br>{$cache_rate}: {$TOTALS_CACHED_AVG}%"; $PROXY_LINE = "<span style='font-size:12px'>{$client_http_requests}Req/s | {$client_http_kbytes_out}KB/s | {$cache_rate}: {$TOTALS_CACHED_AVG}%</span>"; } } if ($CountdeComputers > 0) { $CountdeComputers = FormatNumber($CountdeComputers); $CountdeComputers_uri = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.networks.hosts.php?js=yes&uuid={$uuid}');\"\n\t\t\tstyle='text-decoration:underline'>"; $CountdeComputers_text = "<br><span style='font-size:12px'>{$CountdeComputers_uri}{$computers}: <strong>{$CountdeComputers}</strong></a></span>"; } $OrdersText = null; $ligneOrders = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(orderid) as tcount FROM `metaorders` WHERE `uuid`='{$uuid}'")); $OrdersCount = $ligneOrders["tcount"]; if ($OrdersCount > 0) { $OrdersText = "<br><a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:Loadjs('artica-meta.hosts.orders.php?uuid={$uuid}');\">\n\t\t\t<strong style='text-decoration:underline;color:#E48407'>{$orders_text}:{$OrdersCount} ({$TaskPercent}%)</strong>"; } $ligneOrders = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(uuid) as tcount FROM `policies_storage` WHERE `uuid`='{$uuid}'")); $OrdersCount = $ligneOrders["tcount"]; if ($OrdersCount > 0) { $policies_text_line = "<br><strong style='text-decoration:underline;color:#E48407'>{$policies_text}:{$OrdersCount}</strong>"; } $events = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.events.php?js=yes&uuid={$uuid}');\"\n\t\tstyle='float:right'><img src='css/images-flexigrid/magnifier.png'></a>"; $cpus = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.cpustats.php?js=yes&uuid={$uuid}');\"\n\t\tstyle='text-decoration:underline'>"; $hostsCommands = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.menus.php?js=yes&uuid={$uuid}');\"\n\t\tstyle='text-decoration:underline'>"; $hostag = utf8_encode($ligne["hostag"]); if ($hostag != null) { $hostag = "<br><i style='font-size:12px'>{$hostag}</i>"; } if ($cloneFrom != null) { $cloneFrom = "<br><i style='font-weight:bold;font-size:12px'>{$clone_of_text}: " . $q->uuid_to_host($cloneFrom) . "</i>"; } if ($secondincon != null) { $secondincon = "<br><img src='img/{$secondincon}' style='margin-top:10px'>"; } $LicenseJs = "OnClick=\"javascript:Loadjs('artica-meta.host.license.php?uuid={$uuid}')\""; $LicenseInfos = $q->LicenseInfos($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 = "<br><a href=\"javascript:blur();\" {$LicenseJs} style='font-size:12px;text-decoration:underline'>" . $tpl->_ENGINE_parse_body($LICT) . "</a>"; if ($switch == 1) { $info = null; $secondincon = null; $hostag = null; $cloneFrom = null; $proxyversion = null; $CountdeComputers_text = null; $events = null; $hostag_switch = utf8_encode($ligne["hostag"]); $PING_URI_SWITCH = $PING_URI; $PING_URI = null; $PROXY_PERFS = null; $END_PROXY = null; $LicenseText = null; if (count($LOGSWHY) > 0) { $infodisk = $tpl->_ENGINE_parse_body("<span style='color:#d32d2d;font-size:14px'>" . @implode("<br>", $LOGSWHY) . "</span>"); } } else { $GroupsList = GetGroups($uuid); $PROXY_LINE = null; if (count($LOGSWHY) > 0) { $infodisk = $tpl->_ENGINE_parse_body("<span style='color:#d32d2d;font-size:14px'>" . @implode("<br>", $LOGSWHY) . "</span>") . "<hr>" . $infodisk; } } $cell = array(); if ($ArticaMetaUseSendClient == 1) { $uriAdd = null; if ($ArticaLinkAutoconnect == 1) { if ($ligne["system_adm"] != null) { $uriAdd = "/logon.php?autologmeta=" . md5($ligne["system_adm"] . $ligne["system_password"]); } } $link_ip = "<a href=\"https://{$public_ip}:9000{$uriAdd}\" style='text-decoration:underline;color:{$loadcolor}' target=_new>"; } if ($MemoryColor == null) { $MemoryColor = $loadcolor; } $cell[] = "{$Loadbr}<center><img src=\"img/{$icon}\">{$secondincon}</center>"; $cell[] = "{$style}{$hostsCommands}{$hostname}{$hostag}</a>{$LicenseText}{$NeCommuniquePlus}{$cloneFrom}{$PING_URI_SWITCH}{$events} </span>{$info}\n\t\t{$proxyversion}{$PROXY_PERFS}{$END_PROXY}\n\t\t{$CountdeComputers_text}{$OrdersText}{$policies_text_line}"; $cell[] = "<span style='color:{$loadcolor};{$StyleLoad}'>{$Loadbr}{$load}</span></span>"; $cell[] = "{$style}{$cpus}<span style='{$StyleLoad};color:{$MemoryColor}'>{$Loadbr}{$mem_perc}%</a></span>"; $cell[] = $hostag_switch . " " . $infodisk . $PROXY_LINE; $cell[] = "{$style}<span style='color:{$loadcolor} !important'>{$link_ip}{$public_ip}</span></a>{$PING_URI}</span>{$GroupsList}"; $cell[] = "{$style}{$ligne["squidver"]}</span>"; $cell[] = "{$style}{$linkver}{$version}</a></span>"; $data['rows'][] = array('id' => $ligne['uuid'], 'cell' => $cell); } echo json_encode($data); }
function search() { $MyPage = CurrentPageName(); $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $q = new mysql_meta(); $ArticaMetaPooling = intval($sock->GET_INFO("ArticaMetaPooling")); $ArticaMetaUseSendClient = intval($sock->GET_INFO("ArticaMetaUseSendClient")); if ($ArticaMetaPooling == 0) { $ArticaMetaPooling = 15; } $switch = intval($_GET["switch"]); $table = "metahosts"; $searchstring = string_to_flexquery(); $page = 1; if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY `{$_POST["sortname"]}` {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } if ($searchstring != null) { $sql = "SELECT COUNT( * ) AS tcount FROM {$table} WHERE 1 {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); if (!$q->ok) { json_error_show("Mysql Error [" . __LINE__ . "]: <br>{$q->mysql_error}.<br>{$sql}", 1); } $total = $ligne["tcount"]; } else { $total = $q->COUNT_ROWS($table); } 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} "; $results = $q->QUERY_SQL($sql); if (!$q->ok) { if ($q->mysql_error != null) { json_error_show(date("H:i:s") . "<br>SORT:{$_POST["sortname"]}:<br>Mysql Error [L." . __LINE__ . "]: {$q->mysql_error}<br>{$sql}", 1); } } if (mysql_num_rows($results) == 0) { json_error_show("no data", 1); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $fontsize = "18"; if ($switch == 1) { $fontsize = 12; } $style = "<span style='font-size:{$fontsize}px'>"; $free_text = $tpl->javascript_parse_text("{free}"); $computers = $tpl->javascript_parse_text("{computers}"); $overloaded_text = $tpl->javascript_parse_text("{overloaded}"); $orders_text = $tpl->javascript_parse_text("{orders}"); $policies_text = $tpl->javascript_parse_text("{policies}"); $directories_monitor = $tpl->javascript_parse_text("{directories_monitor}"); while ($ligne = mysql_fetch_assoc($results)) { $LOGSWHY = array(); $overloaded = null; $loadcolor = "black"; $StatHourColor = "black"; $uuid = $ligne["uuid"]; $hostname = $ligne["hostname"]; $public_ip = $ligne["public_ip"]; $updated = $ligne["updated"]; $version = $ligne["version"]; $ColorTime = "black"; $CPU_NUMBER = $ligne["CPU_NUMBER"]; $CPU_NUMBER_MAX = $ligne["CPU_NUMBER"] + 1.5; $load = $ligne["load"]; $mem_perc = $ligne["mem_perc"]; $mem_total = FormatBytes($ligne["mem_total"]); $proxyversion = null; $CountdeComputers_text = null; $policies_text_line = null; $CountdeComputers = $q->network_hosts_count($uuid); $icon_warning_32 = "warning32.png"; $icon_red_32 = "32-red.png"; $icon = "ok-32.png"; $BANDWIDTH = $ligne["BANDWIDTH"]; $BANDWIDTH_text = null; $hostag_switch = null; $uuidenc = urlencode($uuid); $PING_URI_SWITCH = null; if ($ArticaMetaUseSendClient == 1) { $PING_URI = " <a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:Loadjs('artica-meta.menus.php?send-ping-js=yes&uuid={$uuidenc}&gpid=0');\"\n\t\t\tstyle='font-size:12px;text-decoration:underline;color:#0021C6'\n\t\t\t>Ping</a>"; } if ($BANDWIDTH > 0) { $BANDWIDTH_text = " (" . FormatBytes($BANDWIDTH / 1024) . ")"; } if ($switch == 1) { $icon_warning_32 = "22-warn.png"; $icon_red_32 = "22-red.png"; $icon = "ok22.png"; } if ($load > $CPU_NUMBER_MAX) { $overloaded = "<br><strong style='color:red'>{$overloaded_text}</strong>"; $icon = $icon_warning_32; $loadcolor = "#CC0000"; $LOGSWHY[] = "{$overloaded_text} {$load}>{$CPU_NUMBER_MAX}"; } $xtime = strtotime($updated); $diff = time_diff_min($xtime); $Difftext = distanceOfTimeInWords($xtime, time(), true); if ($diff > $ArticaMetaPooling) { $icon = $icon_warning_32; $ColorTime = "#CC0000"; $LOGSWHY[] = $Difftext . "/{$ArticaMetaPooling}Mn"; } if ($diff > $ArticaMetaPooling * 4) { $icon = $icon_red_32; $ColorTime = "#CC0000"; $LOGSWHY[] = $Difftext . "/{$ArticaMetaPooling}Mn"; } $disks = unserialize($ligne["disks"]); $SIZE = 0; $USED = 0; $infodisk = null; $DISKS_TEXT = array(); if ($q->philesight_count($uuid) > 0) { $DISKS_TEXT[] = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.hosts.philesight.php?uuid={$uuid}')\"\n\t\t\tstyle='font-size:14px;font-weight:bold;text-decoration:underline'>{$directories_monitor}</a><hr style='margin-bottom:15px;border:0px;'>"; } if (is_array($disks)) { $DISKS_TEXT[] = "<ul>"; while (list($disks, $mainarray) = each($disks)) { $SIZE = FormatBytes(intval($mainarray["SIZE"]) / 1024); $DISKS_TEXT[] = "<li style='font-weight:bold;font-size:14px'>{$disks} {$SIZE}</li>"; $DISKS_TEXT[] = "<ul>"; while (list($part, $partArray) = each($mainarray["PARTS"])) { $color_disk = "black"; $POURC = $partArray["POURC"]; if ($POURC > 95) { $color_disk = "red"; $icon = $icon_red_32; $LOGSWHY[] = "{$part} {used}:{$POURC}%"; } $TOT = FormatBytes($partArray["TOT"] / 1024); $AIV = FormatBytes($partArray["AIV"] / 1024); $DISKS_TEXT[] = "<li style='color:{$color_disk}'>{$part} {$TOT} - {used}:{$POURC}% {free}: {$AIV}</li>"; } $DISKS_TEXT[] = "</ul>"; } $DISKS_TEXT[] = "</ul>"; $infodisk = $tpl->_ENGINE_parse_body(@implode("", $DISKS_TEXT)); } if ($switch == 1) { $infodisk = null; } $info = $tpl->_ENGINE_parse_body("<br>{last_status}: <span style='color:{$ColorTime}'>{$Difftext}</span><br><span style='font-size:12px'>{$CPU_NUMBER} CPU(s), {memory}:{$mem_total}{$overloaded}</span>"); $cell = array(); $linkver = "<a href=\"javascript:Loadjs('artica-meta.update.artica.php?uuid={$uuid}');\" \n\t\tstyle='text-decoration:underline'>"; if ($q->isOrder($uuid, "UPDATE_ARTICA")) { $version = "<center style='margin:10px'><img src='img/preloader.gif'></center>"; } if ($ligne["PROXY"] == 1) { $proxyuri = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.squid.watchdog-events.php?js=yes&uuid={$uuid}');\"\n\t\tstyle='text-decoration:underline'>"; $proxyversion = "<br><span style='font-size:12px'>{$proxyuri}Proxy: {$ligne["squidver"]}</a> {$BANDWIDTH_text}</span>"; } if ($CountdeComputers > 0) { $CountdeComputers = FormatNumber($CountdeComputers); $CountdeComputers_uri = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.networks.hosts.php?js=yes&uuid={$uuid}');\"\n\t\t\tstyle='text-decoration:underline'>"; $CountdeComputers_text = "<br><span style='font-size:12px'>{$CountdeComputers_uri}{$computers}: <strong>{$CountdeComputers}</strong></a></span>"; } $OrdersText = null; $ligneOrders = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(orderid) as tcount FROM `metaorders` WHERE `uuid`='{$uuid}'")); $OrdersCount = $ligneOrders["tcount"]; if ($OrdersCount > 0) { $OrdersText = "<br><a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:Loadjs('artica-meta.hosts.orders.php?uuid={$uuid}');\">\n\t\t\t<strong style='text-decoration:underline;color:#E48407'>{$orders_text}:{$OrdersCount}</strong>"; } $ligneOrders = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(uuid) as tcount FROM `policies_storage` WHERE `uuid`='{$uuid}'")); $OrdersCount = $ligneOrders["tcount"]; if ($OrdersCount > 0) { $policies_text_line = "<br><strong style='text-decoration:underline;color:#E48407'>{$policies_text}:{$OrdersCount}</strong>"; } $events = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.events.php?js=yes&uuid={$uuid}');\"\n\t\tstyle='float:right'><img src='css/images-flexigrid/magnifier.png'></a>"; $cpus = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.cpustats.php?js=yes&uuid={$uuid}');\"\n\t\tstyle='text-decoration:underline'>"; $hostsCommands = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.menus.php?js=yes&uuid={$uuid}');\"\n\t\tstyle='text-decoration:underline'>"; $hostag = utf8_encode($ligne["hostag"]); if ($hostag != null) { $hostag = "<br><i style='font-size:12px'>{$hostag}</i>"; } if ($switch == 1) { $info = null; $hostag = null; $proxyversion = null; $CountdeComputers_text = null; $events = null; $hostag_switch = utf8_encode($ligne["hostag"]); $PING_URI_SWITCH = $PING_URI; $PING_URI = null; if (count($LOGSWHY) > 0) { $infodisk = $tpl->_ENGINE_parse_body("<span style='color:red;font-size:12px'>" . @implode(", ", $LOGSWHY) . "</span>"); } } $cell = array(); $link_ip = "<a href=\"https://{$public_ip}:9000\" style='text-decoration:underline' target=_new>"; $cell[] = "<img src=\"img/{$icon}\">"; $cell[] = "{$style}{$hostsCommands}{$hostname}{$hostag}</a>{$PING_URI_SWITCH}{$events} </span>{$info}{$proxyversion}{$CountdeComputers_text}{$OrdersText}{$policies_text_line}"; $cell[] = "{$style}<span style='color:{$loadcolor}'>{$load}</span></span>"; $cell[] = "{$style}{$cpus}{$mem_perc}%</a></span>"; $cell[] = $hostag_switch . " " . $infodisk; $cell[] = "{$style}{$link_ip}{$public_ip}</a>{$PING_URI}</span>"; $cell[] = "{$style}{$linkver}{$version}</a></span>"; $data['rows'][] = array('id' => $ligne['uuid'], 'cell' => $cell); } echo json_encode($data); }