/** * Outputs the XML contents of the export file * * @param $setHeaders * set to 0 if you don't want to send out headers * (optional, default 1) */ function export($setHeaders = 1) { if ($setHeaders) { // make sure the mimetype is correct, and that the data does not show up // in the browser, but gets saved into and XML file (popup download window) header('Content-Type: text/xml'); header('Content-Disposition: attachment; filename="skinbackup.xml"'); header('Expires: 0'); header('Pragma: no-cache'); } echo "<nucleusskin>\n"; // meta echo "\t<meta>\n"; // skins foreach ($this->skins as $skinId => $skinName) { $skinName = htmlspecialchars($skinName, ENT_QUOTES); if (strtoupper(_CHARSET) != 'UTF-8') { $skinName = mb_convert_encoding($skinName, 'UTF-8', _CHARSET); } echo "\t\t" . '<skin name="' . htmlspecialchars($skinName, ENT_QUOTES) . '" />' . "\n"; } // templates foreach ($this->templates as $templateId => $templateName) { $templateName = htmlspecialchars($templateName, ENT_QUOTES); if (strtoupper(_CHARSET) != 'UTF-8') { $templateName = mb_convert_encoding($templateName, 'UTF-8', _CHARSET); } echo "\t\t" . '<template name="' . htmlspecialchars($templateName, ENT_QUOTES) . '" />' . "\n"; } // extra info if ($this->info) { if (strtoupper(_CHARSET) != 'UTF-8') { $skin_info = mb_convert_encoding($this->info, 'UTF-8', _CHARSET); } else { $skin_info = $this->info; } echo "\t\t<info><![CDATA[" . $skin_info . "]]></info>\n"; } echo "\t</meta>\n\n\n"; // contents skins foreach ($this->skins as $skinId => $skinName) { $skinId = intval($skinId); $skinObj = new SKIN($skinId); $skinName = htmlspecialchars($skinName, ENT_QUOTES); $contentT = htmlspecialchars($skinObj->getContentType(), ENT_QUOTES); $incMode = htmlspecialchars($skinObj->getIncludeMode(), ENT_QUOTES); $incPrefx = htmlspecialchars($skinObj->getIncludePrefix(), ENT_QUOTES); $skinDesc = htmlspecialchars($skinObj->getDescription(), ENT_QUOTES); if (strtoupper(_CHARSET) != 'UTF-8') { $skinName = mb_convert_encoding($skinName, 'UTF-8', _CHARSET); $contentT = mb_convert_encoding($contentT, 'UTF-8', _CHARSET); $incMode = mb_convert_encoding($incMode, 'UTF-8', _CHARSET); $incPrefx = mb_convert_encoding($incPrefx, 'UTF-8', _CHARSET); $skinDesc = mb_convert_encoding($skinDesc, 'UTF-8', _CHARSET); } echo "\t" . '<skin name="' . $skinName . '" type="' . $contentT . '" includeMode="' . $incMode . '" includePrefix="' . $incPrefx . '">' . "\n"; echo "\t\t" . '<description>' . $skinDesc . '</description>' . "\n"; $que = 'SELECT' . ' stype,' . ' scontent ' . 'FROM ' . sql_table('skin') . ' WHERE' . ' sdesc = ' . $skinId; $res = sql_query($que); while ($partObj = sql_fetch_object($res)) { $type = htmlspecialchars($partObj->stype, ENT_QUOTES); $cdata = $this->escapeCDATA($partObj->scontent); if (strtoupper(_CHARSET) != 'UTF-8') { $type = mb_convert_encoding($type, 'UTF-8', _CHARSET); $cdata = mb_convert_encoding($cdata, 'UTF-8', _CHARSET); } echo "\t\t" . '<part name="' . $type . '">'; echo '<![CDATA[' . $cdata . ']]>'; echo "</part>\n\n"; } echo "\t</skin>\n\n\n"; } // contents templates foreach ($this->templates as $templateId => $templateName) { $templateId = intval($templateId); $templateName = htmlspecialchars($templateName, ENT_QUOTES); $templateDesc = htmlspecialchars(TEMPLATE::getDesc($templateId), ENT_QUOTES); if (strtoupper(_CHARSET) != 'UTF-8') { $templateName = mb_convert_encoding($templateName, 'UTF-8', _CHARSET); $templateDesc = mb_convert_encoding($templateDesc, 'UTF-8', _CHARSET); } echo "\t" . '<template name="' . $templateName . '">' . "\n"; echo "\t\t" . '<description>' . $templateDesc . "</description>\n"; $que = 'SELECT' . ' tpartname,' . ' tcontent' . ' FROM ' . sql_table('template') . ' WHERE' . ' tdesc = ' . $templateId; $res = sql_query($que); while ($partObj = sql_fetch_object($res)) { $type = htmlspecialchars($partObj->tpartname, ENT_QUOTES); $cdata = $this->escapeCDATA($partObj->tcontent); if (strtoupper(_CHARSET) != 'UTF-8') { $type = mb_convert_encoding($type, 'UTF-8', _CHARSET); $cdata = mb_convert_encoding($cdata, 'UTF-8', _CHARSET); } echo "\t\t" . '<part name="' . $type . '">'; echo '<![CDATA[' . $cdata . ']]>'; echo '</part>' . "\n\n"; } echo "\t</template>\n\n\n"; } echo '</nucleusskin>'; }
function event_InitSkinParse($data) { global $blogid, $CONF, $manager; $feedurl = array('rss1.xml', 'index.rdf', 'rss2.xml', 'atom.xml'); $reqPaths = explode('/', serverVar('PATH_INFO')); $reqPath = end($reqPaths); $feeds = in_array($reqPath, $feedurl, true); if (!$feeds) { return; } else { $p_info = trim(serverVar('PATH_INFO'), '/'); $path_arr = explode('/', $p_info); switch (end($path_arr)) { case 'rss1.xml': case 'index.rdf': $skinName = 'feeds/rss10'; break; case 'rss2.xml': $skinName = 'feeds/rss20'; break; case 'atom.xml': $skinName = 'feeds/atom'; break; } if (SKIN::exists($skinName)) { $skin =& SKIN::createFromName($skinName); $data['skin']->SKIN($skin->getID()); $skinData =& $data['skin']; $pageType = $data['type']; if (!$CONF['DisableSite']) { ob_start(); $skinID = $skinData->id; $contents = $this->getSkinContent($pageType, $skinID); $actions = SKIN::getAllowedActionsForType($pageType); $dataArray = array('skin' => &$skinData, 'type' => $pageType, 'contents' => &$contents); $manager->notify('PreSkinParse', $dataArray); PARSER::setProperty('IncludeMode', SKIN::getIncludeMode()); PARSER::setProperty('IncludePrefix', SKIN::getIncludePrefix()); $handler = new ACTIONS($pageType, $skinData); $parser = new PARSER($actions, $handler); $handler->setParser($parser); $handler->setSkin($skinData); $parser->parse($contents); $dataArray = array('skin' => &$skinData, 'type' => $pageType); $manager->notify('PostSkinParse', $dataArray); $feed = ob_get_contents(); ob_end_clean(); $eTag = '"' . md5($feed) . '"'; header('Etag: ' . $eTag); if ($eTag == serverVar('HTTP_IF_NONE_MATCH')) { header('HTTP/1.0 304 Not Modified'); header('Content-Length: 0'); } else { if (extension_loaded('mbstring')) { $feed = mb_convert_encoding($feed, 'UTF-8', _CHARSET); $charset = 'UTF-8'; } else { $charset = _CHARSET; } header('Content-Type: application/xml; charset=' . $charset); header('Generator: Nucleus CMS ' . $nucleus['version']); // dump feed echo $feed; } } else { echo '<' . '?xml version="1.0" encoding="ISO-8859-1"?' . '>'; ?> <rss version="2.0"> <channel> <title><?php echo $this->hsc($CONF['SiteName'], ENT_QUOTES); ?> </title> <link><?php echo $this->hsc($CONF['IndexURL'], ENT_QUOTES); ?> </link> <description></description> <docs>http://backend.userland.com/rss</docs> </channel> </rss> <?php } } exit; } }