/**
  * @param array $params
  * @param string $message
  * @param int $code
  */
 private function showResponse(array $params, $message = '', $code = 0)
 {
     header("Content-type: text/xml; charset=utf-8");
     $writer = new XMLWriter();
     $writer->openURI('php://output');
     $writer->startDocument('1.0', 'UTF-8');
     $writer->startElement($params['action'] . 'Response');
     $writer->startAttribute('performedDatetime');
     $writer->text(date('c'));
     $writer->endAttribute();
     $writer->startAttribute('code');
     $writer->text($code);
     $writer->endAttribute();
     $writer->startAttribute('invoiceId');
     $writer->text($params['invoiceId']);
     $writer->endAttribute();
     $writer->startAttribute('message');
     $writer->text($message);
     $writer->endAttribute();
     $writer->startAttribute('shopId');
     $writer->text($params['shopId']);
     $writer->endAttribute();
     $writer->endElement();
     $writer->endDocument();
     Yii::app()->end();
 }
 /**
  * @param string $fileToSave
  * @param number $offsetStart
  * @param number $limit
  * @param null | string $suffix
  *
  * @return string
  */
 protected function saveToFile($fileToSave, $offsetStart, $limit, $suffix = null)
 {
     $writer = new \XMLWriter();
     $path = pathinfo($fileToSave);
     $filePath = $path['dirname'] . '/' . $path['filename'];
     if (!is_null($suffix)) {
         $filePath .= self::SEPERATOR . $suffix;
     }
     if (empty($path['extension'])) {
         $filePath .= self::XML_EXT;
     } else {
         $filePath .= '.' . $path['extension'];
     }
     $writer->openURI($filePath);
     $writer->startDocument('1.0', 'UTF-8');
     $writer->setIndent(true);
     $writer->startElement('sitemapindex');
     $writer->writeAttribute('xmlns', self::SCHEMA);
     for ($i = $offsetStart; $i < count($this->items) && $i < $limit; $i++) {
         $item = $this->items[$i];
         $writer->startElement('sitemap');
         $writer->writeElement('loc', $item['url']);
         $writer->writeElement('lastmod', $item['modified']->format(ModifiableInterface::MODIFIED_DATE_FORMAT));
         $writer->endElement();
     }
     $writer->endElement();
     $writer->endDocument();
     return $filePath;
 }
Exemple #3
0
 /**
  * @param string $resource
  */
 private function writeTo($resource)
 {
     $this->writer->openURI($resource);
     $this->writer->startDocument($this->version, $this->encoding);
     $this->writer->setIndent(true);
     $this->writer->setIndentString("\t");
     $this->getRoot()->save($this->writer);
     $this->writer->endDocument();
     $this->writer->flush();
 }
 /**
  * generate export
  * 
  * @return mixed filename/generated object/...
  */
 public function generate()
 {
     $this->_writer = new XMLWriter();
     $this->_writer->openURI('php://output');
     $this->_writer->startDocument("1.0", "iso-8859-1");
     $this->_writer->startElement("phonebooks");
     $this->_writer->startElement("phonebook");
     $this->_exportRecords();
     $this->_writer->endDocument();
     $this->_writer->flush();
 }
 /**
  * Write XRDS using XMLWriter
  *
  * Outputs a XRDS document specifying an OMB service.
  *
  * @param OMB_profile     $user   The target user for the OMB service
  * @param OMB_XRDS_Mapper $mapper An OMB_XRDS_Mapper providing endpoint URLs
  */
 public function writeXRDS($user, $mapper)
 {
     header('Content-Type: application/xrds+xml');
     $xw = new XMLWriter();
     $xw->openURI('php://output');
     $xw->setIndent(true);
     $xw->startDocument('1.0', 'UTF-8');
     $this->_writeFullElement($xw, 'XRDS', array('xmlns' => 'xri://$xrds'), array(array('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', 'xml:id' => 'oauth', 'xmlns:simple' => 'http://xrds-simple.net/core/1.0', 'version' => '2.0'), array(array('Type', null, 'xri://$xrds*simple'), array('Service', null, array(array('Type', null, OAUTH_ENDPOINT_REQUEST), array('URI', null, $mapper->getURL(OAUTH_ENDPOINT_REQUEST)), array('Type', null, OAUTH_AUTH_HEADER), array('Type', null, OAUTH_POST_BODY), array('Type', null, OAUTH_HMAC_SHA1), array('LocalID', null, $user->getIdentifierURI()))), array('Service', null, array(array('Type', null, OAUTH_ENDPOINT_AUTHORIZE), array('URI', null, $mapper->getURL(OAUTH_ENDPOINT_AUTHORIZE)), array('Type', null, OAUTH_AUTH_HEADER), array('Type', null, OAUTH_POST_BODY), array('Type', null, OAUTH_HMAC_SHA1))), array('Service', null, array(array('Type', null, OAUTH_ENDPOINT_ACCESS), array('URI', null, $mapper->getURL(OAUTH_ENDPOINT_ACCESS)), array('Type', null, OAUTH_AUTH_HEADER), array('Type', null, OAUTH_POST_BODY), array('Type', null, OAUTH_HMAC_SHA1))), array('Service', null, array(array('Type', null, OAUTH_ENDPOINT_RESOURCE), array('Type', null, OAUTH_AUTH_HEADER), array('Type', null, OAUTH_POST_BODY), array('Type', null, OAUTH_HMAC_SHA1))))), array('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', 'xml:id' => 'omb', 'xmlns:simple' => 'http://xrds-simple.net/core/1.0', 'version' => '2.0'), array(array('Type', null, 'xri://$xrds*simple'), array('Service', null, array(array('Type', null, OMB_ENDPOINT_POSTNOTICE), array('URI', null, $mapper->getURL(OMB_ENDPOINT_POSTNOTICE)))), array('Service', null, array(array('Type', null, OMB_ENDPOINT_UPDATEPROFILE), array('URI', null, $mapper->getURL(OMB_ENDPOINT_UPDATEPROFILE)))))), array('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', 'version' => '2.0'), array(array('Type', null, 'xri://$xrds*simple'), array('Service', null, array(array('Type', null, OAUTH_DISCOVERY), array('URI', null, '#oauth'))), array('Service', null, array(array('Type', null, OMB_VERSION), array('URI', null, '#omb')))))));
     $xw->endDocument();
     $xw->flush();
 }
 /**
  * Writes view informations into a XML file, replacing or creating it if necessary.
  */
 public function saveToFile()
 {
     $XMLViewDoc = new XMLWriter();
     $XMLViewDoc->openURI('file://' . VIEW_DATA_DIR . '/' . $this->id . '.xml');
     $XMLViewDoc->setIndent(true);
     $XMLViewDoc->setIndentString('    ');
     $XMLViewDoc->startDocument();
     $XMLViewDoc->startElement("view");
     $XMLViewDoc->writeElement("slice-transformation-filename", $this->getXsltSliceToSVG());
     $XMLViewDoc->writeElement("obsel-transformation-filename", $this->getXsltObselToSVG());
     $XMLViewDoc->writeElement("default-scale", $this->getDefaultScale());
     $XMLViewDoc->writeElement("css-filename", $this->getCssFileName());
     $XMLViewDoc->endElement();
 }
/**
 * Create RSS Feed
 * @param entries
 * @param config
 */
