The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Another problem with "onlyto"...

4 posters

Go down

Solved Another problem with "onlyto"...

Post by Sn0w April 8th 2020, 7:46 am

przepraszam za bycie utrapieniem.  Shit Another problem with this code:
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();
})();
Still big thanks for @pedxz and @Deamon

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
Sn0w
Sn0w
New Member

Posts : 21
Reputation : 1
Language : English, Polish

http://wonderful-world.forumpolish.com

Back to top Go down

Solved Re: Another problem with "onlyto"...

Post by tikky April 8th 2020, 11:23 am

Hey @Sn0w,

So, i'm sorry, if i don't catch that. Well, if you use:
Code:
[quote][onlyto=pedxz]qweasdzxc[/onlyto][/quote]
It doesn't work?

- pedxz
tikky
tikky
Forumember

Posts : 856
Reputation : 155
Language : 🇵🇹

https://www.forumotion.com/create-forum/modernbb

Back to top Go down

Solved Re: Another problem with "onlyto"...

Post by Neptune- April 8th 2020, 11:25 am

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.
Neptune-
Neptune-
Forumember

Female Posts : 496
Reputation : 104
Language : French (10), English (8), CSS (5), HTML (4), Javascript (4)
Location : Scotland, UK

https://www.galaxie-series.net/

Back to top Go down

Solved Re: Another problem with "onlyto"...

Post by Sn0w April 8th 2020, 11:48 am

@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...
Sn0w
Sn0w
New Member

Posts : 21
Reputation : 1
Language : English, Polish

http://wonderful-world.forumpolish.com

Back to top Go down

Solved Re: Another problem with "onlyto"...

Post by tikky April 8th 2020, 12:08 pm

Strange, to me is working:

Another problem with "onlyto"...  Img_2071




PHP but is not yet supported for the use of administrators. Maybe one day they will have a system of Plugins :/
tikky
tikky
Forumember

Posts : 856
Reputation : 155
Language : 🇵🇹

https://www.forumotion.com/create-forum/modernbb

Back to top Go down

Solved Re: Another problem with "onlyto"...

Post by Sn0w April 8th 2020, 12:17 pm

@pedxz
before quote:
Another problem with "onlyto"...  Cdm5eAw
After:
Another problem with "onlyto"...  Qg3uB7J

just use
Code:
http://forumadress.pl/post?p=NUMBER OF POST&mode=quote
And you see the content.
Sn0w
Sn0w
New Member

Posts : 21
Reputation : 1
Language : English, Polish

http://wonderful-world.forumpolish.com

Back to top Go down

Solved Re: Another problem with "onlyto"...

Post by Neptune- April 8th 2020, 2:00 pm

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

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...
Of course it is possible, but with all suggestions made so far, i dont think this will be added one day.
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
Neptune-
Neptune-
Forumember

Female Posts : 496
Reputation : 104
Language : French (10), English (8), CSS (5), HTML (4), Javascript (4)
Location : Scotland, UK

https://www.galaxie-series.net/

Back to top Go down

Solved Re: Another problem with "onlyto"...

Post by tikky April 8th 2020, 7:06 pm

Sn0w wrote:just use
Code:
http://forumadress.pl/post?p=NUMBER OF POST&mode=quote
And you see the content.

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
tikky
tikky
Forumember

Posts : 856
Reputation : 155
Language : 🇵🇹

https://www.forumotion.com/create-forum/modernbb

Back to top Go down

Solved Re: Another problem with "onlyto"...

Post by Sn0w April 8th 2020, 7:52 pm

pedxz wrote:
Sn0w wrote:just use
Code:
http://forumadress.pl/post?p=NUMBER OF POST&mode=quote
And you see the content.

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
Solved! Really thanks. For you I hope that there will be no problem with this code anymore. Very Happy
Sn0w
Sn0w
New Member

Posts : 21
Reputation : 1
Language : English, Polish

http://wonderful-world.forumpolish.com

Back to top Go down

Solved Re: Another problem with "onlyto"...

Post by skouliki April 8th 2020, 7:54 pm

Problem solved & topic archived.
Please read our forum rules: ESF General Rules
skouliki
skouliki
Manager
Manager

Female Posts : 14217
Reputation : 1635
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum