private function writeReaderImpl(XMLWriter $writer, XMLReader $reader)
 {
     switch ($reader->nodeType) {
         case XMLReader::ELEMENT:
             $writer->startElement($reader->name);
             if ($reader->moveToFirstAttribute()) {
                 do {
                     $writer->writeAttribute($reader->name, $reader->value);
                 } while ($reader->moveToNextAttribute());
                 $reader->moveToElement();
             }
             if ($reader->isEmptyElement) {
                 $writer->endElement();
             }
             break;
         case XMLReader::END_ELEMENT:
             $writer->endElement();
             break;
         case XMLReader::COMMENT:
             $writer->writeComment($reader->value);
             break;
         case XMLReader::SIGNIFICANT_WHITESPACE:
         case XMLReader::TEXT:
             $writer->text($reader->value);
             break;
         case XMLReader::PI:
             $writer->writePi($reader->name, $reader->value);
             break;
         default:
             XMLReaderNode::dump($reader);
     }
 }
示例#2
0
 public function initialize(Config $config, $directory, $filenameWithDate = false)
 {
     $this->setFilename($config, $directory, $filenameWithDate);
     $this->xml = new \XMLWriter();
     $this->xml->openUri($this->filename);
     $this->xml->startDocument('1.0', 'utf-8');
     $this->xml->setIndent(true);
     $this->xml->setIndentString('    ');
     $this->xml->writeComment('list of ' . $config->getClassName());
     $this->elementName = strtolower($config->getClassNameLastPart());
     $this->xml->startElement(strtolower($config->getClassNameLastPart(true)));
 }
示例#3
0
 /**
  * Method for parsing of elements
  *
  * @param string $node - node name
  * @param string $item - node content
  * @param bool $wrap - should be wrapped in array for singularization
  *
  * @return void
  *
  * @since 1.0
  */
 protected function handleElement($node, $item, $wrap = true)
 {
     if ($this->dispatcher->listensTo($node)) {
         $this->dispatcher->trigger($node, array($this->writer, $node, $item));
     } else {
         if ($node === self::COMMENT) {
             if (!is_array($item)) {
                 $item = array($item);
             }
             foreach ($item as $comment) {
                 $this->writer->writeComment($comment);
             }
         } elseif ($node === self::CDATA) {
             $this->writer->writeCdata($item);
         } else {
             if ($wrap === true) {
                 if ($this->assertElementName($node)) {
                     if ($this->config->nil_on_null === true && is_null($item)) {
                         $this->writer->startElement($node);
                         $this->writer->writeAttribute('xsi:nil', 'true');
                         $this->writer->writeRaw($item);
                         $this->writer->endElement();
                     } else {
                         $this->writer->writeElement($node, $item);
                     }
                 }
             } else {
                 $this->writer->writeRaw($item);
             }
         }
     }
 }
示例#4
0
 /**
  * Creates the XML
  *
  * @return string BeerXML
  */
 public function render()
 {
     $this->xmlWriter->openMemory();
     $this->xmlWriter->startDocument('1.0', 'UTF-8');
     $this->xmlWriter->writeComment('Created with php-beerxml: https://github.com/georgeh/php-beerxml');
     list($setTag, $generator) = $this->getTagGeneratorForObject($this->records[0]);
     /** @var $generator Record */
     $generator->setXmlWriter($this->xmlWriter);
     $this->xmlWriter->startElement($setTag);
     foreach ($this->records as $record) {
         $generator->setRecord($record);
         $generator->build();
     }
     $this->xmlWriter->endElement();
     return $this->xmlWriter->outputMemory(true);
 }
 /**
  * Generates the export
  *
  * @param integer $categoryId Category Id
  * @param boolean $downwards  If true, downwards, otherwise upward ordering
  * @param string  $language   Language
  *
  * @return string
  */
 public function generate($categoryId = 0, $downwards = true, $language = '')
 {
     global $PMF_LANG;
     // Initialize categories
     $this->category->transform($categoryId);
     $faqdata = $this->faq->get(FAQ_QUERY_TYPE_EXPORT_XHTML, $categoryId, $downwards, $language);
     $version = $this->_config->get('main.currentVersion');
     $comment = sprintf('XHTML output by phpMyFAQ %s | Date: %s', $version, PMF_Date::createIsoDate(date("YmdHis")));
     $this->xml->startDocument('1.0', 'utf-8');
     $this->xml->writeDtd('html', '-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd');
     $this->xml->startElement('html');
     $this->xml->writeAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
     $this->xml->writeAttribute('xml:lang', $language);
     $this->xml->writeComment($comment);
     $this->xml->startElement('head');
     $this->xml->writeElement('title', $this->_config->get('main.titleFAQ'));
     $this->xml->startElement('meta');
     $this->xml->writeAttribute('http-equiv', 'Content-Type');
     $this->xml->writeAttribute('content', 'application/xhtml+xml; charset=utf-8');
     $this->xml->endElement();
     $this->xml->endElement();
     // </head>
     $this->xml->startElement('body');
     $this->xml->writeAttribute('dir', $PMF_LANG['dir']);
     if (count($faqdata)) {
         $lastCategory = 0;
         foreach ($faqdata as $data) {
             if ($data['category_id'] != $lastCategory) {
                 $this->xml->writeElement('h1', $this->category->getPath($data['category_id'], ' >> '));
             }
             $this->xml->writeElement('h2', strip_tags($data['topic']));
             $this->xml->startElement('p');
             $this->xml->writeCdata(html_entity_decode($data['content'], ENT_QUOTES, 'UTF-8'));
             $this->xml->endElement();
             $this->xml->writeElement('p', $PMF_LANG['msgAuthor'] . ': ' . $data['author_email']);
             $this->xml->writeElement('p', $PMF_LANG['msgLastUpdateArticle'] . PMF_Date::createIsoDate($data['lastmodified']));
             $lastCategory = $data['category_id'];
         }
     }
     $this->xml->endElement();
     // </body>
     $this->xml->endElement();
     // </html>
     header('Content-type: text/html');
     return $this->xml->outputMemory();
 }
