static function createDhcpConfFile($slist) { $list = os_get_allips(); foreach ($list as $l) { $base = strtil($l, "."); $subnet[$base] = null; } $string = null; $string .= "ddns-update-style interim;\n"; $string .= "ignore client-updates;\n\n\n"; $string .= self::getSubnetString($k, $slist); /* foreach($subnet as $k => $v) { $string .= self::getSubnetString($k, $slist); } */ foreach ($slist as $s) { $string .= self::getHostString($s); } lfile_put_contents("/etc/dhcpd.conf", $string); createRestartFile("dhcpd"); }
<?php include_once "htmllib/lib/include.php"; $list = os_get_allips(); $list[] = "127.0.0.1/8"; change_config("/etc/mararc", "ipv4_bind_addresses", implode(",", $list));
static function createSSlConf($iplist, $domainiplist) { global $gbl, $sgbl, $login, $ghtml; $string = null; $alliplist = os_get_allips(); foreach ((array) $iplist as $ip) { if (!array_search_bool($ip['ipaddr'], $alliplist)) { continue; } // issue related to delete 'exclusive ip/domain' if (isset($domainiplist[$ip['ipaddr']])) { $v = $domainiplist[$ip['ipaddr']]; if ($v !== '' && $v !== '--Disabled--') { continue; } } $string .= "\n\t<Virtualhost "; $string .= "{$ip['ipaddr']}:443"; $string .= ">\n\n"; $ssl_cert = sslcert::getSslCertnameFromIP($ip['nname']); $ssl_root = $sgbl->__path_ssl_root; $certificatef = "{$ssl_root}/{$ssl_cert}.crt"; $keyfile = "{$ssl_root}/{$ssl_cert}.key"; $cafile = "{$ssl_root}/{$ssl_cert}.ca"; sslcert::checkAndThrow(lfile_get_contents($certificatef), lfile_get_contents($keyfile), $ssl_cert); $string .= "\t\tSSLEngine On \n"; $string .= "\t\tSSLCertificateFile {$certificatef}\n"; $string .= "\t\tSSLCertificateKeyFile {$keyfile}\n"; $string .= "\t\tSSLCACertificatefile {$cafile}\n\n"; $string .= "\t</Virtualhost>\n"; } // issue #725, #760 - ssl.conf must be the first file in listing // MR -- so change name from ssl.conf to __ssl.conf system("rm -rf /home/apache/conf/defaults/ssl.conf"); $sslfile = "/home/apache/conf/defaults/__ssl.conf"; $string = "<IfModule mod_ssl.c>\n{$string}\n</IfModule>\n\n"; $string .= "DirectoryIndex index.php index.htm default.htm default.html\n\n"; lfile_put_contents($sslfile, $string); }
function getOneIPForLocalhost($v) { if (isLocalhost($v)) { return 'localhost'; } if (is_secondary_master()) { $list = os_get_allips(); $ip = getFirstFromList($list); return $ip; } return getFQDNforServer('localhost'); }
function fixRelay() { $list = os_get_allips(); $out = implode("\n", $list); $out = "{$out}\n"; lfile_put_contents("/var/dnscache/root/servers/{$this->main->nname}", $out); foreach ((array) $this->main->__var_addonlist as $d) { $dnsfile = "/var/dnscache/root/servers/{$d->nname}"; lfile_put_contents($dnsfile, $out); } }
static function createSSlConf($iplist, $domainiplist) { global $gbl, $sgbl, $login, $ghtml; $string = null; $alliplist = os_get_allips(); foreach ($iplist as $ip) { if (!array_search_bool($ip['ipaddr'], $alliplist)) { continue; } // issue related to delete 'exclusive ip/domain' if (isset($domainiplist[$ip['ipaddr']])) { $v = $domainiplist[$ip['ipaddr']]; if ($v !== '' && $v !== '--Disabled--') { continue; } } $ssl_cert = null; $ssl_cert = sslcert::getSslCertnameFromIP($ip['nname']); $certificatef = "{$sgbl->__path_ssl_root}/{$ssl_cert}.crt"; $keyfile = "{$sgbl->__path_ssl_root}/{$ssl_cert}.key"; $pemfile = "{$sgbl->__path_ssl_root}/{$ssl_cert}.pem"; $cafile = "{$sgbl->__path_ssl_root}/{$ssl_cert}.ca"; sslcert::checkAndThrow(lfile_get_contents($certificatef), lfile_get_contents($keyfile), $ssl_cert); if (!lxfile_exists($pemfile)) { $c = lfile_get_contents($certificatef); $k = lfile_get_contents($keyfile); lfile_put_contents($pemfile, "{$c}\n{$k}"); } $string .= "\$SERVER[\"socket\"] == \"{$ip['ipaddr']}:443\" {\n\n"; $string .= "\tssl.engine = \"enable\"\n"; $string .= "\tssl.pemfile = \"{$pemfile}\"\n"; $string .= "\tssl.ca-file = \"{$cafile}\"\n\n"; $string .= "}\n\n"; } // issue #725, #760 - ssl.conf must be the first file in listing // so change name from ssl.conf to __ssl.conf system("rm -rf /home/lighttpd/conf/defaults/ssl.conf"); $sslfile = "/home/lighttpd/conf/defaults/__ssl.conf"; lfile_put_contents($sslfile, $string); }
function syncCreateConf() { global $gbl, $sgbl, $login, $ghtml; // $host = `hostname`; $result = $this->main->__var_domainlist; $fdata = null; $dnsfile = "{$sgbl->__path_mara_conf}"; $nameduser = $sgbl->__var_programuser_dns; $iplist = os_get_allips(); $iplist[] = "127.0.0.1"; $iplist = implode(",", $iplist); $fdata = "csv2 = {}\n"; $fdata .= "chroot_dir = \"/etc/maradns\"\n"; $fdata .= "ipv4_bind_addresses=\"{$iplist}\"\n"; $fdata .= "recursive_acl=\"0.0.0.0/0\"\n"; $result = merge_array_object_not_deleted($result, $this->main); if (!$this->main->isDeleted()) { foreach ((array) $this->main->__var_addonlist as $d) { $result = merge_array_object_not_deleted($result, $d); } } foreach ((array) $result as $value) { $tmp = "csv2[\"{$value['nname']}.\"] = \"{$value['nname']}\"\n"; $fdata .= $tmp; } lfile_put_contents($dnsfile, $fdata); lxfile_unix_chown($dnsfile, $nameduser); }