Exemple #1
0
 function emailResetPassword()
 {
     #now email them their password
     $this->load->library('email');
     $this->email->to($_POST['email']);
     $this->email->from("*****@*****.**", 'Gob');
     $this->email->subject('Your password reset request');
     $this->email->message("Hello " . $_POST['username'] . "!\n\r You or someone posing as you has requested your account's password be changed. This request came from " . $_SERVER['REMOTE_ADDR'] . " at " . date("D M j G:i:s T Y") . '. If this happens a lot, please contact the admins. Otherwise, click on the following link to reset your password: \\n ' . site_url() . "/login/passwordReset/" . encodeText($_POST['username']) . "/" . encodeText($_POST['email']) . "/" . randomTextGenerate());
     $this->email->send();
     echo $this->email->print_debugger();
     redirect(site_url() . "/login", "refresh");
 }
                echo "          <title>{'How do I' from language file}</title>\r\n";
                echo "          <para>" . encodeText($q_howdoi) . "</para>\r\n";
                echo "        </note>\r\n";
            }
            if (!empty($q_diduno)) {
                echo "        <note Conformance=\"diduno\">\r\n";
                echo "          <title>{'Did you know' from language file}</title>\r\n";
                echo "          <para>" . encodeText($q_diduno) . "</para>\r\n";
                echo "        </note>\r\n";
            }
            echo "      </question>\r\n";
            $resultA = $xoopsDB->query("select * from " . $xoopsDB->prefix("smartsection_answers") . " where answerid={$q_answerid}");
            while ($arrA = $xoopsDB->fetchArray($resultA)) {
                extract($arrA, EXTR_PREFIX_ALL, 'a');
                echo "      <answer ID=\"a{$a_answerid}\" Revision=\"{$a_datesub}\" Vendor=\"" . getUserFullName($a_uid) . "\">\r\n";
                echo "        <para>" . encodeText($a_answer) . "</para>\r\n";
                echo "      </answer>\r\n";
            }
            mysql_free_result($resultA);
            echo "    </qandaentry>\r\n";
        }
        mysql_free_result($resultQ);
        echo "  </qandadiv>\r\n";
    }
    echo "</qandaset>\r\n";
    exit;
}
function encodeText($text)
{
    return utf8_encode(htmlspecialchars($text));
}
Exemple #3
0
                    if ($program_time < $starttime) {
                    } else {
                        if ($program_time >= $starttime && $program_time < $endtime) {
                            $date["programs"][0]["program"][] = array("pid" => $pid, "time" => date('H:i', $program_time), "name" => encodeText($row_program["title"]), "contents" => encodeText($row_program["contents"]));
                        } else {
                            break;
                        }
                    }
                    $row_program = mysql_fetch_array($result_program, MYSQL_ASSOC);
                }
                $starttime += 3600 * 24;
                $channel["date"][] = $date;
            }
            // next program
            while ($row_program) {
                $program_time = strtotime($row_program["program_time"]);
                $pid = number_format($program_time * 1000 / $row["piecelength"], 0, '', '');
                $channel["programs"][0]["program"][] = array("pid" => $pid, "time" => date('Y-m-d H:i', $program_time), "name" => encodeText($row_program["title"]), "contents" => encodeText($row_program["contents"]));
                $row_program = mysql_fetch_array($result_program, MYSQL_ASSOC);
            }
            mysql_free_result($result_program);
        }
        $xml["channel"][] = $channel;
    }
    mysql_free_result($result);
    closeDB($conn);
    header('Content-Type: text/xml; charset=utf-8');
    $data = printXML("result", $xml);
    $data = gzcompress($data);
    echo $data;
}
        }
    }
    $opentag .= ">";
    return $opentag . $children . $closetag;
}
if ($_REQUEST["verb"] == "current") {
    $macid = $_REQUEST["macid"];
    $channels = $_REQUEST["channels"];
    if (substr($channels, strlen($channels) - 1) == ',') {
        $channels = substr($channels, 0, strlen($channels) - 1);
    }
    $arrchs = explode(",", $channels);
    $channels = '"' . implode('","', $arrchs) . '"';
    $conn = connectDB();
    $xml = array("nowtime" => time(), "channel" => array());
    foreach ($arrchs as $hashid) {
        $channel = array();
        $channel["id"] = $hashid;
        $result = getGuideByChannelHashId($conn, $hashid);
        while ($row_program = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $channel["programs"][0]["program"][] = array("program_time" => $row_program['program_time'], "title" => encodeText($row_program["title"]));
        }
        $xml["channel"][] = $channel;
        mysql_free_result($result);
    }
    closeDB($conn);
    header('Content-Type: text/xml; charset=utf-8');
    $data = printXML("channels", $xml);
    $data = gzcompress($data);
    echo $data;
}
/**
 * Inserts previously filled fields for commenting. They can come from either
 * a previous submit (when previewing, or when an error in the form occurred)
 * or from the cookie.
 *
 * @param array $params
 * @param object $smarty
 * @return string
 */