function _dovetail_verify_subscription($url, $product_id, $token)
{
    $writer = new XMLWriter();
    $writer->openMemory();
    $writer->setIndent(true);
    $writer->setIndentString('  ');
    $writer->startDocument('1.0', 'UTF-8');
    $writer->startElement('subscription');
    if ($token == '') {
        $writer->writeAttribute('state', 'inactive');
        $writer->writeComment("NO TOKEN PROVIDED");
    } else {
        // Do the request
        $response = _dovetail_verify_entitlement($url, $product_id, $token);
        header('Content-type: text/xml');
        $check = _dovetail_check_entitlement_response($response);
        $failopen = $check['failopen'];
        $failmessage = $check['failmessage'];
        $state = $check['state'];
        if (!$failopen) {
            $writer->writeAttribute('state', $state ? 'active' : 'inactive');
        } else {
            $writer->writeAttribute('state', 'active');
            $writer->writeComment("FAILING OPEN: " . $failmessage);
        }
        $writer->writeComment("Request: " . $response->request);
        $status_message = empty($response->status_message) ? null : $response->status_message;
        if (isset($response->error) && !is_null($response->error) && $response->error != '' && $response->error != $status_message) {
            $writer->writeComment($response->error);
        }
        $writer->writeComment("Status code: " . $response->code);
        $writer->writeComment("Status message: " . $status_message);
    }
    $writer->endElement();
    $writer->endDocument();
    header('Content-type: text/xml');
    header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0');
    echo $writer->outputMemory();
    exit;
    // Don't do the usual Drupal caching headers etc when completing the request
}
 protected function createRequestXml()
 {
     $XMLWriter = new \XMLWriter();
     $XMLWriter->openMemory();
     $XMLWriter->setIndent(true);
     $XMLWriter->startDocument("1.0", "UTF-8");
     $XMLWriter->writeComment(\Svea\Helper::getLibraryAndPlatformPropertiesAsJson($this->config));
     $XMLWriter->startElement($this->method);
     $XMLWriter->writeElement("merchantid", $this->config->getMerchantId(\ConfigurationProvider::HOSTED_TYPE, $this->countryCode));
     $XMLWriter->endElement();
     $XMLWriter->endDocument();
     return $XMLWriter->flush();
 }
 /** returns xml for hosted webservice "annul" request */
 protected function createRequestXml()
 {
     $XMLWriter = new \XMLWriter();
     $XMLWriter->openMemory();
     $XMLWriter->setIndent(true);
     $XMLWriter->startDocument("1.0", "UTF-8");
     $XMLWriter->writeComment(\Svea\Helper::getLibraryAndPlatformPropertiesAsJson($this->config));
     $XMLWriter->startElement($this->method);
     $XMLWriter->writeElement("transactionid", $this->transactionId);
     $XMLWriter->endElement();
     $XMLWriter->endDocument();
     return $XMLWriter->flush();
 }
 /**
  * Writes out a single property into the XML structure.
  *
  * @param array $data The data as an array, the given property name is looked up there
  * @param string $propertyName The name of the property
  * @param string $elementName an optional name to use, defaults to $propertyName
  * @return void
  */
 protected function writeConvertedElement(array &$data, $propertyName, $elementName = null, $declaredPropertyType = null)
 {
     if (array_key_exists($propertyName, $data) && $data[$propertyName] !== null) {
         $propertyValue = $data[$propertyName];
         $this->xmlWriter->startElement($elementName ?: $propertyName);
         if (!empty($propertyValue)) {
             switch ($declaredPropertyType) {
                 case null:
                 case 'reference':
                 case 'references':
                     break;
                 default:
                     $propertyValue = $this->propertyMapper->convert($propertyValue, $declaredPropertyType);
                     break;
             }
         }
         $this->xmlWriter->writeAttribute('__type', gettype($propertyValue));
         try {
             if (is_object($propertyValue) && !$propertyValue instanceof \DateTime) {
                 $objectIdentifier = $this->persistenceManager->getIdentifierByObject($propertyValue);
                 if ($objectIdentifier !== null) {
                     $this->xmlWriter->writeAttribute('__identifier', $objectIdentifier);
                 }
                 if ($propertyValue instanceof \Doctrine\ORM\Proxy\Proxy) {
                     $className = get_parent_class($propertyValue);
                 } else {
                     $className = get_class($propertyValue);
                 }
                 $this->xmlWriter->writeAttribute('__classname', $className);
                 $this->xmlWriter->writeAttribute('__encoding', 'json');
                 $converted = json_encode($this->propertyMapper->convert($propertyValue, 'array', $this->propertyMappingConfiguration));
                 $this->xmlWriter->text($converted);
             } elseif (is_array($propertyValue)) {
                 foreach ($propertyValue as $key => $element) {
                     $this->writeConvertedElement($propertyValue, $key, 'entry' . $key);
                 }
             } else {
                 if ($propertyValue instanceof \DateTime) {
                     $this->xmlWriter->writeAttribute('__classname', 'DateTime');
                 }
                 $this->xmlWriter->text($this->propertyMapper->convert($propertyValue, 'string', $this->propertyMappingConfiguration));
             }
         } catch (\Exception $exception) {
             $this->xmlWriter->writeComment(sprintf('Could not convert property "%s" to string.', $propertyName));
             $this->xmlWriter->writeComment($exception->getMessage());
             $this->systemLogger->logException($exception);
             $this->exceptionsDuringExport[] = $exception;
         }
         $this->xmlWriter->endElement();
     }
 }
 /**
  * Generates the export
  *
  * @param integer $categoryId Category Id
  * @param boolean $downwards  If true, downwards, otherwise upward ordering
  * @param string  $language   Language
  *
  * @return string
  */
 public function generate($categoryId = 0, $downwards = true, $language = '')
 {
     // Initialize categories
     $this->category->transform($categoryId);
     $faqdata = $this->faq->get(FAQ_QUERY_TYPE_EXPORT_XML, $categoryId, $downwards, $language);
     $version = $this->_config->get('main.currentVersion');
     $comment = sprintf('XML output by phpMyFAQ %s | Date: %s', $version, PMF_Date::createIsoDate(date("YmdHis")));
     $this->xml->startDocument('1.0', 'utf-8', 'yes');
     $this->xml->writeComment($comment);
     $this->xml->startElement('phpmyfaq');
     if (count($faqdata)) {
         foreach ($faqdata as $data) {
             // Build the <article/> node
             $this->xml->startElement('article');
             $this->xml->writeAttribute('id', $data['id']);
             $this->xml->writeElement('language', $data['lang']);
             $this->xml->writeElement('category', $this->category->getPath($data['category_id'], ' >> '));
             if (!empty($data['keywords'])) {
                 $this->xml->writeElement('keywords', $data['keywords']);
             } else {
                 $this->xml->writeElement('keywords');
             }
             $this->xml->writeElement('question', strip_tags($data['topic']));
             $this->xml->writeElement('answer', PMF_String::htmlspecialchars($data['content']));
             if (!empty($data['author_name'])) {
                 $this->xml->writeElement('author', $data['author_name']);
             } else {
                 $this->xml->writeElement('author');
             }
             $this->xml->writeElement('data', PMF_Date::createIsoDate($data['lastmodified']));
             $this->xml->endElement();
         }
     }
     $this->xml->endElement();
     header('Content-type: text/xml');
     return $this->xml->outputMemory();
 }
