forum

if( isset($_GET[“f”]) ){
$_GET[“forum_id”] = $_GET[“f”];
}
if( isset($_GET[“t”]) ){
$_GET[“topic_id”] = $_GET[“t”];
}

$w3forum_id = isset($_GET[“forum_id”]) ? $_GET[“forum_id”] : ”;
$w3topic_id = isset($_GET[“topic_id”]) ? $_GET[“topic_id”] : ”;
$w3post_id = isset($_GET[“post_id”]) ? $_GET[“post_id”] : ”; // p reserved // may used for htaccess “strong” and consistent, V1 code redirect trick
$w3mode = isset($_GET[“mode”]) ? $_GET[“mode”] : ”;
$w3phpbbuid = isset($_GET[“u”]) ? $_GET[“u”] : ”;
$w3phpbbsid = isset($_GET[“sid”]) ? $_GET[“sid”] : ”;
$w3phpbbwatch = isset($_GET[“watch”]) ? $_GET[“watch”] : ”;
$w3phpbbunwatch = isset($_GET[“unwatch”]) ? $_GET[“unwatch”] : ”;
$w3phpbb_start = isset($_GET[“start”]) ? $_GET[“start”] : ”;
$w3iu = isset($_GET[“i”]) ? $_GET[“i”] : ”;
$w3iu_folder = isset($_GET[“folder”]) ? $_GET[“folder”] : ”;

$w3allhomeurl = get_home_url();
$current_user = wp_get_current_user();
$dd = get_option(‘w3all_phpbb_cookie’);
$phpbb_on_template_iframe = get_option( ‘w3all_iframe_phpbb_link_yn’ );
$wp_w3all_forum_folder_wp = get_option(‘w3all_forum_template_wppage’);
$w3all_url_to_cms = get_option( ‘w3all_url_to_cms’ );

if( preg_match(‘/[^0-9]/’,$w3phpbbuid) OR preg_match(‘/[^a-z]/’,$w3phpbbwatch) OR preg_match(‘/[^a-z]/’,$w3phpbbunwatch) OR preg_match(‘/[^A-Za-z]/’,$w3iu_folder) OR preg_match(‘/[^A-Za-z]/’,$w3iu) OR preg_match(‘/[^0-9]/’,$w3phpbb_start) OR preg_match(‘/[^0-9]/’,$w3topic_id) OR preg_match(‘/[^0-9]/’,$w3forum_id) OR preg_match(‘/[^0-9]/’,$w3post_id) OR preg_match(‘/[^0-9A-Za-z]/’,$w3mode) OR preg_match(‘/[^0-9A-Za-z]/’,$w3phpbbsid) ){

die(“Something goes wrong with your URL request, please leave this page.”);
}

if(!empty($dd)){
$p = strpos($dd, ‘.’);
if($p !== false && $p === 0){
$document_domain = substr($dd, 1);
} else {
$document_domain = $dd;
}
} else {
$document_domain = ‘localhost’;
}

