define('CN_API_URL', 'https://dnsapi.cn/');
define('LOG_FILE', 'export_domain.log');
set_time_limit(0);
$FileLog = new FileLog(LOG_FILE);
try {
    $DNSPodCN = new DNSPodCN(CN_USER, CN_PASSWORD, CN_DTOKEN);
    $DNSPodCom = new DNSPodCOM(COM_USER, COM_PASSWORD);
    $domains = $DNSPodCN->getDomains();
} catch (Exception $e) {
    die('Initialization Exception: ' . $e->getMessage() . "\n");
}
foreach ($domains as $domain) {
    $FileLog->newLine("Adding domain: {$domain};");
    try {
        $ret = $DNSPodCom->addDomain($domain);
        $ret = true === $ret ? $FileLog->append(' Result: success') : $FileLog->append(" Result: error ({$ret})");
    } catch (Exception $e) {
        $FileLog->append(' Exception: ' . $e->getMessage());
    }
    $records = $DNSPodCN->getRecords($domain);
    if (is_array($records) && !empty($records)) {
        foreach ($records as $k => $v) {
            $FileLog->newLine("   Adding record: {$v['sub_domain']}, {$v['record_type']}, {$v['value']}, {$v['ttl']}, {$v['mx']};");
            try {
                $ret = $DNSPodCom->addRecord($v['domain'], $v['sub_domain'], $v['record_type'], $v['value'], $v['ttl'], $v['mx']);
                $ret = true === $ret ? $FileLog->append(' Result: success') : $FileLog->append(" Result: error({$ret})");
            } catch (Exception $e) {
                $FileLog->append(' Exception: ' . $e->getMessage());
            }
        }
    } else {