示例#11
0
 protected function createRequestXml()
 {
     $XMLWriter = new \XMLWriter();
     $XMLWriter->openMemory();
     $XMLWriter->setIndent(true);
     $XMLWriter->startDocument("1.0", "UTF-8");
     $XMLWriter->writeComment(\Svea\Helper::getLibraryAndPlatformPropertiesAsJson($this->config));
     $XMLWriter->startElement($this->method);
     $XMLWriter->writeElement("amount", $this->amount);
     $XMLWriter->writeElement("customerrefno", $this->customerRefNo);
     $XMLWriter->writeElement("subscriptionid", $this->subscriptionId);
     if (isset($this->currency)) {
         $XMLWriter->writeElement("currency", $this->currency);
     }
     $XMLWriter->endElement();
     $XMLWriter->endDocument();
     return $XMLWriter->flush();
 }
 protected static function _array2xml($hash, $elementName, XMLWriter $writer, $level = 0)
 {
     if (is_array($hash) && array_key_exists(self::COMMENT_PFX, $hash)) {
         $writer->writeComment($hash[self::COMMENT_PFX]);
     }
     if ($level > self::MAX_RECURSION_LEVEL) {
         throw new Exception('Recursion threshold exceed on element: ' . $elementName . ' for hashvalue: ' . var_export($hash, true));
     }
     if ($hash == self::PLACEHOLDER_VALUE) {
         // Ignore placeholders
         return;
     }
     if (!isset($hash[0])) {
         $writer->startElement($elementName);
     }
     foreach ((array) $hash as $key => $value) {
         if (is_int($key)) {
             // Normal numeric index, value is probably a hash structure, recurse...
             self::_array2xml($value, $elementName, $writer, $level + 1);
         } elseif ($key === self::VALUE_PFX) {
             $writer->text($value);
         } elseif (strpos($key, self::PRIVATE_PFX) === 0) {
             # [__][<x>] is used for private attributes for internal consumption
         } elseif (strpos($key, self::ATTRIBUTE_PFX) === 0) {
             $writer->writeAttribute(substr($key, 1), $value);
         } elseif (is_array($value) || $value === self::PLACEHOLDER_VALUE) {
             self::_array2xml($value, $key, $writer, $level + 1);
         } else {
             throw new Corto_XmlToArray_Exception("Value for key '{$key}' unrecognized (key naming error?)! Value" . print_r($value, true));
         }
     }
     if (!isset($hash[0])) {
         $writer->endElement();
     }
 }
示例#13
0
<?php

/* $Id$ */
/*
Libxml 2.6.24 and up adds a new line after a processing instruction (PI)
*/
$xw = new XMLWriter();
$xw->openMemory();
$xw->setIndent(TRUE);
$xw->startDocument("1.0", "UTF-8");
$xw->startElement('root');
$xw->writeAttribute('id', 'elem1');
$xw->startElement('elem1');
$xw->writeAttribute('attr1', 'first');
$xw->writeComment('start PI');
$xw->startElement('pi');
$xw->writePi('php', 'echo "hello world"; ');
$xw->endElement();
$xw->startElement('cdata');
$xw->startCdata();
$xw->text('<>&"');
$xw->endCdata();
$xw->endElement();
$xw->endElement();
$xw->endElement();
$xw->endDocument();
// Force to write and empty the buffer
$output = $xw->flush(true);
print $output;
 /**
  * builds the XML out of the provided data
  *
  * @return 	string		the built xml
  */
 public function renderXML()
 {
     $w = new XMLWriter();
     $w->openMemory();
     // only indent when NICE_XML is true
     $w->setIndent(self::NICE_XML);
     // use tabs as indents
     $w->setIndentString("\t");
     $w->startDocument("1.0", CHARSET);
     $w->startElement('section');
     $w->writeAttribute('name', 'packages');
     if (self::SIGNATURE) {
         $w->writeComment('Generated by PackageBuilder @ ' . gmdate('r'));
     }
     try {
         if (PAGE_URL == '') {
             throw new SystemException('PAGE_URL is empty');
         }
         foreach ($this->packages as $package) {
             // if package has no valid versions just continue
             if (self::countValidVersions($package, $this->type) == 0) {
                 continue;
             }
             $generalData = self::getPackageData($package);
             $w->startElement('package');
             $w->writeAttribute('name', $generalData['packageIdentifier']);
             $w->startElement('packageinformation');
             if ($generalData['packageName'] !== null) {
                 $w->startElement('packagename');
                 $w->writeCData($generalData['packageName']);
                 $w->endElement();
             }
             if ($generalData['packageDescription'] !== null) {
                 $w->startElement('packagedescription');
                 $w->writeCData($generalData['packageDescription']);
                 $w->endElement();
             }
             if ($generalData['plugin'] !== null) {
                 $w->startElement('plugin');
                 $w->writeCData($generalData['plugin']);
                 $w->endElement();
             }
             if ($generalData['standalone'] !== null) {
                 $w->startElement('standalone');
                 $w->writeCData($generalData['standalone']);
                 $w->endElement();
             }
             // packageinformation
             $w->endElement();
             $w->startElement('authorinformation');
             if ($generalData['author'] !== null) {
                 $w->startElement('author');
                 $w->writeCData($generalData['author']);
                 $w->endElement();
             }
             if ($generalData['authorURL'] !== null) {
                 $w->startElement('authorurl');
                 $w->writeCData($generalData['authorURL']);
                 $w->endElement();
             }
             // authorinformation
             $w->endElement();
             $w->startElement('versions');
             // list each version
             foreach ($package as $key => $val) {
                 // get type, dont display if this type is not wanted
                 if (self::getTypeByVersion($key) != $this->type && $this->type != 'all') {
                     continue;
                 }
                 $data = self::getPackageData($package, $key);
                 $w->startElement('version');
                 $w->writeAttribute('name', $key);
                 if (!empty($data['fromVersions'])) {
                     $w->startElement('fromversions');
                     foreach ($data['fromVersions'] as $fromVersion) {
                         $w->startElement('fromversion');
                         $w->writeCData($fromVersion);
                         $w->endElement();
                     }
                     // fromversions
                     $w->endElement();
                 }
                 if (!empty($data['requirements'])) {
                     $w->startElement('requiredpackages');
                     foreach ($data['requirements'] as $required) {
                         $w->startElement('requiredpackage');
                         if (isset($required['minversion'])) {
                             $w->writeAttribute('minversion', $required['minversion']);
                         }
                         $w->writeCData($required['name']);
                         $w->endElement();
                     }
                     // requiredpackages
                     $w->endElement();
                 }
                 // determine updatetype
                 if ($data['isUpdate'] && stripos($key, 'pl')) {
                     $updateType = 'security';
                 } else {
                     if ($data['isUpdate']) {
                         $updateType = 'update';
                     } else {
                         $updateType = 'install';
                     }
                 }
                 $w->startElement('updatetype');
                 $w->writeCData($updateType);
                 $w->endElement();
                 // use the build time of that package as timestamp
                 $w->startElement('timestamp');
                 $w->writeCData(filemtime($this->source->buildDirectory . $val['file']));
                 $w->endElement();
                 $w->startElement('versiontype');
                 $w->writeCData(self::getTypeByVersion($key));
                 $w->endElement();
                 $w->startElement('file');
                 $w->writeCData(PAGE_URL . '/index.php?page=DownloadPackage&sourceID=' . $this->source->sourceID . '&filename=' . $val['file']);
                 $w->endElement();
                 // version
                 $w->endElement();
             }
             // versions
             $w->endElement();
             // package
             $w->endElement();
         }
     } catch (SystemException $e) {
         $w->writeComment('Fatal Error: ' . $e->getMessage());
     }
     // section
     $w->endElement();
     $w->endDocument();
     return $w->outputMemory();
 }
