Ejemplo n.º 1
0
 function product_conversion($products = array(), $isFullName = false)
 {
     $converted = array();
     foreach ($products as $product) {
         if ($product['description']) {
             $product['description'] = preg_replace(array("/\r\n|\r|\n/"), array("<br/>"), $product['description']);
         }
         if ($product['specs']) {
             $product['specs'] = preg_replace(array("/\r\n|\r|\n/"), array("<br/>"), $product['specs']);
         }
         if ($product['images']) {
             $product['images'] = explode(",", $product['images']);
             list($file, $ext) = explode(".", $product['images'][0]);
             $filename = FCPATH . 'public/frontend/products/' . $file . '-thumbnail.' . $ext;
             if (file_exists($filename)) {
                 $product['thumbnail'] = $file . '-thumbnail.' . $ext;
             }
         }
         if (!isset($product['url']) || !$product['url']) {
             $product['url'] = generate_url($product['name']) . '-' . $product['id'];
         }
         if (!$isFullName && strlen($product['name']) > 35) {
             $product['name'] = substr($product['name'], 0, 33) . '...';
         }
         $converted[] = $product;
     }
     return $converted;
 }
Ejemplo n.º 2
0
function find_child($components, $parent, $level)
{
    global $vars;
    foreach ($components as $id => $array) {
        if ($array['qos-type'] == 3) {
            continue;
        }
        if ($array['parent'] == $components[$parent]['sp-obj'] && $array['sp-id'] == $components[$parent]['sp-id']) {
            echo "<ul>";
            echo "<li>";
            if ($array['qos-type'] == 1) {
                // Its a policy, we need to make it a link.
                $linkvars = array_merge($vars, array('policy' => $id));
                unset($linkvars['class']);
                echo '<a href="' . generate_url($linkvars) . '">' . $array['label'] . '</a>';
            } elseif ($array['qos-type'] == 2) {
                // Its a class, we need to make it a link.
                echo '<a href="' . generate_url($vars, array('policy' => $parent, 'class' => $id)) . '">' . $array['label'] . '</a>';
            } else {
                // Unknown, no link
                echo $array['label'];
            }
            if (isset($array['match'])) {
                echo ' (' . $array['match'] . ')';
            }
            find_child($components, $id, $level + 1);
            echo "</li>";
            echo "</ul>";
        }
    }
}
Ejemplo n.º 3
0
 public function redirect($controller = null, $action = "default", $params = null)
 {
     if ($controller == null) {
         $controller = $this->getControllerName();
     }
     $redirecturl = generate_url($controller, $action, $params);
     header("Location: {$redirecturl}");
     $this->dontRender();
 }
Ejemplo n.º 4
0
function print_graph_row($graph_array)
{
    global $config;
    if ($_SESSION['widescreen']) {
        if ($_SESSION['big_graphs']) {
            if (!$graph_array['height']) {
                $graph_array['height'] = "110";
            }
            if (!$graph_array['width']) {
                $graph_array['width'] = "353";
            }
            $periods = array('sixhour', 'week', 'month', 'year');
        } else {
            if (!$graph_array['height']) {
                $graph_array['height'] = "110";
            }
            if (!$graph_array['width']) {
                $graph_array['width'] = "215";
            }
            $periods = array('sixhour', 'day', 'week', 'month', 'year', 'twoyear');
        }
    } else {
        if ($_SESSION['big_graphs']) {
            if (!$graph_array['height']) {
                $graph_array['height'] = "100";
            }
            if (!$graph_array['width']) {
                $graph_array['width'] = "323";
            }
            $periods = array('day', 'week', 'month');
        } else {
            if (!$graph_array['height']) {
                $graph_array['height'] = "100";
            }
            if (!$graph_array['width']) {
                $graph_array['width'] = "228";
            }
            $periods = array('day', 'week', 'month', 'year');
        }
    }
    if ($graph_array['shrink']) {
        $graph_array['width'] = $graph_array['width'] - $graph_array['shrink'];
    }
    $graph_array['to'] = $config['time']['now'];
    foreach ($periods as $period) {
        $graph_array['from'] = $config['time'][$period];
        $graph_array_zoom = $graph_array;
        $graph_array_zoom['height'] = "175";
        $graph_array_zoom['width'] = "600";
        $link_array = $graph_array;
        $link_array['page'] = "graphs";
        unset($link_array['height'], $link_array['width']);
        $link = generate_url($link_array);
        echo overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
    }
}
Ejemplo n.º 5
0
function debug_url()
{
    $DEBUG_OUTPUT = DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'url.txt';
    $fh = fopen($DEBUG_OUTPUT, 'a');
    $v = var_export($_GET, TRUE);
    fwrite($fh, str_replace(NEWLINE, BLANK, $v) . NEWLINE);
    fwrite($fh, generate_url() . NEWLINE);
    fclose($fh);
    return 0;
}
Ejemplo n.º 6
0
function generate_page_url($page, $subpage = false, $suffix = false, $return = false)
{
    $append = $subpage !== false ? '&amp;subpage=' . $subpage : '';
    $append .= $suffix !== false ? $suffix : '';
    $url = generate_url('adm/index.php?page=' . $page . $append);
    if ($return) {
        return $url;
    }
    echo $url;
}
Ejemplo n.º 7
0
 public function logout($redirect = '')
 {
     global $config, $db;
     // Kill session
     $sql = 'DELETE FROM ' . SESSIONS_TABLE . ' WHERE session_id = ' . $db->quote($this->sid);
     $db->query($sql);
     if (empty($redirect)) {
         $redirect = generate_url('', '');
     }
     redirect($redirect);
 }
