|
Page 1 of 1
|
Xusqui 
Joined: August 2006
Posts: 211
Location:  C?rdoba
|
 Idea With Bbcodes
Hile, neighbours and friends!!!
Since I have installed a couple of complex bbcodes for phpBBXS, i've noticed that the forum is slower, although the code is inside an "if/else" block and it is suposed not to be parsed everytime...
But the fact is that I have noticed a slow down when reading posts or entering the home page.
So I've had an idea which I don't know if it is possible. I've tried myself without result.
I wanted to take all the code for bbcodes outside the bbcode.php and make independent files for each one, ie:
a file called "/includes/bbcodes/hr.php" with the following code:
- <?php
- if ( !defined('IN_PHPBB') )
- {
- die("Hacking attempt");
- }
- $extras = $this->allow_styling ? array('style', 'class') : array();
- if(isset($item['params']['param']))
- {
- $color = $item['params']['param'];
- }
- elseif(isset($item['params']['color']))
- {
- $color = $item['params']['color'];
- }
- $color = $this->valid_color($color);
- if($color === false)
- {
- $html = '<' . $tag . ' />';
- }
- else
- {
- $html = '<' . $tag . ' color="' . $color . '" />';
- }
- return array(
- 'valid' => true,
- 'html' => $html
- );
- ?>
And modify the bbcode.php in order to include that file when de hr bbcode is invoked. Something like this.
-
- // Single tags: HR
- if($tag === 'hr')
- {
- include_once ('./includes/bbcodes/hr.php');
- }
I've tried this way with the hr bbcode but it's not parsed
I've tried also by making $html global but no way.
I've thought this could be a good idea because in one modification you'll save more than 2000 codelines in my case or more than 1500 in a standard bbcode.php
Could this be a good idea or is it only another lost of time made in Xusqui
Thnx!!
____________ Icy Phoenix Latest 2.0 (working pending)
Style: Aphrodite and MG_Themes
Site: Spanish Stephen King fan forum
Mods: Medal System Mod. BBAntispam 1.2. Several own BBcodes.
|
#1 Sun 03 Sep, 2006 08:57 |
|
Sponsors

|
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.
|
|
moreteavicar
Joined: August 2006
Posts: 608
Location:  Classified
|
 Re: Idea With Bbcodes
I was almost going to say that perhaps you could define each one as a class... but you would either have them all in one file, then include that, which would defeat the purpose of what you're tring to do...
I think for this to work, you would need to encase the code within a function, in each file, inorder for it to parse variables to the main bbcode.php...
Saying that, I don't even understand the bbcode implementation in XS yet... I'm trying to get a variant of the you bbcode working... but the XS system is very confusing. It looks like the only way to get it to work is if I put this somewhere in bbcode.php:
- /////////////////////// You code///////////////////////
- function youbbcode($text)
- {
- global $userdata, $item;
- $item['you'] = str_replace('{YOU}', "'" . $userdata['username'] . "'", $item['you']);
- $patterns = array();
- $replacements = array();
- $patterns[] = "#[you]#ise";
- $replacements[] = $item['you'];
- $text = preg_replace($patterns, $replacements, $text);
- $text = substr($text, 1);
-
- // Remove our padding from the string..
- $text = substr($text, 1);
- return $text;
-
- }
-
- /////////////////////// End of youbbcode ///////////////////////
And put
<!-- BEGIN you -->{YOU}<!-- END you -->
in bbcode.tpl
But this doesn't work! Maybe its something simple like how $item is defined...
|
#2 Mon 18 Sep, 2006 03:26 |
|
Xusqui 
Joined: August 2006
Posts: 211
Location:  C?rdoba
|
 Respuesta: Idea With Bbcodes
I have you bbcode working for XS...
I have this code in the $allowed_bbcode array:
'you' => array(
'nested' => false,
'inurl' => false,
'allow_empty' => true,
),
And this is de code in the process_tag($item) function:
if($tag === 'you')
{
if($this->is_sig)
{
return $error;
}
if($item['iteration'] > 1)
{
return $error;
}
global $userdata;
$extras = $this->allow_styling ? array('style', 'class') : array();
$str = '<span ' . $this->add_extras($item['params'], $extras) . '>' . $userdata['username'];
return array(
'valid' => true,
'start' => $str,
'end' => '</span>'
);
}
is that what you mean?
____________ Icy Phoenix Latest 2.0 (working pending)
Style: Aphrodite and MG_Themes
Site: Spanish Stephen King fan forum
Mods: Medal System Mod. BBAntispam 1.2. Several own BBcodes.
|
#3 Mon 18 Sep, 2006 21:57 |
|
moreteavicar
Joined: August 2006
Posts: 608
Location:  Classified
|
 Re: Idea With Bbcodes
