$tpl->assign('sitename', $xoopsConfig['sitename']);
$tpl->assign('site_url', XOOPS_URL);
$tpl->assign('content_url', XOOPS_URL . "/modules/{$mydirname}/index.php?id={$storyid}");
$tpl->assign('lang_comesfrom', sprintf(_TC_THISCOMESFROM, $xoopsConfig['sitename']));
$tpl->assign('lang_contentfrom', _TC_URLFORSTORY);
$myts =& MyTextSanitizer::getInstance();
$tpl->assign('title', $myts->makeTboxData4Show($title));
$tpl->assign('modulename', $xoopsModule->getVar('name'));
// getting "content"
if ($link > 0) {
    // external (=wrapped) content
    $wrap_file = "{$mymodpath}/content/{$address}";
    if (!file_exists($wrap_file)) {
        redirect_header(XOOPS_URL . '/', 2, _TC_FILENOTFOUND);
        exit;
    }
    ob_start();
    include $wrap_file;
    $content = tc_convert_wrap_to_ie(ob_get_contents());
    if ($link == TC_WRAPTYPE_CHANGESRCHREF) {
        $content = tc_change_srchref($content, XOOPS_URL . "/modules/{$mydirname}/content");
    }
    ob_end_clean();
} else {
    $content = tc_content_render($text, $nohtml, $nosmiley, $nobreaks, $xoopsModuleConfig['tc_space2nbsp']);
}
// convert from {X_SITEURL} to XOOPS_URL
$content = str_replace('{X_SITEURL}', XOOPS_URL, $content);
$tpl->assign('content', $content);
$main_template = empty($tinyd_singlecontent) ? "db:tinycontent{$mydirnumber}_print.html" : "db:tinycontent{$mydirnumber}_index.html";
$tpl->display($main_template);
 function b_tinycontent_content_show($options)
 {
     global $xoopsDB, $xoopsConfig;
     $mydirname = $options[0];
     if (!preg_match('/^(\\D+)(\\d*)$/', $mydirname, $regs)) {
         echo "invalid dirname: " . htmlspecialchars($mydirname);
     }
     $mydirnumber = $regs[2] === '' ? '' : intval($regs[2]);
     $mytablename = $xoopsDB->prefix("tinycontent{$mydirnumber}");
     $mymodpath = XOOPS_ROOT_PATH . "/modules/{$mydirname}";
     $mymoddir = XOOPS_URL . "/modules/{$mydirname}";
     if (!class_exists('TinyDTextSanitizer')) {
         include_once "{$mymodpath}/class/tinyd.textsanitizer.php";
     }
     if (!defined('TC_RENDER_FUNCTIONS_INCLUDED')) {
         include_once "{$mymodpath}/include/render_function.inc.php";
     }
     if (!defined('TINYCONTENT_MB_LOADED')) {
         if (file_exists("{$mymodpath}/language/{$xoopsConfig['language']}/main.php")) {
             include_once "{$mymodpath}/language/{$xoopsConfig['language']}/main.php";
         } else {
             include_once "{$mymodpath}/language/english/main.php";
         }
     }
     // get my config
     $module_handler =& xoops_gethandler('module');
     $config_handler =& xoops_gethandler('config');
     $module =& $module_handler->getByDirname($mydirname);
     $config =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
     $space2nbsp = empty($config['tc_space2nbsp']) ? 0 : 1;
     $result = $xoopsDB->query("SELECT text,title,link,nohtml,nosmiley,nobreaks,address FROM {$mytablename} WHERE storyid='{$options[1]}'");
     list($text, $title, $link, $nohtml, $nosmiley, $nobreaks, $address) = $xoopsDB->fetchRow($result);
     // getting "content"
     if ($link > 0) {
         // external (=wrapped) content
         $wrap_file = "{$mymodpath}/content/{$address}";
         if (!file_exists($wrap_file)) {
             redirect_header(XOOPS_URL . '/', 2, _TC_FILENOTFOUND);
             exit;
         }
         ob_start();
         include $wrap_file;
         $content = tc_convert_wrap_to_ie(ob_get_contents());
         /* if( $link == TC_WRAPTYPE_CHANGESRCHREF ) */
         $content = tc_change_srchref($content, "{$mymoddir}/content");
         ob_end_clean();
     } else {
         $myts =& TinyDTextSanitizer::getInstance();
         $shorten_text = $myts->tinyExtractSummary($text);
         $is_summary = $shorten_text != $text;
         $content = tc_content_render($shorten_text, $nohtml, $nosmiley, $nobreaks, $space2nbsp);
     }
     // if template file exists, parse it.
     if (file_exists("{$mymodpath}/templates/blocks/tinycontent_content_block.html")) {
         $myts =& TinyDTextSanitizer::getInstance();
         $tpl = new XoopsTpl();
         $tpl->assign(array('storyid' => $options[1], 'mymoddir' => $mymoddir, 'is_summary' => $is_summary, 'lang_more' => _MORE, 'title' => $myts->makeTboxData4Show($title), 'content' => $content));
         $block['content'] = $tpl->fetch("file:{$mymodpath}/templates/blocks/tinycontent_content_block.html");
     } else {
         $block['content'] = $content;
     }
     return $block;
 }
}
// for "Duplicatable"
$mydirname = basename(dirname(__FILE__));
if (!preg_match('/^(\\D+)(\\d*)$/', $mydirname, $regs)) {
    echo "invalid dirname: " . htmlspecialchars($mydirname);
}
$mydirnumber = $regs[2] === '' ? '' : intval($regs[2]);
// utility variables
$mymodpath = XOOPS_ROOT_PATH . "/modules/{$mydirname}";
$mytablename = $xoopsDB->prefix("tinycontent{$mydirnumber}");
// check if post data is passed via session...
if (empty($_SESSION['tinyd_preview_post'])) {
    exit;
}
$post = $_SESSION['tinyd_preview_post'];
unset($_SESSION['tinyd_preview_post']);
// cache file name check (thx JM2)
/* if( ! preg_match( '/^'.$mydirname.'_preview_\d{10}$/' , $_GET['preview'] ) ) exit ;

$content_cache_full_path = XOOPS_CACHE_PATH . '/' . $_GET['preview'] ;
$fp = fopen( $content_cache_full_path , 'r' ) ;
if( $fp === false ) die( _TC_FILENOTFOUND . " $content_cache_full_path" ) ;
$text = fread( $fp , 65536 ) ;
fclose( $fp ) ;
@unlink( $content_cache_full_path ) ;*/
// force turning PHP debug on
$original_level = error_reporting(E_ALL);
$content = tc_content_render($post['message'], $post['nohtml'], $post['nosmiley'], $post['nobreaks'], $xoopsModuleConfig['tc_space2nbsp']);
// restore error_report_level
error_reporting($original_level);
echo '<html><head><meta http-equiv="content-type" content="text/html; charset=' . _CHARSET . '" /><meta http-equiv="content-language" content="' . _LANGCODE . '" /><title>' . $xoopsConfig['sitename'] . '</title></head><body>' . $content . '</body></html>';