Ejemplo n.º 8
0
function smarty_url_tag($params, $smarty)
{
    global $controller;
    $ctrl = empty($params["controller"]) ? $controller : $params["controller"];
    $act = empty($params["action"]) ? "default" : $params["action"];
    $pars = array();
    foreach ($params as $key => $value) {
        if ($key != "controller" && $key != "action") {
            $pars[$key] = $value;
        }
    }
    return generate_url($ctrl, $act, $pars);
}
Ejemplo n.º 9
0
 private function replaceReferenceWithLink($ref)
 {
     $delim = strpos($ref, "|");
     $title = $delim !== false ? substr($ref, 0, $delim) : $ref;
     $text = $delim !== false ? substr($ref, $delim + 1) : $title;
     $cm = new \Manager\CardsManager();
     $card = $cm->findByTitle($title);
     if ($card == null) {
         return '<a class="createlink" href="' . generate_url("cards", "add", array("title" => $title)) . "\">{$text}</a>";
     } else {
         return '<a href="' . generate_url("cards", "show", array("cardId" => $card->getId())) . "\">{$text}</a>";
     }
 }
Ejemplo n.º 10
0
 /**
  * Executado apos atualizar uma página
  */
 function atualizar_url_filhos($parent_id, $parent_url)
 {
     $filhos = $this->db->select('id, titulo, url')->from($this->table_name)->where('parent_id', $parent_id)->get()->result_array();
     if (!is_array($filhos) || count($filhos) == 0) {
         foreach ($filhos as $pagina) {
             if (strpos($pagina['url'], $parent_url) !== 0) {
                 $alias = generate_url($pagina['titulo']);
                 $separator = $parent_url != '' ? '/' : '';
                 $new_url = $parent_url . $separator . $alias;
                 $this->db->update($this->table_name, array('url' => $new_url), array('id' => $pagina['id']));
                 $this->atualizar_url_filhos($pagina['id'], $new_url);
             }
         }
     }
 }
Ejemplo n.º 11
0
 * @author     Adam Armstrong <*****@*****.**>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
