831 echo '</div>'; |
831 echo '</div>'; |
832 } |
832 } |
833 if ( $this->site_disabled && $session->user_level >= USER_LEVEL_ADMIN && ( $paths->page != $paths->nslist['Special'] . 'Administration' ) ) |
833 if ( $this->site_disabled && $session->user_level >= USER_LEVEL_ADMIN && ( $paths->page != $paths->nslist['Special'] . 'Administration' ) ) |
834 { |
834 { |
835 $admin_link = makeUrlNS('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'GeneralConfig', true); |
835 $admin_link = makeUrlNS('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'GeneralConfig', true); |
836 echo '<div class="usermessage"><b>The site is currently disabled and thus is only accessible to administrators.</b><br /> |
836 echo '<div class="usermessage"><b>' . $lang->get('page_sitedisabled_admin_msg_title') . '</b><br /> |
837 You can re-enable the site through the <a href="' . $admin_link . '">administration panel</a>. |
837 ' . $lang->get('page_sitedisabled_admin_msg_body', array('admin_link' => $admin_link)) . ' |
838 </div>'; |
838 </div>'; |
839 } |
839 } |
840 } |
840 } |
841 |
841 |
842 function footer($simple = false) |
842 function footer($simple = false) |
843 { |
843 { |
844 global $db, $session, $paths, $template, $plugins; // Common objects |
844 echo $this->getFooter(); |
845 if ( !$this->no_headers ) |
845 ob_end_flush(); |
846 { |
|
847 |
|
848 if(!defined('ENANO_HEADERS_SENT')) |
|
849 $this->header(); |
|
850 |
|
851 global $_starttime; |
|
852 if(isset($_GET['sqldbg']) && $session->get_permissions('mod_misc')) |
|
853 { |
|
854 echo '<h3>Query list as requested on URI</h3><pre style="margin-left: 1em">'; |
|
855 echo htmlspecialchars($db->sql_backtrace()); |
|
856 echo '</pre>'; |
|
857 } |
|
858 |
|
859 $f = microtime_float(); |
|
860 $f = $f - $_starttime; |
|
861 $f = round($f, 4); |
|
862 $dbg = 'Time: '.$f.'s | Queries: '.$db->num_queries; |
|
863 $t = ( $simple ) ? $this->process_template('simple-footer.tpl') : $this->process_template('footer.tpl'); |
|
864 $t = str_replace('[[Stats]]', $dbg, $t); |
|
865 $t = str_replace('[[NumQueries]]', (string)$db->num_queries, $t); |
|
866 $t = str_replace('[[GenTime]]', (string)$f, $t); |
|
867 |
|
868 if ( defined('ENANO_DEBUG') ) |
|
869 $t = str_replace('</body>', '<div id="profile" style="margin: 10px;">' . profiler_make_html() . '</div></body>', $t); |
|
870 |
|
871 echo $t; |
|
872 |
|
873 ob_end_flush(); |
|
874 } |
|
875 else |
|
876 { |
|
877 return ''; |
|
878 } |
|
879 } |
846 } |
880 |
847 |
881 function getHeader() |
848 function getHeader() |
882 { |
849 { |
883 $headers_sent = true; |
850 $headers_sent = true; |
886 if(!$this->no_headers) return $this->process_template('header.tpl'); |
853 if(!$this->no_headers) return $this->process_template('header.tpl'); |
887 } |
854 } |
888 function getFooter() |
855 function getFooter() |
889 { |
856 { |
890 global $db, $session, $paths, $template, $plugins; // Common objects |
857 global $db, $session, $paths, $template, $plugins; // Common objects |
891 if(!$this->no_headers) { |
858 global $lang; |
|
859 if ( !$this->no_headers ) |
|
860 { |
|
861 |
|
862 if(!defined('ENANO_HEADERS_SENT')) |
|
863 $this->header(); |
|
864 |
892 global $_starttime; |
865 global $_starttime; |
893 $t = ''; |
|
894 |
|
895 if(isset($_GET['sqldbg']) && $session->get_permissions('mod_misc')) |
866 if(isset($_GET['sqldbg']) && $session->get_permissions('mod_misc')) |
896 { |
867 { |
897 $t .= '<h3>Query list as requested on URI</h3><pre style="margin-left: 1em">'; |
868 echo '<h3>' . $lang->get('page_heading_sql_list') . '</h3><pre style="margin-left: 1em">'; |
898 $t .= $db->sql_backtrace(); |
869 echo htmlspecialchars($db->sql_backtrace()); |
899 $t .= '</pre>'; |
870 echo '</pre>'; |
900 } |
871 } |
|
872 |
|
873 $t = ( $simple ) ? $this->process_template('simple-footer.tpl') : $this->process_template('footer.tpl'); |
901 |
874 |
902 $f = microtime_float(); |
875 $f = microtime_float(); |
903 $f = $f - $_starttime; |
876 $f = $f - $_starttime; |
904 $f = round($f, 4); |
877 $f = round($f, 4); |
905 $dbg = 'Time: '.$f.'s | Queries: '.$db->num_queries; |
878 |
906 $t.= $this->process_template('footer.tpl'); |
879 $t_loc = $lang->get('page_msg_stats_gentime_short', array('time' => $f)); |
|
880 $t_loc_long = $lang->get('page_msg_stats_gentime_long', array('time' => $f)); |
|
881 $q_loc = '<a href="' . $this->tpl_strings['REPORT_URI'] . '">' . $lang->get('page_msg_stats_sql', array('nq' => $db->num_queries)) . '</a>'; |
|
882 $dbg = $t_loc; |
|
883 $dbg_long = $t_loc_long; |
|
884 if ( $session->user_level >= USER_LEVEL_ADMIN ) |
|
885 { |
|
886 $dbg .= " | $q_loc"; |
|
887 $dbg_long .= " | $q_loc"; |
|
888 } |
|
889 |
907 $t = str_replace('[[Stats]]', $dbg, $t); |
890 $t = str_replace('[[Stats]]', $dbg, $t); |
|
891 $t = str_replace('[[StatsLong]]', $dbg_long, $t); |
908 $t = str_replace('[[NumQueries]]', (string)$db->num_queries, $t); |
892 $t = str_replace('[[NumQueries]]', (string)$db->num_queries, $t); |
909 $t = str_replace('[[GenTime]]', (string)$f, $t); |
893 $t = str_replace('[[GenTime]]', (string)$f, $t); |
|
894 $t = str_replace('[[NumQueriesLoc]]', $q_loc, $t); |
|
895 $t = str_replace('[[GenTimeLoc]]', $t_loc, $t); |
|
896 $t = str_replace('[[EnanoPoweredLink]]', $lang->get('page_enano_powered', array('about_uri' => $this->tpl_strings['URL_ABOUT_ENANO'])), $t); |
|
897 $t = str_replace('[[EnanoPoweredLinkLong]]', $lang->get('page_enano_powered_long', array('about_uri' => $this->tpl_strings['URL_ABOUT_ENANO'])), $t); |
|
898 |
|
899 if ( defined('ENANO_DEBUG') ) |
|
900 $t = str_replace('</body>', '<div id="profile" style="margin: 10px;">' . profiler_make_html() . '</div></body>', $t); |
|
901 |
910 return $t; |
902 return $t; |
911 } |
903 } |
912 else return ''; |
904 else |
|
905 { |
|
906 return ''; |
|
907 } |
913 } |
908 } |
914 |
909 |
915 /** |
910 /** |
916 * Compiles and executes a template based on the current variables and booleans. Loads |
911 * Compiles and executes a template based on the current variables and booleans. Loads |
917 * the theme and initializes variables if needed. This mostly just calls child functions. |
912 * the theme and initializes variables if needed. This mostly just calls child functions. |
2027 } |
2022 } |
2028 } |
2023 } |
2029 function footer($simple = false) |
2024 function footer($simple = false) |
2030 { |
2025 { |
2031 global $db, $session, $paths, $template, $plugins; // Common objects |
2026 global $db, $session, $paths, $template, $plugins; // Common objects |
|
2027 global $lang; |
|
2028 |
2032 if(!$this->no_headers) { |
2029 if(!$this->no_headers) { |
2033 global $_starttime; |
2030 global $_starttime; |
2034 |
2031 |
2035 $f = microtime(true); |
2032 $filename = ( $simple ) ? 'simple-footer.tpl' : 'footer.tpl'; |
|
2033 $t = $this->process_template($filename); |
|
2034 |
|
2035 $f = microtime_float(); |
2036 $f = $f - $_starttime; |
2036 $f = $f - $_starttime; |
2037 $f = round($f, 4); |
2037 $f = round($f, 4); |
2038 if(defined('IN_ENANO_INSTALL')) $nq = 'N/A'; |
2038 |
2039 else $nq = $db->num_queries; |
2039 if ( is_object($lang) ) |
2040 if($nq == 0) $nq = 'N/A'; |
2040 { |
2041 $dbg = 'Time: '.$f.'s | Queries: '.$nq; |
2041 $t_loc = $lang->get('page_msg_stats_gentime_short', array('time' => $f)); |
2042 $filename = ( $simple ) ? 'simple-footer.tpl' : 'footer.tpl'; |
2042 $t_loc_long = $lang->get('page_msg_stats_gentime_long', array('time' => $f)); |
2043 $t = $this->process_template($filename); |
2043 $q_loc = '<a href="' . $this->tpl_strings['REPORT_URI'] . '">' . $lang->get('page_msg_stats_sql', array('nq' => ( is_object($db) ? $db->num_queries : 'N/A' ))) . '</a>'; |
|
2044 $dbg = $t_loc; |
|
2045 $dbg_long = $t_loc_long; |
|
2046 if ( $session->user_level >= USER_LEVEL_ADMIN ) |
|
2047 { |
|
2048 $dbg .= " | $q_loc"; |
|
2049 $dbg_long .= " | $q_loc"; |
|
2050 } |
|
2051 $t = str_replace('[[EnanoPoweredLink]]', $lang->get('page_enano_powered', array('about_uri' => $this->tpl_strings['URL_ABOUT_ENANO'])), $t); |
|
2052 $t = str_replace('[[EnanoPoweredLinkLong]]', $lang->get('page_enano_powered_long', array('about_uri' => $this->tpl_strings['URL_ABOUT_ENANO'])), $t); |
|
2053 } |
|
2054 else |
|
2055 { |
|
2056 $t_loc = "Time: {$f}s"; |
|
2057 $t_loc_long = "Generated in {$f}sec"; |
|
2058 $q_loc = '<a href="' . $this->tpl_strings['REPORT_URI'] . '">' . ( is_object($db) ? "{$db->num_queries} SQL" : 'Queries: N/A' ) . '</a>'; |
|
2059 $dbg = $t_loc; |
|
2060 $dbg_long = $t_loc_long; |
|
2061 if ( $session->user_level >= USER_LEVEL_ADMIN ) |
|
2062 { |
|
2063 $dbg .= " | $q_loc"; |
|
2064 $dbg_long .= " | $q_loc"; |
|
2065 } |
|
2066 $t = str_replace('[[EnanoPoweredLink]]', 'Powered by <a href="http://enanocms.org/" onclick="window.open(this.href); return false;">Enano</a>', $t); |
|
2067 $t = str_replace('[[EnanoPoweredLinkLong]]', 'Website engine powered by <a href="http://enanocms.org/" onclick="window.open(this.href); return false;">Enano</a>', $t); |
|
2068 } |
|
2069 |
2044 $t = str_replace('[[Stats]]', $dbg, $t); |
2070 $t = str_replace('[[Stats]]', $dbg, $t); |
2045 if ( is_object($db) ) |
2071 $t = str_replace('[[StatsLong]]', $dbg_long, $t); |
2046 { |
2072 $t = str_replace('[[NumQueries]]', ( is_object($db) ? (string)$db->num_queries : '0' ), $t); |
2047 $t = str_replace('[[NumQueries]]', (string)$db->num_queries, $t); |
|
2048 } |
|
2049 else |
|
2050 { |
|
2051 $t = str_replace('[[NumQueries]]', '0', $t); |
|
2052 } |
|
2053 $t = str_replace('[[GenTime]]', (string)$f, $t); |
2073 $t = str_replace('[[GenTime]]', (string)$f, $t); |
|
2074 $t = str_replace('[[NumQueriesLoc]]', $q_loc, $t); |
|
2075 $t = str_replace('[[GenTimeLoc]]', $t_loc, $t); |
2054 |
2076 |
2055 echo $t; |
2077 echo $t; |
2056 } |
2078 } |
2057 else return ''; |
2079 else return ''; |
2058 } |
2080 } |