Dude! Everyday I like you more and more! One thing though, I tried something like this to start with, and couldn't get it to work... now I just tried this, but still can't seem to get it to work... although it looks right to me, better than my intial attempt before the function in the last post.
Did you definitely have Quote: <!-- BEGIN you -->{YOU}<!-- END you -->
in bbcode.tpl?
On topic... I have a feeling that you will lose more than you gain by having a load of individual files for the bbcode functions... mainly because the time it takes to access a file is limited by the access time of the hard drives, the data transfer itself being comparable whether a small file or slightly bigger file with them all in (which is still tiny for a server). Much better just to cache them in a single file, in RAM, which should happen on a server anyway... I think...
I am suprised that adding some bbcode managed to slow the site noticebly - like in my post r.e. phpbb security, theres so much other stuff going on with a server, that its not always straightforward to relate a sudden decrease in speed with having just installed a bit of code... unless that bit of code is a real resource hog. That should be obvious though, if it makes enquires to SQL, along with the type of enquires it makes to the database... for that reason, search.php (besides site statistics, which could be regarded as a specific search routine) is one of the biggest SQL hoggers, but naturally (and fortunately) it is not executed unless you want to make a search.... Or if not SQL... mathematical operations... e.g. if it performs some image compression algorithm.... What on earth were these BBcodes?
|
#4 Wed 20 Sep, 2006 18:38 |
|
Xusqui 
Joined: August 2006
Posts: 211
Location:  C?rdoba
|
 Respuesta: Idea With Bbcodes
Nop... I don't have such a line in bbcode.tpl
BTW... The way of using you mod is:
Hello, [you /]. How are you?
Hello, [you style="color: red" /]. How are you?
Hello, [you][/you]. How are you?
Hello, [you style="color: #f00; font-weight: bold;"][/you]. How are you?
Hello, [you class="you-class"][/you]. How are you?
Maybe you tried the wrong way tu use de bbcode...
On topic... Well Probably you are right... You mean that the time to access and read 3 small files is greater than the time to access and read 1 bigger file... I didn't thought about that... But probably you are right!!!
One of those bbcodes, which is really cool, really make mathematical operations through transform the given text in an image, parsing the text to a perl program... Or even a given formula in the mathematical representation of that formula... Is that one called [tex] I use it to display my email: [tex]me@mydomain.com[/tex] and the web shows an image with my email... That's cool!!! You can see the ones I have installed with another bbcode called "[version]", if you write [version] in a post and preview it, the whole list of bbcodes and an explanation for each one is displayed!! Is very usefull, I think!!
Thanks!!!!
____________ Icy Phoenix Latest 2.0 (working pending)
Style: Aphrodite and MG_Themes
Site: Spanish Stephen King fan forum
Mods: Medal System Mod. BBAntispam 1.2. Several own BBcodes.
|
#5 Wed 20 Sep, 2006 20:27 |
|
moreteavicar
Joined: August 2006
Posts: 608
Location:  Classified
|
 Re: Idea With Bbcodes
Ah... I see now...
I also see that for [you /] to work properly, you have to disable the pre-compile posts mod!
Conversion to a tex document - brilliant!... I thought I saw a php mod somewhere to do that... but haven't been able to find it again... I know theres a discussion on phpbb about doing it in php , but that one depends on latex being installed on the server... I haven't checked with my host about that yet... and unfortunately I don't have pearl access to do it. Would be really nice to have though, as my site is for physics students (both undergraduate and graduate students)... who naturally would like to use tex for writing equations...
Maybe theres a lot of people viewing posts with it in, which is slowing it down... in which case maybe precompiled pages are the answer (at the expense of the you function... unless you could put a hack in the percompile mod to ignore certain bbcodes...)...
|
#6 Fri 22 Sep, 2006 00:47 |
|
Mighty Gorgon 
Luca Libralato
Joined: August 2006
Posts: 7192
Location:  Borgo San Michele
|
 Re: Idea With Bbcodes
