oidc-registration-php/delete.php

114 lines
3.6 KiB
PHP
Raw Normal View History

2024-09-06 20:00:02 +00:00
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
echo file_get_contents("html/header.html");
$ini_arr = parse_ini_file( "cacert.ini", true );
$dbUser = $ini_arr[ 'DB' ][ 'User' ];
$dbPass = $ini_arr[ 'DB' ][ 'Password' ];
$clientDN = $_SERVER['SSL_CLIENT_S_DN'];
$radioArray = [];
$db = new PDO("pgsql:host=localhost;port=5432;dbname=oidc_db;user=$dbUser;password=$dbPass");
$sql = "select id, site_name, site_owner, client_id, owner_id, created_at from clients where owner_id = '$clientDN' and deleted_at is null";
foreach ($db->query($sql) as $row) {
$data['id'] = $row['id'];
$data['site_name'] = $row['site_name'];
$data['site_owner'] = $row['site_owner'];
$data['client_id'] = $row['client_id'];
$data['owner_id'] = $row['owner_id'];
$data['created_at'] = $row['created_at'];
$radioArray[] = $data;
}
$itemCount = count($radioArray);
?>
<div class="scrollDiv" style=" border: 5px outset blue; padding: 1em; ">
<p>
This page allows you to remove a site registration that
you have created with this tool.
</p>
<h3>Choose a Site Registration to Delete</h3>
<form id="delete_form" action="delete1.php" method="post" enctype="application/x-www-form-urlencoded">
<div>
<table style="border: solid 1px black ; border-collapse: collapse">
<tr>
<th>
&nbsp;
</th>
<th>
Site Name
</th>
<th>
Site Owner
</th>
<th>
Owner ID
</th>
<th>
Date Created
</th>
</tr>
<?php
for ($i = 0; $i < $itemCount; $i++) {
echo "<tr>";
echo "<td>";
echo "<input type='radio' id='radiobtn' name='radiobtn' value='$i' />";
echo "</td>";
echo "<td>";
$site_name = $radioArray[$i]["site_name"];
echo "$site_name";
echo "</td>";
echo "<td>";
$site_owner = $radioArray[$i]["site_owner"];
echo "$site_owner";
echo "</td>";
echo "<td>";
$owner_id = $radioArray[$i]["owner_id"];
echo "$owner_id";
$client_id = $radioArray[$i]["client_id"];
echo "<input type='hidden' id='client_id[$i]' name='client_id[$i]' value='$client_id' />";
echo "</td>";
echo "<td>";
$createdAt = new DateTime($radioArray[$i]["created_at"]);
$createdAtStr = date_format($createdAt, 'Y-m-d H:i:s');
echo "$createdAtStr";
echo "</td>";
echo "</tr>";
}
?>
</table>
</div>
<br>
<input type="submit" name="deleteit" value="Remove Site Registration"/>
</form>
<br>
<br>
<?php
echo "<div class='pageFooter'>";
echo file_get_contents("html/footer.html");
echo "<br>";
echo '<p>Copyright © CAcert, Inc ';
echo date("Y");
echo "</p>";
echo "</div>";
echo "</div>";