1<?php
2/**
3 * iphelper Plugin
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     An-Dir <1.c-j@gmx.de>
7 */
8
9if(!defined('DOKU_INC')) die();
10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
11
12require_once(DOKU_PLUGIN.'action.php');
13
14class action_plugin_iphelper extends DokuWiki_Action_Plugin {
15
16    function register(Doku_Event_Handler $controller) {
17        $controller->register_hook('TPL_CONTENT_DISPLAY', 'BEFORE', $this, 'handle_content_display', array());
18    }
19
20    function handle_content_display(&$event, $param) {
21
22		            $subnetcalculator = $this->getConf('subnetcalculator');
23		            $subnetcalculatortarget = $this->getConf('subnetcalculatortarget');
24                    $tool1name = $this->getConf('tool1name');
25                    $tool2name = $this->getConf('tool2name');
26                    $tool3name = $this->getConf('tool3name');
27                    $tool4name = $this->getConf('tool4name');
28                    $tool5name = $this->getConf('tool5name');
29                    $tool6name = $this->getConf('tool6name');
30                    $tool7name = $this->getConf('tool7name');
31                    $tool8name = $this->getConf('tool8name');
32                    $tool9name = $this->getConf('tool9name');
33                    $tool10name = $this->getConf('tool10name');
34                    $rawtools = $this->getConf('rawtools');
35
36
37                    if (strlen($tool1name) > 1) {$tool1url = $this->getConf('tool1url');$tool1urltarget = $this->getConf('tool1urltarget'); $tool1html = "<a href=\"". $tool1url ."\" target=\"". $tool1urltarget ."\">" . $tool1name . "</a><br>";}
38                    if (strlen($tool2name) > 1) {$tool2url = $this->getConf('tool2url');$tool2urltarget = $this->getConf('tool2urltarget'); $tool2html = "<a href=\"". $tool2url ."\" target=\"". $tool2urltarget ."\">" . $tool2name . "</a><br>";}
39                    if (strlen($tool3name) > 1) {$tool3url = $this->getConf('tool3url');$tool3urltarget = $this->getConf('tool3urltarget'); $tool3html = "<a href=\"". $tool3url ."\" target=\"". $tool3urltarget ."\">" . $tool3name . "</a><br>";}
40                    if (strlen($tool4name) > 1) {$tool4url = $this->getConf('tool4url');$tool4urltarget = $this->getConf('tool4urltarget'); $tool4html = "<a href=\"". $tool4url ."\" target=\"". $tool4urltarget ."\">" . $tool4name . "</a><br>";}
41                    if (strlen($tool5name) > 1) {$tool5url = $this->getConf('tool5url');$tool5urltarget = $this->getConf('tool5urltarget'); $tool5html = "<a href=\"". $tool5url ."\" target=\"". $tool5urltarget ."\">" . $tool5name . "</a><br>";}
42                    if (strlen($tool6name) > 1) {$tool6url = $this->getConf('tool6url');$tool6urltarget = $this->getConf('tool6urltarget'); $tool6html = "<a href=\"". $tool6url ."\" target=\"". $tool6urltarget ."\">" . $tool6name . "</a><br>";}
43                    if (strlen($tool7name) > 1) {$tool7url = $this->getConf('tool7url');$tool7urltarget = $this->getConf('tool7urltarget'); $tool7html = "<a href=\"". $tool7url ."\" target=\"". $tool7urltarget ."\">" . $tool7name . "</a><br>";}
44                    if (strlen($tool8name) > 1) {$tool8url = $this->getConf('tool8url');$tool8urltarget = $this->getConf('tool8urltarget'); $tool8html = "<a href=\"". $tool8url ."\" target=\"". $tool8urltarget ."\">" . $tool8name . "</a><br>";}
45                    if (strlen($tool9name) > 1) {$tool9url = $this->getConf('tool9url');$tool9urltarget = $this->getConf('tool9urltarget'); $tool9html = "<a href=\"". $tool9url ."\" target=\"". $tool9urltarget ."\">" . $tool9name . "</a><br>";}
46                    if (strlen($tool10name) > 1) {$tool10url = $this->getConf('tool10url');$tool10urltarget = $this->getConf('tool10urltarget'); $tool10html = "<a href=\"". $tool10url ."\" target=\"". $tool10urltarget ."\">" . $tool10name . "</a><br>";}
47
48                    $iphelperbase = "" . $tool1html . $tool2html . $tool3html . $tool4html . $tool5html . $tool6html . $tool7html . $tool8html . $tool9html . $tool10html . $rawtools;
49
50
51
52
53            $event->data .= <<<TEXT
54<!-- The iphelper Template -->
55<div style="display: none;" id="iphelpertemplate">$iphelperbase</div>
56<div style="display: none;" id="iphelpertemplatemask"><a href="$subnetcalculator" target="$subnetcalculatortarget">Start SubnetCalc ($subnetcalculator)</a></div>
57<!-- The iphelper -->
58<div id="myiphelper" class="myiphelper">
59
60  <!-- iphelper content -->
61  <div class="iphelper-content">
62    <div class="iphelper-header" style="font-size: 28px;">
63      <span class="iphelperclose">&times;</span>
64      iphelper toolbox <input type="text" id="iphelperinput"></input>
65    </div>
66    <div class="iphelper-body">
67      <p id="iphelperbodyp">you see this when javscript or css is not working correct</p>
68	  <p id="iphelpersubnetcalc">
69
70<div class="section" id="calc">
71<div class="input" style="display:none;">
72<h2>Input</h2>
73<form name="input" action="post">
74IP-Address:<input type="text" id="iphelpersubnetcalcinput" name="in_address" value="127.0.0.1" onkeyup="ipChange()" />
75Subnet:<input type="text" id="iphelpersubnetcalcsubnetinput" name="in_subnet" value="255.0.0.0" onkeyup="subChange()" />
76</form>
77</div>
78<div class="output">
79<div id='is_valid' class='is_valid' style="background-color:#E6E6FA">Untested</div>
80<form name="output" action="post">
81IP Address:
82<span id="out_address"></span><br>
83First usable:
84<span id="out_firstusable"></span><br>
85Subnet:
86<span id="out_subnet"></span><br>
87Last usable:
88<span id="out_lastusable"></span><br>
89CIDR:
90<span id="out_cidr"></span><br>
91Amount of usable:
92<span id="out_amountaddresses"></span><br>
93Network address:
94<span id="out_netaddr"></span><br>
95Reverse address:
96<span id="out_ptraddr"></span><br>
97Broadcast address:
98<span id="out_bcast"></span><br>
99</form>
100</div>
101</div>
102
103</p>
104    </div>
105    <div class="iphelper-footer">
106      <h3 id="iphelperfooter">&nbsp;</h3>
107    </div>
108  </div>
109
110</div>
111
112TEXT;
113    }
114
115}
116