Nop... I don't have such a line in bbcode.tpl
bbcode.tpl it's not used by XS, you can remove that file...
One of those bbcodes, which is really cool, really make mathematical operations through transform the given text in an image, parsing the text to a perl program... Or even a given formula in the mathematical representation of that formula... Is that one called [tex] I use it to display my email: [tex]me@mydomain.com[/tex] and the web shows an image with my email... That's cool!!! You can see the ones I have installed with another bbcode called "[version]", if you write [version] in a post and preview it, the whole list of bbcodes and an explanation for each one is displayed!! Is very usefull, I think!!
Thanks!!!!
Conversion to a tex document - brilliant!... I thought I saw a php mod somewhere to do that... but haven't been able to find it again... I know theres a discussion on phpbb about doing it in php , but that one depends on latex being installed on the server... I haven't checked with my host about that yet... and unfortunately I don't have pearl access to do it. Would be really nice to have though, as my site is for physics students (both undergraduate and graduate students)... who naturally would like to use tex for writing equations...
Maybe theres a lot of people viewing posts with it in, which is slowing it down... in which case maybe precompiled pages are the answer (at the expense of the you function... unless you could put a hack in the percompile mod to ignore certain bbcodes...)...
Tex was implemented in XS some months ago by Bicet... the BBCode is already there, but you will need the PERL script to let this works correctly... I should have the library somewhere. We didn't add this to XS because Pearl is required... plus the Tex Library should be compiled for the server you are using, so it's not so easy to be used...
Try to search the web for this library, you should find it, and then you may be able to install it for XS.
____________ Luca
SEARCH is the quickest way to get support.
Icy Phoenix ColorizeIt - CustomIcy - HON
|
#7 Sun 24 Sep, 2006 15:50 |
|
Xusqui 
Joined: August 2006
Posts: 211
Location:  C?rdoba
|
 Respuesta: Idea With Bbcodes
Tex was implemented in XS some months ago by Bicet... the BBCode is already there, but you will need the PERL script to let this works correctly... I should have the library somewhere. We didn't add this to XS because Pearl is required... plus the Tex Library should be compiled for the server you are using, so it's not so easy to be used...
Try to search the web for this library, you should find it, and then you may be able to install it for XS.
Yes, you're right, MG... I downloaded the mimetex library from here, compiled it in my server and gave execution permissions... It's required a medium level to install that bbcode
____________ Icy Phoenix Latest 2.0 (working pending)
Style: Aphrodite and MG_Themes
Site: Spanish Stephen King fan forum
Mods: Medal System Mod. BBAntispam 1.2. Several own BBcodes.
|
#8 Sun 24 Sep, 2006 17:26 |
|
moreteavicar
Joined: August 2006
Posts: 608
Location:  Classified
|
 Re: Idea With Bbcodes
If thats the way, I'm doomed... my host barely lets me run php... I just found out they don't allow .htaccess... so to even have perl... did I ever tell you how easy it is to extract blood from a stone?
It would be really nice if the same scripts existed in php as well as perl... maybe the perl scripts can be re-worked into php...? Or are the server side dependencies such that they can't be replicated in php?
|
#9 Sun 24 Sep, 2006 20:09 |
|
Xusqui 
Joined: August 2006
Posts: 211
Location:  C?rdoba
|
 Respuesta: Idea With Bbcodes
I don't know, morete!!!!
As I don't know a word in perl programming nor in php, I don't know if it could be adapted!!! Anyway you can ask in the support forum of mimetex (see previous post)
Greetz!!!
____________ Icy Phoenix Latest 2.0 (working pending)
Style: Aphrodite and MG_Themes
Site: Spanish Stephen King fan forum
Mods: Medal System Mod. BBAntispam 1.2. Several own BBcodes.
|
#10 Sun 24 Sep, 2006 20:22 |
|
|
Page 1 of 1
|
Was this topic useful?
Was this topic useful?
Link this topic |
URL |
|
BBCode |
|
HTML |
|
You cannot post new topics You cannot reply to topics You cannot edit your posts You cannot delete your posts You cannot vote in polls You cannot attach files You can download files You cannot post calendar events
|
|
|
|