by axew3 » Tue Dec 21, 2021 10:45 pm
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
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)
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 [i]/addons[/i] but as before, it can be used also as standalone in phpBB.
[size=150]About the iframe loop fix:[/size]
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)
[b]update page-forum[/b] with this into your active template folder
[attachment=0]page-forum.zip[/attachment]
[b]then update the overall_footer.html[/b] code of phpBB (and set to recompile stale template phpBB option to make changes take effect)
with this:
[code]<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>[/code]
[size=150]NOTE[/size] 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)