Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /************************************************
- * *
- * OUTPUT THE TNG PAGE *
- * *
- * mbtng_use_tng_homepage *
- * mbtng_frontend_header *
- * mbtng_frontend_footer *
- * mbtng_fake_post *
- * mbtng_output_page *
- * mbtng_buffer_start *
- * mbtng_buffer_end *
- * mbtng_discard_output *
- * mbtng_eval_php *
- ************************************************/
- function mbtng_use_tng_homepage() {
- if (get_option('mbtng_use_wordpress_homepage')==TRUE && mbtng_requested_url() == get_option('mbtng_url'))
- return false;
- else
- return true;
- }
- //Adds TNG header to Wordpress header
- function mbtng_frontend_header() {
- global $tng_head;
- $tng_head = "<style type=\"text/css\">
- #tng_main {line-height: 1.4em}
- #tng_main tr td {padding: 2px 4px; margin:0; border-top: none}
- </style>\r\n".$tng_head;
- if (strpos(mbtng_filename(), 'admin') !== FALSE)
- $tng_head .= '<base href = "'.get_permalink(get_option('mbtng_wordpress_page')).'"/>';
- $tng_head .= "<style type=\"text/css\">#tng_main td.menuback, #tng_main td.spacercol, #tng_main table.page td.section td.fieldname {display:none}</style>";
- if ($tng_head != '')
- echo $tng_head;
- }
- //Adds TNG footer to Wordpress footer
- function mbtng_frontend_footer() {
- global $tng_footer;
- if ($tng_footer != '')
- echo $tng_footer;
- }
- // Returns the TNG Wordpress post whenever a TNG page is requested
- function mbtng_fake_post($posts){
- if (mbtng_display_page()){
- $posts = get_pages('include='.get_option('mbtng_wordpress_page'));
- add_filter('user_trailingslashit', 'mbtng_smart_trailingslashit');
- }
- return $posts;
- }
- //Outputs the TNG code (outside the loop to minimise CSS conflicts)
- function mbtng_output_page() {
- global $tng_output;
- if (mbtng_display_page() && mbtng_use_tng_homepage()) {
- echo $tng_output;
- ob_start();
- }
- }
- // Buffers Wordpress and TNG code to allow for correct merging of HTML
- function mbtng_buffer_start() {
- global $tng_output, $tng_head, $tng_footer;
- $query = mbtng_requested('query');
- if (mbtng_display_page()) {
- $tng_folder = get_option('mbtng_path');
- $filename = mbtng_filename();
- if (mbtng_extension() == 'php') {
- if ($filename == 'newacctform.php' && get_option('mbtng_integrate_logins')) {
- header("Location: ".trailingslashit(get_bloginfo('wpurl'))."wp-login.php?action=register");
- die();
- }
- if ($filename == 'login.php' && get_option('mbtng_integrate_logins')) {
- header("Location: ".trailingslashit(get_bloginfo('wpurl'))."wp-login.php");
- die();
- }
- if ($filename == 'logout.php' && get_option('mbtng_integrate_logins')) {
- if (function_exists('wp_logout_url'))
- header("Location: ".html_entity_decode(wp_logout_url()));
- else
- header("Location: ".trailingslashit(get_bloginfo('wpurl'))."wp-login.php?action=logout");
- die();
- }
- $tng_output = mbtng_eval_php($filename);
- $non_template_files = array ('tngrss.php', 'addbookmark.php', 'fpdf.php', 'ufpdf.php');
- if (in_array($filename, $non_template_files) || (isset($_REQUEST['tngprint']) && $_REQUEST['tngprint']==1) || stripos($filename, 'admin') !== FALSE || stripos($filename, 'ajx_') !== FALSE || stripos($filename, 'img_') !== FALSE || stripos($filename, 'find') !== FALSE || stripos($filename, 'rpt_') !== FALSE || stripos($tng_output, '<!-- The Next Generation of Genealogy Sitebuilding') === FALSE) {
- echo $tng_output;
- die();
- } else {
- if ($filename == 'admin/index.php') {
- $tng_output = '<div id="tng_main">'.mbtng_display_tng_admin(false).'</div>';
- }
- else {
- $head_start = stripos ($tng_output, '<head>')+6;
- $head_end = stripos ($tng_output, '</head>');
- $tng_head = substr ($tng_output, $head_start, $head_end-$head_start);
- $tng_head = str_replace('.css?', '.css?frontend&', $tng_head);
- $tng_head = str_replace('.css" rel', '.css?frontend" rel', $tng_head);
- $footer_start = stripos ($tng_output, '</body>')+7;
- $footer_end = stripos ($tng_output, '</html>');
- $tng_footer = substr ($tng_output, $footer_start, $footer_end-$footer_start);
- $output_start = stripos($tng_output, '>', stripos ($tng_output, '<body'))+1;
- $output_end = $footer_start-8;
- $tng_output = '<div id="tng_main">'.substr ($tng_output, $output_start, $output_end-$output_start).'</div>';
- }
- ob_start('');
- }
- }
- }
- }
- //Flushes the output buffer
- function mbtng_buffer_end() {
- @ob_end_flush();
- }
- // Discards contents of page if TNG is displayed
- function mbtng_discard_output() {
- if (mbtng_display_page() && mbtng_use_tng_homepage()) {
- ob_clean();
- // Remove actions in case loop used elsewhere (e.g. in sidebar)
- //remove_action('loop_start', 'mbtng_output_page');
- //remove_action('loop_end', 'mbtng_discard_output');
- }
- }
- //Runs the TNG PHP code and returns the HTML
- function mbtng_eval_php($filename) {
- global $tng_output;
- if ($tng_output == '') {
- $tng_folder = get_option('mbtng_path');
- if (stripos($filename, 'admin') !== FALSE) {
- //$filename = substr ($filename, 6);
- $admin = true;
- //$tng_folder .= 'admin';
- } else {
- ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.$tng_folder);
- $admin = false;
- }
- eval('?>'.get_option('mbtng_globals').'<?php ');
- ob_start();
- $code = file_get_contents(mbtng_folder_trailingslashit($tng_folder).$filename);
- if ($admin | $filename == 'pdfform.php')
- chdir($tng_folder);
- eval("?>$code<?php ");
- $output = ob_get_contents();
- ob_end_clean();
- $tng_output = $output;
- }
- mbtng_close_tng_table();
- return $tng_output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement