コード例 #1
0
 public function create_arpa($response, $identifier, $data, &$out = null)
 {
     ArpaFunctions::get_arpa($response, $identifier, $o);
     if (!empty($o)) {
         $response->code = Response::CONFLICT;
         $response->error = "Resource already exists";
         $response->error_detail = "ARPA_ALREADY_EXISTS";
         $out = false;
         return $response;
     }
     $response->error = null;
     unset($o);
     ZoneFunctions::get_zone($response, $identifier, $o, false);
     if (empty($o)) {
         if ($response->code == Response::NOTFOUND) {
             $response->error = sprintf("Could not find Arpa zone for ip '%s'", $identifier);
             $response->error_detail = "ARPA_ZONE_NOT_FOUND";
         }
         $out = false;
         return $response;
     }
     $zone = $o['name'];
     unset($o);
     $record = new stdClass();
     $record->name = HelperFunctions::ip_to_arpa($identifier);
     $record->type = "PTR";
     $record->content = $data;
     $req = new stdClass();
     $req->records = array($record);
     $response = ZoneFunctions::create_records($response, $zone, $req, $o, true);
     if (empty($o)) {
         return $response;
     }
     $response->code = Response::OK;
     $response->body = true;
     $response->log_message = sprintf("Added '%s' to Arpa zone '%s'", $identifier, $zone);
     $out = true;
     return $response;
 }