149 bool $auto_header =
true,
150 bool $auto_auth =
true
153 global
$database, $MESSAGE, $section_id, $page_id;
155 parent::__construct();
157 static::$instance = $this;
159 $section_id = (isset ($_POST[
'section_id']) ? intval($_POST[
'section_id']) : 0);
160 if ($section_id == 0 )
162 $section_id = (isset ($_GET[
'section_id'])? intval($_GET[
'section_id']): 0);
165 $page_id = (isset ($_POST[
'page_id']) ? intval($_POST[
'page_id']) : 0);
168 $page_id = (isset ($_GET[
'page_id']) ? intval($_GET[
'page_id']) : 0);
174 if (is_null($this->oTWIG))
176 $this->oTWIG = lib_twig_box::getInstance();
177 $this->oTWIG->loader->prependPath(
THEME_PATH.
"/templates/",
"theme" );
184 if (
true === $auto_auth)
195 if ($auto_auth ===
true)
198 if ($this->is_authenticated() ===
false)
200 header(
'Location:' . ADMIN_URL .
'/login/index.php');
205 if (!$this->checkLepToken())
207 $pin_set = $this->database->get_one(
"SELECT `pin_set` FROM `".TABLE_PREFIX.
"users` WHERE `user_id` = '".$_SESSION[
'USER_ID'].
"' ");
210 $this->database->simple_query(
"UPDATE `" . TABLE_PREFIX .
"users` SET `pin_set` = 1 WHERE user_id = '" . $_SESSION[
'USER_ID'] .
"' ");
212 unset($_SESSION[
'USER_ID']);
213 header(
'Location:' . ADMIN_URL .
'/login/index.php');
224 die($MESSAGE[
'ADMIN_INSUFFICIENT_PRIVILEGES'].
" [007-002]");
228 die($MESSAGE[
'ADMIN_INSUFFICIENT_PRIVILEGES'].
" [007-001]");
235 $this->database->execute_query(
236 "SELECT `language` FROM `" . TABLE_PREFIX .
"users` WHERE `user_id` = '" . (
int) $this->getValue(
'user_id',
'integer',
'session') .
"'",
242 $user_language = (!isset($user_language[
'language']))
244 : substr($user_language[
'language'], 0,2)
248 $admin_folder = str_replace(LEPTON_PATH,
'', ADMIN_PATH);
249 if ((LANGUAGE != $user_language) && file_exists(LEPTON_PATH .
'/languages/' . $user_language .
'.php') && strpos($_SERVER[
'SCRIPT_NAME'], $admin_folder .
'/') !==
false)
252 $page_id_url = (isset($_GET[
'page_id'])) ?
'&page_id=' . (
int) $_GET[
'page_id'] :
'';
253 $section_id_url = (isset($_GET[
'section_id'])) ?
'§ion_id=' . (
int) $_GET[
'section_id'] :
'';
254 if (isset($_SERVER[
'QUERY_STRING']) && $_SERVER[
'QUERY_STRING'] !=
'')
256 header(
'Location: ' . $_SERVER[
'SCRIPT_NAME'] .
'?lang=' . $user_language . $page_id_url . $section_id_url .
'&' . $_SERVER[
'QUERY_STRING']);
260 header(
'Location: ' . $_SERVER[
'SCRIPT_NAME'] .
'?lang=' . $user_language . $page_id_url . $section_id_url);
266 if ($auto_header ===
true)
272 if(CRONJOB == 2 || CRONJOB == 3)
533 $title = $this->database->get_one(
"SELECT `value` FROM `".TABLE_PREFIX.
"settings` WHERE `name`='website_title'");
535 $charset = (
true === defined(
'DEFAULT_CHARSET')) ? DEFAULT_CHARSET :
'utf-8';
539 $view_url = LEPTON_URL;
540 if (isset($_GET[
'page_id']))
543 $result = $this->database->get_one(
"SELECT `link` FROM `" . TABLE_PREFIX .
"pages` WHERE `page_id`= '" . (
int) addslashes($_GET[
'page_id']) .
"'");
544 if (!is_null($result))
546 $view_url .= PAGES_DIRECTORY.$result.PAGE_EXTENSION;
554 $backend_theme_version =
"";
555 if (defined(
'DEFAULT_THEME'))
557 $backend_theme_version = $this->database->get_one(
"SELECT `version` from `" . TABLE_PREFIX .
"addons` where `directory`='" . DEFAULT_THEME .
"'");
561 'SECTION_NAME' => $MENU[strtoupper($this->section_name)],
562 'WEBSITE_TITLE' => $title,
563 'BACKEND_TITLE' => BACKEND_TITLE,
564 'TEXT_ADMINISTRATION' => $TEXT[
'ADMINISTRATION'],
565 'CURRENT_USER' => $MESSAGE[
'START_CURRENT_USER'],
566 'DISPLAY_NAME' => $this->getValue(
'display_name',
'string',
'session'),
567 'CHARSET' => $charset,
568 'LANGUAGE' => strtolower(LANGUAGE),
569 'LEPTON_VERSION' => LEPTON_VERSION,
570 'SUBVERSION' => SUBVERSION,
571 'LEPTON_URL' => LEPTON_URL,
572 'ADMIN_URL' => ADMIN_URL,
573 'THEME_URL' => THEME_URL,
574 'TITLE_START' => $MENU[
'START'],
575 'TITLE_VIEW' => $MENU[
'VIEW'],
576 'TITLE_HELP' => $MENU[
'HELP'],
577 'TITLE_LOGOUT' => $MENU[
'LOGOUT'],
587 'URL_VIEW' => $view_url,
588 'URL_HELP' =>
' https://lepton-cms.org/',
590 'THEME_VERSION' => $backend_theme_version,
591 'THEME_NAME' => DEFAULT_THEME,
617 echo $this->oTWIG->render(
640 echo $this->oTWIG->render(
653 $this->html_output_storage = ob_get_clean();
654 if (
true === $this->droplets_ok)
656 evalDroplets($this->html_output_storage);
660 if ($this->is_authenticated() )
662 LEPTON_core::getInstance()->getProtectedFunctions($this->html_output_storage, $this);
665 echo $this->html_output_storage;
790 if (LEPTON_core::userHasAdminRights() ==
true)
795 if (empty($this->adminTools))
797 $aAllAdminToolsStorage = [];
798 $this->database->execute_query(
799 "SELECT `directory` FROM `".TABLE_PREFIX.
"addons` WHERE `function` = 'tool'",
801 $aAllAdminToolsStorage,
805 foreach ($aAllAdminToolsStorage as $tempTool)
807 $this->adminTools[] = $tempTool[
'directory'];
811 $aUserModules = LEPTON_core::getValue(
"module_permissions",
"array",
"session");
813 return !empty(array_intersect($aUserModules, $this->adminTools));