if (!defined('PHPWCMS_ROOT')) {
    die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------
//image with text
// read template
if (empty($crow["acontent_template"]) && is_file(PHPWCMS_TEMPLATE . 'inc_default/imagetext.tmpl')) {
    $crow["acontent_template"] = render_device(@file_get_contents(PHPWCMS_TEMPLATE . 'inc_default/imagetext.tmpl'));
} elseif (is_file(PHPWCMS_TEMPLATE . 'inc_cntpart/imagetext/' . $crow["acontent_template"])) {
    $crow["acontent_template"] = render_device(@file_get_contents(PHPWCMS_TEMPLATE . 'inc_cntpart/imagetext/' . $crow["acontent_template"]));
} else {
    $crow["acontent_template"] = '[IMAGETEXT]<div class="image-with-text">{IMAGETEXT}</div>[/IMAGETEXT]';
}
$crow["settings"] = get_tmpl_section('IMAGETEXT_SETTINGS', $crow["acontent_template"]);
$crow["settings"] = parse_ini_str($crow["settings"], false);
$crow["acontent_template"] = replace_tmpl_section('IMAGETEXT_SETTINGS', $crow["acontent_template"]);
$crow["acontent_template"] = render_cnt_template($crow["acontent_template"], 'TITLE', html($crow['acontent_title']));
$crow["acontent_template"] = render_cnt_template($crow["acontent_template"], 'SUBTITLE', html($crow['acontent_subtitle']));
$crow["acontent_template"] = str_replace('{ID}', $crow["acontent_id"], $crow["acontent_template"]);
$crow['is_imagetext'] = strpos($crow["acontent_template"], '{IMAGETEXT}') !== false ? true : false;
$crow['has_image'] = false;
// 0   :1       :2   :3        :4    :5     :6      :7       :8
// dbid:filename:hash:extension:width:height:caption:position:zoom
$image = $crow["acontent_image"] ? explode(":", $crow["acontent_image"]) : false;
$crow["default_settings"] = array('class_top_left' => $template_default['classes']['imgtxt-top-left'], 'class_top_center' => $template_default['classes']['imgtxt-top-center'], 'class_top_right' => $template_default['classes']['imgtxt-top-right'], 'class_bottom_left' => $template_default['classes']['imgtxt-bottom-left'], 'class_bottom_center' => $template_default['classes']['imgtxt-bottom-center'], 'class_bottom_right' => $template_default['classes']['imgtxt-bottom-right'], 'class_float_left' => $template_default['classes']['imgtxt-left'], 'class_float_right' => $template_default['classes']['imgtxt-right'], 'class_column_left' => $template_default['classes']['imgtxt-column-left'], 'class_column_right' => $template_default['classes']['imgtxt-column-right'], 'class_column_left_image' => $template_default['classes']['imgtxt-column-left-image'], 'class_column_right_image' => $template_default['classes']['imgtxt-column-right-image'], 'class_column_left_text' => $template_default['classes']['imgtxt-column-left-text'], 'class_column_right_text' => $template_default['classes']['imgtxt-column-right-text'], 'width' => $image[4], 'height' => $image[5], 'zoom' => $image[8], 'crop' => 0, 'lightbox' => 0, 'nocaption' => 0);
$image_text = '';
$crow["settings"] = array_merge($crow["default_settings"], $crow["settings"]);
//zoom click = $image[8];
if ($image) {
    $cnt_image = @unserialize($crow["acontent_form"]);
    $crow['has_image'] = true;
                        $guestbook['entry_image'] .= ' alt="' . html_specialchars($guestbook['row']['guestbook_imagename']) . '" />';
                        //zoom
                        if ($guestbook['imgdata'][2]) {
                            $zoominfo = get_cached_image(array("target_ext" => which_ext($guestbook['row']['guestbook_image']), "image_name" => $guestbook['row']['guestbook_image'], "image_dir" => $guestbook['image_dir'] . '/', "max_width" => $phpwcms["img_prev_width"], "max_height" => $phpwcms["img_prev_height"], "thumb_name" => md5($guestbook['row']['guestbook_image'] . $phpwcms["img_prev_width"] . $phpwcms["img_prev_height"] . $phpwcms["sharpen_level"] . $phpwcms['colorspace'])));
                            if ($zoominfo != false) {
                                $popup_img = 'image_zoom.php?' . getClickZoomImageParameter($zoominfo[0] . '?' . $zoominfo[3]);
                                $guestbook['entry_image'] = '<a href="' . $popup_img . '" onclick="window.open(\'' . $popup_img . "','previewpic','width=" . $zoominfo[1] . ",height=" . $zoominfo[2] . "');return false;" . '">' . $guestbook['entry_image'] . '</a>';
                            }
                        }
                    }
                }
            }
            $guestbook['c'] = render_cnt_template($guestbook['c'], 'IMAGE', $guestbook['entry_image']);
            $guestbook['entry_list'] .= $guestbook['c'];
            $guestbook['counter']++;
        }
        mysql_free_result($guestbook['result']);
        // initialize lightbox
        if ($thumb_image != false) {
            initSlimbox();
        }
        // comments
        $guestbook['entry_list'] = preg_replace('/\\[c\\](.*?)\\[\\/c\\]/is', $guestbook['comment'][0] . "\$1" . $guestbook['comment'][1], $guestbook['entry_list']);
    }
    $guestbook['list'] = str_replace('{NAV}', $guestbook['nav'], $guestbook['list']);
    $guestbook['list'] = str_replace('{FORM}', $guestbook['form'], $guestbook['list']);
    $guestbook['list'] = replace_tmpl_section('GUESTBOOK_ENTRY', $guestbook['list'], $guestbook['entry_list']);
    $CNT_TMP .= $guestbook['list'];
}
// delete guetbook array
unset($guestbook);
        $content['all'] = replace_tmpl_section('NO_PRINT', $content['all']);
        $block['css'] = array('print_layout.css');
    } else {
        $content['all'] = str_replace(array('<!--NO_PRINT_START//-->', '<!--NO_PRINT_END//-->'), '', $content['all']);
    }
}
// now clean up special sections in case user is logged in OR not
if (strpos($content['all'], '--LOGGED_')) {
    if (_getFeUserLoginStatus()) {
        // if user IS logged in
        $content['all'] = str_replace(array('<!--LOGGED_IN_START//-->', '<!--LOGGED_IN_END//-->'), '', $content['all']);
        $content['all'] = replace_tmpl_section('LOGGED_OUT', $content['all']);
    } else {
        // user is NOT logged
        $content['all'] = str_replace(array('<!--LOGGED_OUT_START//-->', '<!--LOGGED_OUT_END//-->'), '', $content['all']);
        $content['all'] = replace_tmpl_section('LOGGED_IN', $content['all']);
    }
}
$content['all'] = preg_replace_callback('/\\[HTML\\](.*?)\\[\\/HTML\\]/s', 'convert2html', $content['all']);
$content['all'] = preg_replace_callback('/\\[HTML_SPECIAL\\](.*?)\\[\\/HTML_SPECIAL\\]/s', 'convert2htmlspecialchars', $content['all']);
parse_CKEDitor_resized_images();
// cleanup document to enhance XHTML Strict compatibility
if (HTML5_MODE) {
    $phpwcms['html5shiv_disabled'] = empty($phpwcms['html5shiv_disabled']) ? false : true;
    $phpwcms['respondjs_disabled'] = empty($phpwcms['respondjs_disabled']) ? false : true;
    // put it as first item
    if (!$phpwcms['html5shiv_disabled'] && !$phpwcms['respondjs_disabled']) {
        $block['custom_htmlhead']['html5shiv'] = '  <!--[if lt IE 9]>
	<script src="' . PHPWCMS_URL . TEMPLATE_PATH . 'lib/html5shiv/html5shiv.min.js"></script>
	<script src="' . PHPWCMS_URL . TEMPLATE_PATH . 'lib/respond/respond.min.js"></script>
  <![endif]-->';
     if (is_intval($news['news_detail_link'])) {
         $news['news_detail_link'] = 'aid=' . $news['news_detail_link'];
     }
     $news['base_href'] = rel_url($news['listing_page'], array('newsdetail'), $news['news_detail_link']);
 }
 foreach ($news['result'] as $key => $value) {
     $value['cnt_object'] = @unserialize($value['cnt_object']);
     $news['entries'][$key] = getFrontendEditLink('news', $value['cnt_id']);
     if (empty($value['cnt_object']['cnt_files']['gallery'])) {
         $news['tmpl_gallery_item'] = '';
         $news['entries'][$key] .= $news['tmpl_entry'];
     } else {
         if (empty($news['tmpl_gallery_item'])) {
             $news['tmpl_gallery_item'] = get_tmpl_section('GALLERY_ITEM', $news['tmpl_entry']);
         }
         $news['entries'][$key] .= replace_tmpl_section('GALLERY_ITEM', $news['tmpl_entry']);
     }
     if ($value['cnt_teasertext']) {
         $value['cnt_opengraph_teasertext'] = $value['cnt_teasertext'];
         if ($news['config']['news_teaser_limit_chars']) {
             $value['cnt_teasertext'] = getCleanSubString($value['cnt_teasertext'], $news['config']['news_teaser_limit_chars'], $news['config']['news_teaser_limit_ellipse'], 'char');
         } elseif ($news['config']['news_teaser_limit_words']) {
             $value['cnt_teasertext'] = getCleanSubString($value['cnt_teasertext'], $news['config']['news_teaser_limit_words'], $news['config']['news_teaser_limit_ellipse'], 'word');
         }
         if (empty($value['cnt_object']['cnt_textformat']) || $value['cnt_object']['cnt_textformat'] == 'plain') {
             $value['cnt_teasertext'] = plaintext_htmlencode($value['cnt_teasertext']);
         } elseif ($value['cnt_object']['cnt_textformat'] == 'br') {
             $value['cnt_teasertext'] = br_htmlencode($value['cnt_teasertext']);
         } elseif ($value['cnt_object']['cnt_textformat'] == 'markdown') {
             if (!isset($phpwcms['parsedown_class'])) {
                 require_once PHPWCMS_ROOT . '/include/inc_ext/parsedown/Parsedown.php';
         $img_a = render_cnt_template($img_a, 'TITLE', $caption[3]);
         $img_a = render_cnt_template($img_a, 'ALT', $caption[1]);
         $img_a = render_cnt_template($img_a, 'LINK', $img_thumb_link);
         // check if this is the last image in row
         if ($image['col'] == $col || $image['count'] == $total) {
             $img_a = render_cnt_template($img_a, 'LAST', $col);
             $xx = $x;
             $x++;
             $col = 0;
         } else {
             $img_a = render_cnt_template($img_a, 'LAST', '');
             $xx = $x;
         }
         // Get the entry data
         $image['tmpl_data'][] = get_tmpl_section('ENTRY_DATA', $img_a);
         $img_a = replace_tmpl_section('ENTRY_DATA', $img_a, '');
         $image['tmpl_images'][$xx] .= $img_a;
     }
     $image['template'] .= implode($image['tmpl_row_space'], $image['tmpl_images']);
 }
 $image['template'] .= $image['tmpl_footer'];
 $image['tmpl_data'] = implode('', $image['tmpl_data']);
 // now do main replacements
 $image['template'] = render_cnt_template($image['template'], 'DATA', $image['tmpl_data']);
 $image['template'] = str_replace('{ID}', $crow['acontent_id'], $image['template']);
 $image['template'] = str_replace('{SPACE}', $image['space'], $image['template']);
 $image['template'] = str_replace('{THUMB_WIDTH_MAX}', $image['tmpl_thumb_width_max'], $image['template']);
 $image['template'] = str_replace('{THUMB_HEIGHT_MAX}', $image['tmpl_thumb_height_max'], $image['template']);
 $image['template'] = str_replace('{THUMB_COLUMNS}', $image['col'], $image['template']);
 $image['template'] = render_cnt_template($image['template'], 'TITLE', html_specialchars($crow['acontent_title']));
 $image['template'] = render_cnt_template($image['template'], 'SUBTITLE', html_specialchars($crow['acontent_subtitle']));
function backend_language_parser()
{
    global $phpwcms, $BE, $BL;
    if (!$phpwcms['be_parse_lang_process'] || empty($phpwcms['be_lang_parse'])) {
        return backend_language_replace('');
    } elseif (empty($phpwcms['allowed_lang']) || !is_array($phpwcms['allowed_lang']) || count($phpwcms['allowed_lang']) < 2) {
        return backend_language_replace('');
    } else {
        $parse_mode = strtoupper($phpwcms['be_lang_parse']);
        if (!in_array($parse_mode, array('BBCODE', 'BRACECODE'))) {
            // i18n later
            return backend_language_replace('');
        }
    }
    // cut main backend content innerHTML
    $html_pos1 = strpos($BE['HTML'], '<!--BE_MAIN_CONTENT_START//-->');
    $html_pos2 = strpos($BE['HTML'], '<!--BE_MAIN_CONTENT_END//-->');
    if ($html_pos1 !== false && $html_pos2 !== false) {
        $html_pos1 += strlen('<!--BE_MAIN_CONTENT_START//-->');
        $html_pos2 -= 1;
    }
    $html = trim(preg_replace('/\\s+/', ' ', substr($BE['HTML'], $html_pos1, $html_pos2 - $html_pos1)));
    $BE['HTML'] = substr($BE['HTML'], 0, $html_pos1) . substr($BE['HTML'], $html_pos2);
    // load MooTools too
    if (empty($phpwcms['mootools_mode'])) {
        initMootools();
    }
    // init language replacements
    $regexp = array('search' => array(), 'replace' => array());
    $bracket = array('BBCODE_OPEN' => '[', 'BRACECODE_OPEN' => '{', 'BBCODE_CLOSE' => ']', 'BRACECODE_CLOSE' => '}');
    $cookie = empty($_COOKIE['phpwcms_be_parse_lang']) || !in_array($_COOKIE['phpwcms_be_parse_lang'], $phpwcms['allowed_lang']) ? false : $_COOKIE['phpwcms_be_parse_lang'];
    // init menu
    $menu = array('<ul id="be_lang">', '<li class="be-lang-label chatlist">' . $BL['be_profile_label_lang'] . ':</li>', '<li><a href="#" class="be-disabled' . ($cookie === false ? ' be-active' : '') . '" rel="disabled" title="' . $BL['be_profile_label_lang'] . ': ' . $BL['be_off'] . '">' . $BL['be_off'] . '</a></li>');
    // Header CSS section
    $BE['HEADER']['be_parse_lang'] = '	<style type="text/css">' . LF;
    // JavaScript section
    $BE['BODY_CLOSE']['hidden_main_content'] = '	<script type="text/javascript">' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= "\t\tvar be_lang_html = [];" . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= "\t\tvar cur_be_lang = 'disabled';" . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= "\t\tbe_lang_html['disabled'] = '" . trim(str_replace(array("\\", "'"), array("\\\\", "\\'"), $html)) . "';" . LF . LF;
    // build regular expression at first
    foreach ($phpwcms['allowed_lang'] as $lang) {
        $regexp['search'][$lang] = '/\\' . $bracket[$parse_mode . '_OPEN'] . $lang . '\\' . $bracket[$parse_mode . '_CLOSE'] . '(.*?)\\' . $bracket[$parse_mode . '_OPEN'] . '\\/' . $lang . '\\' . $bracket[$parse_mode . '_CLOSE'] . '/is';
        $regexp['replace'][$lang] = '';
    }
    // parse each language at second
    foreach ($phpwcms['allowed_lang'] as $lang) {
        $replace = $regexp['replace'];
        $replace[$lang] = '$1';
        $lang_html = preg_replace($regexp['search'], $replace, $html);
        $BE['HEADER']['be_parse_lang'] .= '	#be_lang a.be-lang-' . $lang . ' {background-image:url(img/famfamfam/lang/' . $lang . '.png);}' . LF;
        $menu_item = '<li><a href="#" class="be-lang be-lang-' . $lang;
        // check which is current default
        if ($lang == $cookie) {
            $new_html = $lang_html;
            // phpwcms should use the curent lang html
            $BE['BODY_CLOSE']['hidden_main_content'] .= "\t\tcur_be_lang = '" . $lang . "';" . LF;
            $menu_item .= ' be-active';
        }
        $menu[] = $menu_item . '" rel="' . $lang . '" title="' . $BL['be_profile_label_lang'] . ': ' . strtoupper($lang) . '">' . $lang . '</a></li>';
        $BE['BODY_CLOSE']['hidden_main_content'] .= "\t\tbe_lang_html['" . $lang . "'] = '" . trim(str_replace(array("\\", "'"), array("\\\\", "\\'"), $lang_html)) . "';" . LF . LF;
    }
    $BE['HEADER']['be_parse_lang'] .= '	</style>';
    $BE['BODY_CLOSE']['hidden_main_content'] .= '	window.addEvent("domready", function() {' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '		var be_lang = $("be_lang");' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '		var be_lang_cnt = $("be_lang_cnt");' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '		if(be_lang && be_lang_cnt) {' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '			var be_lang_items = be_lang.getElements("a");' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '			be_lang_items.each(function(l) {' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '				l.addEvent("click", function(){' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= "\t\t\t\t\tif(cur_be_lang == l.rel) {return;}" . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= "\t\t\t\t\tcur_be_lang = l.rel;" . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '					be_lang_items.each(function(el){el.removeClass("be-active");});' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '					l.addClass("be-active");' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '					be_lang_cnt.setHTML(be_lang_html[l.rel]);' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '					Cookie.set("phpwcms_be_parse_lang", cur_be_lang);' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '				});' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '			});' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '		}' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '	});' . LF;
    $BE['BODY_CLOSE']['hidden_main_content'] .= '	</script>';
    $menu[] = '</ul>';
    // wrap current lang/html with <div>
    $BE['HTML'] = replace_tmpl_section('BE_MAIN_CONTENT', $BE['HTML'], '<div id="be_lang_cnt">' . (empty($new_html) ? $html : $new_html) . '</div>');
    backend_language_replace(implode(LF, $menu));
}
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
    die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------
//bullet list
// read template
if (empty($crow["acontent_template"]) && is_file(PHPWCMS_TEMPLATE . 'inc_default/bulletlist.tmpl')) {
    $crow["acontent_template"] = render_device(@file_get_contents(PHPWCMS_TEMPLATE . 'inc_default/bulletlist.tmpl'));
} elseif (is_file(PHPWCMS_TEMPLATE . 'inc_cntpart/bulletlist/' . $crow["acontent_template"])) {
    $crow["acontent_template"] = render_device(@file_get_contents(PHPWCMS_TEMPLATE . 'inc_cntpart/bulletlist/' . $crow["acontent_template"]));
} else {
    $crow["acontent_template"] = '[TITLE]<h4>{TITLE}</h4>' . LF . '[/TITLE][SUBTITLE]<h5>{SUBTITLE}</h5>' . LF . '[/SUBTITLE]';
    $crow["acontent_template"] .= '[BULLETLIST]<ul class="bulletlist">{BULLETLIST}<!--BULLETLIST_ITEM_START//--><li>{BULLETLIST_ITEM}</li><!--BULLETLIST_ITEM_END//--></ul>[/BULLETLIST]';
}
$crow['bulletlist_item_template'] = get_tmpl_section('BULLETLIST_ITEM', $crow["acontent_template"]);
$crow["acontent_template"] = replace_tmpl_section('BULLETLIST_ITEM', $crow["acontent_template"]);
$crow["acontent_template"] = render_cnt_template($crow["acontent_template"], 'TITLE', html_specialchars($crow['acontent_title']));
$crow["acontent_template"] = render_cnt_template($crow["acontent_template"], 'SUBTITLE', html_specialchars($crow['acontent_subtitle']));
$crow['bullets'] = convertStringToArray($crow["acontent_text"], LF);
if (count($crow['bullets'])) {
    $crow['bulletlist_items'] = array();
    foreach ($crow['bullets'] as $item) {
        $crow['bulletlist_items'][] = str_replace('{BULLETLIST_ITEM}', html($item), $crow['bulletlist_item_template']);
    }
    $crow['bulletlist_items'] = implode(LF, $crow['bulletlist_items']);
} else {
    $crow['bulletlist_items'] = '';
}
$crow["acontent_template"] = render_cnt_template($crow["acontent_template"], 'BULLETLIST', $crow['bulletlist_items']);
$CNT_TMP .= $crow["acontent_template"];
                 $_files_entries[$fkey] = render_cnt_template($_files_entries[$fkey], 'FILE_IMAGE_WIDTH', '');
                 $_files_entries[$fkey] = render_cnt_template($_files_entries[$fkey], 'FILE_IMAGE_HEIGHT', '');
                 $_files_entries[$fkey] = render_cnt_template($_files_entries[$fkey], 'FILE_IMAGE_MIME', '');
                 $_files_entries[$fkey] = render_cnt_template($_files_entries[$fkey], 'FILE_IMAGE_CHANNEL', '');
                 $_files_entries[$fkey] = render_cnt_template($_files_entries[$fkey], 'FILE_IMAGE_LANDSCAPE', '');
                 $_files_entries[$fkey] = render_cnt_template($_files_entries[$fkey], 'FILE_IMAGE_PORTRAIT', '');
             }
             $_files_image = $_files_image != false ? PHPWCMS_IMAGES . $_files_image[0] : '';
             $_files_entries[$fkey] = render_cnt_template($_files_entries[$fkey], 'FILE_IMAGE', $_files_image);
             // now replace a possible icon image
             $_files_entries[$fkey] = render_cnt_template($_files_entries[$fkey], 'FILE_ICON', str_replace('{FILE_EXT}', $content['files_result'][$_files_x]['f_ext'], $_files_settings['icon_path'] . $_files_settings['icon_name']));
             break;
         }
     }
 }
 $crow["acontent_template"] = replace_tmpl_section('FILE_ENTRY', $crow["acontent_template"], implode(LF, $_files_entries));
 $crow["acontent_template"] = render_cnt_template($crow["acontent_template"], 'TITLE', html_specialchars($crow['file_cp_title']));
 $crow["acontent_template"] = render_cnt_template($crow["acontent_template"], 'SUBTITLE', html_specialchars($crow['file_cp_subtitle']));
 $crow["acontent_template"] = render_cnt_template($crow["acontent_template"], 'TEXT', $crow["acontent_html"]);
 // cleanup left over FILE_IMAGE sections
 $crow["acontent_template"] = replace_cnt_template($crow["acontent_template"], 'FILE_IMAGE', '');
 // return result
 if (empty($IS_NEWS_CP)) {
     $CNT_TMP .= LF . trim($crow["acontent_template"]) . LF;
 } else {
     $news['files_result'] = trim($crow["acontent_template"]);
 }
 // reset locale settings
 if (!empty($_files_old_locale)) {
     setlocale(LC_ALL, $_files_old_locale);
 }