htaccess trick for right click /copy/paste/ links
Posted: Sat Oct 13, 2018 2:56 pm
Hey Axe!
Did you remove the "htaccess trick for right click /copy/paste/ links" from the code that needs to be pasted into overall_footer.html?
Because with the new version of w3all wp it does not seem to be there.
Did you add another way to copy links within the iframed forum?
I used to have this code
Which seems to have been replaced with this?
Did you remove the "htaccess trick for right click /copy/paste/ links" from the code that needs to be pasted into overall_footer.html?
Because with the new version of w3all wp it does not seem to be there.
Did you add another way to copy links within the iframed forum?
I used to have this code
Code: Select all
///////////////////////////////////////////////////////////////////////////
// htaccess trick for right click /copy/paste/ links
// to apply htaccess rules and rewrite urls for this and email notification, please read this tutorial:
// https://www.axew3.com/w3/2017/04/wp_w3all-htaccess-javascript-rewrite-links-point-iframe-how-to/
// remove starting /* and ending */
// that wrap the code here below to activate
// remove this line to activate click /copy/paste/ links x htaccess
$( "a" ).contextmenu(function() {
var href = $(this).attr("href");
var shortlink = /^#p[0-9]+/ig.exec(href);
var ck = (href.indexOf('iframe=true') > -1);
var ckl = /^(http[s]?:\/\/[-a-z0-9\.]+)/ig.exec(href); // check if link point to external resource: a passed phpBB url (attr("href")) is relative, not absolute: so we assume that if http(s) is present,
// than it should be a link that point to an external iframe resource. Can be improved further more using this same pattern result.
// for app.php url type
var ckApp = (href.indexOf('app.php/') > -1);
if ( ckApp == true ){
var hrefApp = href.split('app.php/');
var hA = hrefApp[0] + 'app.php/iframe=true/' + hrefApp[1];
$(this).attr("href", hA); // send out before mouseup ...
//http://rng.clanroyal.dk/forums/app.php/iframe=true/applicationform
}
else if ( ck == false && ckl == null && shortlink == null ){ // not re-append // not append if short link like #p49 (link of the post on viewtopic) or passed link point to an external resource
var href0 = href.split('?');
if(href0[1] == null){ href0[1] = ''; } else { href0[1] = '&' + href0[1]; }
var href1 = href0[0] + '?iframe=true' + href0[1];
$(this).attr("href", href1); // send out before mouseup ...
}
});
$( "a" ).mouseup(function() { // but remove on mouseup, or leaving iframe=true we'll loop with htaccess ...
var href = $(this).attr("href");
var ck0 = (href.indexOf('iframe=true/') > -1);
if ( ck0 == true ){
$(this).attr("href", href.replace('iframe=true/', ''));
} else {
$(this).attr("href", href.replace('iframe=true&', ''));
}
});
Code: Select all
// htaccess isn't needed anymore
$( "a" ).contextmenu(function() {
var href = $(this).attr("href");
var ohref = href;
var applink = /app\.php[\w\/]+/ig.exec(href);
var ckext = /^(f|ht)tps?:\/\//i.test(href); // external resource url?
var ffile = '';
var shortinp = /^#[a-z][0-9]+$/ig.exec(href);
var shortfaq = /^#[a-z][a-z0-9]+$/ig.exec(href);
var hrefu = document.location.href;
if ( href.charAt(0) == '.' && href.charAt(1) == '/' ){
ffile = ohref;
} else {
pu = href.split('app.php');
ffile = './app.php' + pu[1];
}
if( shortinp != null ){
ffile = './' + hrefu.split('\\').pop().split('/').pop();
}
if( shortfaq != null && href.charAt(1) != 'p'){
pu = hrefu.split('app.php');
ffile = './app.php' + pu[1] + shortfaq;
}
var d = ffile;
if( href.length < 2 ){ // #
d = document.location.href;
}
hrefEnc = window.btoa(unescape(encodeURIComponent(d)));
href1 = wordpress_url_page_forum + '/?w3=' + hrefEnc;
if( ckext != false ){ // external Url
href1 = ohref;
}
$(this).attr("href", href1); // send out encoded
$(this).mouseout(function() { // reset
$(this).attr("href", ohref);
});
});