<?php
        
        # Page specific information / included in pagep.php
        
        include_once 'en_code.php';
        

        # post

        if (isset($fn)) {

            if (isset($fninfo)) 
                $xmlfile = $fninfo;
            else 
                $xmlfile = getxmlpost('../../monofiles/autosaves/'.$fn); #support older version without prepost.php
            
            $title = $xmlfile['title'];
            $meta_description = (string)$xmlfile['description'];
            $meta_description = cut_content($meta_description,160);
            $htm_file = '../../monofiles/autosaves/content/'.basename($fn,'.xml').'.htm';
            
            
            
            
            # content
            if (is_file($htm_file)) {
            
                $content = file_get_contents($htm_file);

                if ($xmlfile['excerpt'] != 'none')
                    $content = str_replace('<hr>','',$content);

                if ($meta_description == '')
                    $meta_description = cut_content($content,160);
            }

            
            
            

            # post date
            if ($xmlfile['ptime'] !== false) {

                $form = (string)$cms['show_date'];
                $fpdate = (int)$xmlfile['ptime'];
                
                if ($form != 'none(turn off)')
                    $post_date = date($form,$fpdate);

            }


            
            

            # post tags
            if ($cms['show_tags'] == 'on') {
            
                if ($xmlfile['tags'] != '') {

                    $taginfo = load_xml($xmlfile['tags']);
                    $sep = array_values(preg_split('/[,]/', $taginfo, PREG_SPLIT_NO_EMPTY));
                    
                    $tags = '';
                    foreach($sep as $val)
                        $tags .= '<a href="../../tags/'.str_replace(' ','-',mb_strtolower($val,'UTF-8')).'" class="tagged">'.$val.'</a> '.PHP_EOL;
                    
                }
            }


            
            
            
            # post category
            if ($cms['show_category'] == 'on') {
                
                $catinfo = load_xml($xmlfile['category']);
                $folders = glob('../../category/*',GLOB_ONLYDIR);

                foreach($folders as $catf) {
                    
                    if (basename($catf) == $catinfo) {
                        
                        $ctgr = '<a href="'.$catf.'" class="catword">'.$catinfo.'</a>';
                        break;
                    }
                }
            }
            
            
            
            
            # post author-editor
            if ($cms['sign_posts'] == 'on') :
                
                $the_author = '';
                $created = $xmlfile['createdby'];
                $edited = $xmlfile['editedby'];

                $logfile = simplexml_object('log.xml','l',null);
                foreach ($logfile->user as $userinfo) {

                    if ((string)$userinfo->userID == $created) {
                        $the_author = $userinfo->editorname;
                        
                        if ($edited != '' && (string)$edited != (string)$created) {
                            
                            foreach ($logfile->user as $userdata) {
                                
                                if ((string)$userdata->userID == $edited) {
                                    $the_author .= ' ,&nbsp;'.$userdata->editorname;
                                    break;
                                }
                            }
                        }
                        
                        break;
                    }
                }
                
                endif;
            
            
            
            
        }

        #END post
        


        


        # page
        elseif (isset($pn)) {
        
            $rt = isset($incp) ? $incp : '';
            $xmlfile = simplexml_object($pn.'.xml','l','page',$rt.'monofiles/savedpages/');
            $title = load_xml($xmlfile->pageinfo->page->title);
            $meta_description = cut_content((string)$xmlfile->pageinfo->page->description,160);
            $content = file_get_contents($rt.'monofiles/savedpages/'.$pn.'.htm');

        }





        # home, tag or category
        elseif (isset($index) || isset($catg) || isset($tagg)) {

            $title = $cms['website_title'];
            $meta_description = $cms['website_description'];
            
            


        }
 
    
?>