function create_rss($entries, $config)
{
    // Inspired from http://www.phpntips.com/xmlwriter-2009-06/
    $xml = new XMLWriter();
    // Output directly to the user
    $xml->openURI('php://output');
    $xml->startDocument('1.0');
    $xml->setIndent(2);
    //rss
    $xml->startElement('rss');
    $xml->writeAttribute('version', '2.0');
    $xml->writeAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom');
    //channel
    $xml->startElement('channel');
    // title, desc, link, date
    $xml->writeElement('title', $config['title']);
    // $xml->writeElement('description', $config['description']);
    // $xml->writeElement('link', 'http://www.example.com/rss.hml');
    $xml->writeElement('pubDate', date('r'));
    if (!empty($entries)) {
        foreach ($entries as $entry) {
            // item
            $xml->startElement('item');
            $xml->writeElement('title', $entry->title);
            if (isset($entry->permalink)) {
                $xml->writeElement('link', $entry->permalink);
            }
            $xml->startElement('description');
            $xml->writeCData($entry->content);
            $xml->endElement();
            $xml->writeElement('pubDate', date('r', strtotime($entry->date)));
            // category
            // $xml->startElement('category');
            // $xml->writeAttribute('domain', 'http://www.example.com/cat1.htm');
            // $xml->text('News');
            // $xml->endElement();
            // end item
            $xml->endElement();
        }
    }
    // end channel
    $xml->endElement();
    // end rss
    $xml->endElement();
    // end doc
    $xml->endDocument();
    // flush
    $xml->flush();
}
 /**
  * Write metadata for the given package into a Package.xml file.
  *
  * @param \F3\FLOW3\Package\PackageInterface $package The package - also contains information about where to write the Package meta file
  * @param \F3\FLOW3\Package\MetaDataInterface $meta The MetaData object containing the information to write
  * @return boolean If writing the XML file was successful returns TRUE, otherwise FALSE
  * @author Christopher Hlubek <*****@*****.**>
  * @author Robert Lemke <*****@*****.**>
  */
 public function writePackageMetaData(\F3\FLOW3\Package\PackageInterface $package, \F3\FLOW3\Package\MetaDataInterface $meta)
 {
     $xml = new \XMLWriter();
     if ($xml->openURI($package->getMetaPath() . 'Package.xml') === FALSE) {
         return FALSE;
     }
     $xml->setIndent(true);
     $xml->setIndentString(chr(9));
     $xml->startDocument('1.0', 'utf-8', 'yes');
     $xml->startElement('package');
     $xml->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $xml->writeAttribute('xmlns', 'http://typo3.org/ns/2008/flow3/package');
     $xml->writeAttribute('version', '1.0');
     $xml->writeElement('key', $meta->getPackageKey());
     $xml->writeElement('title', $meta->getTitle());
     $xml->writeElement('description', $meta->getDescription());
     $xml->writeElement('version', $meta->getVersion());
     if (count($meta->getCategories())) {
         $xml->startElement('categories');
         foreach ($meta->getCategories() as $category) {
             $xml->writeElement('category', $category);
         }
         $xml->endElement();
     }
     if (count($meta->getParties())) {
         $xml->startElement('parties');
         foreach ($meta->getParties() as $party) {
             $this->writeParty($xml, $party);
         }
         $xml->endElement();
     }
     if (count($meta->getConstraints())) {
         $xml->startElement('constraints');
         foreach ($meta->getConstraintTypes() as $constraintType) {
             $constraints = $meta->getConstraintsByType($constraintType);
             if (count($constraints)) {
                 $xml->startElement($constraintType);
                 foreach ($constraints as $constraint) {
                     $this->writeConstraint($xml, $constraint);
                 }
                 $xml->endElement();
             }
         }
         $xml->endElement();
     }
     $xml->endElement();
     return TRUE;
 }
Exemple #9
0
function write_major_file($code, $data, $type)
{
    $pointer = new XMLWriter();
    $time = strftime("%Y-%m-%d %H:%m:%S");
    foreach (array_keys($data) as $group) {
        echo "writing major xml files for: {$group}\n";
        $dir = realpath(dirname(dirname(__FILE__)) . "/modules") . "/isco_{$code}/modules/" . "isco_{$code}_major_{$group}";
        if (!is_dir($dir)) {
            if (!mkdir($dir, 0777, TRUE)) {
                echo "Couldn't make {$dir}!";
                exit(1);
            }
        }
        $pointer->openURI("file://{$dir}/majorgroup" . $group . ".xml");
        xml_header($pointer, $code, $group);
        foreach ($type as $i => $level) {
            write_group($pointer, $i, $level, $code, $group, $data[$group], $time, $type);
        }
        xml_footer($pointer);
        $pointer->flush();
    }
}
Exemple #10
0
 /**
  * @param string $fileToSave
  * @param int $offsetStart
  * @param number $limit
  * @param null | string $suffix
  *
  * @return string
  */
 protected function saveToFile($fileToSave, $offsetStart, $limit, $suffix = null)
 {
     $writer = new \XMLWriter();
     $path = pathinfo($fileToSave);
     $filePath = $path['dirname'] . '/' . $path['filename'];
     if (!is_null($suffix)) {
         $filePath .= self::SEPERATOR . $suffix;
     }
     if (empty($path['extension'])) {
         $filePath .= self::XML_EXT;
     } else {
         $filePath .= '.' . $path['extension'];
     }
     $writer->openURI($filePath);
     $writer->startDocument('1.0', 'UTF-8');
     $writer->setIndent(true);
     $writer->startElement('urlset');
     $writer->writeAttribute('xmlns', self::SCHEMA);
     /* @var $item SitemapItemInterface */
     for ($i = $offsetStart; $i < count($this->items) && $i < $limit; $i++) {
         $item = $this->items[$i];
         $writer->startElement('url');
         $writer->writeElement('loc', $item->getLocation());
         if (!is_null($priority = $item->getPriority())) {
             $writer->writeElement('priority', $priority);
         }
         if (!is_null($freq = $item->getChangeFrequency())) {
             $writer->writeElement('changefreq', $freq);
         }
         if (!is_null($lastmod = $item->getLastModified())) {
             $writer->writeElement('lastmod', $lastmod);
         }
         $writer->endElement();
     }
     $writer->endElement();
     $writer->endDocument();
     return $filePath;
 }
Exemple #11
0
function out_Xml($result)
{
    header('Content-Type:text/xml');
    $writer = new XMLWriter();
    $writer->openURI('php://output');
    $writer->startDocument('1.0', 'UTF-8');
    $writer->startElement('Categories');
    $parent_id = null;
    foreach ($result as $category) {
        if ($category['parent'] == null && $category['_id'] != $parent_id) {
            if ($parent_id) {
                $writer->endElement();
                // Children
                $writer->endElement();
                // Category
            }
            $parent_id = $category['_id'];
            $writer->startElement('Category');
            $writer->writeElement('label', $category['label']);
            $writer->writeElement('short_label', $category['short_label']);
            $writer->startElement('Children');
        } else {
            $writer->startElement('Category');
            $writer->writeElement('label', $category['label']);
            $writer->writeElement('short_label', $category['short_label']);
            $writer->endElement();
        }
    }
    $writer->endElement();
    // Children
    $writer->endElement();
    // Category
    $writer->endElement();
    // Categories
    $writer->endDocument();
}
 /**
  * Test method
  */
 public function simpleXML()
 {
     $writer = new XMLWriter();
     $writer->openURI('test.xml');
     //$writer->openURI('php://output');
     $writer->startDocument('1.0', 'UTF-8');
     $writer->setIndent(4);
     $writer->startElement('test');
     $writer->writeElement('blop', 'blupblup');
     $writer->endElement();
     $writer->endDocument();
     $writer->flush();
 }
