Skip to content

Commit 7fe908c

Browse files
author
Marius Cramer
committed
Cleaning up code to match coding guidelines
1 parent 7d52e00 commit 7fe908c

File tree

812 files changed

+51861
-51036
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

812 files changed

+51861
-51036
lines changed

helper_scripts/dns_export_to_bind.php

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,103 +2,103 @@
22
$host="IP_ADDRESS";
33
$user="USERNAME";
44
$password="PASSWORD";
5-
mysql_connect($host,$user,$password) or die(mysql_error());
5+
mysql_connect($host, $user, $password) or die(mysql_error());
66
mysql_select_db("dbispconfig");
77
$result = "";
88
$result = mysql_query("SELECT id,origin,ns,ttl,mbox,serial,refresh,retry,expire,minimum FROM dns_soa;");
99
function hostname2ipfunktion($tmp1, $timeout = 1)
10-
{
11-
if ($tmp1 == 0)
12-
{
13-
$query = `nslookup -timeout=$timeout -retry=0 $tmp1`;
14-
if(preg_match('/\nAddress: (.*)\n/', $query, $matches))
15-
return trim($matches[1]);
16-
return $tmp1;
17-
}
18-
}
10+
{
11+
if ($tmp1 == 0)
12+
{
13+
$query = `nslookup -timeout=$timeout -retry=0 $tmp1`;
14+
if(preg_match('/\nAddress: (.*)\n/', $query, $matches))
15+
return trim($matches[1]);
16+
return $tmp1;
17+
}
18+
}
1919

2020
$serialsearch=date("Ymd");
2121
$resultx12 = mysql_query("SELECT origin,serial FROM dns_soa WHERE serial LIKE '$serialsearch%' ORDER BY origin ASC;");
2222
while ($rowx12=mysql_fetch_array($resultx12)) {
23-
$zone=substr($rowx12["origin"],0,-1);
24-
$filename_x1="/var/cache/bind/".$zone;
25-
if (file_exists($filename_x1)) {
26-
$serialvergleich[$zone]=exec("grep \";Serial\" /var/cache/bind/$zone |cut -d\" \" -f1 | awk '{print $1}'");
27-
}
23+
$zone=substr($rowx12["origin"], 0, -1);
24+
$filename_x1="/var/cache/bind/".$zone;
25+
if (file_exists($filename_x1)) {
26+
$serialvergleich[$zone]=exec("grep \";Serial\" /var/cache/bind/$zone |cut -d\" \" -f1 | awk '{print $1}'");
27+
}
2828
}
2929

