/
action.php
36 lines (30 loc) · 977 Bytes
/
action.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
* Text Variable plugin for DokuWiki; Action component
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Sahara Satoshi <sahara.satoshi@gmail.com>
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
class action_plugin_textvar extends DokuWiki_Action_Plugin {
// register hook
public function register(Doku_Event_Handler $controller) {
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, '_ajax_call');
}
/**
* Ajax handler
*/
function _ajax_call(Doku_Event $event, $param) {
if ($event->data !== 'plugin_textvar') return;
$event->stopPropagation();
$event->preventDefault();
$json = new JSON();
$data = array(
'%SERVER_ADDR%' => $_SERVER['SERVER_ADDR'],
'%REMOTE_ADDR%' => $_SERVER['REMOTE_ADDR'],
);
header('Content-Type: application/json');
echo $json->encode($data);
}
}