$build_link_base = 'http://www.angstrom-distribution.org/core/autobuild/'; $builder_log_date = file('autobuilder.log'); if (empty($builder_log_date)) { die("No logs\n"); } $builder_log_date = array_reverse($builder_log_date); $rss_xml = new xmlWriter(); if (!$rss_xml) { die("Unable to create XML Writer\n"); } $rss_xml->openMemory(); $rss_xml->startDocument('1.0', 'utf-8'); $rss_xml->startElement('rss'); $rss_xml->writeAttribute('version', '2.0'); $rss_xml->startElement('channel'); $rss_xml->writeElement('title', 'Ångström autobuilder updates'); $rss_xml->writeElement('link', $build_link_base); $rss_xml->writeElement('description', 'Ångström autobuilder updates list'); foreach ($builder_log_date as $build) { $build = str_replace("\n", "", $build); $data = explode(' ', $build); $rss_xml->startElement('item'); $rss_xml->writeElement('title', "{$data[1]} ({$data[2]}) built for {$data[3]} (" . date('c', $data[0]) . ")"); $rss_xml->writeElement('link', "{$build_link_base}{$data[3]}/"); $rss_xml->writeElement('pubDate', date('r', $data[0])); $rss_xml->endElement(); } $rss_xml->endElement(); $rss_xml->endElement(); echo $rss_xml->outputMemory(true); echo "\n";
function daia($data, $resource) { $xml = new xmlWriter(); $xml->openMemory(); $xml->startElement("daia"); $xml->writeAttribute("xmlns", "http://ws.gbv.de/daia/"); $xml->writeElement("timestamp", strftime("%Y-%m-%dT%H:%m:%s-%Z")); $xml->startElement("item"); $xml->writeElement("id", $resource->id); $xml->writeElement("localid", $data["barcode_nmbr"]); $availability = array("service" => "loan", "available" => "false"); if (preg_match("/in|dis/", $data["status_cd"])) { $availability["available"] = "true"; } if ($data["status_cd"] == "out") { $now = time(); $then = strtotime($data["due_back_dt"]); $delay = round(($now - $then) / 86400); $availability["delay"] = "P" . $delay . "D"; } elseif ($data["status_cd"] == "out") { $availability["delay"] = "inf"; } elseif ($data["status_cd"] == "disp") { $availability["service"] = "presentation"; } $q = "SELECT material_cd FROM biblio WHERE bibid = " . $data["bibid"]; $r = mysql_query($q); $row = mysql_fetch_row($r); if ($row[0] == 6) { $availability["service"] = "presentation"; } $xml->startElement("availability"); for ($i = 0; $i < count($availability); $i++) { $xml->writeAttribute(key($availability), $availability[key($availability)]); next($availability); } $xml->startElement("message"); $xml->writeAttribute("lang", "en"); $xml->text($data["description"]); $xml->endElement(); $xml->endElement(); $xml->endElement(); $xml->endElement(); return $xml->outputMemory(true); }
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(); }
/** * Serializes an NimbleRecord to XML * @param NimbleRecord $obj * @return string XML */ public function build_record_xml($obj) { $data = $this->prep_for_serialization($obj); $xw = new xmlWriter(); $xw->openMemory(); foreach ($data as $key => $value) { $xw->writeElement($key, $value); } $xml = $xw->outputMemory(true); unset($xw); return $xml; }
if ($matchid != "") { // update the amount of bug occurances of the found item $query = "UPDATE " . $dbanalyzetable . " SET amount=amount+1 WHERE id=" . $matchid; $result = mysql_query($query) or die("<?xml version=\"1.0\" encoding=\"UTF-8\"?><result>0</result>"); } } // if the bug was found in a pattern, then store the id of the pattern, otherwise mark it as not linked via -1 value if ($matchid == "") { $matchid = -1; } $query = "INSERT INTO " . $dbcrashtable . " (contact, version, crashappversion, startmemory, endmemory, log, done, analyzed) values ('" . $contact . "', '" . $version . "', '" . $crashappversion . "', '" . $startmemory . "', '" . $endmemory . "', '" . $log . "', '" . $done . "', '" . $matchid . "')"; $result = mysql_query($query) or die("<?xml version=\"1.0\" encoding=\"UTF-8\"?><result>0</result>"); } } } } } } } } } $reader->close(); /* schliessen der Verbinung */ mysql_close($link); /* Ausgabe der Ergebnisse in XML */ $xw = new xmlWriter(); $xw->openMemory(); $xw->startDocument('1.0', 'UTF-8'); $xw->writeElement('result', $bugstatus); $xw->endElement(); echo $xw->outputMemory(true);
public function batman_advanced_conn_nexthop() { 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('Document'); $xw->writeElement('name', '200903170407-200903170408'); $xw->startElement('Folder'); $xw->startElement('name'); $xw->writeRaw('create'); $xw->endElement(); $routers = Router_old::getRouters(); $last_endet_crawl_cycle = Crawling::getLastEndedCrawlCycle(); foreach ($routers as $router) { //set own position to the position saved fix in netmon $router_longitude = $router['longitude']; $router_latitude = $router['latitude']; //if the router has an position in it's actual crawl data, then prefer this position $router_crawl = Router_old::getCrawlRouterByCrawlCycleId($last_endet_crawl_cycle['id'], $router['id']); if (!empty($router_crawl['longitude']) and !empty($router_crawl['latitude'])) { $router_longitude = $router_crawl['longitude']; $router_latitude = $router_crawl['latitude']; } //if the own position is not empt, then look for neighbours if (!empty($router_longitude) and !empty($router_latitude)) { //$originators = BatmanAdvanced::getCrawlBatmanAdvOriginatorsByCrawlCycleId($last_endet_crawl_cycle['id'], $router['id']); $originators = BatmanAdvanced::getCrawlBatmanAdvNexthopsByCrawlCycleId($last_endet_crawl_cycle['id'], $router['id']); //$originators = unserialize($originators['originators']); if (!empty($originators)) { foreach ($originators as $originator) { $neighbour_router = Router_old::getRouterByMacAndCrawlCycleId($originator['nexthop'], $last_endet_crawl_cycle['id']); $neighbour_router_longitude = $neighbour_router['longitude']; $neighbour_router_latitude = $neighbour_router['latitude']; $neighbour_router = Router_old::getCrawlRouterByCrawlCycleId($last_endet_crawl_cycle['id'], $neighbour_router['router_id']); if (!empty($neighbour_router['longitude']) and !empty($neighbour_router['latitude'])) { $neighbour_router_longitude = $neighbour_router['longitude']; $neighbour_router_latitude = $neighbour_router['latitude']; } //check if the position is not empty if (!empty($neighbour_router_longitude) and !empty($neighbour_router_longitude) and strlen($originator['nexthop']) == 17) { $xw->startElement('Placemark'); $xw->startElement('Style'); $xw->startElement('LineStyle'); $xw->startElement('color'); if (Config::getConfigValueByName('routervpnif') == $originator['outgoing_interface']) { $xw->writeRaw("20ff0000"); } else { if ($originator['link_quality'] >= 0 and $originator['link_quality'] < 105) { $xw->writeRaw("ff1e1eff"); } elseif ($originator['link_quality'] >= 105 and $originator['link_quality'] < 130) { $xw->writeRaw("ff4949ff"); } elseif ($originator['link_quality'] >= 130 and $originator['link_quality'] < 155) { $xw->writeRaw("ff6a6aff"); } elseif ($originator['link_quality'] >= 155 and $originator['link_quality'] < 180) { $xw->writeRaw("ff53acff"); } elseif ($originator['link_quality'] >= 180 and $originator['link_quality'] < 205) { $xw->writeRaw("ff79ebff"); } elseif ($originator['link_quality'] >= 205 and $originator['link_quality'] < 230) { $xw->writeRaw("ff7cff79"); } elseif ($originator['link_quality'] >= 230) { $xw->writeRaw("ff0aff04"); } } $xw->endElement(); /*$xw->startElement('width'); $xw->writeRaw("5"); $xw->endElement();*/ $xw->endElement(); $xw->endElement(); $xw->startElement('name'); $xw->writeRaw("myname"); $xw->endElement(); $xw->startElement('Polygon'); $xw->startElement('outerBoundaryIs'); $xw->startElement('LinearRing'); $xw->startElement('coordinates'); $xw->writeRaw("{$router['longitude']},{$router['latitude']},0\n\t\t\t\t\t\t\t{$neighbour_router_longitude},{$neighbour_router_latitude},0"); $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->endElement(); } } } } } $xw->endElement(); $xw->endElement(); $xw->endElement(); $xw->endDocument(); print $xw->outputMemory(true); return true; }
public function to_xml($include_head = true) { $xw = new \xmlWriter(); $xw->openMemory(); if ($include_head) { $xw->startDocument('1.0', 'UTF-8'); $xw->startElement(strtolower(static::$class)); } foreach ($this->row as $key => $value) { $xw->writeElement($key, $value); } if ($include_head) { $xw->endElement(); } return $xw->outputMemory(true); }
function toXML() { $xml = new xmlWriter(); $xml->openMemory(); $xml->startDocument('1.0', 'UTF-8'); $xml->startElement("OpenSearchDescription"); $xml->writeAttribute("xmlns", "http://a9.com/-/spec/opensearch/1.1/"); $xml->writeAttribute("xmlns:jangle", "http://jangle.org/opensearch/"); $xml->writeElement("ShortName", $this->shortName); if (isset($this->longName)) { $xml->writeElement("LongName", $this->longName); } if (isset($this->description)) { $xml->writeElement("Description", $this->description); } if (isset($this->developer)) { $xml->writeElement("Developer", $this->description); } if (isset($this->contact)) { $xml->writeElement("Contact", $this->contact); } if (isset($this->attribution)) { $xml->writeELement("Attribution", $this->attribution); } if (isset($this->syndicationRight)) { $xml->writeElement("SyndicationRight", $this->syndicationRight); } if (isset($this->adultContent)) { $xml->writeElement("adultContent", $this->adultContent); } if (isset($this->language)) { if (is_array($this->language)) { for ($i = 0; $i < count($this->language); $i++) { $xml->writeELement("Language", $this->language[$i]); } } else { $xml->writeElement("Language", $this->language); } } if (count($this->inputEncoding)) { if (is_array($this->inputEncoding)) { for ($i = 0; $i < count($this->inputEncoding); $i++) { $xml->writeELement("InputEncoding", $this->inputEncoding[$i]); } } else { $xml->writeElement("InputEncoding", $this->inputEncoding); } } if (count($this->outputEncoding)) { if (is_array($this->outputEncoding)) { for ($i = 0; $i < count($this->outputEncoding); $i++) { $xml->writeELement("OutputEncoding", $this->OuputEncoding[$i]); } } else { $xml->writeElement("OuputEncoding", $this->OuputEncoding); } } if (count($this->tags)) { $xml->writeElement("Tags", join($this->tags, " ")); } if (count($this->image)) { $xml->startElement("Image", $this->image["location"]); if ($this->image["height"]) { $xml->writeAttribute("height", $this->image["height"]); } if ($this->image["width"]) { $xml->writeAttribute("width", $this->image["width"]); } if ($this->image["type"]) { $xml->writeAttribute("type", $this->image["type"]); } $xml->endElement(); } if (count($this->indexes) || isset($this->exampleQuery)) { $xml->startElement("Query"); if (isset($this->exampleQuery)) { $xml->writeAttribute("role", "example"); $xml->writeAttribute("searchTerms", $this->exampleQuery); } if (count($this->indexes)) { $xml->startElement("zr:explain"); $xml->writeAttribute("xmlns:zr", "http://explain.z3950.org/dtd/2.1/"); $xml->startElement("zr:indexInfo"); for ($i = 0; $i < count($this->indexes); $i++) { $xml->startElement("zr:set"); $xml->writeAttribute("name", $this->indexes[$i]->name); if ($this->indexes[$i]->identifier) { $xml->writeAttribute("identifier", $this->indexes[$i]->identifier); } $xml->endELement(); for ($x = 0; $x < count($this->indexes[$i]->indexes); $x++) { $xml->startElement("zr:index"); $xml->startElement("zr:map"); $xml->startElement("zr:name"); $xml->writeAttribute("set", $this->indexes[$i]->name); $xml->text($this->indexes[$i]->indexes[$x]); $xml->endElement(); $xml->endElement(); $xml->endELement(); } } $xml->endElement(); $xml->endElement(); } $xml->endElement(); } $xml->endElement(); return $xml->outputMemory(true); }