bug fixes on webhooks

This commit is contained in:
Diego Najar 2017-07-29 01:20:47 +02:00
parent fdca541194
commit 21fafa9082
6 changed files with 24 additions and 18 deletions

View File

@ -276,7 +276,7 @@ class Plugin {
// Returns the parameters after the URI, FALSE if the URI doesn't match with the webhook // Returns the parameters after the URI, FALSE if the URI doesn't match with the webhook
// Example: https://www.mybludit.com/api/foo/bar // 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; global $Url;
@ -292,8 +292,18 @@ class Plugin {
return false; return false;
} }
$afterURI = mb_substr($URI, $length);
if (!empty($afterURI)) {
if ($fixed) {
return false;
}
if ($afterURI[0]!='/') {
return false;
}
}
if ($returnsAfterURI) { if ($returnsAfterURI) {
return mb_substr($URI, $length); return $afterURI;
} }
Log::set(__METHOD__.LOG_SEP.'Webhook requested.'); Log::set(__METHOD__.LOG_SEP.'Webhook requested.');

View File

@ -111,7 +111,7 @@ define('CLI_STATUS', 'published');
define('CLI_USERNAME', 'admin'); define('CLI_USERNAME', 'admin');
// Filename // Filename
define('FILENAME', 'index.txt'); define('FILENAME', 'index.md');
// Database date format // Database date format
define('DB_DATE_FORMAT', 'Y-m-d H:i:s'); define('DB_DATE_FORMAT', 'Y-m-d H:i:s');

View File

@ -46,7 +46,7 @@ class pluginAPI extends Plugin {
// CHECK URL // CHECK URL
// ------------------------------------------------------------ // ------------------------------------------------------------
$URI = $this->webhook('api', $returnsAfterURI=true); $URI = $this->webhook('api', $returnsAfterURI=true, $fixed=false);
if ($URI===false) { if ($URI===false) {
return false; return false;
} }

View File

@ -97,11 +97,10 @@ class pluginRSS extends Plugin {
return '<link rel="alternate" type="application/rss+xml" href="'.DOMAIN_BASE.'rss.xml" title="RSS Feed">'.PHP_EOL; return '<link rel="alternate" type="application/rss+xml" href="'.DOMAIN_BASE.'rss.xml" title="RSS Feed">'.PHP_EOL;
} }
public function beforeRulesLoad() public function beforeAll()
{ {
global $Url; $webhook = 'rss.xml';
if( $this->webhook($webhook) ) {
if($Url->uri()===HTML_PATH_ROOT.'rss.xml') {
// Send XML header // Send XML header
header('Content-type: text/xml'); header('Content-type: text/xml');
$doc = new DOMDocument(); $doc = new DOMDocument();
@ -118,5 +117,4 @@ class pluginRSS extends Plugin {
exit(0); exit(0);
} }
} }
} }

View File

@ -62,11 +62,10 @@ class pluginSitemap extends Plugin {
$this->createXML(); $this->createXML();
} }
public function beforeRulesLoad() public function beforeAll()
{ {
global $Url; $webhook = 'sitemap.xml';
if( $this->webhook($webhook) ) {
if($Url->uri()===HTML_PATH_ROOT.'sitemap.xml') {
// Send XML header // Send XML header
header('Content-type: text/xml'); header('Content-type: text/xml');
$doc = new DOMDocument(); $doc = new DOMDocument();
@ -86,5 +85,4 @@ class pluginSitemap extends Plugin {
exit(0); exit(0);
} }
} }
} }