$port['device_id'] = $device['device_id'];
$port['hostname'] = $device['hostname'];
// Process port properties and generate printable values
humanize_port($port);
if (!isset($ports_has_ext['ports_adsl']) || in_array($port['port_id'], $ports_has_ext['ports_adsl'])) {
    $port_adsl = dbFetchRow("SELECT * FROM `ports_adsl` WHERE `port_id` = ?", array($port['port_id']));
}
if ($port['ifInErrors_delta'] > 0 || $port['ifOutErrors_delta'] > 0) {
    $port['tags'] .= generate_port_link($port, '<span class="label label-important">Errors</span>', 'port_errors');
}
if ($port['deleted'] == '1') {
    $port['tags'] .= '<a href="' . generate_url(array('page' => 'deleted-ports')) . '"><span class="label label-important">Deleted</span></a>';
}
if (isset($ports_has_ext['ports_cbqos'])) {
    if (in_array($port['port_id'], $ports_has_ext['ports_cbqos'])) {
        $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'cbqos')) . '"><span class="label label-info">CBQoS</span></a>';
    }
} else {
    if (dbFetchCell("SELECT COUNT(*) FROM `ports_cbqos` WHERE `port_id` = ?", array($port['port_id']))) {
        $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'cbqos')) . '"><span class="label label-info">CBQoS</span></a>';
    }
}
if (isset($ports_has_ext['mac_accounting'])) {
    if (in_array($port['port_id'], $ports_has_ext['mac_accounting'])) {
        $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'macaccounting')) . '"><span class="label label-info">MAC</span></a>';
    }
} else {
Ejemplo n.º 12
0
if (is_file($app_filename)) {
    // Include app code to output data
    include $app_filename;
    // If an $app_sections array has been returned, build a menu
    if (isset($app_sections) && is_array($app_sections)) {
        $navbar['brand'] = nicecase($vars['app']);
        $navbar['class'] = "navbar-narrow";
        foreach ($app_sections as $app_section => $text) {
            // Set the chosen app to be this one if it's not already set.
            if (!$vars['app_section']) {
                $vars['app_section'] = $app_section;
            }
            if ($vars['app_section'] == $app_section) {
                $navbar['options'][$app_section]['class'] = "active";
            }
            $navbar['options'][$app_section]['url'] = generate_url($vars, array('app_section' => $app_section));
            $navbar['options'][$app_section]['text'] = $text;
        }
        print_navbar($navbar);
        unset($navbar);
    } else {
        // It appears this app doesn't have multiple sections. We set app_section to default here.
        $vars['app_section'] = 'default';
    }
    // If a matching app_section array exists within app_graphs, print the graphs.
    if (isset($app_graphs[$vars['app_section']]) && is_array($app_graphs[$vars['app_section']])) {
        echo generate_box_open();
        echo '<table class="table table-striped table-hover  table-condensed">';
        foreach ($app_graphs[$vars['app_section']] as $key => $text) {
            $graph_type = $key;
            $graph_array['to'] = $config['time']['now'];
Ejemplo n.º 13
0
/**
 * Display status alerts.
 *
 * Display pages with alerts about device troubles.
 * Examples:
 * print_status(array('devices' => TRUE)) - display for devices down
 *
 * Another statuses:
 * devices, uptime, ports, errors, services, bgp
 *
 * @param array $status
 * @return none
 *
 */
function print_status($status)
{
    global $config;
    $max_interval = filter_var($status['max']['interval'], FILTER_VALIDATE_INT, array('options' => array('default' => 24, 'min_range' => 1)));
    $max_count = filter_var($status['max']['count'], FILTER_VALIDATE_INT, array('options' => array('default' => 200, 'min_range' => 1)));
    $string = '<table class="table table-bordered table-striped table-hover table-condensed">' . PHP_EOL;
    $string .= '  <thead>' . PHP_EOL;
    $string .= '  <tr>' . PHP_EOL;
    $string .= '    <th>Device</th>' . PHP_EOL;
    $string .= '    <th>Type</th>' . PHP_EOL;
    $string .= '    <th>Status</th>' . PHP_EOL;
    $string .= '    <th>Entity</th>' . PHP_EOL;
    $string .= '    <th>Location</th>' . PHP_EOL;
    $string .= '    <th>Time Since / Information</th>' . PHP_EOL;
    $string .= '  </tr>' . PHP_EOL;
    $string .= '  </thead>' . PHP_EOL;
    $string .= '  <tbody>' . PHP_EOL;
    $query_device_permitted = generate_query_permitted(array('device'), array('device_table' => 'D'));
    $query_port_permitted = generate_query_permitted(array('port'), array('port_table' => 'I'));
    // Show Device Status
    if ($status['devices']) {
        $query = 'SELECT * FROM `devices` AS D';
        $query .= ' WHERE D.`status` = 0' . $query_device_permitted;
        $query .= ' ORDER BY D.`hostname` ASC';
        $entries = dbFetchRows($query);
        foreach ($entries as $device) {
            $string .= '  <tr>' . PHP_EOL;
            $string .= '    <td class="entity">' . generate_device_link($device, short_hostname($device['hostname'])) . '</td>' . PHP_EOL;
            $string .= '    <td><span class="badge badge-inverse">Device</span></td>' . PHP_EOL;
            $string .= '    <td><span class="label label-important">Device Down</span></td>' . PHP_EOL;
            $string .= '    <td>-</td>' . PHP_EOL;
            $string .= '    <td style="white-space: nowrap">' . htmlspecialchars(truncate($device['location'], 30)) . '</td>' . PHP_EOL;
            $string .= '    <td style="white-space: nowrap">' . deviceUptime($device, 'short') . '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
    }
    // Uptime
    if ($status['uptime']) {
        if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) {
            $query = 'SELECT * FROM `devices` AS D';
            $query .= ' WHERE D.`status` = 1 AND D.`uptime` > 0 AND D.`uptime` < ' . $config['uptime_warning'];
            $query .= $query_device_permitted;
            $query .= 'ORDER BY D.`hostname` ASC';
            $entries = dbFetchRows($query);
            foreach ($entries as $device) {
                $string .= '  <tr>' . PHP_EOL;
                $string .= '    <td class="entity">' . generate_device_link($device, short_hostname($device['hostname'])) . '</td>' . PHP_EOL;
                $string .= '    <td><span class="badge badge-inverse">Device</span></td>' . PHP_EOL;
                $string .= '    <td><span class="label label-success">Device Rebooted</span></td>' . PHP_EOL;
                $string .= '    <td>-</td>' . PHP_EOL;
                $string .= '    <td style="white-space: nowrap">' . htmlspecialchars(truncate($device['location'], 30)) . '</td>' . PHP_EOL;
                $string .= '    <td style="white-space: nowrap">Uptime ' . formatUptime($device['uptime'], 'short') . '</td>' . PHP_EOL;
                $string .= '  </tr>' . PHP_EOL;
            }
        }
    }
    // Ports Down
    if ($status['ports'] || $status['links']) {
        // warning about deprecated option: $config['warn']['ifdown']
        if (isset($config['warn']['ifdown']) && !$config['warn']['ifdown']) {
            print_warning("<strong>Config option obsolete</strong>\n                    Please note that config option <strong>\$config['warn']['ifdown']</strong> is now obsolete.\n                    Use options: <strong>\$config['frontpage']['device_status']['ports']</strong> and <strong>\$config['frontpage']['device_status']['errors']</strong>\n                    To remove this message, delete <strong>\$config['warn']['ifdown']</strong> from configuration file.");
        }
        $query = 'SELECT * FROM `ports` AS I ';
        if ($status['links'] && !$status['ports']) {
            $query .= 'INNER JOIN `links` AS L ON I.`port_id` = L.`local_port_id` ';
        }
        $query .= 'LEFT JOIN `devices` AS D ON I.`device_id` = D.`device_id` ';
        $query .= "WHERE I.`ifOperStatus` = 'down' AND I.`ifAdminStatus` = 'up' ";
        if ($status['links'] && !$status['ports']) {
            $query .= ' AND L.`active` = 1 ';
        }
        $query .= $query_port_permitted;
        $query .= ' AND I.`ifLastChange` >= DATE_SUB(NOW(), INTERVAL ' . $max_interval . ' HOUR) ';
        $query .= 'ORDER BY I.`ifLastChange` DESC, D.`hostname` ASC, I.`ifDescr` * 1 ASC ';
        $entries = dbFetchRows($query);
        $i = 1;
        foreach ($entries as $port) {
            if ($i > $max_count) {
                $string .= '  <tr><td></td><td><span class="badge badge-info">Port</span></td>';
                $string .= '<td><span class="label label-important">Port Down</span></td>';
                $string .= '<td colspan=3>Too many ports down. See <strong><a href="' . generate_url(array('page' => 'ports'), array('state' => 'down')) . '">All DOWN ports</a></strong>.</td></tr>' . PHP_EOL;
                break;
            }
            humanize_port($port);
            $string .= '  <tr>' . PHP_EOL;
            $string .= '    <td class="entity">' . generate_device_link($port, short_hostname($port['hostname'])) . '</td>' . PHP_EOL;
            $string .= '    <td><span class="badge badge-info">Port</span></td>' . PHP_EOL;
            $string .= '    <td><span class="label label-important">Port Down</span></td>' . PHP_EOL;
            $string .= '    <td class="entity">' . generate_port_link($port, short_ifname($port['label'])) . '</td>' . PHP_EOL;
            $string .= '    <td style="white-space: nowrap">' . htmlspecialchars(truncate($port['location'], 30)) . '</td>' . PHP_EOL;
            $string .= '    <td style="white-space: nowrap">Down for ' . formatUptime($config['time']['now'] - strtotime($port['ifLastChange']), 'short');
            // This is like deviceUptime()
            if ($status['links'] && !$status['ports']) {
                $string .= ' (' . strtoupper($port['protocol']) . ': ' . $port['remote_hostname'] . ' / ' . $port['remote_port'] . ')';
            }
            $string .= '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
            $i++;
        }
    }
    // Ports Errors (only deltas)
    if ($status['errors']) {
        $query = 'SELECT * FROM `ports` AS I ';
        $query .= 'LEFT JOIN `ports-state` AS E ON I.`port_id` = E.`port_id` ';
        $query .= 'LEFT JOIN `devices` AS D ON I.`device_id` = D.`device_id` ';
        $query .= "WHERE D.`status` = 1 AND I.`ifOperStatus` = 'up' AND I.`ignore` = 0 AND I.`deleted` = 0 AND (E.`ifInErrors_delta` > 0 OR E.`ifOutErrors_delta` > 0)";
        $query .= $query_port_permitted;
        $query .= 'ORDER BY D.`hostname` ASC, I.`ifDescr` * 1 ASC';
        $entries = dbFetchRows($query);
        foreach ($entries as $port) {
            humanize_port($port);
            $string .= '  <tr>' . PHP_EOL;
            $string .= '    <td class="entity">' . generate_device_link($port, short_hostname($port['hostname'])) . '</td>' . PHP_EOL;
            $string .= '    <td><span class="badge badge-info">Port</span></td>' . PHP_EOL;
            $string .= '    <td><span class="label label-important">Port Errors</span></td>' . PHP_EOL;
            $string .= '    <td class="entity">' . generate_port_link($port, short_ifname($port['label']), 'port_errors') . '</td>' . PHP_EOL;
            $string .= '    <td style="white-space: nowrap">' . htmlspecialchars(truncate($port['location'], 30)) . '</td>' . PHP_EOL;
            $string .= '    <td>Errors ';
            if ($port['ifInErrors_delta']) {
                $string .= 'In: ' . $port['ifInErrors_delta'];
            }
            if ($port['ifInErrors_delta'] && $port['ifOutErrors_delta']) {
                $string .= ', ';
            }
            if ($port['ifOutErrors_delta']) {
                $string .= 'Out: ' . $port['ifOutErrors_delta'];
            }
            $string .= '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
    }
    // Services
    if ($status['services']) {
        $query = 'SELECT * FROM `services` AS S ';
        $query .= 'LEFT JOIN `devices` AS D ON S.`device_id` = D.`device_id` ';
        $query .= "WHERE S.`service_status` = 'down' AND S.`service_ignore` = 0";
        $query .= $query_device_permitted;
        $query .= 'ORDER BY D.`hostname` ASC';
        $entries = dbFetchRows($query);
        foreach ($entries as $service) {
            $string .= '  <tr>' . PHP_EOL;
            $string .= '    <td class="entity">' . generate_device_link($service, short_hostname($service['hostname'])) . '</td>' . PHP_EOL;
            $string .= '    <td><span class="badge">Service</span></td>' . PHP_EOL;
            $string .= '    <td><span class="label label-important">Service Down</span></td>' . PHP_EOL;
            $string .= '    <td>' . $service['service_type'] . '</td>' . PHP_EOL;
            $string .= '    <td style="white-space: nowrap">' . htmlspecialchars(truncate($service['location'], 30)) . '</td>' . PHP_EOL;
            $string .= '    <td style="white-space: nowrap">Down for ' . formatUptime($config['time']['now'] - strtotime($service['service_changed']), 'short') . '</td>' . PHP_EOL;
            // This is like deviceUptime()
            $string .= '  </tr>' . PHP_EOL;
        }
    }
    // BGP
    if ($status['bgp']) {
        if (isset($config['enable_bgp']) && $config['enable_bgp']) {
            // Description for BGP states
            $bgpstates = 'IDLE - Router is searching routing table to see whether a route exists to reach the neighbor. &#xA;';
            $bgpstates .= 'CONNECT - Router found a route to the neighbor and has completed the three-way TCP handshake. &#xA;';
            $bgpstates .= 'OPEN SENT - Open message sent, with parameters for the BGP session. &#xA;';
            $bgpstates .= 'OPEN CONFIRM - Router received agreement on the parameters for establishing session. &#xA;';
            $bgpstates .= 'ACTIVE - Router did not receive agreement on parameters of establishment. &#xA;';
            //$bgpstates .= 'ESTABLISHED - Peering is established; routing begins.';
            $query = 'SELECT * FROM `devices` AS D ';
            $query .= 'LEFT JOIN `bgpPeers` AS B ON B.`device_id` = D.`device_id` ';
            $query .= "WHERE (`bgpPeerAdminStatus` = 'start' OR `bgpPeerAdminStatus` = 'running') AND `bgpPeerState` != 'established' ";
            $query .= $query_device_permitted;
            $query .= 'ORDER BY D.`hostname` ASC';
            $entries = dbFetchRows($query);
            foreach ($entries as $peer) {
                $peer_ip = strstr($peer['bgpPeerRemoteAddr'], ':') ? Net_IPv6::compress($peer['bgpPeerRemoteAddr']) : $peer['bgpPeerRemoteAddr'];
                $string .= '  <tr>' . PHP_EOL;
                $string .= '    <td class="entity">' . generate_device_link($peer, short_hostname($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp')) . '</td>' . PHP_EOL;
                $string .= '    <td><span class="badge badge-warning">BGP</span></td>' . PHP_EOL;
                $string .= '    <td><span class="label label-important" title="' . $bgpstates . '">BGP ' . strtoupper($peer['bgpPeerState']) . '</span></td>' . PHP_EOL;
                $string .= '    <td style="white-space: nowrap">' . $peer_ip . '</td>' . PHP_EOL;
                $string .= '    <td style="white-space: nowrap">' . htmlspecialchars(truncate($peer['location'], 30)) . '</td>' . PHP_EOL;
                $string .= '    <td><strong>AS' . $peer['bgpPeerRemoteAs'] . ' :</strong> ' . $peer['astext'] . '</td>' . PHP_EOL;
                $string .= '  </tr>' . PHP_EOL;
            }
        }
    }
    $string .= '  </tbody>' . PHP_EOL;
    $string .= '</table>';
    // Final print all statuses
    echo $string;
}
        </li><!-- End 4 columns container -->

<?php 
}
$packages = dbFetchCell("SELECT COUNT(pkg_id) from `packages`");
if ($packages) {
    ?>

        <li class="dropdown">
          <a href="<?php 
    echo generate_url(array('page' => 'packages'));
    ?>
" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><img src="images/16/box.png" border="0" align="absmiddle" /> Packages<b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li><a href="<?php 
    echo generate_url(array('page' => 'packages'));
    ?>
"><img src="images/16/box.png" border="0" align="absmiddle" /> All Packages</a></li>
          </ul>
        </li>
<?php 
}
# if ($packages)
?>

        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"> Plugins<b class="caret"></b></a>
          <ul class="dropdown-menu">
<?php 
Plugins::call('menu');
?>
Ejemplo n.º 15
0
     $width_div = 438;
 } else {
     $width_div = 393;
 }
 $graph_array = array();
 $graph_array['height'] = 100;
 $graph_array['width'] = 210;
 $graph_array['to'] = $config['time']['now'];
 $graph_array['id'] = $port['port_id'];
 $graph_array['type'] = $graph_type;
 $graph_array['from'] = $config['time']['day'];
 $graph_array['legend'] = 'no';
 $link_array = $graph_array;
 $link_array['page'] = 'graphs';
 unset($link_array['height'], $link_array['width'], $link_array['legend']);
 $link = generate_url($link_array);
 $overlib_content = generate_overlib_content($graph_array, $port['hostname'] . ' - ' . $port['label']);
 $graph_array['title'] = 'yes';
 $graph_array['width'] = $width;
 $graph_array['height'] = 119;
 $graph = generate_lazy_graph_tag($graph_array);
 echo "<div style='display: block; padding: 1px; margin: 2px; min-width: " . $width_div . 'px; max-width:' . $width_div . "px; min-height:180px; max-height:180px; text-align: center; float: left; background-color: #f5f5f5;'>";
 echo overlib_link($link, $graph, $overlib_content);
 echo '</div>';
 // echo("<div style='display: block; padding: 1px; margin: 2px; min-width: 393px; max-width:393px; min-height:180px; max-height:180px; text-align: center; float: left; background-color: #f5f5f5;'>
 // <a href='".generate_port_url($port)."/' onmouseover=\"return overlib('\
 // <div style=\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\'>".$device['hostname']." - ".$port['ifDescr']."</div>\
 // <img src=\'graph.php?type=$graph_type&amp;id=".$port['port_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=450&amp;height=150&amp;title=yes\'>\
 // ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\"  >".
 // "<img src='graph.php?type=$graph_type&amp;id=".$port['port_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=315&amp;height=110&amp;legend=no&amp;title=yes'>
 // </a>
Ejemplo n.º 16
0
 * @author     Adam Armstrong <*****@*****.**>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
$link_array = array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'latency');
$navbar['brand'] = "Latency";
$navbar['class'] = "navbar-narrow";
foreach (array('incoming', 'outgoing') as $view) {
    if (!strlen($vars['view'])) {
        $vars['view'] = $view;
    }
    if (count($smokeping_files[$view][$device['hostname']])) {
        if ($vars['view'] == $view) {
            $navbar['options'][$view]['class'] = "active";
        }
        $navbar['options'][$view]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'latency', 'view' => $view));
        $navbar['options'][$view]['text'] = ucwords($view);
    }
}
print_navbar($navbar);
echo '<table class="table table-striped">';
if ($vars['view'] == "incoming") {
    if (count($smokeping_files['incoming'][$device['hostname']])) {
        $graph_array['type'] = "device_smokeping_in_all_avg";
        $graph_array['device'] = $device['device_id'];
        echo '<tr><td>';
        echo '<h3>Average</h3>';
        print_graph_row($graph_array);
        echo '</td></tr>';
        $graph_array['type'] = "device_smokeping_in_all";
        $graph_array['legend'] = 'no';
Ejemplo n.º 17
0
<?php 
    $sorts = array('device' => 'Device', 'port' => 'Port', 'speed' => 'Speed', 'traffic' => 'Traffic', 'traffic_in' => 'Traffic In', 'traffic_out' => 'Traffic Out', 'packets' => 'Packets', 'packets_in' => 'Packets In', 'packets_out' => 'Packets Out', 'errors' => 'Errors', 'media' => 'Media', 'descr' => 'Description');
    foreach ($sorts as $sort => $sort_text) {
        echo '<option value="' . $sort . '" ';
        if ($vars['sort'] == $sort) {
            echo "selected";
        }
        echo '>' . $sort_text . '</option>';
    }
    ?>

        </select>
      </div>
      <button type="submit" class="btn btn-default btn-sm">Search</button>
      <a class="btn btn-default btn-sm" href="<?php 
    echo generate_url(array('page' => 'ports', 'section' => $vars['section'], 'bare' => $vars['bare']));
    ?>
" title="Reset critera to default." >Reset</a>
      </td>
    </form>
  </tr>
</table>

<?php 
}
print_optionbar_end();
$param = array();
if (!isset($vars['ignore'])) {
    $vars['ignore'] = "0";
}
if (!isset($vars['disabled'])) {
Ejemplo n.º 18
0
                         $map .= "\"" . $sif['port_id'] . "\" [label=\"" . $sif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"" . generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'port', 'port' => $local_port_id)) . "\"]\n";
                         if (!$ifdone[$src][$sif['port_id']]) {
                             $map .= "\"{$src}\" -> \"" . $sif['port_id'] . "\" [weight=500000, arrowsize=0, len=0];\n";
                             $ifdone[$src][$sif['port_id']] = 1;
                         }
                         if ($dst_host) {
                             $map .= "\"{$dst}\" [URL=\"" . generate_url(array('page' => 'device', 'device' => $dst_host, 'tab' => 'ports', 'view' => 'map')) . "\", fontsize=20, shape=box3d]\n";
                         } else {
                             $map .= "\"{$dst}\" [ fontsize=20 shape=box3d]\n";
                         }
                         if ($dst_host == $device['device_id'] || !is_numeric($device['device_id'])) {
                             $map .= "\"" . $dif['port_id'] . "\" [label=\"" . $dif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"" . generate_url(array('page' => 'device', 'device' => $dst_host, 'tab' => 'port', 'port' => $remote_port_id)) . "\"]\n";
                         } else {
                             $map .= "\"" . $dif['port_id'] . "\" [label=\"" . $dif['label'] . " \", fontsize=12, fillcolor=lightgray";
                             if ($dst_host) {
                                 $map .= ", URL=\"" . generate_url(array('page' => 'device', 'device' => $dst_host, 'tab' => 'port', 'port' => $remote_port_id)) . "\"";
                             }
                             $map .= "]\n";
                         }
                         if (!$ifdone[$dst][$dif['port_id']]) {
                             $map .= "\"" . $dif['port_id'] . "\" -> \"{$dst}\" [weight=500000, arrowsize=0, len=0];\n";
                             $ifdone[$dst][$dif['port_id']] = 1;
                         }
                         $map .= "\"" . $sif['port_id'] . "\" -> \"" . $dif['port_id'] . "\" [weight=1, arrowhead=normal, arrowtail=normal, len=2, {$info}] \n";
                     }
                 }
             }
             $done = 0;
         }
     }
 }