function smarty_remember($params, &$smarty)
{
    global $PIVOTX, $temp_comment;
    static $default_values;
    $params = cleanParams($params);
    $name = $params['name'];
    // Only calculate previous fields once
    if (!is_array($default_values)) {
        $default_values = array();
        // Get the cookies in an array.. (Why aren't we just using $_COOKIE?)
        if (isset($_SERVER['HTTP_COOKIE'])) {
            foreach (explode(";", $_SERVER['HTTP_COOKIE']) as $cookie) {
                list($key, $value) = explode("=", $cookie);
                $default_values[trim($key)] = urldecode(trim($value));
            }
        }
        if (!empty($temp_comment) && is_array($temp_comment)) {
            $default_values = $temp_comment;
        } else {
            if (!empty($_COOKIE['pivotxcomment'])) {
                $cookie = explode('|', $_COOKIE['pivotxcomment']);
                $default_values['name'] = $cookie[0];
                $default_values['email'] = $cookie[1];
                $default_values['url'] = $cookie[2];
                $default_values['reguser'] = $cookie[3];
                $default_values['notify'] = $cookie[4];
                $default_values['discreet'] = $cookie[5];
                $default_values['rememberinfo'] = 1;
            } else {
                // Check if this is a logged in registered visitor
                require_once $PIVOTX['paths']['pivotx_path'] . 'modules/module_userreg.php';
                $visitors = new Visitors();
                if ($visitor = $visitors->isLoggedIn()) {
                    $default_values['name'] = $visitor['name'];
                    $default_values['email'] = $visitor['email'];
                    $default_values['url'] = $visitor['url'];
                    $default_values['notify'] = $visitor['notify_default'];
                    $default_values['discreet'] = 1 - $visitor['show_address'];
                }
            }
        }
        // Posted values should override cookies since they are newer.
        // (The corresponding posted keys start with "piv_".)
        foreach ($_POST as $key => $value) {
            if (substr($key, 0, 4) == 'piv_') {
                $default_values[substr($key, 4)] = urldecode(trim($value));
            }
        }
        // Execute hooks, if present, and (potentially) override existing values.
        $hookname = "remember";
        $hook_values = $PIVOTX['extensions']->executeHook('template', $hookname, $default_values);
        if (is_array($hook_values)) {
            $default_values = $hook_values;
        }
    }
    switch ($name) {
        case 'all':
            echo "<h1>koekies</h1><pre>cookies:";
            print_r($_COOKIE);
            echo "</pre>";
            break;
        case 'name':
            return !empty($default_values['name']) ? encodeText($default_values['name']) : "";
            break;
        case 'email':
            return !empty($default_values['email']) ? encodeText($default_values['email']) : "";
            break;
        case 'url':
            return !empty($default_values['url']) ? encodeText($default_values['url']) : "";
            break;
        case 'comment':
            return !empty($default_values['comment']) ? $default_values['comment'] : "";
            break;
        case 'rememberinfo':
            return !empty($default_values['rememberinfo']) ? "checked='checked'" : "";
            break;
        case 'notify':
            return !empty($default_values['notify']) ? "checked='checked'" : "";
            break;
        case 'discreet':
            return !empty($default_values['discreet']) ? "checked='checked'" : "";
            break;
        case 'reguser':
            return !empty($default_values['piv_reguser']) ? $default_values['piv_reguser'] : "";
            break;
    }
}
/**
 * Enter description here...
 *
 */
