示例#1
0
/**
 * @file guifi_gml.inc.php
 */
function guifi_gml($zid, $action = "help", $type = 'gml')
{
    if ($action == "help") {
        $zone = db_fetch_object(db_query('SELECT title, nick FROM {guifi_zone} WHERE id = %d', $zid));
        drupal_set_breadcrumb(guifi_zone_ariadna($zid));
        $output = '<div id="guifi">';
        $output .= '<h2>' . t('Zone %zname%', array('%zname%' => $zone->title)) . '</h2>';
        $output .= '<p>' . t('You must specify which data do you want to export, the following options are available:') . '</p>';
        $output .= '<ol><li>' . l(t('Nodes'), "guifi/gml/" . $zid . "/nodes", array('title' => t('export zone nodes in gml format'))) . '</li>';
        $output .= '<li>' . l(t('Links'), "guifi/gml/" . $zid . "/links", array('title' => t('export zone links in gml format'))) . '</li></ol>';
        $output .= '<p>' . t('The <a href="http://opengis.net/gml/">GML</a> is a Markup Language XML for Geography described at the <a href="http://www.opengeospatial.org/">Open Geospatial Consortium</a>') . '</p>';
        $output .= '<p>' . t('<b>IMPORTANT LEGAL NOTE:</b> This network information is under the <a href="http://guifi.net/ComunsSensefils/">Comuns Sensefils</a> license, and therefore, available for any other network under the same licensing. If is not your case, you should ask for permission before using it.</a>') . '</p>';
        $output .= "</div>";
        print theme('page', $output, t('export %zname% in GML format', array('%zname%' => $z->title)));
        return;
    }
    switch ($action) {
        case 'links':
            guifi_gml_links($zid, $type);
            break;
        case 'nodes':
            guifi_gml_nodes($zid, $type);
            break;
    }
}
示例#2
0
/**
 *
 * @param $cnmlid
 *
 * @param $action
 *
 * @return
 */
