Esempio n. 1
0
function wpu_wp_template_load()
{
    global $phpbbForum, $wpUtdInt, $wpUnited;
    $phpbbForum->background();
    // get the page
    ob_start();
    $oldGET = $_GET;
    $_GET = array();
    wpu_initialise_wp();
    // items usually set by wordpress template loads:
    define("WP_USE_THEMES", true);
    global $wp_did_header;
    $wp_did_header = true;
    wp();
    if (!$wpUnited->should_do_action('template-p-in-w')) {
        $wpUtdInt->load_template();
    }
    $_GET = $oldGET;
    $content = ob_get_contents();
    ob_end_clean();
    return $content;
}
Esempio n. 2
0
/**
 * Capture the outputted page, and prevent phpBB from exiting
 * @todo: use better check to ensure hook is called on template->display and just drop for everything else
 */
function wpu_execute(&$hook, $handle)
{
    global $wpUnited, $wpuBuffered, $wpuRunning, $template, $db, $cache, $phpbbForum;
    // We only want this action to fire once, and only on a real $template->display('body') event
    if (!$wpuRunning && isset($template->filename[$handle])) {
        // perform profile sync if required
        if ($wpUnited->should_do_action('profile')) {
            global $phpbbForum, $user;
            $idToFetch = $wpUnited->actions_for_another() ? $wpUnited->actions_for_another() : $user->data['user_id'];
            // have to reload data from scratch otherwise cached $user is used
            $newUserData = $phpbbForum->get_userdata('', $idToFetch, true);
            // only sync password if it is changing
            $ignorePassword = request_var('new_password', '') == '';
            $phpbbForum->background();
            wpu_initialise_wp();
            $wpUserData = get_userdata($newUserData['user_wpuint_id']);
            wpu_sync_profiles($wpUserData, $newUserData, 'phpbb-update', $ignorePassword);
            $phpbbForum->foreground();
        }
        if ($handle != 'body') {
            return;
        }
        /**
         * An additional check to ensure we don't act on a $template->assign_display('body') event --
         * if a mod is doing weird things with $template instead of creating their own $template object
         */
        if ($wpUnited->should_do_action('template-w-in-p')) {
            if ($wpuBuffered = wpu_am_i_buffered()) {
                return;
            }
        }
        // nested hooks don't work, and append_sid calls a hook. Furthermore we will call ->display again anyway:
        $wpuRunning = true;
        if (defined('SHOW_BLOG_LINK') && SHOW_BLOG_LINK) {
            $template->assign_vars(array('U_BLOG' => append_sid($wpUnited->get_wp_home_url(), false, false, $GLOBALS['user']->session_id), 'S_BLOG' => TRUE));
        }
        if ($wpUnited->should_do_action('template-p-in-w')) {
            $template->display($handle);
            $wpUnited->set_inner_content(ob_get_contents());
            ob_end_clean();
            if (in_array($template->filename[$handle], (array) $GLOBALS['WPU_NOT_INTEGRATED_TPLS'])) {
                //Don't reverse-integrate pages we know don't want header/footers
                echo $wpUnited->get_inner_content();
            } else {
                //insert phpBB into a wordpress page
                require_once $wpUnited->get_plugin_path() . 'template-integrator.php';
                wpu_integrate_templates();
            }
        } elseif (defined('PHPBB_EXIT_DISABLED')) {
            /**
             * page_footer was called, but we don't want to close the DB connection & cache yet
             */
            $template->display($handle);
            $GLOBALS['bckDB'] = $db;
            $GLOBALS['bckCache'] = $cache;
            $db = '';
            $cache = '';
            return '';
        }
    }
}