bug fixes on webhooks
This commit is contained in:
parent
fdca541194
commit
21fafa9082
|
@ -276,7 +276,7 @@ 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;
|
||||
|
||||
|
@ -292,8 +292,18 @@ class Plugin {
|
|||
return false;
|
||||
}
|
||||
|
||||
$afterURI = mb_substr($URI, $length);
|
||||
if (!empty($afterURI)) {
|
||||
if ($fixed) {
|
||||
return false;
|
||||
}
|
||||
if ($afterURI[0]!='/') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($returnsAfterURI) {
|
||||
return mb_substr($URI, $length);
|
||||
return $afterURI;
|
||||
}
|
||||
|
||||
Log::set(__METHOD__.LOG_SEP.'Webhook requested.');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue