public static function build_update_xmls($data) { if (!is_array($data)) { return self::build_update_xml($data); } $xw = new xmlWriter(); $xw->openMemory(); $xw->startDocument('1.0', 'UTF-8'); $xw->startElement('add'); foreach ($data as $row) { $xw->startElement('doc'); foreach ($row as $key => $value) { if (is_array($value)) { foreach ($value as $v) { $xw->startElement('field'); $xw->writeAttribute('name', $key); $xw->writeCdata($v); $xw->endElement(); } } else { $xw->startElement('field'); $xw->writeAttribute('name', $key); $xw->writeCdata($value); $xw->endElement(); } } $xw->endElement(); } $xw->endElement(); $xw->endDocument(); $xml = $xw->outputMemory(true); return $xml; }
public function getXMLFromArray($table_headers, $table, $sum_row_content) { $xw = new xmlWriter(); // Neues xmlWriter Objekt $xw->openMemory(); // Oeffnen eines XML-Dokuments im Speicher $xw->setIndent(true); // sieht einfach besser aus ;-) $xw->startDocument(); // start document $xw->startElement("yaphobia_data"); // start <book> $counter = 0; foreach ($table as $row) { $xw->startElement('row'); $xw->writeElement('id', $counter++); foreach ($row as $key => $value) { //$xw->writeElement( $key, $value); //if ($value == "") $value = "FILLED_BY_YAPHOBIA"; //if ($key == "") $key = "filled_by_yaphobia"; $xw->writeElement(htmlspecialchars($key), htmlspecialchars($value)); } $xw->endElement(); } $xw->endElement(); // yaphobia_data $xw->endDocument(); // end document return $xw->outputMemory(); }
/** * 这个不知道……暂时用不到 * @param unknown_type $row */ public static function build_update_xml($row) { $xw = new xmlWriter(); $xw->openMemory(); $xw->startDocument("1.0", "UTF-8"); $xw->startElement("add"); $xw->startElement("doc"); foreach ($row as $key => $value) { if (is_array($value)) { foreach ($value as $v) { $xw->startElement("field"); $xw->writeAttribute("name", $key); $xw->writeCdata($v); $xw->endElement(); } } else { $xw->startElement("field"); $xw->writeAttribute("name", $key); $xw->writeCdata($value); $xw->endElement(); } } $xw->endElement(); $xw->endElement(); $xw->endDocument(); $xml = $xw->outputMemory(true); return $xml; }
public function getRoutersClients() { header('Content-type: text/xml'); $xw = new xmlWriter(); $xw->openMemory(); $xw->startDocument('1.0', 'UTF-8'); $xw->startElement('kml'); $xw->writeAttribute('xmlns', 'http://earth.google.com/kml/2.1'); $xw->startElement('Style'); $xw->writeAttribute('id', 'sh_client-pushpin-1'); $xw->startElement('IconStyle'); $xw->writeRaw('<scale>1.0</scale>'); $xw->startElement('Icon'); $xw->writeRaw('<href>' . $GLOBALS['url_to_netmon'] . '/templates/' . $GLOBALS['template'] . '/img/ffmap/clients_2_1.png</href>'); $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->startElement('Style'); $xw->writeAttribute('id', 'sh_client-pushpin-2'); $xw->startElement('IconStyle'); $xw->writeRaw('<scale>1.0</scale>'); $xw->startElement('Icon'); $xw->writeRaw('<href>' . $GLOBALS['url_to_netmon'] . '/templates/' . $GLOBALS['template'] . '/img/ffmap/clients_2_2.png</href>'); $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->startElement('Style'); $xw->writeAttribute('id', 'sh_client-pushpin-3'); $xw->startElement('IconStyle'); $xw->writeRaw('<scale>1.0</scale>'); $xw->startElement('Icon'); $xw->writeRaw('<href>' . $GLOBALS['url_to_netmon'] . '/templates/' . $GLOBALS['template'] . '/img/ffmap/clients_2_3.png</href>'); $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->startElement('Style'); $xw->writeAttribute('id', 'sh_client-pushpin-4'); $xw->startElement('IconStyle'); $xw->writeRaw('<scale>1.0</scale>'); $xw->startElement('Icon'); $xw->writeRaw('<href>' . $GLOBALS['url_to_netmon'] . '/templates/' . $GLOBALS['template'] . '/img/ffmap/clients_2_4.png</href>'); $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->startElement('Style'); $xw->writeAttribute('id', 'sh_client-pushpin-5'); $xw->startElement('IconStyle'); $xw->writeRaw('<scale>1.0</scale>'); $xw->startElement('Icon'); $xw->writeRaw('<href>' . $GLOBALS['url_to_netmon'] . '/templates/' . $GLOBALS['template'] . '/img/ffmap/clients_2_5.png</href>'); $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->startElement('Style'); $xw->writeAttribute('id', 'sh_client-pushpin-6'); $xw->startElement('IconStyle'); $xw->writeRaw('<scale>1.0</scale>'); $xw->startElement('Icon'); $xw->writeRaw('<href>' . $GLOBALS['url_to_netmon'] . '/templates/' . $GLOBALS['template'] . '/img/ffmap/clients_2_6.png</href>'); $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->startElement('Style'); $xw->writeAttribute('id', 'sh_blue-pushpin'); $xw->startElement('IconStyle'); $xw->writeRaw('<scale>0.5</scale>'); $xw->startElement('Icon'); $xw->writeRaw('<href>' . $GLOBALS['url_to_netmon'] . '/templates/' . $GLOBALS['template'] . '/img/ffmap/ip_highlighted.png</href>'); $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->startElement('ListStyle'); $xw->endElement(); $xw->startElement('Style'); $xw->writeAttribute('id', 'sh_ip_online_highlighted_pushpin'); $xw->startElement('IconStyle'); $xw->writeRaw('<scale>0.5</scale>'); $xw->startElement('Icon'); $xw->writeRaw('<href>' . $GLOBALS['url_to_netmon'] . '/templates/' . $GLOBALS['template'] . '/img/ffmap/ip_online_highlighted_1.png</href>'); $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->startElement('ListStyle'); $xw->endElement(); $xw->startElement('Style'); $xw->writeAttribute('id', 'sh_red-pushpin'); $xw->startElement('IconStyle'); $xw->writeRaw('<scale>0.5</scale>'); $xw->startElement('Icon'); $xw->writeRaw('<href>' . $GLOBALS['url_to_netmon'] . '/templates/' . $GLOBALS['template'] . '/img/ffmap/ip_offline.png</href>'); $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->startElement('ListStyle'); $xw->endElement(); $xw->startElement('Style'); $xw->writeAttribute('id', 'sh_yellow-pushpin'); $xw->startElement('IconStyle'); $xw->writeRaw('<scale>0.5</scale>'); $xw->startElement('Icon'); $xw->writeRaw('<href>' . $GLOBALS['url_to_netmon'] . '/templates/' . $GLOBALS['template'] . '/img/ffmap/ip_unknown.png</href>'); $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->startElement('ListStyle'); $xw->endElement(); $xw->startElement('Folder'); $xw->startElement('name'); $xw->writeRaw('create'); $xw->endElement(); $last_endet_crawl_cycle = Crawling::getLastEndedCrawlCycle(); $crawl_routers = Router_old::getCrawlRoutersByCrawlCycleId($last_endet_crawl_cycle['id']); foreach ($crawl_routers as $crawl_router) { $router_data = Router_old::getRouterInfo($crawl_router['router_id']); $crawl_interfaces = Interfaces::getInterfacesCrawlByCrawlCycle($last_endet_crawl_cycle['id'], $crawl_router['router_id']); $row['traffic'] = 0; foreach ($crawl_interfaces as $interface) { $traffic = $traffic + $interface['traffic_rx_avg'] + $interface['traffic_tx_avg']; } $traffic = round($traffic / 1024, 2); //Make coordinates and location information if (!empty($crawl_router['longitude']) and !empty($crawl_router['latitude'])) { $longitude = $crawl_router['longitude']; $latitude = $crawl_router['latitude']; $location = $crawl_router['location']; $do = true; } elseif (!empty($router_data['longitude']) and !empty($router_data['latitude'])) { $longitude = $router_data['longitude']; $latitude = $router_data['latitude']; $location = $router_data['location']; $do = true; } else { $do = false; } if ($do) { $xw->startElement('Placemark'); $xw->startElement('name'); $xw->writeRaw("<![CDATA[Router <a href='" . $GLOBALS['url_to_netmon'] . "/router.php?router_id=" . $router_data['router_id'] . "'>" . $router_data['hostname'] . "</a>]]>"); $xw->endElement(); $xw->startElement('description'); $box_inhalt = "Clients"; $xw->writeRaw("<![CDATA[{$box_inhalt}]]>"); $xw->endElement(); $xw->startElement('styleUrl'); if ($crawl_router['client_count'] == 0) { $xw->writeRaw('#sh_client-pushpin-0'); } elseif ($crawl_router['client_count'] == 1) { $xw->writeRaw('#sh_client-pushpin-1'); } elseif ($crawl_router['client_count'] == 2) { $xw->writeRaw('#sh_client-pushpin-2'); } elseif ($crawl_router['client_count'] == 3) { $xw->writeRaw('#sh_client-pushpin-3'); } elseif ($crawl_router['client_count'] == 4) { $xw->writeRaw('#sh_client-pushpin-4'); } elseif ($crawl_router['client_count'] == 5) { $xw->writeRaw('#sh_client-pushpin-5'); } elseif ($crawl_router['client_count'] >= 6) { $xw->writeRaw('#sh_client-pushpin-6'); } $xw->endElement(); $xw->startElement('Point'); $xw->startElement('coordinates'); $xw->writeRaw("{$longitude},{$latitude},0"); $xw->endElement(); $xw->endElement(); $xw->endElement(); } } $xw->endElement(); $xw->endElement(); $xw->endDocument(); print $xw->outputMemory(true); return true; }