3030
while($row = mysql_fetch_array($result))
31-
{
32-
### Hier ALLES Aktivieren bei Primary Nameserver TEIL 1 #################################################################################
33-
$varx11=substr($row["origin"],0,-1);
34-
$filename="/var/cache/bind/".$varx11;
35-
if (file_exists($filename)) {
36-
unlink("/var/cache/bind/$varx11");
37-
}
38-
$arr1[$x11]="zone \"$varx11\" in { type master; file \"$varx11\"; };\n";
39-
$x11=$x11+1;
40-
$result2 = mysql_query("select name,type,aux,data from dns_rr where zone=$row[id] and active='Y' ORDER BY name ASC;");
41-
$arr3[0]="\$TTL ".$row['ttl']."\n@ IN SOA ".$row['ns']." ".$row['mbox']." (\n ".$row['serial']." ;Serial\n"." ".$row['refresh']." ;Refresh\n"." ".$row['retry']." ;Retry\n"." ".$row['expire']." ;Expire\n"." ".$row['minimum']." ) ;Minimum\n\n";
31+
{
32+
//## Hier ALLES Aktivieren bei Primary Nameserver TEIL 1 #################################################################################
33+
$varx11=substr($row["origin"], 0, -1);
34+
$filename="/var/cache/bind/".$varx11;
35+
if (file_exists($filename)) {
36+
unlink("/var/cache/bind/$varx11");
37+
}
38+
$arr1[$x11]="zone \"$varx11\" in { type master; file \"$varx11\"; };\n";
39+
$x11=$x11+1;
40+
$result2 = mysql_query("select name,type,aux,data from dns_rr where zone=$row[id] and active='Y' ORDER BY name ASC;");
41+
$arr3[0]="\$TTL ".$row['ttl']."\n@ IN SOA ".$row['ns']." ".$row['mbox']." (\n ".$row['serial']." ;Serial\n"." ".$row['refresh']." ;Refresh\n"." ".$row['retry']." ;Retry\n"." ".$row['expire']." ;Expire\n"." ".$row['minimum']." ) ;Minimum\n\n";
4242

43-
$xx1=1;
44-
while($row2 = mysql_fetch_row($result2))
45-
{
46-
$arr2[$xx1]=$row2['0']." IN ".$row2['1']." ";
43+
$xx1=1;
44+
while($row2 = mysql_fetch_row($result2))
45+
{
46+
$arr2[$xx1]=$row2['0']." IN ".$row2['1']." ";
4747

48-
if ($row2['2']>0)
49-
{
50-
$arr3[$xx1]=$arr2[$xx1].$row2['2']." ".$row2['3']."\n";
51-
}
52-
else
53-
{
54-
$arr3[$xx1]=$arr2[$xx1].$row2['3']."\n";
55-
}
56-
$xx1=$xx1+1;
57-
}
58-
$f = fopen("/var/cache/bind/$varx11", "a+");
59-
foreach($arr3 as $values) fputs($f, $values);
60-
fclose($f);
61-
$arr2=array();
62-
$arr3=array();
63-
### ENDE Primärer Nameserver TEIL 2 #####################################################################################################
48+
if ($row2['2']>0)
49+
{
50+
$arr3[$xx1]=$arr2[$xx1].$row2['2']." ".$row2['3']."\n";
51+
}
52+
else
53+
{
54+
$arr3[$xx1]=$arr2[$xx1].$row2['3']."\n";
55+
}
56+
$xx1=$xx1+1;
57+
}
58+
$f = fopen("/var/cache/bind/$varx11", "a+");
59+
foreach($arr3 as $values) fputs($f, $values);
60+
fclose($f);
61+
$arr2=array();
62+
$arr3=array();
63+
//## ENDE Primärer Nameserver TEIL 2 #####################################################################################################
6464

65-
### Hier ALLES Aktivieren bei Secondary Nameserver ######################################################################################
66-
# $tmp1 = substr($row["ns"],0,-1);
67-
# $tmp2 = substr($row["origin"],0,-1);
65+
//## Hier ALLES Aktivieren bei Secondary Nameserver ######################################################################################
66+
// $tmp1 = substr($row["ns"],0,-1);
67+
// $tmp2 = substr($row["origin"],0,-1);
6868

69-
# if (!isset($dnscache[$tmp1])) $nsip = hostname2ipfunktion($tmp1) ;
70-
# else $nsip=$dnscache[$tmp1] ;
69+
// if (!isset($dnscache[$tmp1])) $nsip = hostname2ipfunktion($tmp1) ;
70+
// else $nsip=$dnscache[$tmp1] ;
7171

72-
# if ($nsip == $tmp1)
73-
# {
74-
# echo "$tmp2 $tmp1 Not a valid Nameserver";
75-
# echo "\n";
76-
# }
77-
# else
78-
# {
79-
# $dnscache[$tmp1]=$nsip;
80-
# $arr1[$x11]="zone \"".$tmp2."\" in { type slave; file \"".$tmp2."\"; masters {".$nsip."; }; };\n";
81-
# $x11=$x11+1;
82-
# }
83-
### ENDE Secondary Nameserver ###########################################################################################################
84-
}
72+
// if ($nsip == $tmp1)
73+
// {
74+
// echo "$tmp2 $tmp1 Not a valid Nameserver";
75+
// echo "\n";
76+
// }
77+
// else
78+
// {
79+
// $dnscache[$tmp1]=$nsip;
80+
// $arr1[$x11]="zone \"".$tmp2."\" in { type slave; file \"".$tmp2."\"; masters {".$nsip."; }; };\n";
81+
// $x11=$x11+1;
82+
// }
83+
//## ENDE Secondary Nameserver ###########################################################################################################
84+
}
8585

