2 header("Content-type: text/plain");
4 define("ZONENAME", "cacert.dyn.dogcraft.de");
5 define("KEYNAME", "keys/Kcacert.dyn.dogcraft.de.+165+54687.key");
7 if(!isset($_GET['token']) || !isset($_GET['t1']) || !isset($_GET['t2']) || !isset($_GET['action'])){
10 if($_GET['token'] != "rD1m3A9ew6Hs4DIv7lnTxNbR6dr"){
15 if(!preg_match("/^[a-zA-Z0-9]+$/", $t1) || !preg_match("/^[a-zA-Z0-9]+$/", $t2)){
20 if(file_exists("data.php")){
25 if(!isset($todelete[$time])){
26 $todelete[$time] = array();
31 if($_GET['action'] == "http"){
32 $todelete[$time][] = array("http", $t1);
33 file_put_contents("cacert-$t1.txt", $t2);
34 } else if($_GET['action'] == "dns") {
35 $todelete[$time][] = array("dns", $t1);
36 $dnscalls .= "update delete {$t1}._cacert._auth." . ZONENAME . " TXT\n"
37 ."update add {$t1}._cacert._auth." . ZONENAME . " 60 TXT {$t2}\n";
40 foreach($copy as $nt => $ar){
42 unset($todelete[$nt]);
44 if($act[0] == "http"){
45 unlink("cacert-{$act[1]}.txt");
46 } else if($act[0] == "dns") {
47 $dnscalls .= "update delete {$act[1]}._cacert._auth." . ZONENAME . " TXT\n";
52 file_put_contents("data.php", "<?php \$todelete = ".var_export($todelete,true).";\n?>");
58 function dnsAction($command) {
59 $call = "server localhost\n$command\nsend\nquit\n";
61 $nsupdate = popen("/usr/bin/nsupdate -k " . KEYNAME, 'w');
62 fwrite($nsupdate, $call);
63 $retval = pclose($nsupdate); // nsupdate doesn't return anything useful when called this way