X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=doc%2FjenkinsJob%2Fdyn-txt.php;fp=doc%2FjenkinsJob%2Fdyn-txt.php;h=f2fc49d92c08253e6fe7960717cb2256ff0de5ed;hp=c7b6cfeccb387ea9d363abc2696133955d2d31ec;hb=f9c330aaf4537d80cb6bb4a0734b2fe7fe5c6b89;hpb=5a1b7ee1d24604eaa2d0572f59555b5777e9c4eb diff --git a/doc/jenkinsJob/dyn-txt.php b/doc/jenkinsJob/dyn-txt.php index c7b6cfec..f2fc49d9 100644 --- a/doc/jenkinsJob/dyn-txt.php +++ b/doc/jenkinsJob/dyn-txt.php @@ -1,13 +1,15 @@ prepare("INSERT INTO tokens SET type=?, name=?"); + $stmt->bind_param("ss", $type, $name); + $type=$_GET['action']; + $name = $t1; + if($_GET['action'] == "http"){ + $stmt->execute(); -$time = time()/60; -if(!isset($todelete[$time])){ - $todelete[$time] = array(); + file_put_contents(".well-known/$appIdentifier-challenge/$t1.txt", $t2); + } else if($_GET['action'] == "dns") { + $stmt->execute(); + + $dnscalls .= "update delete {$t1}._$appIdentifier._auth." . ZONENAME . " TXT\n" + ."update add {$t1}._$appIdentifier._auth." . ZONENAME . " 60 TXT {$t2}\n"; + } } +$stmt = $link->prepare("SELECT type, name FROM tokens WHERE created + 60000 < CURRENT_TIMESTAMP;"); +$stmt->execute(); -$dnscalls = ""; +/* bind result variables */ +$stmt->bind_result($type, $name); +$todelete = array(); -if($_GET['action'] == "http"){ - $todelete[$time][] = array("http", $t1); - file_put_contents("cacert-$t1.txt", $t2); -} else if($_GET['action'] == "dns") { - $todelete[$time][] = array("dns", $t1); - $dnscalls .= "update delete {$t1}._cacert._auth." . ZONENAME . " TXT\n" - ."update add {$t1}._cacert._auth." . ZONENAME . " 60 TXT {$t2}\n"; -} -$copy = $todelete; -foreach($copy as $nt => $ar){ - if($nt < $time - 2){ - unset($todelete[$nt]); - foreach($ar as $act){ - if($act[0] == "http"){ - unlink("cacert-{$act[1]}.txt"); - } else if($act[0] == "dns") { - $dnscalls .= "update delete {$act[1]}._cacert._auth." . ZONENAME . " TXT\n"; - } - } +/* fetch value */ +while($stmt->fetch()){ + if($type == "http"){ + unlink(".well-known/$appIdentifier-challenge/{$name}.txt"); + } else if($type == "dns") { + $dnscalls .= "update delete {$name}._$appIdentifier._auth." . ZONENAME . " TXT\n"; } + $todelete[] = array("type"=>$type, "name"=>$name); +} + +$stmtd = $link->prepare("DELETE FROM tokens WHERE type=? AND name=?"); +$stmtd->bind_param("ss", $type, $name); + +foreach($todelete as $val){ + $type = $val["type"]; + $name = $val["name"]; + $stmtd->execute(); } -file_put_contents("data.php", ""); if($dnscalls != ""){ dnsAction($dnscalls); @@ -62,4 +72,3 @@ function dnsAction($command) { fwrite($nsupdate, $call); $retval = pclose($nsupdate); // nsupdate doesn't return anything useful when called this way } -