| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- <?php
- /*
- *
- * OGP - Open Game Panel
- * Copyright (C) 2008 - 2018 The OGP Development Team
- *
- * http://www.opengamepanel.org/
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
- define("DEFAULT_REFRESH_TIME","2");
- class OGPView {
- private $meta;
- private $title;
- private $refreshTime;
- private $refreshUrl;
- function __construct() {
- ob_start();
- $this->logo = "home.php?m=dashboard&p=dashboard";
- $this->bg_wrapper = "";
- $this->title = "Open Game Panel";
- $this->charset = "utf-8";
- $this->refreshTime = DEFAULT_REFRESH_TIME;
- }
- function __destruct() {
- }
- function menu(){}
-
- function printView($cleared = false, $dataType = "html") {
- global $db, $OGPLangPre;
- if ( is_object($db) && array_key_exists( "OGPDatabase", class_parents($db) ) ) {
- $panel_settings = $db->getSettings();
- }
-
- // Our global CSS goes first so that themes can override
- $this->header_code = '<link rel="stylesheet" href="css/global.css">' . "\n";
- $path = "";
- if ( isset($_SESSION['users_theme']) &&
- !empty($_SESSION['users_theme']) &&
- is_dir( 'themes/'.$_SESSION['users_theme'] ) &&
- is_file( 'themes/'.$_SESSION['users_theme'].'/layout.html') )
- {
- $path = 'themes/'.$_SESSION['users_theme'].'/';
- }
- // Using default theme if there is not one selected.
- else if ( !isset($panel_settings['theme']) )
- {
- $path = 'themes/Revolution/';
- }
- else if ( is_dir( 'themes/'.$panel_settings['theme'] ) &&
- is_file( 'themes/'.$panel_settings['theme'].'/layout.html') )
- {
- $path = 'themes/'.$panel_settings['theme'].'/';
- }
- // In case the theme that was selected is invalid print error and use default.
- else
- {
- $path = 'themes/Revolution/';
- }
- $page = file_get_contents($path.'layout.html');
- @$top = file_get_contents($path.'top.html');
- @$bottom = file_get_contents($path.'bottom.html');
- @$topbody = file_get_contents($path.'topbody.html');
- @$botbody = file_get_contents($path.'botbody.html');
-
- if ( isset($panel_settings['logo_link']) &&
- !empty($panel_settings['logo_link']))
- $this->logo = $panel_settings['logo_link'];
-
- if ( isset($panel_settings['bg_wrapper']) &&
- !empty($panel_settings['bg_wrapper']))
- $this->bg_wrapper = $panel_settings['bg_wrapper'];
-
- if ( isset($panel_settings['charset']) &&
- !empty($panel_settings['charset']))
- {
- $this->charset = $panel_settings['charset'];
- ini_set('default_charset', $panel_settings['charset']);
- }
-
- if ( isset($panel_settings['time_zone']) &&
- !empty($panel_settings['time_zone']))
- {
- $this->time_zone = $panel_settings['time_zone'];
- ini_set('date.timezone', $panel_settings['time_zone']);
- }
-
- if ( isset($panel_settings['panel_name']) &&
- !empty($panel_settings['panel_name']))
- $this->title = $panel_settings['panel_name'];
-
- if ( isset($panel_settings['header_code']) &&
- !empty($panel_settings['header_code']))
- $this->header_code .= $panel_settings['header_code']."\n";
-
- $module = isset($_GET['m']) ? $_GET['m'] : "";
- $subpage = isset($_GET['p']) ? $_GET['p'] : $module;
-
- $fc = array(
- $path . MODULES . $module."/".$subpage.".css",
- $path . MODULES . $module."/".$module.".css",
- MODULES . $module."/".$subpage.".css",
- MODULES . $module."/".$module.".css"
- );
- foreach($fc as $file_check){
- if(file_exists($file_check)){
- $this->header_code .= "<link rel='stylesheet' href='".$file_check."'>\n";
- break;
- }
- }
-
- $module_name = isset($_GET['m']) ? get_lang($_GET['m']) : "";
- $page_name = isset($_GET['p']) ? get_lang($_GET['p']) : "";
- $title = $page_name == "" ? $module_name : "$module_name - $page_name";
- $title = str_replace("_", " ", $title);
- $this->title = $title == "" ? $this->title : $this->title . " [$title]";
-
- // Include jQuery, jQuery UI, and our global CSS file in the header code
- $this->header_code .= '<link rel="stylesheet" href="js/jquery/ui/jquery-ui.min.css">' . "\n";
- $this->header_code .= '<script type="text/javascript" src="js/jquery/jquery.min.js"></script><script type="text/javascript" src="js/jquery/ui/jquery-ui.min.js"></script>' . "\n";
-
- // Include magnific popup
- $this->header_code .= '<script type="text/javascript" src="js/magnific/magnific.js"></script>' . "\n";
- $this->header_code .= '<link rel="stylesheet" href="js/magnific/magnific.css">' . "\n";
-
- // Include tablesorter, table collapse, and quick search
- $this->header_code .= '<script type="text/javascript" src="js/jquery/plugins/jquery.tablesorter.collapsible.js"></script>' . "\n";
- $this->header_code .= '<script type="text/javascript" src="js/jquery/plugins/jquery.tablesorter.min.js"></script>' . "\n";
- $this->header_code .= '<script type="text/javascript" src="js/jquery/plugins/jquery.quicksearch.js"></script>' . "\n";
-
- // Dump defined constants to json (for language javascript)
- $jsonStrConsts = getOGPLangConstantsJSON();
- if($jsonStrConsts !== false){
- $this->header_code .= '<script type="text/javascript">var langConsts = ' . $jsonStrConsts . ';' . "\n" . 'var langConstPrefix = "' . $OGPLangPre . '";</script>' . "\n";
- }
-
- // Include our global JS
- $this->header_code .= '<script type="text/javascript" src="js/global.js"></script>' . "\n";
- $fc = array(
- $path . MODULES . $module."/".$subpage.".js",
- $path . MODULES . $module."/".$module.".js"
- );
- foreach($fc as $file_check){
- if(file_exists($file_check)){
- $this->header_code .= "<script type='text/javascript' src='".$file_check."'></script>\n";
- break;
- }
- }
-
- $buffer = ob_get_contents();
- ob_end_clean();
-
- if ( !empty($this->refreshUrl) )
- {
- if ( $panel_settings['page_auto_refresh'] == "1" )
- {
- $topbody .= "<div id='refresh-manual'>";
- if($this->refreshUrl != "{CURRENT_PAGE}"){
- $topbody .= "<a href='".$this->refreshUrl."' class='redirectLink'>".get_lang('redirecting_in')." ".$this->refreshTime."s.</a>";
- }else{
- $url = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
- $escaped_url = htmlspecialchars( $url, ENT_QUOTES, 'UTF-8' );
- $topbody .= "<a href='" . $escaped_url . "' class='redirectLink'>".get_lang('redirecting_in')." ".$this->refreshTime."s.</a>";
- }
- $topbody .= "</div>";
-
- $this->meta .= "<meta http-equiv='refresh' content='".$this->refreshTime.";";
- if($this->refreshUrl != "{CURRENT_PAGE}"){
- $this->meta .= "url=".$this->refreshUrl;
- }
- $this->meta .= "' />";
- }
- else
- {
- $topbody .= "<div id='refresh-manual'>";
-
- if($this->refreshUrl != "{CURRENT_PAGE}"){
- $topbody .= "<a href='" . $this->refreshUrl . "'>".get_lang('refresh_page')."</a>";
- }else{
- $url = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
- $escaped_url = htmlspecialchars( $url, ENT_QUOTES, 'UTF-8' );
- $topbody .= "<a href='" . $escaped_url . "'>".get_lang('refresh_page')."</a>";
- }
- $topbody .= "</div>";
- }
- }
-
- $footer = "";
- if ( is_object($db) && array_key_exists( "OGPDatabase", class_parents($db) ) ) {
- $footer .= "<div class=\"footer center\">";
- $footer .= get_lang_f('cur_theme', !empty($_SESSION['users_theme']) ? $_SESSION['users_theme'] : @$panel_settings['theme']) . " - " . $db->getNbOfQueries()." ".get_lang('queries_executed');
- $footer .= "<br />".get_lang('copyright')." © <a href=\"http://www.opengamepanel.org\">Open Game Panel</a> " . date("Y") . " - ".get_lang('all_rights_reserved')." - <span class='versionInfo'>".get_lang('show_version')."</span><br /><div class='inline-block OGPVersionArea'><span class='version hide'>" . get_lang('version') . ":</span> <span class='hide versionNumber'>".@$panel_settings['ogp_version']."</span> <span class='copyVersionResult' lang='" . get_lang('copied') . "'></span></div></div>";
- }
- else
- {
- $footer .= "<div class='footer center'>".get_lang('copyright')." © <a href=\"http://www.opengamepanel.org\">Open Game Panel</a> " . date("Y") . " - ".get_lang('all_rights_reserved').".</div>";
- }
-
- // Add our magnific popup holder to the page (hidden element):
- $footer .= '<div class="mangificWrapper hide"><div class="white-popup"><div class="magnificTitle"></div><div class="magnificSubTitle"></div><div class="magnificContentsDiv"></div><button title="Close (Esc)" type="button" class="mfp-close">×</button></div></div>';
-
- if (!isset($_GET['action']))
- {
- $filename = 'install.php';
- if ( !empty($_SESSION['users_theme']) ) $theme = $_SESSION['users_theme'];
- else $theme = $panel_settings['theme'];
-
- // Attempt to automatically delete the install file only if an admin user has already been created and exists
- if(is_object($db)){
- $admins = $db->getAdmins();
- if (file_exists($filename) && is_array($admins) && !empty($admins)) {
- unlink($filename);
- }
- }
-
- if (is_readable($filename))
- {
- if (is_readable($filename) AND $theme == "Modern")
- {
- $top = "<h4 class='failure'>".get_lang('remove_install')."</h4>".$top;
- }
- else
- {
- $topbody = "<h4 class='failure'>".get_lang('remove_install')."</h4>".$topbody;
- }
- }
- }
-
- if ( isset($panel_settings['maintenance_mode']) && $panel_settings['maintenance_mode'] == "1" )
- {
- if ( !empty($_SESSION['users_theme']) ) $theme = $_SESSION['users_theme'];
- else $theme = $panel_settings['theme'];
-
- if (@$_SESSION['users_group'] == "admin" AND $theme == "Modern")
- {
- $top = "<h4 class='failure'>".get_lang('maintenance_mode_on')."!</b></h4>".$top;
- }
- elseif (@$_SESSION['users_group'] == "admin")
- {
- $topbody = "<h4 class='failure'>".get_lang('maintenance_mode_on')."!</b></h4>".$topbody;
- }
- }
-
- if($cleared){
- $page = $buffer;
- }
- else
- {
- $page = str_replace("%meta%",$this->meta,$page);
- $top = str_replace("%logo%",$this->logo,$top);
- $topbody = str_replace("%bg_wrapper%",$this->bg_wrapper,$topbody);
- if ( !empty($_SESSION['users_theme']) )
- $theme = $_SESSION['users_theme'];
- else
- $theme = @$panel_settings['theme'];
-
- $page = str_replace("%bg_wrapper%",$this->bg_wrapper,$page);
- $page = str_replace("%title%",$this->title,$page);
- $page = str_replace("%header_code%",$this->header_code,$page);
- $page = str_replace("%charset%",$this->charset,$page);
- $page = str_replace("%body%",$buffer,$page);
- $page = str_replace("%top%",$top,$page);
- $page = str_replace("%topbody%",$topbody,$page);
- $page = str_replace("%botbody%",$botbody,$page);
- $page = str_replace("%bottom%",$bottom,$page);
- $page = str_replace("%footer%",$footer,$page);
- $page = str_replace("%notifications%",@$notifications,$page);
- }
-
- // Set the content-type header as this is needed by older browsers
- if($dataType == "html"){
- header("Content-type: text/html; charset=" . $this->charset);
- }else if($dataType == "json"){
- header("Content-type: application/json; charset=" . $this->charset);
- }
-
- // Print everything for the template.
- print $page;
- }
- function refresh($url,$time = "")
- {
- if ( !empty($time) || $time === 0 )
- $this->refreshTime = $time;
- $this->refreshUrl = $url;
- }
- function setTitle($title)
- {
- $this->title = $title;
- }
-
- function setCharset($charset)
- {
- $this->charset = $charset;
- ini_set('default_charset', $charset);
- }
-
- function setTimeZone($time_zone)
- {
- $time_zone = (!isset($time_zone) or $time_zone == "") ? "America/Chicago" : $time_zone;
- $this->time_zone = $time_zone;
- ini_set('date.timezone', $time_zone);
- $_SESSION['time_zone'] = $time_zone;
- }
- }
- ?>
|