tuxis-ie / nsedit

DNS Editor working with PowerDNS's new API
GNU General Public License v2.0
199 stars 55 forks source link

Ability to use cname in template #150

Closed webvanced closed 7 years ago

webvanced commented 7 years ago

Hi,

It would be nice to be able to add a cname to the zonename in the template. I made a small modification to the code to make this work. Would be nice to have this in the nsedit source.

Example template config: array( 'name' => '', 'type' => 'A', 'content' => '1.2.3.4' ), array( 'name' => '', 'type' => 'CNAME', 'content' => '[zonename]' )

In zones change add below 333 a line that replaces [zonenname].

            foreach ($template['records'] as $record) {
                $name = $record['name'] != '' ? join(Array($record['name'],'.',$zonename)) : $zonename;
                $record['content'] = str_replace("[zonename]", $zonename, $record['content']);
                $zone->addRecord($name, $record['type'], $record['content']);
            }

Thanx for the good work.

tuxis-ie commented 7 years ago

Thanks. Can you turn this into a PR?

webvanced commented 7 years ago

Hi, created the pull request.

tuxis-ie commented 7 years ago

Merged #153