1<?php
2/**
3 * CORSharing - enabling CORS (Cross-Origin Resource Sharing)
4 * Enable/disable CORS (Cross-Origin Resource Sharing). Used to enable CORS http headers to permits web client visiting other website to load some data from your dokuwiki website.
5 *
6 * @author Cyrille Giquello <cyrille@comptoir.net>
7 * @copyright 2016 Cyrille Giquello
8 * @license LGPL v3 http://www.gnu.org/licenses/lgpl.html
9 * @link http://savoirscommuns.comptoir.net
10 */
11
12if(!defined('DOKU_INC')) die();
13if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
14
15// https://framagit.org/Cyrille37/dokuwiki-plugin-corsharing/-/issues/3
16// require(DOKU_PLUGIN.'action.php');
17
18class action_plugin_corsharing extends DokuWiki_Action_Plugin {
19
20	/**
21	 * return some info
22   */
23	function getInfo() {
24		return array(
25		 'author' => 'Cyrille37',
26		 'email'  => 'cyrille@comptoir.net',
27		 'date'   => '2022-08-20',
28		 'name'   => 'CORS - enabling Cross-Origin Resource Sharing',
29		 'desc'   => 'Used to enable Cross-Origin Resource Sharing http headers
30									to permit client visiting other website
31									to load some data from your dokuwiki website',
32		 'url'    => 'https://framagit.org/Cyrille37/dokuwiki-plugin-corsharing'
33		);
34	}
35
36	/**
37	 * Register its handlers with the DokuWiki's event controller.
38	 *
39	 * https://www.dokuwiki.org/devel:events
40	 */
41	function register( $controller) {
42
43		$controller->register_hook('DOKUWIKI_INIT_DONE', 'AFTER', $this, 'handleEvent');
44	}
45
46	function handleEvent( $event, $param ) {
47
48		header('Access-Control-Allow-Origin: *');
49	}
50
51}
52
53