VPN-Management-GUI 2.0.3 porting start
This commit is contained in:
66
Admin/Modules/VPNconfig/config.inc
Executable file
66
Admin/Modules/VPNconfig/config.inc
Executable file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
//include($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
|
||||
|
||||
// Change: your company name
|
||||
$config['Company_Name'] = 'SchulVPN';
|
||||
// Change: your company home page
|
||||
$config['URL_Home_Page'] = 'http://10.10.63.60/index.php';
|
||||
$config['AUTH_REALM'] = $config['Company_Name'] .' OpenVPN Web GUI v.0.3.2';
|
||||
// What files to include into ZIP
|
||||
$config['Download']['ZIP']['.pem'] = true;
|
||||
$config['Download']['ZIP']['.key'] = true;
|
||||
$config['Download']['ZIP']['.csr'] = false;
|
||||
// All the following files should be placed into downloads folder
|
||||
$config['Download']['ZIP']['Others'] = array ('readme.txt','ca.crt', 'schulvpn.ovpn', 'certinstall.sh');
|
||||
//$config['Download']['ZIP']['Others'] = array ('readme.txt', 'install.cmd', 'tls-auth.key');
|
||||
|
||||
// Use the real absolute path here.
|
||||
$config['PluginsAbsolutePath'] = $_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNConfig/plugins/";
|
||||
|
||||
// If there are no plugins
|
||||
//$config['Plugins'] = NULL;
|
||||
// Otherwise, follow this example:
|
||||
//$config['Plugins']['PLUGINMANE']['Folder'] = 'FOLDERNAME';
|
||||
|
||||
// The post-install helper plugin. Shows if PHP5 has the neccessary functions available
|
||||
$config['Plugins']['systemcheck']['Folder'] = 'systemcheck';
|
||||
|
||||
// OPENVPN ________________________________
|
||||
|
||||
// Change: the configuration directory
|
||||
$config['openvpn']['folder'] = db_getconfval("ovpnconfdir")."/";
|
||||
// Change: configuration and status file names
|
||||
$config['openvpn']['config'] = $config['openvpn']['folder'].db_getconfval("ovpnconffile");
|
||||
$config['openvpn']['status'] = $config['openvpn']['folder']."openvpn-status.log";
|
||||
|
||||
// OPENSSL ________________________________
|
||||
|
||||
// Change: openssl keys directory
|
||||
$config['openssl']['folder'] = db_getconfval("ovpnkeydir")."/keys/";
|
||||
// Change: different folders for Public Certificates, Certificate Requests and Private Keys.
|
||||
// NOTE: openssl somehow respects only newpem folder (for Public Certificates).
|
||||
$config['openssl']['pubfolder'] = $config['openssl']['folder'];
|
||||
$config['openssl']['reqfolder'] = $config['openssl']['folder'];
|
||||
$config['openssl']['prvfolder'] = $config['openssl']['folder'];
|
||||
// Change: openssl CA private and public keys
|
||||
$config['openssl']['CA']['priv'] = $config['openssl']['folder'] .'ca.key';
|
||||
$config['openssl']['CA']['pub'] = $config['openssl']['folder'] .'ca.crt';
|
||||
// Change: openssl serial file
|
||||
$config['openssl']['serial'] = $config['openssl']['folder'] .'serial';
|
||||
// Change: openssl database
|
||||
$config['openssl']['database'] = $config['openssl']['folder'] .'index.txt';
|
||||
// Change: openssl configuration
|
||||
$config['openssl']['config'] = $config['openvpn']['folder'] .'openssl.cnf';
|
||||
// NEW OPENSSL CERTIFICATE DEFAULTS _________
|
||||
|
||||
// Change all of them as it is done in your easy-rsa/vars
|
||||
$config['openssl']['default']['expiration'] = 3560;
|
||||
$config['openssl']['default']['countryName'] = 'AT';
|
||||
$config['openssl']['default']['stateOrProvinceName'] = 'Tirol';
|
||||
$config['openssl']['default']['localityName'] = 'Innsbruck';
|
||||
$config['openssl']['default']['organizationName'] = 'HTL';
|
||||
$config['openssl']['default']['organizationalUnitName'] = '';
|
||||
$config['openssl']['default']['commonName'] = '';
|
||||
$config['openssl']['default']['emailAddress'] = 'vpn@students.htlinn.ac.at';
|
||||
|
||||
?>
|
86
Admin/Modules/VPNconfig/include/certs (Kopie).php
Normal file
86
Admin/Modules/VPNconfig/include/certs (Kopie).php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openvpn-functions.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openssl-functions.inc");
|
||||
openvpn_load_server_conf ();
|
||||
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
|
||||
openvpn_load_status ();
|
||||
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
|
||||
openssl_load_database ();
|
||||
openvpn_find_connected ();
|
||||
|
||||
$openvpn["Certificates"] = $openssl["Database"];
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<table border="0" width="100%" cellspacing="0" cellpadding="4">
|
||||
|
||||
<tr valign="top">
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray" bgcolor="#DDFFCC"><b>#</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray" width="1%"> </td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Common Name</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Department</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>e-mail</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Serial</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Status</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray" bgcolor="#DDFFCC" width="5%"><b>Download</b></td>
|
||||
</tr>
|
||||
|
||||
<?php unset($openvpn['i']);
|
||||
$openvpn['i']['name'] = 'i';
|
||||
$openvpn['i']['loop'] = is_array($_loop=$openvpn['Certificates']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
|
||||
$openvpn['i']['show'] = true;
|
||||
$openvpn['i']['max'] = $openvpn['i']['loop'];
|
||||
$openvpn['i']['step'] = 1;
|
||||
$openvpn['i']['start'] = $openvpn['i']['step'] > 0 ? 0 : $openvpn['i']['loop']-1;
|
||||
if ($openvpn['i']['show']) {
|
||||
$openvpn['i']['total'] = $openvpn['i']['loop'];
|
||||
if ($openvpn['i']['total'] == 0)
|
||||
$openvpn['i']['show'] = false;
|
||||
} else
|
||||
$openvpn['i']['total'] = 0;
|
||||
if ($openvpn['i']['show']):
|
||||
|
||||
for ($openvpn['i']['index'] = $openvpn['i']['start'], $openvpn['i']['iteration'] = 1;
|
||||
$openvpn['i']['iteration'] <= $openvpn['i']['total'];
|
||||
$openvpn['i']['index'] += $openvpn['i']['step'], $openvpn['i']['iteration']++):
|
||||
$openvpn['i']['rownum'] = $openvpn['i']['iteration'];
|
||||
$openvpn['i']['index_prev'] = $openvpn['i']['index'] - $openvpn['i']['step'];
|
||||
$openvpn['i']['index_next'] = $openvpn['i']['index'] + $openvpn['i']['step'];
|
||||
$openvpn['i']['first'] = ($openvpn['i']['iteration'] == 1);
|
||||
$openvpn['i']['last'] = ($openvpn['i']['iteration'] == $openvpn['i']['total']);
|
||||
?>
|
||||
|
||||
|
||||
<tr valign="top"<?php echo ''; ?><?php if ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'R'): ?><?php echo ' bgcolor="#FFDFDF"'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'E'): ?><?php echo ' bgcolor="#DFDFDF"'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Connected']): ?><?php echo ' bgcolor="#DFDFFF"'; ?><?php endif; ?><?php echo ''; ?>
|
||||
>
|
||||
<td style="border-bottom:1px groove gray" nowrap width="1%" rowspan="1" align="right" bgcolor="#DDFFCC"><?php echo $openvpn['i']['iteration']; ?>
|
||||
</td>
|
||||
<?php echo '<td style="border-bottom:1px groove gray">'; ?><?php if ($openvpn['Certificates'][$openvpn['i']['index']]['Connected']): ?><?php echo '<a title="connected"><font color="black"><b>#</b></font></a>'; ?><?php else: ?><?php echo ' '; ?><?php endif; ?><?php echo '</td>'; ?>
|
||||
|
||||
<?php echo '<td style="border-bottom:1px groove gray"><a href="'; ?><?php echo $moduleurl; ?><?php echo '&uebergabe=5&uebergabe2='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '" title=\'View this certificate\'>'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['CN']; ?><?php echo '</td>'; ?>
|
||||
|
||||
<?php echo '<td style="border-bottom:1px groove gray">'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Department']; ?><?php echo '</td>'; ?>
|
||||
|
||||
<?php echo '<td style="border-bottom:1px groove gray">'; ?><?php if ($openvpn['Certificates'][$openvpn['i']['index']]['Email'] != ''): ?><?php echo '<a href="mailto:'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Email']; ?><?php echo '">'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Email']; ?><?php echo '</a>'; ?><?php else: ?><?php echo ' '; ?><?php endif; ?><?php echo '</td>'; ?>
|
||||
|
||||
<?php echo '<td style="border-bottom:1px groove gray" nowrap width="1%" align="right">'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '</td>'; ?>
|
||||
|
||||
<?php echo '<td style="border-bottom:1px groove gray" nowrap width="1%" align="right">'; ?><?php if ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'V'): ?><?php echo 'Valid'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'R'): ?><?php echo 'Revoked'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'E'): ?><?php echo 'Expired'; ?><?php else: ?><?php echo ''; ?><?php endif; ?><?php echo '</td>'; ?>
|
||||
|
||||
<?php echo '<td style="border-bottom:1px groove gray" bgcolor="#DDFFCC" nowrap="nowrap">[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=ZIP" title=\'Download All files in one archive\'>zip</a>]'; ?>
|
||||
<?php echo '[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=CRT" title=\'Download Public Certificate\'>crt</a>]'; ?>
|
||||
<?php echo '[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=KEY" title=\'Download Private Key\'>key</a>]'; ?>
|
||||
<?php echo '[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=CSR" title=\'Download Certificate Request\'>csr</a>]</td>'; ?>
|
||||
|
||||
<?php echo '</tr>'; ?>
|
||||
|
||||
<?php endfor; else: ?>
|
||||
|
||||
<tr><td colspan="2" align="center"><i>There are no certificates made at the minute</i></td></tr>
|
||||
<?php endif; ?>
|
||||
|
||||
</table>
|
98
Admin/Modules/VPNconfig/include/certs.php
Normal file
98
Admin/Modules/VPNconfig/include/certs.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openvpn-functions.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openssl-functions.inc");
|
||||
openvpn_load_server_conf ();
|
||||
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
|
||||
openvpn_load_status ();
|
||||
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
|
||||
openssl_load_database ();
|
||||
openvpn_find_connected ();
|
||||
|
||||
$openvpn["Certificates"] = $openssl["Database"];
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<table border="0" width="100%" cellspacing="0" cellpadding="4">
|
||||
|
||||
<tr valign="top">
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray" bgcolor="#DDFFCC"><b>#</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray" width="1%"> </td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Common Name</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Department</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>e-mail</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Serial</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Status</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray" bgcolor="#DDFFCC" width="5%"><b>Download</b></td>
|
||||
</tr>
|
||||
|
||||
<?php unset($openvpn['i']);
|
||||
$openvpn['i']['name'] = 'i';
|
||||
$openvpn['i']['loop'] = is_array($_loop=$openvpn['Certificates']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
|
||||
$openvpn['i']['show'] = true;
|
||||
$openvpn['i']['max'] = $openvpn['i']['loop'];
|
||||
$openvpn['i']['step'] = 1;
|
||||
$openvpn['i']['start'] = $openvpn['i']['step'] > 0 ? 0 : $openvpn['i']['loop']-1;
|
||||
if ($openvpn['i']['show']) {
|
||||
$openvpn['i']['total'] = $openvpn['i']['loop'];
|
||||
if ($openvpn['i']['total'] == 0)
|
||||
$openvpn['i']['show'] = false;
|
||||
} else
|
||||
$openvpn['i']['total'] = 0;
|
||||
if ($openvpn['i']['show']):
|
||||
|
||||
for ($openvpn['i']['index'] = $openvpn['i']['start'], $openvpn['i']['iteration'] = 1;
|
||||
$openvpn['i']['iteration'] <= $openvpn['i']['total'];
|
||||
$openvpn['i']['index'] += $openvpn['i']['step'], $openvpn['i']['iteration']++):
|
||||
$openvpn['i']['rownum'] = $openvpn['i']['iteration'];
|
||||
$openvpn['i']['index_prev'] = $openvpn['i']['index'] - $openvpn['i']['step'];
|
||||
$openvpn['i']['index_next'] = $openvpn['i']['index'] + $openvpn['i']['step'];
|
||||
$openvpn['i']['first'] = ($openvpn['i']['iteration'] == 1);
|
||||
$openvpn['i']['last'] = ($openvpn['i']['iteration'] == $openvpn['i']['total']);
|
||||
?>
|
||||
|
||||
|
||||
<tr valign="top"<?php echo ''; ?><?php if ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'R'): ?><?php echo ' bgcolor="#FFDFDF"'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'E'): ?><?php echo ' bgcolor="#DFDFDF"'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Connected']): ?><?php echo ' bgcolor="#DFDFFF"'; ?><?php endif; ?><?php echo ''; ?>
|
||||
>
|
||||
<td style="border-bottom:1px groove gray" nowrap width="1%" rowspan="1" align="right" bgcolor="#DDFFCC"><?php echo $openvpn['i']['iteration']; ?>
|
||||
</td>
|
||||
<?php
|
||||
echo '<td style="border-bottom:1px groove gray">';
|
||||
|
||||
if ($openvpn['Certificates'][$openvpn['i']['index']]['Connected'] && $openvpn['Certificates'][$openvpn['i']['index']]['Status'] != 'R')
|
||||
{
|
||||
echo '<a title="connected"><font color="black"><b>#</b></font></a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo ' ';
|
||||
}
|
||||
|
||||
echo '</td>'; ?>
|
||||
|
||||
<?php echo '<td style="border-bottom:1px groove gray"><a href="'; ?><?php echo $moduleurl; ?><?php echo '&uebergabe=5&uebergabe2='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '" title=\'View this certificate\'>'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['CN']; ?><?php echo '</td>'; ?>
|
||||
|
||||
<?php echo '<td style="border-bottom:1px groove gray">'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Department']; ?><?php echo '</td>'; ?>
|
||||
|
||||
<?php echo '<td style="border-bottom:1px groove gray">'; ?><?php if ($openvpn['Certificates'][$openvpn['i']['index']]['Email'] != ''): ?><?php echo '<a href="mailto:'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Email']; ?><?php echo '">'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Email']; ?><?php echo '</a>'; ?><?php else: ?><?php echo ' '; ?><?php endif; ?><?php echo '</td>'; ?>
|
||||
|
||||
<?php echo '<td style="border-bottom:1px groove gray" nowrap width="1%" align="right">'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '</td>'; ?>
|
||||
|
||||
<?php echo '<td style="border-bottom:1px groove gray" nowrap width="1%" align="right">'; ?><?php if ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'V'): ?><?php echo 'Valid'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'R'): ?><?php echo 'Revoked'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'E'): ?><?php echo 'Expired'; ?><?php else: ?><?php echo ''; ?><?php endif; ?><?php echo '</td>'; ?>
|
||||
|
||||
<?php echo '<td style="border-bottom:1px groove gray" bgcolor="#DDFFCC" nowrap="nowrap">[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=ZIP" title=\'Download All files in one archive\'>zip</a>]'; ?>
|
||||
<?php echo '[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=CRT" title=\'Download Public Certificate\'>crt</a>]'; ?>
|
||||
<?php echo '[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=KEY" title=\'Download Private Key\'>key</a>]'; ?>
|
||||
<?php echo '[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=CSR" title=\'Download Certificate Request\'>csr</a>]</td>'; ?>
|
||||
|
||||
<?php echo '</tr>'; ?>
|
||||
|
||||
<?php endfor; else: ?>
|
||||
|
||||
<tr><td colspan="2" align="center"><i>There are no certificates made at the minute</i></td></tr>
|
||||
<?php endif; ?>
|
||||
|
||||
</table>
|
41
Admin/Modules/VPNconfig/include/config-edit.php
Normal file
41
Admin/Modules/VPNconfig/include/config-edit.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
$moduleurl = $_SERVER["REQUEST_URI"];
|
||||
|
||||
$ovpnconfdir = db_getconfval("ovpnconfdir");
|
||||
$sqddir = db_getconfval("sqddir");
|
||||
$ovpnconffile = db_getconfval("ovpnconffile");
|
||||
// echo $ovpnconfdir."/".$ovpnconffile;
|
||||
|
||||
echo "
|
||||
Change the OpenVPN Config...";
|
||||
if ($_REQUEST["uebergabe3"] == "1")
|
||||
{
|
||||
$check_ok = "<b><br /><br />Die Daten wurden erfolgreich gespeichert!</b>";
|
||||
echo $check_ok;
|
||||
}
|
||||
if ($_REQUEST["submit"] == "Speichern")
|
||||
{
|
||||
$fp = fopen($ovpnconfdir."/".$ovpnconffile,"w");
|
||||
$data =$_REQUEST["inhalt"];
|
||||
$data = str_replace("\r","",$data);
|
||||
fputs($fp,$data);
|
||||
fclose($fp);
|
||||
|
||||
echo "<meta http-equiv=\"Refresh\" content=\"4; url=".$moduleurl."&uebergabe3=1\">";
|
||||
$check_ok = "<font color = 'red'><br /><br />Ihre Daten wurden erfolgreich geändert!<br>Bitte warten sie bis die Daten aktualisiert werden.</font>";
|
||||
echo $check_ok;
|
||||
}
|
||||
echo "<form action=\"".$_SERVER["REQUEST_URI"]."\" method =\"post\">
|
||||
<textarea name=\"inhalt\" rows=30 cols=120 wrap=\"virtual\">
|
||||
";
|
||||
|
||||
include($ovpnconfdir."/".$ovpnconffile);
|
||||
|
||||
echo "
|
||||
</textarea><br />
|
||||
<input name=\"submit\" type=\"submit\" id=\"submit\" value=\"Speichern\" />
|
||||
<input type=\"reset\" name=\"Submit2\" value=\"Reset\" />
|
||||
|
||||
</form>";
|
||||
|
||||
?>
|
149
Admin/Modules/VPNconfig/include/config.php
Normal file
149
Admin/Modules/VPNconfig/include/config.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
$moduleurl = $_SERVER["REQUEST_URI"];
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openvpn-functions.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openssl-functions.inc");
|
||||
openvpn_load_server_conf ();
|
||||
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
|
||||
openvpn_load_status ();
|
||||
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
|
||||
openssl_load_database ();
|
||||
|
||||
if(is_file("/var/run/openvpn.server.pid"))
|
||||
{
|
||||
echo "<b>VPN Server is currently: <font color=green>running</font></b><br />";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<b>VPN Server is currently: <font color=red>stopped</font></b><br />";
|
||||
}
|
||||
|
||||
if ($_REQUEST["uebergabe3"]=="1")
|
||||
{
|
||||
echo "<b>VPN Server restarted successfully!</b>";
|
||||
echo "<meta http-equiv=\"Refresh\" content=\"1; url=".$moduleurl."&uebergabe=2\">";
|
||||
}
|
||||
if ($_REQUEST["uebergabe3"]=="2")
|
||||
{
|
||||
echo "<b>VPN Server started successfully!</b>";
|
||||
echo "<meta http-equiv=\"Refresh\" content=\"1; url=".$moduleurl."&uebergabe=2\">";
|
||||
}
|
||||
if ($_REQUEST["uebergabe3"]=="3")
|
||||
{
|
||||
echo "<b>VPN Server stopped successfully!</b>";
|
||||
echo "<meta http-equiv=\"Refresh\" content=\"1; url=".$moduleurl."&uebergabe=2\">";
|
||||
}
|
||||
?>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<form action="/Admin/Modules/VPNconfig/include/restartvpn.php" method="post" >
|
||||
<input type="hidden" name="path" size="50" value="<?php echo $moduleurl;?>" />
|
||||
<input type="submit" value="Restart VPN Server" />
|
||||
</form>
|
||||
</td>
|
||||
<?php
|
||||
if(!is_file("/var/run/openvpn.server.pid"))
|
||||
{
|
||||
echo "
|
||||
<td>
|
||||
<form action=\"/Admin/Modules/VPNconfig/include/startvpn.php\" method=\"post\" >
|
||||
<input type=\"hidden\" name=\"path\" size=\"50\" value=\"".$moduleurl."\" />
|
||||
<input type=\"submit\" value=\"Start VPN Server\" />
|
||||
</form>
|
||||
</td>";
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if(is_file("/var/run/openvpn.server.pid"))
|
||||
{
|
||||
echo "
|
||||
<td>
|
||||
<form action=\"/Admin/Modules/VPNconfig/include/stopvpn.php\" method=\"post\" >
|
||||
<input type=\"hidden\" name=\"path\" size=\"50\" value=\"".$moduleurl."\" />
|
||||
<input type=\"submit\" value=\"Stop VPN Server\" />
|
||||
</form>
|
||||
</td>";
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
|
||||
<table border="0" width="100%" cellspacing="0" cellpadding="4">
|
||||
|
||||
<tr valign="top">
|
||||
<td colspan="2" style="border-top:1px groove black; border-bottom:1px groove black"><b>Server Settings</b></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Mode</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Server']['Mode']; ?>
|
||||
</font></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Uses device</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Server']['Dev']; ?>
|
||||
</font></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Listens on</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Server']['Local']; ?>
|
||||
: <?php echo $openvpn['Server']['Port']; ?>
|
||||
(<?php echo $openvpn['Server']['Proto']; ?>
|
||||
)</font></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Maximum Clients</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Server']['MaxClients']; ?>
|
||||
</font></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><td colspan="2" style="border-top:1px groove black; border-bottom:1px groove black"><b>Certificate Files</b></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">DH</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Server']['DH']['File']; ?>
|
||||
</font> <?php echo ''; ?><?php if ($openvpn['Server']['DH']['Exists'] == true): ?><?php echo '[<a href="'; ?><?php echo $moduleurl; ?><?php echo '?Action=DownloadConfigFile&id=DH" title=\'DH File\'>download</a>]'; ?><?php else: ?><?php echo '[<font color="red">does not exist</font>]'; ?><?php endif; ?><?php echo ''; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">CA Certificate</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Openssl']['CA']['File']; ?>
|
||||
</font> <?php echo ''; ?><?php if ($openvpn['Openssl']['CA']['Exists'] == true): ?><?php echo '[<a href="'; ?><?php echo $moduleurl; ?><?php echo '?Action=DownloadConfigFile&id=CA" title=\'Certificate Authority Public Certificate\'>download</a>]'; ?><?php else: ?><?php echo '[<font color="red">does not exist</font>]'; ?><?php endif; ?><?php echo ''; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Server Certificate</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Server']['Certificate']['File']; ?>
|
||||
</font> <?php echo ''; ?><?php if ($openvpn['Server']['Certificate']['Exists'] == true): ?><?php echo '[<a href="'; ?><?php echo $moduleurl; ?><?php echo '?Action=DownloadConfigFile&id=CRT" title=\'Server Public Certificate\'>download</a>]'; ?><?php else: ?><?php echo '[<font color="red">does not exist</font>]'; ?><?php endif; ?><?php echo ''; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Server Private Key</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Server']['Private_Key']['File']; ?>
|
||||
</font> <?php echo ''; ?><?php if ($openvpn['Server']['Private_Key']['Exists'] == true): ?><?php echo '[<a href="'; ?><?php echo $_SERVER['PHP_SELF']; ?><?php echo '?Action=DownloadConfigFile&id=KEY" title=\'Server Private Key\'>download</a>]'; ?><?php else: ?><?php echo '[<font color="red">does not exist</font>]'; ?><?php endif; ?><?php echo ''; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">TLS Authentication</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Server']['TLS_Auth']['File']; ?>
|
||||
</font><?php echo ''; ?><?php if ($openvpn['Server']['DH']['Exists'] == true): ?><?php echo ', '; ?><?php if ($openvpn['Server']['TLS_Auth']['Key'] == 0): ?><?php echo 'server '; ?><?php else: ?><?php echo 'client '; ?><?php endif; ?><?php echo 'side [<a href="'; ?><?php echo $moduleurl; ?><?php echo '?Action=DownloadConfigFile&id=TLS" title=\'Server TLS Key\'>download</a>]'; ?><?php else: ?><?php echo ' [<font color="red">does not exist</font>]'; ?><?php endif; ?><?php echo ''; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">CRL Verify File</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Server']['CRL_Verify']['File']; ?>
|
||||
</font> <?php echo ''; ?><?php if ($openvpn['Server']['CRL_Verify']['Exists'] == true): ?><?php echo '[<a href="'; ?><?php echo $moduleurl; ?><?php echo '?Action=DownloadConfigFile&id=CRL" title=\'OPENSSL Certificate Revocation List\'>download</a>]'; ?><?php else: ?><?php echo '[<font color="red">does not exist</font>]'; ?><?php endif; ?><?php echo ''; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
251
Admin/Modules/VPNconfig/include/functions.inc
Executable file
251
Admin/Modules/VPNconfig/include/functions.inc
Executable file
@@ -0,0 +1,251 @@
|
||||
<?php
|
||||
// ----------------------------------------------
|
||||
function load_plugins ()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (isset ($config['Plugins']))
|
||||
{
|
||||
foreach ($config['Plugins'] as $PluginName => $PluginData)
|
||||
{
|
||||
// Check if the config.inc for a plugin exists
|
||||
if (file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/config.inc"))
|
||||
{
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/config.inc");
|
||||
|
||||
// Check if claimed inc files do exist
|
||||
if (isset ($config['Plugins'][$PluginName]['Action']['Include']) &&
|
||||
!file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/".
|
||||
$config['Plugins'][$PluginName]['Action']['Include']))
|
||||
$config['Plugins'][$PluginName]['Action']['Include'] = NULL;
|
||||
|
||||
if (isset ($config['Plugins'][$PluginName]['Left']['Menu']) &&
|
||||
!file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/".
|
||||
$config['Plugins'][$PluginName]['Left']['Menu']))
|
||||
$config['Plugins'][$PluginName]['Left']['Menu'] = NULL;
|
||||
|
||||
if (isset ($config['Plugins'][$PluginName]['Left']['Status']) &&
|
||||
!file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/".
|
||||
$config['Plugins'][$PluginName]['Left']['Status']))
|
||||
$config['Plugins'][$PluginName]['Left']['Status'] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function seconds_string ($seconds, $periods = null)
|
||||
{
|
||||
$Wanted = '';
|
||||
|
||||
// Define time periods
|
||||
if (!is_array ($periods))
|
||||
{
|
||||
$periods = array (
|
||||
'years' => 31556926,
|
||||
'months' => 2629743,
|
||||
'weeks' => 604800,
|
||||
'days' => 86400,
|
||||
'hours' => 3600,
|
||||
'minutes' => 60,
|
||||
'seconds' => 1
|
||||
);
|
||||
}
|
||||
|
||||
// Wanted
|
||||
if (empty ($seconds))
|
||||
{ $Wanted = ''; }
|
||||
else
|
||||
{
|
||||
// Loop
|
||||
$seconds = (int) $seconds;
|
||||
foreach ($periods as $period => $value)
|
||||
{
|
||||
$count = floor ($seconds / $value);
|
||||
|
||||
if ($count == 0)
|
||||
continue;
|
||||
elseif ($count == 1)
|
||||
$Wanted .= ($count . ' ' . substr ($period, 0, strlen ($period) - 1) . ' ');
|
||||
else
|
||||
$Wanted .= ($count . ' ' . $period . ' ');
|
||||
|
||||
$seconds = $seconds % $value;
|
||||
}
|
||||
}
|
||||
|
||||
return rtrim ($Wanted);
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function chomp (&$string)
|
||||
{
|
||||
if (is_array ($string))
|
||||
{
|
||||
foreach ($string as $i => $val)
|
||||
{ $endchar = chomp ($string[$i]); }
|
||||
}
|
||||
else
|
||||
{
|
||||
$endchar = substr ("$string", strlen("$string") - 1, 1);
|
||||
if ($endchar == "\n")
|
||||
{ $string = substr ("$string", 0, -1); }
|
||||
}
|
||||
return $endchar;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function str_strip_spaces ($aline)
|
||||
{
|
||||
while (strpos ($aline, "\t") != FALSE) $aline = str_replace ("\t", ' ', $aline);
|
||||
while (strpos ($aline, ' ') != FALSE) $aline = str_replace (' ', ' ', $aline);
|
||||
|
||||
return $aline;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// Returns $afile only if it is the full name, or prefixed by $apath
|
||||
function str_file_fullname ($apath, $afile)
|
||||
{
|
||||
if (substr ($afile, 0, 1) != '/')
|
||||
$afile = ($apath . $afile);
|
||||
|
||||
return $afile;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// Returns $afile only if it is the full name, or prefixed by $apath
|
||||
function str_openssldata_to_string ($adata)
|
||||
{
|
||||
$Return = '';
|
||||
$amonth = array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
|
||||
|
||||
if (substr ($adata, -1, 1) == 'Z')
|
||||
{
|
||||
$Return = sprintf ("%s %d %s%02d, %02d:%02d:%02d",
|
||||
$amonth [substr ($adata, 2, 2) - 1],
|
||||
substr ($adata, 4, 2),
|
||||
(substr ($adata, 0, 2) > 50 ? '19' : '20'),
|
||||
substr ($adata, 0, 2),
|
||||
substr ($adata, 6, 2),
|
||||
substr ($adata, 8, 2),
|
||||
substr ($adata, 10, 2));
|
||||
}
|
||||
|
||||
return $Return;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function str_get_sometag ($aline, $sometag)
|
||||
{
|
||||
if (eregi ($sometag, $aline, $anarray))
|
||||
return $anarray[1];
|
||||
else
|
||||
return '';
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// Writes content into file
|
||||
// Optionally sames old file into backup file.
|
||||
// The Backup File has to reside on the same partition!
|
||||
function writefile ($afile, $adata, $abackup = NULL)
|
||||
{
|
||||
// Move the old file into Backup one
|
||||
if ($abackup != NULL)
|
||||
{
|
||||
if (file_exists ($afile))
|
||||
{
|
||||
if (file_exists ($abackup))
|
||||
if (!unlink ($abackup))
|
||||
exit;
|
||||
if (!rename ($afile, $abackup))
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$fp = fopen ($afile, "w", 0);
|
||||
if (!$fp)
|
||||
exit;
|
||||
|
||||
fputs ($fp, $adata);
|
||||
fclose ($fp);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------
|
||||
// Guess the full file name
|
||||
function if_file_exists (&$sFileName, $bFix = FALSE)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (strpos ($sFileName, '/') == FALSE)
|
||||
{
|
||||
$sLongFileName = $config['openvpn']['folder'] . $sFileName;
|
||||
if (file_exists ($sLongFileName) && $bFix)
|
||||
$sFileName = $sLongFileName;
|
||||
}
|
||||
|
||||
return file_exists ($sFileName);
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function zlib_check_functions ()
|
||||
{
|
||||
$Result = '';
|
||||
$ZLibs = array
|
||||
(
|
||||
'gzcompress'
|
||||
);
|
||||
|
||||
foreach ($ZLibs as $Function)
|
||||
{
|
||||
$Result .= $Function . '<font color="black">:</font> ' . (function_exists ($Function) ?
|
||||
'<font color="black">OK</font>' :
|
||||
'<font color="red">DOES NOT EXIST</font>') . '<br>';
|
||||
}
|
||||
|
||||
return $Result;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function html_dump ($aname, $athing)
|
||||
{
|
||||
echo '<pre><b><font color="darkgreen">'. $aname .'</font></b>: ';
|
||||
print_r ($athing);
|
||||
echo "</pre><br>\n";
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function html_error ($amessage, $ifexit = true)
|
||||
{
|
||||
global $config;
|
||||
echo $amessage;
|
||||
if ($ifexit)
|
||||
exit;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function html_postredir ($url)
|
||||
{
|
||||
header ('HTTP/1.1 303 REDIRECT');
|
||||
header ('Location: '. $url);
|
||||
#header ('Status: 303'); // if 1st header generates 500, then commend it out and use this one as 2nd
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// ----------------------------------------------
|
||||
function html_download ($sFile, $sName)
|
||||
{
|
||||
header ('Content-type: application/octet-stream');
|
||||
header ('Content-Disposition: attachment; filename="'. $sName . '"');
|
||||
readfile ($sFile);
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function html_download_data ($sData, $sName)
|
||||
{
|
||||
header ('Content-type: application/octet-stream');
|
||||
header ('Content-Disposition: attachment; filename="'. $sName . '"');
|
||||
echo $sData;
|
||||
}
|
||||
?>
|
74
Admin/Modules/VPNconfig/include/getfile.php
Executable file
74
Admin/Modules/VPNconfig/include/getfile.php
Executable file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
session_start();
|
||||
include($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
|
||||
include($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
|
||||
include_once ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
|
||||
include_once ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
|
||||
include_once ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openssl-functions.inc");
|
||||
include_once ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openvpn-functions.inc");
|
||||
|
||||
|
||||
//#################################################################################################################
|
||||
|
||||
openvpn_load_server_conf ();
|
||||
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
|
||||
openvpn_load_status ();
|
||||
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
|
||||
|
||||
openssl_load_database ();
|
||||
|
||||
// Check permissions :)
|
||||
// ...
|
||||
$GETidDEC[0] =$_REQUEST['id'];
|
||||
$sExt = '.pem';
|
||||
if (isset ($_REQUEST['Type']))
|
||||
if ($_REQUEST['Type'] == 'CRT') $sExt = '.pem';
|
||||
elseif ($_REQUEST['Type'] == 'KEY') $sExt = '.key';
|
||||
elseif ($_REQUEST['Type'] == 'CSR') $sExt = '.csr';
|
||||
elseif ($_REQUEST['Type'] == 'ZIP') $sExt = '.zip';
|
||||
|
||||
if ($sExt == '.zip')
|
||||
{
|
||||
include_once ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/zip.lib.php");
|
||||
$zipData = new zipfile ();
|
||||
|
||||
// Add the certificate files
|
||||
foreach (array ('.pem', '.key', '.csr') as $Ext2zip)
|
||||
{
|
||||
if ($config['Download']['ZIP'][$Ext2zip])
|
||||
{
|
||||
$File2zip = openssl_get_filename ($GETidDEC[0], $Ext2zip);
|
||||
$File2name = basename ($File2zip, '.pem');
|
||||
// Cheat the extension
|
||||
if ($Ext2zip == '.pem') $File2name .= '.crt';
|
||||
|
||||
if (is_file ($File2zip))
|
||||
$zipData->addFile (implode ('', file ($File2zip)), $File2name);
|
||||
}
|
||||
}
|
||||
|
||||
// Add the extra files
|
||||
foreach ($config['Download']['ZIP']['Others'] as $File2zip)
|
||||
{
|
||||
if (is_file (db_getconfval("publicdown")."/". $File2zip))
|
||||
$zipData->addFile (implode ('', file (db_getconfval("publicdown")."/". $File2zip)), $File2zip);
|
||||
}
|
||||
|
||||
// Flush the ZIP file to the client
|
||||
html_download_data ($zipData -> file (), openssl_hex_serial ($GETidDEC[0]) .'.zip');
|
||||
//echo "<a href=getfile.php?dir=$zipData -> file () target=_blank>Direktlink zur Datei</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
// echo "ID: " .$GETidDEC[0] . "Ext: " .$sExt;
|
||||
if (($sCertificateFile = openssl_get_filename ($GETidDEC[0], $sExt)) == '') html_error ("Can't find requested file..FU");
|
||||
|
||||
// Cheat the extension
|
||||
if ($sExt == '.pem') $sExt = '.crt';
|
||||
|
||||
// Download
|
||||
html_download ($sCertificateFile, openssl_hex_serial ($GETidDEC[0]) . $sExt);
|
||||
//html_dump ('$GLOBALS', $GLOBALS);
|
||||
}
|
||||
|
||||
?>
|
41
Admin/Modules/VPNconfig/include/ipp.php
Normal file
41
Admin/Modules/VPNconfig/include/ipp.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
$moduleurl = $_SERVER["REQUEST_URI"];
|
||||
|
||||
$ovpnconfdir = db_getconfval("ovpnconfdir");
|
||||
$sqddir = db_getconfval("sqddir");
|
||||
$ovpnconffile = db_getconfval("ovpnconffile");
|
||||
// echo $ovpnconfdir."/".$ovpnconffile;
|
||||
|
||||
echo "
|
||||
Change the OpenVPN Client IP list...";
|
||||
if ($_REQUEST["uebergabe3"] == "1")
|
||||
{
|
||||
$check_ok = "<b><br /><br />Die Daten wurden erfolgreich gespeichert!</b>";
|
||||
echo $check_ok;
|
||||
}
|
||||
if ($_REQUEST["submit"] == "Speichern")
|
||||
{
|
||||
$fp = fopen($sqddir."/ipp.txt","w");
|
||||
$data =$_REQUEST["inhalt"];
|
||||
$data = str_replace("\r","",$data);
|
||||
fputs($fp,$data);
|
||||
fclose($fp);
|
||||
|
||||
echo "<meta http-equiv=\"Refresh\" content=\"4; url=".$moduleurl."&uebergabe3=1\">";
|
||||
$check_ok = "<font color = 'red'><br /><br />Ihre Daten wurden erfolgreich geändert!<br>Bitte warten sie bis die Daten aktualisiert werden.</font>";
|
||||
echo $check_ok;
|
||||
}
|
||||
echo "<form action=\"".$_SERVER["REQUEST_URI"]."\" method =\"post\">
|
||||
<textarea name=\"inhalt\" rows=20 cols=100 wrap=\"virtual\">
|
||||
";
|
||||
|
||||
include($ovpnconfdir."/ipp.txt");
|
||||
|
||||
echo "
|
||||
</textarea><br />
|
||||
<input name=\"submit\" type=\"submit\" id=\"submit\" value=\"Speichern\" />
|
||||
<input type=\"reset\" name=\"Submit2\" value=\"Reset\" />
|
||||
|
||||
</form>";
|
||||
|
||||
?>
|
377
Admin/Modules/VPNconfig/include/openssl-functions.inc
Executable file
377
Admin/Modules/VPNconfig/include/openssl-functions.inc
Executable file
@@ -0,0 +1,377 @@
|
||||
<?php
|
||||
// ----------------------------------------------
|
||||
function openssl_check_functions ()
|
||||
{
|
||||
$Result = '';
|
||||
$OpenSSLs = array
|
||||
(
|
||||
'openssl_csr_new',
|
||||
'openssl_csr_sign',
|
||||
'openssl_csr_export_to_file',
|
||||
'openssl_pkey_new',
|
||||
'openssl_pkey_get_private',
|
||||
'openssl_pkey_export_to_file',
|
||||
'openssl_x509_export_to_file'
|
||||
);
|
||||
|
||||
foreach ($OpenSSLs as $Function)
|
||||
{
|
||||
$Result .= $Function . '<font color="black">:</font> ' . (function_exists ($Function) ?
|
||||
'<font color="black">OK</font>' :
|
||||
'<font color="red">DOES NOT EXIST</font>') . '<br>';
|
||||
}
|
||||
|
||||
return $Result;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function openssl_load_database ($afile = '')
|
||||
{
|
||||
global $config;
|
||||
global $openssl;
|
||||
|
||||
$afile = ($afile == '' ? $config['openssl']['database'] : $afile);
|
||||
$lines = file ($afile);
|
||||
|
||||
if (!is_array ($lines))
|
||||
exit;
|
||||
|
||||
foreach ($lines as $line_num => $line)
|
||||
{
|
||||
chomp ($line);
|
||||
$linetokens = explode ("\t", $line);
|
||||
|
||||
// Ensure that all the fields are set
|
||||
if (count ($linetokens) == 6)
|
||||
{
|
||||
// Decode the openssl's database. See apps/apps.h
|
||||
$openssl['Database'][] = array ('Status' => $linetokens[0],
|
||||
'ExpDate' => $linetokens[1],
|
||||
'RevDate' => $linetokens[2],
|
||||
'Serial' => $linetokens[3],
|
||||
'File' => $linetokens[4],
|
||||
'Name' => $linetokens[5],
|
||||
'Country' => openssl_get_country ($linetokens[5]),
|
||||
'State' => openssl_get_state ($linetokens[5]),
|
||||
'City' => openssl_get_city ($linetokens[5]),
|
||||
'Company' => openssl_get_company ($linetokens[5]),
|
||||
'Department' => openssl_get_department ($linetokens[5]),
|
||||
'CN' => openssl_get_CN ($linetokens[5]),
|
||||
'Email' => openssl_get_email ($linetokens[5])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function openssl_write_database ($afile = '')
|
||||
{
|
||||
global $config;
|
||||
global $openssl;
|
||||
|
||||
$afile = ($afile == '' ? $config['openssl']['database'] : $afile);
|
||||
|
||||
$atext = '';
|
||||
for ($i = 0; $i < count ($openssl['Database']); $i++)
|
||||
{
|
||||
$atext .= ($atext == '' ? '' : "\n");
|
||||
$atext .= $openssl['Database'][$i]['Status'] ."\t".
|
||||
$openssl['Database'][$i]['ExpDate'] ."\t".
|
||||
$openssl['Database'][$i]['RevDate'] ."\t".
|
||||
$openssl['Database'][$i]['Serial'] ."\t".
|
||||
$openssl['Database'][$i]['File'] ."\t".
|
||||
$openssl['Database'][$i]['Name'];
|
||||
}
|
||||
|
||||
writefile ($afile, $atext, $afile .'.old');
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function openssl_write_database_attr ($atext = '', $afile = '')
|
||||
{
|
||||
global $config;
|
||||
global $openssl;
|
||||
|
||||
$afile = ($afile == '' ? $config['openssl']['database'] : $afile) .'.attr';
|
||||
$atext = ($atext == '' ? "unique_subject = yes\n" : $atext);
|
||||
|
||||
if (file_exists ($afile))
|
||||
{
|
||||
ob_start ();
|
||||
readfile ($afile);
|
||||
$atext = ob_get_contents ();
|
||||
ob_end_clean ();
|
||||
}
|
||||
|
||||
writefile ($afile, $atext, $afile .'.old');
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// Returns the PEM file with spaces reduced and replaced to
|
||||
function openssl_load_cert ($anid)
|
||||
{
|
||||
global $config;
|
||||
|
||||
do
|
||||
{
|
||||
$lines = file ($config['openssl']['pubfolder'] . $anid . '.pem');
|
||||
|
||||
if (!is_array ($lines))
|
||||
{
|
||||
$Return = '';
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($lines as $line_num => $line)
|
||||
{
|
||||
chomp ($line);
|
||||
$Return[] = str_replace (' ', ' ', htmlspecialchars (str_replace (' ', ' ', $line)));
|
||||
}
|
||||
} while (FALSE);
|
||||
|
||||
return $Return;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function openssl_load_serial ($afile = '')
|
||||
{
|
||||
global $config;
|
||||
|
||||
$afile = ($afile == '' ? $config['openssl']['serial'] : $afile);
|
||||
|
||||
$lines = file ($afile);
|
||||
|
||||
if (!is_array ($lines))
|
||||
exit;
|
||||
|
||||
$Return = sscanf ($lines[0], "%X");
|
||||
|
||||
return $Return[0];
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function openssl_write_serial ($iNumber, $afile = '')
|
||||
{
|
||||
global $config;
|
||||
|
||||
$afile = ($afile == '' ? $config['openssl']['serial'] : $afile);
|
||||
|
||||
writefile ($afile, openssl_hex_serial ($iNumber) . "\n", $afile .'.old');
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// Supports up to 999,999 serials
|
||||
function openssl_hex_serial ($iNumber)
|
||||
{
|
||||
if ($iNumber < 100)
|
||||
$sString = sprintf ("%02X", $iNumber);
|
||||
elseif ($iNumber < 10000)
|
||||
$sString = sprintf ("%04X", $iNumber);
|
||||
else
|
||||
$sString = sprintf ("%06X", $iNumber);
|
||||
|
||||
return $sString;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// Builds User Private Key, CSR and Public Certificate
|
||||
function openssl_build_key (&$anoutput, $adn, $validdays = NULL)
|
||||
{
|
||||
global $config;
|
||||
global $openssl;
|
||||
|
||||
$anoutput = '';
|
||||
$Return = FALSE;
|
||||
|
||||
// Allow to override default value
|
||||
$validdays = ($validdays == NULL ? $config['openssl']['default']['expiration'] : $validdays);
|
||||
|
||||
do
|
||||
{
|
||||
if (!isset ($adn) ||
|
||||
!isset ($adn['countryName']) ||
|
||||
!isset ($adn['stateOrProvinceName']) ||
|
||||
!isset ($adn['localityName']) ||
|
||||
!isset ($adn['organizationName']) ||
|
||||
!isset ($adn['organizationalUnitName']) ||
|
||||
!isset ($adn['commonName']) ||
|
||||
!isset ($adn['emailAddress'])
|
||||
)
|
||||
{ $anoutput .= "- ERROR on ". __LINE__ ." line: incomplete DN information\n"; break; }
|
||||
$anoutput .= "+ OK got the valid input\n";
|
||||
|
||||
// Get the new User Private Key
|
||||
$UserPrivKey = openssl_pkey_new (array($config['openssl']['config'],0));
|
||||
if ($UserPrivKey == FALSE)
|
||||
{ $anoutput .= "- ERROR on ". (__LINE__ - 2) ." line (openssl_pkey_new):\n ". openssl_error_strings () ." (that might usually mean that the openssl.cnf file is unavailable)"; break; }
|
||||
$anoutput .= "+ OK got the User Private Key\n";
|
||||
|
||||
// Generate the User Certificate Request
|
||||
$UserReq = openssl_csr_new ($adn,
|
||||
$UserPrivKey,
|
||||
$config['openssl']['config']);
|
||||
if ($UserReq == FALSE)
|
||||
{ $anoutput .= "- ERROR on ". (__LINE__ - 4) ." line (openssl_csr_new):\n ". openssl_error_strings (); break; }
|
||||
$anoutput .= "+ OK generated the User Certificate Request\n";
|
||||
|
||||
// Read the openssl serial
|
||||
$CAserial = openssl_load_serial ($config['openssl']['serial']);
|
||||
$anoutput .= "+ OK read current openssl serial (". openssl_hex_serial ($CAserial) .")\n";
|
||||
|
||||
$UserPubCertFile = $config['openssl']['pubfolder'] . openssl_hex_serial ($CAserial) .'.pem';
|
||||
$UserCertReqFile = $config['openssl']['reqfolder'] . openssl_hex_serial ($CAserial) .'.csr';
|
||||
$UserPrivKeyFile = $config['openssl']['prvfolder'] . openssl_hex_serial ($CAserial) .'.key';
|
||||
|
||||
// Read the openssl database
|
||||
openssl_load_database ($config['openssl']['database']);
|
||||
$anoutput .= "+ OK read the openssl database (". count ($openssl['Database']) ." items)\n";
|
||||
|
||||
// Get CA's Private Key
|
||||
$CAPrivKey = openssl_pkey_get_private ($config['openssl']['CA']['priv']);
|
||||
|
||||
if ($CAPrivKey == FALSE)
|
||||
{ $anoutput .= "- ERROR on ". (__LINE__ - 2) ." line (openssl_pkey_get_private)\n ". openssl_error_strings (); break; }
|
||||
$anoutput .= "+ OK read the CA Private Key\n";
|
||||
|
||||
// Get a CA-signed cert that lasts for 1 year
|
||||
$UserPubCert = openssl_csr_sign ($UserReq,
|
||||
$config['openssl']['CA']['pub'],
|
||||
$CAPrivKey,
|
||||
$validdays,
|
||||
$config['openssl']['config'],
|
||||
$CAserial);
|
||||
if ($UserPubCert == FALSE)
|
||||
{ $anoutput .= "- ERROR on ". (__LINE__ - 7) ." line (openssl_csr_sign)\n ". openssl_error_strings (); break; }
|
||||
$anoutput .= "+ OK signed the User Certificate Request with CA Private Key\n";
|
||||
|
||||
// Add the new row into openssl database
|
||||
$openssl['Database'][] = array ('Status' => 'V',
|
||||
'ExpDate' => date ('ymdHis',
|
||||
time() +
|
||||
date ('Z') +
|
||||
($validdays * 24 * 60 * 60)) .'Z',
|
||||
'RevDate' => '',
|
||||
'Serial' => openssl_hex_serial ($CAserial),
|
||||
'File' => openssl_hex_serial ($CAserial) .'.crt',
|
||||
'Name' => openssl_make_name ($adn)
|
||||
);
|
||||
|
||||
// Create files
|
||||
|
||||
$OldUMask = umask (0007);
|
||||
|
||||
// Write User Private Key
|
||||
if (!openssl_pkey_export_to_file ($UserPrivKey, $UserPrivKeyFile, NULL, $config['openssl']['config']))
|
||||
{ $anoutput .= "- ERROR on ". (__LINE__ - 1) ." line (openssl_pkey_export_to_file)\n ". openssl_error_strings () ." (That might mean that the key folder is not write enabled for www user)"; break; }
|
||||
$anoutput .= "+ OK wrote User Private Key into file $UserPrivKeyFile\n";
|
||||
|
||||
// Write User Public Certificate
|
||||
if (!openssl_x509_export_to_file ($UserPubCert, $UserPubCertFile, FALSE))
|
||||
{ $anoutput .= "- ERROR on ". (__LINE__ - 1) ." line (openssl_x509_export_to_file)\n ". openssl_error_strings (); break; }
|
||||
$anoutput .= "+ OK wrote User Public Certificate into file $UserPubCertFile\n";
|
||||
|
||||
// Write User Certificate Request
|
||||
if (!openssl_csr_export_to_file ($UserReq, $UserCertReqFile))
|
||||
{ $anoutput .= "- ERROR on ". (__LINE__ - 1) ." line (openssl_csr_export_to_file)\n ". openssl_error_strings (); break; }
|
||||
$anoutput .= "+ OK wrote User Certificate Request into file $UserCertReqFile\n";
|
||||
|
||||
// Write new openssl database
|
||||
openssl_write_database ($config['openssl']['database']);
|
||||
openssl_write_database_attr ('', $config['openssl']['database']);
|
||||
$anoutput .= "+ OK wrote new openssl database\n";
|
||||
|
||||
// Write new openssl serial
|
||||
openssl_write_serial ($CAserial + 1, $config['openssl']['serial']);
|
||||
$anoutput .= "+ OK wrote new openssl serial\n";
|
||||
|
||||
umask ($OldUMask);
|
||||
|
||||
$Return = openssl_hex_serial ($CAserial);
|
||||
} while (FALSE);
|
||||
|
||||
return $Return;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function openssl_error_strings ()
|
||||
{
|
||||
$sString = '';
|
||||
while ($msg = openssl_error_string ())
|
||||
$sString .= $msg ."\n";
|
||||
|
||||
return $sString;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function openssl_make_name ($adn)
|
||||
{
|
||||
$sString = '';
|
||||
|
||||
if (strlen ($adn['countryName']) > 0) $sString .= '/C=' . $adn['countryName'];
|
||||
if (strlen ($adn['stateOrProvinceName']) > 0) $sString .= '/ST=' . $adn['stateOrProvinceName'];
|
||||
if (strlen ($adn['localityName']) > 0) $sString .= '/L=' . $adn['localityName'];
|
||||
if (strlen ($adn['organizationName']) > 0) $sString .= '/O=' . $adn['organizationName'];
|
||||
if (strlen ($adn['organizationalUnitName']) > 0) $sString .= '/OU=' . $adn['organizationalUnitName'];
|
||||
if (strlen ($adn['commonName']) > 0) $sString .= '/CN=' . $adn['commonName'];
|
||||
if (strlen ($adn['emailAddress']) > 0) $sString .= '/emailAddress='. $adn['emailAddress'];
|
||||
|
||||
return $sString;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function openssl_get_country ($aline)
|
||||
{ return str_get_sometag ($aline . '/', '\/C=([^/]*)\/'); }
|
||||
|
||||
// ----------------------------------------------
|
||||
function openssl_get_state ($aline)
|
||||
{ return str_get_sometag ($aline . '/', '\/ST=([^/]*)\/'); }
|
||||
|
||||
// ----------------------------------------------
|
||||
function openssl_get_city ($aline)
|
||||
{ return str_get_sometag ($aline . '/', '\/L=([^/]*)\/'); }
|
||||
|
||||
// ----------------------------------------------
|
||||
function openssl_get_company ($aline)
|
||||
{ return str_get_sometag ($aline . '/', '\/O=([^/]*)\/'); }
|
||||
|
||||
// ----------------------------------------------
|
||||
function openssl_get_department ($aline)
|
||||
{ return str_get_sometag ($aline . '/', '\/OU=([^/]*)\/'); }
|
||||
|
||||
// ----------------------------------------------
|
||||
function openssl_get_CN ($aline)
|
||||
{ return str_get_sometag ($aline . '/', '\/CN=([^/]*)\/'); }
|
||||
|
||||
// ----------------------------------------------
|
||||
function openssl_get_email ($aline)
|
||||
{ return str_get_sometag ($aline . '/', '\/emailAddress=([^/]*)\/'); }
|
||||
|
||||
// ----------------------------------------------
|
||||
// Guess the full file name
|
||||
function openssl_get_filename ($iSerial, $sExt)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$sReturn = $config['openssl']['folder'] . openssl_hex_serial ($iSerial) . $sExt;
|
||||
if (!file_exists ($sReturn))
|
||||
{
|
||||
$sReturn = $config['openssl']['pubfolder'] . openssl_hex_serial ($iSerial) . $sExt;
|
||||
if (!file_exists ($sReturn))
|
||||
{
|
||||
$sReturn = $config['openssl']['reqfolder'] . openssl_hex_serial ($iSerial) . $sExt;
|
||||
if (!file_exists ($sReturn))
|
||||
{
|
||||
$sReturn = $config['openssl']['prvfolder'] . openssl_hex_serial ($iSerial) . $sExt;
|
||||
if (!file_exists ($sReturn))
|
||||
{
|
||||
$sReturn = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $sReturn;
|
||||
}
|
||||
|
||||
|
||||
?>
|
176
Admin/Modules/VPNconfig/include/openvpn-functions.inc
Executable file
176
Admin/Modules/VPNconfig/include/openvpn-functions.inc
Executable file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
// ----------------------------------------------
|
||||
function openvpn_load_server_conf ()
|
||||
{
|
||||
global $config;
|
||||
global $openvpn;
|
||||
global $openssl;
|
||||
|
||||
$lines = file ($config['openvpn']['config']);
|
||||
|
||||
if (!is_array ($lines))
|
||||
exit;
|
||||
|
||||
foreach ($lines as $line_num => $line)
|
||||
{
|
||||
chomp ($line);
|
||||
$linetokens = explode (' ', str_strip_spaces ($line));
|
||||
|
||||
switch (strtolower ($linetokens[0]))
|
||||
{
|
||||
case 'local': $openvpn['Server']['Local'] = $linetokens[1]; break;
|
||||
case 'proto': $openvpn['Server']['Proto'] = $linetokens[1]; break;
|
||||
case 'port': $openvpn['Server']['Port'] = $linetokens[1]; break;
|
||||
case 'dev': $openvpn['Server']['Dev'] = $linetokens[1]; break;
|
||||
case 'mode': $openvpn['Server']['Mode'] = $linetokens[1]; break;
|
||||
case 'max-clients': $openvpn['Server']['MaxClients'] = $linetokens[1]; break;
|
||||
case 'status':
|
||||
$openvpn['Server']['Status']['Exists'] = if_file_exists ($linetokens[1], true);
|
||||
$openvpn['Server']['Status']['File'] = $linetokens[1];
|
||||
break;
|
||||
case 'status-version': $openvpn['Server']['Status']['Version'] = $linetokens[1]; break;
|
||||
case 'ca':
|
||||
$openssl['Server']['CA']['Exists'] = if_file_exists ($linetokens[1], true);
|
||||
$openssl['Server']['CA']['File'] = $linetokens[1];
|
||||
break;
|
||||
case 'dh':
|
||||
$openvpn['Server']['DH']['Exists'] = if_file_exists ($linetokens[1], true);
|
||||
$openvpn['Server']['DH']['File'] = $linetokens[1];
|
||||
break;
|
||||
case 'cert':
|
||||
$openvpn['Server']['Certificate']['Exists'] = if_file_exists ($linetokens[1], true);
|
||||
$openvpn['Server']['Certificate']['File'] = $linetokens[1];
|
||||
break;
|
||||
case 'key':
|
||||
$openvpn['Server']['Private_Key']['Exists'] = if_file_exists ($linetokens[1], true);
|
||||
$openvpn['Server']['Private_Key']['File'] = $linetokens[1];
|
||||
break;
|
||||
case 'tls-auth':
|
||||
$openvpn['Server']['TLS_Auth']['Exists'] = if_file_exists ($linetokens[1], true);
|
||||
$openvpn['Server']['TLS_Auth']['File'] = $linetokens[1];
|
||||
$openvpn['Server']['TLS_Auth']['Key'] = $linetokens[2];
|
||||
break;
|
||||
case 'crl-verify':
|
||||
$openvpn['Server']['CRL_Verify']['Exists'] = if_file_exists ($linetokens[1], true);
|
||||
$openvpn['Server']['CRL_Verify']['File'] = $linetokens[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
function openvpn_load_status ()
|
||||
{
|
||||
global $config;
|
||||
global $openvpn;
|
||||
|
||||
$stop_reading = FALSE;
|
||||
|
||||
if (!isset ($openvpn['Server']['Status']['File']))
|
||||
{
|
||||
echo "Config file not found";
|
||||
exit;
|
||||
}
|
||||
$lines = file (str_file_fullname ($config['openvpn']['folder'], $openvpn['Server']['Status']['File']));
|
||||
|
||||
if (!is_array ($lines))
|
||||
{
|
||||
echo "Status file empty";
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($lines as $line_num => $line)
|
||||
{
|
||||
chomp ($line);
|
||||
$linetokens = explode (',', $line);
|
||||
|
||||
if ($linetokens[0] == 'TITLE')
|
||||
$openvpn['Server']['Title'] = $linetokens[1];
|
||||
else if ($linetokens[0] == 'TIME')
|
||||
{
|
||||
$openvpn['Server']['DateTime'] = $linetokens[1];
|
||||
$openvpn['Server']['Time'] = $linetokens[2];
|
||||
}
|
||||
else if ($linetokens[0] == 'HEADER' && $linetokens[1] == 'CLIENT_LIST')
|
||||
{
|
||||
// We will need to know what field is what ?
|
||||
}
|
||||
else if ($linetokens[0] == 'HEADER' && $linetokens[1] == 'ROUTING_TABLE')
|
||||
{
|
||||
// We will need to know what field is what ?
|
||||
}
|
||||
else if ($linetokens[0] == 'CLIENT_LIST')
|
||||
{
|
||||
$openvpn['Client'][] = array ('CN' => str_replace ('_', ' ', $linetokens[1]),
|
||||
'REALADDR' => $linetokens[2],
|
||||
'VIRTADDR' => $linetokens[3],
|
||||
'BYTESRCV' => $linetokens[4],
|
||||
'BYTESSND' => $linetokens[5],
|
||||
'SINCE' => $linetokens[6],
|
||||
'SINCEUT' => $linetokens[7],
|
||||
'Seconds_Ago' => seconds_string (time () - $linetokens[7])
|
||||
);
|
||||
}
|
||||
else if ($linetokens[0] == 'ROUTING_TABLE')
|
||||
{
|
||||
$openvpn['Routing'][] = array ('VIRTADDR' => $linetokens[1],
|
||||
'CN' => str_replace ('_', ' ', $linetokens[2]),
|
||||
'REALADDR' => $linetokens[3],
|
||||
'LAST' => $linetokens[4],
|
||||
'Seconds_Ago' => seconds_string (time () - $linetokens[4])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
/*function openvpn_find_connected ()
|
||||
{
|
||||
global $openvpn;
|
||||
global $openssl;
|
||||
|
||||
// find who is connected
|
||||
if (isset ($openvpn['Client']))
|
||||
$cnconnected = count ($openvpn['Client']);
|
||||
else
|
||||
$cnconnected = 0;
|
||||
$cntotal = count ($openssl['Database']);
|
||||
|
||||
if ($cnconnected > 0)
|
||||
for ($i = 0; $i < $cnconnected; $i++)
|
||||
for ($j = 0; $j < $cntotal; $j++)
|
||||
if ($openvpn['Client'][$i]['CN'] == $openssl['Database'][$j]['CN'])
|
||||
{
|
||||
$openssl['Database'][$j]['Connected'] = true;
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
|
||||
function openvpn_find_connected ()
|
||||
{
|
||||
global $openvpn;
|
||||
global $openssl;
|
||||
|
||||
// find who is connected
|
||||
if (isset ($openvpn['Client']))
|
||||
$cnconnected = count ($openvpn['Client']);
|
||||
else
|
||||
$cnconnected = 0;
|
||||
$cntotal = count ($openssl['Database']);
|
||||
|
||||
if ($cnconnected > 0)
|
||||
{
|
||||
for ($i = 0; $i < $cntotal; $i++)
|
||||
{
|
||||
for ($j = 0; $j < $cnconnected; $j++)
|
||||
{
|
||||
if ($openvpn['Client'][$j]['CN'] == $openssl['Database'][$i]['CN'] && $openssl['Database'][$i]['Status'] != "R")
|
||||
{
|
||||
$openssl['Database'][$i]['Connected'] = true;
|
||||
// break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
11
Admin/Modules/VPNconfig/include/restartvpn.php
Executable file
11
Admin/Modules/VPNconfig/include/restartvpn.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
session_start();
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
|
||||
|
||||
$path = $_REQUEST["path"];
|
||||
// Write to file vpnid_man
|
||||
exec("touch /var/vpn/openvpn_restart");
|
||||
|
||||
header ("Location: ".$path."&uebergabe=2&uebergabe3=1");
|
||||
?>
|
11
Admin/Modules/VPNconfig/include/startvpn.php
Executable file
11
Admin/Modules/VPNconfig/include/startvpn.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
session_start();
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
|
||||
|
||||
$path = $_REQUEST["path"];
|
||||
// Write to file vpnid_man
|
||||
exec("touch /var/vpn/openvpn_start");
|
||||
|
||||
header ("Location: ".$path."&uebergabe=2&uebergabe3=2");
|
||||
?>
|
108
Admin/Modules/VPNconfig/include/status.php
Normal file
108
Admin/Modules/VPNconfig/include/status.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openvpn-functions.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openssl-functions.inc");
|
||||
openvpn_load_server_conf ();
|
||||
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
|
||||
openvpn_load_status ();
|
||||
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
|
||||
openssl_load_database ();
|
||||
?>
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<colgroup>
|
||||
<col width="200">
|
||||
<col>
|
||||
</colgroup>
|
||||
<tr>
|
||||
<td valign="top" width="200">
|
||||
<table border="0" cellpadding="10" cellspacing="0">
|
||||
<tr>
|
||||
<td style="border-top:1px groove black; border-bottom:1px groove black;border-left:1px groove black;border-right:1px groove black;">
|
||||
<b>Server Status</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border-right:1px groove black; border-left:1px groove black;">
|
||||
The OpenVPN server version is <b><font color="darkgreen"><?php echo $openvpn['Server']['Title'];?></font></b><br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border-right:1px groove black; border-left:1px groove black;">
|
||||
The last status was recorded at <b><font color="darkgreen"><?php echo $openvpn['Server']['DateTime'];?> </font></b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border-right:1px groove black; border-left:1px groove black;" nowrap width="5%">
|
||||
<?php echo '';
|
||||
if ($openvpn['Client'] == 0)
|
||||
echo 'No clients connected</b>';
|
||||
elseif ($openvpn['Client'] == 1)
|
||||
echo 'Connected <b><font color="darkgreen">1</font></b> client';
|
||||
elseif ($openvpn['Client'] > 1)
|
||||
{
|
||||
echo 'Connected <b><font color="darkgreen">';
|
||||
echo count($openvpn['Client']);
|
||||
echo '</font></b> clients';
|
||||
}?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border-right:1px groove black; border-bottom:1px groove black; border-left:1px groove black;">
|
||||
OpenSSL has <b><font color="darkgreen">
|
||||
<?php
|
||||
if (count($openssl['Database']) == 0)
|
||||
echo 'no certificates</font></b>';
|
||||
elseif (count($openssl['Database']) == 1)
|
||||
{
|
||||
echo '1</font></b> <a href="';
|
||||
echo $moduleurl;
|
||||
echo '&uebergabe=3">certificate</a>';
|
||||
}
|
||||
elseif (count($openssl['Database']) > 1)
|
||||
{
|
||||
echo '';
|
||||
echo count($openssl['Database']);
|
||||
echo '</font></b> <a href="';
|
||||
echo $moduleurl;
|
||||
echo '&uebergabe=3">certificates</a>';
|
||||
}?>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<table border="0" width="90%" cellspacing="0" cellpadding="4" align="center">
|
||||
<tr valign="top">
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray" bgcolor="#DDFFCC"><b>#</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray" nowrap><b>Common Name</td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray" nowrap><b>Connected since</td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray" nowrap><b>Connected Time</td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray" nowrap><b>Virtual Address</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray" nowrap><b>Real Address</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray" nowrap><b>Upload</b></td>
|
||||
<td style="border-bottom:1px groove gray; border-top:1px groove gray" nowrap><b>Download</b></td>
|
||||
</tr>
|
||||
<?php
|
||||
$count = 0;
|
||||
foreach ($openvpn['Client'] as $client)
|
||||
{
|
||||
$count++;
|
||||
echo '<tr>
|
||||
<td>'.$count.'</td>
|
||||
<td>'.$client["CN"].'</td>
|
||||
<td>'.$client["SINCE"].'</td>
|
||||
<td>'.$client["Seconds_Ago"].'</td>
|
||||
<td>'.$client["VIRTADDR"].'</td>
|
||||
<td>'.$client["REALADDR"].'</td>
|
||||
<td>'.$client["BYTESRCV"].'</td>
|
||||
<td>'.$client["BYTESSND"].'</td>
|
||||
</tr>';
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
11
Admin/Modules/VPNconfig/include/stopvpn.php
Executable file
11
Admin/Modules/VPNconfig/include/stopvpn.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
session_start();
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
|
||||
|
||||
$path = $_REQUEST["path"];
|
||||
// Write to file vpnid_man
|
||||
exec("touch /var/vpn/openvpn_stop");
|
||||
|
||||
header ("Location: ".$path."&uebergabe=2&uebergabe3=3");
|
||||
?>
|
31
Admin/Modules/VPNconfig/include/sys.php
Normal file
31
Admin/Modules/VPNconfig/include/sys.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openvpn-functions.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openssl-functions.inc");
|
||||
openvpn_load_server_conf ();
|
||||
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
|
||||
openvpn_load_status ();
|
||||
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
|
||||
openssl_load_database ();
|
||||
openvpn_find_connected ();
|
||||
?>
|
||||
|
||||
<table border="0" width="100%" cellspacing="0" cellpadding="4">
|
||||
|
||||
<tr valign="top">
|
||||
<td colspan="2" style="border-top:1px groove black; border-bottom:1px groove black"><b>PHP Libraries</b></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC" style="border-bottom:1px groove black">PHP5 OpenSSL Functions</td>
|
||||
<td style="border-bottom:1px groove black"><font color="darkgreen"><?php echo openssl_check_functions (); ?>
|
||||
</font></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC" style="border-bottom:1px groove black">PHP5 ZLib Functions</td>
|
||||
<td style="border-bottom:1px groove black"><font color="darkgreen"><?php echo zlib_check_functions ();?>
|
||||
</font></td>
|
||||
</tr>
|
||||
</table>
|
128
Admin/Modules/VPNconfig/include/viewcert.php
Normal file
128
Admin/Modules/VPNconfig/include/viewcert.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openvpn-functions.inc");
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openssl-functions.inc");
|
||||
openvpn_load_server_conf ();
|
||||
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
|
||||
openvpn_load_status ();
|
||||
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
|
||||
openssl_load_database ();
|
||||
openvpn_find_connected ();
|
||||
|
||||
$openvpn["Certificates"] = $openssl["Database"];
|
||||
$openvpn["Seconds_Ago"] = time () - $openvpn['Server']['Time'];
|
||||
|
||||
$cntotal = count ($openssl['Database']);
|
||||
|
||||
$GETid = $cert;
|
||||
|
||||
$GETidDEC = sscanf ($GETid, '%X');
|
||||
|
||||
for ($j = 0; $j < $cntotal; $j++)
|
||||
if ($openssl['Database'][$j]['Serial'] == $GETid)
|
||||
{
|
||||
$openssl['Database'][$j]['ExpDate'] = str_openssldata_to_string ($openssl['Database'][$j]['ExpDate']);
|
||||
$openssl['Database'][$j]['RevDate'] = str_openssldata_to_string ($openssl['Database'][$j]['RevDate']);
|
||||
$openvpn['Certificate'] = $openssl['Database'][$j];
|
||||
$openvpn['CertificateFileCRT'] = openssl_get_filename ($GETidDEC[0], '.pem');
|
||||
$openvpn['CertificateFileKEY'] = openssl_get_filename ($GETidDEC[0], '.key');
|
||||
$openvpn['CertificateFileCSR'] = openssl_get_filename ($GETidDEC[0], '.csr');
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<table border="0" width="100%" cellspacing="0" cellpadding="4">
|
||||
|
||||
<tr valign="top"><td colspan="2" style="border-top:1px groove black; border-bottom:1px groove black"><b>Certificate Information</b></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Serial</td>
|
||||
<td><font color="blue"><?php echo $openvpn['Certificate']['Serial']; ?>
|
||||
</font></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Status</td>
|
||||
<?php echo '<td><font color="blue">'; ?><?php if ($openvpn['Certificate']['Status'] == 'V'): ?><?php echo 'Valid'; ?><?php elseif ($openvpn['Certificate']['Status'] == 'R'): ?><?php echo 'Revoked'; ?><?php elseif ($openvpn['Certificate']['Status'] == 'E'): ?><?php echo 'Expired'; ?><?php endif; ?><?php echo ''; ?><?php if ($openvpn['Certificate']['Connected']): ?><?php echo ', Now connected'; ?><?php endif; ?><?php echo '</font></td>'; ?>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC" style="border-bottom:1px groove black"><?php echo ''; ?><?php if ($openvpn['Certificate']['Status'] == 'V'): ?><?php echo 'Expiration'; ?><?php elseif ($openvpn['Certificate']['Status'] == 'R'): ?><?php echo 'Revoked'; ?><?php else: ?><?php echo ' '; ?><?php endif; ?><?php echo '</td>'; ?>
|
||||
|
||||
<td style="border-bottom:1px groove black"><font color="darkgreen"><?php echo ''; ?><?php if ($openvpn['Certificate']['Status'] == 'V'): ?><?php echo ''; ?><?php echo $openvpn['Certificate']['ExpDate']; ?><?php echo ''; ?><?php elseif ($openvpn['Certificate']['Status'] == 'R'): ?><?php echo ''; ?><?php echo $openvpn['Certificate']['RevDate']; ?><?php echo ''; ?><?php else: ?><?php echo ' '; ?><?php endif; ?><?php echo '</font></td>'; ?>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Common Name</td>
|
||||
<td><font color="blue"><?php echo $openvpn['Certificate']['CN']; ?>
|
||||
</font></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC" style="border-bottom:1px groove black">e-mail</td>
|
||||
<td style="border-bottom:1px groove black"><font color="darkgreen"><?php echo ''; ?><?php if ($openvpn['Certificate']['Email'] != ''): ?><?php echo '<a href="mailto:'; ?><?php echo $openvpn['Certificate']['Email']; ?><?php echo '">'; ?><?php echo $openvpn['Certificate']['Email']; ?><?php echo '</a>'; ?><?php else: ?><?php echo ' '; ?><?php endif; ?><?php echo '</font></td>'; ?>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Country</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Certificate']['Country']; ?>
|
||||
</font></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">State or Province</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Certificate']['State']; ?>
|
||||
</font></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">City</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Certificate']['City']; ?>
|
||||
</font></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Company</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Certificate']['Company']; ?>
|
||||
</font></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Department</td>
|
||||
<td><font color="darkgreen"><?php echo $openvpn['Certificate']['Department']; ?>
|
||||
</font></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><td colspan="2" style="border-top:1px groove black; border-bottom:1px groove black"><b>Certificate Files</b></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Public Certificate</td>
|
||||
<td><?php echo ''; ?><?php if ($openvpn['CertificateFileCRT'] != ''): ?><?php echo '<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificate']['Serial']; ?><?php echo '&Type=CRT" title=\'Download Public Certificate\'>Download</a>'; ?><?php else: ?><?php echo '<File not found>'; ?><?php endif; ?><?php echo ''; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Private Key</td>
|
||||
<td><?php echo ''; ?><?php if ($openvpn['CertificateFileKEY'] != ''): ?><?php echo '<a href="g/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificate']['Serial']; ?><?php echo '&Type=KEY" title=\'Download Private Key\'>Download</a>'; ?><?php else: ?><?php echo '<File not found>'; ?><?php endif; ?><?php echo ''; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td style="border-bottom:1px groove black" nowrap width="1%" align="right" bgcolor="#DDFFCC">Certificate Request</td>
|
||||
<td style="border-bottom:1px groove black"><?php echo ''; ?><?php if ($openvpn['CertificateFileCSR'] != ''): ?><?php echo '<a href=/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificate']['Serial']; ?><?php echo '&Type=CSR" title=\'Download Certificate Request\'>Download</a>'; ?><?php else: ?><?php echo '<File not found>'; ?><?php endif; ?><?php echo ''; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td style="border-bottom:1px groove black" nowrap width="1%" align="right" bgcolor="#DDFFCC">Archive</td>
|
||||
<td style="border-bottom:1px groove black"><?php echo ''; ?><?php if ($openvpn['CertificateFileCRT'] != '' || $openvpn['CertificateFileKEY'] != '' || $openvpn['CertificateFileCSR'] != ''): ?><?php echo '<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificate']['Serial']; ?><?php echo '&Type=ZIP" title=\'Download all files in one archive\'>Download</a>'; ?><?php else: ?><?php echo '<File not found>'; ?><?php endif; ?><?php echo ''; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
113
Admin/Modules/VPNconfig/include/zip.lib.php
Executable file
113
Admin/Modules/VPNconfig/include/zip.lib.php
Executable file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyrights are following:
|
||||
*
|
||||
* Eric Mueller <eric@themepark.com>
|
||||
* http://www.zend.com/codex.php?id=535&single=1
|
||||
*
|
||||
* Denis125 <webmaster@atlant.ru>
|
||||
* http://www.zend.com/codex.php?id=470&single=1
|
||||
*
|
||||
* Peter Listiak <mlady@users.sourceforge.net>
|
||||
*
|
||||
* PK ZIP
|
||||
* http://www.pkware.com/appnote.txt
|
||||
*/
|
||||
|
||||
class zipfile
|
||||
{
|
||||
var $datasec = array ();
|
||||
var $ctrl_dir = array ();
|
||||
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
|
||||
var $old_offset = 0;
|
||||
|
||||
function unix2DosTime ($unixtime = 0)
|
||||
{
|
||||
$timearray = ($unixtime == 0) ?
|
||||
getdate () :
|
||||
getdate ($unixtime);
|
||||
|
||||
if ($timearray['year'] < 1980)
|
||||
{
|
||||
$timearray['year'] = 1980;
|
||||
$timearray['mon'] = 1;
|
||||
$timearray['mday'] = 1;
|
||||
$timearray['hours'] = 0;
|
||||
$timearray['minutes'] = 0;
|
||||
$timearray['seconds'] = 0;
|
||||
}
|
||||
|
||||
return (($timearray['year'] - 1980) << 25) |
|
||||
($timearray['mon'] << 21) |
|
||||
($timearray['mday'] << 16) |
|
||||
($timearray['hours'] << 11) |
|
||||
($timearray['minutes'] << 5) |
|
||||
($timearray['seconds'] >> 1);
|
||||
}
|
||||
|
||||
function addFile ($data, $name, $time = 0)
|
||||
{
|
||||
$name = str_replace ('\\', '/', $name);
|
||||
|
||||
$dtime = dechex ($this->unix2DosTime ($time));
|
||||
$hexdtime = '\x' . $dtime[6] . $dtime[7] .
|
||||
'\x' . $dtime[4] . $dtime[5] .
|
||||
'\x' . $dtime[2] . $dtime[3] .
|
||||
'\x' . $dtime[0] . $dtime[1];
|
||||
eval ('$hexdtime = "' . $hexdtime . '";');
|
||||
|
||||
$unc_len = strlen ($data);
|
||||
$crc = crc32 ($data);
|
||||
$zdata = gzcompress ($data);
|
||||
$zdata = substr (substr ($zdata, 0, strlen ($zdata) - 4), 2);
|
||||
$c_len = strlen ($zdata);
|
||||
|
||||
$fr = "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00" .
|
||||
$hexdtime .
|
||||
pack ('V', $crc) .
|
||||
pack ('V', $c_len) .
|
||||
pack ('V', $unc_len) .
|
||||
pack ('v', strlen ($name)) .
|
||||
pack ('v', 0) .
|
||||
$name .
|
||||
$zdata .
|
||||
pack ('V', $crc) .
|
||||
pack ('V', $c_len) .
|
||||
pack ('V', $unc_len);
|
||||
|
||||
$this -> datasec[] = $fr;
|
||||
|
||||
$cdrec = "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00" .
|
||||
$hexdtime .
|
||||
pack ('V', $crc) .
|
||||
pack ('V', $c_len) .
|
||||
pack ('V', $unc_len) .
|
||||
pack ('v', strlen ($name)) .
|
||||
pack ('v', 0 ) .
|
||||
pack ('v', 0 ) .
|
||||
pack ('v', 0 ) .
|
||||
pack ('v', 0 ) .
|
||||
pack ('V', 32 ) .
|
||||
pack ('V', $this -> old_offset ) .
|
||||
$name;
|
||||
|
||||
$this -> old_offset += strlen ($fr);
|
||||
$this -> ctrl_dir[] = $cdrec;
|
||||
}
|
||||
|
||||
function file ()
|
||||
{
|
||||
$data = implode ('', $this -> datasec);
|
||||
$ctrldir = implode ('', $this -> ctrl_dir);
|
||||
|
||||
return $data .
|
||||
$ctrldir .
|
||||
$this -> eof_ctrl_dir .
|
||||
pack ('v', sizeof ($this -> ctrl_dir)) .
|
||||
pack ('v', sizeof ($this -> ctrl_dir)) .
|
||||
pack ('V', strlen ($ctrldir)) .
|
||||
pack ('V', strlen ($data)) .
|
||||
"\x00\x00";
|
||||
}
|
||||
}
|
||||
?>
|
65
Admin/Modules/VPNconfig/index.php
Executable file
65
Admin/Modules/VPNconfig/index.php
Executable file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
$moduleurl = $_SERVER["REQUEST_URI"];
|
||||
$urlcut = strpos($moduleurl, "&");
|
||||
if($urlcut > 0)
|
||||
{
|
||||
$moduleurl = substr($moduleurl,0,$urlcut);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(strpos($moduleurl, "?") == 0)
|
||||
{
|
||||
$moduleurl = $_SERVER["REQUEST_URI"]."?site=1";
|
||||
}
|
||||
}
|
||||
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
|
||||
//include_once ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
|
||||
//include_once ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
|
||||
|
||||
$mode = $_REQUEST["uebergabe"];
|
||||
$cert = $_REQUEST["uebergabe2"];
|
||||
|
||||
echo" <p><a href=\"".$moduleurl."&uebergabe=0\">Home</a>
|
||||
| <a href=\"".$moduleurl."&uebergabe=1\">Status</a>
|
||||
| <a href=\"".$moduleurl."&uebergabe=2\">Config</a>
|
||||
| <a href=\"".$moduleurl."&uebergabe=3\">Certificates</a>
|
||||
| <a href=\"".$moduleurl."&uebergabe=6\">IP-List</a>
|
||||
| <a href=\"".$moduleurl."&uebergabe=7\">Config-Editor</a>
|
||||
| <a href=\"".$moduleurl."&uebergabe=4\">Systemcheck</a><hr /><br />";
|
||||
|
||||
switch($mode)
|
||||
{
|
||||
case 1:
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/status.php");
|
||||
break;
|
||||
case 2:
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/config.php");
|
||||
break;
|
||||
case 3:
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/certs.php");
|
||||
break;
|
||||
case 4:
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/sys.php");
|
||||
break;
|
||||
case 5:
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/viewcert.php");
|
||||
break;
|
||||
case 6:
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/ipp.php");
|
||||
break;
|
||||
case 7:
|
||||
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/config-edit.php");
|
||||
break;
|
||||
default:
|
||||
echo"<h1><b>VPN Configuration</b></h1>
|
||||
<h2>Choose an action:</h2>
|
||||
<p># <a href=\"".$moduleurl."&uebergabe=1\">Status</a></p>
|
||||
<p># <a href=\"".$moduleurl."&uebergabe=2\">Config</a></p>
|
||||
<p># <a href=\"".$moduleurl."&uebergabe=3\">Certificates</a></p>
|
||||
<p># <a href=\"".$moduleurl."&uebergabe=6\">IP-List</a></p>
|
||||
<p># <a href=\"".$moduleurl."&uebergabe=7\">Config Editor</a></p>
|
||||
<p># <a href=\"".$moduleurl."&uebergabe=4\">Systemcheck</a></p><br />";
|
||||
break;
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user