Another problem with "onlyto"...
4 posters
Page 1 of 1
Another problem with "onlyto"...
przepraszam za bycie utrapieniem.
Another problem with this code:
All users can see onlyto, if they just use "quote". Even if I hide button for quote, it's simple to get around it.

- Code:
/*
* Application: Create New BBCode Tags
* Date: 18/05/2018
* Version: 1.321052018
* Copyright (c) 2018 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
(function() {
BBParser = {
initialize: function() {
$(function() {
BBParser.setupBBParser();
});
},
add: [
/*
* Note: Add a comma at the end of each new entry
* '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
*/
{
tag: 'success',
close: true,
replacement: '<div class="notice notice-success"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'warn',
close: true,
replacement: '<div class="notice notice-warn"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'info',
close: true,
replacement: '<div class="notice notice-info"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'alert',
close: true,
replacement: '<div class="notice notice-alert"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'onlyto',
close: true,
replacement: '<div class="onlyto">{content}</div>',
replace: function(option, content) {
var myArray = new Array();
// this will return an array with strings "1", "2", etc.
if(option) {
myArray = option.split(",").map(function(el) {
return el.trim();
});
}
if ($.inArray(_userdata.username, myArray) == -1 && _userdata.user_level != 1 && _userdata.user_level != 2) {
return 'Only ' + ( myArray.length ? myArray.join(", ").replace(/,([^,]*)$/, ' and $1', ' and $2', ' and $3') : 'Administrator and Moderator' ) + ' can view this message';
return content;
} else if (_userdata.user_level !== 1 && _userdata.user_level !== 2) {
return content;
}
}
}
// Note: Do not add a comma at the end of the last entry
],
// Do not change anything down
validateTag: function(a) {
if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
},
replacers: function(a, b, c) {
return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
},
optionReg: /.*?=("|'|)(.*?)\1\]/,
parsedContent: function(a, b, c) {
return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
c || (e = d);
e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
if("undefined" !== typeof b.replace) {
d = c ? b.replace(e, f) : b.replace(e);
"string" === typeof d ? c ? f = d : e = d : d;
"object" === typeof d && (e = d.option || e, f = d.content || f);
}
return BBParser.replacers(b.replacement, e, f);
});
},
setupBBParser: function() {
var postBody = $(".postbody, .blog_message");
for (var i = 0, e;(e = postBody[i++]);) {
for (var j in BBParser.add) {
var item = BBParser.add[j];
// Validating tag
BBParser.validateTag(item.tag);
e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
}
}
}
};
BBParser.initialize();
})();
All users can see onlyto, if they just use "quote". Even if I hide button for quote, it's simple to get around it.
Last edited by Sn0w on April 8th 2020, 7:52 pm; edited 1 time in total
Re: Another problem with "onlyto"...
Hey @Sn0w,
So, i'm sorry, if i don't catch that. Well, if you use:
- pedxz
So, i'm sorry, if i don't catch that. Well, if you use:
- Code:
[quote][onlyto=pedxz]qweasdzxc[/onlyto][/quote]
- pedxz
Re: Another problem with "onlyto"...
Hi
Don't forget it's javascript. You'll never have a 100% safe script since this is user itself who chooses if he runs or not the scripts.
Don't forget it's javascript. You'll never have a 100% safe script since this is user itself who chooses if he runs or not the scripts.
Re: Another problem with "onlyto"...
@pedxz
Nah, I mean that if you quote a message with "onlyto", you can seen content as a code. So, it's not hide at all.
@Neptune-
Is there any language code other than java, that would let avoid this problem? Of course, which I could use on forumotion. I saw page where "similar code" worked without any problem like: "quote to see content in onlyto". So, hence my question.
If it possible that, in future that administrators of forumotion will add "hide" where you can mentioning which user is see content?
It is after all standard "hide" so...
Nah, I mean that if you quote a message with "onlyto", you can seen content as a code. So, it's not hide at all.
@Neptune-
Is there any language code other than java, that would let avoid this problem? Of course, which I could use on forumotion. I saw page where "similar code" worked without any problem like: "quote to see content in onlyto". So, hence my question.
If it possible that, in future that administrators of forumotion will add "hide" where you can mentioning which user is see content?
It is after all standard "hide" so...
Re: Another problem with "onlyto"...
@pedxz
before quote:

After:

just use
before quote:

After:

