Sytemoutput.php
5.66 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/**
* This file is part of ncfilters by netz.coop eG.
*
* Ncfilters is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Ncfilters is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Ncfilters. If not, see <http://www.gnu.org/licenses/>.
*
* Diese Datei ist Teil von ncfilters by netz.coop eG.
*
* Ncfilters ist Freie Software: Sie können es unter den Bedingungen
* der GNU General Public License, wie von der Free Software Foundation,
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren
* veröffentlichten Version, weiterverbreiten und/oder modifizieren.
*
* Ncfilters wird in der Hoffnung, dass es nützlich sein wird, aber
* OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
* Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
* Siehe die GNU General Public License für weitere Details.
*
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
*
*/
/**
* Sytemoutput
* Output to files or System calls
*
* @author kontakt@nc
*/
class Sytemoutput {
public function createfw($array_pclistgroups){
$i=0;
file_put_contents(FWFILENAME, PHP_EOL);
file_put_contents(FWFILENAME,' -t nat -F PREROUTING'. PHP_EOL);
file_put_contents(FWFILENAME,' -F FORWARD'. PHP_EOL ,FILE_APPEND);
foreach($array_pclistgroups as $key =>$value){
if($value['open']==='1'){
// file_put_contents(FWFILENAME,''.$value['ip'].'\n',FILE_APPEND);
file_put_contents(FWFILENAME,' -t nat -A PREROUTING --src '.$value['ip'].' -i eth1 -j OPEN'. PHP_EOL ,FILE_APPEND);
}else if($value['open']==='0' || $value['open']==='off' ){
// by Heiko }else if($value['open']==='1' || $value['open']==='on' ){
// if($i===0){
// file_put_contents(FWFILENAME,' -t nat -A PREROUTING --src '.$value['ip'].' -i eth1 -p udp --dport 53 -j REDIRECT --to-port 5335 '. PHP_EOL ,FILE_APPEND);
// }else{
file_put_contents(FWFILENAME,' -t nat -A PREROUTING --src '.$value['ip'].' -i eth1 -j BLOCK'. PHP_EOL ,FILE_APPEND);
// schlechte Idee, blockiert auch den gewünschten Datenverkehr
// file_put_contents(FWFILENAME,' -A FORWARD --src '.$value['ip'].' -i eth1 -j DROP'. PHP_EOL ,FILE_APPEND);
// }
// file_put_contents(FWFILENAME,' -t nat -A PREROUTING --src '.$value['ip'].' -i eth1 -p tcp --dport 53 -j REDIRECT --to-port 5335 '. PHP_EOL ,FILE_APPEND);
}
// $i++;
}
}
public function createhosts($array_pclistgroups){
file_put_contents(DNSFILENAME,' -t nat -N OPEN'. PHP_EOL);
file_put_contents(DNSFILENAME,' -t nat -F OPEN'. PHP_EOL ,FILE_APPEND);
file_put_contents(DNSFILENAME,' -t nat -A OPEN -j ACCEPT'. PHP_EOL ,FILE_APPEND);
file_put_contents(DNSFILENAME,' -t nat -N BLOCK'. PHP_EOL ,FILE_APPEND);
file_put_contents(DNSFILENAME,' -t nat -F BLOCK'. PHP_EOL ,FILE_APPEND);
foreach($array_pclistgroups as $key =>$value){
if($value['open']==='0'){
}else if($value['enable']==='1' || $value['enable']==='on' ){
file_put_contents(DNSFILENAME,' -t nat -A BLOCK -i eth1 -d '.$value['ip'].' -j ACCEPT'. PHP_EOL ,FILE_APPEND);
}
}
file_put_contents(DNSFILENAME,' -t nat -A BLOCK -i eth1 -m multiport -p tcp --dports 80,443,8080 -j DNAT --to-destination 10.8.11.10'. PHP_EOL ,FILE_APPEND);
}
public function closefwcron($array_closefwcron){
$i=0;
foreach($array_closefwcron as $key =>$value){
if($i===0){
file_put_contents(CRONFILENAME,$value['close_time_minute'].' '.$value['close_time_hour'].' * * * /usr/local/sbin/close_fw.sh'. PHP_EOL);
}else{
file_put_contents(CRONFILENAME,$value['close_time_minute'].' '.$value['close_time_hour'].' * * * /usr/local/sbin/close_fw.sh'. PHP_EOL ,FILE_APPEND);
}
$i++;
}
}
function start_index_html($array_url){
foreach($array_url as $key =>$url){
$http_url = 'http://'.$url['url'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $http_url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);
//parsing begins here:
$doc = new DOMDocument();
@$doc->loadHTML($data);
$nodes = $doc->getElementsByTagName('title');
//get and display what you need:
$title = $nodes->item(0)->nodeValue;
$metas = $doc->getElementsByTagName('meta');
for ($i = 0; $i < $metas->length; $i++) {
$meta = $metas->item($i);
if($meta->getAttribute('name') == 'description') {
$description = $meta->getAttribute('content'); }
if($meta->getAttribute('name') == 'keywords') {
$keywords = $meta->getAttribute('content'); }
}
echo "Title: $title". '<br/><br/>';
echo "Beschreibung: $description". '<br/><br/>';
echo "Stichworte: $keywords". '<br/><br/>';
}
}
}