47 LEPTON_core::registerBasicFunctions();
48 LEPTON_core::loadCodeSnippets();
52 if(CRONJOB == 1 || CRONJOB == 3)
58 self::$instance = $this;
61 if (!isset($_SESSION[
'USER_ID']))
67 $pin_set = $this->database->get_one(
"SELECT pin_set FROM ".TABLE_PREFIX.
"users WHERE user_id = '".$_SESSION[
'USER_ID'].
"' ");
75 header(
'Location: '.LEPTON_URL.
'/account/logout.php');
80 LEPTON_SecureCMS::clearLepTokens();
84 LEPTON_SecureCMS::clearLepTokens();
85 header(
'Location: '.LEPTON_URL.
'/account/logout.php');
95 if (PAGE_LANGUAGES ==
true)
97 $sql_where_language =
" AND language = '".LANGUAGE.
"'";
101 $sql_where_language =
"";
108 FROM `".TABLE_PREFIX .
"pages` AS `p`
109 INNER JOIN `".TABLE_PREFIX .
"sections`
115 AND `visibility` = 'public'
118 (".$now.
" >= `publ_start` OR `publ_start` = 0)
120 (".$now.
" <= `publ_end` OR `publ_end` = 0)
122 ".$sql_where_language.
"
130 $this->database->execute_query(
140 if (!empty($fetch_default))
142 $this->default_link = $fetch_default[
'link' ];
143 $this->default_page_id = intval($fetch_default[
'page_id' ]);
146 if ( HOMEPAGE_REDIRECTION )
149 header(
"Location: " . $this->buildPageLink( $this->default_link ) );
166 if(!isset($fetch_default[
'link' ]))
172 $this->default_link = $fetch_default[
'link' ];
173 $this->default_page_id = intval($fetch_default[
'page_id' ]);
174 $this->page = $fetch_default;
183 if ($this->page_id != 0)
186 $query_page =
"SELECT * FROM ".TABLE_PREFIX.
"pages WHERE page_id = ".
$this->page_id;
187 $this->database->execute_query(
195 if (empty($this->page))
198 exit(
"Page not found." );
202 foreach ($this->page as $key => $value)
205 $key = strtoupper($key);
208 if ($key ===
'TEMPLATE' && empty($value))
210 $value = $this->database->get_one(
"SELECT value FROM ".TABLE_PREFIX.
"settings WHERE name = 'default_template' ");
213 if ($key ===
'DESCRIPTION' && empty($value))
215 $value = WEBSITE_DESCRIPTION;
218 if ($key ===
'KEYWORDS' && empty($value))
220 $value = WEBSITE_KEYWORDS;
223 define($key, $value);
230 foreach ( explode(
',', $this->page[
'page_trail' ] ) AS $pid )
232 $this->page_trail[ $pid ] = $pid;
238 if(!defined(
'TEMPLATE'))
240 define(
'TEMPLATE', DEFAULT_TEMPLATE);
242 define(
'TEMPLATE_DIR', LEPTON_URL .
'/templates/' . TEMPLATE );
244 if ($this->page_is_visible($this->page) ===
false)
246 if ( VISIBILITY ==
'deleted' || VISIBILITY ==
'none' )
249 $this->page_access_denied =
true;
251 elseif ( VISIBILITY ==
'private' || VISIBILITY ==
'registered' )
254 if ( $this->is_authenticated() ===
false )
257 header(
"Location: " . LEPTON_URL .
"/account/login.php?redirect=" . $this->buildPageLink($this->page[
'link']) );
262 $aAllowedGroupsId = explode(
',',$this->page[
'viewing_groups']);
263 $aSessionGroupsId = LEPTON_core::getValue(
'groups_id',
'string_clean',
'session',
',');
264 $result = array_intersect( $aSessionGroupsId,$aAllowedGroupsId);
268 $this->page_access_denied =
false;
273 $this->page_access_denied =
true;
282 if ($this->page_is_active($this->page) ===
false)
284 $this->page_no_active_sections =
true;
335 $content = str_ireplace( [
"%5B",
"%5D"], [
"[",
"]"], $content);
338 if (preg_match_all(
'/\[LEPTONlink([0-9]+)\]/isU', $content, $ids))
340 $new_ids = array_unique( $ids[ 1 ] );
341 foreach ($new_ids as $key => $temp_page_id)
343 $link = $this->database->get_one(
"SELECT `link` FROM `" . TABLE_PREFIX .
"pages` WHERE `page_id` = " . $temp_page_id );
346 $content = str_replace($ids[0][$key], $this->buildPageLink($link), $content);
349 unset($temp_page_id);