示例#15
0
 public function exportXmlLog()
 {
     $xml = new XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->startDocument();
     $xml->startElement('invoice-log');
     $xml->writeElement('version', '1.0');
     // log format version
     $xml->startElement('config');
     $xml->startElement('item');
     $xml->writeAttribute('name', 'plugin.' . $this->paysys_id . '.sample');
     $xml->text('VALUE');
     $xml->endElement();
     $xml->endElement();
     $xml->writeComment(sprintf("Dumping invoice#%d, user#%d", $this->invoice_id, $this->user_id));
     $xml->startElement('event');
     $xml->writeAttribute('time', $this->tm_added);
     $this->exportXml($xml, array('element' => 'invoice', 'nested' => array(array('invoiceItem'), array('access', array('element' => 'access')), array('invoicePayment', array('element' => 'invoice-payment')))));
     $xml->endElement();
     foreach ($this->getDi()->invoiceLogTable->findByInvoiceId($this->pk()) as $log) {
         $xml->startElement('event');
         $xml->writeAttribute('time', $log->tm);
         foreach ($log->getXmlDetails() as $a) {
             list($type, $source) = $a;
             $xml->writeRaw($source);
         }
         $xml->endElement();
     }
     $xml->endElement();
     echo $xml->flush();
 }
示例#16
0
function queryAndStreamXML($conditions, $randomize = false, $limit = null)
{
    $beginTime = microtime(true);
    $mysql = connectToMySQL();
    $conditions[] = '`isactive` = 1';
    $query = 'SELECT `edittype`,
				`editid`,
				`comment`,
				`user`,
				`user_edit_count`,
				`user_distinct_pages`,
				`user_warns`,
				`prev_user`,
				UNIX_TIMESTAMP( `user_reg_time` ) AS `user_reg_time_unix`,
				UNIX_TIMESTAMP( `common_page_made_time` ) AS `common_page_made_time_unix`,
				`common_title`,
				`common_namespace`,
				`common_creator`,
				`common_num_recent_edits`,
				`common_num_recent_reversions`,
				`current_minor`,
				UNIX_TIMESTAMP( `current_timestamp` ) AS `current_timestamp_unix`,
				`current_text`,
				UNIX_TIMESTAMP( `previous_timestamp` ) AS `previous_timestamp_unix`,
				`previous_text`,
				`isvandalism`,
				`isactive`,
				`source`,
				UNIX_TIMESTAMP( `updated` ) AS `updated_unix`,
				`reviewers`,
				`reviewers_agreeing` FROM `editset` WHERE ';
    $query .= implode(' AND ', $conditions);
    if ($randomize) {
        $query .= ' ORDER BY RAND()';
    } else {
        if ($randomize === false and ($limit !== null and strpos(',', $limit) === false or $limit === null)) {
            $row = mysql_fetch_assoc(mysql_query('SELECT COUNT(*) as `count` FROM `editset` WHERE ' . implode(' AND ', $conditions)));
            $start = rand(0, $row['count'] - ($limit === null ? 0 : $limit));
            if ($limit !== null and strpos(',', $limit) === false) {
                $limit = $start . ',' . $limit;
            } else {
                $limit = $start . ',18446744073709551615';
            }
        }
    }
    if ($limit !== null) {
        $query .= ' LIMIT ' . $limit;
    }
    $xml = new XMLWriter();
    $xml->openURI('php://output');
    $xml->setIndent(true);
    $xml->startDocument('1.0', 'UTF-8');
    $xml->startElement('WPEditSet');
    $xml->startComment();
    $xml->startElement('EditDB');
    $xml->writeElement('query', $query);
    $xml->writeElement('time', time());
    if (function_exists('posix_uname')) {
        $uname = posix_uname();
        $xml->startElement('uname');
        foreach ($uname as $key => $value) {
            $xml->writeElement($key, $value);
        }
        $xml->endElement();
    }
    if (function_exists('posix_getlogin')) {
        $xml->writeElement('username', posix_getlogin());
    }
    $xml->endElement();
    $xml->endComment();
    $result = mysql_unbuffered_query($query);
    if (!$result) {
        error('MySQL Query Error: ' . mysql_error() . "\n" . 'Query: ' . $query);
    }
    $count = 0;
    while ($row = mysql_fetch_assoc($result)) {
        $xml->startElement('WPEdit');
        $xml->startElement('EditDB');
        $xml->writeElement('isActive', $row['isactive'] ? 'true' : 'false');
        $xml->writeElement('source', $row['source']);
        $xml->writeElement('lastUpdated', $row['updated_unix']);
        $xml->endElement();
        $xml->writeElement('EditType', $row['edittype']);
        $xml->writeElement('EditID', $row['editid']);
        $xml->writeElement('comment', $row['comment']);
        $xml->writeElement('user', $row['user']);
        $xml->writeElement('user_edit_count', $row['user_edit_count']);
        $xml->writeElement('user_distinct_pages', $row['user_distinct_pages']);
        $xml->writeElement('user_warns', $row['user_warns']);
        $xml->writeElement('prev_user', $row['prev_user']);
        $xml->writeElement('user_reg_time', $row['user_reg_time_unix']);
        $xml->startElement('common');
        $xml->writeElement('page_made_time', $row['common_page_made_time_unix']);
        $xml->writeElement('title', $row['common_title']);
        $xml->writeElement('namespace', $row['common_namespace']);
        $xml->writeElement('creator', $row['common_creator']);
        $xml->writeElement('num_recent_edits', $row['common_num_recent_edits']);
        $xml->writeElement('num_recent_reversions', $row['common_num_recent_reversions']);
        $xml->endElement();
        $xml->startElement('current');
        $xml->writeElement('minor', $row['current_minor'] ? 'true' : 'false');
        $xml->writeElement('timestamp', $row['current_timestamp_unix']);
        $xml->writeElement('text', $row['current_text']);
        $xml->endElement();
        $xml->startElement('previous');
        $xml->writeElement('timestamp', $row['previous_timestamp_unix']);
        $xml->writeElement('text', $row['previous_text']);
        $xml->endElement();
        $xml->writeElement('isVandalism', $row['isvandalism'] ? 'true' : 'false');
        $xml->startElement('ReviewInterface');
        $xml->writeElement('reviewers', $row['reviewers']);
        $xml->writeElement('reviewers_agreeing', $row['reviewers_agreeing']);
        $xml->endElement();
        $xml->endElement();
        $count++;
    }
    $xml->writeComment('Generated in ' . (microtime(true) - $beginTime) . ' seconds.  ' . $count . ' entries returned.');
    $xml->endElement();
    $xml->endDocument();
    $xml->flush();
}
<?php

