diff --git a/bl-kernel/abstract/plugin.class.php b/bl-kernel/abstract/plugin.class.php index 3fd2be03..95d4e14e 100644 --- a/bl-kernel/abstract/plugin.class.php +++ b/bl-kernel/abstract/plugin.class.php @@ -276,11 +276,11 @@ class Plugin { // Returns the parameters after the URI, FALSE if the URI doesn't match with the webhook // Example: https://www.mybludit.com/api/foo/bar - public function webhook($URI=false, $returnsAfterURI=false) + public function webhook($URI=false, $returnsAfterURI=false, $fixed=true) { global $Url; - if(empty($URI)) { + if (empty($URI)) { return false; } @@ -288,12 +288,22 @@ class Plugin { $startString = HTML_PATH_ROOT.$URI; $URI = $Url->uri(); $length = mb_strlen($startString, CHARSET); - if( mb_substr($URI, 0, $length)!=$startString ) { + if (mb_substr($URI, 0, $length)!=$startString) { return false; } - if($returnsAfterURI) { - return mb_substr($URI, $length); + $afterURI = mb_substr($URI, $length); + if (!empty($afterURI)) { + if ($fixed) { + return false; + } + if ($afterURI[0]!='/') { + return false; + } + } + + if ($returnsAfterURI) { + return $afterURI; } Log::set(__METHOD__.LOG_SEP.'Webhook requested.'); diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index f1cbe32d..7abfc971 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -111,7 +111,7 @@ define('CLI_STATUS', 'published'); define('CLI_USERNAME', 'admin'); // Filename -define('FILENAME', 'index.txt'); +define('FILENAME', 'index.md'); // Database date format define('DB_DATE_FORMAT', 'Y-m-d H:i:s'); diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 009b3986..e6c2a3aa 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -265,7 +265,7 @@ function createPage($args) { } $key = $dbPages->add($args); - if($key) { + if ($key) { // Call the plugins after page created Theme::plugins('afterPageCreate'); diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php index 53d98ab1..9fa95f9e 100644 --- a/bl-plugins/api/plugin.php +++ b/bl-plugins/api/plugin.php @@ -46,7 +46,7 @@ class pluginAPI extends Plugin { // CHECK URL // ------------------------------------------------------------ - $URI = $this->webhook('api', $returnsAfterURI=true); + $URI = $this->webhook('api', $returnsAfterURI=true, $fixed=false); if ($URI===false) { return false; } diff --git a/bl-plugins/rss/plugin.php b/bl-plugins/rss/plugin.php index c1622b77..be868bb6 100644 --- a/bl-plugins/rss/plugin.php +++ b/bl-plugins/rss/plugin.php @@ -97,11 +97,10 @@ class pluginRSS extends Plugin { return ''.PHP_EOL; } - public function beforeRulesLoad() + public function beforeAll() { - global $Url; - - if($Url->uri()===HTML_PATH_ROOT.'rss.xml') { + $webhook = 'rss.xml'; + if( $this->webhook($webhook) ) { // Send XML header header('Content-type: text/xml'); $doc = new DOMDocument(); @@ -118,5 +117,4 @@ class pluginRSS extends Plugin { exit(0); } } - } \ No newline at end of file diff --git a/bl-plugins/sitemap/plugin.php b/bl-plugins/sitemap/plugin.php index c5546e60..45c5448d 100644 --- a/bl-plugins/sitemap/plugin.php +++ b/bl-plugins/sitemap/plugin.php @@ -62,11 +62,10 @@ class pluginSitemap extends Plugin { $this->createXML(); } - public function beforeRulesLoad() + public function beforeAll() { - global $Url; - - if($Url->uri()===HTML_PATH_ROOT.'sitemap.xml') { + $webhook = 'sitemap.xml'; + if( $this->webhook($webhook) ) { // Send XML header header('Content-type: text/xml'); $doc = new DOMDocument(); @@ -86,5 +85,4 @@ class pluginSitemap extends Plugin { exit(0); } } - } \ No newline at end of file