Manage BB Code functions from your AdminCP. These can be internal PHP functions, or custom (derived from a specified PHP file).
Apply a BB Code function to a custom BB Code tag, and you can use it (when the correct arguments are provided) in posts, etc.
You may choose for a function to be static, or update everytime upon page refresh. If it's static, the first time a function is called the value returned will be replaced with the tag in the post (hard-coded).
Known bugs
One must have posted in the WYSIWYG editor in order for function tags that are unchecked for "update upon page refresh" to work correctly. This is an annoying bug I discovered an hour from releasing this hack, and it will prevent functions tags from being replaced with their return values (hard-coded) in the post. It's only significant if you are using a function that returns a random/dynamic value, and wish not for the value to be updated upon page refresh, but stay unique. I will be looking into a solution when I have the time.
Know of another? Please PM me of it, or post it in the thread.
Notes
This script can only be maliciously taken advantage of if you provide functions that access your server. For example, don't create a custom function that queries your database and returns something. A user could place 100 of these tags into a post, and it would make 100 queries. Even worse, if the "update upon refresh" is enabled, it'll call 100 queries for every view of the page. Especially don't create functions that manipulate data on your server or in your database!
Everything is at your risk, but I implore you to stick with simple functions.
More important notes inside install.html.
Screenshots
See attachments.
Enjoy. Remember to click install if you do use this hack.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
wcbryant, I understand what you're trying to do, but I don't think this hack serves the purpose. (unless my interpretation is wrong, and mudpyr8 is closer to your question)
Quote:
One control that might be necessary is the ability to prohibit the use of a particular code in a signature. BBCodes are normally allowed in signatures, but someone who puts [power] into their sig, or [roll]50d1000[/roll] could generate a lot of server activity. If this isn't possible, the admin will just have to watch for such sigs, but it is important to note that. 100 people with factorials in their sigs is gonna be bad.
In the case you have a server-extensive function, it would. If you have the feature for not calling a function every time upon page refresh (although there is a bug right now where you must post in the WYSIWYG editor for this to apply) then it wouldn't be that big of a deal.
I will look into disabling it for signatures, as well fixing that bug, over the weekend.
wcbryant, I understand what you're trying to do, but I don't think this hack serves the purpose. (unless my interpretation is wrong, and mudpyr8 is closer to your question)
My explanation was convoluted at best, but despite that I think you both understood. I've looked at the hack some more, and while I think it walks a line very near to what I want to do -- may even be able to function loosely in that capacity in the manner mudpyr8 suggested -- it's probably not the 'right' approach. Which might be somehow just adding a 'no text copy' flag to the Additional Options field when posting.
You can turn off 'email to a friend' or 'printer friendly format' in threads, all I want to be able to do is turn off user's ability to copy and paste. Disable text highlighting (not that I think the JS I found does that), and disable right clicking. Again, I understand people can always just view source, but my goal is the prevention of accidental leaks, rather than intentional/malicious ones.
VeloCD, thanks. I got it working and it is superb. A couple of things:
1. In your install notes, steps 49 & 50 refer to 'allowsmilie". It should be 'allowsmilies'.
2. It reevaluates on edit of the message. It would be nice if this could be disabled. For my dice roller, I only want it to roll once. Not a big deal since when rolling dice it is a faux pas to edit your post anyway.
3. It only accepts one instance of the code (the last one). If I put two [roll] tags in one message, it only evaluates the last one.
2. If you are using the WYSIWYG editor and have the update option disabled, it shouldn't do so, since the return value of the function is hard-coded into the post. But, I haven't had time to look into making the update work for non-WYSIWYG.
3. That's odd. I'll check this out, although it should evaluate all tags. If you place two custom BB Code function tags that aren't your roll function, say maybe [random], does this generate two random values?
I have installed this hack so far since I was looking for something that enables me to use php functions in bbcodes...
But I'm fiddling around and it's not working....
Here's the function to include:
PHP Code:
<?php
// ###################### Start fetch_countdown_timer ######################
// returns the time left untill $dateline
function fetch_countdown_timer($dateline) {
Now I added a function like this:
Title: countdown
Handle: fetch_countdown_timer
Include File: countdown.php (containing above code)
Also I added a bbcode 'countdown' and have choosen the function in there....
It's just not working, what am I doing wrong?
As an example I used
[countdown]03, July 2004[/countdown] and the function returns something like -13h -40m instead of 11d and something....
How do I pass the date of interest to the function?
OK, I'm those of those guys that hated math classes in school.... besides the mathematical functions, what are some other uses that you guys have come up with?