Пример #1
0
    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;
        }
    }
Пример #2
0
    /**
     * @todo document this
     */
    function action_skinedittype($msg = '')
    {
        global $member, $manager;
        $skinid = intRequestVar('skinid');
        $type = requestVar('type');
        $member->isAdmin() or $this->disallow();
        $type = trim($type);
        $type = strtolower($type);
        if (!isValidShortName($type)) {
            $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
        }
        $skin =& new SKIN($skinid);
        $friendlyNames = SKIN::getFriendlyNames();
        $this->pagehead();
        ?>
		<p>(<a href="index.php?action=skinoverview"><?php 
        echo _SKIN_GOBACK;
        ?>
</a>)</p>

		<h2><?php 
        echo _SKIN_EDITPART_TITLE;
        ?>
 '<?php 
        echo htmlspecialchars($skin->getName());
        ?>
': <?php 
        echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type));
        ?>
</h2>

		<?php 
        if ($msg) {
            echo "<p>" . _MESSAGE . ": {$msg}</p>";
        }
        ?>

		<div style="width:100%;">
		<form method="post" action="index.php">
		<div>

		<input type="hidden" name="action" value="skinupdate" />
		<?php 
        $manager->addTicketHidden();
        ?>
		<input type="hidden" name="skinid" value="<?php 
        echo $skinid;
        ?>
" />
		<input type="hidden" name="type" value="<?php 
        echo $type;
        ?>
" />

		<input type="submit" value="<?php 
        echo _SKIN_UPDATE_BTN;
        ?>
" onclick="return checkSubmit();" />
		<input type="reset" value="<?php 
        echo _SKIN_RESET_BTN;
        ?>
" />
		(skin type: <?php 
        echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type));
        ?>
)
		<?php 
        if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
            help('skinpart' . $type);
        } else {
            help('skinpartspecial');
        }
        ?>
		<br />

		<textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php 
        echo htmlspecialchars($skin->getContent($type));
        ?>
</textarea>

		<br />
		<input type="submit" tabindex="20" value="<?php 
        echo _SKIN_UPDATE_BTN;
        ?>
" onclick="return checkSubmit();" />
		<input type="reset" value="<?php 
        echo _SKIN_RESET_BTN;
        ?>
" />
		(skin type: <?php 
        echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type));
        ?>
)

		<br /><br />
		<?php 
        echo _SKIN_ALLOWEDVARS;
        ?>
		<?php 
        $actions = SKIN::getAllowedActionsForType($type);
        sort($actions);
        while ($current = array_shift($actions)) {
            // skip deprecated vars
            if ($current == 'ifcat') {
                continue;
            }
            if ($current == 'imagetext') {
                continue;
            }
            if ($current == 'vars') {
                continue;
            }
            echo helplink('skinvar-' . $current) . "{$current}</a>";
            if (count($actions) != 0) {
                echo ", ";
            }
        }
        echo '<br /><br />' . _SKINEDIT_ALLOWEDBLOGS;
        $query = 'SELECT bshortname, bname FROM ' . sql_table('blog');
        showlist($query, 'table', array('content' => 'shortblognames'));
        echo '<br />' . _SKINEDIT_ALLOWEDTEMPLATESS;
        $query = 'SELECT tdname as name, tddesc as description FROM ' . sql_table('template_desc');
        showlist($query, 'table', array('content' => 'shortnames'));
        echo '</div></form></div>';
        $this->pagefoot();
    }
Пример #3
0
function parseFile($filename, $includeMode = 'normal', $includePrefix = '')
{
    $handler = new ACTIONS('fileparser');
    $parser = new PARSER(SKIN::getAllowedActionsForType('fileparser'), $handler);
    $handler->parser =& $parser;
    // set IncludeMode properties of parser
    PARSER::setProperty('IncludeMode', $includeMode);
    PARSER::setProperty('IncludePrefix', $includePrefix);
    if (!file_exists($filename)) {
        doError(_GFUNCTIONS_PARSEFILE_FILEMISSING);
    }
    $fsize = filesize($filename);
    if ($fsize <= 0) {
        return;
    }
    // read file
    $fd = fopen($filename, 'r');
    $contents = fread($fd, $fsize);
    fclose($fd);
    // parse file contents
    $parser->parse($contents);
}