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/');
14require_once(DOKU_PLUGIN.'action.php');
15
16class action_plugin_corsharing extends DokuWiki_Action_Plugin {
17
18	/**
19	 * return some info
20   */
21	function getInfo() {
22		return array(
23		 'author' => 'Cyrille37',
24		 'email'  => 'cyrille@comptoir.net',
25		 'date'   => '2022-08-20',
26		 'name'   => 'CORS - enabling Cross-Origin Resource Sharing',
27		 'desc'   => 'Used to enable Cross-Origin Resource Sharing http headers
28									to permit client visiting other website
29									to load some data from your dokuwiki website',
30		 'url'    => 'https://framagit.org/Cyrille37/dokuwiki-plugin-corsharing'
31		);
32	}
33
34	/**
35	 * Register its handlers with the DokuWiki's event controller.
36	 *
37	 * https://www.dokuwiki.org/devel:events
38	 */
39	function register( $controller) {
40
41		$controller->register_hook('DOKUWIKI_INIT_DONE', 'AFTER', $this, 'handleEvent');
42	}
43
44	function handleEvent( $event, $param ) {
45
46		header('Access-Control-Allow-Origin: *');
47	}
48
49}
50
51