Exemple #13
0
    $t_result = array();
}
$t_filename = "exported_issues.xml";
# Send headers to browser to activate mime loading
# Make sure that IE can download the attachments under https.
header('Pragma: public');
header('Content-Type: text/xml; name=' . $t_filename);
header('Content-Transfer-Encoding: BASE64;');
# Added Quotes (") around file name.
header('Content-Disposition: attachment; filename="' . $t_filename . '"');
$t_version = MANTIS_VERSION;
$t_url = config_get('path');
$t_bug_link = config_get('bug_link_tag');
$t_bugnote_link = config_get('bugnote_link_tag');
$writer = new XMLWriter();
$writer->openURI('php://output');
$writer->setIndent(true);
$writer->setIndentString('    ');
$writer->startDocument('1.0', 'UTF-8');
$writer->startElement('mantis');
$writer->writeAttribute('version', $t_version);
$writer->writeAttribute('urlbase', $t_url);
$writer->writeAttribute('issuelink', $t_bug_link);
$writer->writeAttribute('notelink', $t_bugnote_link);
$writer->writeAttribute('format', '1');
# Ignored fields, these will be skipped
$t_ignore = array('_stats', 'bug_text_id');
/* properties that we want to export are 'protected' */
$t_columns = array_keys(getClassProperties('BugData', 'protected'));
# export the rows
foreach ($t_result as $t_row) {
            $matched = true;
            if (!isset($tracker[$id])) {
                $tracker[$id] = array();
            }
            if (!isset($tracker[$id][$file])) {
                $tracker[$id][$file] = array();
            }
            $tracker[$id][$file][] = $line;
        } while (0);
        //echo "$file:$line uses $namespace.$directive\n";
    }
}
echo "\n{$counter}/{$full_counter} instances of \$config or \$this->config found in source code.\n";
echo "Generating XML... ";
$xw = new XMLWriter();
$xw->openURI('../configdoc/usage.xml');
$xw->setIndent(true);
$xw->startDocument('1.0', 'UTF-8');
$xw->startElement('usage');
foreach ($tracker as $id => $files) {
    $xw->startElement('directive');
    $xw->writeAttribute('id', $id);
    foreach ($files as $file => $lines) {
        $xw->startElement('file');
        $xw->writeAttribute('name', $file);
        foreach ($lines as $line) {
            $xw->writeElement('line', $line);
        }
        $xw->endElement();
    }
    $xw->endElement();
 public function export($v92ec19ffde05e15769b1bb3ee05ad745)
 {
     set_time_limit(0);
     if (!count($v92ec19ffde05e15769b1bb3ee05ad745)) {
         $v8be74552df93e31bbdd6b36ed74bdb6a = new selector('pages');
         $v8be74552df93e31bbdd6b36ed74bdb6a->where('hierarchy')->page(0)->childs(0);
         $v92ec19ffde05e15769b1bb3ee05ad745 = $v8be74552df93e31bbdd6b36ed74bdb6a->result;
     }
     if (getRequest('as_file') === '0') {
         $ved780287e302ec3b9fd3c5e78771919f = new xmlExporter($this->getSourceName());
         $ved780287e302ec3b9fd3c5e78771919f->addBranches($v92ec19ffde05e15769b1bb3ee05ad745);
         $result = $ved780287e302ec3b9fd3c5e78771919f->execute();
         return $result->saveXML();
     }
     $v857a5246dff0c3c79e476b004684f6d3 = "./sys-temp/export/";
     $vb80bb7740288fda1f201890375a60c8f = getRequest('param0');
     $v97fd815a3803a0588876bdd862014fed = $v857a5246dff0c3c79e476b004684f6d3 . $vb80bb7740288fda1f201890375a60c8f . "." . parent::getFileExt();
     $v6990a54322d9232390a784c5c9247dd6 = $v857a5246dff0c3c79e476b004684f6d3 . $vb80bb7740288fda1f201890375a60c8f;
     if (!is_dir($v6990a54322d9232390a784c5c9247dd6)) {
         mkdir($v6990a54322d9232390a784c5c9247dd6, 0777, true);
     }
     if (file_exists($v97fd815a3803a0588876bdd862014fed) && !file_exists(CURRENT_WORKING_DIR . '/sys-temp/runtime-cache/' . md5($this->getSourceName()))) {
         unlink($v97fd815a3803a0588876bdd862014fed);
     }
     if ($v92ec19ffde05e15769b1bb3ee05ad745) {
         $v33030abc929f083da5f6c3f755b46034 = array('./tpls/', './xsltTpls/', './css/', './js/', './usels/', './umaps/', './templates/');
         foreach ($v33030abc929f083da5f6c3f755b46034 as $v100664c6e2c0333b19a729f2f3ddb7dd) {
             if (is_dir($v100664c6e2c0333b19a729f2f3ddb7dd)) {
                 $v736007832d2167baaae763fd3a3f3cf1 = new umiDirectory($v100664c6e2c0333b19a729f2f3ddb7dd);
                 $v45b963397aa40d4a0063e0d85e4fe7a1 = $v736007832d2167baaae763fd3a3f3cf1->getAllFiles(1);
                 foreach ($v45b963397aa40d4a0063e0d85e4fe7a1 as $vd6fe1d0be6347b8ef2427fa629c04485 => $vb068931cc450442b63f5b3d276ea4297) {
                     $v8c7dd922ad47494fc02c388e12c00eac = new umiFile($vd6fe1d0be6347b8ef2427fa629c04485);
                     if (!is_dir($v6990a54322d9232390a784c5c9247dd6 . ltrim($v8c7dd922ad47494fc02c388e12c00eac->getDirName(), '.'))) {
                         mkdir($v6990a54322d9232390a784c5c9247dd6 . ltrim($v8c7dd922ad47494fc02c388e12c00eac->getDirName(), '.'), 0777, true);
                     }
                     copy($v8c7dd922ad47494fc02c388e12c00eac->getFilePath(), $v6990a54322d9232390a784c5c9247dd6 . $v8c7dd922ad47494fc02c388e12c00eac->getFilePath(true));
                 }
             }
         }
     }
     $v71b70dd1e455c477220693d84ccd5682 = $v97fd815a3803a0588876bdd862014fed . '.tmp';
     $v480d1b61a0432d1319f7504a3d7318dd = (int) mainConfiguration::getInstance()->get("modules", "exchange.export.limit");
     if ($v480d1b61a0432d1319f7504a3d7318dd <= 0) {
         $v480d1b61a0432d1319f7504a3d7318dd = 25;
     }
     $ved780287e302ec3b9fd3c5e78771919f = new xmlExporter($this->getSourceName(), $v480d1b61a0432d1319f7504a3d7318dd);
     $ved780287e302ec3b9fd3c5e78771919f->addBranches($v92ec19ffde05e15769b1bb3ee05ad745);
     $vdd988cfd769c9f7fbd795a0f5da8e751 = $ved780287e302ec3b9fd3c5e78771919f->execute();
     if (file_exists($v97fd815a3803a0588876bdd862014fed)) {
         $v1de9b0a30075ae8c303eb420c103c320 = new XMLReader();
         $va82feee3cc1af8bcabda979e8775ef0f = new XMLWriter();
         $v1de9b0a30075ae8c303eb420c103c320->open($v97fd815a3803a0588876bdd862014fed);
         $va82feee3cc1af8bcabda979e8775ef0f->openURI($v71b70dd1e455c477220693d84ccd5682);
         $va82feee3cc1af8bcabda979e8775ef0f->startDocument('1.0', 'utf-8');
         $va82feee3cc1af8bcabda979e8775ef0f->startElement('umidump');
         $va82feee3cc1af8bcabda979e8775ef0f->writeAttribute('version', '2.0');
         $va82feee3cc1af8bcabda979e8775ef0f->writeAttribute('xmlns:xlink', 'http://www.w3.org/TR/xlink');
         $v7aa28ed115707345d0274032757e8991 = $v1de9b0a30075ae8c303eb420c103c320->read();
         while ($v7aa28ed115707345d0274032757e8991) {
             if ($v1de9b0a30075ae8c303eb420c103c320->nodeType == XMLReader::ELEMENT) {
                 $ve24455211a964330063a18670d943835 = $v1de9b0a30075ae8c303eb420c103c320->name;
                 if ($ve24455211a964330063a18670d943835 != 'umidump') {
                     $va82feee3cc1af8bcabda979e8775ef0f->startElement($ve24455211a964330063a18670d943835);
                     if ($ve24455211a964330063a18670d943835 != 'meta') {
                         if (!$v1de9b0a30075ae8c303eb420c103c320->isEmptyElement) {
                             $v7852ddca47412c0d947ebf27eb83ed3a = $v1de9b0a30075ae8c303eb420c103c320->read();
                             while ($v7852ddca47412c0d947ebf27eb83ed3a) {
                                 if ($v1de9b0a30075ae8c303eb420c103c320->nodeType == XMLReader::ELEMENT) {
                                     $vcf7f5c76225a101e6320a96c02f92fc1 = $v1de9b0a30075ae8c303eb420c103c320->name;
                                     $va82feee3cc1af8bcabda979e8775ef0f->writeRaw($v1de9b0a30075ae8c303eb420c103c320->readOuterXML());
                                     $v7852ddca47412c0d947ebf27eb83ed3a = $v1de9b0a30075ae8c303eb420c103c320->next();
                                 } elseif ($v1de9b0a30075ae8c303eb420c103c320->nodeType == XMLReader::END_ELEMENT && $v1de9b0a30075ae8c303eb420c103c320->name == $ve24455211a964330063a18670d943835) {
                                     $v7852ddca47412c0d947ebf27eb83ed3a = false;
                                 } else {
                                     $v7852ddca47412c0d947ebf27eb83ed3a = $v1de9b0a30075ae8c303eb420c103c320->next();
                                 }
                             }
                         }
                         if ($vdd988cfd769c9f7fbd795a0f5da8e751->getElementsByTagName($ve24455211a964330063a18670d943835)->item(0)->hasChildNodes()) {
                             $v268184c12df027f536154d099d497b31 = $vdd988cfd769c9f7fbd795a0f5da8e751->getElementsByTagName($ve24455211a964330063a18670d943835)->item(0)->childNodes;
                             foreach ($v268184c12df027f536154d099d497b31 as $v1b7d5726533ab525a8760351e9b5e415) {
                                 $va5e171f642af8e3bd24c50cdc4d66fe3 = new DOMDocument();
                                 $va5e171f642af8e3bd24c50cdc4d66fe3->formatOutput = true;
                                 $v36c4536996ca5615dcf9911f068786dc = $va5e171f642af8e3bd24c50cdc4d66fe3->importNode($v1b7d5726533ab525a8760351e9b5e415, true);
                                 $va5e171f642af8e3bd24c50cdc4d66fe3->appendChild($v36c4536996ca5615dcf9911f068786dc);
                                 $va82feee3cc1af8bcabda979e8775ef0f->writeRaw($va5e171f642af8e3bd24c50cdc4d66fe3->saveXML($v36c4536996ca5615dcf9911f068786dc, LIBXML_NOXMLDECL));
                             }
                         }
                     } elseif ($ve24455211a964330063a18670d943835 == 'meta') {
                         $va82feee3cc1af8bcabda979e8775ef0f->writeRaw($v1de9b0a30075ae8c303eb420c103c320->readInnerXML());
                         $v92ec19ffde05e15769b1bb3ee05ad745 = $vdd988cfd769c9f7fbd795a0f5da8e751->getElementsByTagName('branches');
                         if ($v92ec19ffde05e15769b1bb3ee05ad745->item(0)) {
                             $va82feee3cc1af8bcabda979e8775ef0f->writeRaw($vdd988cfd769c9f7fbd795a0f5da8e751->saveXML($v92ec19ffde05e15769b1bb3ee05ad745->item(0), LIBXML_NOXMLDECL));
                         }
                     }
                     $va82feee3cc1af8bcabda979e8775ef0f->fullEndElement();
                     $v7aa28ed115707345d0274032757e8991 = $v1de9b0a30075ae8c303eb420c103c320->next();
                     continue;
                 }
             }
             $v7aa28ed115707345d0274032757e8991 = $v1de9b0a30075ae8c303eb420c103c320->read();
         }
         $va82feee3cc1af8bcabda979e8775ef0f->fullEndElement();
         $v1de9b0a30075ae8c303eb420c103c320->close();
         $va82feee3cc1af8bcabda979e8775ef0f->endDocument();
         $va82feee3cc1af8bcabda979e8775ef0f->flush();
         unlink($v97fd815a3803a0588876bdd862014fed);
         rename($v71b70dd1e455c477220693d84ccd5682, $v97fd815a3803a0588876bdd862014fed);
     } else {
         file_put_contents($v97fd815a3803a0588876bdd862014fed, $vdd988cfd769c9f7fbd795a0f5da8e751->saveXML());
     }
     $this->completed = $ved780287e302ec3b9fd3c5e78771919f->isCompleted();
     return false;
 }
function write_metadata($collection)
{
    $writer = new XMLWriter();
    $writer->openURI("{$collection['project_id']}.void.rdf");
    //$writer->openURI('php://output');
    $writer->startDocument('1.0', 'UTF-8');
    $writer->setIndent(true);
    //now we need to define our Indent string,which is basically how many blank spaces we want to have for the indent
    $writer->setIndentString("    ");
    $writer->startElement('rdf:RDF');
    $writer->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema#');
    $writer->writeAttribute('xmlns:nm', "http://nomisma.org/id/");
    $writer->writeAttribute('xmlns:nmo', "http://nomisma.org/ontology#");
    $writer->writeAttribute('xmlns:dcterms', "http://purl.org/dc/terms/");
    $writer->writeAttribute('xmlns:foaf', "http://xmlns.com/foaf/0.1/");
    $writer->writeAttribute('xmlns:geo', "http://www.w3.org/2003/01/geo/wgs84_pos#");
    $writer->writeAttribute('xmlns:rdf', "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
    $writer->writeAttribute('xmlns:void', "http://rdfs.org/ns/void#");
    $writer->startElement('void:Dataset');
    $writer->writeAttribute('rdf:about', $collection['database_homepage']);
    //titles
    if (strlen($collection['title_en']) > 0) {
        $writer->startElement('dcterms:title');
        $writer->writeAttribute('xml:lang', 'en');
        $writer->text(trim($collection['title_en']));
        $writer->endElement();
    }
    if (strlen($collection['title_de']) > 0) {
        $writer->startElement('dcterms:title');
        $writer->writeAttribute('xml:lang', 'de');
        $writer->text(trim($collection['title_de']));
        $writer->endElement();
    }
    //descriptions
    if (strlen($collection['description_en']) > 0) {
        $writer->startElement('dcterms:description');
        $writer->writeAttribute('xml:lang', 'en');
        $writer->text(trim($collection['description_en']));
        $writer->endElement();
    }
    if (strlen($collection['description_de']) > 0) {
        $writer->startElement('dcterms:description');
        $writer->writeAttribute('xml:lang', 'de');
        $writer->text(trim($collection['description_de']));
        $writer->endElement();
    }
    $writer->writeElement('dcterms:publisher', $collection['publisher']);
    $writer->startElement('dcterms:license');
    $writer->writeAttribute('rdf:resource', $collection['license']);
    $writer->endElement();
    $writer->startElement('void:dataDump');
    $writer->writeAttribute('rdf:resource', 'http://numismatics.org/rdf/' . $collection['project_id'] . '.rdf');
    $writer->endElement();
    $writer->endElement();
    $writer->endElement();
    $writer->flush();
}
 function toXML($fixBrokenSymbols = false)
 {
     $c = 0;
     $d = "" != $this->delimiter ? $this->delimiter : $this->settings['delimiter'];
     $e = $this->settings['escape'];
     $l = $this->settings['length'];
     PMXI_Plugin::$is_csv = $d;
     $res = fopen($this->_filename, 'rb');
     $xmlWriter = new XMLWriter();
     $xmlWriter->openURI($this->xml_path);
     $xmlWriter->setIndent(true);
     $xmlWriter->setIndentString("\t");
     $xmlWriter->startDocument('1.0', $this->csv_encoding);
     $xmlWriter->startElement('data');
     $create_new_headers = false;
     while ($keys = fgetcsv($res, $l, $d, $e)) {
         if ($c == 0) {
             $buf_keys = $keys;
             foreach ($keys as $key => $value) {
                 if (!$create_new_headers and (preg_match('%\\W(http:|https:|ftp:)$%i', $value) or is_numeric($value))) {
                     $create_new_headers = true;
                 }
                 $value = trim(strtolower(preg_replace('/^[0-9]{1}/', 'el_', preg_replace('/[^a-z0-9_]/i', '', $value))));
                 $keys[$key] = !empty($value) ? $value : 'undefined' . $key;
             }
             $this->headers = $keys;
             if ($create_new_headers) {
                 $this->createHeaders('column');
                 $keys = $buf_keys;
             }
         }
         if ($c or $create_new_headers) {
             if (!empty($keys)) {
                 $chunk = array();
                 foreach ($this->headers as $key => $header) {
                     $chunk[$header] = $this->fixEncoding($keys[$key]);
                 }
                 if (!empty($chunk)) {
                     $xmlWriter->startElement('node');
                     foreach ($chunk as $header => $value) {
                         $xmlWriter->startElement($header);
                         if ($fixBrokenSymbols) {
                             // Remove non ASCII symbols and write CDATA
                             $xmlWriter->writeCData(preg_replace('/[^\\x{0009}\\x{000a}\\x{000d}\\x{0020}-\\x{D7FF}\\x{E000}-\\x{FFFD}]+/u', ' ', $value));
                         } else {
                             $xmlWriter->writeCData($value);
                         }
                         $xmlWriter->endElement();
                     }
                     $xmlWriter->endElement();
                 }
             }
         }
         $c++;
     }
     fclose($res);
     $xmlWriter->endElement();
     $xmlWriter->flush(true);
     return true;
 }
 /**
  * Gerenate configuration file for a module
  *
  * @param array $row The module information
  */
 private function generateModule($row)
 {
     $filename = $this->tmpPath . '/' . $this->pollerId . '/' . $row['config_name'] . '.xml';
     // store broker id
     $this->baseConfig['%broker_id%'] = $row['config_id'];
     $moduleInformation = $this->getInformationFromTpl($row['config_name']);
     $xml = new \XMLWriter();
     if (false === $xml->openURI($filename)) {
         throw new Exception('Error when create configuration file.');
     }
     $xml->setIndent(true);
     $xml->startDocument('1.0', 'UTF-8');
     $xml->startElement('conf');
     foreach ($moduleInformation as $module => $information) {
         if ($module == 'general') {
             /* Merge information with default */
             $configuration = $this->moduleGeneral($information, $row);
             $configuration = array_merge($this->defaults['general'], $configuration);
             $this->addModule($xml, $module, $configuration, true);
         } else {
             $nbGroup = 1;
             foreach ($information as $group) {
                 /* Merge information with default */
                 $configuration = $this->moduleBlock($row['config_id'], $module, $nbGroup, $group);
                 $default = $this->getDefaults($module, $group);
                 $configuration = array_merge($default, $configuration);
                 $this->addModule($xml, $module, $configuration);
                 $nbGroup++;
             }
         }
     }
     $xml->endElement();
     $xml->endDocument();
 }
 protected function toXML()
 {
     $fp = fopen($this->_filename, 'rb');
     fseek($fp, 0);
     $xmlWriter = new XMLWriter();
     $xmlWriter->openURI($this->xml_path);
     $xmlWriter->setIndent(true);
     $xmlWriter->setIndentString("\t");
     $xmlWriter->startDocument('1.0', 'UTF-8');
     $xmlWriter->startElement('data');
     while (!feof($fp)) {
         //reset time limit for big files
         set_time_limit(0);
         $sql = fread($fp, 1024 * 8);
         $count = preg_match_all("%INSERT INTO .*;%Uis", $sql, $matches);
         if ($count) {
             foreach ($matches[0] as $key => $insert) {
                 $current_table = 'node';
                 $table = preg_match_all("%INTO\\s*[^\\(].*\\(%Uis", $insert, $table_matches);
                 if ($table) {
                     $current_table = sanitize_key(trim(trim(str_replace('INTO', '', trim($table_matches[0][0], '('))), '`'));
                 }
                 $rawData = array();
                 $headers = preg_match_all("%\\(.*\\)\\s*VALUES%Uis", $insert, $headers_matches);
                 if ($headers) {
                     foreach ($headers_matches[0] as $key => $founded_headers) {
                         $hdrs = explode(',', rtrim(ltrim(trim(rtrim(trim($founded_headers), 'VALUES')), '('), ')'));
                         if (!empty($hdrs)) {
                             foreach ($hdrs as $header) {
                                 $rawData[sanitize_key(trim(trim($header), '`'))] = '';
                             }
                         }
                     }
                     $values = preg_match_all("%\\([^`].*\\)\\s*[,|;]{1}%Uis", $insert, $values_matches);
                     if ($values) {
                         foreach ($values_matches[0] as $key => $value) {
                             $insertData = array();
                             $vals = explode(',', rtrim(ltrim(trim(rtrim(rtrim(trim($value), ','), ';')), '('), ')'));
                             if (!empty($vals)) {
                                 $i = 0;
                                 foreach ($rawData as $r_key => $v) {
                                     foreach ($vals as $k => $val) {
                                         if ($i == $k) {
                                             $insertData[$r_key] = trim(trim($val), "'");
                                         }
                                     }
                                     $i++;
                                 }
                             }
                             if (!empty($insertData)) {
                                 $xmlWriter->startElement($current_table);
                                 foreach ($insertData as $h => $xml_value) {
                                     $xmlWriter->startElement($h);
                                     $xmlWriter->writeCData($xml_value);
                                     $xmlWriter->endElement();
                                 }
                                 $xmlWriter->endElement();
                             }
                         }
                     }
                 }
             }
         }
     }
     fclose($fp);
     $xmlWriter->endElement();
     $xmlWriter->flush(true);
     return true;
 }
Exemple #20
0
 public function xmlout()
 {
     if (!array_key_exists('debug', $_REQUEST)) {
         header('Content-type: text/xml');
     } else {
         header('Content-type: text/plain');
     }
     $listing = $this->_build_listing();
     $writer = new XMLWriter();
     $writer->openURI('php://output');
     $writer->setIndentString('    ');
     $writer->setIndent(1);
     $writer->startDocument('1.0');
     $this->_xml_unparser($listing, $writer);
     $writer->endDocument();
     $writer->flush();
     exit;
 }
/**
 * (re)write the web.config file to prevent browser access to the log file
 */
function handleWebConfig()
{
    if (!isset($_SERVER['IIS_UrlRewriteModule'])) {
        return;
    }
    global $setup_site_log_dir;
    global $setup_site_log_file;
    global $sugar_config;
    // Bug 36968 - Fallback to using $sugar_config values when we are not calling this from the installer
    if (empty($setup_site_log_file)) {
        $setup_site_log_file = $sugar_config['log_file'];
        if (empty($sugar_config['log_file'])) {
            $setup_site_log_file = 'sugarcrm.log';
        }
    }
    if (empty($setup_site_log_dir)) {
        $setup_site_log_dir = $sugar_config['log_dir'];
        if (empty($sugar_config['log_dir'])) {
            $setup_site_log_dir = '.';
        }
    }
    $prefix = $setup_site_log_dir . empty($setup_site_log_dir) ? '' : '/';
    $config_array = array(array('1' => $prefix . str_replace('.', '\\.', $setup_site_log_file) . '\\.*', '2' => 'log_file_restricted.html'), array('1' => $prefix . 'install.log', '2' => 'log_file_restricted.html'), array('1' => $prefix . 'upgradeWizard.log', '2' => 'log_file_restricted.html'), array('1' => $prefix . 'emailman.log', '2' => 'log_file_restricted.html'), array('1' => 'not_imported_.*.txt', '2' => 'log_file_restricted.html'), array('1' => 'XTemplate/(.*)/(.*).php', '2' => 'index.php'), array('1' => 'data/(.*).php', '2' => 'index.php'), array('1' => 'examples/(.*).php', '2' => 'index.php'), array('1' => 'include/(.*).php', '2' => 'index.php'), array('1' => 'include/(.*)/(.*).php', '2' => 'index.php'), array('1' => 'log4php/(.*).php', '2' => 'index.php'), array('1' => 'log4php/(.*)/(.*)', '2' => 'index.php'), array('1' => 'metadata/(.*)/(.*).php', '2' => 'index.php'), array('1' => 'modules/(.*)/(.*).php', '2' => 'index.php'), array('1' => 'soap/(.*).php', '2' => 'index.php'), array('1' => 'emailmandelivery.php', '2' => 'index.php'), array('1' => 'cron.php', '2' => 'index.php'), array('1' => $sugar_config['upload_dir'] . '.*', '2' => 'index.php'));
    $xmldoc = new XMLWriter();
    $xmldoc->openURI('web.config');
    $xmldoc->setIndent(true);
    $xmldoc->setIndentString(' ');
    $xmldoc->startDocument('1.0', 'UTF-8');
    $xmldoc->startElement('configuration');
    $xmldoc->startElement('system.webServer');
    $xmldoc->startElement('rewrite');
    $xmldoc->startElement('rules');
    for ($i = 0; $i < count($config_array); $i++) {
        $xmldoc->startElement('rule');
        $xmldoc->writeAttribute('name', "redirect{$i}");
        $xmldoc->writeAttribute('stopProcessing', 'true');
        $xmldoc->startElement('match');
        $xmldoc->writeAttribute('url', $config_array[$i]['1']);
        $xmldoc->endElement();
        $xmldoc->startElement('action');
        $xmldoc->writeAttribute('type', 'Redirect');
        $xmldoc->writeAttribute('url', $config_array[$i]['2']);
        $xmldoc->writeAttribute('redirectType', 'Found');
        $xmldoc->endElement();
        $xmldoc->endElement();
    }
    $xmldoc->endElement();
    $xmldoc->endElement();
    $xmldoc->startElement('caching');
    $xmldoc->startElement('profiles');
    $xmldoc->startElement('remove');
    $xmldoc->writeAttribute('extension', ".php");
    $xmldoc->endElement();
    $xmldoc->endElement();
    $xmldoc->endElement();
    $xmldoc->startElement('staticContent');
    $xmldoc->startElement("clientCache");
    $xmldoc->writeAttribute('cacheControlMode', 'UseMaxAge');
    $xmldoc->writeAttribute('cacheControlMaxAge', '30.00:00:00');
    $xmldoc->endElement();
    $xmldoc->endElement();
    $xmldoc->endElement();
    $xmldoc->endElement();
    $xmldoc->endDocument();
    $xmldoc->flush();
}
Exemple #22
0
    exit;
}
/* set character set */
if (!$mysqli->set_charset("utf8")) {
    print "Error loading character set utf8: " . $mysqli->error;
    exit;
}
$options = array('connectTimeout' => 5, 'arrayResult' => true, 'matchMode' => SPH_MATCH_EXTENDED2, 'limits' => 1, 'page' => 1, 'index' => "i_ref_vehicles i_delta_vehicles");
$conf = new Conftmp('3313');
$sph = new CSphinx($conf, '192.168.240.45');
print_text("Start");
$sql = "\n\t\tselect \n\t\t\tgroup_concat(p.id) as stat_ids,\n\t\t\tconcat(\n\t\t\t\t'http://pingola.ru/auto/search/all/',\n\t\t\t\tmake,\n\t\t\t\t'/',\n\t\t\t\tmodel,\n\t\t\t\t'/?year=',\n\t\t\t\tyear,'-',year\n\t\t\t) as url,\n\t\t\tmake as brand,model as series,year as year,sum(items_counted) as count,avg(avg_price) as avgPrice\n\t\tfrom ru_eyezeek.np_market_trends_vehicles_prices p join ru_eyezeek.np_market_trends_vehicles_items i on i.id=p.item_id\n\t\twhere `month`='" . date('Y-m-00', strtotime('-30 day')) . "' and items_counted>10\n\t\tgroup by make,model,year";
print_text("Fetching all relevant items");
if ($result = $mysqli->query($sql)) {
    $writer = new XMLWriter();
    $writer->openURI('/home/eyezeek/netup/ru/avtology/avtologystat.xml');
    $writer->startDocument('1.0', 'UTF-8');
    $writer->setIndent(TRUE);
    $writer->startElement('report');
    $writer->writeElement('creationDate', date("Y-m-d H:i:s", time()));
    $writer->startElement('vehicles');
    while ($arr = $result->fetch_assoc()) {
        $writer->startElement('vehicle');
        $stat_ids = $arr['stat_ids'];
        unset($arr['stat_ids']);
        $sql = "select `range`,`text`,`price` from ru_eyezeek.np_market_trends_vehicles_ranges where stat_id in (" . $stat_ids . ") and `range`=3";
        print_text("Fetching km ranges for " . $arr['brand'] . " " . $arr['series'] . " " . $arr['year']);
        if ($result1 = $mysqli->query($sql)) {
            $avg_km_counter = 0;
            $avg_km = 0;
            while ($arr1 = $result1->fetch_assoc()) {
Exemple #23
0
 /**
  * Writes Google sitemap index for generated sitemap files
  *
  * @param string $loc Accessible URL path of sitemaps
  * @param string|int $lastmod The date of last modification of sitemap. Unix timestamp or any English textual datetime description.
  */
 public function createSitemapIndex($loc = null, $lastmod = 'Today')
 {
     if (!$loc) {
         $loc = $this->getDomain() . 'sitemap/';
     }
     $this->endSitemap();
     $indexwriter = new \XMLWriter();
     $indexwriter->openURI($this->getPath(false) . $this->getFilename() . self::EXT);
     $indexwriter->startDocument('1.0', 'UTF-8');
     $indexwriter->setIndent(true);
     $indexwriter->startElement('sitemapindex');
     $indexwriter->writeAttribute('xmlns', self::SCHEMA);
     for ($index = 0; $index < $this->getCurrentSitemap(); $index++) {
         $indexwriter->startElement('sitemap');
         $indexwriter->writeElement('loc', $loc . $this->getFilename() . ($index ? self::SEPERATOR . $index : '') . self::EXT);
         $indexwriter->writeElement('lastmod', $this->getLastModifiedDate($lastmod));
         $indexwriter->endElement();
     }
     $indexwriter->endElement();
     $indexwriter->endDocument();
 }
function xmlexport()
{
    global $opt;
    header('Content-type:application/octet-stream');
    header('Content-Disposition:attachment;filename="translation.xml"');
    $lang = array();
    foreach ($opt['template']['locales'] as $k => $v) {
        $lang[] = $k;
    }
    @date_default_timezone_set("GMT");
    $writer = new XMLWriter();
    $writer->openURI('php://output');
    $writer->startDocument('1.0', 'UTF-8', 'yes');
    $writer->setIndent(2);
    $writer->startElement('translation');
    $writer->writeAttribute('version', '1.0');
    $writer->writeAttribute('timestamp', date('c'));
    $rs = sql("SELECT `id`, `text` FROM `sys_trans` ORDER BY `id` ASC");
    while ($r = sql_fetch_assoc($rs)) {
        $writer->startElement('text');
        $writer->writeAttribute('id', $r['id']);
        $writer->writeElement('code', $r['text']);
        for ($n = 0; $n < count($lang); $n++) {
            $writer->writeElement($lang[$n], sql_value("SELECT `text` FROM `sys_trans_text` WHERE `trans_id`='&1' AND `lang`='&2'", '', $r['id'], $lang[$n]));
        }
        $rsUsage = sql("SELECT `resource_name`, `line` FROM `sys_trans_ref` WHERE `trans_id`='&1'", $r['id']);
        while ($rUsage = sql_fetch_assoc($rsUsage)) {
            $line = '';
            if ($rUsage['line'] != 0) {
                $line = ' (' . $rUsage['line'] . ')';
            }
            $writer->writeElement('usage', $rUsage['resource_name'] . $line);
        }
        sql_free_result($rsUsage);
        $writer->endElement();
    }
    sql_free_result($rs);
    $writer->endElement();
    $writer->endDocument();
    $writer->flush();
    exit;
}
function generate_rdf($records, $project)
{
    //start RDF/XML file
    //use XML writer to generate RDF
    $writer = new XMLWriter();
    $writer->openURI("fitzwilliam-{$project}.rdf");
    //$writer->openURI('php://output');
    $writer->startDocument('1.0', 'UTF-8');
    $writer->setIndent(true);
    //now we need to define our Indent string,which is basically how many blank spaces we want to have for the indent
    $writer->setIndentString("    ");
    $writer->startElement('rdf:RDF');
    $writer->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema#');
    $writer->writeAttribute('xmlns:nm', "http://nomisma.org/id/");
    $writer->writeAttribute('xmlns:nmo', "http://nomisma.org/ontology#");
    $writer->writeAttribute('xmlns:dcterms', "http://purl.org/dc/terms/");
    $writer->writeAttribute('xmlns:foaf', "http://xmlns.com/foaf/0.1/");
    $writer->writeAttribute('xmlns:geo', "http://www.w3.org/2003/01/geo/wgs84_pos#");
    $writer->writeAttribute('xmlns:rdf', "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
    $writer->writeAttribute('xmlns:void', "http://rdfs.org/ns/void#");
    foreach ($records as $record) {
        if (isset($record['cointype'])) {
            $writer->startElement('nmo:NumismaticObject');
            $writer->writeAttribute('rdf:about', $record['uri']);
            $writer->startElement('dcterms:title');
            $writer->writeAttribute('xml:lang', 'en');
            $writer->text($record['title']);
            $writer->endElement();
            $writer->writeElement('dcterms:identifier', $record['objectnumber']);
            $writer->startElement('dcterms:publisher');
            $writer->writeAttribute('rdf:resource', 'http://nomisma.org/id/fitzwilliam');
            $writer->endElement();
            $writer->startElement('nmo:hasCollection');
            $writer->writeAttribute('rdf:resource', 'http://nomisma.org/id/fitzwilliam');
            $writer->endElement();
            $writer->startElement('nmo:hasTypeSeriesItem');
            $writer->writeAttribute('rdf:resource', $record['cointype']);
            $writer->endElement();
            //conditional measurement data
            if (isset($record['weight'])) {
                $writer->startElement('nmo:hasWeight');
                $writer->writeAttribute('rdf:datatype', 'http://www.w3.org/2001/XMLSchema#decimal');
                $writer->text($record['weight']);
                $writer->endElement();
            }
            if (isset($record['axis'])) {
                $writer->startElement('nmo:hasAxis');
                $writer->writeAttribute('rdf:datatype', 'http://www.w3.org/2001/XMLSchema#integer');
                $writer->text($record['axis']);
                $writer->endElement();
            }
            //conditional images
            if (isset($record['obv_image'])) {
                $writer->startElement('nmo:hasObverse');
                $writer->startElement('rdf:Description');
                $writer->startElement('foaf:depiction');
                $writer->writeAttribute('rdf:resource', $record['obv_image']);
                $writer->endElement();
                $writer->endElement();
                $writer->endElement();
            }
            if (isset($record['rev_image'])) {
                $writer->startElement('nmo:hasReverse');
                $writer->startElement('rdf:Description');
                $writer->startElement('foaf:depiction');
                $writer->writeAttribute('rdf:resource', $record['rev_image']);
                $writer->endElement();
                $writer->endElement();
                $writer->endElement();
            }
            //void:inDataset
            $writer->startElement('void:inDataset');
            $writer->writeAttribute('rdf:resource', 'http://www.fitzmuseum.cam.ac.uk/');
            $writer->endElement();
            //end nmo:NumismaticObject
            $writer->endElement();
        }
    }
    //end RDF file
    $writer->endElement();
    $writer->flush();
}
<?php

require_once "sparqllib.php";
error_reporting(0);
$data = generate_json('bm-concordances.csv', false);
//use XML writer to generate RDF
$writer = new XMLWriter();
$writer->openURI("bm-price.rdf");
//$writer->openURI('php://output');
$writer->startDocument('1.0', 'UTF-8');
$writer->setIndent(true);
//now we need to define our Indent string,which is basically how many blank spaces we want to have for the indent
$writer->setIndentString("    ");
$writer->startElement('rdf:RDF');
$writer->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema#');
$writer->writeAttribute('xmlns:nm', "http://nomisma.org/id/");
$writer->writeAttribute('xmlns:nmo', "http://nomisma.org/ontology#");
$writer->writeAttribute('xmlns:dcterms', "http://purl.org/dc/terms/");
$writer->writeAttribute('xmlns:foaf', "http://xmlns.com/foaf/0.1/");
$writer->writeAttribute('xmlns:rdf', "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
$writer->writeAttribute('xmlns:void', "http://rdfs.org/ns/void#");
$count = 1;
foreach ($data as $row) {
    $pieces = explode('/', $row['uri']);
    $id = $pieces[5];
    echo "Processing {$count}: {$id}\n";
    if (strlen($row['coinType']) > 0) {
        $writer->startElement('nmo:NumismaticObject');
        $writer->writeAttribute('rdf:about', $row['uri']);
        $writer->startElement('dcterms:title');
        $writer->writeAttribute('xml:lang', 'en');
 /**
  * Generate inclusion file
  *
  * @param string $tmpPath Temporary path
  */
 protected static function generateInclusionFile($tmpPath)
 {
     static $generated = false;
     /* We'll generate only once and for all */
     if (false === $generated) {
         $generated = true;
         /* Retrieve active pollers */
         $db = Di::getDefault()->get('db_centreon');
         $sql = "SELECT poller.poller_id, directory_config\n                FROM cfg_pollers poller, cfg_centreonbroker_paths paths \n                WHERE poller.poller_id = paths.poller_id \n                AND poller.enable = 1";
         $stmt = $db->prepare($sql);
         $stmt->execute();
         $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
         $pollers = $rows;
         foreach ($rows as $row) {
             if (!is_dir("{$tmpPath}/{$row['poller_id']}")) {
                 mkdir("{$tmpPath}/{$row['poller_id']}");
             }
             /* @todo: replace hardcoded "correlation.xml" with value from template */
             $correlationFile = rtrim($tmpPath, '/') . '/' . $row['poller_id'] . '/correlation.xml';
             $xml = new \XMLWriter();
             if (false === @$xml->openURI($correlationFile)) {
                 throw new Exception(sprintf('Error while opening %s', $correlationFile));
             }
             $xml->startDocument('1.0', 'UTF-8');
             $xml->startElement('conf');
             /* includes */
             foreach ($pollers as $poller) {
                 $tmpFile = rtrim($tmpPath, '/') . '/' . $row['poller_id'] . '/correlation_' . $row['poller_id'] . '.xml';
                 $file = rtrim($row['directory_config'], '/') . "/correlation_" . $row['poller_id'] . ".xml";
                 if (is_file($tmpFile)) {
                     $xml->writeElement('include', $file);
                 }
             }
             $xml->endElement();
             $xml->endDocument();
         }
     }
 }
    array(
        'region_cond' => ' (l_geo_city="Санкт-Петербург" OR r.Name="Ленинградская область") ',
        'file_name' => 'context_rk_realty_spb.xml'
    ),
    array(
        'region_cond' => ' (l_geo_city<>"Москва" AND r.Name<>"Московская область" AND l_geo_city<>"Санкт-Петербург" AND r.Name<>"Ленинградская область") ',
        'file_name' => 'context_rk_realty_other.xml'
    )
);*/
$regions = array('msk' => array('condition' => 'l_geo_city="Москва"', 'metro' => true, 'suburb' => true), 'spb' => array('condition' => 'l_geo_city="Санкт-Петербург"', 'metro' => true, 'suburb' => true), 'other' => array('condition' => '', 'metro' => false, 'suburb' => false));
foreach ($regions as $region_arr) {
    echo "\nFilling " . $region_arr['file_name'];
    $sql = "\n            SELECT\n                IF(l_deal_type = 1,'продажа','аренда') as dealType,\n                l_assetType as assetType,\n                r.Name as region,\n                l_geo_city as geo,\n                l_rooms as rooms,\n                COUNT(*) as num,\n                SUM(IF(cmp_rank IS NULL,0,1)) as promoted,\n                IF((SUM(IF(cmp_rank IS NULL,0,1)) / COUNT(*)) > 0.6,'true','false') as flag,\n                CONCAT(\n                    'http://',l_geo_city,'.pingola.ru/realty/',\n                    IF(l_deal_type = 1,'sale','rent'),\n                    CONCAT('/',REPLACE(l_assetType,'/','_'),'/'),\n                    IF(CAST(l_rooms as SIGNED) <> 0,CONCAT('?rooms=',CAST(l_rooms as SIGNED)),'')\n                ) as link\n            FROM ru_eyezeek.realestate v\n                LEFT JOIN ru_eyezeek.promoted_realestate p ON v.l_id=p.o_l_id\n                LEFT JOIN ru_geo.Region r ON v.l_geo_region_id=r.ID\n            WHERE l_isactive=1 AND l_assetType IN ('" . implode("', '", array_keys($l_aCategories)) . "') AND l_geo_city<>'' AND l_www_id<>123\n                AND " . $region_arr['region_cond'] . "\n            GROUP BY l_deal_type,l_assetType,l_geo_city,l_rooms\n            ORDER BY num DESC LIMIT 10000";
    if ($result = $mysqli->query($sql)) {
        $writer = new XMLWriter();
        $writer->openURI($file_path . $region_arr['file_name']);
        $writer->startDocument('1.0', 'UTF-8');
        $writer->setIndent(TRUE);
        $writer->startElement('root');
        $writer->writeElement('creation-date', date("d/m/y : H:i:s", time()));
        while ($arr = $result->fetch_assoc()) {
            if (!in_array(mb_strtolower($arr['geo'], 'UTF-8'), $cities)) {
                continue;
            }
            if (empty($arr['region'])) {
                $sql = 'SELECT r.Name as region FROM ru_geo.City c JOIN ru_geo.Region r ON c.Region=r.ID WHERE c.Name="' . $arr['geo'] . '"';
                $res = $mysqli->query($sql);
                if ($res === FALSE) {
                    continue;
                }
                $arrr = $res->fetch_assoc();
Exemple #29
0
 /**
  * Writes Google sitemap index for generated sitemap files
  *
  * @param string $loc Accessible URL path of sitemaps
  * @param string|int $lastmod The date of last modification of sitemap. Unix timestamp or any English textual datetime description.
  */
 public function createSitemapIndex($loc, $lastmod = 'Today')
 {
     $this->endSitemap();
     $indexwriter = new XMLWriter();
     $indexwriter->openURI($this->getPath() . $this->getFilename() . self::SEPERATOR . self::INDEX_SUFFIX . self::EXT);
     $indexwriter->startDocument('1.0', 'UTF-8');
     $indexwriter->setIndent(true);
     $indexwriter->startElement('sitemapindex');
     $indexwriter->writeAttribute('xmlns', self::SCHEMA);
     for ($index = 0; $index < $this->getCurrentSitemap(); $index++) {
         $indexwriter->startElement('sitemap');
         $indexwriter->writeElement('loc', $loc . $this->getFilename() . self::SEPERATOR . $index . self::EXT);
         $indexwriter->writeElement('lastmod', $this->getLastModifiedDate($lastmod));
         $indexwriter->endElement();
     }
     $indexwriter->endElement();
     $indexwriter->endDocument();
 }
 public function settingsAction($path)
 {
     require_once 'models/table/System.php';
     $sysTable = new System();
     @date_default_timezone_set("GMT");
     $settingsWriter = new XMLWriter();
     // Output directly to the user
     $settingsWriter->openURI($path . 'Settings.xml');
     $settingsWriter->startDocument('1.0');
     $settingsWriter->setIndent(4);
     $settingsWriter->startElement('system');
     $settingsWriter->writeAttribute('version', '1.0');
     $settingsWriter->writeAttribute('password', 'mango');
     $sysTable->select('*');
     $row = $sysTable->fetchRow();
     foreach ($row->toArray() as $k => $v) {
         $settingsWriter->writeAttribute($k, $v);
     }
     $option_tables = array('translation');
     foreach ($option_tables as $opt) {
         $settingsWriter->startElement(str_replace('_option', '', $opt));
         $optTable = new OptionList(array('name' => $opt));
         $optTable->select('*');
         foreach ($optTable->fetchAll() as $row) {
             $settingsWriter->startElement('add');
             foreach ($row->toArray() as $k => $v) {
                 if ($k == 'id') {
                     $settingsWriter->writeAttribute('key', $v);
                 } else {
                     if (strpos($k, '_phrase')) {
                         $settingsWriter->writeAttribute('value', $v);
                     } else {
                         $settingsWriter->writeAttribute($k, $v);
                     }
                 }
             }
             $settingsWriter->endElement();
         }
         $settingsWriter->endElement();
     }
     // End Item
     $settingsWriter->endElement();
 }