86-
unlink ("/etc/bind/named.conf.local");
86+
unlink("/etc/bind/named.conf.local");
8787
$fx = fopen("/etc/bind/named.conf.local", "a+");
8888
foreach($arr1 as $values) fputs($fx, $values);
8989
fclose($fx);
9090
system("rndc reconfig >/dev/null 2>&1");
9191

92-
### ANFANG Primärer Namerserver TEIL 2 ##################################################################################################
92+
//## ANFANG Primärer Namerserver TEIL 2 ##################################################################################################
9393
$serialsearch=date("Ymd");
9494
$resultx13 = mysql_query("SELECT origin,serial FROM dns_soa WHERE serial LIKE '$serialsearch%' ORDER BY origin ASC;");
9595
while ($rowx13=mysql_fetch_array($resultx13)) {
96-
$serial_ist=($rowx13["serial"]);
97-
$zone=substr($rowx13["origin"],0,-1);
98-
# echo "zone: ".$zone." ist: ".$serial_ist." vergleich: ".$serialvergleich[$zone]."\n";
99-
if ($serialvergleich[$zone] != $serial_ist) {
100-
$reload=system("rndc reload $zone >/dev/null 2>&1");
101-
}
96+
$serial_ist=($rowx13["serial"]);
97+
$zone=substr($rowx13["origin"], 0, -1);
98+
// echo "zone: ".$zone." ist: ".$serial_ist." vergleich: ".$serialvergleich[$zone]."\n";
99+
if ($serialvergleich[$zone] != $serial_ist) {
100+
$reload=system("rndc reload $zone >/dev/null 2>&1");
101+
}
102102
}
103-
### ENDE Primärer NamerserverTEIL 2 ######################################################################################################
104-
?>
103+
//## ENDE Primärer NamerserverTEIL 2 ######################################################################################################
104+
?>

helper_scripts/dns_export_to_bind_retrans_daily.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
$host="IP_ADDRESS";
33
$user="USERNAME";
44
$password="PASSWORD";
5-
mysql_connect($host,$user,$password) or die(mysql_error());
5+
mysql_connect($host, $user, $password) or die(mysql_error());
66
mysql_select_db("dbispconfig");
77
$result = "";
88
$result = mysql_query("SELECT origin FROM dns_soa ORDER BY origin ASC;");
99
while($row = mysql_fetch_array($result))
1010
{
11-
$zone=substr($row["origin"],0,-1);
12-
system("rndc retransfer ".$zone);
11+
$zone=substr($row["origin"], 0, -1);
12+
system("rndc retransfer ".$zone);
1313
}
14-
?>
14+
?>

helper_scripts/mydns_to_powerdns_migration.php

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,69 @@
22
$host="localhost";
33
$user="root";
44
$password="MYSQL-ROOT-PASSWD";
5-
mysql_connect($host,$user,$password) or die(mysql_error());
5+
mysql_connect($host, $user, $password) or die(mysql_error());
66

77
mysql_select_db("dbispconfig");
88
$sql1 = mysql_query("SELECT id, substr(origin,1, LENGTH(origin)-1) AS origin, substr(ns,1, LENGTH(ns)-1) AS ns, substr(mbox,1, LENGTH(mbox)-1) AS mbox,ttl FROM dns_soa order by id asc;");
99
mysql_select_db("powerdns");
1010
while($row1 = mysql_fetch_array($sql1))
1111
{
12-
mysql_query("INSERT INTO domains (id,name,type,ispconfig_id) values ('$row1[id]','$row1[origin]','NATIVE','$row1[id]');");
13-
mysql_query("INSERT INTO records (domain_id,name,content,ispconfig_id,type,ttl,prio,change_date) values ('$row1[id]','$row1[origin]','$row1[ns] $row1[mbox] 0','$row1[id]','SOA','$row1[ttl]','0','1260446221');");
12+
mysql_query("INSERT INTO domains (id,name,type,ispconfig_id) values ('$row1[id]','$row1[origin]','NATIVE','$row1[id]');");
13+
mysql_query("INSERT INTO records (domain_id,name,content,ispconfig_id,type,ttl,prio,change_date) values ('$row1[id]','$row1[origin]','$row1[ns] $row1[mbox] 0','$row1[id]','SOA','$row1[ttl]','0','1260446221');");
1414
}
1515

