Сделано в основном для применения с модом Glance v.2, для создания user-dependent или просто динамических объявлений.
Делал для себя - может кому-то будет интересно...
P.S. Возможно название не очень удачное - тогда поправьте меня

Код: Выделить всё
################################################################
## MOD Title: Include BBcode MOD
## MOD Author: avm < avm@tverskie.net > (Alex V.Musienko) N/A
## MOD Description: Adds [include(remote_filename_or_url)] BBcode tag for evaluating external scripts/files.
## MOD Version: 1.0.1
##
## Installation Level: Easy
## Installation Time: 5 Minutes
## Files To Edit: includes/bbcode.php
## Included Files: N/A
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes:
## Tag behaviour is similar to php include() statement.
## This mod gives an ability for administrator to make dinamic posts.
## Using it with Glance v.2 MOD, administrator can make visitor-dependent annotations.
## Since PHP 4.3.0 it is available to include remote files if allow_url_fopen is true.
##
## IMPORTANT: Use it carefully, because of possible security holes in external scripts/pages.
##
##############################################################
## MOD History:
##
## 2005-02-05 - Version 1.0.1
## - modified behaviuor, if tag used not by forum administrator
## - modified order of tag processing (now it goes after [i]...[/i] tags)
## - added cut of frameset from external file
##
## 2005-01-25 - Version 1.0.0
## - Initial Release
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]---------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]---------------------------------
#
$text = str_replace("[/i:$uid]", $bbcode_tpl['i_close'], $text);
#
#-----[ AFTER, ADD ]---------------------------
#
// [include] for external script use
$text = preg_replace("#\[include\((.*?)\):$uid\]#sie", "use_include('\\1')", $text);
#
#-----[ FIND ]---------------------------------
#
function bbencode_first_pass($text, $uid)
{
#
#-----[ AFTER, ADD ]---------------------------
#
global $userdata;
#
#-----[ FIND ]---------------------------------
#
$text = preg_replace("#\[i\](.*?)\[/i\]#si", "[i:$uid]\\1[/i:$uid]", $text);
#
#-----[ AFTER, ADD ]---------------------------
#
// [include] for external script use
$text = preg_replace("#\[include\((.*?)\)\]#si", (($userdata['user_level'] == ADMIN) ? "[include(\\1):$uid]" : "[u:$uid]\\1[/u:$uid]") , $text);
#
#-----[ FIND ]---------------------------------
#
?>
#
#-----[ BEFORE, ADD ]--------------------------
#
function use_include($link) {
$map = array(
"'.*?<body[^>]*?>'si", "", // replace all before BODY
"'</body[^>]*?>.*?'si", "", // replace all after BODY
"'.*?<html[^>]*?>'si", "", // replace all before HTML
"'</html[^>]*?>.*?'si", "", // replace all after HTML
"'<head[^>]*?>.*?</head>'si", "", // replace all HEADers
"'<script[^>]*?>.*?</script>'si", "", // replace all javaScript
"'(^|[\r\n])[\s]+'", "\\1", // replace all leading spaces
"'<frameset[^>]*?>.*?</frameset>'si", "", // replace all FRAMESETs
);
/*
"'<[\/\!]*?[^<>]*?>'si", "", // replace html-tags
"'&(quot|#34);'i", "\"",
"'&(amp|#38);'i", "&",
"'&(lt|#60);'i", "<",
"'&(gt|#62);'i", ">",
"'&(nbsp|#160);'i", " ",
"'&(iexcl|#161);'i", chr(161),
"'&(cent|#162);'i", chr(162),
"'&(pound|#163);'i", chr(163),
"'&(copy|#169);'i", chr(169),
"'&#(\d+);'e", "chr(\\1)",
*/
$i=0; while ($i < count($map)) { $srch[]=$map[$i++]; $repl[]=$map[$i++]; }
ob_start();
@include($link);
$result=ob_get_contents();
ob_end_clean();
return trim(preg_replace($srch, $repl, $result));
}
#
#-----[ SAVE/CLOSE ALL FILES ]-----------------
#
# EoM