当前位置: 首页>>代码示例>>PHP>>正文


PHP Bs_IniHandler::set方法代码示例

本文整理汇总了PHP中Bs_IniHandler::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Bs_IniHandler::set方法的具体用法?PHP Bs_IniHandler::set怎么用?PHP Bs_IniHandler::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bs_IniHandler的用法示例。


在下文中一共展示了Bs_IniHandler::set方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: restore

function restore($id, $target_resource, $db)
{
    $sql = "SELECT * FROM dar_index where filekey='{$id}'";
    $q = new mysql();
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    $ressource = $ligne["mount_md5"];
    $sourcefile = $ligne["filepath"];
    if ($_GET["RESTORE_DIR"]) {
        $sourcefile = dirname($sourcefile);
    }
    $ini = new Bs_IniHandler("/tmp/restore.{$id}.ini");
    $ini->set('INFO', "backup_resource", $ressource);
    $ini->set('INFO', "target_resource", $target_resource);
    $ini->set('INFO', "database", $db);
    $ini->set('INFO', "source_path", $sourcefile);
    $ini->saveFile("/tmp/restore.{$id}.ini");
    $ini = new Bs_IniHandler(dirname(__FILE__) . "/ressources/logs/exec.dar.find.restore.ini");
    $ini->set("STATUS", "progress", 15);
    $ini->set("STATUS", "text", "{Executing}...");
    $ini->saveFile(dirname(__FILE__) . "/ressources/logs/exec.dar.find.restore.ini");
    $cmd = "/usr/share/artica-postfix/bin/artica-backup --dar-restore-path /tmp/restore.{$id}.ini";
    events($cmd);
    system($cmd);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:24,代码来源:exec.dar.find.php

示例2: BuildTunServer

function BuildTunServer(){
LoadArgvs();
   $unix=new unix();
   if(isset($GLOBALS["CLASS_SOCKETS"])){$sock=$GLOBALS["CLASS_SOCKETS"];}else{$GLOBALS["CLASS_SOCKETS"]=new sockets();$sock=$GLOBALS["CLASS_SOCKETS"];}
   $servername=$unix->hostname_g();	
   $routess=array();
   $duplicate_cn=null;
 
   
  if(preg_match("#^(.+?)\.#",$servername,$re)){$servername=$re[1];}
   $servername=strtoupper($servername);       
   echo "Starting......: OpenVPN building settings for $servername...\n";
   
   
   
   $ini=new Bs_IniHandler();
   
   $ini->loadString($sock->GET_INFO("ArticaOpenVPNSettings"));
   if(!isset($ini->_params["GLOBAL"]["ENABLE_BRIDGE_MODE"])){$ini->_params["GLOBAL"]["ENABLE_BRIDGE_MODE"]=0;}
   if(!isset($ini->_params["GLOBAL"]["IP_START"])){$ini->_params["GLOBAL"]["IP_START"]="10.8.0.0";}
   if(!isset($ini->_params["GLOBAL"]["NETMASK"])){$ini->_params["GLOBAL"]["NETMASK"]="255.255.255.0";}
   
   
   if($ini->_params["GLOBAL"]["ENABLE_BRIDGE_MODE"]==1){
   		echo "Starting......: OpenVPN building settings mode bridge enabled...\n";
   		BuildBridgeServer();
   		return;
   }
   
   
   $IPTABLES_ETH=$GLOBALS["IPTABLES_ETH"];
   $DEV_TYPE=$ini->_params["GLOBAL"]["DEV_TYPE"];
   $port=$ini->_params["GLOBAL"]["LISTEN_PORT"];
   $IP_START=$ini->_params["GLOBAL"]["IP_START"];
   $NETMASK=$ini->_params["GLOBAL"]["NETMASK"];
   $bind_addr=$ini->_params["GLOBAL"]["LOCAL_BIND"];
   $LISTEN_PROTO=$ini->_params["GLOBAL"]["LISTEN_PROTO"];
   if($LISTEN_PROTO==null){$LISTEN_PROTO="udp";}
   if($LISTEN_PROTO=="udp"){$proto="--proto udp";}else{$proto="--proto tcp-server";}
   
    
   if(trim($port)==null){$port=1194;}
   if(trim($IP_START)==null){$IP_START="10.8.0.0";}
   if(trim($NETMASK)==null){$NETMASK="255.255.255.0";}
   
$nic=new networking();

while (list ($num, $ligne) = each ($nic->array_TCP) ){
	if($ligne==null){continue;}
		$eths[][$num]=$num;
		$ethi[$num]=$ligne;
	} 

if($IPTABLES_ETH<>null){
		echo "Starting......: OpenVPN linked to $IPTABLES_ETH ({$ethi[$IPTABLES_ETH]})...\n";
		$IPTABLES_ETH_ROUTE=IpCalcRoute($ethi[$IPTABLES_ETH]);
}else{
	echo "Starting......: OpenVPN no local NIC linked...\n";
}
	
   $ca='/etc/artica-postfix/openvpn/keys/allca.crt';
   $dh='/etc/artica-postfix/openvpn/keys/dh1024.pem';
   $key="/etc/artica-postfix/openvpn/keys/vpn-server.key";
   $crt="/etc/artica-postfix/openvpn/keys/vpn-server.crt";
   $route='';
   
   //$IPTABLES_ETH_IP=

if (is_file('/etc/artica-postfix/settings/Daemons/OpenVPNRoutes')){
   $routes=(explode("\n",@file_get_contents("/etc/artica-postfix/settings/Daemons/OpenVPNRoutes")));
   while (list ($num, $ligne) = each ($routes) ){
   	if(!preg_match("#(.+?)\s+(.+)#",$ligne,$re)){continue;}
   	$routess[]="--push \"route {$re[1]} {$re[2]}\"";
   }
}
$GetRoutes=GetRoutes();
$routess=$routess+$GetRoutes;



if(count($routess)==0){
	if($IPTABLES_ETH_ROUTE<>null){
		echo "Starting......: OpenVPN IP adding default route \"$IPTABLES_ETH_ROUTE\"\n";
		$routess[]="--push \"route $IPTABLES_ETH_ROUTE\"";
	}
  }else{
  	echo "Starting......: OpenVPN IP adding ".count($routess)." routes\n";
  }
   

	
   if(trim($bind_addr)<>null){
   	$local=" --local $bind_addr";
   	echo "Starting......: OpenVPN IP bind $bind_addr\n";
   }
   
   $IP_START=FIX_IP_START($IP_START,$local);
   $ini->set("GLOBAL","IP_START",$IP_START); 	
  
   if(preg_match("#(.+?)\.([0-9]+)$#",$IP_START,$re)){
//.........这里部分代码省略.........
开发者ID:rsd,项目名称:artica-1.5,代码行数:101,代码来源:exec.openvpn.php

示例3: parsequeue

function parsequeue()
{
    $unix = new unix();
    $iptables = $unix->find_program("iptables");
    $q = new mysql();
    $q->Check_iptables_table();
    $ini = new Bs_IniHandler();
    $ini->loadFile('/etc/artica-postfix/settings/Daemons/PostfixAutoBlockResults');
    if ($GLOBALS["VERBOSE"]) {
        echo "Scanning /var/log/artica-postfix/smtp-hack\n";
    }
    foreach (glob("/var/log/artica-postfix/smtp-hack/*.hack") as $filename) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Scanning {$filename}\n";
        }
        $basename = basename($filename);
        $array = unserialize(@file_get_contents($filename));
        $IP = $array["IP"];
        if ($IP == "127.0.0.1") {
            @unlink($filename);
            continue;
        }
        $server_name = gethostbyaddr($IP);
        $matches = $array["MATCHES"];
        $EVENTS = $array["EVENTS"];
        $date = $array["DATE"];
        if ($GLOBALS["VERBOSE"]) {
            echo "{$basename}: servername:{$server_name} IP=[{$IP}]\n";
        }
        $cmd = "{$iptables} -A INPUT -s {$IP} -p tcp --destination-port 25 -j DROP -m comment --comment \"ArticaInstantPostfix\"";
        $iptablesClass = new iptables_chains();
        $iptablesClass->serverip = $IP;
        $iptablesClass->servername = $server_name;
        $iptablesClass->rule_string = $cmd;
        $iptablesClass->EventsToAdd = $EVENTS;
        if ($iptablesClass->addPostfix_chain()) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Add IP:Addr=<{$IP}>, servername=<{$server_name}> to mysql\n";
            }
            $ini->set($IP, "events", $matches);
            $ini->set($IP, "iptablerule", $cmd);
            $ini->set($IP, "hostname", $server_name);
            if ($GLOBALS["VERBOSE"]) {
                echo "delete {$filename}\n";
            }
            @unlink($filename);
        }
        $cmd = "{$iptables} -A INPUT -s {$IP} -p tcp --destination-port 587 -j DROP -m comment --comment \"ArticaInstantPostfix\"";
        $iptablesClass = new iptables_chains(587);
        $iptablesClass->serverip = $IP;
        $iptablesClass->servername = $server_name;
        $iptablesClass->rule_string = $cmd;
        $iptablesClass->EventsToAdd = $EVENTS;
        $iptablesClass->addPostfix_chain();
        $cmd = "{$iptables} -A INPUT -s {$IP} -p tcp --destination-port 465 -j DROP -m comment --comment \"ArticaInstantPostfix\"";
        $iptablesClass = new iptables_chains();
        $iptablesClass->serverip = $IP;
        $iptablesClass->servername = $server_name;
        $iptablesClass->rule_string = $cmd;
        $iptablesClass->EventsToAdd = $EVENTS;
        $iptablesClass->addPostfix_chain(465);
    }
    $filestr = $ini->toString();
    file_put_contents("/etc/artica-postfix/settings/Daemons/PostfixAutoBlockResults", $filestr);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:65,代码来源:exec.postfix.iptables.php

