1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791
|
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2024 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
/* html_start_box - draws the start of an HTML box with an optional title
@arg $title - the title of this box ("" for no title)
@arg $width - the width of the box in pixels or percent
@arg $div - end with a starting div
@arg $cell_padding - the amount of cell padding to use inside of the box
@arg $align - the HTML alignment to use for the box (center, left, or right)
@arg $add_text - the url to use when the user clicks 'Add' in the upper-right
corner of the box ("" for no 'Add' link)
This function has two method. This first is for legacy behavior where you
you pass in a href to the function, and an optional label as $add_label
The new format accepts an array of hrefs to add to the start box. The format
of the array is as follows:
$add_text = array(
array(
'id' => 'uniqueid',
'href' => 'value',
'title' => 'title',
'callback' => true|false,
'class' => 'fa fa-icon'
),
...
);
If the callback is true, the Cacti attribute will be added to the href
to present only the contents and not to include both the headers. If
the link must go off page, simply make sure $callback is false. There
is a requirement to use fontawesome icon sets for this class, but it
can include other classes. In addition, the href can be a hash '#' if
your page has a ready function that has it's own javascript.
@arg $add_label - used with legacy behavior to add specific text to the link.
This parameter is only used in the legacy behavior.
*/
function html_start_box($title, $width, $div, $cell_padding, $align, $add_text, $add_label = false) {
global $config;
static $table_suffix = 1;
static $help_count = 0;
static $mode_count = 0;
static $beta_count = 0;
if ($add_label === false) {
$add_label = __('Add');
}
if (defined('CACTI_VERSION_BETA') && $title != '' && $beta_count == 0) {
$title .= ' [ ' . get_cacti_version_text(false) . ' ]';
$beta_count++;
}
if ($config['poller_id'] > 1 && $title != '' && $mode_count == 0) {
$title .= ' [ ' . __('Remote Server') . ': ';
if ($config['connection'] == 'offline') {
$title .= '<span class="deviceDown">' . __('Offline') . '</span>';
} elseif ($config['connection'] == 'recovery') {
$title .= '<span class="deviceRecovering">' . __('Recovering') . '</span>';
} else {
$title .= __('Online');
}
$title .= ' ]';
$mode_count++;
}
$table_prefix = basename(get_current_page(), '.php');;
if (!isempty_request_var('action')) {
$table_prefix .= '_' . clean_up_name(get_nfilter_request_var('action'));
} elseif (!isempty_request_var('report')) {
$table_prefix .= '_' . clean_up_name(get_nfilter_request_var('report'));
} elseif (!isempty_request_var('tab')) {
$table_prefix .= '_' . clean_up_name(get_nfilter_request_var('tab'));
}
$table_id = $table_prefix . $table_suffix;
if ($title != '') {
print "<div id='$table_id' class='cactiTable' style='width:$width;text-align:$align;'>";
print '<div>';
print "<div class='cactiTableTitle'><span>" . ($title != '' ? $title:'') . '</span></div>';
print "<div class='cactiTableButton'>";
$page = get_current_page();
$help_file = html_help_page($page);
if ($help_file === false) {
if (isset_request_var('tab')) {
$tpage = $page . ':' . get_nfilter_request_var('tab');
$help_file = html_help_page($tpage);
}
}
if ($help_file === false) {
if (isset_request_var('action')) {
$tpage = $page . ':' . get_nfilter_request_var('action');
$help_file = html_help_page($tpage);
}
}
if ($help_file !== false && $help_count == 0 && is_realm_allowed(28)) {
print "<span class='cactiHelp' title='" . __esc('Get Page Help') . "'><a class='linkOverDark helpPage' data-page='" . html_escape(basename($help_file)) . "' href='#'><i class='far fa-question-circle'></i></a></span>";
$help_count++;
}
if ($add_text != '' && !is_array($add_text)) {
print "<span class='cactiFilterAdd' title='$add_label'><a class='linkOverDark' href='" . html_escape($add_text) . "'><i class='fa fa-plus'></i></a></span>";
} else {
if (is_array($add_text)) {
if (cacti_sizeof($add_text)) {
foreach($add_text as $icon) {
if (isset($icon['callback']) && $icon['callback'] === true) {
$classo = 'linkOverDark';
} else {
$classo = '';
}
if (isset($icon['class']) && $icon['class'] !== '') {
$classi = $icon['class'];
} else {
$classi = 'fa fa-plus';
}
if (isset($icon['href'])) {
$href = html_escape($icon['href']);
} else {
$href = '#';
}
if (isset($icon['title'])) {
$title = $icon['title'];
} else {
$title = $add_label;
}
print "<span class='cactiFilterAdd' title='$title'><a" . (isset($icon['id']) ? " id='" . $icon['id'] . "'":'') . " class='$classo' href='$href'><i class='$classi'></i></a></span>";
}
}
} else {
print '<span> </span>';
}
}
print '</div></div>';
if ($div === true) {
print "<div id='$table_id" . "_child' class='cactiTable'>";
} else {
print "<table id='$table_id" . "_child' class='cactiTable' style='padding:" . $cell_padding . "px;'>";
}
} else {
print "<div id='$table_id' class='cactiTable' style='width:$width;text-align:$align;'>";
if ($div === true) {
print "<div id='$table_id" . "_child' class='cactiTable'>";
} else {
print "<table id='$table_id" . "_child' class='cactiTable' style='padding:" . $cell_padding . "px;'>";
}
}
$table_suffix++;
}
/* html_end_box - draws the end of an HTML box
@arg $trailing_br (bool) - whether to draw a trailing <br> tag after ending
@arg $div (bool) - whether type of box is div or table */
function html_end_box($trailing_br = true, $div = false) {
if ($div) {
print '</div></div>';
} else {
print '</table></div>';
}
if ($trailing_br == true) {
print "<div class='break'></div>";
}
}
/* html_graph_template_multiselect - consistent multiselect javascript library for cacti. */
function html_graph_template_multiselect() {
?>
var msWidth = 200;
$('#graph_template_id').hide().multiselect({
menuHeight: $(window).height()*.7,
menuWidth: 'auto',
linkInfo: faIcons,
buttonWidth: 'auto',
noneSelectedText: '<?php print __('All Graphs & Templates');?>',
selectedText: function(numChecked, numTotal, checkedItems) {
myReturn = numChecked + ' <?php print __('Templates Selected');?>';
$.each(checkedItems, function(index, value) {
if (value.value == '-1') {
myReturn='<?php print __('All Graphs & Templates');?>';
return false;
} else if (value.value == '0') {
myReturn='<?php print __('Not Templated');?>';
return false;
}
});
return myReturn;
},
checkAllText: '<?php print __('All');?>',
uncheckAllText: '<?php print __('None');?>',
uncheckAll: function() {
$(this).multiselect('widget').find(':checkbox:first').each(function() {
$(this).prop('checked', true);
});
},
close: function(event, ui) {
applyGraphFilter();
},
open: function(event, ui) {
$("input[type='search']:first").focus();
},
click: function(event, ui) {
checked=$(this).multiselect('widget').find('input:checked').length;
if (ui.value == -1 || ui.value == 0) {
if (ui.checked == true) {
$('#graph_template_id').multiselect('uncheckAll');
if (ui.value == -1) {
$(this).multiselect('widget').find(':checkbox:first').prop('checked', true);
} else {
$(this).multiselect('widget').find(':checkbox[value="0"]').prop('checked', true);
}
}
} else if (checked == 0) {
$(this).multiselect('widget').find(':checkbox:first').each(function() {
$(this).click();
});
} else if ($(this).multiselect('widget').find('input:checked:first').val() == '-1') {
if (checked > 0) {
$(this).multiselect('widget').find(':checkbox:first').each(function() {
$(this).click();
$(this).prop('disable', true);
});
}
} else {
$(this).multiselect('widget').find(':checkbox[value="0"]').prop('checked', false);
}
}
}).multiselectfilter({
label: '<?php print __('Search');?>',
placeholder: '<?php print __('Enter keyword');?>',
width: msWidth
});
<?php
}
/* html_graph_area - draws an area the contains full sized graphs
@arg $graph_array - the array to contains graph information. for each graph in the
array, the following two keys must exist
$arr[0]["local_graph_id"] // graph id
$arr[0]["title_cache"] // graph title
@arg $no_graphs_message - display this message if no graphs are found in $graph_array
@arg $extra_url_args - extra arguments to append to the url
@arg $header - html to use as a header
@arg $columns - the number of columns to present
@arg $tree_id - the tree id if this is a tree thumbnail
@arg $branch_id - the branch id if this is a tree thumbnail
*/
function html_graph_area(&$graph_array, $no_graphs_message = '', $extra_url_args = '', $header = '', $columns = 0, $tree_id = 0, $branch_id = 0) {
global $config;
$i = 0; $k = 0; $j = 0;
$num_graphs = cacti_sizeof($graph_array);
if ($columns == 0) {
$columns = read_user_setting('num_columns');
}
?>
<script type='text/javascript'>
var refreshMSeconds = <?php print read_user_setting('page_refresh')*1000;?>;
var graph_start = <?php print get_current_graph_start();?>;
var graph_end = <?php print get_current_graph_end();?>;
</script>
<?php
if ($num_graphs > 0) {
if ($header != '') {
print $header;
}
foreach ($graph_array as $graph) {
if (!isset($graph['host_id'])) {
list($graph['host_id'], $graph['disabled']) = db_fetch_row_prepared('SELECT host_id, disabled
FROM graph_local AS gl
LEFT JOIN host AS h
ON gl.host_id = h.id
WHERE gl.id = ?',
array($graph['local_graph_id']));
}
if ($i == 0) {
print "<tr class='tableRowGraph'>";
}
?>
<td class='graphWrapperOuter' data-disabled='<?php print ($graph['disabled'] == 'on' ? 'true':'false');?>' style='width:<?php print round(100 / $columns, 2);?>%;'>
<div>
<table style='text-align:center;margin:auto;'>
<tr>
<td>
<div class='graphWrapper' style='width:100%;' id='wrapper_<?php print $graph['local_graph_id']?>' graph_width='<?php print $graph['width'];?>' graph_height='<?php print $graph['height'];?>' title_font_size='<?php print ((read_user_setting('custom_fonts') == 'on') ? read_user_setting('title_size') : read_config_option('title_size'));?>'></div>
<?php print (read_user_setting('show_graph_title') == 'on' ? "<span class='center'>" . html_escape($graph['title_cache']) . '</span>' : '');?>
</td>
<?php if (is_realm_allowed(27)) { ?><td id='dd<?php print $graph['local_graph_id'];?>' class='noprint graphDrillDown'>
<?php graph_drilldown_icons($graph['local_graph_id'], 'graph_buttons', $tree_id, $branch_id);?>
</td><?php } ?>
</tr>
</table>
<div>
</td>
<?php
$i++;
if (($i % $columns) == 0) {
$i = 0;
print '</tr>';
}
}
while(($i % $columns) != 0) {
print "<td style='text-align:center;width:" . round(100 / $columns, 2) . "%;'></td>";
$i++;
}
print '</tr>';
} else {
if ($no_graphs_message != '') {
print "<td><em>$no_graphs_message</em></td>";
}
}
}
/* html_graph_thumbnail_area - draws an area the contains thumbnail sized graphs
@arg $graph_array - the array to contains graph information. for each graph in the
array, the following two keys must exist
$arr[0]["local_graph_id"] // graph id
$arr[0]["title_cache"] // graph title
@arg $no_graphs_message - display this message if no graphs are found in $graph_array
@arg $extra_url_args - extra arguments to append to the url
@arg $header - html to use as a header
@arg $columns - the number of columns to present
@arg $tree_id - the tree id if this is a tree thumbnail
@arg $branch_id - the branch id if this is a tree thumbnail
*/
function html_graph_thumbnail_area(&$graph_array, $no_graphs_message = '', $extra_url_args = '', $header = '', $columns = 0, $tree_id = 0, $branch_id = 0) {
global $config;
$i = 0; $k = 0; $j = 0;
$num_graphs = cacti_sizeof($graph_array);
if ($columns == 0) {
$columns = read_user_setting('num_columns');
}
?>
<script type='text/javascript'>
var refreshMSeconds = <?php print read_user_setting('page_refresh')*1000;?>;
var graph_start = <?php print get_current_graph_start();?>;
var graph_end = <?php print get_current_graph_end();?>;
</script>
<?php
if ($num_graphs > 0) {
if ($header != '') {
print $header;
}
$start = true;
foreach ($graph_array as $graph) {
if (!isset($graph['host_id'])) {
list($graph['host_id'], $graph['disabled']) = db_fetch_row_prepared('SELECT host_id, disabled
FROM graph_local AS gl
LEFT JOIN host AS h
ON gl.host_id = h.id
WHERE gl.id = ?',
array($graph['local_graph_id']));
}
if (isset($graph['graph_template_name'])) {
if (isset($prev_graph_template_name)) {
if ($prev_graph_template_name != $graph['graph_template_name']) {
$prev_graph_template_name = $graph['graph_template_name'];
}
} else {
$prev_graph_template_name = $graph['graph_template_name'];
}
} elseif (isset($graph['data_query_name'])) {
if (isset($prev_data_query_name)) {
if ($prev_data_query_name != $graph['data_query_name']) {
$print = true;
$prev_data_query_name = $graph['data_query_name'];
} else {
$print = false;
}
} else {
$print = true;
$prev_data_query_name = $graph['data_query_name'];
}
if ($print) {
if (!$start) {
while(($i % $columns) != 0) {
print "<td style='text-align:center;width:" . round(100 / $columns, 3) . "%;'></td>";
$i++;
}
print '</tr>';
}
print "<tr class='tableHeader'>
<td class='graphSubHeaderColumn textHeaderDark' colspan='$columns'>" . __('Data Query:') . ' ' . $graph['data_query_name'] . '</td>
</tr>';
$i = 0;
}
}
if ($i == 0) {
print "<tr class='tableRowGraph'>";
$start = false;
}
?>
<td class='graphWrapperOuter' data-disabled='<?php print ($graph['disabled'] == 'on' ? 'true':'false');?>' style='width:<?php print round(100 / $columns, 2);?>%;'>
<div>
<table style='text-align:center;margin:auto;'>
<tr>
<td>
<div class='graphWrapper' id='wrapper_<?php print $graph['local_graph_id']?>' graph_width='<?php print read_user_setting('default_width');?>' graph_height='<?php print read_user_setting('default_height');?>'></div>
<?php print (read_user_setting('show_graph_title') == 'on' ? "<span class='center'>" . html_escape($graph['title_cache']) . '</span>' : '');?>
</td>
<?php if (is_realm_allowed(27)) { ?><td id='dd<?php print $graph['local_graph_id'];?>' class='noprint graphDrillDown'>
<?php print graph_drilldown_icons($graph['local_graph_id'], 'graph_buttons_thumbnails', $tree_id, $branch_id);?>
</td><?php } ?>
</tr>
</table>
</div>
</td>
<?php
$i++;
$k++;
if (($i % $columns) == 0 && ($k < $num_graphs)) {
$i=0;
$j++;
print '</tr>';
$start = true;
}
}
if (!$start) {
while(($i % $columns) != 0) {
print "<td style='text-align:center;width:" . round(100 / $columns, 2) . "%;'></td>";
$i++;
}
print '</tr>';
}
} else {
if ($no_graphs_message != '') {
print "<td><em>$no_graphs_message</em></td>";
}
}
}
function graph_drilldown_icons($local_graph_id, $type = 'graph_buttons', $tree_id = 0, $branch_id = 0) {
global $config;
static $rand = 0;
$aggregate_url = aggregate_build_children_url($local_graph_id);
$graph_template_id = db_fetch_cell_prepared('SELECT graph_template_id
FROM graph_local
WHERE id = ?',
array($local_graph_id));
print "<div class='iconWrapper'>";
print "<a class='iconLink utils' href='#' role='link' id='graph_" . $local_graph_id . "_util'><img class='drillDown' src='" . $config['url_path'] . "images/cog.png' alt='' title='" . __esc('Graph Details, Zooming and Debugging Utilities') . "'></a><br>";
print "<a class='iconLink csvexport' href='#' role='link' id='graph_" . $local_graph_id . "_csv'><img class='drillDown' src='" . $config['url_path'] . "images/table_go.png' alt='' title='" . __esc('CSV Export of Graph Data'). "'></a><br>";
print "<a class='iconLink mrtg' href='#' role='link' id='graph_" . $local_graph_id . "_mrtg'><img class='drillDown' src='" . $config['url_path'] . "images/timeview.png' alt='' title='" . __esc('Time Graph View'). "'></a><br>";
if (is_realm_allowed(3)) {
$host_id = db_fetch_cell_prepared('SELECT host_id
FROM graph_local
WHERE id = ?',
array($local_graph_id));
if ($host_id > 0) {
print "<a class='iconLink' href='" . html_escape($config['url_path'] . "host.php?action=edit&id=$host_id") . "' data-graph='" . $local_graph_id . "' id='graph_" . $local_graph_id . "_de'><img id='de" . $host_id . '_' . $rand . "' class='drillDown' src='" . $config['url_path'] . "images/server_edit.png' title='" . __esc('Edit Device') . "'></a>";
print '<br/>';
$rand++;
}
}
if (is_realm_allowed(10) && $graph_template_id > 0) {
print "<a class='iconLink' role='link' title='" . __esc('Edit Graph Template') . "' href='" . html_escape($config['url_path'] . 'graph_templates.php?action=template_edit&id=' . $graph_template_id) . "'><img src='" . html_escape($config['url_path'] . 'images/template_edit.png') . "'></img></a>";
print '<br/>';
}
if (read_config_option('realtime_enabled') == 'on' && is_realm_allowed(25)) {
if (read_user_setting('realtime_mode') == '' || read_user_setting('realtime_mode') == '1') {
print "<a class='iconLink realtime' href='#' role='link' id='graph_" . $local_graph_id . "_realtime'><img class='drillDown' src='" . $config['url_path'] . "images/chart_curve_go.png' alt='' title='" . __esc('Click to view just this Graph in Real-time'). "'></a><br/>";
} else {
print "<a class='iconLink' href='#' onclick=\"window.open('" . $config['url_path'] . 'graph_realtime.php?top=0&left=0&local_graph_id=' . $local_graph_id . "', 'popup_" . $local_graph_id . "', 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=650,height=300');return false\"><img src='" . $config['url_path'] . "images/chart_curve_go.png' alt='' title='" . __esc('Click to view just this Graph in Real-time') . "'></a><br/>";
}
}
if (is_realm_allowed(1043)) {
print "<span class='iconLink spikekill' data-graph='" . $local_graph_id . "' id='graph_" . $local_graph_id . "_sk'><img id='sk" . $local_graph_id . "' class='drillDown' src='" . $config['url_path'] . "images/spikekill.gif' title='" . __esc('Kill Spikes in Graphs') . "'></span>";
print '<br/>';
}
if ($aggregate_url != '') {
print $aggregate_url;
}
api_plugin_hook($type, array(
'hook' => $type,
'local_graph_id' => $local_graph_id,
'rra' => 0,
'view_type' => $tree_id > 0 ? 'tree':'preview',
'tree_id' => $tree_id,
'branch_id' => $branch_id)
);
print '</div>';
}
/* html_nav_bar - draws a navigation bar which includes previous/next links as well as current
page information
@arg $base_url - the base URL will all filter options except page (should include url_path)
@arg $max_pages - the maximum number of pages to display
@arg $current_page - the current page in the navigation system
@arg $rows_per_page - the number of rows that are displayed on a single page
@arg $total_rows - the total number of rows in the navigation system
@arg $object - the object types that is being displayed
@arg $page_var - the object types that is being displayed
@arg $return_to - paint the resulting page into this dom object
@arg $page_count - provide a page count */
function html_nav_bar($base_url, $max_pages, $current_page, $rows_per_page, $total_rows, $colspan=30, $object = '', $page_var = 'page', $return_to = '', $page_count = true) {
if ($object == '') $object = __('Rows');
if ($total_rows > $rows_per_page && $page_count) {
if (substr_count($base_url, '?') == 0) {
$base_url = trim($base_url) . '?';
} else {
$base_url = trim($base_url) . '&';
}
$url_page_select = get_page_list($current_page, $max_pages, $rows_per_page, $total_rows, $base_url, $page_var, $return_to);
$nav = "<div class='navBarNavigation'>
<div class='navBarNavigationPrevious'>
" . (($current_page > 1) ? "<a href='#' onClick='goto$page_var(" . ($current_page-1) . ");return false;'><i class='fa fa-angle-double-left previous'></i>" . __('Previous'). '</a>':'') . "
</div>
<div class='navBarNavigationCenter'>
" . __('%d to %d of %s [ %s ]', (($rows_per_page*($current_page-1))+1), (($total_rows < $rows_per_page) || ($total_rows < ($rows_per_page*$current_page)) ? $total_rows : $rows_per_page*$current_page), $total_rows, $url_page_select) . "
</div>
<div class='navBarNavigationNext'>
" . (($current_page*$rows_per_page) < $total_rows ? "<a href='#' onClick='goto$page_var(" . ($current_page+1) . ");return false;'>" . __('Next'). "<i class='fa fa-angle-double-right next'></i></a>":'') . "
</div>
</div>";
} elseif ($total_rows > 0) {
if ($page_count || ($total_rows < $rows_per_page && $current_page ==1) ) {
$nav = "<div class='navBarNavigation'>
<div class='navBarNavigationNone'>
" . __('All %d %s', $total_rows, $object) . "
</div>
</div>\n";
} else {
if (substr_count($base_url, '?') == 0) {
$base_url = trim($base_url) . '?';
} else {
$base_url = trim($base_url) . '&';
}
$url_page_select = "<ul class='pagination'>"; //for the same height as write in get_page_list()
$url_page_select .= "<li>$current_page</a></li>";
$url_page_select .= '</ul>';
$nav = "<div class='navBarNavigation'>
<div class='navBarNavigationPrevious'>
" . (($current_page > 1) ? "<a href='#' onClick='goto$page_var(" . ($current_page-1) . ");return false;'><i class='fa fa-angle-double-left previous'></i>" . __('Previous'). "</a>":"") . "
</div>
<div class='navBarNavigationCenter'>
" . __('Current Page: %s', $url_page_select) . "
</div>
<div class='navBarNavigationNext'>
" . ($total_rows >= $rows_per_page ? "<a href='#' onClick='goto$page_var(" . ($current_page+1) . ");return false;'>" . __('Next'). "<i class='fa fa-angle-double-right next'></i></a>":"") . "
</div>
</div>\n";
if ($return_to != '') {//code as in get_page_list()
$nav .= "<script type='text/javascript'>function goto$page_var(pageNo) { if (typeof url_graph === 'function') { var url_add=url_graph('') } else { var url_add=''; }; $.get('" . $base_url . "header=false&" . $page_var . "='+pageNo+url_add).done(function(data) { $('#$return_to').html(data); applySkin(); }); }</script>";
} else {
$nav .= "<script type='text/javascript'>function goto{$page_var}(pageNo) { if (typeof url_graph === 'function') { var url_add=url_graph('') } else { var url_add=''; }; document.location='$base_url$page_var='+pageNo+url_add }</script>";
}
}
} else {
$nav = "<div class='navBarNavigation'>
<div class='navBarNavigationNone'>
" . __('No %s Found', $object) . '
</div>
</div>';
}
return $nav;
}
/* html_header_sort - draws a header row suitable for display inside of a box element. When
a user selects a column header, the callback function "filename" will be called to handle
the sort the column and display the altered results.
@arg $header_items - an array containing a list of column items to display. The
format is similar to the html_header, with the exception that it has three
dimensions associated with each element (db_column => display_text, default_sort_order)
alternatively (db_column => array('display' = 'blah', 'align' = 'blah', 'sort' = 'blah'))
@arg $sort_column - the value of current sort column.
@arg $sort_direction - the value the current sort direction. The actual sort direction
will be opposite this direction if the user selects the same named column.
@arg $last_item_colspan - the TD 'colspan' to apply to the last cell in the row
@arg $url - a base url to redirect sort actions to
@arg $return_to - the id of the object to inject output into as a result of the sort action */
function html_header_sort($header_items, $sort_column, $sort_direction, $last_item_colspan = 1, $url = '', $return_to = '') {
static $page_count = 0;
/* reverse the sort direction */
if ($sort_direction == 'ASC') {
$new_sort_direction = 'DESC';
} else {
$new_sort_direction = 'ASC';
}
$page = $page_count . '_' . str_replace('.php', '', basename($_SERVER['SCRIPT_NAME']));
if (isset_request_var('action')) {
$page .= '_' . get_request_var('action');
}
if (isset_request_var('tab')) {
$page .= '_' . get_request_var('tab');
}
if (isset($_SESSION['sort_data'][$page])) {
$order_data = $_SESSION['sort_data'][$page];
} else {
$order_data = array(get_request_var('sort_column') => get_request_var('sort_direction'));
}
foreach($order_data as $key => $direction) {
$primarySort = $key;
break;
}
print "<tr class='tableHeader'>";
$i = 1;
foreach ($header_items as $db_column => $display_array) {
$isSort = '';
if (isset($display_array['nohide'])) {
$nohide = 'nohide';
} else {
$nohide = '';
}
if (array_key_exists('display', $display_array)) {
$display_text = $display_array['display'];
if ($sort_column == $db_column) {
$icon = $sort_direction;
$direction = $new_sort_direction;
if ($db_column == $primarySort) {
$isSort = 'primarySort';
} else {
$isSort = 'secondarySort';
}
} else {
if (isset($order_data[$db_column])) {
$icon = $order_data[$db_column];
if ($order_data[$db_column] == 'DESC') {
$direction = 'ASC';
} else {
$direction = 'DESC';
}
if ($db_column == $primarySort) {
$isSort = 'primarySort';
} else {
$isSort = 'secondarySort';
}
} else {
$icon = '';
if (isset($display_array['sort'])) {
$direction = $display_array['sort'];
} else {
$direction = 'ASC';
}
}
}
if (isset($display_array['align'])) {
$align = $display_array['align'];
} else {
$align = 'left';
}
if (isset($display_array['tip'])) {
$tip = $display_array['tip'];
} else {
$tip = '';
}
} else {
/* by default, you will always sort ascending, with the exception of an already sorted column */
if ($sort_column == $db_column) {
$icon = $sort_direction;
$direction = $new_sort_direction;
$display_text = $display_array[0];
if ($db_column == $primarySort) {
$isSort = 'primarySort';
} else {
$isSort = 'secondarySort';
}
} else {
if (isset($order_data[$db_column])) {
$icon = $order_data[$db_column];
if ($order_data[$db_column] == 'DESC') {
$direction = 'ASC';
} else {
$direction = 'DESC';
}
if ($db_column == $primarySort) {
$isSort = 'primarySort';
} else {
$isSort = 'secondarySort';
}
} else {
$icon = '';
$direction = $display_array[1];
}
$display_text = $display_array[0];
}
$align = 'left';
$tip = '';
}
if (strtolower($icon) == 'asc') {
$icon = 'fa fa-sort-up';
} elseif (strtolower($icon) == 'desc') {
$icon = 'fa fa-sort-down';
} else {
$icon = 'fa fa-sort';
}
if (($db_column == '') || (substr_count($db_column, 'nosort'))) {
print '<th ' . ($tip != '' ? "title='" . html_escape($tip) . "'":'') . " class='$nohide $align' " . ((($i+1) == cacti_count($header_items)) ? "colspan='$last_item_colspan' " : '') . '>' . $display_text . '</th>';
} else {
print '<th ' . ($tip != '' ? "title='" . html_escape($tip) . "'":'') . " class='sortable $align $nohide $isSort'>";
print "<div class='sortinfo' sort-return='" . ($return_to == '' ? 'main':$return_to) . "' sort-page='" . ($url == '' ? html_escape(get_current_page(false)):$url) . "' sort-column='$db_column' sort-direction='$direction'><div class='textSubHeaderDark'>" . $display_text . "<i class='$icon'></i></div></div></th>";
}
$i++;
}
print '</tr>';
$page_count++;
}
/* html_header_sort_checkbox - draws a header row with a 'select all' checkbox in the last cell
suitable for display inside of a box element. When a user selects a column header,
the callback function "filename" will be called to handle the sort the column and display
the altered results.
@arg $header_items - an array containing a list of column items to display. The
format is similar to the html_header, with the exception that it has three
dimensions associated with each element (db_column => display_text, default_sort_order)
alternatively (db_column => array('display' = 'blah', 'align' = 'blah', 'sort' = 'blah'))
@arg $sort_column - the value of current sort column.
@arg $sort_direction - the value the current sort direction. The actual sort direction
will be opposite this direction if the user selects the same named column.
@arg $form_action - the url to post the 'select all' form to
@arg $return_to - the id of the object to inject output into as a result of the sort action */
function html_header_sort_checkbox($header_items, $sort_column, $sort_direction, $include_form = true, $form_action = '', $return_to = '', $prefix = 'chk') {
static $page_count = 0;
/* reverse the sort direction */
if ($sort_direction == 'ASC') {
$new_sort_direction = 'DESC';
} else {
$new_sort_direction = 'ASC';
}
$page = $page_count . '_' . str_replace('.php', '', basename($_SERVER['SCRIPT_NAME']));
if (isset_request_var('action')) {
$page .= '_' . get_request_var('action');
}
if (isset_request_var('tab')) {
$page .= '_' . get_request_var('tab');
}
if (isset($_SESSION['sort_data'][$page])) {
$order_data = $_SESSION['sort_data'][$page];
} else {
$order_data = array(get_request_var('sort_column') => get_request_var('sort_direction'));
}
foreach($order_data as $key => $direction) {
$primarySort = $key;
break;
}
/* default to the 'current' file */
if ($form_action == '') { $form_action = get_current_page(); }
print "<tr class='tableHeader'>";
foreach($header_items as $db_column => $display_array) {
$isSort = '';
if (isset($display_array['nohide'])) {
$nohide = 'nohide';
} else {
$nohide = '';
}
$icon = '';
if (array_key_exists('display', $display_array)) {
$display_text = $display_array['display'];
if ($sort_column == $db_column) {
$icon = $sort_direction;
$direction = $new_sort_direction;
if ($db_column == $primarySort) {
$isSort = 'primarySort';
} else {
$isSort = 'secondarySort';
}
} else {
if (isset($order_data[$db_column])) {
$icon = $order_data[$db_column];
if ($order_data[$db_column] == 'DESC') {
$direction = 'ASC';
} else {
$direction = 'DESC';
}
if ($db_column == $primarySort) {
$isSort = 'primarySort';
} else {
$isSort = 'secondarySort';
}
} else {
$icon = '';
if (isset($display_array['sort'])) {
$direction = $display_array['sort'];
} else {
$direction = 'ASC';
}
}
}
if (isset($display_array['align'])) {
$align = $display_array['align'];
} else {
$align = 'left';
}
if (isset($display_array['tip'])) {
$tip = $display_array['tip'];
} else {
$tip = '';
}
} else {
/* by default, you will always sort ascending, with the exception of an already sorted column */
if ($sort_column == $db_column) {
$icon = $sort_direction;
$direction = $new_sort_direction;
$display_text = $display_array[0];
if ($db_column == $primarySort) {
$isSort = 'primarySort';
} else {
$isSort = 'secondarySort';
}
} else {
if (isset($order_data[$db_column])) {
$icon = $order_data[$db_column];
if ($order_data[$db_column] == 'DESC') {
$direction = 'ASC';
} else {
$direction = 'DESC';
}
if ($db_column == $primarySort) {
$isSort = 'primarySort';
} else {
$isSort = 'secondarySort';
}
} else {
$icon = '';
$direction = $display_array[1];
}
$display_text = $display_array[0];
}
$align = 'left';
$tip = '';
}
if (strtolower($icon) == 'asc') {
$icon = 'fa fa-sort-up';
} elseif (strtolower($icon) == 'desc') {
$icon = 'fa fa-sort-down';
} else {
$icon = 'fa fa-sort';
}
if (($db_column == '') || (substr_count($db_column, 'nosort'))) {
print '<th ' . ($tip != '' ? "title='" . html_escape($tip) . "'":'') . " class='$align $nohide'>" . $display_text . '</th>';
} else {
print '<th ' . ($tip != '' ? "title='" . html_escape($tip) . "'":'') . " class='sortable $align $nohide $isSort'>";
print "<div class='sortinfo' sort-return='" . ($return_to == '' ? 'main':$return_to) . "' sort-page='" . html_escape($form_action) . "' sort-column='$db_column' sort-direction='$direction'><div class='textSubHeaderDark'>" . $display_text . "<i class='$icon'></i></div></div></th>";
}
}
print "<th class='tableSubHeaderCheckbox'><input id='selectall' class='checkbox' type='checkbox' title='" . __esc('Select All Rows'). "' onClick='selectAll(\"$prefix\",this.checked)'><label class='formCheckboxLabel' title='" . __esc('Select All Rows') . "' for='selectall'></label></th>" . ($include_form ? "<th style='display:none;'><form id='$prefix' name='$prefix' method='post' action='$form_action'></th>":'');
print '</tr>';
$page_count++;
}
/* html_header - draws a header row suitable for display inside of a box element
@arg $header_items - an array containing a list of items to be included in the header
alternatively and array of header names and alignment array('display' = 'blah', 'align' = 'blah')
@arg $last_item_colspan - the TD 'colspan' to apply to the last cell in the row */
function html_header($header_items, $last_item_colspan = 1) {
print "<tr class='tableHeader " . (!$last_item_colspan > 1 ? 'tableFixed':'') . "'>";
$i = 0;
foreach($header_items as $item) {
if (is_array($item)) {
if (isset($item['nohide'])) {
$nohide = 'nohide';
} else {
$nohide = '';
}
if (isset($item['align'])) {
$align = $item['align'];
} else {
$align = 'left';
}
if (isset($item['tip'])) {
$tip = $item['tip'];
} else {
$tip = '';
}
print '<th ' . ($tip != '' ? "title='" . html_escape($tip) . "' ":'') . "class='$nohide $align' " . ((($i+1) == cacti_count($header_items)) ? "colspan='$last_item_colspan' " : '') . '>' . html_escape($item['display']) . '</th>';
} else {
print '<th ' . ((($i+1) == cacti_count($header_items)) ? "colspan='$last_item_colspan' " : '') . '>' . html_escape($item) . '</th>';
}
$i++;
}
print '</tr>';
}
/* html_section_header - draws a header row suitable for display inside of a box element
but for display as a section title and not as a series of table header columns
@arg $header_name - an array of the display name of the header for the section and
optional alignment.
@arg $last_item_colspan - the TD 'colspan' to apply to the last cell in the row */
function html_section_header($header_item, $last_item_colspan = 1) {
print "<tr class='tableHeader " . (!$last_item_colspan > 1 ? 'tableFixed':'') . "'>";
if (is_array($header_item) && isset($header_item['display'])) {
print "<th " . (isset($header_item['align']) ? "style='text-align:" . $header_item['align'] . ";'":"") . " colspan='$last_item_colspan'>" . $header_item['display'] . '</th>';
} else {
print "<th colspan='$last_item_colspan'>" . $header_item . '</th>';
}
print '</tr>';
}
/* html_header_checkbox - draws a header row with a 'select all' checkbox in the last cell
suitable for display inside of a box element
@arg $header_items - an array containing a list of items to be included in the header
alternatively and array of header names and alignment array('display' = 'blah', 'align' = 'blah')
@arg $form_action - the url to post the 'select all' form to */
function html_header_checkbox($header_items, $include_form = true, $form_action = '', $resizable = true, $prefix = 'chk') {
/* default to the 'current' file */
if ($form_action == '') { $form_action = get_current_page(); }
print "<tr class='tableHeader " . (!$resizable ? 'tableFixed':'') . "'>";
foreach($header_items as $item) {
if (is_array($item)) {
if (isset($item['nohide'])) {
$nohide = 'nohide';
} else {
$nohide = '';
}
if (isset($item['align'])) {
$align = $item['align'];
} else {
$align = 'left';
}
if (isset($item['tip'])) {
$tip = $item['tip'];
} else {
$tip = '';
}
print '<th ' . ($tip != '' ? " title='" . html_escape($tip) . "' ":'') . "class='$align $nohide'>" . html_escape($item['display']) . '</th>';
} else {
print "<th class='left'>" . html_escape($item) . '</th>';
}
}
print "<th class='tableSubHeaderCheckbox'><input id='selectall' class='checkbox' type='checkbox' title='" . __esc('Select All Rows'). "' onClick='selectAll(\"$prefix\",this.checked)'><label class='formCheckboxLabel' title='" . __esc('Select All') . "' for='selectall'></label></th>" . ($include_form ? "<th style='display:none;'><form id='$prefix' name='$prefix' method='post' action='$form_action'></th>":'');
print '</tr>';
}
/* html_create_list - draws the items for an html dropdown given an array of data
@arg $form_data - an array containing data for this dropdown. it can be formatted
in one of two ways:
$array["id"] = "value";
-- or --
$array[0]["id"] = 43;
$array[0]["name"] = "Red";
@arg $column_display - used to identify the key to be used for display data. this
is only applicable if the array is formatted using the second method above
@arg $column_id - used to identify the key to be used for id data. this
is only applicable if the array is formatted using the second method above
@arg $form_previous_value - the current value of this form element */
function html_create_list($form_data, $column_display, $column_id, $form_previous_value) {
if (empty($column_display)) {
if (cacti_sizeof($form_data)) {
foreach (array_keys($form_data) as $id) {
print '<option value="' . html_escape($id) . '"';
if ($form_previous_value == $id) {
print ' selected';
}
print '>' . html_escape(null_out_substitutions($form_data[$id])) . '</option>';
}
}
} else {
if (cacti_sizeof($form_data)) {
foreach ($form_data as $row) {
print "<option value='" . html_escape($row[$column_id]) . "'";
if ($form_previous_value == $row[$column_id]) {
print ' selected';
}
if (isset($row['host_id'])) {
print '>' . html_escape($row[$column_display]) . '</option>';
} else {
print '>' . html_escape(null_out_substitutions($row[$column_display])) . '</option>';
}
}
}
}
}
/* html_escape_request_var - sanitizes a request variable for display
@arg $string - string the request variable to escape
@returns $new_string - the escaped request variable to be returned. */
function html_escape_request_var($string) {
return html_escape(get_request_var($string));
}
/* html_escape - sanitizes a string for display
@arg $string - string the string to escape
@returns $new_string - the escaped string to be returned. */
function html_escape($string) {
static $charset;
if ($charset == '') {
$charset = ini_get('default_charset');
}
if ($charset == '') {
$charset = 'UTF-8';
}
// Grave Accent character can lead to xss
if ($string !== null) {
$string = str_replace('`', '`', $string);
return htmlspecialchars($string, ENT_QUOTES|ENT_HTML5, $charset, false);
} else {
return $string;
}
}
/* html_split_string - takes a string and breaks it into a number of <br> separated segments
@arg $string - string to be modified and returned
@arg $length - the maximal string length to split to
@arg $forgiveness - the maximum number of characters to walk back from to determine
the correct break location.
@returns $new_string - the modified string to be returned. */
function html_split_string($string, $length = 90, $forgiveness = 10) {
$new_string = '';
$j = 0;
$done = false;
while (!$done) {
if (mb_strlen($string, 'UTF-8') > $length) {
for($i = 0; $i < $forgiveness; $i++) {
if (substr($string, $length-$i, 1) == ' ') {
$new_string .= mb_substr($string, 0, $length-$i, 'UTF-8') . '<br>';
break;
}
}
$string = mb_substr($string, $length-$i, NULL, 'UTF-8');
} else {
$new_string .= $string;
$done = true;
}
$j++;
if ($j > 4) break;
}
return $new_string;
}
/* draw_graph_items_list - draws a nicely formatted list of graph items for display
on an edit form
@arg $item_list - an array representing the list of graph items. this array should
come directly from the output of db_fetch_assoc()
@arg $filename - the filename to use when referencing any external url
@arg $url_data - any extra GET url information to pass on when referencing any
external url
@arg $disable_controls - whether to hide all edit/delete functionality on this form */
function draw_graph_items_list($item_list, $filename, $url_data, $disable_controls) {
global $config;
include($config['include_path'] . '/global_arrays.php');
print "<tr class='tableHeader'>";
DrawMatrixHeaderItem(__('Graph Item'),'',1);
DrawMatrixHeaderItem(__('#'), '', 1);
DrawMatrixHeaderItem(__('Data Source'),'',1);
DrawMatrixHeaderItem(__('Graph Item Type'),'',1);
DrawMatrixHeaderItem(__('CF Type'),'',1);
DrawMatrixHeaderItem(__('GPrint'),'',1);
DrawMatrixHeaderItem(__('CDEF'),'',1);
DrawMatrixHeaderItem(__('VDEF'),'',1);
DrawMatrixHeaderItem(__('Alpha %'),'',1);
DrawMatrixHeaderItem(__('Item Color'),'',4);
print '</tr>';
$group_counter = 0; $_graph_type_name = ''; $i = 0;
if (cacti_sizeof($item_list)) {
foreach ($item_list as $item) {
/* graph grouping display logic */
$this_row_style = '';
$use_custom_class = false;
$hard_return = '';
if (!preg_match('/(GPRINT|TEXTALIGN|HRULE|VRULE|TICK)/', $graph_item_types[$item['graph_type_id']])) {
$this_row_style = 'font-weight: bold;';
$use_custom_class = true;
$item['gprint_name'] = __('N/A');
if ($group_counter % 2 == 0) {
$customClass = 'graphItem';
} else {
$customClass = 'graphItemAlternate';
}
$group_counter++;
}
$_graph_type_name = $graph_item_types[$item['graph_type_id']];
/* alternating row color */
if ($use_custom_class == false) {
print "<tr class='tableRowGraph'>";
} else {
print "<tr class='tableRowGraph $customClass'>";
}
print '<td>';
if ($disable_controls == false) { print "<a class='linkEditMain' href='" . html_escape("$filename?action=item_edit&id=" . $item['id'] . "&$url_data") . "'>"; }
print __('Item # %d', ($i+1));
if ($disable_controls == false) { print '</a>'; }
print '</td>';
print '<td>' . $item['sequence'] . '</td>';
if (empty($item['data_source_name'])) {
$item['data_source_name'] = __('No Source');
}
switch (true) {
case preg_match('/(TEXTALIGN)/', $_graph_type_name):
$matrix_title = 'TEXTALIGN: ' . ucfirst($item['textalign']);
break;
case preg_match('/(TICK)/', $_graph_type_name):
$matrix_title = $item['data_source_name'] . ': ' . $item['text_format'];
break;
case preg_match('/(AREA|STACK|GPRINT|LINE[123])/', $_graph_type_name):
$matrix_title = $item['data_source_name'] . ': ' . $item['text_format'];
break;
case preg_match('/(HRULE)/', $_graph_type_name):
$matrix_title = 'HRULE: ' . $item['value'];
break;
case preg_match('/(VRULE)/', $_graph_type_name):
$matrix_title = 'VRULE: ' . $item['value'];
break;
case preg_match('/(COMMENT)/', $_graph_type_name):
$matrix_title = 'COMMENT: ' . $item['text_format'];
break;
}
if (preg_match('/(TEXTALIGN)/', $_graph_type_name)) {
$hard_return = '';
} elseif ($item['hard_return'] == 'on') {
$hard_return = "<span style='font-weight:bold;color:#FF0000;'><HR></span>";
}
/* data source */
print "<td style='$this_row_style'>" . html_escape($matrix_title) . $hard_return . '</td>';
/* graph item type */
print "<td style='$this_row_style'>" . $graph_item_types[$item['graph_type_id']] . '</td>';
if (!preg_match('/(TICK|TEXTALIGN|HRULE|VRULE)/', $_graph_type_name)) {
print "<td style='$this_row_style'>" . $consolidation_functions[$item['consolidation_function_id']] . '</td>';
} else {
print '<td>' . __('N/A') . '</td>';
}
print "<td style='$this_row_style'>";
print $item['gprint_name'];
print "</td>";
print "<td style='$this_row_style'>";
print $item['cdef_name'];
print "</td>";
print "<td style='$this_row_style'>";
print $item['vdef_name'];
print "</td>";
/* alpha type */
if (preg_match('/(AREA|STACK|TICK|LINE[123])/', $_graph_type_name)) {
print "<td style='$this_row_style'>" . round((hexdec($item['alpha'])/255)*100) . '%</td>';
} else {
print "<td style='$this_row_style'></td>";
}
/* color name */
if (!preg_match('/(TEXTALIGN)/', $_graph_type_name)) {
print "<td style='width:1%;" . ((!empty($item['hex'])) ? 'background-color:#' . $item['hex'] . ";'" : "'") . '></td>';
print "<td style='$this_row_style'>" . $item['hex'] . '</td>';
} else {
print '<td></td><td></td>';
}
if ($disable_controls == false) {
print "<td class='right nowrap'>";
if ($i != cacti_sizeof($item_list)-1) {
print "<span><a class='moveArrow fa fa-caret-down' title='" . __esc('Move Down'). "' href='" . html_escape("$filename?action=item_movedown&id=" . $item['id'] . "&$url_data") . "'></a></span>";
} else {
print "<span class='moveArrowNone'></span>";
}
if ($i > 0) {
print "<span><a class='moveArrow fa fa-caret-up' title='" . __esc('Move Up') . "' href='" . html_escape("$filename?action=item_moveup&id=" . $item['id'] . "&$url_data") . "'></a></span>";
} else {
print "<span class='moveArrowNone'></span>";
}
print '</td>';
print "<td style='width:1%' class='right'>";
print "<a class='deleteMarker fa fa-times' title='" . __esc('Delete') . "' href='" . html_escape("$filename?action=item_remove&id=" . $item['id'] . "&nostate=true&$url_data") . "'></a>";
print "</td>";
}
print '</tr>';
$i++;
}
} else {
print "<tr class='tableRow'><td colspan='7'><em>" . __('No Items') . '</em></td></tr>';
}
}
/* is_menu_pick_active - determines if current selection is active
@arg $menu_url - url of current page
@returns true if active, false if not
*/
function is_menu_pick_active($menu_url) {
static $url_array, $url_parts;
$menu_parts = array();
/* special case for host.php?action=edit&create=true */
if (strpos($_SERVER['REQUEST_URI'], 'host.php?action=edit&create=true') !== false) {
if (strpos($menu_url, 'host.php?action=edit&create=true') !== false) {
return true;
} else {
return false;
}
} elseif (strpos($_SERVER['REQUEST_URI'], 'graph_templates_items.php') !== false) {
/* special case for Graph Template items edit */
if (strpos($menu_url, 'graph_templates.php') !== false) {
return true;
} else {
return false;
}
} elseif (strpos($_SERVER['REQUEST_URI'], 'graph_items.php') !== false) {
/* special case for Graph items edit */
if (strpos($menu_url, 'graphs.php') !== false) {
return true;
} else {
return false;
}
} elseif (strpos($_SERVER['REQUEST_URI'], 'color_templates_items.php') !== false) {
/* special case for Color Templates items edit */
if (strpos($menu_url, 'color_templates.php') !== false) {
return true;
} else {
return false;
}
} elseif (!is_array($url_array) || (is_array($url_array) && !cacti_sizeof($url_array))) {
/* break out the URL and variables */
$url_array = parse_url($_SERVER['REQUEST_URI']);
if (isset($url_array['query'])) {
parse_str($url_array['query'], $url_parts);
} else {
$url_parts = array();
}
}
// Host requires another check
if (strpos($menu_url, 'host.php?action=edit&create=true') !== false) {
return false;
}
$menu_array = parse_url($menu_url);
if ($menu_array === false) {
return false;
}
if (! array_key_exists('path', $menu_array)) {
return false;
}
if (basename($url_array['path']) == basename($menu_array['path'])) {
if (isset($menu_array['query'])) {
parse_str($menu_array['query'], $menu_parts);
} else {
$menu_parts = array();
}
if (isset($menu_parts['id'])) {
if (isset($url_parts['id'])) {
if ($menu_parts['id'] == $url_parts['id']) {
return true;
}
}
} elseif (isset($menu_parts['action'])) {
if (isset($url_parts['action'])) {
if ($menu_parts['action'] == $url_parts['action']) {
return true;
}
}
} else {
return true;
}
}
return false;
}
/* draw_menu - draws the cacti menu for display in the console */
function draw_menu($user_menu = '') {
global $config, $user_auth_realm_filenames, $menu, $menu_glyphs;
if (!is_array($user_menu)) {
$user_menu = $menu;
}
print "<tr><td><table width='100%'><tr><td><div id='menu'><ul id='nav' role='menu'>";
/* loop through each header */
$i = 0;
$headers = array();
foreach ($user_menu as $header_name => $header_array) {
/* pass 1: see if we are allowed to view any children */
$show_header_items = false;
foreach ($header_array as $item_url => $item_title) {
if (preg_match('#link.php\?id=(\d+)#', $item_url, $matches)) {
if (is_realm_allowed($matches[1]+10000)) {
$show_header_items = true;
} else {
$show_header_items = false;
}
} else {
$current_realm_id = (isset($user_auth_realm_filenames[basename($item_url)]) ? $user_auth_realm_filenames[basename($item_url)] : 0);
if (is_realm_allowed($current_realm_id)) {
$show_header_items = true;
} elseif (api_user_realm_auth(strtok($item_url, '?'))) {
$show_header_items = true;
}
}
}
if ($show_header_items == true) {
// Let's give our menu li's a unique id
$id = 'menu_' . strtolower(clean_up_name($header_name));
if (isset($headers[$id])) {
$id .= '_' . $i++;
}
$headers[$id] = true;
if (isset($menu_glyphs[$header_name])) {
$glyph = '<i class="menu_glyph ' . $menu_glyphs[$header_name] . '"></i>';
} else {
$glyph = '<i class="menu_glyph fa fa-folder"></i>';
}
print "<li class='menuitem' role='menuitem' aria-haspopup='true' id='$id'><a class='menu_parent active' href='#'>$glyph<span>$header_name</span></a>";
print "<ul role='menu' id='{$id}_div' style='display:block;'>";
/* pass 2: loop through each top level item and render it */
foreach ($header_array as $item_url => $item_title) {
$basename = explode('?', basename($item_url));
$basename = $basename[0];
$current_realm_id = (isset($user_auth_realm_filenames[$basename]) ? $user_auth_realm_filenames[$basename] : 0);
/* if this item is an array, then it contains sub-items. if not, is just
the title string and needs to be displayed */
if (is_array($item_title)) {
$i = 0;
if ($current_realm_id == -1 || is_realm_allowed($current_realm_id) || !isset($user_auth_realm_filenames[$basename])) {
/* if the current page exists in the sub-items array, draw each sub-item */
if (array_key_exists(get_current_page(), $item_title) == true) {
$draw_sub_items = true;
} else {
$draw_sub_items = false;
}
foreach ($item_title as $item_sub_url => $item_sub_title) {
if (substr($item_sub_url, 0, 10) == 'EXTERNAL::') {
$item_sub_external = true;
$item_sub_url = substr($item_sub_url, 10);
} else {
$item_sub_external = false;
$item_sub_url = $config['url_path'] . $item_sub_url;
}
/* always draw the first item (parent), only draw the children if we are viewing a page
that is contained in the sub-items array */
if (($i == 0) || ($draw_sub_items)) {
if (is_menu_pick_active($item_sub_url)) {
print "<li><a role='menuitem' class='pic selected' href='";
print html_escape($item_sub_url) . "'";
if ($item_sub_external) {
print " target='_blank' rel='noopener'";
}
print ">$item_sub_title</a></li>";
} else {
print "<li><a role='menuitem' class='pic' href='";
print html_escape($item_sub_url) . "'";
if ($item_sub_external) {
print " target='_blank' rel='noopener'";
}
print ">$item_sub_title</a></li>";
}
}
$i++;
}
}
} else {
if ($current_realm_id == -1 || is_realm_allowed($current_realm_id) || !isset($user_auth_realm_filenames[$basename])) {
/* draw normal (non sub-item) menu item */
if (substr($item_url, 0, 10) == 'EXTERNAL::') {
$item_external = true;
$item_url = substr($item_url, 10);
} else {
$item_external = false;
$item_url = $config['url_path'] . $item_url;
}
if (is_menu_pick_active($item_url)) {
print "<li><a role='menuitem' class='pic selected' href='";
print html_escape($item_url) . "'";
if ($item_external) {
print " target='_blank' rel='noopener'";
}
print ">$item_title</a></li>";
} else {
print "<li><a role='menuitem' class='pic' href='";
print html_escape($item_url) . "'";
if ($item_external) {
print " target='_blank' rel='noopener'";
}
print ">$item_title</a></li>";
}
}
}
}
print '</ul></li>';
}
}
print '</ul></div></td></tr></table></td></tr>';
}
/* draw_actions_dropdown - draws a table the allows the user to select an action to perform
on one or more data elements
@arg $actions_array - an array that contains a list of possible actions. this array should
be compatible with the form_dropdown() function
@arg $delete_action - if there is a delete action that should suppress removal of rows
specify it here. If you don't want any delete actions, set to 0.*/
function draw_actions_dropdown($actions_array, $delete_action = 1) {
global $config;
if ($actions_array === NULL || cacti_sizeof($actions_array) == 0) {
return;
}
if (!isset($actions_array[0])) {
$my_actions[0] = __('Choose an action');
$my_actions += $actions_array;
$actions_array = $my_actions;
}
?>
<div class='actionsDropdown'>
<div>
<span class='actionsDropdownArrow'><img src='<?php print $config['url_path']; ?>images/arrow.gif' alt=''></span>
<?php form_dropdown('drp_action', $actions_array, '', '', '0', '', '');?>
<span class='actionsDropdownButton'><input type='submit' class='ui-button ui-corner-all ui-widget' id='submit' value='<?php print __esc('Go');?>' title='<?php print __esc('Execute Action');?>'></span>
</div>
</div>
<input type='hidden' id='action' name='action' value='actions'>
<script type='text/javascript'>
function setDisabled() {
$('tr[id^="line"]').addClass('selectable').prop('disabled', false).removeClass('disabled_row').unbind('click').prop('disabled', false);
if ($('#drp_action').val() == <?php print $delete_action;?>) {
$(':checkbox.disabled').each(function(data) {
$(this).closest('tr').addClass('disabled_row');
if ($(this).is(':checked')) {
$(this).prop('checked', false).removeAttr('aria-checked').removeAttr('data-prev-check');
$(this).closest('tr').removeClass('selected');
}
$(this).prop('disabled', true).closest('tr').removeClass('selected');
});
$('#submit').each(function() {
if ($(this).button === 'function') {
$(this).button('enable');
} else {
$(this).prop('disabled', false);
}
});
} else if ($('#drp_action').val() == 0) {
$(':checkbox.disabled').each(function(data) {
$(this).prop('disabled', false);
});
$('#submit').each(function() {
if ($(this).button === 'function') {
$(this).button('disable');
} else {
$(this).prop('disabled', true);
}
});
} else if (<?php print $delete_action;?> != 0) {
$('#submit').each(function() {
if ($(this).button === 'function') {
$(this).button('enable');
} else {
$(this).prop('disabled', false);
}
});
}
$('tr[id^="line"]').filter(':not(.disabled_row)').off('click').on('click', function(event) {
selectUpdateRow(event, $(this));
});
}
$(function() {
setDisabled();
$('#drp_action').change(function() {
setDisabled();
});
});
</script>
<?php
}
/*
* Deprecated functions
*/
function DrawMatrixHeaderItem($matrix_name, $matrix_text_color, $column_span = 1) {
?>
<th style='height:1px;' colspan='<?php print $column_span;?>'>
<div class='textSubHeaderDark'><?php print $matrix_name;?></div>
</th>
<?php
}
function form_area($text) {
?>
<tr>
<td class='textArea'>
<?php print html_escape($text);?>
</td>
</tr>
<?php
}
/**
* is_console_page - determines if current passed url is considered to be a console page
*
* @param url - url to be checked
*
* @return true if console page, false if not
*/
function is_console_page($url) {
global $menu;
$basename = basename($url);
if ($basename == 'index.php') {
return true;
}
if ($basename == 'rrdcleaner.php') {
return true;
}
if (api_plugin_hook_function('is_console_page', $url) != $url) {
return true;
}
if (cacti_sizeof($menu)) {
foreach($menu as $section => $children) {
if (cacti_sizeof($children)) {
foreach($children as $page => $name) {
if (basename($page) == $basename) {
return true;
}
}
}
}
}
return false;
}
function html_show_tabs_left() {
global $config, $tabs_left;
$realm_allowed = array();
$realm_allowed[7] = is_realm_allowed(7);
$realm_allowed[8] = is_realm_allowed(8);
$realm_allowed[18] = is_realm_allowed(18);
$realm_allowed[19] = is_realm_allowed(19);
$realm_allowed[21] = is_realm_allowed(21);
$realm_allowed[22] = is_realm_allowed(22);
if ($realm_allowed[8]) {
$show_console_tab = true;
} else {
$show_console_tab = false;
}
if (get_selected_theme() == 'classic') {
if ($show_console_tab == true) {
?><a id='tab-console' <?php print (is_console_page(get_current_page()) ? " class='selected'":'');?> href='<?php print $config['url_path']; ?>index.php'><img src='<?php echo $config['url_path']; ?>images/tab_console<?php print (is_console_page(get_current_page()) ? '_down':'');?>.gif' alt='<?php print __('Console');?>'></a><?php
}
if ($realm_allowed[7]) {
if ($config['poller_id'] > 1 && $config['connection'] != 'online') {
// Don't show graphs tab when offline
} else {
$file = get_current_page();
if ($file == 'graph_view.php' || $file == 'graph.php') {
print "<a id='tab-graphs' class='selected' href='" . html_escape($config['url_path'] . 'graph_view.php') . "'><img src='" . $config['url_path'] . "images/tab_graphs_down.gif' alt='" . __('Graphs') . "'></a>";
} else {
print "<a id='tab-graphs' href='" . html_escape($config['url_path'] . 'graph_view.php') . "'><img src='" . $config['url_path'] . "images/tab_graphs.gif' alt='" . __('Graphs') . "'></a>";
}
}
}
if ($realm_allowed[21] || $realm_allowed[22]) {
if ($config['poller_id'] > 1) {
// Don't show reports table if not poller 1
} else {
if (substr_count($_SERVER['REQUEST_URI'], 'reports_')) {
print '<a id="tab-reports" href="' . $config['url_path'] . ($realm_allowed[21] === true ? 'reports_admin.php':'reports_user.php') . '"><img src="' . $config['url_path'] . 'images/tab_nectar_down.gif" alt="' . __('Reporting') . '"></a>';
} else {
print '<a id="tab-reports" href="' . $config['url_path'] . ($realm_allowed[21] === true ? 'reports_admin.php':'reports_user.php') . '"><img src="' . $config['url_path'] . 'images/tab_nectar.gif" alt="' . __('Reporting') . '"></a>';
}
}
}
if ($realm_allowed[18] || $realm_allowed[19]) {
if (substr_count($_SERVER['REQUEST_URI'], 'clog')) {
print '<a id="tab-logs" href="' . $config['url_path'] . ($realm_allowed[18] ? 'clog.php':'clog_user.php') . '"><img src="' . $config['url_path'] . 'images/tab_clog_down.png" alt="' . __('Logs'). '"></a>';
} else {
print '<a id="tab-logs" href="' . $config['url_path'] . ($realm_allowed[18] ? 'clog.php':'clog_user.php') . '"><img src="' . $config['url_path'] . 'images/tab_clog.png" alt="' . __('Logs') . '"></a>';
}
}
api_plugin_hook('top_graph_header_tabs');
if ($config['poller_id'] > 1 && $config['connection'] != 'online') {
// Only show external links when online
} else {
$external_links = db_fetch_assoc('SELECT id, title
FROM external_links
WHERE style="TAB"
AND enabled="on"
ORDER BY sortorder');
if (cacti_sizeof($external_links)) {
foreach($external_links as $tab) {
if (is_realm_allowed($tab['id']+10000)) {
$parsed_url = parse_url($_SERVER['REQUEST_URI']);
$down = false;
if (basename($parsed_url['path']) == 'link.php') {
if (isset($parsed_url['query'])) {
$queries = explode('&', $parsed_url['query']);
foreach($queries as $q) {
list($var, $value) = explode('=', $q);
if ($var == 'id') {
if ($value == $tab['id']) {
$down = true;
break;
}
}
}
}
}
print '<a id="tab-link' . $tab['id'] . '" href="' . $config['url_path'] . 'link.php?id=' . $tab['id'] . '"><img src="' . get_classic_tabimage($tab['title'], $down) . '" alt="' . html_escape($tab['title']) . '"></a>';
}
}
}
}
} else {
if ($show_console_tab) {
$tabs_left[] =
array(
'title' => __('Console'),
'id' => 'tab-console',
'url' => $config['url_path'] . 'index.php',
);
}
if ($realm_allowed[7]) {
if ($config['poller_id'] > 1 && $config['connection'] != 'online') {
// Don't show the graphs tab when offline
} else {
$tabs_left[] =
array(
'title' => __('Graphs'),
'id' => 'tab-graphs',
'url' => $config['url_path'] . 'graph_view.php',
);
}
}
if ($realm_allowed[21] || $realm_allowed[22]) {
if ($config['poller_id'] > 1) {
// Don't show the reports tab on other pollers
} else {
$tabs_left[] =
array(
'title' => __('Reporting'),
'id' => 'tab-reports',
'url' => $config['url_path'] . ($realm_allowed[21] ? 'reports_admin.php':'reports_user.php'),
);
}
}
if ($realm_allowed[18] || $realm_allowed[19]) {
$tabs_left[] =
array(
'title' => __('Logs'),
'id' => 'tab-logs',
'url' => $config['url_path'] . ($realm_allowed[18] ? 'clog.php':'clog_user.php'),
);
}
// Get Plugin Text Out of Band
ob_start();
api_plugin_hook('top_graph_header_tabs');
$tab_text = trim(ob_get_clean());
$tab_text = str_replace('<a', '', $tab_text);
$tab_text = str_replace('</a>', '|', $tab_text);
$tab_text = str_replace('<img', '', $tab_text);
$tab_text = str_replace('<', '', $tab_text);
$tab_text = str_replace('"', "'", $tab_text);
$tab_text = str_replace('>', '', $tab_text);
$elements = explode('|', $tab_text);
$count = 0;
foreach($elements as $p) {
$p = trim($p);
if ($p == '') {
continue;
}
$altpos = strpos($p, 'alt=');
$hrefpos = strpos($p, 'href=');
$idpos = strpos($p, 'id=');
if ($altpos !== false) {
$alt = substr($p, $altpos+4);
$parts = explode("'", $alt);
if ($parts[0] == '') {
$alt = $parts[1];
} else {
$alt = $parts[0];
}
} else {
$alt = __('Title');
}
if ($hrefpos !== false) {
$href = substr($p, $hrefpos+5);
$parts = explode("'", $href);
if ($parts[0] == '') {
$href = $parts[1];
} else {
$href = $parts[0];
}
} else {
$href = 'unknown';
}
if ($idpos !== false) {
$id = substr($p, $idpos+3);
$parts = explode("'", $id);
if ($parts[0] == '') {
$id = $parts[1];
} else {
$id = $parts[0];
}
} else {
$id = 'unknown' . $count;
$count++;
}
$tabs_left[] = array('title' => ucwords($alt), 'id' => 'tab-' . $id, 'url' => $href);
}
if ($config['poller_id'] > 1 && $config['connection'] != 'online') {
// Only show external links when online
} else {
$external_links = db_fetch_assoc('SELECT id, title
FROM external_links
WHERE style="TAB"
AND enabled="on"
ORDER BY sortorder');
if (cacti_sizeof($external_links)) {
foreach($external_links as $tab) {
if (is_realm_allowed($tab['id']+10000)) {
$tabs_left[] =
array(
'title' => $tab['title'],
'id' => 'tab-link' . $tab['id'],
'url' => $config['url_path'] . 'link.php?id=' . $tab['id']
);
}
}
}
}
$i = 0;
$me_base = get_current_page();
foreach($tabs_left as $tab) {
$tab_base = basename($tab['url']);
if ($tab_base == 'graph_view.php' && ($me_base == 'graph_view.php' || $me_base == 'graph.php')) {
$tabs_left[$i]['selected'] = true;
} elseif (isset_request_var('id') && ($tab_base == 'link.php?id=' . get_nfilter_request_var('id')) && $me_base == 'link.php') {
$tabs_left[$i]['selected'] = true;
} elseif ($tab_base == 'index.php' && is_console_page($me_base)) {
$tabs_left[$i]['selected'] = true;
} elseif ($tab_base == $me_base) {
$tabs_left[$i]['selected'] = true;
}
$i++;
}
$i = 0;
print "<div class='maintabs'><nav><ul role='tablist'>";
foreach($tabs_left as $tab) {
if (isset($tab['id'])) {
$id = $tab['id'];
} else {
$id = 'anchor' . $i;
$i++;
}
print "<li><a id='$id' role='tab' class='lefttab" . (isset($tab['selected']) ? " selected' aria-selected='true'":"' aria-selected='false'") . " href='" . html_escape($tab['url']) . "'><span class='fa glyph_$id'></span><span class='text_$id'>" . html_escape($tab['title']) . "</span></a><a id='menu-$id' class='maintabs-submenu' href='#'><i class='fa fa-angle-down'></i></a></li>";
}
print "<li class='ellipsis maintabs-submenu-ellipsis'><a id='menu-ellipsis' role='tab' aria-selected='false' class='submenu-ellipsis' href='#'><i class='fa fa-angle-down'></i></a></li>";
print '</ul></nav></div>';
}
}
function html_graph_tabs_right() {
global $config, $tabs_right;
$theme = get_selected_theme();
if ($theme == 'classic') {
if (is_view_allowed('show_tree')) {
?><a class='righttab' id='treeview' href='<?php print html_escape($config['url_path'] . 'graph_view.php?action=tree');?>'><img src='<?php print $config['url_path']; ?>images/tab_mode_tree<?php
if (isset_request_var('action') && get_nfilter_request_var('action') == 'tree') {
print '_down';
}?>.gif' title='<?php print __esc('Tree View');?>' alt=''></a><?php
}?><?php
if (is_view_allowed('show_list')) {
?><a class='righttab' id='listview' href='<?php print html_escape($config['url_path'] . 'graph_view.php?action=list');?>'><img src='<?php print $config['url_path']; ?>images/tab_mode_list<?php
if (isset_request_var('action') && get_nfilter_request_var('action') == 'list') {
print '_down';
}?>.gif' title='<?php print __esc('List View');?>' alt=''></a><?php
}?><?php
if (is_view_allowed('show_preview')) {
?><a class='righttab' id='preview' href='<?php print html_escape($config['url_path'] . 'graph_view.php?action=preview');?>'><img src='<?php print $config['url_path']; ?>images/tab_mode_preview<?php
if (isset_request_var('action') && get_nfilter_request_var('action') == 'preview') {
print '_down';
}?>.gif' title='<?php print __esc('Preview View');?>' alt=''></a><?php
}?> <br>
<?php
} else {
$tabs_right = array();
if (is_view_allowed('show_tree')) {
$tabs_right[] = array(
'title' => __('Tree View'),
'image' => 'include/themes/' . $theme . '/images/tab_tree.gif',
'id' => 'tree',
'url' => 'graph_view.php?action=tree',
);
}
if (is_view_allowed('show_list')) {
$tabs_right[] = array(
'title' => __('List View'),
'image' => 'include/themes/' . $theme . '/images/tab_list.gif',
'id' => 'list',
'url' => 'graph_view.php?action=list',
);
}
if (is_view_allowed('show_preview')) {
$tabs_right[] = array(
'title' => __('Preview'),
'image' => 'include/themes/' . $theme . '/images/tab_preview.gif',
'id' => 'preview',
'url' => 'graph_view.php?action=preview',
);
}
$i = 0;
foreach($tabs_right as $tab) {
if ($tab['id'] == 'tree') {
if (isset_request_var('action') && get_nfilter_request_var('action') == 'tree') {
$tabs_right[$i]['selected'] = true;
}
} elseif ($tab['id'] == 'list') {
if (isset_request_var('action') && get_nfilter_request_var('action') == 'list') {
$tabs_right[$i]['selected'] = true;
}
} elseif ($tab['id'] == 'preview') {
if (isset_request_var('action') && get_nfilter_request_var('action') == 'preview') {
$tabs_right[$i]['selected'] = true;
}
} elseif (strstr(get_current_page(false), $tab['url'])) {
$tabs_right[$i]['selected'] = true;
}
$i++;
}
print "<div class='tabs' style='float:right;'><nav><ul role='tablist'>";
foreach($tabs_right as $tab) {
switch($tab['id']) {
case 'tree':
if (isset($tab['image']) && $tab['image'] != '') {
print "<li><a id='treeview' role='tab' title='" . html_escape($tab['title']) . "' class='righttab " . (isset($tab['selected']) ? " selected' aria-selected='true'":"' aria-selected='false'") . " href='" . $tab['url'] . "'><img src='" . $config['url_path'] . $tab['image'] . "' alt='' style='vertical-align:bottom;'></a></li>";
} else {
print "<li><a role='tab' title='" . html_escape($tab['title']) . "' class='righttab " . (isset($tab['selected']) ? " selected' aria-selected='true'":"' aria-selected='false'") . " href='" . $tab['url'] . "'>" . $tab['title'] . '</a></li>';
}
break;
case 'list':
if (isset($tab['image']) && $tab['image'] != '') {
print "<li><a id='listview' role='tab' title='" . html_escape($tab['title']) . "' class='righttab " . (isset($tab['selected']) ? " selected' aria-selected='true'":"' aria-selected='false'") . " href='" . $tab['url'] . "'><img src='" . $config['url_path'] . $tab['image'] . "' alt='' style='vertical-align:bottom;'></a></li>";
} else {
print "<li><a role='tab' title='" . html_escape($tab['title']) . "' class='righttab " . (isset($tab['selected']) ? " selected' aria-selected='true'":"' aria-selected='false'") . " href='" . $tab['url'] . "'>" . $tab['title'] . '</a></li>';
}
break;
case 'preview':
if (isset($tab['image']) && $tab['image'] != '') {
print "<li><a role='tab' id='preview' title='" . html_escape($tab['title']) . "' class='righttab " . (isset($tab['selected']) ? " selected' aria-selected='true'":"' aria-selected='false'") . " href='" . $tab['url'] . "'><img src='" . $config['url_path'] . $tab['image'] . "' alt='' style='vertical-align:bottom;'></a></li>";
} else {
print "<li><a role='tab' title='" . html_escape($tab['title']) . "' class='righttab " . (isset($tab['selected']) ? " selected' aria-selected='true'":"' aria-selected='false'") . " href='" . $tab['url'] . "'>" . $tab['title'] . '</a></li>';
}
break;
}
}
print '</ul></nav></div>';
}
}
function html_host_filter($host_id = '-1', $call_back = 'applyFilter', $sql_where = '', $noany = false, $nonone = false) {
$theme = get_selected_theme();
if (strpos($call_back, '()') === false) {
$call_back .= '()';
}
if ($host_id == '-1' && isset_request_var('host_id')) {
$host_id = get_filter_request_var('host_id');
}
if ($theme == 'classic' || !read_config_option('autocomplete_enabled')) {
?>
<td>
<?php print __('Device');?>
</td>
<td>
<select id='host_id' name='host_id' onChange='<?php print $call_back;?>'>
<?php if (!$noany) {?><option value='-1'<?php if ($host_id == '-1') {?> selected<?php }?>><?php print __('Any');?></option><?php }?>
<?php if (!$nonone) {?><option value='0'<?php if ($host_id == '0') {?> selected<?php }?>><?php print __('None');?></option><?php }?>
<?php
$devices = get_allowed_devices($sql_where);
if (cacti_sizeof($devices)) {
foreach ($devices as $device) {
print "<option value='" . $device['id'] . "'"; if ($host_id == $device['id']) { print ' selected'; } print '>' . html_escape(strip_domain($device['description'])) . '</option>';
}
}
?>
</select>
</td>
<?php
} else {
if ($host_id > 0) {
$hostname = db_fetch_cell_prepared('SELECT description
FROM host WHERE id = ?',
array($host_id));
} elseif ($host_id == 0) {
$hostname = __('None');
} else {
$hostname = __('Any');
}
?>
<td>
<?php print __('Device');?>
</td>
<td>
<span id='host_wrapper' style='width:200px;' class='ui-selectmenu-button ui-selectmenu-button-closed ui-corner-all ui-corner-all ui-button ui-widget'>
<span id='host_click' class='ui-selectmenu-icon ui-icon ui-icon-triangle-1-s'></span>
<span class='ui-select-text'>
<input type='text' size='28' id='host' value='<?php print html_escape($hostname);?>'>
</span>
</span>
<input type='hidden' id='host_id' name='host_id' value='<?php print $host_id;?>'>
<input type='hidden' id='call_back' value='<?php print $call_back;?>'>
</td>
<?php
}
}
function html_site_filter($site_id = '-1', $call_back = 'applyFilter', $sql_where = '', $noany = false, $nonone = false) {
$theme = get_selected_theme();
if (strpos($call_back, '()') === false) {
$call_back .= '()';
}
if ($site_id == '-1' && isset_request_var('site_id')) {
$site_id = get_filter_request_var('site_id');
}
?>
<td>
<?php print __('Site');?>
</td>
<td>
<select id='site_id' onChange='<?php print $call_back;?>'>
<?php if (!$noany) {?><option value='-1'<?php if ($site_id == '-1') {?> selected<?php }?>><?php print __('Any');?></option><?php }?>
<?php if (!$nonone) {?><option value='0'<?php if ($site_id == '0') {?> selected<?php }?>><?php print __('None');?></option><?php }?>
<?php
$sites = get_allowed_sites($sql_where);
if (cacti_sizeof($sites)) {
foreach ($sites as $site) {
print "<option value='" . $site['id'] . "'"; if ($site_id == $site['id']) { print ' selected'; } print '>' . html_escape($site['name']) . '</option>';
}
}
?>
</select>
</td>
<?php
}
function html_location_filter($location = '', $call_back = 'applyFilter', $sql_where = '', $noany = false, $nonone = false) {
$theme = get_selected_theme();
if (strpos($call_back, '()') === false) {
$call_back .= '()';
}
?>
<td>
<?php print __('Location');?>
</td>
<td>
<select id='location' onChange='<?php print $call_back;?>'>
<?php if (!$noany) {?><option value='-1'<?php if ($location == '-1') {?> selected<?php }?>><?php print __('Any');?></option><?php }?>
<?php if (!$nonone) {?><option value='0'<?php if ($location == '0') {?> selected<?php }?>><?php print __('None');?></option><?php }?>
<?php
$locations = array_rekey(
db_fetch_assoc("SELECT DISTINCT location
FROM host
$sql_where
ORDER BY location ASC"),
'location', 'location'
);
if (cacti_sizeof($locations)) {
foreach ($locations as $l) {
if ($l == '') {
continue;
}
print "<option value='" . html_escape($l) . "'"; if ($location == $l) { print ' selected'; } print '>' . html_escape($l) . '</option>';
}
}
?>
</select>
</td>
<?php
}
function html_spikekill_actions() {
switch(get_nfilter_request_var('action')) {
case 'spikemenu':
html_spikekill_menu(get_filter_request_var('local_graph_id'));
break;
case 'spikesave':
switch(get_nfilter_request_var('setting')) {
case 'ravgnan':
$id = get_nfilter_request_var('id');
switch($id) {
case 'avg':
case 'last':
case 'nan':
set_user_setting('spikekill_avgnan', $id);
break;
}
break;
case 'rstddev':
set_user_setting('spikekill_deviations', get_filter_request_var('id'));
break;
case 'rvarout':
set_user_setting('spikekill_outliers', get_filter_request_var('id'));
break;
case 'rvarpct':
set_user_setting('spikekill_percent', get_filter_request_var('id'));
break;
case 'rkills':
set_user_setting('spikekill_number', get_filter_request_var('id'));
break;
}
break;
}
}
function html_spikekill_setting($name) {
return read_user_setting($name, read_config_option($name), true);
}
function html_spikekill_menu_item($text, $icon = '', $class = '', $id = '', $data_graph = '', $subitem = '') {
$output = '<li ';
if (!empty($id)) {
$output .= "id='$id' ";
}
if (!empty($data_graph)) {
$output .= "data-graph='$data_graph' ";
}
$output .= 'class=\'' . (empty($class)?'': " $class") . '\'>';
$output .= '<span class=\'spikeKillMenuItem\'>';
if (!empty($icon)) {
$output .= "<i class='$icon'></i>";
}
$output .= "$text</span>";
if (!empty($subitem)) {
$output .= "<ul>$subitem</ul>";
}
$output .= '</li>';
return $output;
}
function html_spikekill_menu($local_graph_id) {
global $settings;
$ravgnan1 = html_spikekill_menu_item(__('Average'), html_spikekill_setting('spikekill_avgnan') == 'avg' ? 'fa fa-check':'fa', 'skmethod', 'method_avg');
$ravgnan2 = html_spikekill_menu_item(__('NaN\'s'), html_spikekill_setting('spikekill_avgnan') == 'nan' ? 'fa fa-check':'fa', 'skmethod', 'method_nan');
$ravgnan3 = html_spikekill_menu_item(__('Last Known Good'), html_spikekill_setting('spikekill_avgnan') == 'last' ? 'fa fa-check':'fa', 'skmethod', 'method_last');
$ravgnan = html_spikekill_menu_item(__('Replacement Method'), '', '', '', '', $ravgnan1 . $ravgnan2 . $ravgnan3);
$rstddev = '';
foreach ($settings['spikes']['spikekill_deviations']['array'] as $key => $value) {
$rstddev .= html_spikekill_menu_item($value, html_spikekill_setting('spikekill_deviations') == $key ? 'fa fa-check':'fa', 'skstddev', 'stddev_' . $key);
}
$rstddev = html_spikekill_menu_item(__('Standard Deviations'), '', '', '', '', $rstddev);
$rvarpct = '';
foreach ($settings['spikes']['spikekill_percent']['array'] as $key => $value) {
$rvarpct .= html_spikekill_menu_item($value, html_spikekill_setting('spikekill_percent') == $key ? 'fa fa-check':'fa', 'skvarpct', 'varpct_' . $key);
}
$rvarpct = html_spikekill_menu_item(__('Variance Percentage'), '', '', '', '', $rvarpct);
$rvarout = '';
foreach ($settings['spikes']['spikekill_outliers']['array'] as $key => $value) {
$rvarout .= html_spikekill_menu_item($value, html_spikekill_setting('spikekill_outliers') == $key ? 'fa fa-check':'fa', 'skvarout', 'varout_' . $key);
}
$rvarout = html_spikekill_menu_item(__('Variance Outliers'), '', '', '', '', $rvarout);
$rkills = '';
foreach ($settings['spikes']['spikekill_number']['array'] as $key => $value) {
$rkills .= html_spikekill_menu_item($value,html_spikekill_setting('spikekill_number') == $key ? 'fa fa-check':'fa', 'skills', 'kills_' . $key);
}
$rkills = html_spikekill_menu_item(__('Kills Per RRA'), '', '', '', '', $rkills);
?>
<div class='spikekillParent' style='display:none;z-index:20;position:absolute;text-align:left;white-space:nowrap;padding-right:2px;'>
<ul class='spikekillMenu' style='font-size:1em;'>
<?php
print html_spikekill_menu_item(__('Remove StdDev'), 'deviceUp fa fa-life-ring', 'rstddev', '', $local_graph_id);
print html_spikekill_menu_item(__('Remove Variance'), 'deviceRecovering fa fa-life-ring', 'rvariance', '', $local_graph_id);
print html_spikekill_menu_item(__('Gap Fill Range'), 'deviceUnknown fa fa-life-ring', 'routlier', '', $local_graph_id);
print html_spikekill_menu_item(__('Float Range'), 'deviceDown fa fa-life-ring', 'rrangefill', '', $local_graph_id);
print html_spikekill_menu_item(__('Dry Run StdDev'), 'deviceUp fa fa-check', 'dstddev', '', $local_graph_id);
print html_spikekill_menu_item(__('Dry Run Variance'), 'deviceRecovering fa fa-check', 'dvariance', '', $local_graph_id);
print html_spikekill_menu_item(__('Dry Run Gap Fill Range'), 'deviceUnknown fa fa-check', 'doutlier', '', $local_graph_id);
print html_spikekill_menu_item(__('Dry Run Float Range'), 'deviceDown fa fa-check', 'drangefill', '', $local_graph_id);
print html_spikekill_menu_item(__('Settings'), 'fa fa-cog', '', '', '', $ravgnan . $rstddev . $rvarpct . $rvarout . $rkills);
}
function html_spikekill_js() {
?>
<script type='text/javascript'>
spikeKillOpen = false;
$(function() {
$(document).click(function() {
if (spikeKillOpen) {
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
spikeKillOpen = false;
}
});
$('span.spikekill').children().contextmenu(function() {
return false;
});
$('span.spikekill').unbind().click(function() {
if (spikeKillOpen == false) {
local_graph_id = $(this).attr('data-graph');
$.get('?action=spikemenu&local_graph_id='+local_graph_id)
.done(function(data) {
$('#sk'+local_graph_id).after(data);
menuAnchor = $('#sk'+local_graph_id).offset().left;
pageWidth = $(document).width();
if (pageWidth - menuAnchor < 180) {
$('.spikekillMenu').css({ position: 'absolute', top: 0, left: -180 });
}
$('.spikekillMenu').menu({
select: function(event, ui) {
$(this).menu('focus', event, ui.item);
},
delay: 1000
});
$('.spikekillParent').show();
spikeKillActions();
spikeKillOpen = true;
})
.fail(function(data) {
getPresentHTTPError(data);
});
} else {
spikeKillOpen = false;
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
}
});
});
function spikeKillActions() {
$('.rstddev').unbind().click(function() {
removeSpikesStdDev($(this).attr('data-graph'));
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
});
$('.dstddev').unbind().click(function() {
dryRunStdDev($(this).attr('data-graph'));
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
});
$('.rvariance').unbind().click(function() {
removeSpikesVariance($(this).attr('data-graph'));
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
});
$('.dvariance').unbind().click(function() {
dryRunVariance($(this).attr('data-graph'));
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
});
$('.routlier').unbind().click(function() {
removeSpikesInRange($(this).attr('data-graph'));
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
});
$('.doutlier').unbind().click(function() {
dryRunSpikesInRange($(this).attr('data-graph'));
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
});
$('.rrangefill').unbind().click(function() {
removeRangeFill($(this).attr('data-graph'));
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
});
$('.drangefill').unbind().click(function() {
dryRunRangeFill($(this).attr('data-graph'));
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
});
$('.skmethod').unbind().click(function() {
$('.skmethod').find('i').removeClass('fa fa-check');
$(this).find('i:first').addClass('fa fa-check');
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
strURL = '?action=spikesave&setting=ravgnan&id='+$(this).attr('id').replace('method_','');
$.get(strURL)
.fail(function(data) {
getPresentHTTPError(data);
});
});
$('.skills').unbind().click(function() {
$('.skills').find('i').removeClass('fa fa-check');
$(this).find('i:first').addClass('fa fa-check');
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
strURL = '?action=spikesave&setting=rkills&id='+$(this).attr('id').replace('kills_','');
$.get(strURL)
.fail(function(data) {
getPresentHTTPError(data);
});
});
$('.skstddev').unbind().click(function() {
$('.skstddev').find('i').removeClass('fa fa-check');
$(this).find('i:first').addClass('fa fa-check');
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
strURL = '?action=spikesave&setting=rstddev&id='+$(this).attr('id').replace('stddev_','');
$.get(strURL)
.fail(function(data) {
getPresentHTTPError(data);
});
});
$('.skvarpct').unbind().click(function() {
$('.skvarpct').find('i').removeClass('fa fa-check');
$(this).find('i:first').addClass('fa fa-check');
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
strURL = '?action=spikesave&setting=rvarpct&id='+$(this).attr('id').replace('varpct_','');
$.get(strURL)
.fail(function(data) {
getPresentHTTPError(data);
});
});
$('.skvarout').unbind().click(function() {
$('.skvarout').find('i').removeClass('fa fa-check');
$(this).find('i:first').addClass('fa fa-check');
$(this).find('.spikekillMenu').menu('destroy').parent().remove();
strURL = '?action=spikesave&setting=rvarout&id='+$(this).attr('id').replace('varout_','');
$.get(strURL)
.fail(function(data) {
getPresentHTTPError(data);
});
});
}
</script>
<?php
}
/* html_common_header - prints a common set of header, css and javascript links
@arg title - the title of the page to place in the browser
@arg selectedTheme - optionally sets a specific theme over the current one
*/
function html_common_header($title, $selectedTheme = '') {
global $config, $path2calendar, $path2timepicker, $path2colorpicker, $path2ms, $path2msfilter;
if ($selectedTheme == '') {
$selectedTheme = get_selected_theme();
}
if ($selectedTheme == 'classic') {
print "<meta content='width=device-width, initial-scale=0.5, minimum-scale=0.2, maximum-scale=5' name='viewport'>" . PHP_EOL;
} else {
print "<meta content='width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5' name='viewport'>" . PHP_EOL;
}
$script_policy = read_config_option('content_security_policy_script');
if ($script_policy == 'unsafe-eval') {
$script_policy = "'$script_policy'";
} else {
$script_policy = '';
}
$alternates = html_escape(read_config_option('content_security_alternate_sources'));
?>
<meta http-equiv='X-UA-Compatible' content='IE=Edge,chrome=1'>
<meta name='apple-mobile-web-app-capable' content='yes'>
<meta name='description' content='Monitoring tool of the Internet'>
<meta name='mobile-web-app-capable' content='yes'>
<meta name="theme-color" content="#161616"/>
<meta http-equiv="Content-Security-Policy" content="default-src *; img-src 'self' <?php print $alternates;?> data: blob:; style-src 'self' 'unsafe-inline' <?php print $alternates;?>; script-src 'self' <?php print html_escape($script_policy);?> 'unsafe-inline' <?php print $alternates;?>; worker-src 'self' <?php print $alternates;?>;">
<meta name='robots' content='noindex,nofollow'>
<title><?php print $title; ?></title>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'>
<script type='text/javascript'>
var theme='<?php print $selectedTheme;?>';
var hScroll=<?php print read_user_setting('enable_hscroll', '') == 'on' ? 'true':'false';?>;
var userSettings=<?php print is_view_allowed('graph_settings') ? 'true':'false';?>;
var tableConstraints='<?php print __esc('Allow or limit the table columns to extend beyond the current windows limits.');?>';
var searchFilter='<?php print __esc('Enter a search term');?>';
var searchRFilter='<?php print __esc('Enter a regular expression');?>';
var noFileSelected='<?php print __esc('No file selected');?>';
var timeGraphView='<?php print __esc('Time Graph View');?>';
var filterSettingsSaved='<?php print __esc('Filter Settings Saved');?>';
var spikeKillResults='<?php print __esc('SpikeKill Results');?>';
var utilityView='<?php print __esc('Utility View');?>';
var realtimeClickOn='<?php print __esc('Click to view just this Graph in Realtime');?>';
var realtimeClickOff='<?php print __esc('Click again to take this Graph out of Realtime');?>';
var treeView='<?php print __esc('Tree View');?>';
var listView='<?php print __esc('List View');?>';
var previewView='<?php print __esc('Preview View');?>';
var editProfile='<?php print __esc('Edit Profile');?>';
var cactiConsoleAllowed=<?php print (is_realm_allowed(8) ? 'true':'false');?>;
var cactiGraphsAllowed=<?php print (is_realm_allowed(7) ? 'true':'false');?>;
var changePassword='<?php print __esc('Change Password');?>';
var logout='<?php print __esc('Logout');?>';
var standardGraphicalUserInterface='<?php print __esc('Standard Mode');?>';
var compactGraphicalUserInterface='<?php print __esc('Compact Mode');?>';
var darkColorMode='<?php print __esc('Dark Color Mode');?>';
var lightColorMode='<?php print __esc('Light Color Mode');?>';
var usePreferredColorTheme='<?php print __esc('Use System Color');?>';
var ignorePreferredColorTheme='<?php print __esc('Ignore System Color');?>';
var help='<?php print __esc('Help');?>';
var cactiHome='<?php print __esc('Cacti Home');?>';
var cactiConsole='<?php print __esc('Console');?>';
var cactiMisc='<?php print __esc('Miscellaneous');?>';
var cactiDashboards='<?php print __esc('Dashboards');?>';
var cactiGeneral='<?php print __esc('General');?>';
var cactiCharts='<?php print __esc('Charts');?>';
var cactiProjectPage='<?php print __esc('Cacti Project Page');?>';
var cactiCommunityForum='<?php print __esc('User Community');?>';
var cactiUser='<?php print __esc('User');?>';
var cactiDocumentation='<?php print __esc('Documentation');?>';
var cactiSpine='<?php print __esc('Spine');?>';
var cactiRRDProxy='<?php print __esc('RRDProxy');?>';
var cactiKeyboard='<?php print __esc('Keyboard');?>';
var cactiShortcuts='<?php print __esc('Shortcuts');?>';
var cactiContributeTo='<?php print __esc('Contribute to the Cacti Project');?>';
var cactiDevHelp='<?php print __esc('Help in Developing');?>';
var cactiDonate='<?php print __esc('Donation & Sponsoring');?>';
var cactiProfile='<?php print __esc('Profile');?>';
var cactiTheme='<?php print __esc('Theme');?>';
var cactiClient='<?php print __esc('Client');?>';
var cactiTranslate='<?php print __esc('Help in Translating');?>';
var reportABug='<?php print __esc('Report a bug');?>';
var aboutCacti='<?php print __esc('About Cacti');?>';
var justCacti='<?php print __esc('Cacti');?>';
var spikeKillResults='<?php print __esc('SpikeKill Results');?>';
var showHideFilter='<?php print __esc('Click to Show/Hide Filter');?>';
var clearFilterTitle='<?php print __esc('Clear Current Filter');?>';
var clipboard='<?php print __esc('Clipboard');?>';
var clipboardID='<?php print __esc('Clipboard ID');?>';
var clipboardNotAvailable='<?php print __esc('Copy operation is unavailable at this time');?>';
var clipboardCopyFailed='<?php print __esc('Failed to find data to copy!');?>';
var clipboardUpdated='<?php print __esc('Clipboard has been updated');?>';
var clipboardNotUpdated='<?php print __esc('Sorry, your clipboard could not be updated at this time');?>';
var defaultSNMPSecurityLevel='<?php print read_config_option('snmp_security_level');?>';
var defaultSNMPAuthProtocol='<?php print read_config_option('snmp_auth_protocol');?>';
var defaultSNMPPrivProtocol='<?php print read_config_option('snmp_priv_protocol');?>';
var passwordPass='<?php print __esc('Passphrase length meets 8 character minimum');?>';
var passwordTooShort='<?php print __esc('Passphrase too short');?>';
var passwordMatchTooShort='<?php print __esc('Passphrase matches but too short');?>';
var passwordNotMatchTooShort='<?php print __esc('Passphrase too short and not matching');?>';
var passwordMatch='<?php print __esc('Passphrases match');?>';
var passwordNotMatch='<?php print __esc('Passphrases do not match');?>';
var errorOnPage='<?php print __esc('Sorry, we could not process your last action.');?>';
var errorNumberPrefix='<?php print __esc('Error:');?>';
var errorReasonPrefix='<?php print __esc('Reason:');?>';
var errorReasonTitle='<?php print __esc('Action failed');?>';
var testSuccessful='<?php print __esc('Connection Successful');?>';
var testFailed='<?php print __esc('Connection Failed');?>';
var errorReasonUnexpected='<?php print __esc('The response to the last action was unexpected.');?>';
var mixedReasonTitle='<?php print __esc('Some Actions failed');?>';
var mixedOnPage='<?php print __esc('Note, we could not process all your actions. Details are below.');?>';
var sessionMessageTitle='<?php print __esc('Operation successful');?>';
var sessionMessageSave='<?php print __esc('The Operation was successful. Details are below.');?>';
var sessionMessageOk='<?php print __esc('Ok');?>';
var sessionMessagePause='<?php print __esc('Pause');?>';
var sessionMessageContinue='<?php print __esc('Continue');?>';
var sessionMessageCancel='<?php print __esc('Cancel');?>';
var zoom_i18n_zoom_in='<?php print __esc('Zoom In');?>';
var zoom_i18n_zoom_out='<?php print __esc('Zoom Out');?>';
var zoom_i18n_zoom_out_factor='<?php print __esc('Zoom Out Factor');?>';
var zoom_i18n_timestamps='<?php print __esc('Timestamps');?>';
var zoom_i18n_zoom_2='<?php print __esc('2x');?>';
var zoom_i18n_zoom_4='<?php print __esc('4x');?>';
var zoom_i18n_zoom_8='<?php print __esc('8x');?>';
var zoom_i18n_zoom_16='<?php print __esc('16x');?>';
var zoom_i18n_zoom_32='<?php print __esc('32x');?>';
var zoom_i18n_zoom_out_positioning='<?php print __esc('Zoom Out Positioning');?>';
var zoom_i18n_mode='<?php print __esc('Zoom Mode');?>';
var zoom_i18n_graph='<?php print __esc('Graph');?>';
var zoom_i18n_quick='<?php print __esc('Quick');?>';
var zoom_i18n_advanced='<?php print __esc('Advanced');?>';
var zoom_i18n_newTab='<?php print __esc('Open in new tab');?>';
var zoom_i18n_save_graph='<?php print __esc('Save graph');?>';
var zoom_i18n_copy_graph='<?php print __esc('Copy graph');?>';
var zoom_i18n_copy_graph_link='<?php print __esc('Copy graph link');?>';
var zoom_i18n_on='<?php print __esc('Always On');?>';
var zoom_i18n_auto='<?php print __esc('Auto');?>';
var zoom_i18n_off='<?php print __esc('Always Off');?>';
var zoom_i18n_begin='<?php print __esc('Begin with');?>';
var zoom_i18n_center='<?php print __esc('Center');?>';
var zoom_i18n_end='<?php print __esc('End with');?>';
var zoom_i18n_disabled='<?php print __esc('Disabled');?>';
var zoom_i18n_close='<?php print __esc('Close');?>';
var zoom_i18n_settings='<?php print __esc('Settings');?>';
var zoom_i18n_3rd_button='<?php print __esc('3rd Mouse Button');?>';
</script>
<link href='<?php print $config['url_path']; ?>include/themes/<?php print $selectedTheme;?>/images/favicon.ico' rel='shortcut icon'>
<link href='<?php print $config['url_path']; ?>include/themes/<?php print $selectedTheme;?>/images/cacti_logo.gif' rel='icon' sizes='96x96'>
<?php
print get_md5_include_css('include/themes/' . $selectedTheme .'/jquery.zoom.css');
print get_md5_include_css('include/themes/' . $selectedTheme .'/jquery-ui.css');
print get_md5_include_css('include/themes/' . $selectedTheme .'/default/style.css');
print get_md5_include_css('include/themes/' . $selectedTheme .'/jquery.multiselect.css');
print get_md5_include_css('include/themes/' . $selectedTheme .'/jquery.multiselect.filter.css');
print get_md5_include_css('include/themes/' . $selectedTheme .'/jquery.timepicker.css');
print get_md5_include_css('include/themes/' . $selectedTheme .'/jquery.colorpicker.css');
print get_md5_include_css('include/themes/' . $selectedTheme .'/billboard.css');
print get_md5_include_css('include/themes/' . $selectedTheme .'/pace.css');
print get_md5_include_css('include/themes/' . $selectedTheme .'/Diff.css');
print get_md5_include_css('include/fa/css/fork-awesome.css');
print get_md5_include_css('include/fa/css/v5-compat.css');
print get_md5_include_css('include/vendor/flag-icons/css/flag-icons.css');
print get_md5_include_css('include/themes/' . $selectedTheme .'/main.css');
print get_md5_include_js('include/js/screenfull.js', true);
print get_md5_include_js('include/js/jquery.js');
print get_md5_include_js('include/js/jquery-ui.js');
print get_md5_include_js('include/js/jquery.ui.touch.punch.js', true);
print get_md5_include_js('include/js/jquery.cookie.js');
print get_md5_include_js('include/js/js.storage.js');
print get_md5_include_js('include/js/jstree.js');
print get_md5_include_js('include/js/jquery.hotkeys.js', true);
print get_md5_include_js('include/js/jquery.tablednd.js', true);
print get_md5_include_js('include/js/jquery.zoom.js', true);
print get_md5_include_js('include/js/jquery.multiselect.js');
print get_md5_include_js('include/js/jquery.multiselect.filter.js');
print get_md5_include_js('include/js/jquery.timepicker.js');
print get_md5_include_js('include/js/jquery.colorpicker.js', true);
print get_md5_include_js('include/js/jquery.tablesorter.js');
print get_md5_include_js('include/js/jquery.tablesorter.widgets.js', true);
print get_md5_include_js('include/js/jquery.tablesorter.pager.js', true);
print get_md5_include_js('include/js/jquery.sparkline.js', true);
print get_md5_include_js('include/js/Chart.js', true);
print get_md5_include_js('include/js/dygraph-combined.js', true);
print get_md5_include_js('include/js/d3.js');
print get_md5_include_js('include/js/billboard.js');
print get_md5_include_js('include/layout.js');
print get_md5_include_js('include/js/pace.js');
print get_md5_include_js('include/js/purify.js');
print get_md5_include_js('include/realtime.js');
print get_md5_include_js('include/themes/' . $selectedTheme .'/main.js');
if (isset($path2calendar) && file_exists($path2calendar)) {
print get_md5_include_js($path2calendar);
}
if (isset($path2timepicker) && file_exists($path2timepicker)) {
print get_md5_include_js($path2timepicker);
}
if (isset($path2colorpicker) && file_exists($path2colorpicker)) {
print get_md5_include_js($path2colorpicker);
}
if (isset($path2ms) && file_exists($path2ms)) {
print get_md5_include_js($path2ms);
}
if (isset($path2msfilter) && file_exists($path2msfilter)) {
print get_md5_include_js($path2msfilter);
}
if (file_exists('include/themes/custom.css')) {
print get_md5_include_css('include/themes/custom.css');
}
api_plugin_hook('page_head');
}
function html_help_page($page) {
global $config, $help;
$help = array(
'aggregates.php' => 'Aggregates.html',
'aggregate_templates.php' => 'Aggregate-Templates.html',
'automation_networks.php' => 'Automation-Networks.html',
'cdef.php' => 'CDEFs.html',
'color_templates.php' => 'Color-Templates.html',
'color.php' => 'Colors.html',
'pollers.php' => 'Data-Collectors.html',
'data_debug.php' => 'Data-Debug.html',
'data_input.php' => 'Data-Input-Methods.html',
'data_source_profiles.php' => 'Data-Profiles.html',
'data_queries.php' => 'Data-Queries.html',
'data_templates.php' => 'Data-Source-Templates.html',
'data_sources.php' => 'Data-Sources.html',
'host.php' => 'Devices.html',
'automation_templates.php' => 'Device-Rules.html',
'host_templates.php' => 'Device-Templates.html',
'automation_devices.php' => 'Discovered-Devices.html',
'templates_export.php' => 'Export-Template.html',
'links.php' => 'External-Links.html',
'gprint_presets.php' => 'GPRINTs.html',
'graphs_new.php' => 'Graph-a-Single-SNMP-OID.html',
'graph_view.php' => 'Graph-Overview.html',
'automation_graph_rules.php' => 'Graph-Rules.html',
'graph_templates.php' => 'Graph-Templates.html',
'graph_templates_items.php' => 'Graph-Templates.html',
'graph_templates_inputs.php' => 'Graph-Templates.html',
'graphs.php' => 'Graphs.html',
'templates_import.php' => 'Import-Template.html',
'plugins.php' => 'Plugins.html',
'automation_snmp.php' => 'SNMP-Options.html',
'settings.php:authentication' => 'Settings-Auth.html',
'settings.php:data' => 'Settings-Data.html',
'settings.php:snmp' => 'Settings-Device-Defaults.html',
'settings.php:general' => 'Settings-General.html',
'settings.php:mail' => 'Settings-Mail-Reporting-DNS.html',
'settings.php:path' => 'Settings-Paths.html',
'settings.php:boost' => 'Settings-Performance.html',
'settings.php:poller' => 'Settings-Poller.html',
'settings.php:spikes' => 'Settings-Spikes.html',
'settings.php:visual' => 'Settings-Visual.html',
'sites.php' => 'Sites.html',
'automation_tree_rules.php' => 'Tree-Rules.html',
'tree.php' => 'Trees.html',
'user_domains.php' => 'User-Domains.html',
'user_group_admin.php' => 'User-Group-Management.html',
'user_admin.php' => 'User-Management.html',
'vdef.php' => 'VDEFs.html',
'reports_admin.php' => 'Reports-Admin.html',
'reports_admin.php:details' => 'Reports-Admin.html',
'reports_admin.php:items' => 'Reports-Items.html',
'reports_admin.php:preview' => 'Reports-Preview.html',
'reports_admin.php:events' => 'Reports-Events.html',
'reports_user.php' => 'Reports-User.html',
'reports_user.php:details' => 'Reports-User.html',
'reports_user.php:items' => 'Reports-Items.html',
'reports_user.php:preview' => 'Reports-Preview.html',
'reports_user.php:events' => 'Reports-Events.html',
'clog.php' => 'Cacti-Log.html',
'clog_user.php' => 'Cacti-Log.html',
);
$help = api_plugin_hook_function('help_page', $help);
if (isset($help[$page])) {
return $config['url_path'] . 'docs/' . $help[$page];
}
return false;
}
|