64 public $path =
"../content/pages/";
77 if (
$result =
$db->query(
'SELECT count(id) FROM {pages}'))
97 if ($row =
$db->query(
"SELECT meta_local, meta_keywords
99 WHERE id = '".$id.
"'"))
101 $res = $row->fetch_assoc();
104 if (
$type ==
"meta_local"){
105 if (!empty(
$res[
'meta_local'])){
106 return $res[
'meta_local'];
112 else if (
$type ==
"meta_keywords"){
113 if (!empty(
$res[
'meta_keywords'])){
114 return $res[
'meta_keywords'];
127 sys::setSyslog(
$db, 7, 1,
"failed to fetch meta $type for page ID $id", 0, 0, 0, 0);
128 return alert::draw(
"warning",
"Warning",
"Could not fetch meta $type for page ID $id",
"",4200);
143 if ($row =
$db->query(
"SELECT meta_local, meta_keywords
145 WHERE id = '".$id.
"'"))
147 $res = $row->fetch_assoc();
149 && (!empty(
$res[
'meta_local'])
150 && (!empty(
$res[
'meta_keywords'])))){
157 if (!empty(
$res[
'meta_local']) && (!empty(
$res[
'meta_keywords']))){
161 $res[
'meta_local'] =
"Unable to get Meta Description for this page. Neither local or global meta description found.";
162 $res[
'meta_keywords'] =
"Unable to get Meta Keywords for this page. Neither local or global meta keywords found.";
169 sys::setSyslog(
$db, 7, 1,
"failed to fetch meta tags for page ID $id", 0, 0, 0, 0);
170 $res[
'meta_local'] =
"Unable to get Meta Description for this page. Neither local or global meta description found.";
171 $res[
'meta_keywords'] =
"Unable to get Meta Keywords for this page. Neither local or global meta keywords found.";
199 if (
$published ===
"0") { $status =
"offline"; }
else { $status =
"online"; }
202 if (!
$db->query(
"UPDATE {pages}
204 WHERE id = '" .
$id .
"'"))
207 sys::setSyslog(
$db, 7, 1,
"failed to toggle $title status to $status", 0, 0, 0, 0);
208 print
alert::draw(
"danger",
"Error",
"Site Status could not be toggled.",
"", 4200);
212 sys::setSyslog(
$db, 5, 0,
"toggled page $id to $status", 0, 0, 0, 0);
216 if (!
$db->query(
"UPDATE {menu}
218 WHERE title = '" .
$title .
"'")) {
220 print
alert::draw(
"danger",
"Error",
"Menu Status could not be toggled.",
"", 4200);
224 sys::setSyslog(
$db, 21, 0,
"toggled menu $id to $status", 0, 0, 0, 0);
229 print
alert::draw(
"danger",
"Error",
"YaWK said: variable manipulate you shall not do!",
"", 4200);
246 if (
$db->query(
"UPDATE {pages} SET locked = '".$locked.
"' WHERE id = '".
$id.
"'")) {
253 print
alert::draw(
"danger",
"Error",
"Site Lock could not be toggled.",
"page=pages",4200);
254 if (
$locked ===
"0") { $status =
"unlocked"; }
else { $status =
"locked"; }
255 sys::setSyslog(
$db, 5,0,
"set status $status page id #$id", 0, 0, 0, 0);
269 $currentDateTime =
date(
"Y-m-d G:i:s");
281 if (
$res =
$db->query(
"SELECT MAX(id) FROM {pages}"))
283 $row = mysqli_fetch_row(
$res);
284 $this->
id = $row[0] + 1;
288 sys::setSyslog(
$db, 7, 1,
"could not fetch MAX(id) of pages database", 0, 0, 0, 0);
289 die (
"Sorry, database error: could not fetch MAX(id).");
295 if (
$result =
$db->query(
"INSERT INTO {pages} (id,gid,date_created,date_publish,alias,title,blogid,locked,lang,meta_local,meta_keywords,plugin)
296 VALUES ('" . $this->id .
"',
297 '" . $this->gid .
"',
298 '" . $currentDateTime .
"',
299 '" . $currentDateTime .
"',
300 '" . $this->alias.
'-copy'.
"',
301 '" . $this->title .
'-copy'.
"',
302 '" . $this->blogid .
"',
303 '" . $this->locked .
"',
304 '" . $this->language .
"',
305 '" . $this->meta_local .
"',
306 '" . $this->meta_keywords .
"',
307 '" . $this->plugin .
"')"))
332 if ($this->newLanguage ===
true)
334 if (!is_dir($this->path.$this->language))
336 mkdir($this->path.$this->language);
339 $page = $this->path.$this->alias.
".php";
340 $newPage = $this->path.$this->language.
"/".$this->
alias.
"-copy.php";
345 $page = $this->path.$this->alias.
".php";
346 $newPage = $this->path.$this->alias.
"-copy.php";
350 if (!
copy(
$page, $newPage) && !chmod($newPage, 0777))
352 sys::setSyslog(
$db, 8, 1,
"copy failed: $page to $newPage", 0, 0, 0, 0);
353 print
alert::draw(
"danger",
"Error!",
"File could not be copied. Check folder permissions of /content/pages !",
"",
"");
438 sys::setSyslog(
$db, 7, 1,
"could not insert data into pages table", 0, 0, 0, 0);
440 sys::setSyslog(
$db, 8, 1,
"copy $this->path.$this->alias failed.", 0, 0, 0, 0);
453 if (!
$db->query(
"DELETE FROM {pages} WHERE id = '" . $this->id .
"'")) {
454 sys::setSyslog(
$db, 7, 1,
"failed to delete page $this->alias from database", 0, 0, 0, 0);
455 alert::draw(
"danger",
"Error:",
"could not delete page from database",
"pages",
"4300");
459 sys::setSyslog(
$db, 5, 0,
"deleted page $this->alias from database", 0, 0, 0, 0);
462 if (!
$db->query(
"DELETE FROM {menu} WHERE href = '" . $this->alias .
".html'")) {
463 sys::setSyslog(
$db, 23, 1,
"failed to delete menu entry of page $this->alias from database", 0, 0, 0, 0);
464 alert::draw(
"danger",
"Error:",
"could not delete menu entry from database",
"pages",
"4300");
468 sys::setSyslog(
$db, 21, 0,
"deleted menu of ../content/pages/$this->alias.php", 0, 0, 0, 0);
478 $filename = $this->path.$this->alias.
".php";
486 sys::setSyslog(
$db, 8, 2,
"unable to delete $filename", 0, 0, 0, 0);
487 alert::draw(
"danger",
"Error:",
"could not delete file from /content/ folder",
"pages",
"4300");
492 sys::setSyslog(
$db, 5, 0,
"deleted $filename", 0, 0, 0, 0);
497 sys::setSyslog(
$db, 7, 1,
"file $filename does not exist. page->delete() failed", 0, 0, 0, 0);
515 $this->
menu = $menuID;
536 $ersetze = array(
"/ä/",
"/ü/",
"/ö/",
"/Ä/",
"/Ü/",
"/Ö/",
"/ß/");
537 $umlaute = array(
"ae",
"ue",
"oe",
"Ae",
"Ue",
"Oe",
"ss");
545 $link =
"$alias" .
".html";
548 if ($menuID !==
"empty") {
550 if (
$res =
$db->query(
"SELECT MAX(id) FROM {menu}"))
552 $row = mysqli_fetch_row(
$res);
553 if (!isset($row[0])) {
562 sys::setSyslog(
$db, 7, 1,
"failed to fetch MAX(id) FROM {menu}", 0, 0, 0, 0);
563 alert::draw(
"danger",
"Error:",
"Could not fetch MAX(id) FROM {menu}",
"page=page-new",
"4300");
566 if (
$res =
$db->query(
"SELECT MAX(sort) FROM {menu} WHERE menuID = '" . $menuID .
"'"))
568 $row = mysqli_fetch_row(
$res);
581 sys::setSyslog(
$db, 7, 1,
"failed to fetch MAX(id) FROM {menu} WHERE menuID = $menuID", 0, 0, 0, 0);
582 alert::draw(
"danger",
"Error:",
"Could not fetch MAX(id) FROM {menu} WHERE menuID = $menuID",
"page=page-new",
"4300");
600 if (!
$res =
$db->query(
"INSERT INTO {menu} (id,sort,menuID,published,title,text,href,blogid, menuLanguage)
601 VALUES('" .
$id .
"',
604 '" . $menu_published .
"',
605 '" . $titleText .
"',
609 '" . $this->language .
"')"))
611 sys::setSyslog(
$db, 23, 1,
"failed to insert data into {menu}", 0, 0, 0, 0);
612 alert::draw(
"danger",
"Error:",
"could not insert menu data",
"page=page-new",
"4300");
616 sys::setSyslog(
$db, 21, 0,
"added new menu: $title (id: $id)", 0, 0, 0, 0);
627 $content =
"<?php \$blog_id = $blogid; include 'system/plugins/blog/blog.php'; ?>";
633 $plugin = array(
"tos", $_POST[
'signup_tospage'], $_POST[
'signup_terms-long']);
642 else if (strlen(
$plugin) >= 1) {
645 $content =
"<?php include 'system/plugins/$plugin/$plugin.php'; ?>";
653 if (
$res =
$db->query(
"SELECT MAX(id) FROM {pages}"))
655 $row = mysqli_fetch_row(
$res);
661 sys::setSyslog(
$db, 7, 1,
"failed to select MAX(id) from pages db", 0, 0, 0, 0);
666 if (!
$db->query(
"INSERT INTO {pages} (id,published,date_created,date_changed,date_publish,date_unpublish,alias,title,locked,blogid,plugin,lang)
667 VALUES ('" .
$id .
"',
678 '".$this->language.
"')"))
680 sys::setSyslog(
$db, 7, 2,
"unable to add page $alias into database.", 0, 0, 0, 0);
681 alert::draw(
"danger",
"Error!",
"unable to add new page ($alias) id: $id into pages database.",
"", 4300);
688 if (!is_dir($this->path.$this->language)){
689 if (!mkdir($this->path.$this->language)){
690 sys::setSyslog(
$db, 7, 2,
"failed to create language folder: $this->path.$this->language");
709 sys::setSyslog(
$db, 5, 0,
"created $filename", 0, 0, 0, 0);
721 $date_changed =
date(
"Y-m-d G:i:s");
725 $this->
alias = str_replace(
" ",
"-", $this->
alias);
727 $umlaute = array(
"/ä/",
"/ü/",
"/ö/",
"/Ä/",
"/Ü/",
"/Ö/",
"/ß/");
728 $ersetze = array(
"ae",
"ue",
"oe",
"ae",
"ue",
"oe",
"ss");
729 $this->
alias = preg_replace($umlaute, $ersetze, $this->
alias);
730 $this->
alias = preg_replace(
"/[^a-z0-9\-\/]/i",
"", $this->
alias);
734 $oldAlias = substr($this->searchstring, 0, -5);
756 if (!
$db->query(
"UPDATE {pages}
757 SET published = '" . $this->published .
"',
758 gid = '" . $this->gid .
"',
759 date_changed = '" . $date_changed .
"',
760 date_publish = '" . $this->date_publish .
"',
761 date_unpublish = NULL,
762 title = '" . $this->title .
"',
763 alias = '" . $this->alias .
"',
764 bgimage = '" . $this->bgimage .
"',
765 lang = '" . $this->language .
"',
766 meta_local = '" . $this->meta_local .
"',
767 meta_keywords = '" . $this->meta_keywords .
"'
768 WHERE id = '" . $this->id .
"'"))
771 sys::setSyslog(
$db, 23, 1,
"failed to update database of page $this->title", 0, 0, 0, 0);
779 sys::setSyslog(
$db, 5, 0,
"updated $this->alias", 0, 0, 0, 0);
786 if (!
$db->query(
"UPDATE {pages}
787 SET published = '" . $this->published .
"',
788 gid = '" . $this->gid .
"',
789 date_changed = '" . $date_changed .
"',
790 date_publish = '" . $this->date_publish .
"',
791 date_unpublish = '" . $this->date_unpublish .
"',
792 title = '" . $this->title .
"',
793 alias = '" . $this->alias .
"',
794 bgimage = '" . $this->bgimage .
"',
795 lang = '" . $this->language .
"',
796 meta_local = '" . $this->meta_local .
"',
797 meta_keywords = '" . $this->meta_keywords .
"'
798 WHERE id = '" . $this->id .
"'"))
801 sys::setSyslog(
$db, 23, 1,
"failed to update page $this->title", 0, 0, 0, 0);
802 alert::draw(
"warning",
"Warning",
"failed to store data of $this->alias in database.",
"", 6200);
808 sys::setSyslog(
$db, 5, 0,
"updated $this->alias", 0, 0, 0, 0);
828 $filename = $dirprefix.$this->path.$this->alias.
"php";
858 $this->
alias = str_replace(
" ",
"-", $this->
alias);
860 $specialChars = array(
"/ä/",
"/ü/",
"/ö/",
"/Ä/",
"/Ü/",
"/Ö/",
"/ß/");
861 $replacementChars = array(
"ae",
"ue",
"oe",
"ae",
"ue",
"oe",
"ss");
863 $this->
alias = preg_replace(
"/[^a-z0-9\-\/]/i",
"", $this->
alias);
868 if (!is_dir($this->path.$this->language))
870 mkdir ($this->path.$this->language);
877 $filename = $this->path.$this->alias.
".php";
891 sys::setSyslog(
$db, 7, 2,
"unable to write content to file $filename", 0, 0, 0, 0);
910 $filename = $this->path.$this->alias.
".php";
924 return 'ERROR: Unable to read content of file: '.$filename.
'
925 Maybe the file has been physically deleted, moved or renamed.';
931 if (isset(
$id) && (!empty(
$id)))
933 $res =
$db->query(
"SELECT lang FROM {pages} WHERE id ='".
$id.
"'");
934 $currentLanguage = mysqli_fetch_row(
$res);
937 if (isset($currentLanguage[0]) && (!empty($currentLanguage[0])))
939 return $currentLanguage[0];
957 $res =
$db->query(
"SELECT * FROM {pages} WHERE alias = '".
$alias.
"'");
958 if ($row = mysqli_fetch_assoc(
$res))
960 $this->
id = $row[
'id'];
961 $this->date_created = $row[
'date_created'];
965 $this->
gid = $row[
'gid'];
966 $this->
title = $row[
'title'];
967 $this->ownerid = $row[
'owner'];
968 $this->
menu = $row[
'menu'];
969 $this->
bgimage = $row[
'bgimage'];
970 $this->locked = $row[
'locked'];
971 $this->
blogid = $row[
'blogid'];
972 $this->
plugin = $row[
'plugin'];
980 if ($this->
alias ==
"content/errors/404")
982 if (isset($_SESSION[
'uid']) && (!empty($_SESSION[
'uid'])))
984 sys::setSyslog(
$db, 7, 2,
"404: file not found - displayed $alias instead", $_SESSION[
'uid'], 0, 0, 0);
988 sys::setSyslog(
$db, 7, 2,
"404: file not found - displayed $alias instead", 0, 0, 0, 0);
995 sys::setSyslog(
$db, 7, 2,
"failed to load properties because page alias was not set", 0, 0, 0, 0);
1007 if (isset(
$id) && (!empty(
$id)))
1009 $res =
$db->query(
"SELECT * FROM {pages} WHERE id = '".
$id.
"'");
1010 if ($row = mysqli_fetch_assoc(
$res))
1012 $this->
id = $row[
'id'];
1013 $this->date_created = $row[
'date_created'];
1017 $this->
gid = $row[
'gid'];
1018 $this->
alias = $row[
'alias'];
1019 $this->
title = $row[
'title'];
1020 $this->ownerid = $row[
'owner'];
1021 $this->
menu = $row[
'menu'];
1022 $this->
bgimage = $row[
'bgimage'];
1023 $this->locked = $row[
'locked'];
1024 $this->
blogid = $row[
'blogid'];
1025 $this->
plugin = $row[
'plugin'];
1032 if ($this->
alias ==
"content/errors/404")
1034 if (isset($_SESSION[
'uid']) && (!empty($_SESSION[
'uid'])))
1036 sys::setSyslog(
$db, 7, 2,
"404: file not found - displayed $this->alias instead", $_SESSION[
'uid'], 0, 0, 0);
1040 sys::setSyslog(
$db, 7, 2,
"404: file not found - displayed $this->alias instead", 0, 0, 0, 0);
1047 sys::setSyslog(
$db, 7, 2,
"failed to load properties because page ID was not set", 0, 0, 0, 0);
1061 if (!isset($limit) && (empty($limit))) { $limit = 4; }
1063 if (
$res =
$db->query(
"SELECT id, alias, title, published, date_publish
1067 ORDER BY date_created
1068 DESC LIMIT $limit"))
1070 $latestPages = array();
1071 while ($row = mysqli_fetch_assoc(
$res))
1073 $latestPages[] = $row;
1075 return $latestPages;
1079 return "no pages found.";
1093 if (
$res =
$db->query(
"SELECT $property FROM {pages}
1094 WHERE id = '" .
$id .
"'"))
1096 if ($row = mysqli_fetch_row(
$res)){
1102 sys::setSyslog(
$db, 7, 1,
"unable to get property: $property from pages database.", 0, 0, 0, 0);
1103 alert::draw(
"warning",
"Warning",
"unable to get property: $property from Paged Database.",
"",
"4200");
1118 global $currentpage;
1119 if (!isset($currentpage) || (empty($currentpage)))
1121 die(
"CRITICAL ERROR: unable to display content - currentpage var is not set.");
1123 if (isset($currentpage->date_publish))
1126 if (isset($_SESSION[
'gid'])) {
1128 if ($_SESSION[
'gid'] <= $currentpage->gid)
1130 sys::setSyslog(
$db, 11, 1,
"user with group ID $_SESSION[gid] is not allowed to view $currentpage->alias (required GID: $currentpage->gid)", 0, 0, 0, 0);
1134 else if ($currentpage->gid > 1)
1136 sys::setSyslog(
$db, 11, 1,
"public user tried to get content of $currentpage->alias (required GID: $currentpage->gid)", 0, 0, 0, 0);
1141 $future = (isset($currentpage->date_publish));
1143 if (isset($currentpage->date_publish_end))
1145 $publish_end = $currentpage->date_publish_end;
1151 $date_published = trim($future);
1152 $publish_end = trim(isset($publish_end));
1153 $date_now = trim(
$now);
1156 $date_now = substr(
$now, 0, 10);
1157 $time_now = substr(
$now, -8);
1159 $date_published = substr($future, 0, 10);
1160 $time_published = substr($future, -8);
1162 $date_publish_end = substr($publish_end, 0, 10);
1163 $time_publish_end = substr($publish_end, -8);
1166 $time_publish_end = str_replace(
":",
"", $time_publish_end);
1167 $time_published = str_replace(
":",
"", $time_published);
1168 $time_now = str_replace(
":",
"", $time_now);
1169 $date_published = str_replace(
"-",
"", $date_published);
1170 $date_now = str_replace(
"-",
"", $date_now);
1172 if ($time_now >= $time_publish_end &&
1173 $date_now >= $date_publish_end &&
1174 $time_now <= $time_published &&
1175 $date_now <= $date_published ||
1176 $currentpage->published == 0
1184 if ($currentpage->date_publish >
$now) {
1186 if ($timediff ===
'1') {
1187 echo
"<br>Content Pending. Publishing is scheduled for $currentpage->date_publish<br><br>";
1192 $start = strtotime(
$now);
1193 $end = strtotime($currentpage->date_publish);
1195 if ($timediff ===
'1') {
1196 echo
"time diff here";
1201 if ($currentpage->date_unpublish <
$now XOR $currentpage->date_unpublish === NULL) {
1202 echo
"<br>Sadly, this content is not available anymore. <br><br>";
1204 if ($timediff ===
'1') {
1205 echo
"Publishing has ended on $currentpage->date_unpublish.<br><br>";
1218 $path =
"content/pages/";
1228 $languageFolder =
'';
1229 $trailingSlash =
'';
1232 $contentLanguageFolders = array();
1233 foreach (
new DirectoryIterator(
$path) as $fileInfo) {
1234 if($fileInfo->isDot())
continue;
1235 if($fileInfo->isFile())
continue;
1236 if($fileInfo->isDir())
1237 $contentLanguageFolders[] = $fileInfo->getFilename();
1240 if (
$language->httpAcceptedLanguage == $fileInfo->getFilename())
1242 $languageFolder = $fileInfo->getFilename();
1243 $trailingSlash =
"/";
1248 $languageFolder =
'';
1252 if (isset(
$_GET[
'language']) && (!empty(
$_GET[
'language'])))
1254 $languageFolder = mb_substr(
$_GET[
'language'], 0,2);
1255 $trailingSlash =
"/";
1262 if (isset($_COOKIE[
'userSelectedLanguage']) && (!empty($_COOKIE[
'userSelectedLanguage']))){
1263 $languageFolder = $_COOKIE[
'userSelectedLanguage'];
1264 $trailingSlash =
"/";
1276 if (in_array(
"$languageFolder", $contentLanguageFolders)) {
1278 if (is_dir(
$path.$languageFolder))
1281 if (is_file(
$path.$languageFolder.$trailingSlash.$this->alias.$fileExt))
1289 if (is_file(
$path.$this->alias))
1300 if (is_file(
$path.$this->alias))
print $lang['FILEMAN_UPLOAD']
if(!isset($blog)) if(!isset($language)||(!isset($lang))) if(!isset($db)) $blog published
static draw($type, $title, $text, $redirect, $delay)
static filterfilename($db, $lang, $filename)
Main filter controller: checks GET params and lead to corresponding actions.
The language class - support multilingual backend.
The default pages class. Provide all functions to handle static pages.
getProperty($db, $id, $property)
get any requested page property
static getLatest($db, $limit)
get latest pages
create($db, $alias, $menuID, $locked, $blogid, $plugin)
create a new page
toggleLock($db, $id, $locked)
toggle page lock to avoid unintended changes
copy($db)
make a copy of a page
readContent($dirPrefix)
read content from static page
static countPages($db)
count and return the pages in database
loadProperties($db, $alias)
load page properties and store as object properties
writeContent($content)
write content to static page
getContent($db, $lang)
get and include static page content
loadPropertiesByID($db, $id)
load page properties and store as object properties
deleteContent($dirprefix)
delete a static content page
getCurrentLanguageByID($db, $id)
save($db)
save a static page including all settings
static getMetaTags($db, $id, $type)
get and return meta tags for requested page
toggleOffline($db, $id, $published, $title)
toggle page status online or offline (plus corresponding menu entries)
static getMetaTagsArray($db, $id)
get and return meta tags of requested page as array
Handles the Plugin System.
static getSetting($db, $property)
Get and return value for property from settings database.
static iStatusToString($i, $on, $off)
convert a integer status to string variable (0|1) to online / offline
static encodeChars($string)
convert german special chars and vowels into legal html
This class serves methods to create backup from files.
print $page meta_keywords
if(!isset($page)) if(!isset($db)) if(!isset($lang)) if(isset($_GET['id'])) if(isset($_POST['save'])) $dirprefix
print $page date_unpublish