示例4: ASSP_QUAR

        }
    } else {
        events("processing {$quarantine_dir}/{$file} failed");
    }
    $count = $count + 1;
    $ini = new Bs_IniHandler();
    $ini->set("PROGRESS", "current", $count);
    $ini->set("PROGRESS", "total", $max);
    $ini->set("PROGRESS", "pid", $pid);
    $ini->set("PROGRESS", "quarantine", "(spam)/virus *.gz,virus-");
    $ini->saveFile("/usr/share/artica-postfix/ressources/logs/mailarchive-quarantine-progress.ini");
    chmod("/usr/share/artica-postfix/ressources/logs/mailarchive-quarantine-progress.ini", 0755);
    //if($count>50){break;}
}
$ini = new Bs_IniHandler();
$ini->set("PROGRESS", "pid", "0");
$date = date('H:i:s');
$ini->set("PROGRESS", "quarantine", "Finish {$date1} -> {$date}, next in 5mn");
$ini->saveFile("/usr/share/artica-postfix/ressources/logs/mailarchive-quarantine-progress.ini");
system('/bin/rm /var/virusmails/*.eml >/dev/null 2>&1');
ASSP_QUAR("/usr/share/assp/spam");
ASSP_QUAR("/usr/share/assp/discarded");
ASSP_QUAR("/usr/share/assp/quarantine");
ASSP_QUAR("/usr/share/assp/errors/notspam");
ASSP_QUAR("/usr/share/assp/errors/spam");
ASSP_QUAR("/var/spam-mails");
die;
function ASSP_QUAR($baseDir)
{
    //""
    if (!is_dir($baseDir)) {
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:31,代码来源:exec.mailarchive.php

示例5: network_scanner_execute

function network_scanner_execute()
{
    $tpl = new templates();
    $net = new networkscanner();
    $net->save();
    $sock = new sockets();
    $sock->getFrameWork("cmd.php?LaunchNetworkScanner=yes");
    $box = $tpl->javascript_parse_text('{network_scanner_execute_background}', 1);
    $ini = new Bs_IniHandler('ressources/logs/nmap.progress.ini');
    $ini->set('NMAP', 'pourc', '10');
    $ini->set('NMAP', 'text', '{scheduled}');
    $ini->saveFile('ressources/logs/nmap.progress.ini');
    echo $box;
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:14,代码来源:computer-browse.php

示例6: WriteCOmputerBrowseProgress

function WriteCOmputerBrowseProgress($pourc,$text){
	$ini=new Bs_IniHandler();
	$ini->set('NMAP','pourc',$pourc);
	$ini->set('NMAP','text',$text);
	$ini->saveFile('/usr/share/artica-postfix/ressources/logs/nmap.progress.ini');
	@chmod("/usr/share/artica-postfix/ressources/logs/nmap.progress.ini",0755);
}
开发者ID:rsd,项目名称:artica-1.5,代码行数:7,代码来源:exec.computer.scan.php

示例7: point_events

function point_events($postfix_id=null,$smtp_sender=null,$from=null,$to=null,$error=null,$mailsize=0){
	if($postfix_id==null){
		if($GLOBALS["DebugArticaFilter"]==1){events("postfix_id is null",__FUNCTION__,__LINE__);}
		return;
	}
	@mkdir("/var/log/artica-postfix/RTM",null,true);
	$file="/var/log/artica-postfix/RTM/$postfix_id.msg";
	if($GLOBALS["DebugArticaFilter"]==1){events("Loading monitor file $file",__FUNCTION__,__LINE__);}
	$ini=new Bs_IniHandler($file);
	
	if($GLOBALS["DebugArticaFilter"]==1){events("populate monitor file $file",__FUNCTION__,__LINE__);}
	if($smtp_sender<>null){$ini->set("TIME","smtp_sender",$smtp_sender);}
	
	if($from<>null){$ini->set("TIME","mailfrom",$from);}
	$ini->set("TIME","mailto","$to");
	
	$ini->set("TIME","time_end",date("Y-m-d H:i:s"));
	$ini->set("TIME","message-id",$postfix_id);
	$ini->set("TIME","mailsize",$mailsize);
	
	
	if($error==null){
		$ini->set("TIME","bounce_error","Success");
		$ini->set("TIME","delivery_success","yes");
	}else{
		$ini->set("TIME","bounce_error","$error");
		$ini->set("TIME","delivery_success","no");
	}
	if($GLOBALS["DebugArticaFilter"]==1){events("save monitor file $file",__FUNCTION__,__LINE__);}
	$ini->saveFile($file);	
	
	
}
开发者ID:rsd,项目名称:artica-1.5,代码行数:33,代码来源:exec.artica-filter-daemon.php

示例8: cyrus_cluster_receive

function cyrus_cluster_receive()
{
    $array = unserialize(base64_decode($_POST["cyrus-cluster"]));
    $users = new usersMenus();
    $sock = new sockets();
    $fqdn = $users->fqdn;
    if ($fqdn == null) {
        $fqdn = $users->hostname;
    }
    $_GET["admin"] = $array["admin"];
    $_GET["pass"] = $array["pass"];
    if (!islogged(1, 1)) {
        writelogs("Bad username and password", __FUNCTION__, __FILE__, __LINE__);
        $return["RESULT"] = "{$fqdn}: {$array["admin"]}: {username}/{password} {failed}";
        $return["REPLY"] = false;
        echo base64_encode(serialize($return));
        return;
    }
    writelogs("Username and password OK", __FUNCTION__, __FILE__, __LINE__);
    $users = new usersMenus();
    if (!$users->cyrus_sync_installed) {
        $return["RESULT"] = "{$fqdn}: {sync_tools_not_compiled}";
        $return["REPLY"] = false;
        echo base64_encode(serialize($return));
        return;
    }
    if ($sock->GET_INFO("CyrusEnableImapMurderedFrontEnd") == 1) {
        $return["RESULT"] = "{$fqdn}: {already_a_murder_frontend}";
        $return["REPLY"] = false;
        echo base64_encode(serialize($return));
        return;
    }
    if (!function_exists("curl_init")) {
        $return["RESULT"] = "{$fqdn}:{error_php_curl}";
        $return["REPLY"] = false;
        echo base64_encode(serialize($return));
        return;
    }
    writelogs("Success pass tests...", __FUNCTION__, __FILE__, __LINE__);
    if ($array["cmd"] == "tests") {
        $return["RESULT"] = "{$fqdn}: {success}";
        $return["REPLY"] = true;
        echo base64_encode(serialize($return));
        return;
    }
    if ($array["cmd"] == "connect") {
        writelogs("Try to be a replica {$array["master_ip"]}:{$array["master_artica_port"]}", __FUNCTION__, __FILE__, __LINE__);
        $cyrus_cluster = new cyrus_cluster();
        if (!$cyrus_cluster->test_remote_server($array["master_ip"], $array["master_artica_port"], $array["ldap_admin"], $array["ldap_password"])) {
            writelogs("Unable to call master server {$array["master_ip"]}:{$cyrus_cluster->error_text}", __FUNCTION__, __FILE__, __LINE__);
            $return["RESULT"] = $cyrus_cluster->error_text;
            $return["REPLY"] = false;
            echo base64_encode(serialize($return));
            return;
        }
        writelogs("Call master server {$array["master_ip"]}: success", __FUNCTION__, __FILE__, __LINE__);
        $ini = new Bs_IniHandler();
        $ini->set("REPLICA", "servername", $array["master_ip"]);
        $ini->set("REPLICA", "username", $array["ldap_admin"]);
        $ini->set("REPLICA", "password", $array["ldap_password"]);
        $ini->set("REPLICA", "artica_port", $array["master_artica_port"]);
        $ini->set("REPLICA", "suffix", $array["suffix"]);
        $sock->SaveConfigFile($ini->toString(), "CyrusReplicaLDAPConfig");
        $sock->SET_INFO("EnableCyrusReplicaCluster", 1);
        $sock->SET_INFO("EnableCyrusMasterCluster", 0);
        $sock->SET_INFO("CyrusReplicaClusterPort", $array["master_cyrus_port"]);
        $sock->SET_INFO("CyrusReplicaClusterServer", $array["master_ip"]);
        $sock->getFrameWork('cmd.php?cyrus-reconfigure=yes&force=yes');
        writelogs("Success Enable replica", __FUNCTION__, __FILE__, __LINE__);
        $return["RESULT"] = "{success}";
        $return["REPLY"] = true;
        echo base64_encode(serialize($return));
        writelogs("Success to be a replica", __FUNCTION__, __FILE__, __LINE__);
        $sock->getFrameWork('cmd.php?cyrus-reconfigure=yes&force=yes');
        return;
    }
    if ($array["cmd"] == "disconnect") {
        writelogs("Try to disable replica", __FUNCTION__, __FILE__, __LINE__);
        $sock->SET_INFO("EnableCyrusReplicaCluster", 0);
        writelogs("Success disable replica", __FUNCTION__, __FILE__, __LINE__);
        $sock->getFrameWork('cmd.php?cyrus-reconfigure=yes&force=yes');
    }
    if ($array["cmd"] == "isReplica") {
        if ($sock->GET_INFO("EnableCyrusReplicaCluster") == 1) {
            $return["RESULT"] = "{success}";
            $return["REPLY"] = true;
        } else {
            $return["RESULT"] = "{failed}: not a replica";
            $return["REPLY"] = false;
        }
        echo base64_encode(serialize($return));
    }
}
开发者ID:brucewu16899,项目名称:artica,代码行数:93,代码来源:cyrus.murder.listener.php

示例9: readlsfile

function readlsfile($path)
{
    if (!preg_match('#-md-(.+?)\\.ls#', $path, $re)) {
        events("Unable to determine source from this file " . basename($path));
        return true;
    } else {
        $external_source = $re[1];
    }
    $file_name = basename($path);
    $filename = $path;
    $filesize = @filesize($filename);
    events("Request for analyze file {$path} size {$filesize} bytes");
    if ($filesize == 0) {
        events("Obytes -> Abort but return true;");
        return true;
    }
    if (preg_match('#(.+?)-md-.+?\\.[a-z0-9]+$#', $path, $re)) {
        $database_path = $re[1];
    }
    $database_name = basename($database_path);
    if (preg_match('#(.+?)\\-.+?\\-diff#', $database_name, $re)) {
        $database_name = $re[1];
    }
    if ($filesize > 400) {
        DeleteDatabase($database_name);
    }
    $source_path = GetSources($database_path);
    if ($source_path == null) {
        $source_path = GetSources($database_name);
    }
    $external_source_pattern = $_GET["STORAGES"][$external_source];
    if ($external_source == null) {
        events("Unable to find source for {$external_source} !!");
        return false;
    }
    events("*********************************************************************");
    events("Analyzing cache from {$filename}...");
    events("MD5 source....: {$external_source}");
    events("Pattern source: {$external_source_pattern}");
    events("database name.: {$database_name}");
    events("database Path.: {$database_path}");
    events("Source Path...: {$source_path}");
    events("*********************************************************************");
    $content = file_get_contents($filename);
    $md5 = md5($content);
    $ini = new Bs_IniHandler("/etc/artica-postfix/dar.cache.ini");
    if ($ini->_params["{$database_name}"]["md5"] == $md5) {
        events("Analyzing {$database_name} cache:{$md5} already set");
        return true;
    }
    $ini->set($database_name, "md5", $md5);
    $ini->saveFile("/etc/artica-postfix/dar.cache.ini");
    $filesize = @filesize($filename);
    $filesize = round($filesize / 1024, 2) . " Ko";
    events("Analyzing " . basename($filename) . " ({$filesize}) for database: {$database_name} cache:{$md5}");
    if ($fd = @fopen($filename, "r")) {
        while ($fd && !feof($fd)) {
            $line = trim(fgets($fd, 4096));
            if (preg_match("#^\\[.+?\\]\\s+\\[.*?\\]\\s+[a-z\\-]+\\s+[a-zA-Z0-9\\-\\_\\.]+\\s+[a-zA-Z0-9\\-\\_\\.]+\\s+([0-9]+)\\s+([a-zA-Z0-9\\s\\:]+)\\s+(.+)#", $line, $re)) {
                if (!Insert($re[3], $re[1], $re[2], $source_path, $database_name, $external_source_pattern)) {
                    events("Failed line \"{$line}\" aborting process");
                    return false;
                }
            } else {
                events("Failed line {$num} \"{$line}\" -> continue reading file...");
            }
        }
        fclose($fd);
        events("{$_GET["COUNT"][$database_name]} files added...");
        events("Optimize table...");
        $sql = "OPTIMIZE TABLE `dar_index`";
        $q = new mysql();
        $q->QUERY_SQL($sql, "artica_backup");
        return true;
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:76,代码来源:exec.parse.dar-xml.php

示例10: BuildTunServer

function BuildTunServer()
{
    $unix = new unix();
    $sock = new sockets();
    $servername = $unix->hostname_g();
    if (preg_match("#^(.+?)\\.#", $servername, $re)) {
        $servername = $re[1];
    }
    $servername = strtoupper($servername);
    echo "Starting......: OpenVPN building settings for {$servername}...\n";
    $ini = new Bs_IniHandler();
    $sock = new sockets();
    $ini->loadString($sock->GET_INFO("ArticaOpenVPNSettings"));
    if ($ini->_params["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        echo "Starting......: OpenVPN building settings mode bridge enabled...\n";
        BuildBridgeServer();
        return;
    }
    $IPTABLES_ETH = $GLOBALS["IPTABLES_ETH"];
    $DEV_TYPE = $ini->_params["GLOBAL"]["DEV_TYPE"];
    $port = $ini->_params["GLOBAL"]["LISTEN_PORT"];
    $IP_START = $ini->_params["GLOBAL"]["IP_START"];
    $NETMASK = $ini->_params["GLOBAL"]["NETMASK"];
    $bind_addr = $ini->_params["GLOBAL"]["LOCAL_BIND"];
    if (trim($port) == null) {
        $port = 1194;
    }
    if (trim($IP_START) == null) {
        $IP_START = "10.8.0.0";
    }
    if (trim($NETMASK) == null) {
        $IP_START = "255.255.255.0";
    }
    $nic = new networking();
    while (list($num, $ligne) = each($nic->array_TCP)) {
        if ($ligne == null) {
            continue;
        }
        $eths[][$num] = $num;
        $ethi[$num] = $ligne;
    }
    if ($IPTABLES_ETH != null) {
        echo "Starting......: OpenVPN linked to {$IPTABLES_ETH} ({$ethi[$IPTABLES_ETH]})...\n";
        $IPTABLES_ETH_ROUTE = IpCalcRoute($ethi[$IPTABLES_ETH]);
    } else {
        echo "Starting......: OpenVPN no local NIC linked...\n";
    }
    $ca = '/etc/artica-postfix/openvpn/keys/allca.crt';
    $dh = '/etc/artica-postfix/openvpn/keys/dh1024.pem';
    $key = "/etc/artica-postfix/openvpn/keys/vpn-server.key";
    $crt = "/etc/artica-postfix/openvpn/keys/vpn-server.crt";
    $route = '';
    //$IPTABLES_ETH_IP=
    if (is_file('/etc/artica-postfix/settings/Daemons/OpenVPNRoutes')) {
        $routes = explode("\n", @file_get_contents("/etc/artica-postfix/settings/Daemons/OpenVPNRoutes"));
        while (list($num, $ligne) = each($routes)) {
            if (!preg_match("#(.+?)\\s+(.+)#", $ligne, $re)) {
                continue;
            }
            $routess[] = "--push \"route {$re[1]} {$re[2]}\"";
        }
    }
    $routess[] = GetRoutes();
    if (count($routess) == 0) {
        if ($IPTABLES_ETH_ROUTE != null) {
            echo "Starting......: OpenVPN IP adding default route \"{$IPTABLES_ETH_ROUTE}\"\n";
            $routess[] = "--push \"route {$IPTABLES_ETH_ROUTE}\"";
        }
    } else {
        echo "Starting......: OpenVPN IP adding " . count($routess) . " routes\n";
    }
    if (trim($bind_addr) != null) {
        $local = " --local {$bind_addr}";
        echo "Starting......: OpenVPN IP bind {$bind_addr}\n";
    }
    $IP_START = FIX_IP_START($IP_START, $local);
    $ini->set("GLOBAL", "IP_START", $IP_START);
    if (preg_match("#(.+?)\\.([0-9]+)\$#", $IP_START, $re)) {
        $calc_ip = " {$re[1]}.0";
        $calc_ip_end = "{$re[1]}.254";
        echo "Starting......: OpenVPN IP pool from {$re[1]}.2 to {$re[1]}.254 mask:{$NETMASK}\n";
        $server_ip = "{$re[1]}.1";
    }
    if ($NETMASK == null) {
        $ip = new IP();
        $cdir = $ip->ip2cidr($calc_ip, $calc_ip_end);
        $arr = $ip->parseCIDR($cdir);
        $rang = $arr[0];
        $netbit = $arr[1];
        $ipv = new ipv4($calc_ip, $netbit);
        $NETMASK = $ipv->netmask();
        if ($NETMASK == "255.255.255.255") {
            $NETMASK = "255.255.255.0";
        }
        echo "Starting......: OpenVPN Netmask is null for the range {$calc_ip}, assume {$NETMASK}\n";
        $ini->set("GLOBAL", "NETMASK", $NETMASK);
    }
    $OpenVpnPasswordCert = $sock->GET_INFO("OpenVpnPasswordCert");
    if ($OpenVpnPasswordCert == null) {
        $OpenVpnPasswordCert = "MyKey";
//.........这里部分代码省略.........
开发者ID:brucewu16899,项目名称:artica,代码行数:101,代码来源:exec.openvpn.php


注:本文中的Bs_IniHandler::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。