Exemplo n.º 1
0
function spamhurdle_captcha_build_form($data)
{
    if (!isset($data['captcha']['html_form'])) {
        return $data;
    }
    global $PHORUM;
    $config = $PHORUM['mod_spamhurdles']['captcha'];
    $captcha = $data['captcha'];
    $form = $captcha['html_form'];
    // The actual value in the captcha is named {FIELDVALUE} in the
    // generated captcha HTML code. Replace it with the actual value.
    $fn = $captcha["input_fieldname"];
    $fieldvalue = isset($_POST[$fn]) ? $_POST[$fn] : "";
    $form = str_replace("{FIELDVALUE}", htmlspecialchars($fieldvalue), $form);
    // Replace SPOKENURL with the URL for the spoken captcha code.
    if ($config["spoken_captcha"] && file_exists($config["flite_location"])) {
        $url = phorum_get_url(PHORUM_ADDON_URL, 'module=spamhurdles', 'hurdle=captcha', 'spokencaptcha=' . rawurlencode(spamhurdles_encrypt($captcha['spoken_text'])));
        $form = str_replace('{SPOKENURL}', htmlspecialchars($url), $form);
    }
    // Replace IMAGE with the URL for the captcha image.
    $url = phorum_get_url(PHORUM_ADDON_URL, 'module=spamhurdles', 'hurdle=captcha', 'imagecaptcha=' . rawurlencode(spamhurdles_encrypt(array('question' => $captcha['question'], 'type' => $captcha['type']))));
    $form = str_replace('{IMAGEURL}', htmlspecialchars($url), $form);
    if (!empty($data['use_editor_block'])) {
        $PHORUM['DATA']['CONTENT'] = $form;
        $PHORUM['DATA']['EDITOR'] = $data['use_editor_block'];
        include phorum_get_template('spamhurdles::editor_block');
    } else {
        print $form;
    }
    return $data;
}
Exemplo n.º 2
0
    $base = strtolower(phorum_get_url(PHORUM_BASE_URL));
    $len = strlen($base);
    if (strtolower(substr($_SERVER["HTTP_REFERER"],0,$len)) == $base) {
        $redir = htmlspecialchars($_SERVER["HTTP_REFERER"]);
    }
}
if (! isset($redir)) {
    $redir = phorum_get_url(PHORUM_LIST_URL);
}

// Setup template data.
$PHORUM["DATA"]["LOGIN"]["redir"] = $redir;
$PHORUM["DATA"]["URL"]["REGISTER"] = phorum_get_url( PHORUM_REGISTER_URL );
$PHORUM["DATA"]["URL"]["ACTION"] = phorum_get_url( PHORUM_LOGIN_ACTION_URL );
$PHORUM["DATA"]["LOGIN"]["forum_id"] = ( int )$PHORUM["forum_id"];
$PHORUM["DATA"]["LOGIN"]["username"] = htmlspecialchars( $username );
$PHORUM["DATA"]["ERROR"] = htmlspecialchars( $error );
$PHORUM["DATA"]["OKMSG"] = htmlspecialchars( $okmsg );

// Set the field to set the focus to after loading.
$PHORUM["DATA"]["FOCUS_TO_ID"] = empty($username) ? "username" : "password";

// Display the page.
include phorum_get_template( "header" );
phorum_hook( "after_header" );
include phorum_get_template( $template );
phorum_hook( "before_footer" );
include phorum_get_template( "footer" );

