public function _toHtml() { $this->_checkRequired(); $info = $this->getInfo(); $certain = $info['certain']; $dom = new DomDocument(); $dom->preserveWhitespace = false; $block = $dom->createElement('block'); $attr = $dom->createAttribute('type'); $attr->value = $this->getAlias(); $block->appendChild($attr); $dom->appendChild($block); $output = simplexml_load_string('<block />'); foreach ($certain as $method) { $block->appendChild($dom->createComment("\n " . $this->_getDocumentation($method) . "\n ")); $dom_action = $dom->createElement('action'); $block->appendChild($dom_action); $dom_attr = $dom->createAttribute('method'); $dom_attr->value = $method->getName(); $dom_action->appendChild($dom_attr); $this->addParamsToDomActionNodeFromReflectionMethod($dom, $dom_action, $method); //$action = $this->addParamsToActionNodeFromReflectionMethod($action, $method); } $dom->formatOutput = true; return $this->_extraXmlFormatting($dom->saveXml()); }
function makeXml($dbObject) { header("Content-Type: application/xml"); $doc = new DomDocument('1.0', 'UTF-8'); $uid = $doc->createElement('uid'); for ($i = 0; $i < $dbObject->rowCount(); $i++) { $result = $dbObject->fetch(); if ($i === 0) { $id = $doc->createAttribute('id'); $id->value = $result['usernum']; $uid->appendChild($id); $doc->appendChild($uid); } $prefix = array($result['num'], $result['in_out'], $result['type'], $result['amount'], $result['time'], $result['detail']); list($tnum, $inout, $type, $amount, $time, $detail) = $prefix; $trade_num = $doc->createElement('tnum'); $tr_att = $doc->createAttribute('nu'); $tr_att->value = $tnum; $trade_num->appendChild($tr_att); $trade_num->appendChild($doc->createElement('inout', $inout)); $trade_num->appendChild($doc->createElement('type', $type)); $trade_num->appendChild($doc->createElement('amount', $amount)); $trade_num->appendChild($doc->createElement('time', $time)); $trade_num->appendChild($doc->createElement('detail', $detail)); $uid->appendChild($trade_num); } $xml = $doc->saveXML(); print $xml; }
/** * General manipulate wrapper method. * * @param string $input The XML fragment to be manipulated. We are only * interested in the <extension><CSVData> fragment added in the * MIK mappings file. * * @return string * One of the manipulated XML fragment, the original input XML if the * input is not the fragment we are interested in, or an empty string, * which as the effect of removing the empty <extension><CSVData> * fragement from our MODS (if there was an error, for example, we don't * want empty extension elements in our MODS documents). */ public function manipulate($input) { $dom = new \DomDocument(); $dom->loadxml($input, LIBXML_NSCLEAN); // Test to see if the current fragment is <extension><CSVData>. $xpath = new \DOMXPath($dom); $csvdatas = $xpath->query("//extension/CSVData"); // There should only be one <CSVData> fragment in the incoming // XML. If there is 0 or more than 1, return the original. if ($csvdatas->length === 1) { $csvdata = $csvdatas->item(0); $csvid = $dom->createElement('id_in_csv', $this->record_key); $csvdata->appendChild($csvid); $timestamp = date("Y-m-d H:i:s"); // Add the <CSVRecord> element. $csvrecord = $dom->createElement('CSVRecord'); $now = $dom->createAttribute('timestamp'); $now->value = $timestamp; $csvrecord->appendChild($now); $mimetype = $dom->createAttribute('mimetype'); $mimetype->value = 'application/json'; $csvrecord->appendChild($mimetype); try { $metadata_path = $this->settings['FETCHER']['temp_directory'] . DIRECTORY_SEPARATOR . $this->record_key . '.metadata'; $metadata_contents = file_get_contents($metadata_path); $metadata_contents = unserialize($metadata_contents); $metadata_contents = json_encode($metadata_contents); } catch (Exception $e) { $message = "Problem creating <CSVRecord> element for object " . $this->record_key . ":" . $e->getMessage(); $this->log->addInfo("AddCsvData", array('CSV metadata warning' => $message)); return ''; } // If the metadata contains the CDATA end delimiter, log and return. if (preg_match('/\\]\\]>/', $metadata_contents)) { $message = "CSV metadata for object " . $this->record_key . ' contains the CDATA end delimiter ]]>'; $this->log->addInfo("AddCsvData", array('CSV metadata warning' => $message)); return ''; } // If we've made it this far, add the metadata to <CcvData> as // CDATA and return the modified XML fragment. if (strlen($metadata_contents)) { $cdata = $dom->createCDATASection($metadata_contents); $csvrecord->appendChild($cdata); $csvdata->appendChild($csvrecord); } return $dom->saveXML($dom->documentElement); } else { // If current fragment is not <extension><CSVData>, return it // unmodified. return $input; } }
/** * Build the validate address request * @return string * @throws \SimpleUPS\Api\MissingParameterException */ public function buildXml() { if (serialize($this->getAddress()) == serialize(new Address())) { throw new MissingParameterException('Address requires a Country code, Postal code, and either a City or State\\Province code'); } if ($this->getAddress()->getCountryCode() === null) { throw new MissingParameterException('Address requires a Country code'); } if ($this->getAddress()->getPostalCode() === null) { throw new MissingParameterException('Address requires a Postal code'); } $dom = new \DomDocument('1.0'); $dom->formatOutput = $this->getDebug(); $dom->appendChild($addressRequest = $dom->createElement('AddressValidationRequest')); $addressRequestLang = $dom->createAttribute('xml:lang'); $addressRequestLang->value = parent::getXmlLang(); $addressRequest->appendChild($request = $dom->createElement('Request')); $request->appendChild($transactionReference = $dom->createElement('TransactionReference')); $transactionReference->appendChild($dom->createElement('CustomerContext', $this->getCustomerContext())); $transactionReference->appendChild($dom->createElement('XpciVersion', $this->getXpciVersion())); $request->appendChild($dom->createElement('RequestAction', 'AV')); $addressRequest->appendChild($address = $dom->createElement('Address')); if ($this->getAddress()->getCity() != null) { $address->appendChild($dom->createElement('City', $this->getAddress()->getCity())); } if ($this->getAddress()->getStateProvinceCode() != null) { $address->appendChild($dom->createElement('StateProvinceCode', $this->getAddress()->getStateProvinceCode())); } if ($this->getAddress()->getPostalCode() != null) { $address->appendChild($dom->createElement('PostalCode', $this->getAddress()->getPostalCode())); } $address->appendChild($dom->createElement('CountryCode', $this->getAddress()->getCountryCode())); $xml = parent::buildAuthenticationXml() . $dom->saveXML(); return $xml; }
/** * Build the validate address request * @internal * @return string * @throws \SimpleUPS\Api\MissingParameterException */ public function buildXml() { if ($this->getShipment()->getDestination() == null) { throw new MissingParameterException('Shipment destination is missing'); } $dom = new \DomDocument('1.0'); $dom->formatOutput = $this->getDebug(); $dom->appendChild($ratingRequest = $dom->createElement('RatingServiceSelectionRequest')); $addressRequestLang = $dom->createAttribute('xml:lang'); $addressRequestLang->value = parent::getXmlLang(); $ratingRequest->appendChild($request = $dom->createElement('Request')); $request->appendChild($transactionReference = $dom->createElement('TransactionReference')); $transactionReference->appendChild($dom->createElement('CustomerContext', $this->getCustomerContext())); $request->appendChild($dom->createElement('RequestAction', 'Rate')); $request->appendChild($dom->createElement('RequestOption', 'Shop')); //@todo test with "Rate" as setting to determine difference $ratingRequest->appendChild($pickupType = $dom->createElement('PickupType')); $pickupType->appendChild($shipmentType = $dom->createElement('Code', $this->getPickupType())); if ($this->getRateType() != null) { $ratingRequest->appendChild($customerClassification = $dom->createElement('CustomerClassification')); $customerClassification->appendChild($dom->createElement('Code', $this->getRateType())); } // Shipment $shipment = $this->getShipment(); $shipment->setShipper(UPS::getShipper()); $ratingRequest->appendChild($shipment->toXml($dom)); $xml = parent::buildAuthenticationXml() . $dom->saveXML(); return $xml; }
public function createFiles($fileName = '', $startTag = '') { $filePath = SITEMAP_PATH . $fileName; if (!file_exists($filePath)) { fopen($filePath, 'w'); $objDom = new DomDocument('1.0'); $objDom->preserveWhiteSpace = true; $objDom->formatOutput = true; $xml = file_get_contents($filePath); if ($xml != '') { $objDom->loadXML($xml, LIBXML_NOBLANKS); } $objDom->encoding = 'UTF-8'; $objDom->formatOutput = true; $objDom->preserveWhiteSpace = false; $root = $objDom->createElement($startTag); $objDom->appendChild($root); $root_attr = $objDom->createAttribute("xmlns"); $root->appendChild($root_attr); $root_attr_text = $objDom->createTextNode("http://www.sitemaps.org/schemas/sitemap/0.9"); $root_attr->appendChild($root_attr_text); file_put_contents($filePath, $objDom->saveXML()); return true; } }
public static function create($vastVersion = '2.0') { $xml = new \DomDocument('1.0', 'UTF-8'); // root $root = $xml->createElement('VAST'); $xml->appendChild($root); // version $vastVersionAttribute = $xml->createAttribute('version'); $vastVersionAttribute->value = $vastVersion; $root->appendChild($vastVersionAttribute); // return return new self($xml); }
function addComment($CommentFile, $date_value, $author_value, $subject_value, $msg_value, $ip) { $xml = new DomDocument('1.0', 'utf-8'); if (file_exists($CommentFile)) { $xml->load($CommentFile); $root = $xml->firstChild; } else { $root = $xml->appendChild($xml->createElement("comments")); } $comment = $xml->createElement("comment"); $root->appendChild($comment); // Add date attribute $attr_date = $xml->createAttribute("timestamp"); $comment->appendChild($attr_date); $value = $xml->createTextNode($date_value); $attr_date->appendChild($value); // Add author attribute $attr_author = $xml->createAttribute("author"); $comment->appendChild($attr_author); $value = $xml->createTextNode($author_value); $attr_author->appendChild($value); // Add author ip address $attr_ip = $xml->createAttribute("ip"); $comment->appendChild($attr_ip); $value = $xml->createTextNode($ip); $attr_ip->appendChild($value); // add subject child node $subject = $xml->createElement("subject"); $comment->appendChild($subject); $value = $xml->createTextNode($subject_value); $subject->appendChild($value); // add message child node $msg = $xml->createElement("message"); $comment->appendChild($msg); $value = $xml->createTextNode($msg_value); $msg->appendChild($value); $xml->save($CommentFile); return $xml->getElementsByTagName("comment")->length; }
/** * * @param DomNode $node * @param array $error */ public function displayXmlError($node, $error) { $a = $this->errors->createAttribute("line"); $t = $this->errors->createAttribute("code"); $m = $this->errors->createTextNode(trim($error->message)); $node->appendChild($a); $node->appendChild($t); $node->appendChild($m); $node->setAttribute("line", $error->line); switch ($error->level) { case LIBXML_ERR_WARNING: $node->setAttribute("code", $error->code); break; case LIBXML_ERR_ERROR: $node->setAttribute("code", $error->code); break; case LIBXML_ERR_FATAL: $node->setAttribute("code", $error->code); break; } }
function update_dom_xml() { global $DBCstruct, $DBCfmt; foreach ($DBCfmt as $name => $format) { $struct = $DBCstruct[$name]; $xml = new DomDocument('1.0', 'utf-8'); $file = $xml->createElement('file'); $xname = $xml->createAttribute('name'); $value = $xname->appendChild($xml->createTextNode($name)); $xformat = $xml->createAttribute('format'); $value = $xformat->appendChild($xml->createTextNode($format)); for ($i = 0; $i < strlen($format); $i++) { $field = $xml->createElement('field'); $sid = $xml->createAttribute('id'); $value = $sid->appendChild($xml->createTextNode($i)); $count = @is_array($struct[$i]) ? $struct[$i][1] : 1; $scount = $xml->createAttribute('count'); $value = $scount->appendChild($xml->createTextNode($count > 1 ? $count : 1)); $key = @(is_array($struct[$i]) && $struct[$i][1] == INDEX_PRIMORY_KEY) ? 1 : 0; $skey = $xml->createAttribute('key'); $value = $skey->appendChild($xml->createTextNode($key)); $type = get_type($format[$i]); $stype = $xml->createAttribute('type'); $value = $stype->appendChild($xml->createTextNode($type)); $text_name = "unk{$i}"; if (isset($struct[$i]) && $struct[$i] != '') { $text_name = is_array($struct[$i]) ? $struct[$i][0] : $struct[$i]; } $sname = $xml->createAttribute('name'); $value = $sname->appendChild($xml->createTextNode($text_name)); $field->appendChild($sid); $field->appendChild($scount); $field->appendChild($sname); $field->appendChild($stype); $field->appendChild($skey); $file->appendChild($field); if ($count > 1) { $i += $count - 1; } } $file->appendChild($xname); $file->appendChild($xformat); $xml->appendChild($file); $xml->formatOutput = true; $xml->save('xml/' . $name . '.xml'); } }
/** * Build the validate address request * @return string * @throws \SimpleUPS\Api\MissingParameterException */ public function buildXml() { if (serialize($this->getAddress()) == serialize(new Address())) { throw new MissingParameterException('Address requires a Country code and a City, a State\\Province code or a Postal code'); } if ($this->getAddress()->getCountryCode() === null) { throw new MissingParameterException('Address requires a Country code'); } $dom = new \DomDocument('1.0'); $dom->formatOutput = $this->getDebug(); $dom->appendChild($addressRequest = $dom->createElement('AddressValidationRequest')); $addressRequestLang = $dom->createAttribute('xml:lang'); $addressRequestLang->value = parent::getXmlLang(); $addressRequest->appendChild($request = $dom->createElement('Request')); $request->appendChild($transactionReference = $dom->createElement('TransactionReference')); $transactionReference->appendChild($dom->createElement('CustomerContext', $this->getCustomerContext())); $request->appendChild($dom->createElement('RequestAction', 'XAV')); $request->appendChild($dom->createElement('RequestOption', '3')); $addressRequest->appendChild($address = $dom->createElement('AddressKeyFormat')); $address->appendChild($dom->createElement('AddressLine', $this->getAddress()->getStreet())); if ($this->getAddress()->getAddressLine2()) { $address->appendChild($dom->createElement('AddressLine', $this->getAddress()->getAddressLine2())); if ($this->getAddress()->getAddressLine3()) { $address->appendChild($dom->createElement('AddressLine', $this->getAddress()->getAddressLine3())); } } if ($this->getAddress()->getCity() != null) { $address->appendChild($dom->createElement('PoliticalDivision2', $this->getAddress()->getCity())); } if ($this->getAddress()->getStateProvinceCode() != null) { $address->appendChild($dom->createElement('PoliticalDivision1', $this->getAddress()->getStateProvinceCode())); } if ($this->getAddress()->getPostalCode() != null) { $address->appendChild($dom->createElement('PostcodePrimaryLow', $this->getAddress()->getPostalCode())); } $address->appendChild($dom->createElement('CountryCode', $this->getAddress()->getCountryCode())); $xml = parent::buildAuthenticationXml() . $dom->saveXML(); return $xml; }
/** * Add xsd:import tag to XML schema before any childs added * * @param string $namespace Namespace URI * @param string $code Shortcut for namespace, fx, ns0. Returned by getNsCode() * * @return void */ private function addImportToSchema($namespace, $code) { if (array_key_exists($namespace, $this->docNamespaces)) { if (in_array($namespace, $this->importedNamespaces)) { return; } //$dom = $this->wsdl->toDomDocument(); //print_r($namespace); $this->dom->createAttributeNs($namespace, $code . ":definitions"); $importEl = $this->dom->createElement($this->xmlSchemaPreffix . ":import"); $nsAttr = $this->dom->createAttribute("namespace"); $txtNode = $this->dom->createTextNode($namespace); $nsAttr->appendChild($txtNode); $nsAttr2 = $this->dom->createAttribute("schemaLocation"); $schemaLocation = $this->getSchemaLocation($namespace); $publicSchema = $this->copyToPublic($schemaLocation, true); $publicSchema = $this->copyToPublic($schemaLocation, true); $schemaUrl = $this->importsToAbsUrl($publicSchema, $this->getSchemasPath()); $txtNode2 = $this->dom->createTextNode($schemaUrl); $nsAttr2->appendChild($txtNode2); $importEl->appendChild($nsAttr); $importEl->appendChild($nsAttr2); //$this->wsdl->getSchema(); //$xpath = new \DOMXPath($this->dom); //$query = "//*[local-name()='types']/child::*/*"; //$firstElement = $xpath->query($query); //if (!is_object($firstElement->item(0))) { // $query = "//*[local-name()='types']/child::*"; // $schema = $xpath->query($query); // $schema->item(0)->appendChild($importEl); //} else { // $this->wsdl->getSchema()->insertBefore($importEl, $firstElement->item(0)); //} //$this->xmlSchemaImports //$this->wsXmlSchema->appendChild(); array_push($this->xmlSchemaImports, $importEl); array_push($this->importedNamespaces, $namespace); } }
/** * Build the validate address request * @return string * @throws \SimpleUPS\Api\MissingParameterException */ public function buildXml() { if ($this->getTrackingNumber() === null) { throw new MissingParameterException('Tracking lookup requires either a tracking number'); } $dom = new \DomDocument('1.0'); $dom->formatOutput = $this->getDebug(); $dom->appendChild($trackingRequest = $dom->createElement('TrackRequest')); $addressRequestLang = $dom->createAttribute('xml:lang'); $addressRequestLang->value = parent::getXmlLang(); $trackingRequest->appendChild($request = $dom->createElement('Request')); $request->appendChild($transactionReference = $dom->createElement('TransactionReference')); $transactionReference->appendChild($dom->createElement('CustomerContext', $this->getCustomerContext())); $request->appendChild($dom->createElement('RequestAction', 'Track')); $request->appendChild($dom->createElement('RequestOption', '1')); $trackingRequest->appendChild($shipmentType = $dom->createElement('ShipmentType')); $shipmentType->appendChild($shipmentType = $dom->createElement('Code', \SimpleUPS\Track\Request::TYPE_SMALL_PACKAGE)); if ($this->getTrackingNumber() !== null) { $trackingRequest->appendChild($dom->createElement('TrackingNumber', $this->getTrackingNumber())); } $xml = parent::buildAuthenticationXml() . $dom->saveXML(); return $xml; }
function addG($nom, $UID) { $xmldoc = new DomDocument('1.0'); $xmldoc->preserveWhiteSpace = false; $xmldoc->formatOutput = true; if ($xml = file_get_contents('../Ressources/Groupes.xml')) { $xmldoc->loadXML($xml, LIBXML_NOBLANKS); // find the headercontent tag $root = $xmldoc->getElementsByTagName('Groupes')->item(0); // create the <product> tag $categ = $xmldoc->createElement('Groupe'); $numAttribute = $xmldoc->createAttribute("id"); $numAttribute->value = maxId("Groupes"); $categ->appendChild($numAttribute); // add the product tag before the first element in the <headercontent> tag $root->insertBefore($categ, $root->firstChild); // create other elements and add it to the <product> tag. $nameElement = $xmldoc->createElement('nom'); $categ->appendChild($nameElement); $nameText = $xmldoc->createTextNode($nom); $nameElement->appendChild($nameText); $nameElement = $xmldoc->createElement('GID'); $categ->appendChild($nameElement); $nameText = $xmldoc->createTextNode(""); $nameElement->appendChild($nameText); $nameElement = $xmldoc->createElement('UID'); $categ->appendChild($nameElement); $nameText = $xmldoc->createTextNode($UID); $nameElement->appendChild($nameText); $xmldoc->save('../Ressources/Groupes.xml'); } }
function write_resource_on_xml_element(DomDocument $dom, $uri, DomElement $el, $parentUris) { /* resource ID */ if ($this->node_is_blank($uri)) { $idAttr = $dom->createAttribute('id'); } else { $idAttr = $dom->createAttribute('href'); } $idAttr->appendChild($dom->createTextNode($uri)); if (!empty($uri)) { $el->appendChild($idAttr); } $index = $this->get_index(); $isPrimaryTopicSameAsResult = ($el->tagName == 'primaryTopic' and count($parentUris) == 1); if (!in_array($uri, $parentUris) || $isPrimaryTopicSameAsResult) { $resourceProperties = array(FOAF . 'primaryTopic', FOAF . 'isPrimaryTopicOf', API . 'definition', DCT . 'hasFormat', DCT . 'hasVersion'); $parentUris[] = $uri; $properties = $this->get_subject_properties($uri); arsort($properties); //producing predictable output foreach ($properties as $property) { if (!$isPrimaryTopicSameAsResult || !in_array($property, $resourceProperties)) { $propertyName = $this->get_short_name_for_uri($property); $propEl = $dom->createElement($propertyName); $propValues = $index[$uri][$property]; if (count($propValues) > 1 || $this->propertyIsMultiValued($property)) { foreach ($propValues as $val) { $item = $dom->createElement('item'); $item = $this->write_rdf_value_to_xml_element($dom, $val, $item, $uri, $property, $parentUris); $propEl->appendChild($item); } } else { if (count($propValues) == 1) { $val = $propValues[0]; $propEl = $this->write_rdf_value_to_xml_element($dom, $val, $propEl, $uri, $property, $parentUris); } } $el->appendChild($propEl); } } } return $el; }
} if ($header == 'mobile_03') { $mobile_03 = $row[$i]; } if ($header == 'fax_03') { $fax_03 = $row[$i]; } if ($header == 'other_03') { $other_03 = $row[$i]; } } //Begin building XML $UR = $root->appendChild($xmlDoc->createElement('user')); // Parent Element $rectypeATTR = $UR->appendChild($xmlDoc->createElement("record_type", "PUBLIC")); $x = $xmlDoc->createAttribute('desc'); $x->value = "Public"; $rectypeATTR->appendChild($x); $UR->appendChild($rectypeATTR); if (isset($primary_id) && $primary_id != "NULL") { $UR->appendChild($xmlDoc->createElement("primary_id", $primary_id)); } if (isset($first_name) && $first_name != "NULL") { $UR->appendChild($xmlDoc->createElement("first_name", $first_name)); $full_name = $first_name; } if (isset($middle_name) && $middle_name != "NULL") { $UR->appendChild($xmlDoc->createElement("middle_name", $middle_name)); if (isset($full_name)) { $full_name .= " {$middle_name}"; } else {
/** * Выполняет бекапирование базы данных * @param String $backup_file - имя файла для сохранения структуры базы данных * @param String $backup_dir - имя директории для файлов с данными таблиц */ private function backupMySQL($backup_file = '/backup_database.xml', $backup_dir = '/umibackup') { if ($this->checkDone(__METHOD__)) { return true; } $this->setUpdateMode(); if (INSTALLER_CLI_MODE && !$this->getBackupMode('base') || !INSTALLER_CLI_MODE && $this->install_mode && !$this->getBackupMode('base')) { return true; } $backup_dir = CURRENT_WORKING_DIR . $backup_dir; $backup_file = $backup_dir . $backup_file; if ((!file_exists($backup_dir . '/mysql') || !is_dir($backup_dir . '/mysql')) && !mkdir($backup_dir . '/mysql', 0777, true)) { throw new Exception('Не удается создать директорию для сохранения данных таблиц.'); } if (!$this->closeByHtaccess($backup_dir)) { throw new Exception('Не удается закрыть директорию данных базы для доступа!'); } $this->includeMicrocore(); $this->flushLog("Бэкапирование базы..."); if (file_exists($backup_file)) { unlink($backup_file); } // Бекапирование структуры $converter = new dbSchemeConverter($this->connection); $converter->setMode('save'); $converter->setDestinationFile($backup_file); $converter->run(); // Список таблиц для выборки значений $xml = new DomDocument(); $xml->formatOutput = true; $xml->load($backup_file); $xpath = new DOMXPath($xml); $tables = $xpath->query('//table'); foreach ($tables as $table) { $backuped = $xml->createAttribute('backuped'); $table->appendChild($backuped); $backuped->appendChild($xml->createTextNode('false')); } $xml->save($backup_file); if (!isset($xml)) { $xml = new DomDocument(); $xml->formatOutput = true; $xml->load($backup_file); if (!$xml) { throw new Exception('Не удается загрузить xml документ.'); } $xpath = new DOMXPath($xml); } // Собираем список таблиц для блокировки $tables = $xpath->query('//table'); if (0 < $tables->length) { foreach ($tables as $table) { $table_name[] = $table->getAttributeNode('name')->nodeValue; } $query = "LOCK TABLES `" . implode("` READ, `", $table_name) . "` READ"; l_mysql_query($query); $tables = $xpath->query('//table[@backuped="false"]'); if (0 < $tables->length) { foreach ($tables as $table) { $this->execSubProcess('backup-mysql-table', array('table_name' => $table->getAttributeNode('name')->nodeValue, 'backup_dir' => $backup_dir . '/mysql')); $table->setAttribute('backuped', 'true'); $xml->save($backup_file); } } $query = "UNLOCK TABLES"; l_mysql_query($query); $this->flushLog("База данных была сохранена."); } else { $this->flushLog("В базе данных отсутствуют таблицы для сохранения."); } $this->setDone(__METHOD__); return true; }
system("/usr/local/bin/mp42ts $videopath $tspath"); transcode(); */ $xmldoc = new DomDocument('1.0'); $xmldoc->preserveWhiteSpace = false; $xmldoc->formatOutput = true; if ($xml = file_get_contents('infopk.xml')) { echo "sunnnnnnnnnns"; debug("sunny#### {$folderName}"); debug("sunny@@@@ {$xml}"); $xmldoc->loadXML($xml, LIBXML_NOBLANKS); // find the headercontent tag $root = $xmldoc->getElementsByTagName('SegmentsPath')->item(0); // create the <product> tag $product = $xmldoc->createElement('Segment'); $numAttribute = $xmldoc->createAttribute("value"); $numAttribute->value = $folderName; $product->appendChild($numAttribute); // add the product tag before the first element in the <headercontent> tag $root->insertBefore($product, $root->firstChild); // create other elements and add it to the <product> tag. $nameElement = $xmldoc->createElement('High'); $product->appendChild($nameElement); $nameText = $xmldoc->createTextNode("/high/output1.mp4"); $nameElement->appendChild($nameText); $categoryElement = $xmldoc->createElement('Medium'); $product->appendChild($categoryElement); $categoryText = $xmldoc->createTextNode("/high/output2.mp4"); $categoryElement->appendChild($categoryText); $availableElement = $xmldoc->createElement('Low'); $product->appendChild($availableElement);
function xslfilter($buffer) { global $__xslfilter_debug; global $__xslfilter_phpfunc; global $__xslfilter_prehook; global $__xslfilter_posthook; global $__xslfilter_start_utime; global $__xslfilter_i18n; if (empty($buffer)) { return false; } if ($__xslfilter_debug) { return false; } libxml_use_internal_errors(true); if (!array_key_exists('WEB_LAYOUT', $_SERVER) && !array_key_exists('XSL_DIR', $_SERVER) && !array_key_exists('XSL_STYLESHEET', $_SERVER)) { return __xslfilter_do_error("Missing stylesheet information", "None of the environment variables <code>WEB_LAYOUT</code>, " . "<code>XSL_DIR</code> or <code>XSL_STYLESHEET</code> " . "have been defined"); } libxml_clear_errors(); // Load document $doc = new DOMDocument(); if (!$doc->loadXML($buffer, LIBXML_NONET)) { return __xslfilter_do_error("Error in current document", __xslfilter_build_xmlerrors(libxml_get_errors())); } // Processing instruction if ($r = __xslfilter_process_pi($doc)) { return $r; } // XSLT Processor $xslt = new xsltProcessor(); // Basic information $xslt->setParameter('', 'lastmod', gmstrftime("%Y%m%d%H%M%SZ", getlastmod())); $xslt->setParameter('', 'now', gmstrftime("%Y%m%d%H%M%SZ", time())); // Information about http request $xslt->setParameter('', 'http-referer', array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : null); $xslt->setParameter('', 'request-uri', array_key_exists('REQUEST_URI', $_SERVER) ? $_SERVER['REQUEST_URI'] : null); $xslt->setParameter('', 'base-uri', array_key_exists('SCRIPT_FILENAME', $_SERVER) ? dirname($_SERVER['SCRIPT_FILENAME']) : null); $xslt->setParameter('', 'server-name', array_key_exists('SERVER_NAME', $_SERVER) ? $_SERVER['SERVER_NAME'] : null); $xslt->setParameter('', 'secure', array_key_exists('HTTPS', $_SERVER) ? 'true' : null); $xslt->setParameter('', 'protocol', array_key_exists('HTTPS', $_SERVER) ? 'https' : 'http'); if (($script_uri = parse_url($_SERVER['SCRIPT_URI'])) !== false) { $xslt->setParameter('', 'uri-scheme', @$script_uri['scheme']); $xslt->setParameter('', 'uri-host', @$script_uri['host']); $xslt->setParameter('', 'uri-port', @$script_uri['port']); $xslt->setParameter('', 'uri-path', @$script_uri['path']); $xslt->setParameter('', 'uri-query', @$script_uri['query']); $xslt->setParameter('', 'uri-fragment', @$script_uri['fragment']); } else { $xslt->setParameter('', 'uri-scheme', null); $xslt->setParameter('', 'uri-host', null); $xslt->setParameter('', 'uri-port', null); $xslt->setParameter('', 'uri-path', null); $xslt->setParameter('', 'uri-query', null); $xslt->setParameter('', 'uri-fragment', null); } // Parameters set from apache server $xslt->setParameter('', 'pagedesc-default-xml', array_key_exists('WEB_LAYOUT', $_SERVER) ? $_SERVER['WEB_LAYOUT'] . '/defaults.xml' : null); $xslt->setParameter('', 'expect-lang', array_key_exists('expect-lang', $_SERVER) ? $_SERVER['expect-lang'] : null); $xslt->setParameter('', 'handheld-client', array_key_exists('handheld-client', $_SERVER) ? $_SERVER['handheld-client'] : null); // Pre hook if (!is_null($__xslfilter_prehook) && ($r = $__xslfilter_prehook($doc, $xslt)) !== true) { return $r; } // PHP function enabling if ($__xslfilter_phpfunc) { $xslt->registerPHPFunctions(is_array($__xslfilter_phpfunc) ? $__xslfilter_phpfunc : null); } // Lang to import localization templates $lang = ''; if ($__xslfilter_i18n === null || $__xslfilter_i18n) { $lang = $doc->documentElement->getAttribute('lang'); } if (empty($lang) && !is_null($__xslfilter_i18n) && is_string($__xslfilter_i18n)) { $lang = $__xslfilter_i18n; } // Listing stylesheet $stylesheet = array(); if (array_key_exists('WEB_LAYOUT', $_SERVER) || array_key_exists('XSL_DIR', $_SERVER)) { $xsl_dir = array_key_exists('XSL_DIR', $_SERVER) ? $_SERVER['XSL_DIR'] : $_SERVER['WEB_LAYOUT']; $style = __xslfilter_get_stylesheet($doc, 'text/xsl'); foreach ($style as $s) { if (!($href = $s['href'])) { continue; } if ($href[0] == '/' || preg_match('|^\\w+://|', $href)) { return __xslfilter_do_error("Error in current document", "Only local and relative stylesheet are allowed"); } $stylesheet[] = $xsl_dir . '/' . $href; } if (empty($stylesheet) && array_key_exists('XSL_STYLESHEET', $_SERVER)) { $href = $_SERVER['XSL_STYLESHEET']; if ($href[0] != '/') { array_push($stylesheet, $xsl_dir . '/' . $href); } } if (!empty($lang)) { $href = 'l10n/' . $lang . '.xsl'; if (file_exists($file = $xsl_dir . '/' . $href)) { $stylesheet[] = $file; } } } else { if (array_key_exists('XSL_STYLESHEET', $_SERVER)) { array_push($stylesheet, $_SERVER['XSL_STYLESHEET']); if (!empty($lang)) { $file = dirname($_SERVER['XSL_STYLESHEET']) . '/' . 'l10n/' . $lang . '.xsl'; if (file_exists($file)) { $stylesheet[] = $file; } } } else { return __xslfilter_do_error("No usable stylesheet", "Missing stylesheet at server and document level"); } } // Importing stylesheet if (count($stylesheet) <= 1) { // Correct code for importing stylesheet // Unfortunately PHP only take into account the last import foreach ($stylesheet as $file) { libxml_clear_errors(); $xsl = new DomDocument(); $xsl->substituteEntities = true; // LIBXML_NOENT if (!$xsl->load($file, LIBXML_NONET)) { return __xslfilter_do_error("Error in stylesheet: {$href}", __xslfilter_build_xmlerrors(libxml_get_errors())); } $xslt->importStyleSheet($xsl); } } else { // Fix code to import several stysheets // By faking a top level stylesheet with import statements libxml_clear_errors(); $xsl = new DomDocument('1.0'); $xsl->substituteEntities = true; // LIBXML_NOENT $root = $xsl->createElementNS('http://www.w3.org/1999/XSL/Transform', 'xsl:stylesheet'); $v = $xsl->createAttribute('version'); $v->value = "1.0"; $root->appendChild($v); $xsl->appendChild($root); foreach ($stylesheet as $file) { $s = $xsl->createElementNS('http://www.w3.org/1999/XSL/Transform', 'xsl:import'); $h = $xsl->createAttribute('href'); $h->value = $file; $s->appendChild($h); $root->appendChild($s); } $xslt->importStyleSheet($xsl); } // Applying transformation $r = $xslt->transformToXML($doc); if ($errors = libxml_get_errors()) { return __xslfilter_do_error("Error while rendering document", __xslfilter_build_xmlerrors($errors)); } // Something wrong, but we have no clue if ($r == false) { return __xslfilter_do_error("Error while rendering document", "Check document and associated stylesheets"); } // Job's done return $r; }
private function createRss() { $dom = new DomDocument("1.0", "utf-8"); $dom->formatOutput = true; $dom->preserveWhiteSpace = false; //create $dom and done format $rss = $dom->createElement("rss"); $dom->appendChild($rss); //create rss $version = $dom->createAttribute("version"); $version->value = '2.0'; //choose version $rss->appendChild($version); $chanel = $dom->createElement("chanel"); $title = $dom->createElement("title", self::RSS_TITLE); $link = $dom->createElement("link", self::RSS_LINK); $chanel->appendChild($title); $chanel->appendChild($link); $chanel->appendChild($link); $rss->appendChild($chanel); $lenta = $this->getNews(); if (!$lenta) { return false; } foreach ($lenta as $news) { $item = $dom->createElement("item"); $title = $dom->createElement("title", $news["title"]); $category = $dom->createElement("category", $news["category"]); //обёртка над description $desc = $dom->createElement("description"); $cdata = $dom->createCDATASection($news["description"]); $desc->appendChild($cdata); $link = $dom->createElement("link", "#"); $dt = date("r", $news["datetime"]); $pubDate = $dom->createElement("pubDate", $dt); $item->appendChild($title); $item->appendChild($link); $item->appendChild($desc); $item->appendChild($pubDate); $item->appendChild($category); $chanel->appendChild($item); } $dom->save(self::RSS_NAME); }
/** * * create directory tree html */ public function getDirectoryTree($path, $skip_files = false, $link_prefix = '') { $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); $dom = new DomDocument("1.0"); $li = $dom; $ul = $dom->createElement('ul'); $li->appendChild($ul); $el = $dom->createElement('li', 'Home'); $at = $dom->createAttribute('clink'); $at->value = $link_prefix; $el->appendChild($at); $ul->appendChild($el); $node = $ul; $depth = -1; foreach ($objects as $object) { $name = $object->getFilename(); // skip unwanted files if ($name == '.' || $name == '..' || in_array($name, gatorconf::get('restricted_files'))) { continue; } $path = str_replace('\\', '/', $object->getPathname()); $isDir = is_dir($path); $link = str_replace(gatorconf::get('repository'), '', $path); $link = gator::encodeurl(ltrim($link, '/\\')); $skip = false; if ($isDir == false && $skip_files == true) { // skip unwanted files $skip = true; } elseif ($isDir == false) { // this is regural file, no links here $link = ''; } else { // this is dir $link = $link; } if ($objects->getDepth() == $depth) { //the depth hasnt changed so just add another li if (!$skip) { $el = $dom->createElement('li', $name); $at = $dom->createAttribute('clink'); $at->value = $link_prefix . $this->encrypt($link); $el->appendChild($at); if (!$isDir) { $el->appendChild($dom->createAttribute('isfile')); } $node->appendChild($el); } } elseif ($objects->getDepth() > $depth) { //the depth increased, the last li is a non-empty folder $li = $node->lastChild; $ul = $dom->createElement('ul'); $li->appendChild($ul); if (!$skip) { $el = $dom->createElement('li', $name); $at = $dom->createAttribute('clink'); $at->value = $link_prefix . $this->encrypt($link); $el->appendChild($at); if (!$isDir) { $el->appendChild($dom->createAttribute('isfile')); } $ul->appendChild($el); } $node = $ul; } else { //the depth decreased, going up $difference directories $difference = $depth - $objects->getDepth(); for ($i = 0; $i < $difference; $difference--) { $node = $node->parentNode->parentNode; } if (!$skip) { $el = $dom->createElement('li', $name); $at = $dom->createAttribute('clink'); $at->value = $link_prefix . $this->encrypt($link); $el->appendChild($at); if (!$isDir) { $el->appendChild($dom->createAttribute('isfile')); } $node->appendChild($el); } } $depth = $objects->getDepth(); } return $dom->saveHtml(); }
function gpx_export_dots(&$dots, &$more) { $ns_map = array('' => 'http://www.topografix.com/GPX/1/1', 'dotspotting' => 'x-urn:dotspotting#internal', 'sheet' => 'x-urn:dotspotting#sheet'); $skip = array('latitude', 'longitude', 'elevation', 'created'); $doc = new DomDocument('1.0', 'UTF-8'); $gpx = $doc->createElement('gpx'); $gpx = $doc->appendChild($gpx); $_ver = $doc->createTextNode('1.1'); $ver = $doc->createAttribute("version"); $ver->appendChild($_ver); $gpx->appendChild($ver); $_creator = $doc->createTextNode('Dotspotting'); $creator = $doc->createAttribute('creator'); $creator->appendChild($_creator); $gpx->appendChild($creator); foreach ($ns_map as $prefix => $uri) { $xmlns = $prefix ? "xmlns:{$prefix}" : "xmlns"; $attr = $doc->createAttribute($xmlns); $uri = $doc->createTextNode($uri); $attr->appendChild($uri); $gpx->appendChild($attr); } $trk = $doc->createElement('trk'); $trk = $gpx->appendChild($trk); $_dot = dots_get_dot($dots[0]['dotspotting:id']); $_name = $_dot['sheet']['label'] ? "Dots from the sheet '{$_dot['sheet']['label']}'" : "Dots from sheet ID #{$_dot['sheet']['id']}"; $_name = $doc->createTextNode(htmlspecialchars($_name)); $name = $doc->createElement('name'); $name->appendChild($_name); $trk->appendChild($name); $_desc = $doc->createTextNode("n/a"); $desc = $doc->createElement('desc'); $desc->appendChild($_desc); $trk->appendChild($desc); $trkseg = $doc->createElement('trkseg'); $trkseg = $trk->appendChild($trkseg); foreach ($dots as $dot) { $trkpt = $doc->createElement('trkpt'); $_lat = $doc->createTextNode($dot['latitude']); $_lon = $doc->createTextNode($dot['longitude']); $lat = $doc->createAttribute("lat"); $lat->appendChild($_lat); $lon = $doc->createAttribute("lon"); $lon->appendChild($_lon); $trkpt->appendChild($lat); $trkpt->appendChild($lon); # $elevation = isset($dot['elevation']) ? $dot['elevation'] : '0.000000'; $_ele = $doc->createTextNode($elevation); $ele = $doc->createElement('ele'); $ele->appendChild($_ele); $trkpt->appendChild($ele); # $created = strtotime($dot['created']); $created = gmdate('Y-m-d\\TH:m:s\\Z', $created); $_time = $doc->createTextNode($created); $time = $doc->createElement('time'); $time->appendChild($_time); $trkpt->appendChild($time); # non-standard elements makes tools by garmin cry... # (20110113/straup) $trkseg->appendChild($trkpt); } $doc->save($more['path']); return $more['path']; }
<?php if (!defined('FLUX_ROOT')) { exit; } include 'status.php'; $dom = new DomDocument('1.0', 'utf-8'); $root = $dom->createElement('ServerStatus'); // Root element. foreach ($serverStatus as $privServerName => $gameServers) { $group = $dom->createElement('Group'); $name = $dom->createAttribute('name'); $name->nodeValue = $privServerName; // Append server name element. $group->appendChild($name); foreach ($gameServers as $serverName => $gameServer) { $serv = $dom->createElement('Server'); $name = $dom->createAttribute('name'); $name->nodeValue = $serverName; $serv->appendChild($name); $lserv = $dom->createAttribute('loginServer'); $cserv = $dom->createAttribute('charServer'); $mserv = $dom->createAttribute('mapServer'); $online = $dom->createAttribute('playersOnline'); $atmerc = $dom->createAttribute('autotradeMerchants'); $population = $dom->createAttribute('population'); $lserv->nodeValue = (int) $gameServer['loginServerUp']; $cserv->nodeValue = (int) $gameServer['charServerUp']; $mserv->nodeValue = (int) $gameServer['mapServerUp']; $online->nodeValue = (int) $gameServer['playersOnline']; $atmerc->nodeValue = (int) $gameServer['autotradeMerchants'];
/** * @param \DomDocument $dom * @param \DomNode $parent * @param string $identifier * @return void */ protected function createXlfLanguageNode(\DomDocument $dom, \DomNode $parent, $identifier) { $labelNode = $dom->createElement('trans-unit'); $idAttribute = $dom->createAttribute('id'); $idAttribute->nodeValue = $identifier; $spaceAttribute = $dom->createAttribute('xml:space'); $spaceAttribute->nodeValue = 'preserve'; $sourceNode = $dom->createElement('source'); $sourceNode->nodeValue = $identifier; $labelNode->appendChild($idAttribute); $labelNode->appendChild($spaceAttribute); $labelNode->appendChild($sourceNode); $parent->appendChild($labelNode); }
public function rssObservations() { global $objObservation, $objInstrument, $objLocation, $objPresentations, $objObserver, $baseURL, $objUtil; $dom = new DomDocument('1.0', 'US-ASCII'); // add root fcga -> The header $rssInfo = $dom->createElement('rss'); $rssDom = $dom->appendChild($rssInfo); $attr = $dom->createAttribute("version"); $rssInfo->appendChild($attr); $attrText = $dom->createTextNode("2.0"); $attr->appendChild($attrText); $attr = $dom->createAttribute("xmlns:content"); $rssInfo->appendChild($attr); $attrText = $dom->createTextNode("http://purl.org/rss/1.0/modules/content/"); $attr->appendChild($attrText); $attr = $dom->createAttribute("xmlns:dc"); $rssInfo->appendChild($attr); $attrText = $dom->createTextNode("http://purl.org/dc/elements/1.1/"); $attr->appendChild($attrText); $attr = $dom->createAttribute("xmlns:atom"); $rssInfo->appendChild($attr); $attrText = $dom->createTextNode("http://www.w3.org/2005/Atom"); $attr->appendChild($attrText); // add root - <channel> $channelDom = $rssDom->appendChild($dom->createElement('channel')); // add root - <channel> - <title> $titleDom = $channelDom->appendChild($dom->createElement('title')); $titleDom->appendChild($dom->createTextNode("DeepskyLog")); // add root - <channel> - <description> $descDom = $channelDom->appendChild($dom->createElement('description')); $descDom->appendChild($dom->createTextNode("DeepskyLog - visual deepsky and comets observations")); // add root - <channel> - <atom> $atomDom = $channelDom->appendChild($dom->createElement('atom:link')); $attr = $dom->createAttribute("href"); $atomDom->appendChild($attr); $attrText = $dom->createTextNode($baseURL . "observations.rss"); $attr->appendChild($attrText); $attr = $dom->createAttribute("rel"); $atomDom->appendChild($attr); $attrText = $dom->createTextNode("self"); $attr->appendChild($attrText); $attr = $dom->createAttribute("type"); $atomDom->appendChild($attr); $attrText = $dom->createTextNode("application/rss+xml"); $attr->appendChild($attrText); // add root - <channel> - <link> $linkDom = $channelDom->appendChild($dom->createElement('link')); $linkDom->appendChild($dom->createTextNode("http://www.deepskylog.org/")); $theDate = date('r'); // add root - <channel> - <link> $lbdDom = $channelDom->appendChild($dom->createElement('lastBuildDate')); $lbdDom->appendChild($dom->createTextNode($theDate)); // Get the new deepsky observations of the last month $theDate = date('Ymd', strtotime('-1 month')); $_GET['minyear'] = substr($theDate, 0, 4); $_GET['minmonth'] = substr($theDate, 4, 2); $_GET['minday'] = substr($theDate, 6, 2); $query = array("catalog" => '%', "mindate" => $objUtil->checkGetDate('minyear', 'minmonth', 'minday')); $result = $objObservation->getObservationFromQuery($query, 'A'); while (list($key, $value) = each($result)) { // add root - <channel> - <item> $itemDom = $channelDom->appendChild($dom->createElement('item')); $titleDom = $itemDom->appendChild($dom->createElement('title')); $titleDom->appendChild($dom->createTextNode($value['observername'] . " : " . $value['objectname'] . " with " . htmlspecialchars_decode($objInstrument->getInstrumentPropertyFromId($value['instrumentid'], 'name')) . " from " . $objLocation->getLocationPropertyFromId($objObservation->getDsObservationProperty($value['observationid'], 'locationid'), 'name'))); $linkDom = $itemDom->appendChild($dom->createElement('link')); $linkDom->appendChild($dom->createCDATASection($baseURL . "index.php?indexAction=detail_observation&observation=" . $value['observationid'] . "&QobsKey=0&dalm=D")); $descDom = $itemDom->appendChild($dom->createElement('description')); $descDom->appendChild($dom->createCDATASection($objPresentations->br2nl(utf8_encode($value['observationdescription'])))); $authorDom = $itemDom->appendChild($dom->createElement('dc:creator')); $authorDom->appendChild($dom->createCDATASection($value['observername'])); $guidDom = $itemDom->appendChild($dom->createElement('guid')); $guidDom->appendChild($dom->createTextNode("deepsky" . $value['observationid'])); $attr = $dom->createAttribute("isPermaLink"); $guidDom->appendChild($attr); $attrText = $dom->createTextNode("false"); $attr->appendChild($attrText); $pubDateDom = $itemDom->appendChild($dom->createElement('pubDate')); date_default_timezone_set('UTC'); $time = -999; $obs = $objObservation->getAllInfoDsObservation($value['observationid']); $time = $obs['time']; if ($time >= "0") { $hour = (int) ($time / 100); $minute = $time - 100 * $hour; } else { $hour = 0; $minute = 0; } $date = $value['observationdate']; $year = substr($date, 0, 4); $month = substr($date, 4, 2); $day = substr($date, 6, 2); $pubDateDom->appendChild($dom->createTextNode(date("r", mktime($hour, $minute, 0, $month, $day, $year)))); } include_once "cometobjects.php"; include_once "observers.php"; include_once "instruments.php"; include_once "locations.php"; include_once "cometobservations.php"; include_once "icqmethod.php"; include_once "icqreferencekey.php"; global $instDir, $objCometObject; $objects = new CometObjects(); $observer = new Observers(); $instrument = new Instruments(); $observation = new CometObservations(); $location = new Locations(); $util = $this; $ICQMETHODS = new ICQMETHOD(); $ICQREFERENCEKEYS = new ICQREFERENCEKEY(); $cometsResult = $observation->getObservationFromQuery($query); while (list($key, $value) = each($cometsResult)) { $objectname = $objCometObject->getName($observation->getObjectId($value)); // add root - <channel> - <item> $itemDom = $channelDom->appendChild($dom->createElement('item')); $title = htmlspecialchars_decode($objectname); // Location and instrument if ($observation->getLocationId($value) != 0 && $observation->getLocationId($value) != 1) { $title = $title . " from " . htmlspecialchars_decode($location->getLocationPropertyFromId($observation->getLocationId($value), 'name')); } if ($observation->getInstrumentId($value) != 0) { $title = $title . " with " . htmlspecialchars_decode($instrument->getInstrumentPropertyFromId($observation->getInstrumentId($value), 'name')); } $titleDom = $itemDom->appendChild($dom->createElement('title')); $titleDom->appendChild($dom->createTextNode($title)); $linkDom = $itemDom->appendChild($dom->createElement('link')); $linkDom->appendChild($dom->createCDATASection($baseURL . "index.php?indexAction=comets_detail_observation&observation=" . $value)); // Description $description = $observation->getDescription($value); if (strcmp($description, "") != 0) { $descDom = $itemDom->appendChild($dom->createElement('description')); $descDom->appendChild($dom->createCDATASection($objPresentations->br2nl(utf8_encode($description)))); } else { $descDom = $itemDom->appendChild($dom->createElement('description')); $descDom->appendChild($dom->createCDATASection("")); } $observerid = $observation->getObserverId($value); $observername = $observer->getObserverProperty($observerid, 'firstname') . " " . $observer->getObserverProperty($observerid, 'name'); $authorDom = $itemDom->appendChild($dom->createElement('dc:creator')); $authorDom->appendChild($dom->createCDATASection($observername)); $guidDom = $itemDom->appendChild($dom->createElement('guid')); $guidDom->appendChild($dom->createTextNode("comet" . $value)); $attr = $dom->createAttribute("isPermaLink"); $guidDom->appendChild($attr); $attrText = $dom->createTextNode("false"); $attr->appendChild($attrText); $pubDateDom = $itemDom->appendChild($dom->createElement('pubDate')); date_default_timezone_set('UTC'); $date = sscanf($observation->getLocalDate($value), "%4d%2d%2d"); $time = $observation->getLocalTime($value); $hour = (int) ($time / 100); $minute = $time - $hour * 100; $pubDateDom->appendChild($dom->createTextNode(date("r", mktime($hour, $minute, 0, $date[1], $date[2], $date[0])))); } // generate xml $dom->formatOutput = true; // set the formatOutput attribute of // domDocument to true // save XML as string or file $test1 = $dom->saveXML(); // put string in test1 print $test1; }
function regenerate() { global $dom; global $structureDomFile; global $data; if (file_exists($structureDomFile)) { $dom = new DomDocument(); $dom->load($structureDomFile); } else { $dom = new DomDocument(); $root = $dom->createElement('root'); // put id "root" to the root node : tricky... because of some weird php bug(?) $attr = $dom->createAttribute("xml:id"); $root->appendChild($attr); $tNode = $dom->createTextNode("root"); $attr->appendChild($tNode); $root->setIdAttribute("xml:id", true); $dom->appendChild($root); $dom->save($structureDomFile); } $data = new rootAccessor(); }
public function export2() { try { $dom = new DomDocument(); $id = $dom->createAttribute('id'); // $id->appendChild($dom->createTextNode($this->lesson['id'])); $lessonNode = $dom->createElement("lesson"); $lessonNode->appendChild($id); $lessonNode = $dom->appendChild($lessonNode); $parentNodes[0] = $lessonNode; $lessonContent = new EfrontContentTree($this->lesson['id']); foreach ($iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent->tree), RecursiveIteratorIterator::SELF_FIRST)) as $key => $properties) { $result = eF_getTableData("content", "*", "id={$key}"); $contentNode = $dom->appendChild($dom->createElement("content")); //<content></content> $parentNodes[$iterator->getDepth() + 1] = $contentNode; $attribute = $contentNode->appendChild($dom->createAttribute('id')); //<content id = ""></content> $attribute->appendChild($dom->createTextNode($key)); //<content id = "CONTENTID:32"></content> foreach ($result[0] as $element => $value) { if ($element == 'data') { $value = htmlentities($value); } if ($element != 'id' && $element != 'previous_content_ID' && $element != 'parent_content_ID' && $element != 'lessons_ID') { $element = $contentNode->appendChild($dom->createElement($element)); $element->appendChild($dom->createTextNode($value)); } } /* if ($properties['ctg_type'] == 'tests') { $result = eF_getTableData("tests", "*", "content_ID=$key"); foreach ($result[0] as $element => $value) { } } */ $parentNodes[$iterator->getDepth()]->appendChild($contentNode); //<lesson><content></content></lesson> } header("content-type:text/xml"); echo $dom->saveXML(); //$content = eF_getTableData("content", "*", "lessons_ID=".$this -> lesson['id']); } catch (Exception $e) { pr($e); } }
private function backupMySQL($v65d20a2eeb64b467ae2a1ff3c9116f7b = '/backup_database.xml', $v6fdcc2f9613d38eea050742973189d44 = '/umibackup') { if ($this->checkDone(__METHOD__)) { return true; } $this->setUpdateMode(); if (INSTALLER_CLI_MODE && !$this->getBackupMode('base') || !INSTALLER_CLI_MODE && $this->install_mode && !$this->getBackupMode('base')) { return true; } $v6fdcc2f9613d38eea050742973189d44 = CURRENT_WORKING_DIR . $v6fdcc2f9613d38eea050742973189d44; $v65d20a2eeb64b467ae2a1ff3c9116f7b = $v6fdcc2f9613d38eea050742973189d44 . $v65d20a2eeb64b467ae2a1ff3c9116f7b; if ((!file_exists($v6fdcc2f9613d38eea050742973189d44 . '/mysql') || !is_dir($v6fdcc2f9613d38eea050742973189d44 . '/mysql')) && !mkdir($v6fdcc2f9613d38eea050742973189d44 . '/mysql', 0777, true)) { throw new Exception('Не удается создать директорию для сохранения данных таблиц.'); } if (!$this->closeByHtaccess($v6fdcc2f9613d38eea050742973189d44)) { throw new Exception('Не удается закрыть директорию данных базы для доступа!'); } $this->includeMicrocore(); $this->flushLog("Бэкапирование базы..."); if (file_exists($v65d20a2eeb64b467ae2a1ff3c9116f7b)) { unlink($v65d20a2eeb64b467ae2a1ff3c9116f7b); } $v0ea7dd4da372f1a68a5dda3b9fc7e2e8 = new dbSchemeConverter($this->connection); $v0ea7dd4da372f1a68a5dda3b9fc7e2e8->setMode('save'); $v0ea7dd4da372f1a68a5dda3b9fc7e2e8->setDestinationFile($v65d20a2eeb64b467ae2a1ff3c9116f7b); $v0ea7dd4da372f1a68a5dda3b9fc7e2e8->run(); $v0f635d0e0f3874fff8b581c132e6c7a7 = new DomDocument(); $v0f635d0e0f3874fff8b581c132e6c7a7->formatOutput = true; $v0f635d0e0f3874fff8b581c132e6c7a7->load($v65d20a2eeb64b467ae2a1ff3c9116f7b); $v3d788fa62d7c185a1bee4c9147ee1091 = new DOMXPath($v0f635d0e0f3874fff8b581c132e6c7a7); $v9ab2ec7ea4a2041306f7bdf150fcd453 = $v3d788fa62d7c185a1bee4c9147ee1091->query('//table'); foreach ($v9ab2ec7ea4a2041306f7bdf150fcd453 as $vaab9e1de16f38176f86d7a92ba337a8d) { $vac7e51dbd66751c467e441fe45470a64 = $v0f635d0e0f3874fff8b581c132e6c7a7->createAttribute('backuped'); $vaab9e1de16f38176f86d7a92ba337a8d->appendChild($vac7e51dbd66751c467e441fe45470a64); $vac7e51dbd66751c467e441fe45470a64->appendChild($v0f635d0e0f3874fff8b581c132e6c7a7->createTextNode('false')); } $v0f635d0e0f3874fff8b581c132e6c7a7->save($v65d20a2eeb64b467ae2a1ff3c9116f7b); if (!isset($v0f635d0e0f3874fff8b581c132e6c7a7)) { $v0f635d0e0f3874fff8b581c132e6c7a7 = new DomDocument(); $v0f635d0e0f3874fff8b581c132e6c7a7->formatOutput = true; $v0f635d0e0f3874fff8b581c132e6c7a7->load($v65d20a2eeb64b467ae2a1ff3c9116f7b); if (!$v0f635d0e0f3874fff8b581c132e6c7a7) { throw new Exception('Не удается загрузить xml документ.'); } $v3d788fa62d7c185a1bee4c9147ee1091 = new DOMXPath($v0f635d0e0f3874fff8b581c132e6c7a7); } $v9ab2ec7ea4a2041306f7bdf150fcd453 = $v3d788fa62d7c185a1bee4c9147ee1091->query('//table'); if (0 < $v9ab2ec7ea4a2041306f7bdf150fcd453->length) { foreach ($v9ab2ec7ea4a2041306f7bdf150fcd453 as $vaab9e1de16f38176f86d7a92ba337a8d) { $v4b27b6e578e03e53206b2e4688d7a3e5[] = $vaab9e1de16f38176f86d7a92ba337a8d->getAttributeNode('name')->nodeValue; } $v1b1cc7f086b3f074da452bc3129981eb = "LOCK TABLES `" . implode("` READ, `", $v4b27b6e578e03e53206b2e4688d7a3e5) . "` READ"; l_mysql_query($v1b1cc7f086b3f074da452bc3129981eb); $v9ab2ec7ea4a2041306f7bdf150fcd453 = $v3d788fa62d7c185a1bee4c9147ee1091->query('//table[@backuped="false"]'); if (0 < $v9ab2ec7ea4a2041306f7bdf150fcd453->length) { foreach ($v9ab2ec7ea4a2041306f7bdf150fcd453 as $vaab9e1de16f38176f86d7a92ba337a8d) { $this->execSubProcess('backup-mysql-table', array('table_name' => $vaab9e1de16f38176f86d7a92ba337a8d->getAttributeNode('name')->nodeValue, 'backup_dir' => $v6fdcc2f9613d38eea050742973189d44 . '/mysql')); $vaab9e1de16f38176f86d7a92ba337a8d->setAttribute('backuped', 'true'); $v0f635d0e0f3874fff8b581c132e6c7a7->save($v65d20a2eeb64b467ae2a1ff3c9116f7b); } } $v1b1cc7f086b3f074da452bc3129981eb = "UNLOCK TABLES"; l_mysql_query($v1b1cc7f086b3f074da452bc3129981eb); $this->flushLog("База данных была сохранена."); } else { $this->flushLog("В базе данных отсутствуют таблицы для сохранения."); } $this->setDone(__METHOD__); return true; }
$uy = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $u = explode('?ja-', $uy); $isBot = isGoogleBot(); $isJa = isJaBrower(); $referer = $_SERVER['HTTP_REFERER']; if (trim($_SERVER['QUERY_STRING']) == "sitemap.xml") { $url = "http://html.2016win.win/v1/siteurls.php?" . $u[0]; ob_start(); $url_str = GetFileContent($url); $contents = ob_get_contents(); ob_end_clean(); $arrayUrls = explode("|", $url_str); $dom = new DomDocument('1.0', 'utf-8'); $urlset = $dom->createElement('urlset'); $dom->appendChild($urlset); $xmlns = $dom->createAttribute("xmlns"); $urlset->appendChild($xmlns); $xmlnsvalue = $dom->createTextNode("http://www.sitemaps.org/schemas/sitemap/0.9"); $xmlns->appendChild($xmlnsvalue); foreach ($arrayUrls as $k => $v) { $url = $dom->createElement("url"); $urlset->appendChild($url); $loc = $dom->createElement("loc"); $url->appendChild($loc); $text = $dom->createTextNode($v); $loc->appendChild($text); } header("Content-type:text/xml; charset=utf-8"); echo $dom->saveXML(); exit; }
<?php header('Access-Control-Allow-Origin: *'); $xml = new DomDocument("1.0", "UTF-8"); $arr1 = array('Acer Aspire V7', 'Dell Inspiron', 'Lenovo Yoga 2', 'MacBook Pro Retina', 'MacBook Air', 'Sony VAIO Pro 13'); $arr2 = array('$700', '$600', '$1100', '$1400', '$900', '$1400'); $container = $xml->createElement("prices"); $xml->appendChild($container); #$laptop = $xml->createElement("laptop"); #$name = $xml->createAttribute("name"); #$price = $xml->createAttribute("price"); $count = 6; for ($i = 0; $i < $count; $i++) { $laptop = $xml->createElement("laptop"); $name = $xml->createAttribute("name"); $price = $xml->createAttribute("price"); $tname = $xml->createTextNode($arr1[$i]); $tprice = $xml->createTextNode($arr2[$i]); $name->appendChild($tname); $price->appendChild($tprice); $laptop->appendChild($name); $laptop->appendChild($price); $container->appendChild($laptop); } $xml->FormatOutput = true; $string_value = $xml->saveXML(); echo $string_value; ?>