oidc-registration-php/list.php

115 lines
3.4 KiB
PHP

<?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'];
$listArray = [];
$db = new PDO("pgsql:host=localhost;port=5432;dbname=oidc_db;user=$dbUser;password=$dbPass");
// $sql = "select id, site_name, site_owner, client_id, deleted_at, created_at from clients where owner_id = '$clientDN' and deleted_at is null";
$sql = "select id, site_name, site_owner, client_id, deleted_at, created_at from clients where owner_id = '$clientDN' ";
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['created_at'] = $row['created_at'];
$data['deleted_at'] = $row['deleted_at'];
$listArray[] = $data;
}
$itemCount = count($listArray);
?>
<div class="scrollDiv" style=" line-height: normal; border: 5px outset blue; padding: 1em; background-color: lightblue" >
<p>
This page shows you all of the sites
that you have registered here, and their
current status.
</p>
<div style="/* position:fixed; top: 270px; left: 30px; padding: 15px; width: 80%; */ background-color: lightblue">
<h3>List of Site Registrations</h3>
<div>
<table style="border: solid 1px black ; border-collapse: collapse">
<tr>
<th>
Site Name
</th>
<th>
Site Owner
</th>
<th>
Client ID
</th>
<th>
Created
</th>
<th>
Status
</th>
</tr>
<?php
for ($i = 0; $i < $itemCount; $i++) {
echo "<tr>";
echo "<td>";
$site_name = $listArray[$i]["site_name"];
echo "$site_name";
echo "</td>";
echo "<td>";
$site_owner = $listArray[$i]["site_owner"];
echo "$site_owner";
echo "</td>";
echo "<td>";
$client_id = $listArray[$i]["client_id"];
echo "$client_id";
echo "</td>";
echo "<td>";
$createdAt = new DateTime($listArray[$i]["created_at"]);
$createdAtStr = date_format($createdAt, 'Y-m-d H:i:s');
echo "$createdAtStr";
echo "</td>";
echo "<td>";
if ( is_null($listArray[$i]["deleted_at"]) ) {
echo "Active";
} else {
echo "Deleted";
}
echo "</td>";
echo "</tr>";
}
?>
</table>
</div>
<br>
<br>
<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>";