Icy Phoenix

     
 


Post new topic  This topic is locked: you cannot edit posts or make replies. 
Page 1 of 1
 
 
Reply with quote Download Post 
Post 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:
Code: [Download] [Hide]
  1. <?php  
  2. if ( !defined('IN_PHPBB') )  
  3. {  
  4.     die("Hacking attempt");  
  5. }  
  6.             $extras = $this->allow_styling ? array('style', 'class') : array();  
  7.             if(isset($item['params']['param']))  
  8.             {  
  9.                 $color = $item['params']['param'];  
  10.             }  
  11.             elseif(isset($item['params']['color']))  
  12.             {  
  13.                 $color = $item['params']['color'];  
  14.             }  
  15.             $color = $this->valid_color($color);  
  16.             if($color === false)  
  17.             {  
  18.                 $html = '<' . $tag . ' />';  
  19.             }  
  20.             else  
  21.             {  
  22.                 $html = '<' . $tag . ' color="' . $color . '" />';  
  23.             }  
  24.             return array(  
  25.                 'valid' => true,  
  26.                 'html' => $html  
  27.             );  
  28. ?> 


And modify the bbcode.php in order to include that file when de hr bbcode is invoked. Something like this.

Code: [Download] [Hide]
  1.           
  2. // Single tags: HR  
  3. if($tag === 'hr')  
  4. {  
  5.      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.
 
XusquiSend private messageVisit poster's website  
Back to topPage bottom
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.

Support us
 
Reply with quote Download Post 
Post 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:

Code: [Download] [Hide]
  1. /////////////////////// You code///////////////////////  
  2. function youbbcode($text)  
  3. {  
  4.          global $userdata, $item;  
  5.           $item['you'] = str_replace('{YOU}', "'" . $userdata['username'] . "'", $item['you']);  
  6.                          $patterns = array();  
  7.                          $replacements = array();  
  8.                          $patterns[] = "#[you]#ise";  
  9.                          $replacements[] = $item['you'];  
  10.                  $text = preg_replace($patterns, $replacements, $text);  
  11.                              $text = substr($text, 1);  
  12.  
  13.                      // Remove our padding from the string..  
  14.                      $text = substr($text, 1);  
  15.                         return $text;  
  16.  
  17. }  
  18.  
  19. /////////////////////// 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...
 



 
moreteavicarSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Respuesta: Idea With Bbcodes 
 
I have you bbcode working for XS...

I have this code in the $allowed_bbcode array:

Code: [Download] [Hide] [Select]
            'you' => array(
                    'nested'    => false,
                    'inurl'        => false,
                    'allow_empty'    => true,
                    ),


And this is de code in the process_tag($item) function:

Code: [Download] [Hide] [Select]
        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.
 
XusquiSend private messageVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post 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?
 



 
moreteavicarSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post 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.
 
XusquiSend private messageVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post 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...)...
 



 
moreteavicarSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Idea With Bbcodes 
 
Xusqui wrote: [View Post]
Nop... I don't have such a line in bbcode.tpl

bbcode.tpl it's not used by XS, you can remove that file...

Xusqui wrote: [View Post]
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!!!!


moreteavicar wrote: [View Post]
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
 
Mighty GorgonSend private messageSend e-mail to userVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post Respuesta: Idea With Bbcodes 
 
Mighty Gorgon wrote: [View Post]
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 fromhere, 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.
 
XusquiSend private messageVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post 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?
 



 
moreteavicarSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post 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.
 
XusquiSend private messageVisit poster's website  
Back to topPage bottom
Post new topic  This topic is locked: you cannot edit posts or make replies.  Page 1 of 1
 


Display posts from previous:    

HideWas this topic useful?

Link this topic
URL
BBCode
HTML




 
Permissions List
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


  

 

  cron