?>
Exemplo n.º 3
0
function phorum_mod_bbcode_tpl_editor_disable_bbcode()
{
    $PHORUM = $GLOBALS["PHORUM"];
    if (empty($PHORUM["mod_bbcode"]["allow_disable_per_post"])) {
        return;
    }
    include phorum_get_template('bbcode::disable_option');
}
Exemplo n.º 4
0
function phorum_setup_announcements()
{
    global $PHORUM;
    // This variable will be used to store the formatted announcements.
    $PHORUM['DATA']['MOD_ANNOUNCEMENTS'] = '';
    // Check if we are on a page on which the announcements have to be shown.
    if (phorum_page == 'index') {
        // Hide the announcements, unless enabled for "index".
        $hide = empty($PHORUM["mod_announcements"]["pages"]["index"]);
        // Show announcements for the root page if "home" is enabled.
        if ($PHORUM['vroot'] == $PHORUM['forum_id'] && !empty($PHORUM["mod_announcements"]["pages"]["home"])) {
            $hide = FALSE;
        }
        if ($hide) {
            return;
        }
    } else {
        if (empty($PHORUM["mod_announcements"]["pages"][phorum_page])) {
            return;
        }
    }
    // Check if we need to show announcements.
    $ann_forum_id = NULL;
    // Inside a vroot, where we have a vroot configuration for the forum
    // to use for announcements and the current forum is not that
    // announcement forum.
    if ($PHORUM['vroot'] > 0 && !empty($PHORUM["mod_announcements"]["vroot"][$PHORUM['vroot']]) && $PHORUM["forum_id"] != $PHORUM["mod_announcements"]["vroot"][$PHORUM['vroot']]) {
        $ann_forum_id = $PHORUM["mod_announcements"]["vroot"][$PHORUM['vroot']];
        // Inside the top level folder, where we have a forum that is configured
        // to be used for announcements and the current forum is not that
        // announcement forum.
    } elseif ($PHORUM['vroot'] == 0 && !empty($PHORUM["mod_announcements"]["forum_id"]) && $PHORUM["forum_id"] != $PHORUM["mod_announcements"]["forum_id"]) {
        $ann_forum_id = $PHORUM["mod_announcements"]["forum_id"];
    }
    // If no announcement forum_id is found, no announcements
    // have to be shown.
    if ($ann_forum_id === NULL) {
        return;
    }
    // Retrieve the last number of posts from the announcement forum.
    $messages = phorum_db_get_recent_messages($PHORUM["mod_announcements"]["number_to_show"], 0, $ann_forum_id, 0, true);
    unset($messages["users"]);
    // No announcements to show? Then we are done.
    if (count($messages) == 0) {
        return;
    }
    // Read the newflags information for authenticated users.
    $newinfo = NULL;
    if ($PHORUM["DATA"]["LOGGEDIN"]) {
        $newflagkey = $ann_forum_id . "-" . $PHORUM['user']['user_id'];
        if ($PHORUM['cache_newflags']) {
            $newinfo = phorum_cache_get('newflags', $newflagkey, $PHORUM['cache_version']);
        }
        if ($newinfo == NULL) {
            $newinfo = phorum_db_newflag_get_flags($ann_forum_id);
            if ($PHORUM['cache_newflags']) {
                phorum_cache_put('newflags', $newflagkey, $newinfo, 86400, $PHORUM['cache_version']);
            }
        }
    }
    require_once "./include/format_functions.php";
    // Process the announcements.
    foreach ($messages as $message) {
        // Skip this message if it's older than the number of days that was
        // configured in the settings screen.
        if (!empty($PHORUM["mod_announcements"]["days_to_show"]) && $message["datestamp"] < time() - $PHORUM["mod_announcements"]["days_to_show"] * 86400) {
            continue;
        }
        // Check if there are new messages in the thread.
        if (isset($newinfo)) {
            $new = 0;
            foreach ($message["meta"]["message_ids"] as $id) {
                if (!isset($newinfo[$id]) && $id > $newinfo['min_id']) {
                    $new = 1;
                    break;
                }
            }
            // There are new messages. Setup the template data for showing
            // a new flag.
            if ($new) {
                $message["new"] = $new ? $PHORUM["DATA"]["LANG"]["newflag"] : NULL;
                $message["URL"]["NEWPOST"] = phorum_get_url(PHORUM_FOREIGN_READ_URL, $message["forum_id"], $message["thread"], "gotonewpost");
            } elseif ($PHORUM["mod_announcements"]["only_show_unread"]) {
                continue;
            }
        }
        // Setup template data for the message.
        unset($message['body']);
        $message["lastpost"] = phorum_date($PHORUM["short_date_time"], $message["modifystamp"]);
        $message["raw_datestamp"] = $message["datestamp"];
        $message["datestamp"] = phorum_date($PHORUM["short_date_time"], $message["datestamp"]);
        $message["URL"]["READ"] = phorum_get_url(PHORUM_FOREIGN_READ_URL, $message["forum_id"], $message["message_id"]);
        $PHORUM["DATA"]["ANNOUNCEMENTS"][] = $message;
    }
    // If all announcements were skipped, then we are done.
    if (!isset($PHORUM["DATA"]["ANNOUNCEMENTS"])) {
        return;
    }
    // format / clean etc. the messages found
    $PHORUM["DATA"]["ANNOUNCEMENTS"] = phorum_format_messages($PHORUM["DATA"]["ANNOUNCEMENTS"]);
    // Build the announcements code.
    ob_start();
    include phorum_get_template("announcements::announcements");
    $PHORUM['DATA']['MOD_ANNOUNCEMENTS'] = ob_get_contents();
    ob_end_clean();
}
Exemplo n.º 5
0
 $module_registrations[$id]['type'] = $m[1];
 $module_registrations[$id]['source'] = $m[2];
 switch ($m[1]) {
     case "file":
         if (!isset($r['cache_key'])) {
             $mtime = @filemtime($m[2]);
             $r['cache_key'] = $mtime;
             $module_registrations[$id]['cache_key'] = $mtime;
         }
         break;
     case "template":
         // We load the parsed template into memory. This will refresh
         // the cached template file if required. This is the easiest
         // way to make this work correctly for nested template files.
         ob_start();
         include phorum_get_template($m[2]);
         $module_registrations[$id]['content'] = ob_get_contents();
         ob_end_clean();
         // We use the mtime of the compiled template as the cache
         // key if no specific cache key was set.
         if (!isset($r['cache_key'])) {
             list($m[2], $php, $tpl) = phorum_get_template_file($m[2]);
             $mtime = @filemtime($php);
             $r['cache_key'] = $mtime;
             $module_registrations[$id]['cache_key'] = $mtime;
         }
         break;
     case "function":
         if (!isset($r['cache_key'])) {
             trigger_error("css_register hook: module registration error: " . "\"cache_key\" field missing for source " . "\"{$r['source']}\" in module \"{$r['module']}\".");
             exit(1);
Exemplo n.º 6
0
 
include './common.php';

if($argc < 2) {
    echo "needs 2 parameters, first as forum-id, second as filename (including path) of the css to be generated.\n";
    exit();       
}

// the second arg is the filename
$filepath=$argv[2];

if(is_dir($filename)) {
    echo "the second argument has to be a filename and no directory!\n";
    exit();       
}

echo "Generating static CSS-file for Forum ".$PHORUM['forum_id']."\n";

ob_start();
include phorum_get_template('css');
$css_str=ob_get_contents();
ob_end_clean();

echo "writing CSS-file to ".$filepath.".\n";

$fp=fopen($filepath,"w");
fputs($fp,$css_str);
fclose($fp);

?>
Exemplo n.º 7
0
/**
 * A common function for checking the read-permissions for a forum-page
 * returns false if access is not allowed and an error page-was output
 */
function phorum_check_read_common()
{
    $PHORUM = $GLOBALS['PHORUM'];

    $retval = true;

    if ( $PHORUM["forum_id"] > 0 && !$PHORUM["folder_flag"] && !phorum_user_access_allowed( PHORUM_USER_ALLOW_READ ) ) {
        if ( $PHORUM["DATA"]["LOGGEDIN"] ) {
            // if they are logged in and not allowed, they don't have rights
            $PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["NoRead"];
        } else {
            // check if they could read if logged in.
            // if so, let them know to log in.
            if ( ( empty( $PHORUM["DATA"]["POST"]["parentid"] ) && $PHORUM["reg_perms"] &PHORUM_USER_ALLOW_READ ) ) {
                $PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["PleaseLoginRead"];
            } else {
                $PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["NoRead"];
            }
        }

        phorum_build_common_urls();

        include phorum_get_template( "header" );
        phorum_hook( "after_header" );
        include phorum_get_template( "message" );
        phorum_hook( "before_footer" );
        include phorum_get_template( "footer" );

        $retval = false;
    }

    return $retval;
}
Exemplo n.º 8
0
/**
 * Wrapper function to handle most common output scenarios.
 *
 * @param mixed $template
 *     If string, that template is included.
 *     If array, all the templates are included in the order of the array.
 */
function phorum_output($templates)
{
    if (!is_array($templates)) {
        $templates = array($templates);
    }
    /*
     * [hook]
     *     start_output
     *
     * [description]
     *     This hook gives modules a chance to apply some last minute
     *     changes to the Phorum data. You can also use this hook to
     *     call <phpfunc>ob_start</phpfunc> if you need to buffer Phorum's
     *     full output (e.g. to do some post processing on the data
     *     from the <hook>end_output</hook> hook.<sbr/>
     *     <sbr/>
     *     Note: this hook is only called for standard pages (the ones
     *     that are constructed using a header, body and footer) and not
     *     for output from scripts that do raw output like
     *     <filename>file.php</filename>, <filename>javascript.php</filename>,
     *     <filename>css.php</filename> and <filename>rss.php</filename>.
     *
     * [category]
     *     Page output
     *
     * [when]
     *     After setting up all Phorum data, right before sending the
     *     page header template.
     *
     * [input]
     *     No input.
     *
     * [output]
     *     No output.
     *
     * [example]
     *     <hookcode>
     *     function phorum_mod_foo_start_output()
     *     {
     *         global $PHORUM;
     *
     *         // Add some custom data to the page title.
     *         $title = $PHORUM['DATA']['HTML_TITLE'];
     *         $PHORUM['DATA']['HTML_TITLE'] = "-=| Phorum Rocks! |=- $title";
     *     }
     *     </hookcode>
     */
    if (isset($GLOBALS["PHORUM"]["hooks"]["start_output"])) {
        phorum_hook("start_output");
    }
    // Copy only what we need into the current scope. We do this at
    // this point and not earlier, so the start_output hook can be
    // used for changing values in the $PHORUM data.
    $PHORUM = array("DATA" => $GLOBALS["PHORUM"]["DATA"], "locale" => $GLOBALS["PHORUM"]["locale"], "hooks" => $GLOBALS["PHORUM"]["hooks"]);
    include phorum_get_template("header");
    /*
     * [hook]
     *     after_header
     *
     * [description]
     *     This hook can be used for adding content to the pages that is
     *     displayed after the page header template, but before the main
     *     page content.
     *
     * [category]
     *     Page output
     *
     * [when]
     *     After sending the page header template, but before sending the
     *     main page content.
     *
     * [input]
     *     No input.
     *
     * [output]
     *     No output.
     *
     * [example]
     *     <hookcode>
     *     function phorum_mod_foo_after_header()
     *     {
     *         // Only add data after the header for the index and list pages.
     *         if (phorum_page != 'index' && phorum_page != 'list') return;
     *
     *         // Add some static notification after the header.
     *         print '<div style="border:1px solid orange; padding: 1em">';
     *         print 'Welcome to our forums!';
     *         print '</div>';
     *     }
     *     </hookcode>
     */
    if (isset($PHORUM["hooks"]["after_header"])) {
        phorum_hook("after_header");
    }
    foreach ($templates as $template) {
        include phorum_get_template($template);
    }
    /*
     * [hook]
     *     before_footer
     *
     * [description]
     *     This hook can be used for adding content to the pages that is
     *     displayed after the main page content, but before the page footer.
     *
     * [category]
     *     Page output
     *
     * [when]
     *     After sending the main page content, but before sending the
     *     page footer template.
     *
     * [input]
     *     No input.
     *
     * [output]
     *     No output.
     *
     * [example]
     *     <hookcode>
     *     function phorum_mod_foo_before_footer()
     *     {
     *         // Add some static notification before the footer.
     *         print '<div style="font-size: 90%">';
     *         print '  For technical support, please send a mail to ';
     *         print '  <a href="mailto:tech@example.com">the webmaster</a>.';
     *         print '</div>';
     *     }
     *     </hookcode>
     */
    if (isset($PHORUM["hooks"]["before_footer"])) {
        phorum_hook("before_footer");
    }
    include phorum_get_template("footer");
    /*
     * [hook]
     *     end_output
     *
     * [description]
     *     This hook can be used for performing post output tasks.
     *     One of the things that you could use this for, is for
     *     reading in buffered output using <phpfunc>ob_get_contents</phpfunc>
     *     in case you started buffering using <phpfunc>ob_start</phpfunc>
     *     from the <hook>start_output</hook> hook.
     *
     * [category]
     *     Page output
     *
     * [when]
     *     After sending the page footer template.
     *
     * [input]
     *     No input.
     *
     * [output]
     *     No output.
     *
     * [example]
     *     <hookcode>
     *     function phorum_mod_foo_end_output()
     *     {
     *         // Some made up call to some fake statistics package.
     *         include("/usr/share/lib/footracker.php");
     *         footracker_register_request();
     *     }
     *     </hookcode>
     */
    if (isset($PHORUM["hooks"]["end_output"])) {
        phorum_hook("end_output");
    }
}
Exemplo n.º 9
0
function spamhurdle_blockerror()
{
    global $PHORUM;
    phorum_build_common_urls();
    $PHORUM["DATA"]["ERROR"] = $PHORUM["DATA"]["LANG"]["mod_spamhurdles"]["BlockError"];
    include phorum_get_template("header");
    phorum_hook("after_header");
    include phorum_get_template("message");
    phorum_hook("before_footer");
    include phorum_get_template("footer");
    exit(0);
}
Exemplo n.º 10
0
function phorum_import_template($tplfile, $outfile)
{
    global $include_level, $include_deps;
    $include_level++;

    // Remember that we used this template.
    $include_deps[$tplfile] = $outfile;

    // In case we're handling 0 byte large files, we set $page
    // directly. Running fread($fp, 0) gives a PHP warning.
    if (filesize($tplfile)) {
        $fp=fopen($tplfile, "r");
        $page=fread($fp, filesize($tplfile));
        fclose($fp);
    } else {
        $page = '';
    }

    preg_match_all("/\{[\!\/A-Za-z].+?\}/s", $page, $matches);

    settype($oldloopvar, "string");
    settype($loopvar, "string");
    settype($olddatavar, "string");
    settype($datavar, "string");
    $loopvars = array();

    foreach($matches[0] as $match){
        unset($parts);

        $string=substr($match, 1, -1);

        $string = trim($string);

        // pre-parse pointer variables
        if(strstr($string, "->")){
            $string=str_replace("->", "']['", $string);
        }

        $parts=explode(" ", $string);

        switch(strtolower($parts[0])){

            // Comment
            case "!":

            $repl="<?php // ".implode(" ", $parts)." ?>";
            break;


            case "include":

            $repl = file_get_contents(phorum_get_template($parts[1],1));
            break;

            case "include_once":

            $repl="<?php include_once phorum_get_template('$parts[1]'); ?>";
            break;

            case "include_var": // include a file given by a variable

            $repl="<?php include_once phorum_get_template( \$PHORUM[\"DATA\"]['$parts[1]']); ?>";
            break;

            // A define is used to create vars for the engine to use.
            case "define":

            $repl="<?php \$PHORUM[\"TMP\"]['$parts[1]']='";
            array_shift($parts);
            array_shift($parts);
            foreach($parts as $part){
                $repl.=str_replace("'", "\\'", $part)." ";
            }
            $repl=trim($repl)."'; ?>";
            break;


            // A var is used to create vars for the template.
            case "var":

            $repl="<?php \$PHORUM[\"DATA\"]['$parts[1]']='";
            array_shift($parts);
            array_shift($parts);
            foreach($parts as $part){
                $repl.=str_replace("'", "\\'", $part)." ";
            }
            $repl=trim($repl)."'; ?>";
            break;

            // Run a Phorum hook. The first parameter is the name of the
            // hook. Other parameters will be passed on as arguments for
            // the hook function. On argument will be passed directly to
            // the hook. Multiple arguments will be passed in an array.
            case "hook":

            // Setup hook arguments.
            $hookargs = array();
            for($i = 2; !empty($parts[$i]); $i++) {
                // For supporting the following construct, where the
                // loopvar is passed to the hook in full:
                // {LOOP SOMELIST}
                //   {HOOK some_hook SOMELIST}
                // {/LOOP SOMELIST}
                if (isset($loopvars[$parts[$i]])) {
                    $hookargs[] = "\$PHORUM['TMP']['".addslashes($parts[$i])."']";
                } else {
                    $index = phorum_determine_index($loopvars, $parts[$i]);
                    $hookargs[] = "\$PHORUM['$index']['".addslashes($parts[$i])."']";
                }
            }

            // Build the replacement string.
            $repl = "<?php if(isset(\$PHORUM['hooks']['".addslashes($parts[1])."'])) phorum_hook('".addslashes($parts[1])."'";
            if (count($hookargs) == 1) {
                $repl .= "," . $hookargs[0];
            } elseif (count($hookargs) > 1) {
                $repl .= ",array(" . implode(",", $hookargs) . ")";
            }
            $repl .= ");?>";
            break;

            // starts a loop
            case "loop":

            $loopvars[$parts[1]]=true;
            $index=phorum_determine_index($loopvars, $parts[1]);
            $repl="<?php \$phorum_loopstack[] = isset(\$PHORUM['TMP']['$parts[1]']) ? \$PHORUM['TMP']['$parts[1]']:NULL; if(isset(\$PHORUM['$index']['$parts[1]']) && is_array(\$PHORUM['$index']['$parts[1]'])) foreach(\$PHORUM['$index']['$parts[1]'] as \$PHORUM['TMP']['$parts[1]']){ ?>";
            break;


            // ends a loop
            case "/loop":

            if (!isset($parts[1])) print "<h3>Template warning: Missing argument for /loop statement in file '" . htmlspecialchars($tplfile) . "'</h3>";
            $repl="<?php } if(isset(\$PHORUM['TMP']) && isset(\$PHORUM['TMP']['$parts[1]'])) unset(\$PHORUM['TMP']['$parts[1]']); \$phorum_loopstackitem=array_pop(\$phorum_loopstack); if (isset(\$phorum_loopstackitem)) \$PHORUM['TMP']['$parts[1]'] = \$phorum_loopstackitem;?>";
            unset($loopvars[$parts[1]]);
            break;


            // if and elseif are the same accept how the line starts
            case "if":
            case "elseif":

            // determine if or elseif
            $prefix = (strtolower($parts[0])=="if") ? "if" : "} elseif";

            // are we wanting == or !=
            if(strtolower($parts[1])=="not"){
                $operator="!=";
                $parts[1]=$parts[2];
                if(isset($parts[3])){
                    $parts[2]=$parts[3];
                    unset($parts[3]);
                } else {
                    unset($parts[2]);
                }
            } else {
                $operator="==";
            }

            $index=phorum_determine_index($loopvars, $parts[1]);

            // if there is no part 2, check that the value is set and not empty
            if(!isset($parts[2])){
                if($operator=="=="){
                    $repl="<?php $prefix(isset(\$PHORUM['$index']['$parts[1]']) && !empty(\$PHORUM['$index']['$parts[1]'])){ ?>";
                } else {
                    $repl="<?php $prefix(!isset(\$PHORUM['$index']['$parts[1]']) || empty(\$PHORUM['$index']['$parts[1]'])){ ?>";
                }

                // if it is numeric, a constant or a string, simply set it as is
            } elseif(is_numeric($parts[2]) || defined($parts[2]) || preg_match('!"[^"]*"!', $parts[2])) {
                $repl="<?php $prefix(isset(\$PHORUM['$index']['$parts[1]']) && \$PHORUM['$index']['$parts[1]']$operator$parts[2]){ ?>";

                // we must have a template var
            } else {

                $index_part2=phorum_determine_index($loopvars, $parts[2]);

                // this is a really complicated IF we are building.

                $repl="<?php $prefix(isset(\$PHORUM['$index']['$parts[1]']) && isset(\$PHORUM['$index_part2']['$parts[2]']) && \$PHORUM['$index']['$parts[1]']$operator\$PHORUM['$index_part2']['$parts[2]']) { ?>";

            }

            // reset $prefix
            $prefix="";
            break;


            // create an else
            case "else":

            $repl="<?php } else { ?>";
            break;


            // close an if
            case "/if":

            $repl="<?php } ?>";
            break;

            case "assign":
            if(defined($parts[2]) || is_numeric($parts[2])){
                $repl="<?php \$PHORUM[\"DATA\"]['$parts[1]']=$parts[2]; ?>";
            } else {
                $index=phorum_determine_index($loopvars, $parts[2]);

                $repl="<?php \$PHORUM[\"DATA\"]['$parts[1]']=\$PHORUM['$index']['$parts[2]']; ?>";
            }
            break;


            // this is just for echoing vars from DATA or TMP if it is a loopvar
            default:

            if(defined($parts[0])){
                $repl="<?php echo $parts[0]; ?>";
            } else {

                $index=phorum_determine_index($loopvars, $parts[0]);

                $repl="<?php echo \$PHORUM['$index']['$parts[0]']; ?>";
            }
        }

        $page=str_replace($match, $repl, $page);
    }

    $include_level--;

    // Did we finish processing our top level template? Then write out
    // the compiled template to the cache.
    //
    // For storing the compiled template, we use two files. The first one
    // has some code for checking if one of the dependant files has been
    // updated and for rebuilding the template if this is the case.
    // This one loads the second file, which is the template itself.
    //
    // This two-stage loading is needed to make sure that syntax
    // errors in a template file won't break the depancy checking process.
    // If both were in the same file, the complete file would not be run
    // at all and the user would have to clean out the template cache to
    // reload the template once it was fixed. This way user intervention
    // is never needed.
    if ($include_level == 0)
    {
        // Find the template name for the top level template.
        $pathparts = preg_split('[\\/]', $outfile);
        $fileparts = explode('-', preg_replace('/^.*\//', '', $pathparts[count($pathparts)-1]));
        $this_template = addslashes($fileparts[2]);

        // Determine first and second stage cache filenames.
        $stage1_file = $outfile;
        $fileparts[3] = "toplevel_stage2";
        unset($pathparts[count($pathparts)-1]);
        $stage2_file = implode('/', $pathparts) . '/' . implode('-', $fileparts);

        // Create code for automatic rebuilding of rendered templates
        // in case of changes. This is done by checking if one of the
        // templates in the dependancy list has been updated. If this
        // is the case, all dependant rendered subtemplates are deleted.
        // After that phorum_get_template() is called on the top level
        // template to rebuild all needed templates.

        $check_deps =
            "<?php\n" .
            '$mymtime = @filemtime("' . addslashes($stage1_file) . '");' . "\n" .
            "\$update_count = 0;\n" .
            "\$need_update = (\n";
        foreach ($include_deps as $tpl => $out) {
            $qtpl = addslashes($tpl);
            $check_deps .= "    @filemtime(\"$qtpl\") > \$mymtime ||\n";
        }
        $check_deps = substr($check_deps, 0, -4); // strip trailing " ||\n"
        $check_deps .=
        "\n" .
        ");\n" .
        "if (\$need_update) {\n";
        foreach ($include_deps as $tpl => $out) {
            $qout = addslashes($out);
            $check_deps .= "    @unlink(\"$qout\");\n";
        }
        $check_deps .=
        "    \$tplfile = phorum_get_template(\"$this_template\");\n" .
        "}\n" .
        "include(\"" . addslashes($stage2_file) . "\");\n" .
        "?>\n";

        // Reset dependancy list for the next phorum_import_template() call.
        $include_deps = array();

        // Write out data to the cache.
        phorum_write_templatefile($stage1_file, $check_deps);
        phorum_write_templatefile($stage2_file, $page, true);
    }
    else
    {
        // Write out subtemplate to the cache.
        phorum_write_templatefile($outfile, $page);
    }


}
Exemplo n.º 11
0
  <br/>
  <br/>

  <input type="text" id="checkpm_user_id" value="<?php 
if ($PHORUM['user']['user_id']) {
    print $PHORUM['user']['user_id'];
}
?>
" />
  <input type="button" value="Check PM for user id" onclick="checkpm(); return false"/>

</form>

<strong>Output</strong><br/>
<div id="viewer" style="border: 1px solid #ddd; padding:10px; margin-bottom:5px; font-size: 9px">
</div>
<strong>Debugging information</strong><br/>
<div id="logger" style="border: 1px solid #ddd; padding:10px; font-size: 9px">
</div>
<div id="state" style="border: 1px solid #ddd; border-top: none; padding:10px; font-size: 9px">
</div>

<script type="text/javascript">
init();
</script>

<?php 
include phorum_get_template('footer');
?>