requested = str_replace(' ','_',$title); $this->label = $langmessage['administration']; $this->scripts = \gp\admin\Tools::AdminScripts(); $this->script_keys = array_keys($this->scripts); $this->script_keys = array_combine( str_replace('_','/',$this->script_keys), $this->script_keys); $this->lang = $config['language']; $this->language = $languages[$this->lang]; $this->head .= "\n".''; @header( 'X-Frame-Options: SAMEORIGIN' ); } public function RunScript(){ ob_start(); $this->RunAdminScript(); $this->contentBuffer = ob_get_clean(); //display admin area in full window? if( $this->FullDisplay() ){ $this->get_theme_css = false; $_REQUEST['gpreq'] = 'admin'; } } //display admin area in full window private function FullDisplay(){ if( \gp\tool::RequestType() == 'template' && $this->show_admin_content ){ return true; } return false; } //called by templates public function GetContent(){ $this->GetGpxContent(); /* rendering non_admin_content moved to GetGpxContent() */ echo '
'; \gp\tool\Output::Get('AfterContent'); \gp\tool\Plugins::Action('GetContent_After'); echo '
'; } public function GetGpxContent($ajax = false){ global $gp_admin_html; if( empty($this->show_admin_content) ){ /* non_admin_content inside #gpx_content */ echo '
'; $this->GetNonAdminContent(); echo '
'; return; } $request_type = \gp\tool::RequestType(); if( $request_type == 'body' ){ echo $this->contentBuffer; return; } ob_start(); echo '
'; echo '
'; $this->AdminContentPanel(); $this->BreadCrumbs(); echo '
'; echo $this->contentBuffer; echo '
'; echo '
'; // /#admincontent /* non_admin_content is now inside #gpx_content */ $this->GetNonAdminContent(); echo '
'; // /#gpx_content $admin_content = ob_get_clean(); if( !$ajax ){ $gp_admin_html .= '
'.$admin_content.'
'; return; } echo $admin_content; } public function GetNonAdminContent(){ if( !empty($this->non_admin_content) ){ echo '
'; if( strpos(\gp\tool\Output::$components, 'bootstrap') !== false ){ echo $this->non_admin_content_bootstrap; }else{ echo $this->non_admin_content; } echo '
'; echo '
'; } } private function BreadCrumbs(){ global $langmessage, $config; echo '
'; echo \gp\tool::Link('',$langmessage['Homepage']); echo ' » '; echo \gp\tool::Link('Admin',$langmessage['administration']); $crumbs = array(); $request_string = str_replace('_','/',$this->requested); $parts = explode('/',$request_string); $addon_key = false; do{ $request_string = implode('/',$parts); $scriptinfo = $this->GetScriptInfo($request_string); if( isset($scriptinfo['addon']) ){ $addon_key = $scriptinfo['addon']; } if( is_array($scriptinfo) && isset($scriptinfo['label']) ){ $crumbs[$request_string] = $scriptinfo['label']; } }while(array_pop($parts)); //add addon to crumbs if( $addon_key && isset($config['addons'][$addon_key]) ){ $slug = 'Admin/Addons/'.\gp\admin\Tools::encode64($addon_key); $crumbs[$slug] = $config['addons'][$addon_key]['name']; $crumbs['Admin/Addons'] = $langmessage['plugins']; } //page label $this->label = implode(' « ', $crumbs); //add to breadcrumbs $crumbs = array_reverse($crumbs); foreach($crumbs as $slug => $label){ echo ' » '; echo \gp\tool::Link($slug,$label); } echo '
'; } /** * Output toolbar for admin window * */ private function AdminContentPanel(){ global $langmessage; echo '
'; echo '
'; \gp\tool\Output::GetTopTwoMenu(); echo '
'; self::ToolbarSearch(); echo '
'; } public static function ToolbarSearch(){ echo ''; } /** * Find the requested admin script and execute it if the user has permissions to view it * */ private function RunAdminScript(){ global $dataDir, $langmessage; if( strtolower($this->requested) == 'admin' ){ $this->AdminPanel(); return; } //resolve request for /Admin_Theme_Content if the request is for /Admin_Theme_Conent/1234 $request_string = str_replace('_','/',$this->requested); $parts = explode('/',$request_string); $extra_parts = []; do{ $request_string = implode('/',$parts); $scriptinfo = $this->GetScriptInfo($request_string); if( is_array($scriptinfo) ){ if( \gp\admin\Tools::HasPermission($request_string) ){ $this->OrganizeFrequentScripts($request_string); // get extra parts without underscores replaced with slashes $len = strlen($request_string); $extra = substr($this->requested,$len); $extra_parts = explode('/',$extra); $extra_parts = array_filter($extra_parts); $extra_parts = array_values($extra_parts); \gp\tool\Output::ExecInfo($scriptinfo, array('page'=>$this,'path_parts'=>$extra_parts) ); return; } msg($langmessage['not_permitted'] . ' (' . $request_string . ')'); $this->AdminPanel(); return; } //these are here because they should be available to everyone switch($request_string){ case 'Admin/Finder': if( \gp\admin\Tools::HasPermission('Admin_Uploaded') ){ includeFile('thirdparty/elFinder/connector.php'); return; } break; } array_pop($parts); }while( count($parts) ); $this->Redirect(); } /** * Get admin script info if the request slug uses underscores or slashes * */ private function GetScriptInfo(&$request_string){ if( isset($this->script_keys[$request_string]) ){ $request_string = $this->script_keys[$request_string]; return $this->scripts[$request_string]; } return false; } /** * Redirect admin request to the most similar page * */ private function Redirect(){ //find similar $scripts = $this->scripts; $scripts['Admin'] = array(); $similar = array(); $lower_req = strtolower($this->requested); foreach($scripts as $key => $script_info){ $lower_key = strtolower($key); similar_text($lower_req,$lower_key,$percent); $similar[$key] = $percent; } arsort($similar); $redir_key = key($similar); $location = \gp\tool::GetUrl($redir_key,'',false); \gp\tool::Redirect($location); } /** * Show the default admin page * */ private function AdminPanel(){ global $langmessage; $cmd = \gp\tool::GetCommand(); switch($cmd){ case 'embededcheck': new \gp\admin\Update('embededcheck'); return; case 'autocomplete-titles': $opts = array('var_name'=>false); echo \gp\tool\Editing::AutoCompleteValues(false,$opts); die(); } $this->head_js[] = '/include/js/auto_width.js'; echo '

'.$langmessage['administration'].'

'; echo '
'; \gp\admin\Tools::AdminPanelLinks(false); echo '
'; } /** * Increment freq_scripts for $page and sort by counts * */ private function OrganizeFrequentScripts($page){ global $gpAdmin; if( !isset($gpAdmin['freq_scripts']) ){ $gpAdmin['freq_scripts'] = array(); } if( !isset($gpAdmin['freq_scripts'][$page]) ){ $gpAdmin['freq_scripts'][$page] = 0; }else{ $gpAdmin['freq_scripts'][$page]++; if( $gpAdmin['freq_scripts'][$page] >= 10 ){ $this->CleanFrequentScripts(); } } arsort($gpAdmin['freq_scripts']); } /** * Reduce the number of scripts in freq_scripts * */ private function CleanFrequentScripts(){ global $gpAdmin; //reduce to length of 5; $count = count($gpAdmin['freq_scripts']); if( $count > 3 ){ for($i=0;$i < ($count - 5);$i++){ array_pop($gpAdmin['freq_scripts']); } } //reduce the hit count on each of the top five $min_value = end($gpAdmin['freq_scripts']); foreach($gpAdmin['freq_scripts'] as $page => $hits){ $gpAdmin['freq_scripts'][$page] = $hits - $min_value; } } }