$type_text['loadbalancer_vservers'] = "Serverfarms";
// Citrix Netscaler
$type_text['netscaler_vsvr'] = "VServers";
$type_text['netscaler_services'] = "Services";
$page_title[] = "Load Balancer";
$navbar['brand'] = "Load Balancer";
$navbar['class'] = "navbar-narrow";
foreach ($loadbalancer_tabs as $type) {
    if (!$vars['type']) {
        $vars['type'] = $type;
    }
    if ($vars['type'] == $type) {
        $navbar['options'][$type]['class'] = "active";
    }
    $navbar['options'][$type]['text'] = $type_text[$type] . " (" . $device_loadbalancer_count[$type] . ")";
    $navbar['options'][$type]['url'] = generate_url($link_array, array('type' => $type));
}
print_navbar($navbar);
unset($navbar);
if (is_file("pages/device/loadbalancer/" . $vars['type'] . ".inc.php")) {
    include "pages/device/loadbalancer/" . $vars['type'] . ".inc.php";
} else {
    foreach ($loadbalancer_tabs as $type) {
        if ($type != "overview") {
            if (is_file("pages/device/loadbalancer/overview/{$type}.inc.php")) {
                $g_i++;
                if (!is_integer($g_i / 2)) {
                    $row_colour = $list_colour_a;
                } else {
                    $row_colour = $list_colour_b;
                }
 <button type="button" class="close" data-dismiss="alert">×</button>
 <div class="pull-left" style="padding:0 5px 0 0"><i class="oicon-information"></i></div>
 <h4>添加分组</h4>';
 foreach (array('entity_type', 'group_name', 'group_descr', 'assoc_device_conditions', 'assoc_entity_conditions') as $var) {
     if (!isset($vars[$var]) || strlen($vars[$var]) == '0') {
         echo "Missing required data.</div>";
         break 2;
     }
 }
 $group_array = array();
 $group_array['entity_type'] = $vars['entity_type'];
 $group_array['group_name'] = $vars['group_name'];
 $group_array['group_descr'] = $vars['group_descr'];
 $group_id = dbInsert('groups', $group_array);
 if (is_numeric($group_id)) {
     echo '<p>分组已创建为ID <a href="' . generate_url(array('page' => 'group', 'group_id' => $group_id)) . '">' . $group_id . '</a></p>';
     $assoc_array = array();
     $assoc_array['group_id'] = $group_id;
     $assoc_array['entity_type'] = $vars['entity_type'];
     $dev_conds = array();
     foreach (explode("\n", $vars['assoc_device_conditions']) as $cond) {
         list($this['attrib'], $this['condition'], $this['value']) = explode(" ", trim($cond), 3);
         $dev_conds[] = $this;
     }
     $assoc_array['device_attribs'] = json_encode($dev_conds);
     if ($vars['assoc_device_conditions'] == "*") {
         $vars['assoc_device_conditions'] = json_encode(array());
     }
     $ent_conds = array();
     foreach (explode("\n", $vars['assoc_entity_conditions']) as $cond) {
         list($this['attrib'], $this['condition'], $this['value']) = explode(" ", trim($cond), 3);
Ejemplo n.º 21
0
$export_device = $device;
if ($config['snmp']['hide_auth']) {
    $params = array('snmp_community', 'snmp_authlevel', 'snmp_authname', 'snmp_authpass', 'snmp_authalgo', 'snmp_cryptopass', 'snmp_cryptoalgo');
    foreach ($params as $param) {
        if (strlen($export_device[$param])) {
            $export_device[$param] = '***';
        }
    }
}
if ($vars['saveas'] == 'yes' && $vars['filename']) {
    download_as_file(gzencode(_json_encode($export_device)), $vars['filename']);
} else {
    if ($config['snmp']['hide_auth']) {
        print_warning("NOTE, <strong>\$config['snmp']['hide_auth']</strong> is set to <strong>TRUE</strong>, snmp community and snmp v3 auth hidden from output and export.");
    } else {
        print_error("WARNING, <strong>\$config['snmp']['hide_auth']</strong> is set to <strong>FALSE</strong>, snmp community and snmp v3 auth <strong>NOT hidden</strong> from output and export.");
    }
    $form = array('type' => 'rows', 'space' => '10px', 'url' => generate_url($vars));
    // Filename
    $form['row'][0]['filename'] = array('type' => 'text', 'name' => 'Filename', 'value' => $device['hostname'] . '.json.txt.gz', 'width' => '100%', 'placeholder' => TRUE);
    // Compress
    //$form['row'][0]['compress'] = array(
    //                                'type'        => 'switch',
    //                                'value'       => 1);
    // Search button
    $form['row'][0]['saveas'] = array('type' => 'submit', 'name' => 'Export', 'icon' => 'icon-save', 'right' => TRUE, 'value' => 'yes');
    print_form($form);
    r($export_device);
}
unset($export_device, $params, $param);
// EOF
Ejemplo n.º 22
0
<?php

$pagetitle[] = "Add a new bill";
$links['this'] = generate_url($vars);
$links['bills'] = generate_url(array('page' => 'bills'));
?>

<div class="tabBox">
  <ul class="nav nav-tabs" id="addBillTab">
    <li class="active"><a href="#properties" data-toggle="tab">Bill Properties</a></li>
<?php 
if ($_SESSION['userlevel'] == "10") {
    if (is_numeric($vars['port'])) {
        $port = dbFetchRow("SELECT * FROM `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id", array($vars['port']));
        echo "    <li><a href=\"#ports\" data-toggle=\"tab\">Billed Ports</a></li>\n";
    }
    ?>
  </ul>
  <div class="tabcontent tab-content" id="addBillTabContent" style="min-height: 50px; padding-bottom: 18px;">
    <div class="tab-pane fade active in" id="properties">
      <form name="form1" method="post" action="<?php 
    echo $links['bills'];
    ?>
" class="form-horizontal">
        <input type="hidden" name="addbill" value="yes">
        <script type="text/javascript">
          function billType() {
            $('#cdrDiv').toggle();
            $('#quotaDiv').toggle();
          }
        </script>
Ejemplo n.º 23
0
function generate_ap_url($ap, $vars = array())
{
    return generate_url(array('page' => 'device', 'device' => $ap['device_id'], 'tab' => 'accesspoint', 'ap' => $ap['accesspoint_id']), $vars);
}
Ejemplo n.º 24
0
/** 
 * LEGACY alias for generate_url, defaults to relative now
 * @deprecated
 */
function find_url($slug, $parent = '', $type = null)
{
    // parent is ignored
    if (!isset($type)) {
        if (!getDef('GSSITEURLREL', true)) {
            $type = "full";
        } else {
            $type = "relative";
        }
    }
    return generate_url($slug, $type == 'full');
}
Ejemplo n.º 25
0
    }
    print " </result>\n";
    print "</response>";
}
$link_array = array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'collectd');
$plugins = collectd_list_plugins($device['hostname']);
#$navbar['brand'] = "CollectD";
$navbar['class'] = "navbar-narrow";
foreach ($plugins as &$plugin) {
    if (!$vars['plugin']) {
        $vars['plugin'] = $plugin;
    }
    if ($vars['plugin'] == $plugin) {
        $navbar['options'][$plugin]['class'] = "active";
    }
    $navbar['options'][$plugin]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'collectd', 'plugin' => $plugin));
    $navbar['options'][$plugin]['text'] = htmlspecialchars(ucwords($plugin));
}
print_navbar($navbar);
echo '<table class="table table-bordered table-condensed table-striped table-hover">';
$i = 0;
$pinsts = collectd_list_pinsts($device['hostname'], $vars['plugin']);
foreach ($pinsts as &$instance) {
    $types = collectd_list_types($device['hostname'], $vars['plugin'], $instance);
    foreach ($types as &$type) {
        $typeinstances = collectd_list_tinsts($device['hostname'], $vars['plugin'], $instance, $type);
        if ($MetaGraphDefs[$type]) {
            $typeinstances = array($MetaGraphDefs[$type]);
        }
        foreach ($typeinstances as &$tinst) {
            $i++;
Ejemplo n.º 26
0
                     <a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '">
                         <div class="service-availability ' . $serviceState . '" style="width:' . $config['webui']['availability_map_direct_tile_size'] . 'px;">
                             <span class="service-name-label label ' . $serviceLabel . ' label-font-border">' . $service["service_type"] . '</span>
                             <span class="availability-label label ' . $serviceLabel . ' label-font-border">' . $serviceState . '</span>
                             <span class="device-icon">' . $deviceIcon . '</span><br>
                             <span class="small">' . shorthost(ip_to_sysname($service, $service['hostname'])) . '</span>
                         </div>
                     </a>';
                 } else {
                     $temp_output[] = '
                     <a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '">
                         <span class="label ' . $serviceLabel . ' widget-availability label-font-border">' . $service['service_type'] . ' - ' . $serviceState . '</span>
                     </a>';
                 }
             } else {
                 $temp_output[] = '<a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service['hostname'] . " - " . $service['service_type'] . " - " . $service['service_desc'] . '"><div class="' . $serviceLabelOld . '" style="width:' . $compact_tile . 'px;"></div></a>';
             }
         }
     } else {
         $temp_output[] = '';
     }
 }
 if ($directpage == "yes") {
     $temp_header[] = '
     <div class="page-availability-title-left">
         <span class="page-availability-title">Availability map for</span>
         <select id="mode" class="page-availability-report-select" name="mode">';
     if ($config['show_services'] == 0) {
         $temp_header[] = '<option value="0" selected>only devices</option>';
     } else {
         foreach ($select_modes as $mode_select => $option) {
Ejemplo n.º 27
0
    </tr>
  </thead>
  <tbody>', PHP_EOL;
foreach (get_type_groups($vars['entity_type']) as $group) {
    $group['member_count'] = dbFetchCell("SELECT COUNT(*) FROM `group_table` WHERE `group_id` = ?", array($group['group_id']));
    $entity_type = $config['entities'][$group['entity_type']];
    echo '<tr class="' . $group['html_row_class'] . '">';
    echo '
    <td style="width: 1px; background-color: #194b7f; margin: 0px; padding: 0px"></td>
    <td style="width: 1px;"></td>';
    // Print the conditions applied by this alert
    echo '<td><strong>';
    echo $group['group_id'];
    echo '</strong></td>';
    echo '<td><strong>';
    echo '<a href="', generate_url(array('page' => 'group', 'group_id' => $group['group_id'])), '">' . $group['group_name'] . '</a></strong><br />';
    echo '<i>', $group['group_descr'], '</i>';
    echo '</td>';
    // Print the count of entities this alert applies to and a popup containing a list and Print breakdown of entities by status.
    // We assume each row here is going to be two lines, so we just <br /> them.
    echo '<td>';
    echo '<i>' . $group['member_count'] . '</i><br />';
    echo '<i class="' . $entity_type['icon'], '"></i> ', nicecase($group['entity_type']);
    echo '</td>';
    echo '<td>';
    echo '<table class="table table-condensed-more table-bordered table-striped table-rounded" style="margin-bottom: 0px;">';
    // Loop the associations which link this alert to this device
    foreach ($group_assoc[$group['group_id']] as $assoc_id => $assoc) {
        echo '<tr>';
        echo '<td style="width: 50%;">';
        if (is_array($assoc['device_attribs'])) {
Ejemplo n.º 28
0
<?php

if (!isset($vars['section'])) {
    $vars['section'] = 'eventlog';
}
$sections = array('eventlog', 'syslog');
$navbar['brand'] = "Logging";
$navbar['class'] = "navbar-narrow";
foreach ($sections as $section) {
    $type = strtolower($section);
    if (!isset($vars['section'])) {
        $vars['section'] = $section;
    }
    if ($vars['section'] == $section) {
        $navbar['options'][$section]['class'] = "active";
    }
    $navbar['options'][$section]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'logs', 'section' => $section));
    $navbar['options'][$section]['text'] = nicecase($section);
}
print_navbar($navbar);
switch ($vars['section']) {
    case 'syslog':
    case 'eventlog':
        include 'pages/device/logs/' . $vars['section'] . '.inc.php';
        break;
    default:
        echo '<h2>Error. No section ' . $vars['section'] . '.<br /> Please report this to observium developers.</h2>';
        break;
}
Ejemplo n.º 29
0
function show_micrographs($config)
{
    if ($_SESSION['userlevel'] >= '5' && $config['frontpage']['micrographs'] != '') {
        $width = $config['frontpage']['micrograph_settings']['width'];
        $height = $config['frontpage']['micrograph_settings']['height'];
        echo generate_box_open();
        echo '<div class="row">';
        echo '  <div class="col-sm-12">';
        echo '  <table class="box box-solid table  table-condensed-more table-rounded">';
        echo '    <tbody>';
        foreach ($config['frontpage']['micrographs'] as $row) {
            $micrographs = explode(';', $row['ids']);
            $legend = $row['legend'] == false ? 'no' : 'yes';
            echo '    <tr>';
            if ($row['title']) {
                echo '      <th style="vertical-align: middle;">' . $row['title'] . '</th>';
            }
            echo '      <td>';
            foreach ($micrographs as $graph) {
                if (!$graph) {
                    continue;
                }
                // Skip empty graphs from excess semicolons
                list($device, $type, $header) = explode(',', $graph, 3);
                if (strpos($type, 'device') === false) {
                    $which = 'id';
                    if (strpos($type, 'multi') !== false) {
                        $links = generate_url(array('page' => 'graphs', 'type' => $type, 'id' => urldecode($device)));
                    } else {
                        $links = generate_url(array('page' => 'graphs', 'type' => $type, 'id' => $device));
                    }
                } else {
                    $which = 'device';
                    $links = generate_url(array('page' => 'graphs', 'type' => $type, 'device' => $device));
                }
                echo '<div class="pull-left">';
                if ($header) {
                    echo '<p style="text-align: center; margin-bottom: 0px;">' . $header . '</p>';
                }
                echo '<a href="' . $links . '" style="margin-left: 5px"><img src="graph.php?type=' . $type . '&amp;' . $which . '=' . $device . '&amp;legend=' . $legend . '&amp;width=' . $width . '&amp;height=' . $height . '"/></a>';
                echo '</div>';
            }
            unset($links);
            echo '      </td>';
            echo '    </tr>';
        }
        echo '    </tbody>';
        echo '  </table>';
        echo '  </div>';
        echo '</div>';
        echo generate_box_close();
    }
}
Ejemplo n.º 30
0
    #  if (strlen($mplug['mplug_category']) == 0) { $mplug['mplug_category'] = "general"; } else {  }
    $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['id'] = $mplug['mplug_id'];
    $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['title'] = $mplug['mplug_title'];
    $graph_enable[$mplug['mplug_category']][$mplug['mplug_type']]['plugin'] = $mplug['mplug_type'];
}
$navbar['class'] = "navbar-narrow";
foreach ($graph_enable as $section => $nothing) {
    if (isset($graph_enable) && is_array($graph_enable[$section])) {
        $type = strtolower($section);
        if (!$vars['group']) {
            $vars['group'] = $type;
        }
        if ($vars['group'] == $type) {
            $navbar['options'][$type]['class'] = "active";
        }
        $navbar['options'][$type]['url'] = generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'munin', 'group' => $type));
        $navbar['options'][$type]['text'] = htmlspecialchars(ucwords($section));
    }
}
print_navbar($navbar);
$graph_enable = $graph_enable[$vars['group']];
#foreach ($config['graph_types']['device'] as $graph => $entry)
foreach ($graph_enable as $graph => $entry) {
    $graph_array = array();
    if ($graph_enable[$graph]) {
        if (!empty($entry['plugin'])) {
            $graph_title = $entry['title'];
            $graph_array['type'] = "munin_graph";
            $graph_array['device'] = $device['device_id'];
            $graph_array['plugin'] = $entry['plugin'];
        } else {