49 LEPTON_core::registerBasicFunctions();
50 LEPTON_core::loadCodeSnippets();
55 if(CRONJOB == 1 || CRONJOB == 3)
61 self::$instance = $this;
64 if (!isset($_SESSION[
'USER_ID']))
70 $pin_set = $this->database->get_one(
"SELECT pin_set FROM ".TABLE_PREFIX.
"users WHERE user_id = '".$_SESSION[
'USER_ID'].
"' ");
78 header(
'Location: '.LEPTON_URL.
'/account/logout.php');
83 LEPTON_SecureCMS::clearLepTokens();
87 LEPTON_SecureCMS::clearLepTokens();
88 header(
'Location: '.LEPTON_URL.
'/account/logout.php');
98 if (PAGE_LANGUAGES ==
true)
100 $sql_where_language =
" AND p.language = '".LANGUAGE.
"'";
104 $sql_where_language =
"";
111 FROM ".TABLE_PREFIX .
"pages AS p
112 INNER JOIN ".TABLE_PREFIX .
"sections AS s
114 ON (s.page_id = p.page_id)
118 AND p.visibility = 'public'
121 ((".$now.
" >= s.publ_start) OR (s.publ_start = 0))
123 ((".$now.
" <= s.publ_end) OR (s.publ_end = 0))
125 ".$sql_where_language.
"
133 $this->database->execute_query(
143 if (!empty($fetch_default))
145 $this->default_link = $fetch_default[
'link' ];
146 $this->default_page_id = intval($fetch_default[
'page_id' ]);
149 if (HOMEPAGE_REDIRECTION)
152 header(
"Location: ".$this->buildPageLink($this->default_link));
169 if (!isset($fetch_default[
'link' ]))
175 $this->default_link = $fetch_default[
'link' ];
176 $this->default_page_id = intval($fetch_default[
'page_id' ]);
177 $this->page = $fetch_default;
186 $this->page_id = intval($this->page_id);
187 if ($this->page_id != 0)
190 $query_page =
"SELECT * FROM ".TABLE_PREFIX.
"pages WHERE page_id = ".
$this->page_id;
191 $this->database->execute_query(
199 if (empty($this->page))
202 exit(
"Page not found." );
206 foreach ($this->page as $key => $value)
209 $key = strtoupper($key);
212 if ($key ===
'TEMPLATE' && empty($value))
214 $value = $this->database->get_one(
"SELECT value FROM ".TABLE_PREFIX.
"settings WHERE name = 'default_template' ");
217 if ($key ===
'DESCRIPTION' && empty($value))
219 $value = WEBSITE_DESCRIPTION;
222 if ($key ===
'KEYWORDS' && empty($value))
224 $value = WEBSITE_KEYWORDS;
227 define($key, $value);
234 foreach ( explode(
',', $this->page[
'page_trail' ] ) AS $pid )
236 $this->page_trail[ $pid ] = $pid;
242 if(!defined(
'TEMPLATE'))
244 define(
'TEMPLATE', DEFAULT_TEMPLATE);
246 define(
'TEMPLATE_DIR', LEPTON_URL .
'/templates/' . TEMPLATE );
248 if ($this->page_is_visible($this->page) ===
false)
250 if ( VISIBILITY ==
'deleted' || VISIBILITY ==
'none' )
253 $this->page_access_denied =
true;
255 elseif ( VISIBILITY ==
'private' || VISIBILITY ==
'registered' )
258 if ( $this->is_authenticated() ===
false )
261 header(
"Location: " . LEPTON_URL .
"/account/login.php?redirect=" . $this->buildPageLink($this->page[
'link']) );
266 $aAllowedGroupsId = explode(
',',$this->page[
'viewing_groups']);
267 $aSessionGroupsId = LEPTON_core::getValue(
'groups_id',
'string_clean',
'session',
',');
268 $result = array_intersect( $aSessionGroupsId,$aAllowedGroupsId);
272 $this->page_access_denied =
false;
277 $this->page_access_denied =
true;
286 if ($this->page_is_active($this->page) ===
false)
288 $this->page_no_active_sections =
true;
339 $content = str_ireplace( [
"%5B",
"%5D"], [
"[",
"]"], $content);
342 if (preg_match_all(
'/\[LEPTONlink([0-9]+)\]/isU', $content, $ids))
344 $new_ids = array_unique( $ids[ 1 ] );
345 foreach ($new_ids as $key => $temp_page_id)
347 $link = $this->database->get_one(
"SELECT `link` FROM `" . TABLE_PREFIX .
"pages` WHERE `page_id` = " . $temp_page_id );
350 $content = str_replace($ids[0][$key], $this->buildPageLink($link), $content);
353 unset($temp_page_id);