From dcc58152a93c46ebc065423c05896bf0fafbffc1 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Wed, 24 Mar 2010 15:02:37 +0200 Subject: First commit --- index.php | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 index.php diff --git a/index.php b/index.php new file mode 100644 index 0000000..857e001 --- /dev/null +++ b/index.php @@ -0,0 +1,230 @@ + + // @copyright (c) 2010 Filipp Lepalaan + + session_start(); + + // Set some defaults + $port = ($_SESSION['port']) ? $_SESSION['port'] : '1194'; + $name = ($_SESSION['name']) ? $_SESSION['name'] : 'example.com'; + $remote = ($_SESSION['remote']) ? $_SESSION['remote'] : 'vpn.example.com'; + + if ($_POST['reset']) { + session_destroy(); + } + + if (!empty($_POST['cert']) && !$_POST['reset']) + { + // Save some settings for later use + $_SESSION['ca'] = $_POST['ca']; + $_SESSION['port'] = $_POST['port']; + $_SESSION['name'] = $_POST['name']; + $_SESSION['remote'] = $_POST['remote']; + $_SESSION['advanced'] = $_POST['advanced']; + + $tmpdir = '/tmp/'.uniqid(); + mkdir($tmpdir); + file_put_contents("$tmpdir/ca.crt", $_POST['ca']); + file_put_contents("$tmpdir/cert.crt", $_POST['cert']); + file_put_contents("$tmpdir/key.key", $_POST['key']); + $dns_support = ($_POST['use_dns']) ? 'true' : 'false'; + + $config =<< '_', '/' => '_', ' ' => ''); + $cf = strtr($_POST['name'], $trans); + } + + file_put_contents("${tmpdir}/{$cf}.conf", $config); + + $filename = ($_POST['user'] != 'username') ? $_POST['user'] : time(); + $outfile = '/tmp/openvpn_'.$filename.'.tgz'; + + // "Pack it up, pack it in..." + `tar -czvf {$outfile} {$tmpdir}`; + + // "... let me begin" + header('Expires: 0'); + header('Pragma: public'); + header('Content-Transfer-Encoding: binary'); + header('Content-Description: File Transfer'); + header('Content-Length: '.filesize($outfile)); + header('Content-Type: application/octet-stream'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Content-Disposition: attachment; filename='.basename($outfile)); + + ob_clean(); + flush(); + readfile($outfile); + + `srm -rs $tmpdir $outfile`; + exit(); + } + +?> + + + + + + + vpn_config - Define OpenVPN Connection + + + + +
+
+
+ General + + +   + +
+ + + : + +
+ + +
+ +
+ Certificates + + +
+ + +
+ + +
+ +
+ Options + + +
+  enable LZO compression +  enable DNS support +

+ + +

+
+
+ +
+ + + -- cgit v1.2.3