// build and pass links x iframe //
// This following from 1.9.4 substantially execute only when links from widgets in WP
// On the new easy way, passed URL’s from iframe are encoded and passed via $_GET[“w3”]
if ( !empty($w3forum_id) && empty($w3topic_id) && empty($w3phpbb_start) && empty($w3post_id) ){
$w3all_url_to_cms = $w3all_url_to_cms . “/viewforum.php?f=”. $w3forum_id .””;
} elseif ( !empty($w3forum_id) && !empty($w3phpbb_start) && empty($w3topic_id) ) {
$w3all_url_to_cms = $w3all_url_to_cms . “/viewforum.php?f=”. $w3forum_id .”&start=”.$w3phpbb_start.””;
} elseif ( !empty($w3forum_id) && !empty($w3topic_id) && empty($w3post_id) && empty($w3phpbb_start) ) {
$w3all_url_to_cms = $w3all_url_to_cms . “/viewtopic.php?f=”. $w3forum_id .”&t=”.$w3topic_id.””;
} elseif ( !empty($w3forum_id) && !empty($w3topic_id) && !empty($w3post_id) ) {
$w3all_url_to_cms = $w3all_url_to_cms . “/viewtopic.php?f=”. $w3forum_id .”&t=”.$w3topic_id.”&p=”.$w3post_id.”#p”.$w3post_id.””;
} elseif ( !empty($w3forum_id) && empty($w3topic_id) && !empty($w3post_id) ) {
$w3all_url_to_cms = $w3all_url_to_cms . “/viewtopic.php?f=”. $w3forum_id .”&p=”.$w3post_id.”#p”.$w3post_id.””;
} elseif ( !empty($w3forum_id) && !empty($w3topic_id) && !empty($w3phpbb_start) ) {
$w3all_url_to_cms = $w3all_url_to_cms . “/viewtopic.php?f=”. $w3forum_id .”&t=”.$w3topic_id.”&start=”.$w3phpbb_start.””;
} elseif ( empty($w3forum_id) && !empty($w3post_id) && empty($w3iu) ) {
$w3all_url_to_cms = $w3all_url_to_cms . “/viewtopic.php?p=”.$w3post_id.”#p”.$w3post_id.””;
} elseif (stristr($w3mode, “ucp”)) { // custom to ucp
$w3all_url_to_cms = $w3all_url_to_cms . “/ucp.php”;
} elseif (stristr($w3mode, “register”)) {
$w3all_url_to_cms = $w3all_url_to_cms . “/ucp.php?mode=register”;
} elseif (stristr($w3mode, “sendpassword”)) {
$w3all_url_to_cms = $w3all_url_to_cms . “/ucp.php?mode=sendpassword”;
} elseif (stristr($w3mode, “login”)) {
$w3all_url_to_cms = $w3all_url_to_cms . “/ucp.php?mode=login”;
} elseif (stristr($w3mode, “logout”)) {
$w3all_url_to_cms = $w3all_url_to_cms . “/ucp.php?mode=logout&sid=”. $w3phpbbsid .””;
} elseif (stristr($w3mode, “memberlist”)) { // custom to memberlist
$w3all_url_to_cms = $w3all_url_to_cms . “/memberlist.php”;
} elseif (stristr($w3mode, “viewprofile”)) {
$w3all_url_to_cms = $w3all_url_to_cms . “/memberlist.php?mode=viewprofile&u=”. $w3phpbbuid .””;
} elseif (stristr($w3mode, “contactadmin”)) {
$w3all_url_to_cms = $w3all_url_to_cms . “/memberlist.php?mode=contactadmin”;
} elseif (stristr($w3mode, “team”)) {
$w3all_url_to_cms = $w3all_url_to_cms . “/memberlist.php?mode=team”;
} elseif (stristr($w3iu, “pm”) && $w3iu_folder == ‘inbox’) {
$w3all_url_to_cms = $w3all_url_to_cms . “/ucp.php?i=pm&folder=inbox”;
} elseif (stristr($w3mode, “view”) && $w3iu == ‘pm’) {
$w3all_url_to_cms = $w3all_url_to_cms . “/ucp.php?i=pm&mode=view&f=0&p=”.$w3post_id.””;
} else {
$w3all_url_to_cms = $w3all_url_to_cms;
}

if( isset($_GET[“w3”]) ){
$phpbb_url = base64_decode($_GET[“w3″]);
$phpbb_url = trim(utf8_encode($phpbb_url));
$w3all_url_to_cms = $w3all_url_to_cms . ‘/’ . $phpbb_url;
if( preg_match(‘/[^-0-9A-Za-z\._#\:\?\/=&%]/ui’,$phpbb_url) ){
$w3all_url_to_cms = $w3all_url_to_cms;
}
}

if( strlen($w3all_url_to_cms) == strlen(get_option( ‘w3all_url_to_cms’ )) OR strlen($w3all_url_to_cms) == strlen(get_option( ‘w3all_url_to_cms’ )) + 1 )
{
// Fix by @tlagren
// bug -> https://wordpress.org/support/topic/problem-using-iframe-feature-with-https/
$w3all_url_to_cms .= (substr($w3all_url_to_cms, -1) == ‘/’ ? ” : ‘/index.php’);
}

function w3all_enqueue_scripts() {
wp_enqueue_script(“jquery”);
}

function wp_w3all_add_ajax() {
global $w3all_url_to_cms, $wp_w3all_forum_folder_wp,$phpbb_on_template_iframe, $w3allhomeurl;

if ($phpbb_on_template_iframe > 0){
$w3all_url_to_phpbb_ib = $w3allhomeurl . “/” . $wp_w3all_forum_folder_wp . “/?i=pm&folder=inbox”;
} else {
$w3all_url_to_phpbb_ib = $w3all_url_to_cms . “/ucp.php?i=pm&folder=inbox”;
}
$s = “

“;
echo $s;
}

add_action(‘wp_enqueue_scripts’, ‘w3all_enqueue_scripts’);
add_action(‘wp_head’,’wp_w3all_add_ajax’);

// END MAY DO NOT MODIFY

// START a default WordPress page

// NOTE FOR CUSTOM phpBB iframe embedded PAGES (two columns etc)
// If you want to create a custom page forum you just need:
// Copy all the above until here (before the call to get_header();)
// Than copy/paste all the code inside the following and
// inside whatever element the iframe need to display into (for example into

on default WP twentysixteen theme)
get_header();
?>