function handlePostComment()
{
    global $weblogmessage, $PIVOTX, $temp_comment;
    $entry = $PIVOTX['db']->read_entry($_POST['piv_code']);
    // Check if we're allowed to comment on this entry. 'isset' is needed, because old entries
    // might not have 'allow comments' set to either choice.
    if (isset($entry['allow_comments']) && $entry['allow_comments'] == 0) {
        echo "Spam is not appreciated.";
        logspammer($_POST['piv_comment'], "closedcomments");
        die;
    }
    // execute a hook here before a comment is processed
    $PIVOTX['extensions']->executeHook('comment_before_processing', $entry);
    $registered = 0;
    // check if the current poster is a (logged in) registered visitor.
    require_once $PIVOTX['paths']['pivotx_path'] . 'modules/module_userreg.php';
    $visitors = new Visitors();
    if ($visitor = $visitors->isLoggedIn()) {
        if ($visitor['name'] == $_POST['piv_name']) {
            $registered = 1;
        }
    }
    // Strip out HTML from input..
    $_POST['piv_name'] = strip_tags($_POST['piv_name']);
    $_POST['piv_email'] = strip_tags($_POST['piv_email']);
    $_POST['piv_url'] = strip_tags($_POST['piv_url']);
    if ($PIVOTX['config']->get('allow_html_in_comments') == 1) {
        $_POST['piv_comment'] = stripTagsAttributes($_POST['piv_comment'], "*");
    } else {
        $_POST['piv_comment'] = stripTagsAttributes($_POST['piv_comment'], "<b><em><i><strong>");
    }
    // Do some more processing on the comment itself: trimming, standardizing line-breaks.
    $comment_text = stripTrailingSpace($_POST['piv_comment']);
    $comment_text = str_replace("\r\n", "\n", $comment_text);
    // CRLF(Win) to LF
    $comment_text = str_replace("\r", "\n", $comment_text);
    // CR(Mac) to LF
    $temp_comment = array('entry_uid' => intval($_POST['piv_code']), 'name' => encodeText($_POST['piv_name']), 'email' => encodeText($_POST['piv_email']), 'url' => encodeText($_POST['piv_url']), 'ip' => $_SERVER['REMOTE_ADDR'], 'useragent' => $_SERVER['HTTP_USER_AGENT'], 'date' => formatDate("", "%year%-%month%-%day%-%hour24%-%minute%"), 'comment' => $comment_text, 'registered' => $registered, 'notify' => intval($_POST['piv_notify']), 'discreet' => intval($_POST['piv_discreet']), 'rememberinfo' => intval($_POST['piv_rememberinfo']), 'moderate' => $PIVOTX['config']->get('moderate_comments'), 'spamscore' => 0);
    if ($temp_comment['rememberinfo'] == 1) {
        rememberCommentInfo($temp_comment);
    }
    //here we do a check to prevent double entries...
    $duplicate = FALSE;
    if (isset($entry['comments']) && count($entry['comments']) > 0) {
        foreach ($entry['comments'] as $loop_comment) {
            $diff = 1 / (min(strlen($loop_comment['comment']), 200) / (levenshtein(substr($loop_comment['comment'], 0, 200), substr($temp_comment['comment'], 0, 200)) + 1));
            if ($diff < 0.25 && $loop_comment['ip'] == $temp_comment['ip']) {
                $duplicate = TRUE;
                break;
            }
        }
    }
    // Check for Hashcash violations..
    if ($PIVOTX['config']->get('hashcash') == 1 && !hashcash_check_hidden_tag()) {
        $weblogmessage = getDefault($PIVOTX['config']->get('hashcash_message'), __('The Hashcash code was not valid, so this comment could not be posted. If you believe this is an error, please make sure you have a modern browser, and that Javascript is enabled. If it still doesn\'t work, contact the maintainer of this website.'));
        unset($_POST['post']);
        $_POST['preview'] = true;
        $spammessage = substr(implode(", ", $temp_comment), 0, 250);
        logspammer($_SERVER["REMOTE_ADDR"], "hashcash", "pom pom pom", $spammessage);
    }
    // Check for SpamQuiz violations, but not when previewing..
    if ($PIVOTX['config']->get('spamquiz') == 1 && !isset($_POST['preview'])) {
        // Is the entry old enough?
        $entryDate = substr($PIVOTX['db']->entry['date'], 0, 10);
        $then = strtotime($entryDate);
        $secsPerDay = 60 * 60 * 24;
        $now = strtotime('now');
        $diff = $now - $then;
        $dayDiff = $diff / $secsPerDay;
        $numDaysOld = (int) $dayDiff;
        if ($numDaysOld > $PIVOTX['config']->get("spamquiz_age")) {
            if (strtolower($_POST['spamquiz_answer']) != strtolower($PIVOTX['config']->get("spamquiz_answer"))) {
                $weblogmessage = __('The Spamquiz answer was not correct, so this comment could not be posted. If you believe this is an error, please try again. If it still doesn\'t work, contact the maintainer of this website.');
                unset($_POST['post']);
                $_POST['preview'] = true;
                logspammer($_SERVER["REMOTE_ADDR"], "spamquiz");
            } else {
                // Store the correct answer in a cookie.
                $sess = $PIVOTX['session'];
                setcookie("spamquiz_answer", $_POST["spamquiz_answer"], time() + $sess->cookie_lifespan, $sess->cookie_path, $sess->cookie_domain);
            }
        }
    }
    // set the message and take proper action:
    if (isset($_POST['preview'])) {
        // Add a 'show in preview' flag to $temp_comment, otherwise it would be suppressed on display
        $temp_comment['showpreview'] = 1;
        // update the current entry
        $entry['comments'][] = $temp_comment;
        if (empty($weblogmessage)) {
            $weblogmessage = __('You are previewing your comment. Be sure to click on "Post Comment" to store it.');
        }
        unset($_POST['post']);
        $_POST['preview'] = TRUE;
    } else {
        if ($temp_comment['spamscore'] > $PIVOTX['config']->get('spamthreshold')) {
            // Add a 'show in preview' flag to $temp_comment, otherwise it would be suppressed on display
            $temp_comment['showpreview'] = 1;
            $weblogmessage = __('Your comment has not been stored, because it seems to be spam.');
            unset($_POST['post']);
            $_POST['preview'] = TRUE;
        } else {
            if ($duplicate) {
                $temp_comment['duplicate'] = true;
                // Add a 'show in preview' flag to $temp_comment, otherwise it would be suppressed on display
                $temp_comment['showpreview'] = 1;
                $weblogmessage = __('Your comment has not been stored, because it seems to be a duplicate of a previous entry.');
                unset($_POST['post']);
                $_POST['preview'] = TRUE;
            } else {
                if ($PIVOTX['config']->get('moderate_comments') == 1) {
                    // update the current entry
                    $entry['comments'][] = $temp_comment;
                    $weblogmessage = __('Your comment has been stored. Because comment moderation is enabled, it is now waiting for approval by an editor.');
                    $_POST['post'] = TRUE;
                } else {
                    // update the current entry
                    $entry['comments'][] = $temp_comment;
                    $weblogmessage = __('Your comment has been stored.');
                    $_POST['post'] = TRUE;
                }
            }
        }
    }
    // if comment or name is missing, give a notice, and show the form again..
    if (strlen($temp_comment['name']) < 2) {
        $weblogmessage = __('You should type your name (or an alias) in the "name"-field. Be sure to click on "Post Comment" to store it permanently.');
        unset($_POST['post']);
        $_POST['preview'] = TRUE;
    }
    if (strlen($temp_comment['comment']) < 3) {
        $weblogmessage = __('You should type something in the "comment"-field. Be sure to click on "Post Comment" to store it permanently.');
        unset($_POST['post']);
        $_POST['preview'] = TRUE;
    }
    if ($PIVOTX['config']->get('maxhrefs') > 0) {
        $low_comment = strtolower($temp_comment['comment']);
        $low_comment_formatted = strtolower(commentFormat($temp_comment['comment']));
        if (substr_count($low_comment, "href=") > $PIVOTX['config']->get('maxhrefs') || substr_count($low_comment_formatted, "href=") > $PIVOTX['config']->get('maxhrefs')) {
            $weblogmessage = __('The maximum number of hyperlinks was exceeded. Stop spamming.');
            unset($_POST['post']);
            $_POST['preview'] = TRUE;
        }
    }
    // execute a hook here after a comment is processed but before that comment is saved
    $PIVOTX['extensions']->executeHook('comment_before_save', $entry);
    if (isset($_POST['post'])) {
        $PIVOTX['db']->set_entry($entry);
        $PIVOTX['db']->save_entry(FALSE);
        // do not update the index.
        // Remove the compiled/parsed pages from the cache.
        if ($PIVOTX['config']->get('smarty_cache')) {
            $PIVOTX['template']->clear_cache();
        }
        //update the 'latest comments' file
        if (isset($temp_comment)) {
            if ($PIVOTX['config']->get('moderate_comments') != 1) {
                generateLatestComments($temp_comment);
                debug("comment from '" . $_POST['piv_name'] . "' added.");
            } else {
                generateModerationQueue($temp_comment);
                debug("comment from '" . $_POST['piv_name'] . "' added to moderation queue.");
            }
        }
        // Handle the users that want to be notified via email..
        if ($PIVOTX['config']->get('dont_send_mail_notification') != 1) {
            $notifications = sendMailNotification('comment', array($PIVOTX['db']->entry, $temp_comment, $PIVOTX['config']->get('moderate_comments')));
        }
        // send mail..
        sendMailComment($temp_comment, $notifications);
        // Don't display the 'preview' of the comment after posting.
        $temp_comment = array();
        unset($_POST);
        // Clean the simple cache..
        $PIVOTX['cache']->clear();
        // Remove the compiled/parsed pages from the cache.
        if ($PIVOTX['config']->get('smarty_cache')) {
            $PIVOTX['template']->clear_cache();
        }
        // Redirect to the entrypage from which we came. (prevents reload-resubmit)
        $uri = $_SERVER['REQUEST_URI'];
        if (strpos($uri, "?") > 0) {
            $uri .= "&weblogmessage=" . urlencode($weblogmessage);
        } else {
            $uri .= "?weblogmessage=" . urlencode($weblogmessage);
        }
        header('Location: ' . $uri);
        exit;
    }
    // Set the 'you are previewing' message..
    if (isset($_POST['preview']) && empty($weblogmessage)) {
        $weblogmessage = __('You are previewing your comment. Be sure to click on "Post Comment" to store it.');
    }
    // execute a hook here after a comment is saved and the mails are sent
    $PIVOTX['extensions']->executeHook('comment_after_save', $entry);
    // After messing about with the comments, clear the cache.
    $PIVOTX['cache']->cache['entries'] = array();
}
    /**
     * The function that does the actual rendering of the smarty template
     *
     * @param string $template
     */
    function parseTemplate($template)
    {
        global $PIVOTX, $build, $version, $codename, $timetaken;
        $this->maintemplate = $template;
        // Extra security measures for when we're rendering 'frontside' pages:
        $PIVOTX['template']->security = true;
        if ($PIVOTX['config']->get('allow_php_in_templates') == 1) {
            $PIVOTX['template']->security_settings['PHP_TAGS'] = true;
        }
        $allowedfunctions = explode(',', "array,addslashes,trim,ltrim,rtrim,strlen,date," . "substr,strpos,md5,nl2br,strstr,strtoupper,strtolower,ucfirst,ucwords," . "count,empty,is_array,is_object,in_array,is_int,is_float,is_integer,is_numeric," . "is_string,serialize,unserialize,isset,sizeof,true,false,stripslashes," . "encode_text,safe_string,htmlentities,htmlspecialchars,html_entity_decode," . "trimtext,round,function_exists,tag_exists,intval,basename,dirname");
        $PIVOTX['template']->security_settings['IF_FUNCS'] = $allowedfunctions;
        $PIVOTX['template']->security_settings['MODIFIER_FUNCS'] = $allowedfunctions;
        // Check if we use caching..
        if ($PIVOTX['config']->get('smarty_cache')) {
            $PIVOTX['template']->caching = true;
            $PIVOTX['template']->compile_check = true;
            $PIVOTX['template']->force_compile = false;
            $code = getDefault($this->code, "");
            $cachekey = "tpl_" . $code . substr(md5($template . ',' . implode(',', $this->modifier)), 0, 10);
            // Now, let's see if the page we want is already in the cache..
            if ($PIVOTX['template']->is_cached($template, $cachekey)) {
                // It is! We can get that, and return to the calling function..
                // But first, we check for cache_before_read hooks..
                $PIVOTX['extensions']->executeHook('cache_before_read', $template);
                $this->html = $PIVOTX['template']->fetch($template, $cachekey);
                // Before we return, we check for cache_after_read hooks..
                $PIVOTX['extensions']->executeHook('cache_after_read', $this->html);
                return;
            } else {
                // Before we continue, we check for cache_missed_read hooks..
                $PIVOTX['extensions']->executeHook('cache_missed_read', $template);
            }
        } else {
            $cachekey = "";
        }
        // If we've set the hidden config option for 'always jquery', add the hook here:
        if ($PIVOTX['config']->get('always_jquery') == 1) {
            $PIVOTX['extensions']->addHook('after_parse', 'callback', 'jqueryIncludeCallback');
        }
        // Add a favicon to the page, PiovtX or user configured, unless it's set
        // to display nothing (by using '0' as user configured favicon)
        $favicon_html = "\t<link rel=\"shortcut icon\" href=\"%s\" />\n";
        $favicon = $PIVOTX['config']->get('favicon');
        if ($favicon == '0') {
            $favicon_html = '';
        } else {
            if ($favicon == '') {
                $favicon = $PIVOTX['paths']['pivotx_url'] . "pics/favicon.ico";
            }
            $favicon_html = sprintf($favicon_html, $favicon);
        }
        // Add a hook to insert the generator meta tag and possibly a favicon link
        $PIVOTX['extensions']->addHook('after_parse', 'insert_before_close_head', "\t<meta name=\"generator\" content=\"PivotX\" /><!-- version: " . strip_tags($build) . " -->\n" . $favicon_html);
        // Output the canonical link. See:
        // http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html
        if ($PIVOTX['config']->get('dont_add_canonical') == 0) {
            // If we're at the site's root, regardless of _what_ page or blog it is,
            // we always return the site url..
            if ($this->modifier['action'] == "page" && $PIVOTX['config']->get('root') == "p:" . $this->modifier['uri'] || $this->modifier['action'] == "weblog" && $PIVOTX['config']->get('root') == "w:" . $this->modifier['uri'] || $this->modifier['uri'] == "" && $PIVOTX['config']->get('root') == "" && !isset($this->modifier['offset'])) {
                $link = "";
                // Also set $modifier.home, so we can check if we're at the homepage from the templates.
                $this->modifier['home'] = true;
            } else {
                $link = smarty_link(array('hrefonly' => true), $PIVOTX['template']);
            }
            if (isset($this->modifier['canonical_link'])) {
                $link = $this->modifier['canonical_link'];
            }
            // Set the canonical link..
            $canonical = sprintf("\t<link rel=\"canonical\" href=\"%s%s\" />\n", $PIVOTX['paths']['canonical_host'], empty($link) ? $PIVOTX['paths']['site_url'] : $link);
            $PIVOTX['extensions']->addHook('after_parse', 'insert_before_close_head', $canonical);
        }
        // Add a hook to insert the scheduler. Unless the hidden configuration option
        // 'dont_run_scheduler' is set.
        if ($PIVOTX['config']->get('dont_run_scheduler') == 0) {
            $PIVOTX['extensions']->addHook('after_parse', 'insert_before_close_body', "\t<div class='scheduler-wrapper'><img src='" . $PIVOTX['paths']['pivotx_url'] . "scheduler.php' alt='' width='0' height='0' /></div>\n");
        }
        // If we've enabled the XML Feeds for this weblog, insert the auto-discovery tags..
        if ($PIVOTX['weblogs']->get('', 'rss') == 1) {
            $feedtitle = $PIVOTX['config']->get('sitename') . ' &raquo; ' . $PIVOTX['weblogs']->get('', 'name');
            $feedtitle = encodeText($feedtitle);
            $autodiscovery = sprintf("\t<link rel=\"alternate\" type=\"application/rss+xml\" title=\"%s (%s)\" href=\"%s\" />\n", $feedtitle, __("RSS feed"), makeFeedLink("rss"));
            $autodiscovery .= sprintf("\t<link rel=\"alternate\" type=\"application/atom+xml\" title=\"%s (%s)\" href=\"%s\" />\n", $feedtitle, __("Atom feed"), makeFeedLink("atom"));
            if ($PIVOTX['config']->get('feed_posts_only') != 1) {
                $feedlink_params = array('content' => 'comments');
                $autodiscovery .= sprintf("\t<link rel=\"alternate\" type=\"application/rss+xml\" title=\"%s (%s)\" href=\"%s\" />\n", $feedtitle, __("RSS feed for comments"), makeFeedLink("rss", $feedlink_params));
                $autodiscovery .= sprintf("\t<link rel=\"alternate\" type=\"application/atom+xml\" title=\"%s (%s)\" href=\"%s\" />\n", $feedtitle, __("Atom feed for comments"), makeFeedLink("atom", $feedlink_params));
            }
            if ($this->modifier['category'] != "") {
                $feedcategory = $PIVOTX['categories']->getCategory($this->modifier['category']);
                if (count($feedcategory) > 0) {
                    $feedtitle = $PIVOTX['config']->get('sitename') . ' &raquo; ' . __('category') . ' ' . $feedcategory['display'];
                    $feedtitle = encodeText($feedtitle);
                    $feedlink_params = array('category' => $feedcategory['name']);
                    $autodiscovery = sprintf("\t<link rel=\"alternate\" type=\"application/rss+xml\" title=\"%s (%s)\" href=\"%s\" />\n", $feedtitle, __("RSS feed"), makeFeedLink("rss", $feedlink_params)) . $autodiscovery;
                    $autodiscovery = sprintf("\t<link rel=\"alternate\" type=\"application/atom+xml\" title=\"%s (%s)\" href=\"%s\" />\n", $feedtitle, __("Atom feed"), makeFeedLink("atom", $feedlink_params)) . $autodiscovery;
                }
            }
            // Add a hook to insert RSS and ATOM autodiscovery-tag
            $PIVOTX['extensions']->addHook('after_parse', 'insert_before_close_head', $autodiscovery);
        }
        // If we've enabled XML-RPC / the MetaWeblog API, insert the auto-discovery tags...
        if ($PIVOTX['config']->get('xmlrpc') == 1) {
            $autodiscovery = sprintf("\t<link rel=\"EditURI\" type=\"application/rsd+xml\" title=\"RSD\" href=\"%s\" />\n", makeRSDLink());
            // Add a hook to insert XML-RPC / the MetaWeblog API autodiscovery-tag
            $PIVOTX['extensions']->addHook('after_parse', 'insert_before_close_head', $autodiscovery);
        }
        // If we've enabled (non-hardened) trackback, insert the auto-discovery tags...
        if ($PIVOTX['config']->get('trackbacks') == 1 && $PIVOTX['config']->get('hardened_trackback') != 1) {
            $autodiscovery = <<<EOM
<!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<rdf:Description
rdf:about="%url%"
dc:identifier="%url%"
dc:title="%title%"
trackback:ping="%tb-url%" />
</rdf:RDF> -->
EOM;
            $url = $PIVOTX['paths']['host'] . makeFilelink($PIVOTX['db']->entry['code'], '', '');
            if ($PIVOTX['config']->get('mod_rewrite') == 0) {
                $tb_url = $url . '&amp;trackback';
            } else {
                $tb_url = $url . '/trackback/';
            }
            $autodiscovery = str_replace("%url%", $url, $autodiscovery);
            $autodiscovery = str_replace("%title%", $PIVOTX['db']->entry['title'], $autodiscovery);
            $autodiscovery = str_replace("%tb-url%", $tb_url, $autodiscovery);
            // Add a hook to insert XML-RPC / the MetaWeblog API autodiscovery-tag
            $PIVOTX['extensions']->addHook('after_parse', 'insert_before_close_head', $autodiscovery);
        }
        // Assign some stuff to $smarty, so it's accessible from the templates.
        $PIVOTX['template']->assign('build', $build);
        $PIVOTX['template']->assign('version', $version);
        $PIVOTX['template']->assign('codename', $codename);
        $PIVOTX['template']->assign('config', $PIVOTX['config']->getConfigArray());
        $PIVOTX['template']->assign('weblogs', $PIVOTX['weblogs']->getWeblogs());
        $PIVOTX['template']->assign('paths', $PIVOTX['paths']);
        $PIVOTX['template']->assign('modifier', $this->modifier);
        $PIVOTX['template']->assign('timetaken', timeTaken());
        $PIVOTX['template']->assign('memtaken', getMem());
        $PIVOTX['template']->assign('query_count', $timetaken['query_count']);
        // If we've set the hidden config option for 'set_request_variables', set them..
        if ($PIVOTX['config']->get('set_request_variables') == 1) {
            $PIVOTX['template']->assign('get', $_GET);
            $PIVOTX['template']->assign('post', $_POST);
            $PIVOTX['template']->assign('request', $_REQUEST);
            $PIVOTX['template']->assign('server', $_SERVER);
            $PIVOTX['template']->assign('session', $_SESSION);
        }
        // Add the 'base part' of the path to the smarty variables as well
        $PIVOTX['template']->assign('templatedir', dirname($template));
        if (file_exists($PIVOTX['paths']['templates_path'] . $template)) {
            // Execute a hook, if present.
            $PIVOTX['extensions']->executeHook('during_parse', $template);
        } else {
            // hmm, template doesn't exist, so we set it to our '404' template..
            $template = "";
            // Execute a hook, if present.
            $PIVOTX['extensions']->executeHook('during_parse', $template);
            if ($template == "") {
                $template = "404.html";
                // TODO: what will be our 404 template?
            }
        }
        if ($PIVOTX['config']->get('smarty_cache')) {
            // Before we continue, we check for cache_before_write hooks..
            $PIVOTX['extensions']->executeHook('cache_before_write', $template);
        }
        $this->html = $PIVOTX['template']->fetch($template, $cachekey);
        // We're going to something really, really stupid here. If we've enabled
        // caching, and we've just written to the cache, we immediately get
        // the page from the cache again, because the copy that's in memory does
        // not have the HTML that's updated with our hooks. Thankfully this step
        // is really, really fast, because we use caching. :-)
        if ($PIVOTX['config']->get('smarty_cache')) {
            $this->html = $PIVOTX['template']->fetch($template, $cachekey);
            // Before we continue, we check for cache_after_write hooks..
            $PIVOTX['extensions']->executeHook('cache_after_write', $this->html);
        }
    }