1616
mysql_select_db("dbispconfig");
1717
$sql2 = mysql_query("SELECT id,zone,name,data,aux,ttl,type FROM dns_rr order by id asc;");
1818
mysql_select_db("powerdns");
1919
while($row2 = mysql_fetch_array($sql2))
2020
{
21-
if (strlen($row2['name']))
22-
{
23-
$file1=substr($row2['data'], -1);
24-
if ($file1==".")
25-
{
26-
$text = $row2['data'];
27-
$laenge = strlen($row2['data'])-1;
28-
$file2 = substr($text, 0,strlen($text)-1);
29-
}
30-
else
31-
{
32-
$file2=$row2['data'];
33-
}
34-
mysql_select_db("dbispconfig");
35-
$sql3 = mysql_query("SELECT substr(origin,1, LENGTH(origin)-1) AS origin FROM dns_soa where id=$row2[zone];");
36-
$row3 = mysql_fetch_array($sql3);
37-
mysql_select_db("powerdns");
38-
mysql_query("INSERT INTO records (domain_id,name,content,ispconfig_id,type,ttl,prio,change_date) values ('$row2[zone]','$row2[name].$row3[origin]','$file2','$row2[id]','$row2[type]','$row2[ttl]','$row2[aux]','1260446221');");
39-
}
40-
else
41-
{
42-
$file1=substr($row2['data'], -1);
43-
if ($file1==".")
44-
{
45-
$text = $row2['data'];
46-
$laenge = strlen($row2['data'])-1;
47-
$file2 = substr($text, 0,strlen($text)-1);
48-
}
49-
else
50-
{
51-
$file2=$row2['data'];
52-
}
53-
mysql_select_db("dbispconfig");
54-
$sql3 = mysql_query("SELECT substr(origin,1, LENGTH(origin)-1) AS origin FROM dns_soa where id=$row2[zone];");
55-
$row3 = mysql_fetch_array($sql3);
56-
mysql_select_db("powerdns");
57-
mysql_query("INSERT INTO records (domain_id,name,content,ispconfig_id,type,ttl,prio,change_date) values ('$row2[zone]','$row3[origin]','$file2','$row2[id]','$row2[type]','$row2[ttl]','$row2[aux]','1260446221');");
58-
}
21+
if (strlen($row2['name']))
22+
{
23+
$file1=substr($row2['data'], -1);
24+
if ($file1==".")
25+
{
26+
$text = $row2['data'];
27+
$laenge = strlen($row2['data'])-1;
28+
$file2 = substr($text, 0, strlen($text)-1);
29+
}
30+
else
31+
{
32+
$file2=$row2['data'];
33+
}
34+
mysql_select_db("dbispconfig");
35+
$sql3 = mysql_query("SELECT substr(origin,1, LENGTH(origin)-1) AS origin FROM dns_soa where id=$row2[zone];");
36+
$row3 = mysql_fetch_array($sql3);
37+
mysql_select_db("powerdns");
38+
mysql_query("INSERT INTO records (domain_id,name,content,ispconfig_id,type,ttl,prio,change_date) values ('$row2[zone]','$row2[name].$row3[origin]','$file2','$row2[id]','$row2[type]','$row2[ttl]','$row2[aux]','1260446221');");
39+
}
40+
else
41+
{
42+
$file1=substr($row2['data'], -1);
43+
if ($file1==".")
44+
{
45+
$text = $row2['data'];
46+
$laenge = strlen($row2['data'])-1;
47+
$file2 = substr($text, 0, strlen($text)-1);
48+
}
49+
else
50+
{
51+
$file2=$row2['data'];
52+
}
53+
mysql_select_db("dbispconfig");
54+
$sql3 = mysql_query("SELECT substr(origin,1, LENGTH(origin)-1) AS origin FROM dns_soa where id=$row2[zone];");
55+
$row3 = mysql_fetch_array($sql3);
56+
mysql_select_db("powerdns");
57+
mysql_query("INSERT INTO records (domain_id,name,content,ispconfig_id,type,ttl,prio,change_date) values ('$row2[zone]','$row3[origin]','$file2','$row2[id]','$row2[type]','$row2[ttl]','$row2[aux]','1260446221');");
58+
}
5959
}
6060

