commit | author | age
|
563af8
|
1 |
<?php |
T |
2 |
$host="localhost"; |
|
3 |
$user="root"; |
|
4 |
$password="MYSQL-ROOT-PASSWD"; |
b1a6a5
|
5 |
mysql_connect($host, $user, $password) or die(mysql_error()); |
563af8
|
6 |
|
T |
7 |
mysql_select_db("dbispconfig"); |
|
8 |
$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;"); |
|
9 |
mysql_select_db("powerdns"); |
|
10 |
while($row1 = mysql_fetch_array($sql1)) |
|
11 |
{ |
b1a6a5
|
12 |
mysql_query("INSERT INTO domains (id,name,type,ispconfig_id) values ('$row1[id]','$row1[origin]','NATIVE','$row1[id]');"); |
MC |
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');"); |
563af8
|
14 |
} |
T |
15 |
|
|
16 |
mysql_select_db("dbispconfig"); |
|
17 |
$sql2 = mysql_query("SELECT id,zone,name,data,aux,ttl,type FROM dns_rr order by id asc;"); |
|
18 |
mysql_select_db("powerdns"); |
|
19 |
while($row2 = mysql_fetch_array($sql2)) |
|
20 |
{ |
b1a6a5
|
21 |
if (strlen($row2['name'])) |
MC |
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 |
} |
563af8
|
59 |
} |
T |
60 |
|
|
61 |
mysql_select_db("powerdns"); |
|
62 |
$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;"); |
|
63 |
|
|
64 |
while($row4 = mysql_fetch_array($sql4)) |
|
65 |
{ |
b1a6a5
|
66 |
mysql_query("UPDATE records SET content = '$row4[content].$row4[name]' where id='$row4[id]';"); |
563af8
|
67 |
} |
T |
68 |
|
|
69 |
|
b1a6a5
|
70 |
?> |