tag archives: phpBB

how to: allow php in static pages 1.0.3 [phpBB3]

[posted: ]  [1 comment]

vondra vojtech’s static pages mod (v. 1.0.3) phpBB3 uses the built-in functions to generate content output, which prohibit the use of HTML and/or PHP. here’s a little hack which enables you to include your own php code in static pages, and have it parsed normally.

please note that allowing PHP on your static pages poses a BIG security risk, and you should only do it if (1) you can absolutely trust the admins of your board, and (2) you really need this.

if you just want to allow HTML in static pages, remove everything after “// end allow HTML”.

open page.php in your phpbb installation’s root folder and find this section:
// Parse the page content to transform BBCode
$content = generate_text_for_display($row['page_content'], $row['bbcode_uid'], $row['bbcode_bitfield'], 7);

now add the following code below it:
//allow HTML
   $replacearray = array(
      'before' => array("&lt;","&gt;","&quot;","<?"),
      'after' => array("<",">","\"","&lt;?")
   );
   $content = str_replace($replacearray['before'],$replacearray['after'],$content);
//end allow HTML
//allow PHP   
   function execute($code) {
         $code = str_replace("<br />","\n",$code); // if you remove this, all the line-breaks in your page content's php-code will be converted into "<br />"s
         ob_start(); // don't output results, but store them in cache
         eval("?> $code"); // create html and php-output from page content
         $code = ob_get_contents(); // retrieve output from cache and store in variable
         ob_end_clean(); // clear cache
         $code = str_replace("\n","<br />",$code); // change line-breaks in HTML back to "<br />"s
         return $code;
      }
      $content = execute($content);
//end allow PHP

[category: general] [tags: , , ]

how to: allow html in static pages 1.0.3 [phpBB3]

[posted: ]  [0 comments]

if you’re using phpBB version 3.x in combination with vondra vojtech’s static pages mod (v. 1.0.3), and you would like to be able to use standard html on static pages, you can easily enable it by inserting a little code snippet into “page.php” in your phpBB installation’s root folder:

simply find this section:
// Parse the page content to transform BBCode
$content = generate_text_for_display($row['page_content'], $row['bbcode_uid'], $row['bbcode_bitfield'], 7);

and add the following snippet below it:
//allow HTML
   $replacearray = array(
      'before' => array("&lt;","&gt;","&quot;","<?"),
      'after' => array("<",">","\"","&lt;?")
   );
   $content = str_replace($replacearray['before'],$replacearray['after'],$content);
//end allow HTML

what this does, is replace the html entities for the opening and closing of tags with the actual characters.

[category: computers & technology] [tags: , , ]