Ejemplo n.º 1
0
                break;
            default:
                $exp_name = urlencode($exp_name."-config.ovpn");
                $expformat = "baseconf";
        }
        $exp_path = openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $verifyservercn, $randomlocalport, $usetoken, $nokeys, $proxy, $expformat, $password, false, false, $openvpnmanager, $advancedoptions);
    }

    if ($act == "visc") {
        $exp_name = urlencode($exp_name."-Viscosity.visc.zip");
        $exp_path = viscosity_openvpn_client_config_exporter($srvid, $usrid, $crtid, $useaddr, $verifyservercn, $randomlocalport, $usetoken, $password, $proxy, $openvpnmanager, $advancedoptions);
    }

    if (substr($act, 0, 4) == "inst") {
        $exp_name = urlencode($exp_name."-install.exe");
        $exp_path = openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $verifyservercn, $randomlocalport, $usetoken, $password, $proxy, $openvpnmanager, $advancedoptions, substr($act, 5));
    }

    if (!$exp_path) {
        $input_errors[] = "Failed to export config files!";
    }

    if (empty($input_errors)) {
        if (($act == "conf") || (substr($act, 0, 10) == "confinline")) {
            $exp_size = strlen($exp_path);
        } else {
            $exp_size = filesize($exp_path);
        }
        header('Pragma: ');
        header('Cache-Control: ');
        header("Content-Type: application/octet-stream");
			if (empty($_GET['proxy_user'])) {
				$error = true;
				$input_errors[] = "You need to specify a username with the proxy config.";
			} else
				$proxy['user'] = $_GET['proxy_user'];
			if (!empty($_GET['proxy_user']) && empty($_GET['proxy_password'])) {
				$error = true;
				$input_errors[] = "You need to specify a password with the proxy user.";
			} else
				$proxy['password'] = $_GET['proxy_password'];
		}
	}

	$exp_name = openvpn_client_export_prefix($srvid);
	$exp_name = urlencode($exp_name."-install.exe");
	$exp_path = openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $usetoken, $password, $proxy, $advancedoptions);
	if (!$exp_path) {
		$input_errors[] = "Failed to export config files!";
		$error = true;
	}
	if (!$error) {
		$exp_size = filesize($exp_path);

		header('Pragma: ');
		header('Cache-Control: ');
		header("Content-Type: application/octet-stream");
		header("Content-Disposition: attachment; filename={$exp_name}");
		header("Content-Length: $exp_size");
		readfile($exp_path);
		unlink($exp_path);
		exit;