code to Using Textile

function file_include($text, $shorten) {

$fulltext = substr($text, 0, $shorten);

$inc = strpos($fulltext, '[/include]');

if ($inc > 0) {

$text = str_replace('[include]', '|&|', $fulltext);

$text = str_replace('[/include]', '|&|', $text);

$text = explode('|&|', $text);

$num = count($text);

$extension = explode(',', l('file_include_extensions'));

for ($i = 0; ; $i++) {

if ($i == $num) {break;}

if (!in_array(substr(strrchr($text[$i], '.'), 1), $extension)) {return substr($text[$i], 0);}

else {

if (preg_match("/^[a-z0-9_\-.\/]+$/i", $text[$i])) {

$filename = $text[$i];

file_exists($filename) ? include($filename) : print l('error_file_exists');

} else {echo l('error_file_name');}

}

}

} else {
return $fulltext;
}

}

?>

Posted in |