Exemple #1
0
 public function display($part = 'all')
 {
     switch ($part) {
         case 'page-menu-only':
             if (file_exists('theme/' . $this->get_config('es_theme') . '/page_menu.php')) {
                 $page_menu_file = 'theme/' . $this->get_config('es_theme') . '/page_menu.php';
             } else {
                 $page_menu_file = 'includes/layout/theme//page_menu.php';
             }
             ob_start();
             include $page_menu_file;
             $page_menu = ob_get_contents();
             ob_end_clean();
             echo $page_menu;
             break;
         case 'posts-only':
             echo '<div id="new-post"></div>';
             $this->get_posts();
             break;
         case 'topbar-only':
             ob_start();
             include 'includes/layout/topbar.php';
             $this->topbar = ob_get_contents();
             ob_end_clean();
             echo $this->topbar;
             break;
         case 'sidebar-only':
             if (file_exists('theme/' . $this->get_config('es_theme') . '/sidebar.php')) {
                 $sidebar_file = 'theme/' . $this->get_config('es_theme') . '/sidebar.php';
             } else {
                 $sidebar_file = 'includes/layout/theme/sidebar.php';
             }
             ob_start();
             include $sidebar_file;
             $sidebar = ob_get_contents();
             ob_end_clean();
             echo $sidebar;
             break;
         case 'first-load':
             if ($this->configFileExists()) {
                 ob_start();
                 include 'includes/layout/topbar.php';
                 $this->topbar = ob_get_contents();
                 ob_end_clean();
                 $script_uri = 'http://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . $_SERVER['REQUEST_URI'];
                 if (substr($script_uri, -1) != '/') {
                     $script_uri .= '/';
                 }
                 $editsee_request = str_replace(str_replace('www.', '', $this->get_config('es_main_url')), '', $script_uri);
                 if (substr($editsee_request, 0, 5) == 'feed/') {
                     include "includes/RSSFeed.class.php";
                     header("Content-type: text/xml; charset=UTF-8");
                     $myfeed = new RSSFeed();
                     $myfeed->SetChannel($this->get_config('es_main_url'), $this->get_config('es_title'), $this->get_config('es_description'), 'en-us', date(Y) . ' ' . $_SERVER['HTTP_HOST'], 'webmaster@' . $_SERVER['HTTP_HOST'], $this->get_config('es_title'));
                     $myfeed->SetImage('');
                     $query = $this->db->_query("select id,title,urltag,content,date_entered from " . $this->db->get_table_prefix() . "post \n\t\t\t\t\t\t\t\t\t\t\t\t\twhere type='post' and deleted='0' and (date_entered <= NOW())\n\t\t\t\t\t\t\t\t\t\t\t\t\torder by date_entered desc");
                     while ($post = $query->_fetch_assoc()) {
                         $post['content'] = strip_tags($post['content'], '<br/><br>');
                         if (strpos($post['content'], '!--full-post--!')) {
                             $post['content'] = substr($post['content'], 0, strpos($post['content'], '!--full-post--!'));
                             $add_dots = true;
                         } else {
                             if (strlen($post['content']) > 280) {
                                 $post['content'] = substr(substr($post['content'], 0, 280), 0, strrpos(substr($post['content'], 0, 280), ' '));
                                 $add_dots = true;
                             }
                         }
                         $post['content'] = htmlentities(stripslashes($post['content']));
                         if ($add_dots) {
                             $post['content'] .= ' [...]';
                         }
                         $myfeed->SetItem($this->get_config('es_main_url') . 'post/' . $post['id'], $this->get_config('es_main_url') . 'post/' . $post['urltag'], $post['title'], $post['date_entered'], $post['content']);
                     }
                     echo $myfeed->output();
                     exit;
                 }
                 $editsee_index = '';
                 if ($editsee_request == '' || $editsee_request == $this->get_config('es_postpage') . '/' || $editsee_request == 'index.php/') {
                     $post_start = 0;
                     $page_number = 1;
                     if ($this->get_config('es_homepage') == '!posts!' || $editsee_request == $this->get_config('es_postpage') . '/') {
                         $this->is_posts = true;
                     } else {
                         $editsee_request = $this->get_config('es_homepage') . '/';
                     }
                 }
                 if (substr($editsee_request, 0, 5) == 'page/') {
                     $page_number = substr(substr($editsee_request, 5), 0, strpos(substr($editsee_request, 5), '/'));
                     $post_start = ($page_number - 1) * $this->get_config('es_posts_per_page');
                     $this->is_posts = true;
                 }
                 if ($this->is_posts) {
                     ob_start();
                     $this->get_posts($post_start);
                     $editsee_index .= ob_get_contents();
                     ob_end_clean();
                 } else {
                     $query = $this->db->_query("select id,title from " . $this->db->get_table_prefix() . "post where urltag='" . substr($editsee_request, 0, -1) . "'");
                     if ($query->_num_rows() == 1) {
                         $this->is_page = true;
                         $page = $query->_fetch_assoc();
                         $this->title .= ' - ' . $page['title'];
                         $editsee_index .= $this->get_single_post($page['id'], 'full', 'page');
                     } else {
                         if (substr($editsee_request, 0, 5) == 'post/') {
                             if (!$this->loggedIn()) {
                                 $if_notloggedin = ' and draft=0 and (date_entered <= NOW())';
                             }
                             $query = $this->db->_query("select id,title from " . $this->db->get_table_prefix() . "post \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere (urltag='" . substr($editsee_request, 5, -1) . "' or id='" . substr($editsee_request, 5, -1) . "') \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tand deleted=0" . $if_notloggedin);
                             if ($query->_num_rows() == 1) {
                                 $this->is_post = true;
                                 $post = $query->_fetch_assoc();
                                 $this->title .= ' - ' . $post['title'];
                                 $editsee_index .= $this->get_single_post($post['id'], 'full', 'post');
                                 $post_id = $post['id'];
                                 ob_start();
                                 include "includes/layout/comment_form.php";
                                 $comment_form = ob_get_contents();
                                 ob_end_clean();
                                 $editsee_index .= $comment_form;
                             } else {
                                 $this->is_404 = true;
                                 $editsee_index .= '404 not found';
                             }
                         } else {
                             if (substr($editsee_request, 0, 9) == 'category/') {
                                 $this->is_category = true;
                                 $category = substr(substr($editsee_request, 9), 0, strpos(substr($editsee_request, 9), '/'));
                                 ob_start();
                                 $this->get_posts(0, $category);
                                 $editsee_index = ob_get_contents();
                                 ob_end_clean();
                             } else {
                                 $this->is_404 = true;
                                 $editsee_index .= '404 not found';
                             }
                         }
                     }
                 }
                 if (file_exists('theme/' . $this->get_config('es_theme') . '/header.php')) {
                     require_once 'theme/' . $this->get_config('es_theme') . '/header.php';
                     echo $editsee_index;
                 }
                 if (file_exists('theme/' . $this->get_config('es_theme') . '/index.php')) {
                     require_once 'theme/' . $this->get_config('es_theme') . '/index.php';
                 }
                 if (file_exists('theme/' . $this->get_config('es_theme') . '/footer.php')) {
                     require_once 'theme/' . $this->get_config('es_theme') . '/footer.php';
                 }
             } else {
                 ob_start();
                 include "includes/layout/install.php";
                 $install_page = ob_get_contents();
                 ob_end_clean();
                 echo $install_page;
             }
     }
 }