YaWK  24.1
Yet another WebKit
page.php
Go to the documentation of this file.
1 <?php
2 namespace YAWK {
3 
4  use DirectoryIterator;
5 
6  /**
7  * @details <b>The default pages class. Provide all functions to handle static html pages.</b>
8  *
9  * All functions that are required to handle a page. Methods are: create, save, edit, delete and many more.
10  * <p><i>Class covers both, backend & frontend functionality.
11  * See Methods Summary for Details!</i></p>
12  *
13  * @author Daniel Retzl <[email protected]>
14  * @copyright 2009-2016 Daniel Retzl
15  * @license https://opensource.org/licenses/MIT
16  * @version 1.0.0
17  * @brief The default pages class. Provide all functions to handle static pages.
18  */
19  class page
20  {
21  /** * @param int every page got its own id */
22  public $id = -1;
23  /** * @param string page filename */
24  public $alias = '';
25  /** * @param string new page filename (used by copy function) */
26  public $alias_new = '';
27  /** * @param string page title */
28  public $title = '';
29  /** * @param string new page title (used by copy function) */
30  public $title_new = '';
31  /** * @param int 0|1 published status */
32  public $published = 0;
33  /** * @param int uid (user id) of the page owner */
34  public $ownerid = -1;
35  /** * @param int menu id according to this page */
36  public $menu = -1;
37  /** * @param int group id for this page */
38  public $gid;
39  /** * @param string date when the site is created */
40  public $date_created;
41  /** * @param string date when the site is published */
42  public $date_publish;
43  /** * @param string date when the site should be unpublished */
45  /** * @param int plugin ID of that page */
46  public $plugin;
47  /** * @param int blog ID of that page*/
48  public $blogid;
49  /** * @param int 0|1 to check if the page is locked */
50  public $locked;
51  /** * @param string meta description for this page */
53  /** * @param string meta keywords for this page*/
54  public $metakeywords;
55  /** * @param string search string for this page */
56  public $searchstring;
57  /** * @param string bg image */
58  public $bgimage;
59  /** * @param string page language */
60  public $language;
61  /** * @param bool copy page into new language indicator */
62  public $newLanguage;
63  /** * @param string the root path where pages are physically stored */
64  public $path = "../content/pages/";
65  /** * @param string the meta tags description of this page */
66  public $meta_local = "Meta Tag Description";
67  /** * @param string the meta tags keywords of this page */
68  public $meta_keywords = "Meta Tag Keywords";
69 
70  /**
71  * @brief count and return the pages in database
72  * @param object $db database
73  * @return int|bool
74  */
75  static function countPages($db)
76  { /** @param $db db */
77  if ($result = $db->query('SELECT count(id) FROM {pages}'))
78  {
79  $i = mysqli_fetch_row($result);
80  return $i[0];
81  }
82  else
83  {
84  return false;
85  }
86  }
87 
88  /**
89  * @brief get and return meta tags for requested page
90  * @param object $db database
91  * @param int $id affected page ID
92  * @param string $type meta description
93  * @return string|bool meta tags as string
94  */
95  public static function getMetaTags($db, $id, $type)
96  { /** @param $db db $res */
97  if ($row = $db->query("SELECT meta_local, meta_keywords
98  FROM {pages}
99  WHERE id = '".$id."'"))
100  { // output meta content description
101  $res = $row->fetch_assoc();
102  if (!empty($type))
103  {
104  if ($type == "meta_local"){
105  if (!empty($res['meta_local'])){
106  return $res['meta_local'];
107  }
108  else {
109  return null;
110  }
111  }
112  else if ($type == "meta_keywords"){
113  if (!empty($res['meta_keywords'])){
114  return $res['meta_keywords'];
115  }
116  else {
117  return null;
118  }
119  }
120  else {
121  return null;
122  }
123  }
124  }
125  else {
126  // throw alert
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);
129  }
130  // q failed
131  return false;
132  }
133 
134  /**
135  * @brief get and return meta tags of requested page as array
136  * @param object $db database
137  * @param int $id affected page ID
138  * @param string $type meta description
139  * @return array|bool meta tags as array
140  */
141  public static function getMetaTagsArray($db, $id)
142  { /** @param $db db $res */
143  if ($row = $db->query("SELECT meta_local, meta_keywords
144  FROM {pages}
145  WHERE id = '".$id."'"))
146  { // output meta content description
147  $res = $row->fetch_assoc();
148  if (is_array($res)
149  && (!empty($res['meta_local'])
150  && (!empty($res['meta_keywords'])))){
151  return $res;
152  }
153  else {
154  // meta tags not set, get global meta tags
155  $res['meta_local'] = \YAWK\settings::getSetting($db, "globalmetatext");
156  $res['meta_keywords'] = \YAWK\settings::getSetting($db, "globalmetakeywords");
157  if (!empty($res['meta_local']) && (!empty($res['meta_keywords']))){
158  return $res;
159  }
160  else {
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.";
163  return $res;
164  }
165  }
166  }
167  else {
168  // throw alert
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.";
172  return $res;
173  }
174  }
175 
176  /**
177  * @brief toggle page status online or offline (plus corresponding menu entries)
178  * @param object $db database
179  * @param int $id affected page ID
180  * @param int $published 0|1 page publish status
181  * @param string $title page title
182  * @return bool page toggle on/offline status
183  */
185  { /* @param $db db */
186  // check data types
187  if (is_numeric($id) && (is_numeric($published) && is_string($title)))
188  {
189  if ($published === '1')
190  { $published = 0; }
191  else if ($published === '0')
192  { $published = 1; }
193 
194  // escape vars
195  $id = $db->quote($id);
196  $published = $db->quote($published);
197  $title = $db->quote($title);
198 
199  if ($published === "0") { $status = "offline"; } else { $status = "online"; }
200 
201  // TOGGLE PAGES
202  if (!$db->query("UPDATE {pages}
203  SET published = '" . $published . "'
204  WHERE id = '" . $id . "'"))
205  { // could not update pages db table
206  $status = sys::iStatusToString($published, "online", "offline");
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);
209  }
210  else
211  { // ok, set syslog entry
212  sys::setSyslog($db, 5, 0, "toggled page $id to $status", 0, 0, 0, 0);
213  }
214 
215  // TOGGLE MENU STATUS
216  if (!$db->query("UPDATE {menu}
217  SET published = '" . $published . "'
218  WHERE title = '" . $title . "'")) {
219  // could not update pages db table
220  print alert::draw("danger", "Error", "Menu Status could not be toggled.", "", 4200);
221  }
222  else
223  { // ok, set syslog entry
224  sys::setSyslog($db, 21, 0, "toggled menu $id to $status", 0, 0, 0, 0);
225  }
226  }
227  else
228  { // data type is incorrect, throw yoda's hint
229  print alert::draw("danger", "Error", "YaWK said: variable manipulate you shall not do!", "", 4200);
230  }
231  return true;
232  }
233 
234  /**
235  * @brief toggle page lock to avoid unintended changes
236  * @param object $db database
237  * @param int $id affected page id
238  * @param int $locked 0|1 lock status
239  * @return bool page toggle lock status
240  */
241  function toggleLock($db, $id, $locked)
242  {
243  /* @param $db db */
244  $id = $db->quote($id);
245  $locked = $db->quote($locked);
246  if ($db->query("UPDATE {pages} SET locked = '".$locked."' WHERE id = '".$id."'")) {
247  /* free result set */
248  // $res->close();
249  return true;
250  }
251  else
252  { //
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);
256  return false;
257  }
258  }
259 
260  /**
261  * @brief make a copy of a page
262  * @param object $db database
263  * @return bool
264  */
265  function copy($db)
266  {
267  /** @param $db db */
268  // creation date
269  $currentDateTime = date("Y-m-d G:i:s");
270 
271 
272  // init helper vars for copy processing
273  $page = '';
274  $newPage = '';
275 
276  // if page name is not given
277  if (!$this->alias) {
278  return false;
279  }
280  // ## select max id from pages
281  if ($res = $db->query("SELECT MAX(id) FROM {pages}"))
282  {
283  $row = mysqli_fetch_row($res);
284  $this->id = $row[0] + 1;
285  }
286  else
287  {
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).");
290  }
291 
292  $this->id++;
293 
294  // ## add new page to db pages
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 . "')"))
308  {
309  /* TODO: COPY META TAGS when COPY PAGE
310  // generate local meta tags
311  $desc = "description";
312  $keyw = "keywords";
313  $words = "";
314  // add local meta tags
315  if (!$db->query("INSERT INTO {meta_local} (name,page,content)
316  VALUES ('" . $desc . "', '" . $id . "', '" . $title . "')"))
317  {
318  \YAWK\sys::setSyslog($db, 8, 1, "failed to store local meta tags", 0, 0, 0, 0);
319  echo \YAWK\alert::draw("warning","Warning", "Could not store local meta tags", "", "");
320  }
321 
322  // add local meta tags to db meta_local
323  if (!$db->query("INSERT INTO {meta_local} (name,page,content)
324  VALUES ('" . $keyw . "','" . $id . "','" . $words . "')"))
325  {
326  \YAWK\sys::setSyslog($db, 8, 1, "failed to store local meta tags", 0, 0, 0, 0);
327  echo \YAWK\alert::draw("warning","Warning", "Could not store local meta tags", "", "");
328  }
329  */
330 
331  // copy page as new language requested
332  if ($this->newLanguage === true)
333  { // check, if requested language dir exists
334  if (!is_dir($this->path.$this->language))
335  { // if not, try to create it
336  mkdir($this->path.$this->language);
337 
338  // prepare files to get copied into new language sub folder
339  $page = $this->path.$this->alias.".php";
340  $newPage = $this->path.$this->language."/".$this->alias."-copy.php";
341  }
342  }
343  else
344  { // prepare files to get copied into content/pages/ root folder
345  $page = $this->path.$this->alias.".php";
346  $newPage = $this->path.$this->alias."-copy.php";
347  }
348 
349  // copy file
350  if (!copy($page, $newPage) && !chmod($newPage, 0777))
351  {
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 !", "", "");
354  }
355  else {
356  // file copies successfully...
357  return true;
358  }
359  /*
360 
361  // ## selectmenuID from menu db
362  if ($row = $db->query("SELECT menuID FROM {menu} WHERE title LIKE '" . $this->title . "'"))
363  {
364  $res = mysqli_fetch_row($row);
365  if (isset($res[0])){
366  $menuID = $res[0];
367  }
368  else {
369  $menuID = 0;
370  }
371  }
372  else
373  { // select failed, throw error
374  sys::setSyslog($db, 23, 1, "failed to select menu entry for $this->title", 0, 0, 0, 0);
375  echo alert::draw("warning","Warning", "Could not select menu entry for: $this->title", "", "");
376  $menuID = '0';
377  }
378 
379  // ## select max ID from menu
380  if ($row = $db->query("SELECT MAX(id) FROM {menu}"))
381  {
382  $res = mysqli_fetch_row($row);
383  if (!isset($res[0]))
384  { // if not, give it a ID of 1
385  $newMenuID = 1;
386  }
387  else
388  { // if entry exists, add +1 to ID #
389  $newMenuID = $res[0]++;
390  }
391  }
392  else
393  {
394  $newMenuID = 0;
395  // select MAX(id) from menu failed, throw error
396  sys::setSyslog($db, 23, 1, "failed to fetch MAX(id) from menu", 0, 0, 0, 0);
397  echo alert::draw("warning","Warning", "Could not fetch MAX(id) from menu", "", "");
398  }
399 
400 
401  // to increment sort var correctly, check if there is an entry in the menu
402  if ($res = $db->query("SELECT MAX(sort) FROM {menu} WHERE menuID = '" . $menuID . "'"))
403  {
404  $row = mysqli_fetch_row($res);
405  if (!isset($row[0]))
406  { // if not, give it a sort ID of 1
407  $sort = 1;
408  }
409  else
410  { // if entry exists, add +1 to sort #
411  $sort = $row[0]++;
412  }
413 
414  $link = "$this->alias" . ".html";
415  if ($db->query("INSERT INTO {menu} (id,sort,menuID,text,href)
416  VALUES('" . $newMenuID . "','" . $sort . "', '" . $menuID . "', '" . $this->title_new . "', '" . $link . "')"))
417  {
418  sys::setSyslog($db, 21, 0, "menu entry $this->title_new added", 0, 0, 0, 0);
419  return true;
420  }
421  else
422  {
423  // insert failed, throw error
424  sys::setSyslog($db, 23, 1, "failed to insert menu entry for: $this->title_new", 0, 0, 0, 0);
425  echo alert::draw("warning","Warning", "Could not insert menu entry for: $this->title_new", "", "");
426  }
427  }
428  else
429  {
430  // select failed, throw error
431  sys::setSyslog($db, 23, 1, "failed to select menu entry for: $menuID", 0, 0, 0, 0);
432  echo alert::draw("warning","Warning", "Could not select menu entry for: $menuID", "", "");
433  }
434  */
435  }
436  else
437  {
438  sys::setSyslog($db, 7, 1, "could not insert data into pages table", 0, 0, 0, 0);
439  }
440  sys::setSyslog($db, 8, 1, "copy $this->path.$this->alias failed.", 0, 0, 0, 0);
441  return false;
442  }
443 
444  /**
445  * @brief delete a page
446  * @param object $db database
447  * @return bool
448  */
449  function delete($db)
450  {
451  /** @param $db db */
452  // delete item from pages db
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");
456  }
457  else
458  { // page deleted
459  sys::setSyslog($db, 5, 0, "deleted page $this->alias from database", 0, 0, 0, 0);
460  }
461  // delete item from menu db
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");
465  }
466  else
467  { // deleted menu syslog entry
468  sys::setSyslog($db, 21, 0, "deleted menu of ../content/pages/$this->alias.php", 0, 0, 0, 0);
469  }
470 
471  // check, if language is set and build path + filename
472  if (isset($this->language) && (!empty($this->language)))
473  { // file should be in corresponding language folder
474  $filename = $this->path.$this->language."/".$this->alias.".php";
475  }
476  else
477  { // file should be in pages root folder
478  $filename = $this->path.$this->alias.".php";
479  }
480 
481  // check if file exists
482  if (file_exists($filename))
483  { // delete file
484  if (!unlink($filename))
485  { // delete failed
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");
488  return false;
489  }
490  else
491  { // delete successful
492  sys::setSyslog($db, 5, 0, "deleted $filename", 0, 0, 0, 0);
493  return true;
494  }
495  }
496  // file does not exist.
497  sys::setSyslog($db, 7, 1, "file $filename does not exist. page->delete() failed", 0, 0, 0, 0);
498  return false;
499  }
500 
501  /**
502  * @brief create a new page
503  * @param object $db database
504  * @param string $alias page filename
505  * @param int $menuID menu ID
506  * @param int $locked 0|1 page lock status
507  * @param int $blogid blog ID, if any
508  * @param int $plugin plugin ID, if any
509  * @return bool
510  */
511  function create($db, $alias, $menuID, $locked, $blogid, $plugin)
512  {
513  // TODO: refactor this method to oop code
514  $this->alias = $alias;
515  $this->menu = $menuID;
516  $this->locked = $locked;
517  $this->blogid = $blogid;
518  $this->plugin = $plugin;
519 
520  /** @param $db db */
521  // init variables
522  // if page name is not given
523  if (!$alias) {
524  return false;
525  }
526  $alias = html_entity_decode($alias);
527  // creation date
528  $date_created = date("Y-m-d G:i:s");
529 // $date_unpublish = date('Y-m-d', strtotime('+25 year', strtotime($date_created)) );
530 // $date_unpublish = NULL;
531  $title = $alias;
532  /* alias string manipulation */
533  $alias = mb_strtolower($alias); // lowercase
534  $alias = str_replace(" ", "-", $alias); // replace all ' ' with -
535  // special chars
536  $ersetze = array("/ä/", "/ü/", "/ö/", "/Ä/", "/Ãœ/", "/Ö/", "/ß/"); // array of special chars
537  $umlaute = array("ae", "ue", "oe", "Ae", "Ue", "Oe", "ss"); // array of replacement chars
538  $alias = preg_replace($ersetze, $umlaute, $alias); // replace with preg
539 
540  // convert special chars
542  // final check: just numbers and chars are allowed
543  $alias = preg_replace("/[^a-z0-9\-\/]/i", "", $alias);
544  // final filename
545  $link = "$alias" . ".html";
546 
547  // if menu select field is not empty
548  if ($menuID !== "empty") {
549  // ## select max ID from menu + add menu entry
550  if ($res = $db->query("SELECT MAX(id) FROM {menu}"))
551  {
552  $row = mysqli_fetch_row($res);
553  if (!isset($row[0])) { // if not, give it a ID of 1
554  $id = 1;
555  } else {
556  $id = $row[0] + 1; // if entry exists, add +1 to ID #
557  }
558  }
559  else
560  { // throw error
561  $id = 1;
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");
564  }
565  // to increment sort var correctly, check if there is an entry in the menu
566  if ($res = $db->query("SELECT MAX(sort) FROM {menu} WHERE menuID = '" . $menuID . "'"))
567  {
568  $row = mysqli_fetch_row($res);
569  if (!isset($row[0]))
570  { // if not, give it a ID of 1
571  $sort = 1;
572  }
573  else
574  { // if entry exists, add +1 to sort #
575  $sort = $row[0] + 1;
576  }
577  }
578  else
579  { // throw error
580  $sort = 1;
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");
583  }
584 
585  if ($plugin) {
586  if (strlen($plugin) >= 1) {
587  $menu_published = 1;
588  }
589  else {
590  $menu_published = 0;
591  }
592  }
593  else {
594  $menu_published = 0;
595  }
596  $title = htmlentities($title);
597  $tmpID = 0;
598  $titleText = '';
599  // insert menu data
600  if (!$res = $db->query("INSERT INTO {menu} (id,sort,menuID,published,title,text,href,blogid, menuLanguage)
601  VALUES('" . $id . "',
602  '" . $sort . "',
603  '" . $menuID . "',
604  '" . $menu_published . "',
605  '" . $titleText . "',
606  '" . $title . "',
607  '" . $link . "',
608  '" . $blogid . "',
609  '" . $this->language . "')"))
610  { // throw error
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");
613  }
614  else
615  { // success syslog entry
616  sys::setSyslog($db, 21, 0, "added new menu: $title (id: $id)", 0, 0, 0, 0);
617  }
618  } // ./ if menu != empty
619 
620  // if the method is called from the blog, set settings
621  if ($locked === '0' && $blogid === '0') {
622  $locked = 0;
623  $published = 0;
624  $content = "leer";
625  } else {
626  $published = 0;
627  $content = "<?php \$blog_id = $blogid; include 'system/plugins/blog/blog.php'; ?>";
628  }
629 
630  // if the method is called from the plugin, set settings
631  if ($plugin) {
632  if (is_array($plugin)){
633  $plugin = array("tos", $_POST['signup_tospage'], $_POST['signup_terms-long']);
634  if ($plugin[0] === 'tos'){
635  $published = 1;
636  $locked = 1;
637  $alias = "$plugin[1]";
638  $content = "$plugin[2]";
639  $plugin = "signup";
640  }
641  }
642  else if (strlen($plugin) >= 1) {
643  $published = 1;
644  $locked = 1;
645  $content = "<?php include 'system/plugins/$plugin/$plugin.php'; ?>";
646  }
647  }
648  else {
649  $plugin = 0;
650  }
651 
652  // ## select max id from pages
653  if ($res = $db->query("SELECT MAX(id) FROM {pages}"))
654  {
655  $row = mysqli_fetch_row($res);
656  $id = $row[0] + 1;
657  }
658  else
659  {
660  $id = 1;
661  sys::setSyslog($db, 7, 1, "failed to select MAX(id) from pages db", 0, 0, 0, 0);
662  }
663 
664  $alias = htmlentities($alias);
665  // ## add new page to db pages
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 . "',
668  '" . $published . "',
669  '" . $date_created . "',
670  '" . $date_created . "',
671  '" . $date_created . "',
672  NULL,
673  '" . $alias . "',
674  '" . $title . "',
675  '" . $locked . "',
676  '" . $blogid . "',
677  '".$plugin."',
678  '".$this->language."')"))
679  { // error inserting page into database - throw error
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);
682  }
683 
684  // check if language is set
685  if (isset($this->language) && (!empty($this->language)))
686  { // set path for new language page
687  $filename = $this->path.$this->language."/".$alias.".php";
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");
691  return false;
692  }
693  }
694  }
695  else
696  { // set path for root dir
697  $filename = $this->path.$alias.".php";
698  }
699 
700  // create file
701  if (!file_exists($filename)) {
702  $handle = fopen($filename, "wr");
703  fwrite($handle, $content);
704  fclose($handle);
705  chmod($filename, 0777);
706  }
707 
708  // page created successfully
709  sys::setSyslog($db, 5, 0, "created $filename", 0, 0, 0, 0);
710  return true;
711  }
712 
713  /**
714  * @brief save a static page including all settings
715  * @param object $db database
716  * @return bool
717  */
718  public function save($db)
719  {
720  /** @param $db db */
721  $date_changed = date("Y-m-d G:i:s");
722 
723  /* alias string manipulation */
724  $this->alias = mb_strtolower($this->alias); // lowercase
725  $this->alias = str_replace(" ", "-", $this->alias); // replace all ' ' with -
726  // special chars
727  $umlaute = array("/ä/", "/ü/", "/ö/", "/Ä/", "/Ãœ/", "/Ö/", "/ß/"); // array of special chars
728  $ersetze = array("ae", "ue", "oe", "ae", "ue", "oe", "ss"); // array of replacement chars
729  $this->alias = preg_replace($umlaute, $ersetze, $this->alias); // replace with preg
730  $this->alias = preg_replace("/[^a-z0-9\-\/]/i", "", $this->alias); // final check: just numbers and chars are allowed
731 
732 
733  // old alias string
734  $oldAlias = substr($this->searchstring, 0, -5); // remove last 5 chars (.html) to get the plain filename
735 
736  // update menu entry
737  /*
738  if (!$db->query("UPDATE {menu}
739  SET text = '" . $this->title ."',
740  href = '" . $this->alias . ".html',
741  gid = '" . $this->gid . "',
742  published = '" . $this->published . "'
743  WHERE href = '" . $this->searchstring . "'"))
744  {
745  // throw error
746  \YAWK\sys::setSyslog($db, 23, 1, "failed to update menu entry $this->title.", 0, 0, 0, 0);
747  \YAWK\alert::draw("warning", "Warning", "menu entry could not be stored in database.", "", 6200);
748  }
749  */
750 
751  // update page db
752  // check unpublish date
753  if ($this->date_unpublish == "0000-00-00 00:00:00" || (empty($this->date_unpublish) || $this->date_unpublish == NULL))
754  {
755  // sql code with NULL unpublish date
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 . "'"))
769  {
770  // throw error
771  sys::setSyslog($db, 23, 1, "failed to update database of page $this->title", 0, 0, 0, 0);
772  // \YAWK\alert::draw("warning", "Warning", "page data could not be stored in database.", "", 6200);
773  // \YAWK\alert::draw("danger", 'MySQL Error: ('.mysqli_errno().')', 'Database error: '.mysqli_error($db).'', "", 0);
774  return false;
775  }
776  else
777  {
778  // update pages db worked, all fin
779  sys::setSyslog($db, 5, 0, "updated $this->alias", 0, 0, 0, 0);
780  return true;
781  }
782  }
783  else
784  {
785  // sql code with correct, user-selected unpublish date
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 . "'"))
799  {
800  // throw error
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);
803  return false;
804  }
805  else
806  {
807  // update pages db worked, all fin
808  sys::setSyslog($db, 5, 0, "updated $this->alias", 0, 0, 0, 0);
809  return true;
810  }
811  }
812  } // ./ save function
813 
814 
815  /**
816  * @brief delete a static content page
817  * @param string $dirprefix directory prefix
818  */
820  {
821  global $dirprefix;
822  if (isset($this->language) && (!empty($this->language)))
823  {
824  $filename = $dirprefix.$this->path.$this->language."/".$this->alias.".php";
825  }
826  else
827  {
828  $filename = $dirprefix.$this->path.$this->alias."php";
829  }
830 
831  if (file_exists($filename))
832  {
833  if (unlink($filename))
834  {
835  return true;
836  }
837  else
838  {
839  return false;
840  }
841  }
842  else
843  {
844  return true;
845  }
846  }
847 
848  /**
849  * @brief write content to static page
850  * @param string $content the content to write
851  * @return bool true|false
852  */
854  {
855  /** @param $db db $alias */
856  /* alias string manipulation */
857  $this->alias = mb_strtolower($this->alias); // lowercase
858  $this->alias = str_replace(" ", "-", $this->alias); // replace all ' ' with -
859  // special chars
860  $specialChars = array("/ä/", "/ü/", "/ö/", "/Ä/", "/Ãœ/", "/Ö/", "/ß/"); // array of special chars
861  $replacementChars = array("ae", "ue", "oe", "ae", "ue", "oe", "ss"); // array of replacement chars
862  $this->alias = preg_replace($specialChars, $replacementChars, $this->alias); // replace with preg
863  $this->alias = preg_replace("/[^a-z0-9\-\/]/i", "", $this->alias); // final check: just numbers and chars are allowed
864  if (!empty($this->language))
865  {
866  $this->language = mb_substr($this->language, 0, 2);
867  // check if requested language directory exists
868  if (!is_dir($this->path.$this->language))
869  { // if not, create it
870  mkdir ($this->path.$this->language);
871  }
872  // store file to corresponding language folder
873  $filename = $this->path.$this->language."/".$this->alias.".php";
874  }
875  else
876  { // store file to content/pages root folder
877  $filename = $this->path.$this->alias.".php";
878  }
879 
880  // open file
881  $handle = fopen($filename, "w+");
882  if (fwrite($handle, $content))
883  { // write content + close
884  fclose($handle);
885  // set file perms
886  chmod($filename, 0777);
887  return true;
888  }
889  else
890  { // writeContent failed
891  sys::setSyslog($db, 7, 2, "unable to write content to file $filename", 0, 0, 0, 0);
892  return false;
893  }
894  }
895 
896  /**
897  * @brief read content from static page
898  * @param string $dirPrefix directory prefix
899  * @return string html content
900  */
901  function readContent($dirPrefix): string
902  {
903  // check, if language is set
904  if (isset($this->language) && (!empty($this->language)))
905  { // if so, build path including language folder
906  $filename = $this->path.$this->language."/".$this->alias.".php";
907  }
908  else
909  { // no language set, build path for content/pages root folder
910  $filename = $this->path.$this->alias.".php";
911  }
912  if(file_exists($filename)){
913  // open page file
914  $handle = @fopen($filename, "rw");
915  // read content into var
916  $content = @fread($handle, filesize($filename));
917  // close resource
918  fclose($handle);
919  // and return page content
920  return $content;
921  }
922  else
923  {
924  return 'ERROR: Unable to read content of file: '.$filename.'
925 Maybe the file has been physically deleted, moved or renamed.';
926  }
927  }
928 
930  /** @param $db db $res */
931  if (isset($id) && (!empty($id)))
932  { // query db for given page ID
933  $res = $db->query("SELECT lang FROM {pages} WHERE id ='".$id."'");
934  $currentLanguage = mysqli_fetch_row($res);
935  }
936  // check, if page got a language set
937  if (isset($currentLanguage[0]) && (!empty($currentLanguage[0])))
938  { // return page language
939  return $currentLanguage[0];
940  }
941  else
942  { // no language set, return empty string
943  return "";
944  }
945  }
946 
947  /**
948  * @brief load page properties and store as object properties
949  * @param object $db database
950  * @param string $alias page filename
951  */
953  {
954  /** @param $db db $res */
955  if (isset($alias) && (!empty($alias)))
956  {
957  $res = $db->query("SELECT * FROM {pages} WHERE alias = '".$alias."'");
958  if ($row = mysqli_fetch_assoc($res))
959  {
960  $this->id = $row['id'];
961  $this->date_created = $row['date_created'];
962  $this->date_publish = $row['date_publish'];
963  $this->date_unpublish = $row['date_unpublish'];
964  $this->published = $row['published'];
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'];
973  $this->language = $row['lang'];
974  $this->meta_local = $row['meta_local'];
975  $this->meta_keywords = $row['meta_keywords'];
976  $this->alias = $alias;
977  }
978  else
979  { // 404 error handling
980  if ($this->alias == "content/errors/404")
981  { // check if user is logged in (session uid is set in that case)
982  if (isset($_SESSION['uid']) && (!empty($_SESSION['uid'])))
983  { // logged in user created a 404 error
984  sys::setSyslog($db, 7, 2, "404: file not found - displayed $alias instead", $_SESSION['uid'], 0, 0, 0);
985  }
986  else
987  { // user is not logged in - unknown user created a 404 error
988  sys::setSyslog($db, 7, 2, "404: file not found - displayed $alias instead", 0, 0, 0, 0);
989  }
990  }
991  }
992  }
993  else
994  { // page not set - unable to load page properties
995  sys::setSyslog($db, 7, 2, "failed to load properties because page alias was not set", 0, 0, 0, 0);
996  }
997  }
998 
999  /**
1000  * @brief load page properties and store as object properties
1001  * @param object $db database
1002  * @param string $id page id
1003  */
1005  {
1006  /** @param $db db $res */
1007  if (isset($id) && (!empty($id)))
1008  {
1009  $res = $db->query("SELECT * FROM {pages} WHERE id = '".$id."'");
1010  if ($row = mysqli_fetch_assoc($res))
1011  {
1012  $this->id = $row['id'];
1013  $this->date_created = $row['date_created'];
1014  $this->date_publish = $row['date_publish'];
1015  $this->date_unpublish = $row['date_unpublish'];
1016  $this->published = $row['published'];
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'];
1026  $this->language = $row['lang'];
1027  $this->meta_local = $row['meta_local'];
1028  $this->meta_keywords = $row['meta_keywords'];
1029  }
1030  else
1031  { // 404 error handling
1032  if ($this->alias == "content/errors/404")
1033  { // check if user is logged in (session uid is set in that case)
1034  if (isset($_SESSION['uid']) && (!empty($_SESSION['uid'])))
1035  { // logged in user created a 404 error
1036  sys::setSyslog($db, 7, 2, "404: file not found - displayed $this->alias instead", $_SESSION['uid'], 0, 0, 0);
1037  }
1038  else
1039  { // user is not logged in - unknown user created a 404 error
1040  sys::setSyslog($db, 7, 2, "404: file not found - displayed $this->alias instead", 0, 0, 0, 0);
1041  }
1042  }
1043  }
1044  }
1045  else
1046  { // page ID not set - unable to load page properties
1047  sys::setSyslog($db, 7, 2, "failed to load properties because page ID was not set", 0, 0, 0, 0);
1048  }
1049  }
1050 
1051 
1052  /**
1053  * @brief get latest pages
1054  * @param object $db database
1055  * @param int $limit limit to n entries
1056  * @return array|string
1057  */
1058  static function getLatest($db, $limit)
1059  { /** @param $db db */
1060  // check and set default value
1061  if (!isset($limit) && (empty($limit))) { $limit = 4; }
1062  // select latest n page titles
1063  if ($res = $db->query("SELECT id, alias, title, published, date_publish
1064  FROM {pages}
1065  WHERE blogid = 0
1066  AND plugin = 0
1067  ORDER BY date_created
1068  DESC LIMIT $limit"))
1069  {
1070  $latestPages = array();
1071  while ($row = mysqli_fetch_assoc($res))
1072  {
1073  $latestPages[] = $row;
1074  }
1075  return $latestPages;
1076  }
1077  else
1078  {
1079  return "no pages found.";
1080  }
1081  }
1082 
1083  /**
1084  * @brief get any requested page property
1085  * @param object $db database
1086  * @param int $id affected page ID
1087  * @param string $property database field to get
1088  * @return string|bool the selected property or false
1089  */
1090  function getProperty($db, $id, $property)
1091  { /** @param $db db $res */
1092  // select property from pages db
1093  if ($res = $db->query("SELECT $property FROM {pages}
1094  WHERE id = '" . $id . "'"))
1095  { // fetch data
1096  if ($row = mysqli_fetch_row($res)){
1097  return $row[0];
1098  }
1099  }
1100  else
1101  { // throw error
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");
1104  return false;
1105  }
1106  // q failed
1107  return null;
1108  }
1109 
1110  /**
1111  * @brief get and include static page content
1112  * @param object $db database
1113  * @param object $lang language obj
1114  * @return mixed
1115  */
1116  function getContent($db, $lang)
1117  {
1118  global $currentpage;
1119  if (!isset($currentpage) || (empty($currentpage)))
1120  {
1121  die("CRITICAL ERROR: unable to display content - currentpage var is not set.");
1122  }
1123  if (isset($currentpage->date_publish))
1124  {
1125  // ROLE CHECK
1126  if (isset($_SESSION['gid'])) {
1127  // if SESSION ROLE is bigger or equal than current PAGE ROLE
1128  if ($_SESSION['gid'] <= $currentpage->gid)
1129  { // user is not allowed to view this content
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);
1131  return false;
1132  }
1133  }
1134  else if ($currentpage->gid > 1)
1135  { // public user not allowed here, so....
1136  sys::setSyslog($db, 11, 1, "public user tried to get content of $currentpage->alias (required GID: $currentpage->gid)", 0, 0, 0, 0);
1137  return false;
1138  }
1139  }
1140  // GET STATUS
1141  $future = (isset($currentpage->date_publish));
1142  // publish date + time
1143  if (isset($currentpage->date_publish_end))
1144  { // end publish date + time
1145  $publish_end = $currentpage->date_publish_end;
1146  }
1147 
1148  // current date + time
1149  $now = date("Y-m-d G:i:s");
1150  // trim vars
1151  $date_published = trim($future);
1152  $publish_end = trim(isset($publish_end));
1153  $date_now = trim($now);
1154 
1155  // de-construct string
1156  $date_now = substr($now, 0, 10); // get the first 10 chars, start from left
1157  $time_now = substr($now, -8); // get the last 8 chars, start from right
1158 
1159  $date_published = substr($future, 0, 10);
1160  $time_published = substr($future, -8);
1161 
1162  $date_publish_end = substr($publish_end, 0, 10);
1163  $time_publish_end = substr($publish_end, -8);
1164 
1165  // remove special chars
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);
1171 
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
1177  )
1178  {
1179  // show error
1180  return include(controller::filterfilename($db, $lang, "content/errors/404.html"));
1181  }
1182  else
1183  {
1184  if ($currentpage->date_publish > $now) {
1185  $timediff = settings::getSetting($db, "timediff");
1186  if ($timediff === '1') {
1187  echo "<br>Content Pending. Publishing is scheduled for $currentpage->date_publish<br><br>";
1188  } else {
1189  echo "&nbsp;";
1190  }
1191 
1192  $start = strtotime($now);
1193  $end = strtotime($currentpage->date_publish);
1194  $timediff = settings::getSetting($db, "timediff");
1195  if ($timediff === '1') {
1196  echo "time diff here";
1197  // TODO: search for sys::showTimeDiff($start, $end);
1198  }
1199  exit;
1200  }
1201  if ($currentpage->date_unpublish < $now XOR $currentpage->date_unpublish === NULL) {
1202  echo "<br>Sadly, this content is not available anymore. <br><br>";
1203  $timediff = settings::getSetting($db, "timediff");
1204  if ($timediff === '1') {
1205  echo "Publishing has ended on $currentpage->date_unpublish.<br><br>";
1206  // YAWK\sys::showTimeDiff($start, $end);
1207  }
1208  exit;
1209  }
1210 
1211  // create language obj
1212  $language = new language();
1213 
1214  // $language->httpAcceptedLanguage = substr($language->getClientLanguage(), 0, 2);
1215  $language->httpAcceptedLanguage = $language->getClientLanguage();
1216 
1217  // set path to content folder (where pages are stored)
1218  $path = "content/pages/";
1219 
1220  // the file extension of files used in path to store pages (typically .php)
1221  $fileExt = ".php";
1222 
1223  // check users browser language, store first 2 chars as $tag
1224  $language->httpAcceptedLanguage = mb_substr($language->httpAcceptedLanguage, 0,2);
1225 
1226 
1227  // init language folder var
1228  $languageFolder = '';
1229  $trailingSlash = '';
1230 
1231  // build array containing all content sub folders
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();
1238 
1239  // check if user's language is available in content folder
1240  if ($language->httpAcceptedLanguage == $fileInfo->getFilename())
1241  { // this is the language we have detected from the user - you want it, we got it
1242  $languageFolder = $fileInfo->getFilename();
1243  $trailingSlash = "/";
1244  // echo "<script>document.cookie = \"userSelectedLanguage=$languageFolder; expires=Thu, 04 Nov 2021 12:00:00 UTC\"; </script>";
1245  }
1246  else
1247  { // leave empty, take from root dir
1248  $languageFolder = '';
1249  }
1250  }
1251 
1252  if (isset($_GET['language']) && (!empty($_GET['language'])))
1253  {
1254  $languageFolder = mb_substr($_GET['language'], 0,2);
1255  $trailingSlash = "/";
1256  // outdated: this has moved to template index page
1257  // echo "<script>document.cookie = \"userSelectedLanguage=$languageFolder; expires=Thu, 04 Nov 2021 12:00:00 UTC\"; </script>";
1258  // $_COOKIE['userSelectedLanguage'] = $languageFolder;
1259  }
1260  // print_r($_COOKIE);
1261 
1262  if (isset($_COOKIE['userSelectedLanguage']) && (!empty($_COOKIE['userSelectedLanguage']))){
1263  $languageFolder = $_COOKIE['userSelectedLanguage'];
1264  $trailingSlash = "/";
1265  }
1266  /*
1267  echo "<pre>";
1268  print_r($contentLanguageFolders);
1269  echo "lang folder: ".$languageFolder;
1270  echo "</pre>";
1271 
1272  echo "<br>";
1273  echo $path.$languageFolder.$trailingSlash.$this->alias.$fileExt."<br>";
1274  */
1275 
1276  if (in_array("$languageFolder", $contentLanguageFolders)) {
1277  // check if folder for this language is available
1278  if (is_dir($path.$languageFolder))
1279  {
1280  // echo "yes, $languageFolder is supported!";
1281  if (is_file($path.$languageFolder.$trailingSlash.$this->alias.$fileExt))
1282  {
1283  // include content page from language folder
1284  /** @noinspection PhpIncludeInspection */
1285  return include(controller::filterfilename($db, $lang, $path.$languageFolder.$trailingSlash.$this->alias));
1286  }
1287  else
1288  { // file not found in this language folder - check if file is found in root directory
1289  if (is_file($path.$this->alias))
1290  { // include content page from root folder
1291  /** @noinspection PhpIncludeInspection */
1292  return include(controller::filterfilename($db, $lang, $path.$this->alias));
1293  }
1294  }
1295  }
1296  else
1297  {
1298  // echo "no, $languageFolder is not supported yet.";
1299  // language folder not found - check if file is found in root directory
1300  if (is_file($path.$this->alias))
1301  { // include content page from root folder
1302  /** @noinspection PhpIncludeInspection */
1303  return include(controller::filterfilename($db, $lang, $path.$this->alias));
1304  }
1305  }
1306  }
1307  else
1308  { // echo "desired language $languageFolder not in array, loading file from root folder";
1309  /** @noinspection PhpIncludeInspection */
1310  return include(controller::filterfilename($db, $lang, $path.$this->alias));
1311  }
1312  }
1313  return true;
1314  }
1315  } // ./ class page
1316 } // ./ namespace
$now
$filename
Definition: actions.php:10
print $lang['FILEMAN_UPLOAD']
die
Definition: block-user.php:27
print $blog blogid
Definition: blog-edit.php:376
$blog gid
Definition: blog-setup.php:139
if(!isset($blog)) if(!isset($language)||(!isset($lang))) if(!isset($db)) $blog published
Definition: blog-toggle.php:17
static draw($type, $title, $text, $redirect, $delay)
Definition: alert.php:30
static filterfilename($db, $lang, $filename)
Main filter controller: checks GET params and lead to corresponding actions.
Definition: controller.php:46
The language class - support multilingual backend.
Definition: language.php:17
The default menu class. Serves all the menu functions.
Definition: menu.php:17
The default pages class. Provide all functions to handle static pages.
Definition: page.php:20
getProperty($db, $id, $property)
get any requested page property
Definition: page.php:1090
$date_unpublish
Definition: page.php:44
static getLatest($db, $limit)
get latest pages
Definition: page.php:1058
$blogid
Definition: page.php:48
$title_new
Definition: page.php:30
create($db, $alias, $menuID, $locked, $blogid, $plugin)
create a new page
Definition: page.php:511
$date_publish
Definition: page.php:42
$newLanguage
Definition: page.php:62
toggleLock($db, $id, $locked)
toggle page lock to avoid unintended changes
Definition: page.php:241
$bgimage
Definition: page.php:58
$meta_keywords
Definition: page.php:68
copy($db)
make a copy of a page
Definition: page.php:265
$date_created
Definition: page.php:40
readContent($dirPrefix)
read content from static page
Definition: page.php:901
$locked
Definition: page.php:50
$title
Definition: page.php:28
static countPages($db)
count and return the pages in database
Definition: page.php:75
loadProperties($db, $alias)
load page properties and store as object properties
Definition: page.php:952
writeContent($content)
write content to static page
Definition: page.php:853
$language
Definition: page.php:60
getContent($db, $lang)
get and include static page content
Definition: page.php:1116
$metadescription
Definition: page.php:52
$alias_new
Definition: page.php:26
$meta_local
Definition: page.php:66
loadPropertiesByID($db, $id)
load page properties and store as object properties
Definition: page.php:1004
$alias
Definition: page.php:24
$plugin
Definition: page.php:46
$ownerid
Definition: page.php:34
deleteContent($dirprefix)
delete a static content page
Definition: page.php:819
$published
Definition: page.php:32
getCurrentLanguageByID($db, $id)
Definition: page.php:929
save($db)
save a static page including all settings
Definition: page.php:718
$searchstring
Definition: page.php:56
$metakeywords
Definition: page.php:54
static getMetaTags($db, $id, $type)
get and return meta tags for requested page
Definition: page.php:95
toggleOffline($db, $id, $published, $title)
toggle page status online or offline (plus corresponding menu entries)
Definition: page.php:184
static getMetaTagsArray($db, $id)
get and return meta tags of requested page as array
Definition: page.php:141
Handles the Plugin System.
Definition: plugin.php:33
static getSetting($db, $property)
Get and return value for property from settings database.
Definition: settings.php:470
static iStatusToString($i, $on, $off)
convert a integer status to string variable (0|1) to online / offline
Definition: sys.php:729
static encodeChars($string)
convert german special chars and vowels into legal html
Definition: sys.php:1089
$result
Definition: email-send.php:137
exit
$type
This class serves methods to create backup from files.
Definition: AdminLTE.php:2
print $page date_publish
Definition: page-edit.php:442
$specialChars
Definition: page-edit.php:71
print $page meta_local
Definition: page-edit.php:489
print $page meta_keywords
Definition: page-edit.php:512
print $page bgimage
Definition: page-edit.php:522
$page alias
Definition: page-edit.php:68
print $page title
Definition: page-edit.php:377
print $_GET['id']
Definition: page-edit.php:357
if(!isset($page)) if(!isset($db)) if(!isset($lang)) if(isset($_GET['id'])) if(isset($_POST['save'])) $dirprefix
Definition: page-edit.php:63
print $page date_unpublish
Definition: page-edit.php:448
$page
Definition: pages.php:355
print $tourdates date
$i