Page 1 of 1

iframe integration infinite loop

Posted: Tue Dec 21, 2021 12:22 pm
by madoma73
Hello,
I have installed a fresh new wordpress (and latest plugin version 2.4.4 and a latest phpbb version.
I carefully followed installation instructions and user synchronisation is OK and I have created template wp page following the doc

If I first connect to wordpress, all is working fine.
but if load the wordpress site without being logged and try to reach the forum page, it ends up with an infinite loop.
you can see it at https://my80isfantastic.com/leSite/forum/

Thanks in advance for your help

[TITLE EDITED]

Re: iframe integration infinite loop

Posted: Tue Dec 21, 2021 1:40 pm
by axew3
Hello.
Let me test things, i will be over in my evening to finish all and release new 2.4.5 (within 23-24 i assume) but also before if possible.
Going to fix this issue you report (and many other since long time) into iframe integration, within this night my time if the devil do not come out here.

Going to follow the integrations steps and reproduce. It is just a cookie/session problem. The page-forum require to be little fixed about this.
If any hint more on this or to detect more problems you noted, let me know please!
I'll return here in reply very soon...

[EDITED]

Re: iframe integration infinite loop

Posted: Tue Dec 21, 2021 1:54 pm
by madoma73
Hello,
I have read all posts about preloader loop and tried several things without success:
- modify line to have: jQuery(window).on(\"load\",function())
- comment: div id="w3_toogle_wrap_loader" class="w3_no_wrap_loader"><div class="w3_loader"></div></div>

but still no luck

Thanks in advance for the upcoming version, the work you are doing is amazing, btw, I have installed the phpbb extension, it works smoothly for now :-)

Re: iframe integration infinite loop

Posted: Tue Dec 21, 2021 10:45 pm
by axew3
The new updated phpBB wP extension will allow to add users into wordpress at same time (if option into the little ext file config activated)
And to redirect after login or autologin (if option activated)
It will come embedded into the plugin folder /addons but as before, it can be used also as standalone in phpBB.

About the iframe loop fix:
the problem was coming out due to latest (little crazy) addition about userid into overall_footer js code (so into page forum)
I am thinking to add this logic, in case, passing phpBB userid var, via the extension: it is very easy to do/add. While grabbing the value as i intended to do is not consistent. And leading to loops in certain cases.
I also noted unwanted and repeated js instructions into page-forum now removed (this is the code i will go to update now after some test more to (may) clean up and fix something else)

update page-forum with this into your active template folder
page-forum.zip
(5.25 KiB) Downloaded 153 times
then update the overall_footer.html code of phpBB (and set to recompile stale template phpBB option to make changes take effect)
with this:

Code: Select all

<script type="text/javascript">

// START MANDATORY CHANGES
document.domain = 'localhost'; // MANDATORY! // Set/Change this value to fit your domain (example: axew3.com (or leave localhost if on localhost)) 
var wordpress_url_page_forum = 'https://localhost/wp/forum'; // MANDATORY! // (DO NOT ADD/INCLUDE final slash here) Url that point to your iframed wordpress forum page
var w3all_custom_wp_w3fancyurl = 'w3'; // MANDATORY! If you changed w3 to have 'fancy URL' query string into WP plugin admin, then change this value to match what your choosed fancy URL setting is
// END MANDATORY CHANGES

var w3all_doc_domain = document.domain;
var w3allappend = false;
var boardU = "{BOARD_URL}";

// Lightbox scroll fix:
// remove /* and */ to activate, also more below to complete ...
/*
$(".postimage").on("click", function(event) {
var pos = event.pageY - 100;
 $(parent.window).scrollTop( 200 );
var el = document.getElementById("lightbox");
$("#lightboxOverlay").on("click", function() {
$(parent.window).scrollTop( pos );
});
$(".lb-close").on("click", function() {
$(parent.window).scrollTop( pos );
});
$(".lightbox").on("click", function() {
$(parent.window).scrollTop( pos );
});
});
*/
 
function w3allNormalize_phpBBUrl(href){
// try to 'normalize' passed relative links: needed all after last slash /
// exception are kind of passed urls like: /phpbb323/app.php/help/faq
// and if SEO mods that may assign some different kind of links values
// by the way, SEO absolute urls http(s) should be (all?) already considered here ...
var phpbbRUrl = href.split(/^.+?(\w+.+)$/);
if( href.indexOf('app.php') > -1 ){ // since the previous not 'normalize' this type of passed value (and may miss something else)
	 phpbburl = href.split(/^.+?(app\.php.+)$/);
	 w3allappend = phpbburl[1];
 } else if ( /^https?/ig.exec(href) !== null ){ // absolute http(s) passed: try to 'normalize' a possible seo mod
   phpbburl = href.split(boardU);
	 w3allappend = phpbburl[1];
 } else if ( phpbbRUrl[1] && phpbbRUrl[1].length > 1 ){ // 'normalize' any other
   w3allappend = phpbbRUrl[1];
 } else if ( phpbbRUrl[0].length > 1 ){
   w3allappend = phpbbRUrl[0];
   }
// ... if still not normalized
if(/^\W/ig.exec(w3allappend) !== null){
 	w3allappend = w3allappend.split(/^.+?(\w+.+)$/);
 	if(w3allappend[1]){
 		w3allappend = w3allappend[1];
 	}
 	if ( w3allappend[1] && w3allappend[1].charAt(0) == '/' ){
 		w3allappend = w3allappend[1].substr(1);
 	}
}
return w3allappend;
}
 
$(document).on("click", "a", function(e) {
  var href = $(this).attr("href"); 
  var w3all_onview_attach = (href.indexOf('file.php') > -1);

// really basic
if( this.getAttribute('target') !== null ){
  e.preventDefault();
  window.open(href,'_blank');
return;
}

if ( href.charAt(0) == '#' || href.indexOf('\./download\/file\.php') > -1 ){ return; }

// external link?
if ((this.href.indexOf(boardU) > -1) != true){
 if(/^(f|ht)tps?:\/\//i.test(href)){
	e.preventDefault();
	parent.location.replace(href);
 return;
 }
}

if ( href.indexOf('view=print') > -1 !== false || /\/adm\//ig.exec(href) !== null ){
 e.preventDefault();
 window.open(href,'_blank');
return;
}

if ( href.indexOf('quickmod') > -1 ) {
	 w3allNOappend = true;
  	return;
}

if( /posting\.php\?mode=[reply|post|bump]/ig.exec(href) !== null || /mcp\.php\?/ig.exec(href) !== null ){
	w3allNOappend = true;
}

// complete Lightbox correct attachment display // activate removing /* and */ 
// or used to open on new tab attachments
/*
if(w3all_onview_attach !== false){
e.preventDefault();
window.open(href,'_blank');
return;
} */

w3allappend = w3allNormalize_phpBBUrl(href);

if ('parentIFrame' in window){
  if( typeof w3allNOappend == 'undefined' || w3allNOappend == false ){
    window.parentIFrame.sendMessage(w3allappend);
  }
 }
});

$("#quickmod,.bookmark-link").on("click", function(event) {
var pos = event.pageY - 100;
  $(parent.window).scrollTop( 200 );
$("#darkenwrapper").on("click", function() {
  $(parent.window).scrollTop( pos );
});
 $("#darken").on("click", function() {
  $(parent.window).scrollTop( pos );
});
});

///////////////////////////////////////////////////////////////////////////
// w3all UPDATES for phpBB events
 
if(window.self !== window.top){
var pmn = "{PRIVATE_MESSAGE_COUNT}"; 
var w3all_phpbb_u_logged = "{S_USER_LOGGED_IN}"; 

var hash = window.location.hash.substr(1);

if( hash == 'unread' ){
 var postN = 1;
 $( "h3 > a" ).each(function (e) {
  ns = this.href.split('#p');
  if( typeof ns != 'undefined' && /viewtopic.php\?p=/ig.exec(this.href) != null ){
   if(ns[1] > postN){
     w3lh = ns[1];
    }
  }
 })

 if( typeof w3lh != 'undefined' ){
  hash = "p" + w3lh;
 }
}

  location.hash = "#" + hash;
  if( location.hash.length < 2 ){
  	var w3all_lochash = 0;
  } else {
  	var w3all_lochash = $(location.hash).offset().top;
  }

var w3appendevents = '#w3all_phpbbpmcount=' + pmn + '#w3all_phpbb_u_logged=' + w3all_phpbb_u_logged + '#w3all_lochash=' + w3all_lochash; 
//if(parent.location.href.indexOf(wordpress_url_page_forum) > -1){
if( typeof w3allNOappend == 'undefined' || w3allNOappend == false ){
$( window ).on( "load", function() {
parent.w3all_ajaxup_from_phpbb(w3appendevents); 
});
}
//}

// fix vertical iframe centered on certain cases
var w3iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
if(w3iOS == false){
$(window).on( "load", function() {
var bd = document.getElementsByTagName("body");
for (var i = 0; i < bd.length; i++) { 
    var bdID = bd[i].getAttribute("id"); 
}
var elt = document.getElementById(bdID);	
elt.setAttribute("style", "position:fixed;top:0%;left:0%;width:100%;margin:0px;");
});
}
 
/*$( "a" ).contextmenu(function() {
 var ohref = $(this).attr("href");
 var href = this.href; // treath like an external because only open New tab or New window
  d = w3allNormalize_phpBBUrl(href);
  hrefEnc = window.btoa(unescape(encodeURIComponent(d)));
  href1 =  wordpress_url_page_forum + '/?' + w3all_custom_wp_w3fancyurl + '=' + hrefEnc;  
    
  $(this).attr("href", href1); // send out encoded
  $(this).mouseleave(function() { // reset (replaced 'mouseup')
  $(this).attr("href", ohref);
  });
});*/
 
} // END if (window.frameElement) {
</script>
<script type="text/javascript" src="https://localhost/phpbb33/iframeResizer.contentWindow.min.js" defer></script>
NOTE that if the wordpress UID 1 is logged in wordpress, and the user ID 2 in phpBB is not logged in, when accessing the page-forum you'll get a loop again. And there is no way to fix this if not with what i said above.
This problem affect ONLY the user ID 1 in WP and phpBB user ID 2 (install admins excluded by the integration by cookies)

Re: iframe integration infinite loop

Posted: Wed Dec 22, 2021 7:39 am
by madoma73
Yeeah !
you are a master chief !

it works now.

Thanks

Pierre

Re: iframe integration infinite loop

Posted: Sat Dec 25, 2021 10:37 am
by axew3
Just to inform that the phpBB WordPress iframe integration

both page-forum.php and javascript code have been updated.

https://www.axew3.com/w3/2020/01/phpbb- ... iframe-v5/

It would be necessary just to substitute the overall_footer.html js code, and replace the page-forum(or whatever named).php into wp template folder, with the new one provided.
It clean up several crazy things on it. All is working here, but if any problem found, please report and it will be fixed.

The phpBB integration extension is ready.
The plugin code has been cleaned up about several things and after some test more 2.4.5 will be so released.