1<?php
2/**
3 * adultcontent plugin
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     S.C. yoo <dryoo@live.com>
7 */
8
9// must be run within Dokuwiki
10if(!defined('DOKU_INC')) die();
11
12if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
13require_once(DOKU_PLUGIN.'action.php');
14
15class action_plugin_adultcontent extends DokuWiki_Action_Plugin {
16
17	var $functions = null;
18
19	function register( Doku_Event_Handler $controller)
20	{
21		$controller->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, 'adultcontent__check');
22	}
23
24	function adultcontent__check(&$event, $args) {
25
26        global $ID;
27
28		$adult = p_get_metadata($ID, "adult");
29		if ($adult == null) $adult=false;
30        $regex=$this->getConf('keywords');
31
32        echo "<script>alert(\"$regex\");</script>";
33		if (preg_match("/$regex/si",$event->data[0][1]))
34		{
35			$adult=true;
36		} else
37		{
38			$adult=false;
39		}
40		p_set_metadata($ID, array('adult' => $adult));
41		return ;
42	}
43}