/* $Id$ */
$doc_dest = '001.xml';
$xw = new XMLWriter();
$xw->openUri($doc_dest);
$xw->startDocument('1.0', 'UTF-8');
$xw->startElement("tag1");
$xw->startComment();
$xw->text('comment');
$xw->endComment();
$xw->writeComment("comment #2");
$xw->endDocument();
// Force to write and empty the buffer
$output_bytes = $xw->flush(true);
echo file_get_contents($doc_dest);
unset($xw);
unlink('001.xml');
?>
===DONE===
示例#18
0
文件: FormatKml.php 项目: Abbe98/ODOK
 function outputWarning(XMLWriter $xml, $head)
 {
     $text = $head['hits'];
     if (!empty($head['warning'])) {
         $text .= "\nWarning: " . $head['warning'];
     }
     if (!empty($text)) {
         $xml->writeComment($text);
     }
 }
示例#19
0
function export($base, $generationSimple, $infos, $user, $mdp, $dbh)
{
    //we get the tables
    $resultFindTables = getTables($dbh, $base);
    //echo "<pre>";var_dump($resultFindTables);exit;
    $arrayConstructHierarchy = array();
    //we start the xml menu
    $xmlMenu = new XMLWriter();
    $xmlMenu->openUri($base . "/config/menu.xml");
    $xmlMenu->setIndent(true);
    $xmlMenu->setIndentString("     ");
    $xmlMenu->startDocument("1.0", "UTF-8");
    $xmlMenu->startElement("menu");
    foreach ($resultFindTables as $table) {
        //we empty the xml menu
        $xmlMenu->startElement("aMenu");
        $xmlMenu->writeAttribute("tableName", $table["Tables_in_" . $base . ""]);
        $xmlMenu->writeAttribute("displayName", $table["Tables_in_" . $base . ""]);
        $xmlMenu->endElement();
        //we initialize a var that contains the infos on the table
        $contenu;
        //we empty the variable
        $contenu = getContenu("simple", $table["Tables_in_" . $base . ""]);
        //we search the different relations on the table
        $sqlFindRelations = "SELECT \r\n\t        ke.column_name col, \r\n\t        ke.referenced_table_schema assoc_db,\r\n\t        ke.referenced_table_name assoc_table,\r\n\t        ke.referenced_column_name assoc_col\r\n\t\t    FROM\r\n\t        information_schema.KEY_COLUMN_USAGE ke\r\n\t\t    WHERE\r\n\t        ke.referenced_table_name IS NOT NULL              \r\n\t\t    AND   ke.table_schema='" . $base . "'\r\n\t\t    AND   ke.table_name='" . $table["Tables_in_" . $base . ""] . "'";
        //we searh the different fields on this table
        $sqlReqFindFields = "DESCRIBE " . $table["Tables_in_" . $base . ""] . "";
        $prepaFindFields = $dbh->query($sqlReqFindFields);
        $prepaFindFields->setFetchMode(PDO::FETCH_ASSOC);
        $resultFindFields = $prepaFindFields->fetchAll();
        //we start a variable that will contain the generated code for the declaration of the differents fields in the future class
        $arrayRoutineFields = "";
        //we start the xml configuration of the table we are into in the loop
        $xml = new XMLWriter();
        $xml->openUri($base . "/config/" . $table["Tables_in_" . $base . ""] . ".xml");
        $xml->setIndent(true);
        $xml->setIndentString("     ");
        $xml->startDocument("1.0", "UTF-8");
        $xml->startElement("formDescription");
        $xml->writeAttribute('reqLimit', 10);
        $xml->writeAttribute('formOrder', "");
        //and for each field ...
        foreach ($resultFindFields as $key => $field) {
            //we start a xml field
            $xml->startElement($field['Field']);
            $xml->writeAttribute('isGridVisible', 'true');
            //...
            $xml->writeAttribute('dataType', $field['Type']);
            //...
            //if its not a primary key , we put it in the form, we do a special treatment for the primary keys
            if ($field['Key'] != "PRI") {
                $xml->writeAttribute('isVisibleInForm', 'true');
                //...
                $xml->writeAttribute('isFilterVisible', 'true');
                //...
            } else {
                if ($key == 0) {
                    //if it(s the first, it(s the one that we define has the primary key...))
                    $xml->writeAttribute('isVisibleInForm', 'false');
                    //...
                    $xml->writeAttribute('isPrimaryKey', 'true');
                    //...
                    $xml->writeAttribute('isFilterVisible', 'false');
                    //...
                    /*$xml -> startElement('pushHierarchy');//...
                    			$xml->writeAttribute('className',' a class name');
                    			$xml->writeAttribute('promptLabel',' prompt label');
                    			$xml->writeAttribute('enabled','false');
                    			$xml->writeAttribute('listIcone',' url of an icon');
                    			$xml->writeAttribute('displayColumn','');
                    			$xml->writeAttribute('displayDenomination','');
                    		$xml->endElement();
                    		
                    		$xml -> startElement('getHierarchy');//...
                    			$xml->writeAttribute('className',' a class name');
                    			$xml->writeAttribute('promptLabel',' prompt label');
                    			$xml->writeAttribute('enabled','false');
                    		$xml->endElement();*/
                } else {
                    //else maybe it's a foreign key so we put a display column label ...
                    $xml->writeAttribute('isVisibleInForm', 'true');
                    //...
                    $xml->writeAttribute('isFilterVisible', 'true');
                    //...
                    $xml->writeComment("in case of forein key , we can specify the column we choose to display datas ..??");
                    //comment
                    $xml->startElement('displayColumn');
                    $xml->writeAttribute('sortColumn', '');
                    $xml->text('');
                    $xml->endElement();
                }
            }
            //label diplayed in the forms
            $xml->writeComment('label displayed in the form');
            $xml->writeElement("label", $field['Field']);
            //maybe it's a foreign key so we put a display column label ...
            if ($field['Key'] == "MUL") {
                $xml->writeComment("in case of forein key , we can specify the column we choose to display datas ..??");
                $xml->startElement('displayColumn');
                $xml->writeAttribute('sortColumn', '');
                $xml->text('');
                $xml->endElement();
            }
            //type of checking
            $xml->writeComment('type of checking for the field : simple,mail,optional,int');
            $xml->writeElement("cheking", "");
            //*******************************************picture upload**************************************************************//
            //infos
            $xml->writeComment('if you want to upload picture , you have to fill the infos in this node , if the enabled attribute is set to true, the configuration will work');
            $xml->startElement("pictureField");
            $xml->writeAttribute("enabled", "false");
            $xml->writeAttribute("enabledForRelation", "false");
            $xml->writeComment('each child node represents a saving of the picture, resizeType can be set to resizeFix, resizeHomo, resizeHomoW, resizeHomoH, noResize; the path attribute is the path of the uploaded pictures, it must be relative to the index.php file of the admin directory wich is created and need end slash');
            $xml->startElement("picture");
            $xml->writeAttribute("resizeType", "type of resizing");
            $xml->writeAttribute("width", "width in pixels");
            $xml->writeAttribute("height", "height in pixels");
            $xml->writeAttribute("ratio", "height in pixels");
            $xml->writeAttribute("path", "path for the picture");
            $xml->writeAttribute("isForAdmin", "false");
            //accepted formats
            $xml->startElement("acceptedFormats");
            $xml->writeComment('each child node represents a format of picture');
            $xml->writeElement("format", ".jpg");
            $xml->endElement();
            $xml->endElement();
            $xml->endElement();
            //*********************************************************************************************************//
            //*******************************************file upload**************************************************************//
            //infos
            $xml->writeComment('if you want to upload files , you have to fill the infos in this node , if the enabled attribute is set to true, the configuration will work');
            $xml->startElement("fileField");
            $xml->writeAttribute("enabled", "false");
            $xml->writeComment('configuration for the upload');
            $xml->startElement("aFile");
            //$xml -> writeComment('the path attribute is the path of the uploaded file, it must be relative to the index.php file of the admin directory wich is created and need end slash');
            //$xml -> writeAttribute("path", "path for the file");
            $xml->writeAttribute("path", "path for the file");
            $xml->writeComment('each child node represents an accepted format');
            //accepted formats
            $xml->startElement("acceptedFormats");
            $xml->writeElement('format', '.extension');
            $xml->endElement();
            $xml->endElement();
            $xml->endElement();
            //*********************************************************************************************************//
            //date fields
            $xml->writeComment('the informations can be a date... in this case we save a timestamp in the bdd');
            $xml->startElement("dateField");
            $xml->writeAttribute("enabled", "false");
            $xml->endElement();
            //boolean fields
            $xml->writeComment('the informations can be a boolean... in this case we save a tinyint in the bdd');
            $xml->startElement("booleanField");
            $xml->writeAttribute("enabled", "false");
            $xml->writeElement("boolean_true_label", "oui");
            $xml->writeElement("boolean_false_label", "non");
            $xml->endElement();
            //riche editor field
            $xml->writeComment('the informations can be text, so we can implement a rich text editor, format can be dd/mm/yyyy or mm/dd/yyyy ');
            $xml->startElement("richTextEditorField");
            $xml->writeAttribute("enabled", "false");
            $xml->endElement();
            //riche editor field
            $xml->writeComment('if you want to make a colorpicker field');
            $xml->startElement("colorPickerField");
            $xml->writeAttribute("enabled", "false");
            $xml->endElement();
            //we empty this variable that contains the generated code for the declaration of the differents fields in the future class
            $arrayRoutineFields .= '
				$this->arrayFields["' . $field['Field'] . '"]=array
				(
					"type"=>"' . $field['Type'] . '",
					"canBeNull"=>"' . $field['Null'] . '",
					"key"=>"' . $field['Key'] . '",
					"default"=>"' . $field['Default'] . '",
					"extra"=>"' . $field['Extra'] . '",
					"formLabel"=>"' . $field['Field'] . '"
				);
			';
            $xml->endElement();
        }
        $xml->writeComment('this node contains all the callbacks for the differents action on this model ');
        $xml->startElement("callbacks");
        $xml->writeComment('action that is executed when an element is saved');
        $xml->startElement('onSave');
        $xml->writeAttribute('fileName', '');
        $xml->writeAttribute('className', '');
        $xml->writeAttribute('methodName', '');
        $xml->endElement();
        $xml->startElement('onDelete');
        $xml->writeAttribute('fileName', '');
        $xml->writeAttribute('className', '');
        $xml->writeAttribute('methodName', '');
        $xml->endElement();
        $xml->startElement('onUpdate');
        $xml->writeAttribute('fileName', '');
        $xml->writeAttribute('className', '');
        $xml->writeAttribute('methodName', '');
        $xml->endElement();
        $xml->endElement();
        $xml->endElement();
        $xml->endDocument();
        $xml->flush();
        // done for the xml of the model and the cruds
        //this query is used to find all the relation for the table in the loop
        $prepaFindRelations = $dbh->query($sqlFindRelations);
        $prepaFindRelations->setFetchMode(PDO::FETCH_ASSOC);
        $resultFindRelations = $prepaFindRelations->fetchAll();
        $arrayConstructHierarchy[$table["Tables_in_" . $base . ""]] = $resultFindRelations;
        $arrayRelations = "";
        //$xmlHierarchy->startElement($table["Tables_in_" . $base . ""]);
        foreach ($resultFindRelations as $relation) {
            $arrayRelations .= '
				$this->arrayRelations["' . $relation["col"] . '"]=array
				(
					"assoc_table"=>"' . $relation["assoc_table"] . '",
					"assoc_col"=>"' . $relation["assoc_col"] . '"
				);
			';
        }
        //$xmlHierarchy->endElement();
        //we empty some variables
        $newContent = str_replace("{arrayFieldRoutine}", $arrayRoutineFields, $contenu);
        $newContent = str_replace("{arrayRelations}", $arrayRelations, $newContent);
        //we empty some files ...
        file_put_contents($base . "/model/" . $table["Tables_in_" . $base . ""] . ".php", $newContent);
        //models
        file_put_contents($base . "/libs/php/inclusion_" . $table["Tables_in_" . $base . ""] . ".php", '<?php $datasManager=new ' . $table["Tables_in_" . $base . ""] . 'DatasManager(); $oneElement=new ' . $table["Tables_in_" . $base . ""] . '(); ?>');
        // inclusion files
        file_put_contents($base . "/libs/php/inclusion_bididi.php", '<?php
				$infos="' . $infos . '";
				$user="******";
				$mdp="' . $mdp . '";
				$dbh=new PDO($infos,$user,$mdp,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
		     ?>');
        //database definition
    }
    $xmlMenu->endElement();
    $xmlMenu->endDocument();
    $xmlMenu->flush();
    //	done for the xml of the backend menu
    //we create a xml for the global labels, formats etc
    $xmlGlobalConfig = new XMLWriter();
    $xmlGlobalConfig->openUri($base . "/config/global_config.xml");
    $xmlGlobalConfig->setIndent(true);
    $xmlGlobalConfig->setIndentString("     ");
    $xmlGlobalConfig->startDocument("1.0", "UTF-8");
    $xmlGlobalConfig->startElement("global_config");
    $xmlGlobalConfig->startElement("generic");
    $xmlGlobalConfig->writeElement("global_date_format", "dd-mm-yy");
    $xmlGlobalConfig->writeElement("global_add_label", "Ajouter un élément");
    $xmlGlobalConfig->writeElement("global_filter_label", "Filtres");
    $xmlGlobalConfig->writeElement("global_search_label", "Rechercher");
    $xmlGlobalConfig->writeElement("global_delete_confirm_label", "Etes vous sur de vouloir effacer cet élément ?");
    $xmlGlobalConfig->writeElement("global_delete_label", "effacer");
    $xmlGlobalConfig->writeElement("global_edit_label", "éditer");
    $xmlGlobalConfig->writeElement("global_edit_title_label", "Modifier l'élement");
    $xmlGlobalConfig->writeElement("global_add_title_label", "Informations sur l'élement");
    $xmlGlobalConfig->writeElement("global_save_label", "Sauvegarder l'élément");
    $xmlGlobalConfig->writeElement("global_cancel_label", "Annuler");
    $xmlGlobalConfig->writeElement("global_error_image_label", "L'image n'a pu être récupéré");
    $xmlGlobalConfig->writeElement("global_error_file_label", "Le fichier n'a pu être récupéré");
    $xmlGlobalConfig->writeElement("global_error_fields_label", "Vérifiez d'avoir bien rempli les champs surlignés en rouge");
    $xmlGlobalConfig->writeElement("global_login", "login");
    $xmlGlobalConfig->writeElement("global_password", "password");
    $xmlGlobalConfig->writeElement("global_login_label", "Identifiant");
    $xmlGlobalConfig->writeElement("global_password_label", "Mot de passe");
    $xmlGlobalConfig->writeElement("global_wrong_login", "login incorrect");
    $xmlGlobalConfig->writeElement("global_disconnect", "Se déconnecter");
    $xmlGlobalConfig->writeElement("global_connect", "Se connecter");
    $xmlGlobalConfig->endElement();
    $xmlGlobalConfig->endElement();
    $xmlGlobalConfig->endDocument();
    $xmlGlobalConfig->flush();
    //	done
    //we start the hierarchy xml
    $xmlHierarchy = new XMLWriter();
    $xmlHierarchy->openUri($base . "/config/hierarchy.xml");
    $xmlHierarchy->setIndent(true);
    $xmlHierarchy->setIndentString("     ");
    $xmlHierarchy->startDocument("1.0", "UTF-8");
    $xmlHierarchy->startElement("hierarchy");
    $arrayReverseHierarchy = array();
    foreach ($arrayConstructHierarchy as $key => $value) {
        $xmlHierarchy->startElement($key);
        $xmlHierarchy->writeAttribute('refName', $key);
        $xmlHierarchy->writeAttribute('displayColumn', "");
        $xmlHierarchy->startElement("parentTables");
        foreach ($value as $value2) {
            $xmlHierarchy->startElement("parentTable");
            if (!isset($arrayReverseHierarchy[$value2['assoc_table']])) {
                $arrayReverseHierarchy[$value2['assoc_table']] = array();
            }
            $arrayReverseHierarchy[$value2['assoc_table']][] = array("className" => $key, "usedCol" => $value2['assoc_col'], "fk" => $value2['col']);
            $xmlHierarchy->writeAttribute("className", $value2['assoc_table']);
            $xmlHierarchy->writeAttribute("fk", $value2['col']);
            $xmlHierarchy->writeAttribute("usedCol", $value2['assoc_col']);
            $xmlHierarchy->writeAttribute("enabled", "false");
            $xmlHierarchy->writeAttribute("prompt", "");
            $xmlHierarchy->writeAttribute("icon", "");
            //$xmlHierarchy->writeAttribute("refName",$value2['assoc_table']);
            /*foreach($value2 as $key3=>$value3)
            		{
            			$xmlHierarchy->writeAttribute($key3,$value3);
            			
            		}*/
            $xmlHierarchy->endElement();
        }
        $xmlHierarchy->endElement();
        $xmlHierarchy->endElement();
    }
    $xmlHierarchy->endElement();
    $xmlHierarchy->endDocument();
    $xmlHierarchy->flush();
    $xmlAgain = simplexml_load_file($base . "/config/hierarchy.xml");
    //echo "<pre>";var_dump($arrayReverseHierarchy);
    foreach ($arrayReverseHierarchy as $key => $value) {
        $xmlAgain->{"" . $key . ""}->addChild("childTables", "");
        foreach ($value as $key2 => $value2) {
            $xmlAgain->{"" . $key . ""}->childTables->addChild("childTable");
            foreach ($value2 as $key3 => $value3) {
                $xmlAgain->{"" . $key . ""}->childTables->childTable[$key2]->addAttribute($key3, $value3);
            }
            $xmlAgain->{"" . $key . ""}->childTables->childTable[$key2]->addAttribute("enabled", "false");
            $xmlAgain->{"" . $key . ""}->childTables->childTable[$key2]->addAttribute("prompt", "");
            $xmlAgain->{"" . $key . ""}->childTables->childTable[$key2]->addAttribute("icon", "");
            //$xmlAgain->{"".$key.""}->childTables->childTable[$key2]->addAttribute("refName",$key);
        }
    }
    $xmlAgain->asXml($base . "/config/hierarchy.xml");
}
示例#20
0
 /**
  * Generates a XML file with table/query rows encoding with the database
  * charset.
  * @param array $table Result of table or query fetching.
  * @param string $tableElement Represents the entire set of data.
  * @param string $rowElement Represents each row data set.
  * @return string The XML file.
  */
 private function generateXML($table, $tableElement, $rowElement)
 {
     $comment = sprintf('File generated by DB2XML, %s', date('M d Y'));
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->startDocument('1.0', $this->charset);
     $xml->writeComment($comment);
     $xml->setIndent(true);
     $xml->startElement($tableElement);
     foreach ($table as $row) {
         $xml->startElement($rowElement);
         foreach ($row as $column => $value) {
             $xml->startElement($column);
             $repValue = str_replace('&', '&amp;', $value);
             $xml->writeRaw($repValue);
             $xml->endElement();
         }
         $xml->endElement();
     }
     $xml->endElement();
     return $xml->flush();
 }
function pugpig_send_itunes_edition_credentials($appStorePassword, $subscriptionPrefix, $allowedSubscriptionArray, $binaryReceipt, $secret, $comments = array(), $proxy_server = '', $proxy_port = '')
{
    global $iTunesErrorCodes;
    $itunesUrl = '';
    $jsonResult = null;
    $jsonReceipt = null;
    $status = -1;
    $exception = '';
    if ($binaryReceipt) {
        $base64Receipt = base64_encode($binaryReceipt);
        $jsonReceipt = json_encode(array('receipt-data' => $base64Receipt, 'password' => $appStorePassword));
        // Always verify your receipt first with the production URL; proceed to
        // verify with the sandbox URL if you receive a 21007 status code.
        // Following this approach ensures that you do not have to switch between
        // URLs while your application is being tested or reviewed in the sandbox
        // or is live in the App Store.
        $itunesUrl = 'https://buy.itunes.apple.com/verifyReceipt';
        $jsonResult = pugpig_validate_receipt_with_itunes($itunesUrl, $jsonReceipt, $proxy_server, $proxy_port);
        if ($jsonResult) {
            $status = $jsonResult->status;
            $comments[] = "BUY: Got status {$status}.";
            if (array_key_exists($status, $iTunesErrorCodes)) {
                $comments[] = "BUY: " . $iTunesErrorCodes[$status];
            }
            if (isset($jsonResult->exception)) {
                $exception = $jsonResult->exception;
            }
        } else {
            $comments[] = "PUGPIG: Failed to connect to production iTunes. Maybe check your outbound rules.";
        }
        if ($status == 21007) {
            $comments[] = "PUGPIG: Trying the Sandbox validator.";
            $status = -1;
            $exception = '';
            $itunesUrl = 'https://sandbox.itunes.apple.com/verifyReceipt';
            $jsonResult = pugpig_validate_receipt_with_itunes($itunesUrl, $jsonReceipt, $proxy_server, $proxy_port);
            if ($jsonResult) {
                $status = $jsonResult->status;
                $comments[] = "SANDBOX: Got status {$status}.";
                if (array_key_exists($status, $iTunesErrorCodes)) {
                    $comments[] = "SANDBOX: " . $iTunesErrorCodes[$status];
                }
                if (isset($jsonResult->exception)) {
                    $exception = $jsonResult->exception;
                }
            } else {
                $comments[] = "PUGPIG: Failed to connect to sandbox iTunes. Maybe it is down.";
            }
        }
    } else {
        $comments[] = "PUGPIG: No receipt data sent.";
    }
    $comments[] = "PUGPIG: Validated using: {$itunesUrl}";
    if ($status == 0) {
        $receiptData = $jsonResult->receipt;
        $productId = $receiptData->product_id;
        $comments[] = "PUGPIG: Receipt Product ID: {$productId}";
        $purchaseDate = $receiptData->original_purchase_date;
        $restoreDate = $receiptData->purchase_date;
        $expiresDate = '';
        $comments[] = "PUGPIG: Valid receipt. Purchase date: {$purchaseDate}, Restore date: {$restoreDate}";
        if (property_exists($receiptData, 'expires_date')) {
            $expiresDate = $receiptData->expires_date;
        }
        if ($expiresDate) {
            $expiresDate = gmdate('Y-m-d H:i:s \\E\\t\\c/\\G\\M\\T', $expiresDate / 1000);
            $comments[] = "PUGPIG: Valid receipt. Expires date: {$expiresDate}";
        }
        // If this is an allowed subscription product, use the ID in the query string
        // We either match the prefix, or
        $is_subscription_product = false;
        if (!empty($subscriptionPrefix) && strpos($productId, $subscriptionPrefix) === 0) {
            $is_subscription_product = true;
            $comments[] = "PUGPIG: Subscription found - {$productId} matches  {$subscriptionPrefix}";
        }
        if (in_array($productId, $allowedSubscriptionArray)) {
            $is_subscription_product = true;
            $comments[] = "PUGPIG: Subscription found - {$productId} in supplied array";
        }
        if ($is_subscription_product) {
            $productId = $_GET['productid'];
        } else {
            $comments[] = "PUGPIG: Using product ID from receipt data";
        }
        _pugpig_subs_edition_credentials_response($productId, $secret, $entitled = true, 'active', $comments, array(), '', '', array());
    } else {
        $writer = new XMLWriter();
        $writer->openMemory();
        $writer->setIndent(true);
        $writer->setIndentString('  ');
        $writer->startDocument('1.0', 'UTF-8');
        $writer->startElement('error');
        $writer->writeAttribute('status', $status);
        $writer->writeAttribute('exception', $exception);
        $writer->writeAttribute('validationurl', $itunesUrl);
        $writer->writeElement('subs_prefix', $subscriptionPrefix);
        $writer->writeElement('subs_list', implode(",", $allowedSubscriptionArray));
        $writer->endElement();
        foreach ($comments as $comment) {
            $writer->writeComment(" " . $comment . " ");
        }
        $writer->endDocument();
        header('Content-type: text/xml');
        echo $writer->outputMemory();
        exit;
    }
}
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB')) {
    exit;
}
$xml = new XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
$xml->setIndentString("\t");
// The header
$xml->startDocument('1.0', 'UTF-8', 'yes');
$xml->writePi('xml-stylesheet', 'type="text/xsl" href="' . (!empty($preview) ? $phpbb_root_path . 'modx_files/' : '') . 'modx.prosilver.en.xsl"');
$xml->writeComment('NOTICE: Please open this file in your web browser. If presented with a security warning, you may safely tell it to allow the blocked content.');
$xml->writeComment('For security purposes, please check: http://www.phpbb.com/mods/ for the latest version of this MOD.\\nAlthough MODs are checked before being allowed in the MODs Database there is no guarantee that there are no security problems within the MOD.\\nNo support will be given for MODs not found within the MODs Database which can be found at http://www.phpbb.com/mods/');
// <mod>
$xml->startElement('mod');
$xml->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$xml->writeAttribute('xmlns', 'https://www.phpbb.com/mods/xml/' . MODX_LATEST);
// <header>
$xml->startElement('header');
// Need to reset the counters.
$parser->modx_reset();
// <meta>
// Start with the own meta tag
write_element('meta', '', array('name' => 'generator', 'content' => META), false, false);
while ($meta = $parser->get_modx_meta()) {
    write_element('meta', '', array('name' => $meta['name'], 'content' => $meta['content']), false, false);
}