6161
mysql_select_db("powerdns");
6262
$sql4 = mysql_query("SELECT records.id,records.content,records.type,domains.name FROM records,domains where records.domain_id=domains.id and records.content NOT LIKE '%.%' and (records.type='CNAME' or records.type='NS' or records.type='MX') order by domain_id asc;");
6363

6464
while($row4 = mysql_fetch_array($sql4))
6565
{
66-
mysql_query("UPDATE records SET content = '$row4[content].$row4[name]' where id='$row4[id]';");
66+
mysql_query("UPDATE records SET content = '$row4[content].$row4[name]' where id='$row4[id]';");
6767
}
6868

6969

70-
?>
70+
?>
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
<?php
22

3-
#######################################################################################################
3+
//######################################################################################################
44
// Re-Create webalizer statistics
5-
#######################################################################################################
5+
//######################################################################################################
66

77

88
$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE server_id = ".$conf["server_id"];
99
$records = $app->db->queryAllRecords($sql);
1010
foreach($records as $rec) {
11-
$domain = escapeshellcmd($rec["domain"]);
12-
$logdir = escapeshellcmd($rec["document_root"].'/log');
13-
$statsdir = escapeshellcmd($rec["document_root"].'/web/stats');
14-
$webalizer = '/usr/bin/webalizer';
15-
16-
$webalizer_conf_main = '/etc/webalizer/webalizer.conf';
17-
$webalizer_conf = escapeshellcmd($rec["document_root"].'/log/webalizer.conf');
18-
exec("rm -rf $webalizer_conf");
19-
if(!@is_file($webalizer_conf)) {
20-
exec("cp $webalizer_conf_main $webalizer_conf");
21-
22-
setConfigVar($webalizer_conf, 'Incremental', 'yes');
23-
setConfigVar($webalizer_conf, 'IncrementalName', $logdir.'/webalizer.current');
24-
setConfigVar($webalizer_conf, 'HistoryName', $logdir.'/webalizer.hist');
25-
}
11+
$domain = escapeshellcmd($rec["domain"]);
12+
$logdir = escapeshellcmd($rec["document_root"].'/log');
13+
$statsdir = escapeshellcmd($rec["document_root"].'/web/stats');
14+
$webalizer = '/usr/bin/webalizer';
15+
16+
$webalizer_conf_main = '/etc/webalizer/webalizer.conf';
17+
$webalizer_conf = escapeshellcmd($rec["document_root"].'/log/webalizer.conf');
18+
exec("rm -rf $webalizer_conf");
19+
if(!@is_file($webalizer_conf)) {
20+
exec("cp $webalizer_conf_main $webalizer_conf");
21+
22+
setConfigVar($webalizer_conf, 'Incremental', 'yes');
23+
setConfigVar($webalizer_conf, 'IncrementalName', $logdir.'/webalizer.current');
24+
setConfigVar($webalizer_conf, 'HistoryName', $logdir.'/webalizer.hist');
25+
}
2626

27-
if(!@is_dir($statsdir)) mkdir($statsdir);
27+
if(!@is_dir($statsdir)) mkdir($statsdir);
2828

2929

30-
echo "Remove stats dir $statsdir ...\n";
31-
exec("rm -rf $statsdir/*");
30+
echo "Remove stats dir $statsdir ...\n";
31+
exec("rm -rf $statsdir/*");
3232

33-
echo "Re-Create stats for $domain...\n";
34-
exec("for logfile in $logdir/*access*; do\n$webalizer -c $webalizer_conf -n $domain -s $domain -r $domain -q -T -p -o $statsdir ".'$logfile'."\ndone");
35-
echo "done.\n";
33+
echo "Re-Create stats for $domain...\n";
34+
exec("for logfile in $logdir/*access*; do\n$webalizer -c $webalizer_conf -n $domain -s $domain -r $domain -q -T -p -o $statsdir ".'$logfile'."\ndone");
35+
echo "done.\n";
3636
}
3737

3838
die("finished.\n");
39-
?>
39+
?>

0 commit comments

Comments
 (0)