function guifi_cnml($cnmlid, $action = 'help')
{
    guifi_log(GUIFILOG_TRACE, 'function guifi_cnml()', $cnmlid);
    if (!is_numeric($cnmlid)) {
        return;
    }
    if ($action == "help") {
        $zone = db_fetch_object(db_query('SELECT title, nick ' . 'FROM {guifi_zone} ' . 'WHERE id = %d', $cnmlid));
        drupal_set_breadcrumb(guifi_zone_ariadna($cnmlid));
        $output = '<div id="guifi">';
        $output .= '<h2>' . t('Zone %zname%', array('%zname%' => $zone->title)) . '</h2>';
        $output .= '<p>' . t('You must specify which data do you want to export, the following options are available:') . '</p>';
        $output .= '<ol><li>' . l(t('Zones'), "guifi/cnml/" . $cnmlid . "/zones", array('title' => t('export zone and zone childs in CNML format'))) . '</li>';
        $output .= '<li>' . l(t('Zones and nodes'), "guifi/cnml/" . $cnmlid . "/nodes", array('title' => t('export zones and nodes in CNML format (short)'))) . '</li>';
        $output .= '<li>' . l(t('Detailed'), "guifi/cnml/" . $cnmlid . "/detail", array('title' => t('export zones, nodes and devices in CNML format (long)'))) . '</li></ol>';
        $output .= '<p>' . t('The <b>C</b>ommunity <b>N</b>etwork <b>M</b>arkup <b>L</b>anguage (<a href="' . base_path() . 'node/3521">CNML</a>) is a XML format to interchange network information between services or servers.') . '</p>';
        $output .= '<p>' . t('<b>IMPORTANT LEGAL NOTE:</b> This network information is under the <a href="http://guifi.net/ComunsSensefils/">Comuns Sensefils</a> license, and therefore, available for any other network under the same licensing. If is not your case, you should ask for permission before using it.</a>') . '</p>';
        $output .= "</div>";
        print theme('page', $output, t('export %zname% in CNML format', array('%zname%' => $z->title)));
        exit;
    }
    function links($iid, $iipv4_id, $ident, $nl)
    {
        $links->count = 0;
        $links->xml = "";
        $qlinks = db_query("SELECT l2.* FROM {guifi_links} l1 LEFT JOIN {guifi_links} l2 ON l1.id=l2.id WHERE l1.device_id<>l2.device_id AND l1.interface_id=%d AND l1.ipv4_id=%d", $iid, $iipv4_id);
        while ($l = db_fetch_object($qlinks)) {
            $links->count++;
            $links->xml .= xmlopentag($ident, 'link', array('id' => $l->id, 'linked_device_id' => $l->device_id, 'linked_node_id' => $l->nid, 'linked_interface_id' => $l->interface_id, 'link_type' => $l->link_type, 'link_status' => $l->flag));
            $links->xml .= xmlclosetag($ident, 'link', $nl);
        }
        return $links->xml;
    }
    global $base_url;
    // load nodes and zones in memory for faster execution
    switch ($action) {
        case 'zones':
        case 'nodes':
        case 'detail':
            $tree = guifi_cnml_tree($cnmlid);
            $sql_devices = 'SELECT * FROM {guifi_devices} d';
            $sql_radios = 'SELECT * FROM {guifi_radios} r ORDER BY r.radiodev_counter ASC';
            $sql_interfaces = 'SELECT i.*,a.ipv4,a.id ipv4_id, a.netmask FROM {guifi_interfaces} i, {guifi_ipv4} a WHERE i.id=a.interface_id';
            $sql_links = 'SELECT l1.id, l1.device_id, l1.interface_id, l1.ipv4_id, l2.device_id linked_device_id, l2.nid linked_node_id, l2.interface_id linked_interface_id, l2.ipv4_id linked_radiodev_counter, l1.link_type, l1.flag status FROM {guifi_links} l1, {guifi_links} l2 WHERE l1.id=l2.id AND l1.device_id != l2.device_id';
            $sql_services = 'SELECT s.* FROM {guifi_services} s';
            break;
        case 'node':
            $qnode = db_query(sprintf('SELECT l.*,r.body body ' . 'FROM {guifi_location} l, {node} n, {node_revisions} r ' . 'WHERE l.id=n.nid AND n.vid=r.vid ' . '  AND l.id in (%s)', $cnmlid));
            while ($node = db_fetch_object($qnode)) {
                $tree[] = $node;
            }
            $sql_devices = sprintf('SELECT * FROM {guifi_devices} d WHERE nid in (%s)', $cnmlid);
            $sql_radios = sprintf('SELECT r.* FROM {guifi_radios} r, {guifi_devices} d WHERE d.nid in (%s) AND d.id=r.id ORDER BY r.radiodev_counter ASC', $cnmlid);
            $sql_interfaces = sprintf('SELECT i.*,a.ipv4,a.id ipv4_id, a.netmask FROM {guifi_devices} d, {guifi_interfaces} i, {guifi_ipv4} a WHERE d.nid in (%s) AND d.id=i.device_id AND i.id=a.interface_id', $cnmlid);
            $sql_links = sprintf('SELECT l1.id, l1.device_id, l1.interface_id, l1.ipv4_id, l2.device_id linked_device_id, l2.nid linked_node_id, l2.interface_id linked_interface_id, l2.ipv4_id linked_radiodev_counter, l1.link_type, l1.flag status FROM {guifi_links} l1, {guifi_links} l2 WHERE l1.nid in (%s) AND l1.id=l2.id AND l1.device_id != l2.device_id', $cnmlid);
            $sql_services = sprintf('SELECT s.*, r.body FROM {guifi_devices} d, {guifi_services} s, {node} n, {node_revisions} r WHERE d.nid in (%s) AND d.id=s.device_id AND n.nid=s.id AND n.vid=r.vid', $cnmlid);
            break;
        case 'nodecount':
            $CNML = fnodecount($cnmlid);
            print_pretty_CNML($CNML);
            return;
            break;
        case 'ips':
            $CNML = dump_guifi_ips();
            print_pretty_CNML($CNML);
            return;
            break;
        case 'ospfnet':
            //http://guifi.net/guifi/cnml/NNNN/ospfnet    NNNN = node id OSPF zone
            $CNML = ospf_net($cnmlid);
            print_pretty_CNML($CNML);
            return;
            break;
        case 'domains':
            $CNML = dump_guifi_domains($cnmlid, $action);
            print_pretty_CNML($CNML);
            return;
            break;
        case 'plot':
            plot_guifi();
            return;
            break;
        case 'growthmap':
            //http://guifi.net/guifi/cnml/0/growthmap?lat1=1.23&lon1=2.34&lat2=1.22&lon2=2.23
            $json = growth_map($_GET["lat1"], $_GET["lon1"], $_GET["lat2"], $_GET["lon2"]);
            //drupal_set_header('Content-Type: application/xml; charset=utf-8');
            echo $json;
            return;
            break;
        case 'home':
            $CNML = guifi_cnml_home($cnmlid);
            print_pretty_CNML($CNML);
            return;
            break;
    }
    // load devices in memory for faster execution
    global $devices;
    $qdevices = db_query($sql_devices);
    while ($device = db_fetch_object($qdevices)) {
        $devices[$device->nid][$device->id] = $device;
    }
    // load radios in memory for faster execution
    global $radios;
    $qradios = db_query($sql_radios);
    while ($radio = db_fetch_object($qradios)) {
        $radios[$radio->nid][$radio->id][$radio->radiodev_counter] = $radio;
    }
    // load interfaces in memory for faster execution
    global $interfaces;
    $qinterfaces = db_query($sql_interfaces);
    while ($interface = db_fetch_object($qinterfaces)) {
        $interfaces[$interface->device_id][$interface->radiodev_counter][$interface->interface_id][] = $interface;
    }
    // load links in memory for faster execution
    global $links;
    $qlinks = db_query($sql_links);
    while ($link = db_fetch_object($qlinks)) {
        $links[$link->device_id][$link->interface_id][$link->id] = $link;
    }
    // load services in memory for faster execution
    global $services;
    $qservices = db_query($sql_services);
    while ($service = db_fetch_object($qservices)) {
        $services[$service->device_id][$service->id] = $service;
    }
    // load radio models in memory for faster execution
    global $models;
    $qmodel = db_query("SELECT mid, fid, model FROM guifi_model_specs ORDER BY mid");
    while ($model = db_fetch_object($qmodel)) {
        $models[$model->mid] = $model->model;
    }
    // print_r($models);
    //  print_r($tree);
    function _add_cnml_node(&$CNML, $node, &$summary, $action)
    {
        global $devices;
        global $radios;
        global $interfaces;
        global $links;
        global $services;
        global $models;
        $nodesummary->ap = 0;
        $nodesummary->client = 0;
        $nodesummary->devices = 0;
        $nodesummary->services = 0;
        $nodesummary->links = 0;
        if ($action != 'zones') {
            //      $nodeXML = $CNML->addChild('node',htmlspecialchars($node->body,ENT_QUOTES));
            $nodeXML = $CNML->addChild('node');
            foreach ($node as $key => $value) {
                if ($value) {
                    switch ($key) {
                        case 'body':
                            break;
                        case 'id':
                            $nodeXML->addAttribute('id', $value);
                            break;
                        case 'nick':
                            $nodeXML->addAttribute('title', $value);
                            break;
                        case 'lat':
                            $nodeXML->addAttribute('lat', $value);
                            break;
                        case 'lon':
                            $nodeXML->addAttribute('lon', $value);
                            break;
                        case 'elevation':
                            if ($value) {
                                $nodeXML->addAttribute('antenna_elevation', $value);
                            }
                            break;
                        case 'status_flag':
                            $nodeXML->addAttribute('status', $value);
                            break;
                        case 'graph_server':
                            $nodeXML->addAttribute('graph_server', $value);
                            break;
                        case 'timestamp_created':
                            $nodeXML->addAttribute('created', date('Ymd hi', $value));
                            break;
                        case 'timestamp_changed':
                            $nodeXML->addAttribute('updated', date('Ymd hi', $value));
                            break;
                    }
                }
            }
        }
        $summary->nodes++;
        if ($node->lon < $summary->minx) {
            $summary->minx = $node->lon;
        }
        if ($node->lat < $summary->miny) {
            $summary->miny = $node->lat;
        }
        if ($node->lon > $summary->maxx) {
            $summary->maxx = $node->lon;
        }
        if ($node->lat > $summary->maxy) {
            $summary->maxy = $node->lat;
        }
        // if report type = 'detail', going to list all node content
        // devices
        if (is_array($devices[$node->id])) {
            if (count($devices[$node->id])) {
                foreach ($devices[$node->id] as $id => $device) {
                    if ($action == 'detail') {
                        $deviceXML = $nodeXML->addChild('device', htmlspecialchars($device->comment, ENT_QUOTES));
                        foreach ($device as $key => $value) {
                            if ($value) {
                                switch ($key) {
                                    case 'body':
                                        comment;
                                    case 'id':
                                        $main_ip = guifi_main_ip($value);
                                        $deviceXML->addAttribute('id', $value);
                                        $deviceXML->addAttribute('mainipv4', $main_ip[ipv4]);
                                        break;
                                    case 'nick':
                                        $deviceXML->addAttribute('title', $value);
                                        break;
                                    case 'type':
                                        $deviceXML->addAttribute('type', $value);
                                        break;
                                    case 'flag':
                                        $deviceXML->addAttribute('status', $value);
                                        break;
                                    case 'graph_server':
                                        $deviceXML->addAttribute('graph_server', $value);
                                        break;
                                    case 'timestamp_created':
                                        $deviceXML->addAttribute('created', date('Ymd hi', $value));
                                        break;
                                    case 'timestamp_changed':
                                        $deviceXML->addAttribute('updated', date('Ymd hi', $value));
                                        break;
                                        // case 'mainipv4': $deviceXML->addAttribute('mainipv4',guifi_main_ip(id)); break;
                                }
                            }
                        }
                        // TODO obtenir model_id i firmware del device o no de extra
                        if (!empty($device->extra)) {
                            $device->variable = unserialize($device->extra);
                            if ($device->type == 'radio') {
                                if (isset($device->variable['firmware'])) {
                                    $deviceXML->addAttribute('firmware', $device->variable['firmware']);
                                }
                            }
                            if (isset($device->variable['model_id'])) {
                                $model_name = $models[(int) $device->variable['model_id']];
                                $deviceXML->addAttribute('name', $model_name);
                            }
                            if (!empty($device->variable['mrtg_index'])) {
                                $deviceXML->addAttribute('snmp_index', $device->variable['mrtg_index']);
                            }
                        }
                    }
                    $nodesummary->devices++;
                    // device radios
                    if (is_array($radios[$node->id][$device->id])) {
                        if (count($radios[$node->id][$device->id])) {
                            foreach ($radios[$node->id][$device->id] as $id => $radio) {
                                if ($action == 'detail') {
                                    $radioXML = $deviceXML->addChild('radio', htmlspecialchars($radio->comment, ENT_QUOTES));
                                    $radioXML->addAttribute('id', $radio->radiodev_counter);
                                    $radioXML->addAttribute('device_id', $device->id);
                                    foreach ($radio as $key => $value) {
                                        if ($value) {
                                            switch ($key) {
                                                case 'radiodev_counter':
                                                case 'comment':
                                                    break;
                                                case 'ssid':
                                                    $radioXML->addAttribute('ssid', $value);
                                                    break;
                                                case 'mode':
                                                    $radioXML->addAttribute('mode', $value);
                                                    break;
                                                case 'protocol':
                                                    $radioXML->addAttribute('protocol', $value);
                                                    break;
                                                case 'channel':
                                                    $radioXML->addAttribute('channel', $value);
                                                    break;
                                                case 'antenna_angle':
                                                    $radioXML->addAttribute('antenna_angle', $value);
                                                    break;
                                                case 'antenna_gain':
                                                    $radioXML->addAttribute('antenna_gain', $value);
                                                    break;
                                                case 'antenna_azimuth':
                                                    $radioXML->addAttribute('antenna_azimuth', $value);
                                                    break;
                                                case 'clients_accepted':
                                                    $radioXML->addAttribute('clients_accepted', $value);
                                                    break;
                                            }
                                        }
                                    }
                                    if (isset($device->variable['model_id'])) {
                                        // TODO resolve issue  wlanX ( 1,2,3,4, etc.. ) incremental.
                                        if (in_array($model_name, array('Routerboard 112', 'Routerboard 133', 'Routerboard 133C', 'Routerboard 153', 'Routerboard 333', 'Routerboard 411', 'Routerboard 433', 'Routerboard 532', 'Routerboard 600', 'Routerboard 800', 'Supertrasto guifiBUS guifi.net', 'Routerboard SXT 5HnD', 'Routerboard 493/G', 'OmniTIK Uxx-5HnD', 'Routerboard SXT Lite2', 'Routerboard SXT Lite5', 'Routerboard 2011', 'Routerboard Sextant'))) {
                                            switch ($device->variable['firmware']) {
                                                case 'RouterOSv2.9':
                                                case 'RouterOSv3.x':
                                                case 'RouterOSv4.0+':
                                                case 'RouterOSv4.7+':
                                                case 'RouterOSv5.x':
                                                case 'RouterOSv6.x':
                                                    $radioXML->addAttribute('snmp_name', 'wlan' . (string) ($id + 1));
                                                    break;
                                            }
                                        } else {
                                            $snmp = db_fetch_object(db_query('SELECT snmp_id FROM guifi_configuracioUnSolclic WHERE id=%d', $device->usc_id));
                                            list($modeap, $modesta) = explode("|", $snmp->snmp_id);
                                            if (empty($modesta)) {
                                                $modesta = $modeap;
                                            }
                                            if (eregi("^[0-9]+\$", $modeap)) {
                                                $snmp_iname = 'snmp_index';
                                            } else {
                                                $snmp_iname = 'snmp_name';
                                            }
                                            if (eregi("^[0-9]+\$", $modesta)) {
                                                $snmp_ciname = 'snmp_index';
                                            } else {
                                                $snmp_ciname = 'snmp_name';
                                            }
                                            if ($radio->mode == 'client') {
                                                $radioXML->addAttribute($snmp_ciname, $modesta);
                                            } else {
                                                $radioXML->addAttribute($snmp_iname, $modeap);
                                            }
                                        }
                                    }
                                    switch ($radio->mode) {
                                        case 'ap':
                                            $nodesummary->ap++;
                                            break;
                                        case 'client':
                                            $nodesummary->client++;
                                            break;
                                    }
                                }
                                // device radio interfaces
                                if (is_array($interfaces[$device->id][$radio->radiodev_counter])) {
                                    if (count($interfaces[$device->id][$radio->radiodev_counter])) {
                                        foreach ($interfaces[$device->id][$radio->radiodev_counter] as $radio_interfaces) {
                                            foreach ($radio_interfaces as $interface) {
                                                if (!array_search($interface->interface_type, array('a' => 'wds/p2p', 'b' => 'wLan', 'c' => 'wLan/Lan', 'd' => 'Wan')) and !array_search($interface->interface_class, array('a' => 'wds/p2p'))) {
                                                    continue;
                                                }
                                                if ($interface->interface_type == 'Wan' and $radio->mode != 'client') {
                                                    continue;
                                                }
                                                if ($action == 'detail') {
                                                    $interfaceXML = $radioXML->addChild('interface');
                                                    foreach ($interface as $key => $value) {
                                                        if ($value) {
                                                            switch ($key) {
                                                                case 'id':
                                                                    $interfaceXML->addAttribute('id', $interface->id);
                                                                    break;
                                                                case 'mac':
                                                                    $interfaceXML->addAttribute('mac', $interface->mac);
                                                                    break;
                                                                case 'ipv4':
                                                                    $interfaceXML->addAttribute('ipv4', $interface->ipv4);
                                                                    break;
                                                                case 'netmask':
                                                                    $interfaceXML->addAttribute('mask', $interface->netmask);
                                                                    break;
                                                                case 'interface_type':
                                                                    $interfaceXML->addAttribute('type', $interface->interface_type);
                                                                    break;
                                                            }
                                                        }
                                                    }
                                                }
                                                // linked interfaces
                                                if (is_array($links[$device->id][$interface->id])) {
                                                    if (count($links[$device->id][$interface->id])) {
                                                        foreach ($links[$device->id][$interface->id] as $id => $link) {
                                                            if (!array_search($link->link_type, array('a' => 'ap/client', 'b' => 'wds'))) {
                                                                continue;
                                                            }
                                                            if ($link->ipv4_id != $interface->ipv4_id) {
                                                                continue;
                                                            }
                                                            $nodesummary->links++;
                                                            if ($action == 'detail') {
                                                                $linkXML = $interfaceXML->addChild('link');
                                                                foreach ($link as $key => $value) {
                                                                    if ($value) {
                                                                        switch ($key) {
                                                                            case 'id':
                                                                                $linkXML->addAttribute('id', $link->id);
                                                                                break;
                                                                            case 'linked_node_id':
                                                                                $linkXML->addAttribute('linked_node_id', $link->linked_node_id);
                                                                                break;
                                                                            case 'linked_device_id':
                                                                                $linkXML->addAttribute('linked_device_id', $link->linked_device_id);
                                                                                break;
                                                                            case 'linked_interface_id':
                                                                                $linkXML->addAttribute('linked_interface_id', $link->linked_interface_id);
                                                                                break;
                                                                            case 'link_type':
                                                                                $linkXML->addAttribute('link_type', $link->link_type);
                                                                                break;
                                                                            case 'status':
                                                                                $linkXML->addAttribute('link_status', $link->status);
                                                                                break;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        // foreach link
                                                    }
                                                }
                                                //interface links
                                            }
                                        }
                                        // foreach radio interface
                                    }
                                }
                                // radio interfaces
                            }
                            // foreach radios
                        }
                    }
                    // device radios
                    // device interfaces
                    if (is_array($interfaces[$device->id])) {
                        if (count($interfaces[$device->id])) {
                            foreach ($interfaces[$device->id] as $device_interfaces) {
                                foreach ($device_interfaces as $counter_interfaces) {
                                    foreach ($counter_interfaces as $interface) {
                                        if (array_search($interface->interface_type, array('a' => 'wds/p2p', 'b' => 'wLan', 'c' => 'wlan/Lan')) and array_search($interface->interface_class, array('a' => 'wds/p2p'))) {
                                            continue;
                                        }
                                        if ($action == 'detail') {
                                            $interfaceXML = $deviceXML->addChild('interface');
                                            foreach ($interface as $key => $value) {
                                                if ($value) {
                                                    switch ($key) {
                                                        case 'id':
                                                            $interfaceXML->addAttribute('id', $interface->id);
                                                            break;
                                                        case 'mac':
                                                            $interfaceXML->addAttribute('mac', $interface->mac);
                                                            break;
                                                        case 'ipv4':
                                                            $interfaceXML->addAttribute('ipv4', $interface->ipv4);
                                                            break;
                                                        case 'netmask':
                                                            $interfaceXML->addAttribute('mask', $interface->netmask);
                                                            break;
                                                        case 'interface_type':
                                                            $interfaceXML->addAttribute('type', $interface->interface_type);
                                                            break;
                                                    }
                                                }
                                            }
                                        }
                                        // linked interfaces
                                        if (is_array($links[$device->id][$interface->id])) {
                                            if (count($links[$device->id][$interface->id])) {
                                                foreach ($links[$device->id][$interface->id] as $id => $link) {
                                                    if (array_search($link->link_type, array('a' => 'ap/client', 'b' => 'wds'))) {
                                                        continue;
                                                    }
                                                    if ($link->ipv4_id != $interface->ipv4_id) {
                                                        continue;
                                                    }
                                                    if ($action == 'detail') {
                                                        $linkXML = $interfaceXML->addChild('link');
                                                        foreach ($link as $key => $value) {
                                                            if ($value) {
                                                                switch ($key) {
                                                                    case 'id':
                                                                        $linkXML->addAttribute('id', $link->id);
                                                                        break;
                                                                    case 'linked_node_id':
                                                                        $linkXML->addAttribute('linked_node_id', $link->linked_node_id);
                                                                        break;
                                                                    case 'linked_device_id':
                                                                        $linkXML->addAttribute('linked_device_id', $link->linked_device_id);
                                                                        break;
                                                                    case 'linked_interface_id':
                                                                        $linkXML->addAttribute('linked_interface_id', $link->linked_interface_id);
                                                                        break;
                                                                    case 'link_type':
                                                                        $linkXML->addAttribute('link_type', $link->link_type);
                                                                        break;
                                                                    case 'status':
                                                                        $linkXML->addAttribute('link_status', $link->status);
                                                                        break;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                // foreach link
                                            }
                                        }
                                        //interface links
                                    }
                                }
                            }
                            // foreach interface
                        }
                    }
                    //interface
                    // services
                    if (is_array($services[$device->id])) {
                        if (count($services[$device->id])) {
                            foreach ($services[$device->id] as $id => $service) {
                                if ($action == 'detail') {
                                    $serviceXML = $deviceXML->addChild('service', htmlspecialchars($service->body, ENT_QUOTES));
                                    foreach ($service as $key => $value) {
                                        if ($value) {
                                            switch ($key) {
                                                case 'body':
                                                    break;
                                                case 'id':
                                                    $serviceXML->addAttribute('id', $value);
                                                    break;
                                                case 'nick':
                                                    $serviceXML->addAttribute('title', $value);
                                                    break;
                                                case 'service_type':
                                                    $serviceXML->addAttribute('type', $value);
                                                    break;
                                                case 'status_flag':
                                                    $serviceXML->addAttribute('status', $value);
                                                    break;
                                                case 'timestamp_created':
                                                    $serviceXML->addAttribute('created', date('Ymd hi', $value));
                                                    break;
                                                case 'timestamp_changed':
                                                    $serviceXML->addAttribute('updated', date('Ymd hi', $value));
                                                    break;
                                            }
                                        }
                                    }
                                }
                                $nodesummary->services++;
                            }
                            // foreach service
                        }
                    }
                    // service
                }
                // foreach device
            }
        }
        // devices
        $summary->ap += $nodesummary->ap;
        $summary->client += $nodesummary->client;
        $summary->devices += $nodesummary->devices;
        $summary->links += $nodesummary->links;
        $summary->services += $nodesummary->services;
        if ($action != 'zones') {
            if ($nodesummary->ap) {
                $nodeXML->addAttribute('access_points', $nodesummary->ap);
            }
            if ($nodesummary->client) {
                $nodeXML->addAttribute('clients', $nodesummary->client);
            }
            if ($nodesummary->devices) {
                $nodeXML->addAttribute('devices', $nodesummary->devices);
            }
            if ($nodesummary->links) {
                $nodeXML->addAttribute('links', $nodesummary->links);
            }
            if ($nodesummary->services) {
                $nodeXML->addAttribute('services', $nodesummary->services);
            }
        }
        return;
    }
    // _add_cnml_node
    function _add_cnml_zone(&$CNML, $zone, $action)
    {
        $summary->nodes = 0;
        $summary->minx = 179.9;
        $summary->miny = 89.90000000000001;
        $summary->maxx = -179.9;
        $summary->maxy = -89.90000000000001;
        $summary->devices = 0;
        $summary->ap = 0;
        $summary->client = 0;
        $summary->services = 0;
        $summary->links = 0;
        $zoneXML = $CNML->addChild('zone', htmlspecialchars($zone->body, ENT_QUOTES));
        reset($zone);
        foreach ($zone as $key => $value) {
            if ($value) {
                switch ($key) {
                    case 'body':
                        break;
                    case 'childs':
                        foreach ($value as $child) {
                            $summary2 = _add_cnml_zone($zoneXML, $child, $action);
                            $summary->nodes += $summary2->nodes;
                            $summary->devices += $summary2->devices;
                            $summary->ap += $summary2->ap;
                            $summary->client += $summary2->client;
                            $summary->servers += $summary2->servers;
                            $summary->links += $summary2->links;
                            $summary->services += $summary2->services;
                            if ($summary2->minx < $summary->minx) {
                                $summary->minx = $summary2->minx;
                            }
                            if ($summary2->miny < $summary->miny) {
                                $summary->miny = $summary2->miny;
                            }
                            if ($summary2->maxx > $summary->maxx) {
                                $summary->maxx = $summary2->maxy;
                            }
                            if ($summary2->maxy > $summary->maxy) {
                                $summary->maxy = $summary2->maxy;
                            }
                        }
                        break;
                    case 'nodes':
                        $summary = (object) array();
                        foreach ($value as $child) {
                            _add_cnml_node($zoneXML, $child, $summary, $action);
                        }
                        break;
                    case 'id':
                        $zoneXML->addAttribute('id', $value);
                        break;
                    case 'parent_id':
                        $zoneXML->addAttribute('parent_id', $value);
                        break;
                    case 'title':
                        $zoneXML->addAttribute('title', $value);
                        break;
                    case 'time_zone':
                        $zoneXML->addAttribute('time_zone', $value);
                        break;
                    case 'ntp_servers':
                        $zoneXML->addAttribute('ntp_servers', $value);
                        break;
                    case 'dns_servers':
                        $zoneXML->addAttribute('dns_servers', $value);
                        break;
                    case 'graph_server':
                        $zoneXML->addAttribute('graph_server', $value);
                        break;
                    case 'timestamp_created':
                        $zoneXML->addAttribute('created', date('Ymd hi', $value));
                        break;
                    case 'timestamp_changed':
                        $zoneXML->addAttribute('updated', date('Ymd hi', $value));
                        break;
                }
            }
        }
        $zoneXML->addAttribute('zone_nodes', $summary->nodes);
        if ($zone->minx != 0 and $zone->miny != 0 and $zone->maxx != 0 and $zone->maxy != 0) {
            $zoneXML->addAttribute('box', $zone->minx . ',' . $zone->miny . ',' . $zone->maxx . ',' . $zone->maxy);
        } else {
            $zoneXML->addAttribute('box', $summary->minx . ',' . $summary->miny . ',' . $summary->maxx . ',' . $summary->maxy);
        }
        if ($summary->ap) {
            $zoneXML->addAttribute('access_points', $summary->ap);
        }
        if ($summary->client) {
            $zoneXML->addAttribute('clients', $summary->client);
        }
        if ($summary->devices) {
            $zoneXML->addAttribute('devices', $summary->devices);
        }
        if ($summary->services) {
            $zoneXML->addAttribute('services', $summary->services);
        }
        if ($summary->links) {
            $zoneXML->addAttribute('links', $summary->links);
        }
        return $summary;
    }
    $summary->nodes = 0;
    $summary->minx = 179.9;
    $summary->miny = 89.90000000000001;
    $summary->maxx = -179.9;
    $summary->maxy = -89.90000000000001;
    $summary->devices = 0;
    $summary->ap = 0;
    $summary->client = 0;
    $summary->services = 0;
    $summary->links = 0;
    $CNML = new SimpleXMLElement('<cnml></cnml>');
    $CNML->addAttribute('version', '0.1');
    $CNML->addAttribute('server_id', '1');
    $CNML->addAttribute('server_url', 'http://guifi.net');
    $CNML->addAttribute('generated', date('Ymd hi', time()));
    $classXML = $CNML->addChild('class');
    if ($action != 'node') {
        $classXML->addAttribute('network_description', $action);
        $classXML->addAttribute('mapping', 'y');
        $networkXML = $CNML->addChild('network');
        if (count($tree)) {
            foreach ($tree as $zone_id => $zone) {
                $summary2 = _add_cnml_zone($networkXML, $zone, $action);
                $summary->nodes += $summary2->nodes;
                $summary->devices += $summary2->devices;
                $summary->ap += $summary2->ap;
                $summary->client += $summary2->client;
                $summary->servers += $summary2->servers;
                $summary->links += $summary2->links;
                $summary->services += $summary2->services;
            }
        }
        $networkXML->addAttribute('nodes', $summary->nodes);
        $networkXML->addAttribute('devices', $summary->devices);
        $networkXML->addAttribute('ap', $summary->ap);
        $networkXML->addAttribute('client', $summary->client);
        $networkXML->addAttribute('services', $summary->services);
        $networkXML->addAttribute('links', $summary->links);
    } else {
        $classXML->addAttribute('node_description', $cnmlid);
        $classXML->addAttribute('mapping', 'y');
        $summary->devices = 0;
        $summary->ap = 0;
        $summary->client = 0;
        $summary->services = 0;
        $summary->links = 0;
        // print_r($tree);
        foreach ($tree as $nodeid => $node) {
            $summary = _add_cnml_node($CNML, $node, $summary, 'detail');
        }
    }
    print_pretty_CNML($CNML);
    return;
}
示例#3
0
function budgets_supplier_view($node, $teaser = FALSE, $page = FALSE)
{
    global $user;
    if (!isset($node->nid)) {
        $node = node_load(array('nid' => $node->id));
    }
    if ($node->sticky) {
        $node->sticky = 0;
    }
    guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_view(teaser)', $teaser);
    node_prepare($node, $teaser);
    if ($teaser) {
        $body = node_teaser($node->body, TRUE, $node->rated == true ? 600 : 300);
        $body = strip_tags($body, '<br> ');
        if ($node->rated) {
            if (!empty($node->logo)) {
                $img = '<img class="supplier-logo" src="/' . $node->logo . '" width="150">';
            }
            if (!empty($node->web_url)) {
                $img = '<a href="' . $node->web_url . '">' . $img . '</a>';
            }
            $body = "<div class=\"supplier-rated\">" . $img . $body . "</div>";
        }
        $node->content['body']['#value'] = $body;
    }
    if ($node->rated) {
        $node->content['body']['#value'] = '<p class="rating" >' . $node->official_rating . '</p>' . $node->content['body']['#value'];
    }
    $node->content['header'] = array('#value' => theme_budgets_supplier_header($node, $teaser), '#weight' => -10);
    if ($page) {
        drupal_set_breadcrumb(guifi_zone_ariadna($node->zone_id, 'node/%d/view/suppliers'));
        $body = $node->content['body']['#value'];
        if (!empty($node->logo)) {
            $img = '<img class="supplier-logo" src="/' . $node->logo . '" width="200">';
        }
        if (!empty($node->web_url)) {
            $img = '<a href="' . $node->web_url . '">' . $img . '</a>';
        }
        // Quotes
        //to-do
        // Accounting
        guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_view(accounting)', $node->accounting_urls);
        if (count($node->accounting_urls) > 1 and !empty($node->accounting_urls[0]['url'])) {
            // There are accounting urls
            $rows = array();
            foreach ($node->accounting_urls as $value) {
                guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_view(value)', $value);
                if (!empty($value['url'])) {
                    $rows[] = array(array('data' => $value['node_id']), array('data' => '<a href="' . $value['url'] . '">' . $value['url'] . '</a>'), array('data' => $value['comment']));
                }
            }
            $headers = array(array('data' => t('Node')), array('data' => t('Url')), array('data' => t('Comment')));
            $body .= '<br><hr><h2>' . t('Accounting') . '</h2>' . theme('table', $headers, $rows);
        }
        $node->content['body']['#value'] = $img . ' ' . $body;
    }
    $node->content['footer'] = array('#value' => theme_budgets_supplier_footer($node, $teaser), '#weight' => 10);
    return $node;
    // format antic
    $node = node_prepare($node, $teaser);
    $output = '';
    $qquotes = pager_query(sprintf('SELECT id ' . 'FROM {supplier_quote} ' . 'WHERE supplier_id = %d ' . 'ORDER BY title, partno, id', $node->nid), variable_get('default_nodes_main', 10));
    $output .= '<h3>' . t('Contact information:') . '<h3 />' . t('Phone') . ':' . $node->phone . t(' Email: ') . $user->uid ? l($node->notification) : l('login to view email contact', 'user/login');
    if (!$teaser) {
        $output .= '<br<br><hr><h2>' . t('Quotes') . '</h2>';
        while ($quote = db_fetch_object($qquotes)) {
            $output .= node_view(node_load(array('nid' => $quote->id)), TRUE, FALSE);
        }
        empty($quote) ? $output .= t('No quotes available') : NULL;
        $node->content['quotes'] = array('#value' => $output . theme('pager', NULL, variable_get('default_nodes_main', 10)), '#weight' => 1);
    }
    return $node;
}
示例#4
0
/**
 * outputs the user information data
**/
function guifi_users_node_list_form($form_state, $params = array())
{
    global $user;
    $owner = $user->uid;
    guifi_log(GUIFILOG_TRACE, 'function guifi_users_node_list_form()', $params);
    if (empty($form_state['values'])) {
        if (is_numeric($params)) {
            $node = node_load($params);
        } else {
            $node = node_load(array('nid' => $params->id));
        }
    }
    //  $form_state['#redirect'] = FALSE;
    //  if (!empty($op)) {
    //    $edit=$_POST['edit'];
    //    if ((empty($edit['user_checked'])) and ($op == t('Edit selected')))
    //      form_set_error('',t('You must select a user checkbox for editing it'));
    //    else
    //      return guifi_edit_user($edit['user_checked']);
    //  }
    drupal_set_breadcrumb(guifi_zone_ariadna($node->zone_id));
    $title = t('Users @') . ' ' . $node->title;
    drupal_set_title($title);
    if ($node->type == 'guifi_node') {
        $query = db_query("SELECT id " . "FROM {guifi_users} " . "WHERE nid = %d " . "ORDER BY lastname, firstname", $node->nid);
    } else {
        $query = db_query("SELECT id " . "FROM {guifi_users} " . "ORDER BY lastname, firstname");
    }
    $rows[] = array();
    $num_rows = FALSE;
    $f = array('#type' => 'fieldset', '#collapsible' => FALSE, '#title' => t('Users'));
    $options = array();
    while ($guserid = db_fetch_object($query)) {
        $guser = (object) guifi_user_load($guserid->id);
        $services = $guser->services;
        if ($node->type == 'guifi_service') {
            if ($node->service_type != 'Proxy' or $node->nid != $services['proxy']) {
                continue;
            }
        }
        if (!empty($guser->lastname)) {
            $realname = $guser->lastname . ', ' . $guser->firstname;
        } else {
            $realname = $guser->firstname;
        }
        $service = node_load(array('nid' => $guser->services['proxy']));
        if (user_access('administer guifi users') or $node->uid == $owner) {
            $realname2 = $realname;
            $username2 = $guser->username;
        } else {
            $realname2 = ereg_replace("_", " ", $realname);
            if (strlen($realname2) > 3) {
                $realname2 = substr($realname, 0, 3);
                $realname2 .= "..";
            }
            $username2 = $guser->username;
            if (strlen($username2) > 3) {
                $username2 = substr($guser->username, 0, 3);
                $username2 .= "..";
            }
        }
        $options[$guser->id] = $realname2 . ' (' . $username2 . ')' . l($service->nick, 'node/' . $service->id, array('attributes' => array('title' => $service->title))) . ' - ' . $guser->status . '<br />' . theme_guifi_contacts($guser, FALSE);
        if (!isset($default_user)) {
            $default_user = $guser->id;
        }
    }
    if (count($options)) {
        $f['user_id'] = array('#type' => 'radios', '#title' => $title, '#options' => $options, '#default_value' => $default_user);
        if (user_access('administer guifi users') or $node->uid == $owner) {
            $f['editUser'] = array('#type' => 'submit', '#value' => t('Edit selected user'));
        }
    } else {
        $f['empty'] = array('#type' => 'item', '#title' => t('There are no users to list at') . ' ' . $node->title);
    }
    if (user_access('administer guifi users') or $node->uid == $owner) {
        if ($node->type == 'guifi_node') {
            $f['addUser'] = array('#type' => 'submit', '#value' => t('Add user'));
        }
    }
    return $f;
}
示例#5
0
/**
 * guifi_graph_detail
 * outputs a page with node detailed graphs
 */
function guifi_graph_detail()
{
    $type = $_GET['type'];
    if (isset($_GET['device'])) {
        $device_id = $_GET['device'];
    } else {
        if (isset($_GET['radio'])) {
            $device_id = $_GET['radio'];
        }
    }
    if (isset($device_id)) {
        $query = db_query("SELECT r.id, r.nick, n.title, r.nid, l.zone_id " . "FROM {guifi_devices} r, {node} n, {guifi_location} l " . "WHERE r.id=%d " . "  AND n.nid=r.nid " . "  AND n.nid = l.id", $device_id);
        $radio = db_fetch_object($query);
        $zid = $radio->zone_id;
    }
    if ($type == 'supernode') {
        $node = node_load(array('nid' => $_GET['node']));
        if ($node->graph_server == -1) {
            $rows[] = array(t('This node has the graphs disabled.'));
            return array_merge($rows);
        }
        if (!empty($node->graph_server)) {
            $gs = node_load(array('nid' => $node->graph_server));
        } else {
            $gs = node_load(array('nid' => guifi_graphs_get_server($node->id, 'node')));
        }
    } else {
        if ($radio->graph_server == -1) {
            $rows[] = array(t('This device has the graphs disabled.'));
            return array_merge($rows);
        }
        if (!empty($radio->graph_server)) {
            $gs = node_load(array('nid' => $radio->graph_server));
        } else {
            $gs = node_load(array('nid' => guifi_graphs_get_server($radio->id, 'device')));
        }
    }
    $help = t('Here you have a detailed view of the available information for several periods of time (daily, weekly, monthly and yearly). You can obtain a detailed graph for a given period of time by entering the period in the boxes below.');
    $args = array('type' => $type, 'node' => $_GET['node'], 'device' => $device_id);
    if (isset($_GET['direction'])) {
        $args['direction'] = $_GET['direction'];
    }
    switch ($type) {
        case 'clients':
            $title = '<a href="' . base_path() . 'guifi/device/' . $radio->id . '">' . $radio->nick . '</a> ' . t('at') . ' ' . '<a href=' . base_path() . 'node/' . $radio->nid . '>' . $radio->title . '</a>';
            $help .= '<br />' . t('The clients graph displays the top clients by transit.');
            break;
        case 'supernode':
            $zid = $node->zone_id;
            $title = '<a href=' . base_path() . 'node/' . $_GET['node'] . '>' . $node->title . '</a>';
            $help .= '<br />' . t('Supernode graph displays the transit of each radio.');
            break;
        case 'radio':
        case 'device':
            $help = '<br />' . t('The radio graph show in &#038; out transit.');
        case 'pings':
            if ($type != 'radio') {
                $help = '<br />' . t('The ping graph displays the latency and availability. High latency usually means bad connection. Yellow means % of failed pings, could be some yellow on the graphs, but must not reach value of 100, if the value reaches 100, that means that the radio is offline.');
            }
            $title = $radio->nick . ' ' . t('at') . ' ' . '<a href=' . base_path() . 'node/' . $radio->nid . '>' . $radio->title . '</a>';
            break;
    }
    $secs_day = 60 * 60 * 24;
    drupal_set_breadcrumb(guifi_zone_ariadna($zid));
    $output = '<div id="guifi">';
    //  $rows[] = array(t('enter a timeframe to graph a customized period'));
    $output .= '<h3>' . $type . '</h3>' . $help;
    switch ($type) {
    }
    if (isset($_POST['date1'])) {
        $date1 = $_POST['date1'];
    } else {
        $date1 = date('d-m-Y H:i', time() - 60 * 60 * 2);
    }
    if (isset($_POST['date2'])) {
        $date2 = $_POST['date2'];
    } else {
        $date2 = date('d-m-Y H:i', time() - 300);
    }
    $str = '<form name="form_timespan_selector" method="post"><strong>&nbsp;' . t('From:');
    $str .= '&nbsp;</strong><input type="text" name="date1" id=\'date1\' size=\'14\' value="' . $date1 . '">&nbsp;<input type="image"
src="' . base_path() . drupal_get_path('module', 'guifi') . '/contrib/calendar.gif" alt="Start date selector" onclick="return showCalendar(\'date1\');">&nbsp;';
    $str .= '<strong>' . t('To:') . '&nbsp;</strong> <input type="text" name="date2" id=\'date2\' size="14" value="' . $date2 . '"> &nbsp;';
    $str .= '<input type="image" src="' . base_path() . drupal_get_path('module', 'guifi') . '/contrib/calendar.gif" alt="End date selector" align="absmiddle" onclick="return showCalendar(\'date2\');"> &nbsp;&nbsp;';
    $str .= '<input type="submit" name="button_refresh" action="submit" value="refresh">';
    $rows[] = array($str);
    if (isset($_POST['date1'])) {
        list($day, $month, $year, $hour, $min) = sscanf($_POST['date1'], '%d-%d-%d %d:%d');
        $start = mktime($hour, $min, 0, $month, $day, $year);
        list($day, $month, $year, $hour, $min) = sscanf($_POST['date2'], '%d-%d-%d %d:%d');
        $end = mktime($hour, $min, 0, $month, $day, $year);
        $rows[] = array(t('customized graph'));
        $rows[] = array('<img src="' . guifi_cnml_call_service($gs->var['url'], 'graph', $args, sprintf('start=%d&end=%d">', $start, $end)));
    }
    $rows[] = array(t('day'));
    $rows[] = array('<img src="' . guifi_cnml_call_service($gs->var['url'], 'graph', $args, sprintf('start=-%d&end=%d">', $secs_day, -300)));
    $rows[] = array(t('week'));
    $rows[] = array('<img src="' . guifi_cnml_call_service($gs->var['url'], 'graph', $args, sprintf('start=-%d&end=%d">', $secs_day * 7, -300)));
    $rows[] = array(t('month'));
    $rows[] = array('<img src="' . guifi_cnml_call_service($gs->var['url'], 'graph', $args, sprintf('start=-%d&end=%d">', $secs_day * 31, -300)));
    $rows[] = array(t('year'));
    $rows[] = array('<img src="' . guifi_cnml_call_service($gs->var['url'], 'graph', $args, sprintf('start=-%d&end=%d">', $secs_day * 365, -300)));
    $output .= theme('table', NULL, array_merge($rows));
    $output .= "</div>" . _guifi_script_calendar();
    drupal_set_html_head('<script type="text/javascript" src="' . base_path() . drupal_get_path('module', 'guifi') . '/contrib/calendar.js"></script> <script type="text/javascript" src="' . base_path() . drupal_get_path('module', 'guifi') . '/contrib/lang/calendar-ca.js"></script></script> <script type="text/javascript" src="' . base_path() . drupal_get_path('module', 'guifi') . '/contrib/calendar-setup.js"></script>');
    drupal_set_title(t('graph details for') . ' ' . $title);
    return print theme('page', $output, t('graph details for') . ' ' . $title);
}
/**
 * outputs the node information
**/
function guifi_service_view($node, $teaser = FALSE, $page = FALSE, $block = FALSE)
{
    node_prepare($node);
    if ($teaser) {
        return $node;
    }
    if ($block) {
        return $node;
    }
    if ($page) {
        drupal_set_breadcrumb(guifi_zone_ariadna($node->zone_id, 'node/%d/view/services'));
        $node->content['body']['#value'] = theme('box', t('Description'), $node->content['body']['#value']);
        $node->content['body']['#weight'] = 1;
        $service_data = array('#value' => theme('box', t('service information'), theme_guifi_service_data($node, FALSE)), '#weight' => -0);
        if ($node->service_type == 'DNS') {
            $form = drupal_get_form('guifi_domain_create_form', $node);
            $id = $node->id;
            $rows = array();
            $header = array('<h2>' . t('Domain') . '</h2>', array('data' => t('type'), 'style' => 'text-align: left;'), array('data' => t('Scope')));
            $query = db_query("SELECT d.id FROM {guifi_dns_domains} d WHERE sid=%d", $id);
            while ($d = db_fetch_object($query)) {
                $domain = guifi_domain_load($d->id);
                if (guifi_domain_access('update', $domain['id'])) {
                    $edit_domain = l(guifi_img_icon('edit.png'), 'guifi/domain/' . $domain['id'] . '/edit', array('html' => TRUE, 'title' => t('edit domain'), 'attributes' => array('target' => '_blank'))) . '</td><td>' . l(guifi_img_icon('drop.png'), 'guifi/domain/' . $domain['id'] . '/delete', array('html' => TRUE, 'title' => t('delete domain'), 'attributes' => array('target' => '_blank')));
                }
                $rows[] = array('<a href="' . url('guifi/domain/' . $domain[id]) . '">' . $domain['name'] . '</a>', array('data' => $domain['type'], 'style' => 'text-align: left;'), array('data' => $domain['scope']), $edit_domain);
            }
            if (count($rows)) {
                $node->content['data'] = array($service_data, array('#value' => theme('table', $header, $rows) . $form, '#weight' => 1));
            } else {
                $node->content['data'] = array(array('#value' => theme('box', t('service information'), theme_guifi_service_data($node, FALSE)) . $form, '#weight' => -0));
            }
        } else {
            $node->content['data'] = array(array('#value' => theme('box', t('service information'), theme_guifi_service_data($node, FALSE)) . $form, '#weight' => -0));
        }
    }
    return $node;
}
示例#7
0
/** theme_guifi_zone_data():  outputs the zone information
**/
function theme_guifi_zone_data($zone, $links = TRUE)
{
    $zone = node_load(array('nid' => $zone->id));
    drupal_set_breadcrumb(guifi_zone_ariadna($zone->id));
    $table = theme('table', NULL, guifi_zone_data($zone), array('width' => '100%'));
    $output .= theme('box', t('zone information'), $table);
    if ($links) {
        drupal_set_breadcrumb(guifi_zone_ariadna($node->id));
        $node = node_load(array('nid' => $node->id));
        $output .= theme_links(module_invoke_all('link', 'node', $node, FALSE));
        print theme('page', $output, FALSE);
        return;
    }
    return $output;
}