OpenVPN_Management_GUI/Admin/Modules/VPNconfig/include/certs (Kopie).php

87 lines
6.4 KiB
PHP
Raw Normal View History

2012-07-16 21:30:19 +02:00
<?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%">&nbsp;</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 '&nbsp;'; ?><?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 '&nbsp;'; ?><?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>