just use
- Code:
http://forumadress.pl/post?p=NUMBER OF POST&mode=quote
Re: Another problem with "onlyto"...
Sn0w wrote:Is there any language code other than java, that would let avoid this problem? Of course, which I could use on forumotion. I saw page where "similar code" worked without any problem like: "quote to see content in onlyto". So, hence my question.
All languages based on server-side, which means nothing on Forumotion since you do not have access to servers.
The only way to keep a message being readable by chosen members is Private Messaging
Of course it is possible, but with all suggestions made so far, i dont think this will be added one day.If it possible that, in future that administrators of forumotion will add "hide" where you can mentioning which user is see content?
It is after all standard "hide" so...
A public subject is not the place to write private things and as it's already possible to send private messages, i really doubt FM would add it to chatbox or to topics
Re: Another problem with "onlyto"...
Sn0w wrote:just useAnd you see the content.
- Code:
http://forumadress.pl/post?p=NUMBER OF POST&mode=quote
It is the only solution i found, change your code to:
- Code:
/*
* Application: Create New BBCode Tags
* Date: 18/05/2018
* Version: 1.321052018
* Copyright (c) 2018 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
(function() {
BBParser = {
initialize: function() {
$(function() {
BBParser.setupBBParser();
});
},
add: [
/*
* Note: Add a comma at the end of each new entry
* '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
*/
{
tag: 'success',
close: true,
replacement: '<div class="notice notice-success"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'warn',
close: true,
replacement: '<div class="notice notice-warn"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'info',
close: true,
replacement: '<div class="notice notice-info"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'alert',
close: true,
replacement: '<div class="notice notice-alert"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'onlyto',
close: true,
replacement: '<div class="onlyto">{content}</div>',
replace: function(option, content) {
var myArray = new Array();
// this will return an array with strings "1", "2", etc.
if(option) {
myArray = option.split(",").map(function(el) {
return el.trim();
});
}
if ($.inArray(_userdata.username, myArray) == -1 && _userdata.user_level != 1 && _userdata.user_level != 2) {
return 'Only ' + ( myArray.length ? myArray.join(", ").replace(/,([^,]*)$/, ' and $1', ' and $2', ' and $3') : 'Administrator and Moderator' ) + ' can view this message';
return content;
} else if (_userdata.user_level !== 1 && _userdata.user_level !== 2) {
return content;
}
}
}
// Note: Do not add a comma at the end of the last entry
],
// Do not change anything down
validateTag: function(a) {
if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
},
replacers: function(a, b, c) {
return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
},
optionReg: /.*?=("|'|)(.*?)\1\]/,
parsedContent: function(a, b, c) {
return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
c || (e = d);
e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
if("undefined" !== typeof b.replace) {
d = c ? b.replace(e, f) : b.replace(e);
"string" === typeof d ? c ? f = d : e = d : d;
"object" === typeof d && (e = d.option || e, f = d.content || f);
}
return BBParser.replacers(b.replacement, e, f);
});
},
setupBBParser: function() {
var postBody = $(".postbody, .blog_message, .post-content, #text_editor_textarea");
for (var i = 0, e;(e = postBody[i++]);) {
for (var j in BBParser.add) {
var item = BBParser.add[j];
// Validating tag
BBParser.validateTag(item.tag);
e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
}
}
}
};
BBParser.initialize();
})();
Re: Another problem with "onlyto"...
Solved! Really thanks.pedxz wrote:Sn0w wrote:just useAnd you see the content.
- Code:
http://forumadress.pl/post?p=NUMBER OF POST&mode=quote
It is the only solution i found, change your code to:
- Code:
/*
* Application: Create New BBCode Tags
* Date: 18/05/2018
* Version: 1.321052018
* Copyright (c) 2018 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
(function() {
BBParser = {
initialize: function() {
$(function() {
BBParser.setupBBParser();
});
},
add: [
/*
* Note: Add a comma at the end of each new entry
* '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
*/
{
tag: 'success',
close: true,
replacement: '<div class="notice notice-success"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'warn',
close: true,
replacement: '<div class="notice notice-warn"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'info',
close: true,
replacement: '<div class="notice notice-info"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'alert',
close: true,
replacement: '<div class="notice notice-alert"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'onlyto',
close: true,
replacement: '<div class="onlyto">{content}</div>',
replace: function(option, content) {
var myArray = new Array();
// this will return an array with strings "1", "2", etc.
if(option) {
myArray = option.split(",").map(function(el) {
return el.trim();
});
}
if ($.inArray(_userdata.username, myArray) == -1 && _userdata.user_level != 1 && _userdata.user_level != 2) {
return 'Only ' + ( myArray.length ? myArray.join(", ").replace(/,([^,]*)$/, ' and $1', ' and $2', ' and $3') : 'Administrator and Moderator' ) + ' can view this message';
return content;
} else if (_userdata.user_level !== 1 && _userdata.user_level !== 2) {
return content;
}
}
}
// Note: Do not add a comma at the end of the last entry
],
// Do not change anything down
validateTag: function(a) {
if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
},
replacers: function(a, b, c) {
return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
},
optionReg: /.*?=("|'|)(.*?)\1\]/,
parsedContent: function(a, b, c) {
return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
c || (e = d);
e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
if("undefined" !== typeof b.replace) {
d = c ? b.replace(e, f) : b.replace(e);
"string" === typeof d ? c ? f = d : e = d : d;
"object" === typeof d && (e = d.option || e, f = d.content || f);
}
return BBParser.replacers(b.replacement, e, f);
});
},
setupBBParser: function() {
var postBody = $(".postbody, .blog_message, .post-content, #text_editor_textarea");
for (var i = 0, e;(e = postBody[i++]);) {
for (var j in BBParser.add) {
var item = BBParser.add[j];
// Validating tag
BBParser.validateTag(item.tag);
e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
}
}
}
};
BBParser.initialize();
})();When quote (or in editor), custom BBCode it will be automatically converted to HTML - can be a problem


Re: Another problem with "onlyto"...
Problem solved & topic archived.
|

» Problem with "onlyto"
» Link Color Problem / Titles Problem / and search problem
» Adding chatbox rules problem and background of announcements problem
» Founder: Kind of a password problem, mostly an e-mail problem
» Hierarchy problem + Whos online problem
» Link Color Problem / Titles Problem / and search problem
» Adding chatbox rules problem and background of announcements problem
» Founder: Kind of a password problem, mostly an e-mail problem
» Hierarchy problem + Whos online problem
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum