@@ -1687,8 +1687,8 @@ |
||
1687 | 1687 | 'q', 'rt', 'ins', 'font', 'strong', |
1688 | 1688 | 's', 'tt', 'kbd', 'mark', |
1689 | 1689 | 'u', 'xm', 'sub', 'nobr', |
1690 | - 'sup', 'ruby', |
|
1691 | - 'var', 'span', |
|
1692 | - 'wbr', 'time', |
|
1690 | + 'sup', 'ruby', |
|
1691 | + 'var', 'span', |
|
1692 | + 'wbr', 'time', |
|
1693 | 1693 | ); |
1694 | 1694 | } |
@@ -27,56 +27,56 @@ |
||
27 | 27 | |
28 | 28 | class Plugin_AdvancedPageTypes_MarkdownPage extends PageType { |
29 | 29 | |
30 | - //https://commonmark.thephpleague.com/ |
|
30 | + //https://commonmark.thephpleague.com/ |
|
31 | 31 | |
32 | - //https://caret.io/ |
|
32 | + //https://caret.io/ |
|
33 | 33 | |
34 | - //http://parsedown.org/ |
|
34 | + //http://parsedown.org/ |
|
35 | 35 | |
36 | - //https://github.com/erusev/parsedown-extra |
|
36 | + //https://github.com/erusev/parsedown-extra |
|
37 | 37 | |
38 | - //https://stackoverflow.com/questions/32068537/generate-table-of-contents-from-markdown-in-php |
|
38 | + //https://stackoverflow.com/questions/32068537/generate-table-of-contents-from-markdown-in-php |
|
39 | 39 | |
40 | - //https://github.com/erusev/parsedown/wiki/Tutorial:-Get-Started |
|
40 | + //https://github.com/erusev/parsedown/wiki/Tutorial:-Get-Started |
|
41 | 41 | |
42 | - public function getContent(): string { |
|
43 | - $content = ""; |
|
42 | + public function getContent(): string { |
|
43 | + $content = ""; |
|
44 | 44 | |
45 | - //check, if generated html is already cached |
|
46 | - if (Cache::contains("plugin_advancedpagetypes", "markdown_" . $this->getPage()->getAlias())) { |
|
47 | - $content = Cache::get("plugin_advancedpagetypes", "markdown_" . $this->getPage()->getAlias()); |
|
48 | - } else { |
|
49 | - //require parsedown |
|
50 | - require_once(PLUGIN_PATH . "advancedpagetypes/parsedown-1.7.1/Parsedown.php"); |
|
45 | + //check, if generated html is already cached |
|
46 | + if (Cache::contains("plugin_advancedpagetypes", "markdown_" . $this->getPage()->getAlias())) { |
|
47 | + $content = Cache::get("plugin_advancedpagetypes", "markdown_" . $this->getPage()->getAlias()); |
|
48 | + } else { |
|
49 | + //require parsedown |
|
50 | + require_once(PLUGIN_PATH . "advancedpagetypes/parsedown-1.7.1/Parsedown.php"); |
|
51 | 51 | |
52 | - $parsedown = Parsedown::instance(); |
|
52 | + $parsedown = Parsedown::instance(); |
|
53 | 53 | |
54 | - //enables automatic line breaks |
|
55 | - $parsedown->setBreaksEnabled(true); |
|
54 | + //enables automatic line breaks |
|
55 | + $parsedown->setBreaksEnabled(true); |
|
56 | 56 | |
57 | - //escape html |
|
58 | - $parsedown->setMarkupEscaped(true); |
|
57 | + //escape html |
|
58 | + $parsedown->setMarkupEscaped(true); |
|
59 | 59 | |
60 | - //automatically link urls |
|
61 | - $parsedown->setUrlsLinked(true); |
|
60 | + //automatically link urls |
|
61 | + $parsedown->setUrlsLinked(true); |
|
62 | 62 | |
63 | - //enable safe mode |
|
64 | - $parsedown->setSafeMode(true); |
|
63 | + //enable safe mode |
|
64 | + $parsedown->setSafeMode(true); |
|
65 | 65 | |
66 | - $content = $parsedown->text($this->getPage()->getContent()); |
|
66 | + $content = $parsedown->text($this->getPage()->getContent()); |
|
67 | 67 | |
68 | - //cache content |
|
69 | - Cache::put("plugin_advancedpagetypes", "markdown_" . $this->getPage()->getAlias(), $content); |
|
70 | - } |
|
68 | + //cache content |
|
69 | + Cache::put("plugin_advancedpagetypes", "markdown_" . $this->getPage()->getAlias(), $content); |
|
70 | + } |
|
71 | 71 | |
72 | - Events::throwEvent("plugin_markdownpage_parse", array( |
|
73 | - 'content' => &$content, |
|
74 | - 'page' => &$this->getPage(), |
|
75 | - 'page_type' => &$this |
|
76 | - )); |
|
72 | + Events::throwEvent("plugin_markdownpage_parse", array( |
|
73 | + 'content' => &$content, |
|
74 | + 'page' => &$this->getPage(), |
|
75 | + 'page_type' => &$this |
|
76 | + )); |
|
77 | 77 | |
78 | - return $content; |
|
79 | - } |
|
78 | + return $content; |
|
79 | + } |
|
80 | 80 | |
81 | 81 | } |
82 | 82 |
@@ -27,18 +27,18 @@ |
||
27 | 27 | |
28 | 28 | class Plugin_AdvancedPageTypes_StaticHTMLPage extends PageType { |
29 | 29 | |
30 | - public function getContent(): string { |
|
31 | - $file_path = $this->getPage()->getContent(); |
|
32 | - |
|
33 | - //../ is not allowed |
|
34 | - $file_path = str_replace("..", "", $file_path); |
|
35 | - |
|
36 | - if (file_exists(STORE_PATH . $file_path)) { |
|
37 | - return file_get_contents(STORE_PATH . $file_path); |
|
38 | - } else { |
|
39 | - return "Error! template '" . $file_path . "' doesnt exists!"; |
|
40 | - } |
|
41 | - } |
|
30 | + public function getContent(): string { |
|
31 | + $file_path = $this->getPage()->getContent(); |
|
32 | + |
|
33 | + //../ is not allowed |
|
34 | + $file_path = str_replace("..", "", $file_path); |
|
35 | + |
|
36 | + if (file_exists(STORE_PATH . $file_path)) { |
|
37 | + return file_get_contents(STORE_PATH . $file_path); |
|
38 | + } else { |
|
39 | + return "Error! template '" . $file_path . "' doesnt exists!"; |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | 43 | } |
44 | 44 |
@@ -27,21 +27,21 @@ discard block |
||
27 | 27 | |
28 | 28 | class Plugin_AdvancedPageTypes_AsciiDocPage extends PageType { |
29 | 29 | |
30 | - public function getAdditionalHeaderCode(): string { |
|
31 | - $base_url = DomainUtils::getBaseURL() . "/"; |
|
30 | + public function getAdditionalHeaderCode(): string { |
|
31 | + $base_url = DomainUtils::getBaseURL() . "/"; |
|
32 | 32 | |
33 | - return "<!-- header javascript --> |
|
33 | + return "<!-- header javascript --> |
|
34 | 34 | <script language=\"javascript\" type=\"text/javascript\" src=\"" . $base_url . "plugins/advancedpagetypes/asciidoc/asciidoc/browser/asciidoctor.js\"></script>"; |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | - public function getContent(): string { |
|
38 | - $content = $this->getPage()->getContent(); |
|
37 | + public function getContent(): string { |
|
38 | + $content = $this->getPage()->getContent(); |
|
39 | 39 | |
40 | - return "<div id=\"asciidocconverter\"></div>"; |
|
41 | - } |
|
40 | + return "<div id=\"asciidocconverter\"></div>"; |
|
41 | + } |
|
42 | 42 | |
43 | - public function getFooterScripts(): string { |
|
44 | - return "<script> |
|
43 | + public function getFooterScripts(): string { |
|
44 | + return "<script> |
|
45 | 45 | $(document).ready(function () { |
46 | 46 | var asciidoctor = Asciidoctor(); |
47 | 47 | var content = $" . "(\"#asciidocconverter\").html(); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $" . "(\"#asciidocconverter\").html(content); |
51 | 51 | }); |
52 | 52 | </script>"; |
53 | - } |
|
53 | + } |
|
54 | 54 | |
55 | 55 | } |
56 | 56 |
@@ -27,55 +27,55 @@ |
||
27 | 27 | |
28 | 28 | class StoreInstaller extends PluginInstaller_Plugin { |
29 | 29 | |
30 | - public function install(Plugin $plugin, array $install_json): bool { |
|
31 | - if (isset($install_json['store'])) { |
|
32 | - $store_dirs = $install_json['store']; |
|
33 | - |
|
34 | - foreach ($store_dirs as $dir) { |
|
35 | - if (is_array($dir)) { |
|
36 | - $dir_path = STORE_PATH . $dir['dir']; |
|
37 | - $permissions = "0" . $dir['chmod']; |
|
38 | - |
|
39 | - //create directory, if not exists |
|
40 | - if (!file_exists($dir_path)) { |
|
41 | - //create directory |
|
42 | - mkdir($dir_path); |
|
43 | - } |
|
44 | - |
|
45 | - chmod($dir_path, $permissions); |
|
46 | - } else { |
|
47 | - $dir = str_replace("..", "", $dir); |
|
48 | - |
|
49 | - //get directory path |
|
50 | - $dir_path = STORE_PATH . $dir; |
|
51 | - |
|
52 | - //create directory, if not exists |
|
53 | - if (!file_exists($dir_path)) { |
|
54 | - //create directory |
|
55 | - mkdir($dir_path); |
|
56 | - |
|
57 | - if(!chmod($dir_path, 0777)) { |
|
58 | - chmod($dir_path, 0755); |
|
59 | - |
|
60 | - throw new IllegalStateException("Cannot change file permissions of directory '". $dir_path . "'"); |
|
61 | - } |
|
62 | - } |
|
63 | - } |
|
64 | - } |
|
65 | - } |
|
66 | - |
|
67 | - return true; |
|
68 | - } |
|
69 | - |
|
70 | - public function uninstall(Plugin $plugin, array $install_json): bool { |
|
71 | - //dont do anything, because directories should not be deleted |
|
72 | - |
|
73 | - return true; |
|
74 | - } |
|
75 | - |
|
76 | - public function upgrade(Plugin $plugin, array $install_json): bool { |
|
77 | - return $this->install($plugin, $install_json); |
|
78 | - } |
|
30 | + public function install(Plugin $plugin, array $install_json): bool { |
|
31 | + if (isset($install_json['store'])) { |
|
32 | + $store_dirs = $install_json['store']; |
|
33 | + |
|
34 | + foreach ($store_dirs as $dir) { |
|
35 | + if (is_array($dir)) { |
|
36 | + $dir_path = STORE_PATH . $dir['dir']; |
|
37 | + $permissions = "0" . $dir['chmod']; |
|
38 | + |
|
39 | + //create directory, if not exists |
|
40 | + if (!file_exists($dir_path)) { |
|
41 | + //create directory |
|
42 | + mkdir($dir_path); |
|
43 | + } |
|
44 | + |
|
45 | + chmod($dir_path, $permissions); |
|
46 | + } else { |
|
47 | + $dir = str_replace("..", "", $dir); |
|
48 | + |
|
49 | + //get directory path |
|
50 | + $dir_path = STORE_PATH . $dir; |
|
51 | + |
|
52 | + //create directory, if not exists |
|
53 | + if (!file_exists($dir_path)) { |
|
54 | + //create directory |
|
55 | + mkdir($dir_path); |
|
56 | + |
|
57 | + if(!chmod($dir_path, 0777)) { |
|
58 | + chmod($dir_path, 0755); |
|
59 | + |
|
60 | + throw new IllegalStateException("Cannot change file permissions of directory '". $dir_path . "'"); |
|
61 | + } |
|
62 | + } |
|
63 | + } |
|
64 | + } |
|
65 | + } |
|
66 | + |
|
67 | + return true; |
|
68 | + } |
|
69 | + |
|
70 | + public function uninstall(Plugin $plugin, array $install_json): bool { |
|
71 | + //dont do anything, because directories should not be deleted |
|
72 | + |
|
73 | + return true; |
|
74 | + } |
|
75 | + |
|
76 | + public function upgrade(Plugin $plugin, array $install_json): bool { |
|
77 | + return $this->install($plugin, $install_json); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | } |
81 | 81 |
@@ -34,20 +34,20 @@ discard block |
||
34 | 34 | @ini_set("expose_php", "off"); |
35 | 35 | |
36 | 36 | //dont allow include($url) to avoid code injection |
37 | - @ini_set("allow_url_include", "0"); |
|
37 | + @ini_set("allow_url_include", "0"); |
|
38 | 38 | |
39 | - header("X-Content-Type-Options: nosniff"); |
|
39 | + header("X-Content-Type-Options: nosniff"); |
|
40 | 40 | |
41 | - //enable internet explorer XSS protection, https://www.perpetual-beta.org/weblog/security-headers.html |
|
42 | - header("X-XSS-Protection: 1; mode=block"); |
|
41 | + //enable internet explorer XSS protection, https://www.perpetual-beta.org/weblog/security-headers.html |
|
42 | + header("X-XSS-Protection: 1; mode=block"); |
|
43 | 43 | |
44 | - //https://developer.mozilla.org/de/docs/Web/HTTP/Headers/X-Frame-Options |
|
45 | - $x_frame_options = Settings::get("x_frame_options", "SAMEORIGIN"); |
|
44 | + //https://developer.mozilla.org/de/docs/Web/HTTP/Headers/X-Frame-Options |
|
45 | + $x_frame_options = Settings::get("x_frame_options", "SAMEORIGIN"); |
|
46 | 46 | |
47 | - if (strcmp($x_frame_options, "none") !== 0) { |
|
48 | - //set X-Frame-Options header to avoid clickjacking attacks |
|
49 | - header("X-Frame-Options: " . $x_frame_options); |
|
50 | - } |
|
47 | + if (strcmp($x_frame_options, "none") !== 0) { |
|
48 | + //set X-Frame-Options header to avoid clickjacking attacks |
|
49 | + header("X-Frame-Options: " . $x_frame_options); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * dont allow some XSS attacks or SQL Injections from host or server name |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | protected static function initCSRFToken () { |
72 | - if (session_status() !== PHP_SESSION_ACTIVE) { |
|
73 | - throw new IllegalStateException("session wasnt started yet."); |
|
74 | - exit; |
|
75 | - } |
|
72 | + if (session_status() !== PHP_SESSION_ACTIVE) { |
|
73 | + throw new IllegalStateException("session wasnt started yet."); |
|
74 | + exit; |
|
75 | + } |
|
76 | 76 | |
77 | 77 | if (!isset($_SESSION['csrf_token'])) { |
78 | 78 | /*self::$csrf_token = hash_hmac( |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | );*/ |
83 | 83 | |
84 | 84 | //generate new CSRF token |
85 | - self::generateNewCSRFToken(); |
|
85 | + self::generateNewCSRFToken(); |
|
86 | 86 | } else { |
87 | 87 | //get CSRF token from string |
88 | 88 | self::$csrf_token = $_SESSION['csrf_token']; |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | public static function generateNewCSRFToken () { |
93 | - //generate new random token with 32 bytes |
|
94 | - self::$csrf_token = base64_encode( openssl_random_pseudo_bytes(32)); |
|
93 | + //generate new random token with 32 bytes |
|
94 | + self::$csrf_token = base64_encode( openssl_random_pseudo_bytes(32)); |
|
95 | 95 | |
96 | - $_SESSION['csrf_token'] = self::$csrf_token; |
|
97 | - } |
|
96 | + $_SESSION['csrf_token'] = self::$csrf_token; |
|
97 | + } |
|
98 | 98 | |
99 | 99 | public static function getCSRFToken () { |
100 | 100 | //return CSRF token |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | public static function checkCSRFToken ($value = null) { |
109 | - if (is_null($value)) { |
|
110 | - if (!isset($_REQUEST['csrf_token']) || empty($_REQUEST['csrf_token'])) { |
|
111 | - return false; |
|
112 | - } |
|
109 | + if (is_null($value)) { |
|
110 | + if (!isset($_REQUEST['csrf_token']) || empty($_REQUEST['csrf_token'])) { |
|
111 | + return false; |
|
112 | + } |
|
113 | 113 | |
114 | - $value = $_REQUEST['csrf_token']; |
|
115 | - } |
|
114 | + $value = $_REQUEST['csrf_token']; |
|
115 | + } |
|
116 | 116 | |
117 | 117 | return self::$csrf_token === $value; |
118 | 118 | } |
@@ -27,103 +27,103 @@ |
||
27 | 27 | |
28 | 28 | class Events { |
29 | 29 | |
30 | - protected static $events = array(); |
|
31 | - |
|
32 | - protected static $isInitialized = false; |
|
33 | - |
|
34 | - public static function init () { |
|
35 | - if (Cache::getCache()->contains("events", "events")) { |
|
36 | - self::$events = Cache::getCache()->get("events", "events"); |
|
37 | - } else { |
|
38 | - //load events from database |
|
39 | - $rows = Database::getInstance()->listRows("SELECT * FROM `{PRAEFIX}events` WHERE `activated` = '1'; "); |
|
40 | - |
|
41 | - //iterate through rows |
|
42 | - foreach ($rows as $row) { |
|
43 | - //get name of event |
|
44 | - $name = $row['name']; |
|
45 | - |
|
46 | - //check, if name exists in array |
|
47 | - if (!isset(self::$events[$name])) { |
|
48 | - self::$events[$name] = array(); |
|
49 | - } |
|
50 | - |
|
51 | - //add row to array |
|
52 | - self::$events[$name][] = $row; |
|
53 | - } |
|
54 | - |
|
55 | - //put events into cache |
|
56 | - Cache::getCache()->put("events", "events", self::$events); |
|
57 | - } |
|
58 | - |
|
59 | - //set initialized flag to true |
|
60 | - self::$isInitialized = true; |
|
61 | - } |
|
62 | - |
|
63 | - public static function throwEvent ($name, $params = array()) { |
|
64 | - if (!is_array($params)) { |
|
65 | - throw new IllegalArgumentException("second parameter params has to be an array."); |
|
66 | - } |
|
67 | - |
|
68 | - //check, if events was initialized first |
|
69 | - if (!self::$isInitialized) { |
|
70 | - //initialize events |
|
71 | - self::init(); |
|
72 | - } |
|
73 | - |
|
74 | - if (isset(self::$events[$name])) { |
|
75 | - foreach (self::$events[$name] as $event) { |
|
76 | - self::executeEvent($event, $params); |
|
77 | - } |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - protected static function executeEvent ($row, $params) { |
|
82 | - $type = strtolower($row['type']); |
|
83 | - $file = $row['file']; |
|
84 | - $class_name = $row['class_name']; |
|
85 | - $class_method = $row['class_method']; |
|
86 | - |
|
87 | - switch ($type) { |
|
88 | - case "file": |
|
89 | - //check, if file exists |
|
90 | - if (file_exists(ROOT_PATH . $file)) { |
|
91 | - require(ROOT_PATH . $file); |
|
92 | - } else { |
|
93 | - throw new IllegalStateException("required file for event not found: " . $file); |
|
94 | - } |
|
95 | - |
|
96 | - break; |
|
97 | - case "function": |
|
98 | - call_user_func($class_method, $params); |
|
99 | - break; |
|
100 | - case "class_static_method": |
|
101 | - call_user_func(array($class_name, $class_method), $params); |
|
102 | - break; |
|
103 | - default: |
|
104 | - throw new IllegalStateException("unknown event type '" . $type . "' for event '" . $row['name'] . "'!"); |
|
105 | - break; |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - public static function addEventClass (string $event, string $class_name, string $method, string $plugin_name) { |
|
110 | - Database::getInstance()->execute("INSERT INTO `{praefix}events` ( |
|
30 | + protected static $events = array(); |
|
31 | + |
|
32 | + protected static $isInitialized = false; |
|
33 | + |
|
34 | + public static function init () { |
|
35 | + if (Cache::getCache()->contains("events", "events")) { |
|
36 | + self::$events = Cache::getCache()->get("events", "events"); |
|
37 | + } else { |
|
38 | + //load events from database |
|
39 | + $rows = Database::getInstance()->listRows("SELECT * FROM `{PRAEFIX}events` WHERE `activated` = '1'; "); |
|
40 | + |
|
41 | + //iterate through rows |
|
42 | + foreach ($rows as $row) { |
|
43 | + //get name of event |
|
44 | + $name = $row['name']; |
|
45 | + |
|
46 | + //check, if name exists in array |
|
47 | + if (!isset(self::$events[$name])) { |
|
48 | + self::$events[$name] = array(); |
|
49 | + } |
|
50 | + |
|
51 | + //add row to array |
|
52 | + self::$events[$name][] = $row; |
|
53 | + } |
|
54 | + |
|
55 | + //put events into cache |
|
56 | + Cache::getCache()->put("events", "events", self::$events); |
|
57 | + } |
|
58 | + |
|
59 | + //set initialized flag to true |
|
60 | + self::$isInitialized = true; |
|
61 | + } |
|
62 | + |
|
63 | + public static function throwEvent ($name, $params = array()) { |
|
64 | + if (!is_array($params)) { |
|
65 | + throw new IllegalArgumentException("second parameter params has to be an array."); |
|
66 | + } |
|
67 | + |
|
68 | + //check, if events was initialized first |
|
69 | + if (!self::$isInitialized) { |
|
70 | + //initialize events |
|
71 | + self::init(); |
|
72 | + } |
|
73 | + |
|
74 | + if (isset(self::$events[$name])) { |
|
75 | + foreach (self::$events[$name] as $event) { |
|
76 | + self::executeEvent($event, $params); |
|
77 | + } |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + protected static function executeEvent ($row, $params) { |
|
82 | + $type = strtolower($row['type']); |
|
83 | + $file = $row['file']; |
|
84 | + $class_name = $row['class_name']; |
|
85 | + $class_method = $row['class_method']; |
|
86 | + |
|
87 | + switch ($type) { |
|
88 | + case "file": |
|
89 | + //check, if file exists |
|
90 | + if (file_exists(ROOT_PATH . $file)) { |
|
91 | + require(ROOT_PATH . $file); |
|
92 | + } else { |
|
93 | + throw new IllegalStateException("required file for event not found: " . $file); |
|
94 | + } |
|
95 | + |
|
96 | + break; |
|
97 | + case "function": |
|
98 | + call_user_func($class_method, $params); |
|
99 | + break; |
|
100 | + case "class_static_method": |
|
101 | + call_user_func(array($class_name, $class_method), $params); |
|
102 | + break; |
|
103 | + default: |
|
104 | + throw new IllegalStateException("unknown event type '" . $type . "' for event '" . $row['name'] . "'!"); |
|
105 | + break; |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + public static function addEventClass (string $event, string $class_name, string $method, string $plugin_name) { |
|
110 | + Database::getInstance()->execute("INSERT INTO `{praefix}events` ( |
|
111 | 111 | `id`, `name`, `type`, `file`, `class_name`, `class_method`, `created_from`, `activated` |
112 | 112 | ) VALUES ( |
113 | 113 | NULL, :event, 'CLASS_STATIC_METHOD', '', :class_name, :method, :created_from, '1' |
114 | 114 | ) ON DUPLICATE KEY UPDATE `activated` = '1';", array( |
115 | - 'event' => $event, |
|
116 | - 'class_name' => $class_name, |
|
117 | - 'method' => $method, |
|
118 | - 'created_from' => "plugin_" . $plugin_name |
|
119 | - )); |
|
120 | - } |
|
121 | - |
|
122 | - public static function removePluginEvents (string $plugin_name) { |
|
123 | - Database::getInstance()->execute("DELETE FROM `{praefix}events` WHERE `created_from` = :created_from; ", array( |
|
124 | - 'created_from' => "plugin_" . $plugin_name |
|
125 | - )); |
|
126 | - } |
|
115 | + 'event' => $event, |
|
116 | + 'class_name' => $class_name, |
|
117 | + 'method' => $method, |
|
118 | + 'created_from' => "plugin_" . $plugin_name |
|
119 | + )); |
|
120 | + } |
|
121 | + |
|
122 | + public static function removePluginEvents (string $plugin_name) { |
|
123 | + Database::getInstance()->execute("DELETE FROM `{praefix}events` WHERE `created_from` = :created_from; ", array( |
|
124 | + 'created_from' => "plugin_" . $plugin_name |
|
125 | + )); |
|
126 | + } |
|
127 | 127 | |
128 | 128 | } |
129 | 129 |
@@ -27,45 +27,45 @@ |
||
27 | 27 | |
28 | 28 | class LogoutPage extends HTMLPage { |
29 | 29 | |
30 | - protected $error = false; |
|
30 | + protected $error = false; |
|
31 | 31 | |
32 | - public function setCustomHeader() { |
|
33 | - //check, if session was started |
|
34 | - PHPUtils::checkSessionStarted(); |
|
32 | + public function setCustomHeader() { |
|
33 | + //check, if session was started |
|
34 | + PHPUtils::checkSessionStarted(); |
|
35 | 35 | |
36 | - if (!Security::checkCSRFToken()) { |
|
37 | - $this->error = true; |
|
36 | + if (!Security::checkCSRFToken()) { |
|
37 | + $this->error = true; |
|
38 | 38 | |
39 | - //dont logout user, because csrf token isnt correct |
|
40 | - return; |
|
41 | - } |
|
39 | + //dont logout user, because csrf token isnt correct |
|
40 | + return; |
|
41 | + } |
|
42 | 42 | |
43 | - //logout user |
|
44 | - User::current()->logout(); |
|
43 | + //logout user |
|
44 | + User::current()->logout(); |
|
45 | 45 | |
46 | - Events::throwEvent("after_logout"); |
|
46 | + Events::throwEvent("after_logout"); |
|
47 | 47 | |
48 | - //get domain |
|
49 | - $domain = Registry::singleton()->getObject("domain"); |
|
48 | + //get domain |
|
49 | + $domain = Registry::singleton()->getObject("domain"); |
|
50 | 50 | |
51 | - //generate index url |
|
52 | - $index_url = DomainUtils::generateURL($domain->getHomePage()); |
|
51 | + //generate index url |
|
52 | + $index_url = DomainUtils::generateURL($domain->getHomePage()); |
|
53 | 53 | |
54 | - header("Location: " . $index_url); |
|
54 | + header("Location: " . $index_url); |
|
55 | 55 | |
56 | - //flush gzip buffer |
|
57 | - ob_end_flush(); |
|
56 | + //flush gzip buffer |
|
57 | + ob_end_flush(); |
|
58 | 58 | |
59 | - exit; |
|
60 | - } |
|
59 | + exit; |
|
60 | + } |
|
61 | 61 | |
62 | - public function getContent(): string { |
|
63 | - if ($this->error) { |
|
64 | - return "Wrong CSRF token!"; |
|
65 | - } |
|
62 | + public function getContent(): string { |
|
63 | + if ($this->error) { |
|
64 | + return "Wrong CSRF token!"; |
|
65 | + } |
|
66 | 66 | |
67 | - return ""; |
|
68 | - } |
|
67 | + return ""; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | } |
71 | 71 |
@@ -27,90 +27,90 @@ |
||
27 | 27 | |
28 | 28 | class Plugin_HTTPAuth_HTTPAuth { |
29 | 29 | |
30 | - //http://php.net/manual/de/features.http-auth.php |
|
30 | + //http://php.net/manual/de/features.http-auth.php |
|
31 | 31 | |
32 | - public static function headerEvent () { |
|
33 | - //get preferences first |
|
34 | - $prefs = new Preferences("plugin_httpauth"); |
|
32 | + public static function headerEvent () { |
|
33 | + //get preferences first |
|
34 | + $prefs = new Preferences("plugin_httpauth"); |
|
35 | 35 | |
36 | - $activated = $prefs->get("activated", true); |
|
36 | + $activated = $prefs->get("activated", true); |
|
37 | 37 | |
38 | - if (!$activated) { |
|
39 | - return; |
|
40 | - } |
|
38 | + if (!$activated) { |
|
39 | + return; |
|
40 | + } |
|
41 | 41 | |
42 | - //check, if user is logged in |
|
43 | - if (User::current()->isLoggedIn()) { |
|
44 | - //http auth is not required, because user is already logged in |
|
45 | - return; |
|
46 | - } |
|
42 | + //check, if user is logged in |
|
43 | + if (User::current()->isLoggedIn()) { |
|
44 | + //http auth is not required, because user is already logged in |
|
45 | + return; |
|
46 | + } |
|
47 | 47 | |
48 | - //check, if credentials was already send |
|
49 | - if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) { |
|
50 | - self::sendHeader($prefs); |
|
51 | - } else { |
|
52 | - $username = $_SERVER['PHP_AUTH_USER']; |
|
53 | - $password = $_SERVER['PHP_AUTH_PW']; |
|
48 | + //check, if credentials was already send |
|
49 | + if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) { |
|
50 | + self::sendHeader($prefs); |
|
51 | + } else { |
|
52 | + $username = $_SERVER['PHP_AUTH_USER']; |
|
53 | + $password = $_SERVER['PHP_AUTH_PW']; |
|
54 | 54 | |
55 | - //try to login |
|
56 | - $res = User::current()->loginByUsername($username, $password); |
|
55 | + //try to login |
|
56 | + $res = User::current()->loginByUsername($username, $password); |
|
57 | 57 | |
58 | - if ($res['success'] !== true) { |
|
59 | - //send http header again |
|
60 | - self::sendHeader($prefs); |
|
61 | - } else { |
|
62 | - //login successful, show redirect |
|
63 | - if (isset($_REQUEST['redirect_url']) && !empty($_REQUEST['redirect_url'])) { |
|
64 | - //TODO: check for security issues, maybe we should check if redirect_url is a known domain |
|
58 | + if ($res['success'] !== true) { |
|
59 | + //send http header again |
|
60 | + self::sendHeader($prefs); |
|
61 | + } else { |
|
62 | + //login successful, show redirect |
|
63 | + if (isset($_REQUEST['redirect_url']) && !empty($_REQUEST['redirect_url'])) { |
|
64 | + //TODO: check for security issues, maybe we should check if redirect_url is a known domain |
|
65 | 65 | |
66 | - header("Location: " . urldecode($_REQUEST['redirect_url'])); |
|
66 | + header("Location: " . urldecode($_REQUEST['redirect_url'])); |
|
67 | 67 | |
68 | - //flush gzip buffer |
|
69 | - ob_end_flush(); |
|
68 | + //flush gzip buffer |
|
69 | + ob_end_flush(); |
|
70 | 70 | |
71 | - exit; |
|
72 | - } else { |
|
73 | - //redirect to index page |
|
71 | + exit; |
|
72 | + } else { |
|
73 | + //redirect to index page |
|
74 | 74 | |
75 | - //get domain |
|
76 | - $domain = Registry::singleton()->getObject("domain"); |
|
75 | + //get domain |
|
76 | + $domain = Registry::singleton()->getObject("domain"); |
|
77 | 77 | |
78 | - //generate index url |
|
79 | - $index_url = DomainUtils::generateURL($domain->getHomePage()); |
|
78 | + //generate index url |
|
79 | + $index_url = DomainUtils::generateURL($domain->getHomePage()); |
|
80 | 80 | |
81 | - header("Location: " . $index_url); |
|
81 | + header("Location: " . $index_url); |
|
82 | 82 | |
83 | - //flush gzip buffer |
|
84 | - ob_end_flush(); |
|
83 | + //flush gzip buffer |
|
84 | + ob_end_flush(); |
|
85 | 85 | |
86 | - exit; |
|
87 | - } |
|
88 | - } |
|
89 | - } |
|
90 | - } |
|
86 | + exit; |
|
87 | + } |
|
88 | + } |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - protected static function sendHeader (Preferences $prefs) { |
|
93 | - $realm_name = $prefs->get("realm_name", "Website"); |
|
92 | + protected static function sendHeader (Preferences $prefs) { |
|
93 | + $realm_name = $prefs->get("realm_name", "Website"); |
|
94 | 94 | |
95 | - //send http header, so browser will show a login form |
|
96 | - header('WWW-Authenticate: Basic realm="' . $realm_name . '"'); |
|
97 | - header('HTTP/1.0 401 Unauthorized'); |
|
95 | + //send http header, so browser will show a login form |
|
96 | + header('WWW-Authenticate: Basic realm="' . $realm_name . '"'); |
|
97 | + header('HTTP/1.0 401 Unauthorized'); |
|
98 | 98 | |
99 | - //text which will be sended, if user clicks on abort |
|
100 | - echo $prefs->get("abort_text", "<h1>401 Authorization Required</h1>"); |
|
99 | + //text which will be sended, if user clicks on abort |
|
100 | + echo $prefs->get("abort_text", "<h1>401 Authorization Required</h1>"); |
|
101 | 101 | |
102 | - ob_end_flush(); |
|
103 | - exit; |
|
104 | - } |
|
102 | + ob_end_flush(); |
|
103 | + exit; |
|
104 | + } |
|
105 | 105 | |
106 | - public static function logoutEvent () { |
|
107 | - //because browser safes http auth credentials by default, we need to do a little trick to clear browser auth cache |
|
108 | - header("Location: " . DomainUtils::getProtocol() . "foo:bar@" . DomainUtils::getBaseURL(true)); |
|
106 | + public static function logoutEvent () { |
|
107 | + //because browser safes http auth credentials by default, we need to do a little trick to clear browser auth cache |
|
108 | + header("Location: " . DomainUtils::getProtocol() . "foo:bar@" . DomainUtils::getBaseURL(true)); |
|
109 | 109 | |
110 | - //echo "Location: " . DomainUtils::getProtocol() . "foo:bar@" . DomainUtils::getBaseURL(true); |
|
110 | + //echo "Location: " . DomainUtils::getProtocol() . "foo:bar@" . DomainUtils::getBaseURL(true); |
|
111 | 111 | |
112 | - exit; |
|
113 | - } |
|
112 | + exit; |
|
113 | + } |
|
114 | 114 | |
115 | 115 | } |
116 | 116 |