2 Commits

Author SHA1 Message Date
boris
8de2b7f29e (airhead): ive no idea no lie
Signed-off-by: boris <boris@borishub.co.uk>
2024-12-04 21:13:46 +00:00
boris
5b0d04b702 (feat): added captcha for invalid login 2024-12-04 01:37:17 +00:00
33 changed files with 285 additions and 1112 deletions

7
.idea/dataSources.xml generated
View File

@@ -16,5 +16,12 @@
</library>
</libraries>
</data-source>
<data-source source="LOCAL" name="ecobuddynew.sqlite" uuid="6566010b-b220-4baf-bb3e-99178c3287f0">
<driver-ref>sqlite.xerial</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:Databases/ecobuddynew.sqlite</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -23,8 +23,8 @@ class Database {
private function __construct() {
try {
$this->_dbHandle = new PDO("sqlite:Databases/ecobuddy.sqlite");
$this->_dbHandle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->_dbHandle = new PDO("sqlite:Databases/ecobuddynew.sqlite");
$this->_dbHandle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$this->_dbHandle->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
catch (PDOException $e) {

View File

@@ -15,12 +15,23 @@ class FacilityDataSet
/**
* @param $data
* @return bool
* Broken last minute, dont have time to fix.
* add / update facility to database from array of columns
*/
public function addFacility($data): bool
{
$userQuery = "
SELECT ecoUser.id FROM ecoUser
WHERE ecoUser.username = :contributor;
";
$catQuery = "
SELECT ecoCategories.id FROM ecoCategories
WHERE ecoCategories.name = :category;
";
$sqlQuery = "
INSERT INTO ecoFacilities
(title,
INSERT OR REPLACE INTO ecoFacilities
(id,
title,
category,
description,
houseNumber,
@@ -31,34 +42,69 @@ class FacilityDataSet
lng,
lat,
contributor)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, -1, -1, ?)
;";
// gets contributor name
$stmt = $this->_dbHandle->prepare($userQuery);
$stmt->bindParam(':contributor', $data->contributor, PDO::PARAM_STR);
$stmt = $this->_dbHandle->prepare($userQuery);
$stmt->execute();
$data['contributor'] = (int)$stmt->fetch(PDO::FETCH_ASSOC);
// gets category ID
$stmt = $this->_dbHandle->prepare($catQuery);
$stmt->bindParam(':category', $data->category, PDO::PARAM_STR);
$stmt = $this->_dbHandle->prepare($catQuery);
$stmt->execute();
$data['category'] = (int)$stmt->fetch(PDO::FETCH_ASSOC);
// run main query and bind updated parameters
$stmt = $this->_dbHandle->prepare($sqlQuery);
// Ensures only one value is returned per column name
$stmt->setFetchMode(\PDO::FETCH_ASSOC);
// Initialize index for binding
$bindIndex = 1;
// Bind other filters
for ($i = 1; $i <= 8; $i++) { // Assuming 8 other filters
$value = !empty($data[$i]) ? "%" . $data[$i] . "%" : "%";
$stmt->bindValue($bindIndex++, $value, \PDO::PARAM_STR);
if (isset($data['id'])) {
$stmt->bindParam(1, $data['id']);
}
$stmt->bindParam(2, $data['title'], PDO::PARAM_STR);
$stmt->bindParam(3, $data['category'], PDO::PARAM_INT);
$stmt->bindParam(4, $data['description'], PDO::PARAM_STR);
$stmt->bindParam(5, $data['houseNumber'], PDO::PARAM_STR);
$stmt->bindParam(6, $data['streetName'], PDO::PARAM_STR);
$stmt->bindParam(7, $data['county'], PDO::PARAM_STR);
$stmt->bindParam(8, $data['town'], PDO::PARAM_STR);
$stmt->bindParam(9, $data['postcode'], PDO::PARAM_STR);
$stmt->bindParam(10, $data['contributor'], PDO::PARAM_INT);
$stmt->execute();
// var_dump($stmt);
// var_dump($this->_dbHandle->errorInfo());
return !($stmt->rowCount());
}
/**
* @param $id
* @return bool
* Deletes Facility Records being passed a facility id.
*/
public function deleteFacility($id): bool
{
$sqlQuery = "DELETE FROM ecoFacilities WHERE id = ?";
$sqlQuery = "DELETE FROM ecoFacilities WHERE ecoFacilities.id = :id;";
$stmt = $this->_dbHandle->prepare($sqlQuery);
$stmt->setFetchMode(\PDO::FETCH_ASSOC);
$stmt->bindValue(1, $id, \PDO::PARAM_INT);
$stmt->bindValue(':id', (int)$id, \PDO::PARAM_INT);
$stmt->execute();
var_dump($stmt);
echo $stmt->rowCount();
return !($stmt->rowCount() == 0);
}
/**
* @param $filterArray
* @param $sortArray
* @return array
* Fetch all records depending on filters, and sort by defined column
*/
public function fetchAll($filterArray, $sortArray): array
{
// Define columns for filtering and sorting
@@ -127,12 +173,13 @@ class FacilityDataSet
ecoUser.username
ORDER BY {$selectedSortColumn} {$direction};
";
// Surround 'term' with % to allow usage with LIKE
$filterArray['term'] = '%' . $filterArray['term'] . '%' ?? '%';
var_dump($filterArray);
// Prepare and execute the count query
$countStmt = $this->_dbHandle->prepare($countQuery);
$countStmt->bindValue(':term', $filterArray['term'], PDO::PARAM_STR);
$countStmt->execute();
// Set total results to output of count statement
$totalResults = (int)$countStmt->fetchColumn();
// Prepare and execute the data query
@@ -151,65 +198,5 @@ class FacilityDataSet
'count' => $totalResults
];
}
/**
* @param $sqlQuery
* @param $filterArray
* @return false|PDOStatement
* Function for fetchAll() to de-dupe code. Performs binding on PDO statements to facilitate
* filtering of facilities. Returns a bound PDO statement.
*/
// private function populateFields($sqlQuery, $filterArray, $sortBy, $direction)
// {
// $stmt = $this->_dbHandle->prepare($sqlQuery);
// $stmt->setFetchMode(\PDO::FETCH_ASSOC);
//
// // Initialize index for binding
// $bindIndex = 1;
//
// // Bind statusComment filter, required due to comments not being so.
// $statusComment = !empty($filterArray[0]) ? "%" . $filterArray[0] . "%" : null;
// $stmt->bindValue($bindIndex++, $statusComment ?? "%", \PDO::PARAM_STR); // First ?
// $stmt->bindValue($bindIndex++, $statusComment, $statusComment === null ? \PDO::PARAM_NULL : \PDO::PARAM_STR); // Second ?
//
// // Bind other filters
// for ($i = 1; $i <= 8; $i++) { // Assuming 8 other filters
// $value = !empty($filterArray[$i]) ? "%" . $filterArray[$i] . "%" : "%";
// $stmt->bindValue($bindIndex++, $value, \PDO::PARAM_STR);
// }
// return $stmt;
// }
// So i worked on trying to get this to work for 30 minutes and it turns out you
// can never bind column name values to placeholders, and must use column orders
// as integers..... what
// if(isset($sortBy) && isset($direction)) {
// $stmt->bindValue(':sortBy', $sortBy, \PDO::PARAM_STR);
// $stmt->bindValue(':direction', $direction, \PDO::PARAM_STR);
// }
private function populateFields($sqlQuery, $filterArray)
{
$stmt = $this->_dbHandle->prepare($sqlQuery);
$stmt->setFetchMode(\PDO::FETCH_ASSOC);
$bindIndex = 1;
// Bind statusComment (two placeholders required)
$statusComment = $filterArray[0] ?? '%';
$stmt->bindValue($bindIndex++, $statusComment, \PDO::PARAM_STR);
$stmt->bindValue($bindIndex++, $statusComment, \PDO::PARAM_STR);
// Bind other filters
for ($i = 1; $i < count($filterArray); $i++) {
$value = $filterArray[$i] ?? '%';
print_r($i . ":" . $value . "||\n");
$stmt->bindValue($bindIndex++, $value, \PDO::PARAM_STR);
}
// Debugging
//$stmt->debugDumpParams();
return $stmt;
}
}

View File

@@ -10,6 +10,10 @@ class User {
public function getUserId() {
return $this->_userId;
}
/**
* Open session, set field variables
*/
public function __construct() {
session_start();
@@ -17,7 +21,7 @@ class User {
$this->_loggedIn = false;
$this->_userId = "0";
$this->_accessLevel = null;
// if user logged in, set variables.
if(isset($_SESSION['login'])) {
$this->_username = $_SESSION['login'];
$this->_userId = $_SESSION['uid'];
@@ -26,17 +30,6 @@ class User {
}
}
public function init() {
$this->_username = "None";
$this->_userId = "0";
$this->_loggedIn = false;
if(isset($_SESSION['login'])) {
$this->_username = $_SESSION['login'];
$this->_userId = $_SESSION['uid'];
$this->_loggedIn = true;
}
}
private function setAccessLevel($level) {
$this->_accessLevel = $level;
$_SESSION['accessLevel'] = $level;
@@ -44,6 +37,13 @@ class User {
public function getAccessLevel() {
return $this->_accessLevel;
}
/**
* @param $username
* @param $password
* @return bool
* Using a username and password, authenticate a user and assign variables from query
*/
public function Authenticate($username, $password): bool
{
$users = new UserDataSet();
@@ -64,6 +64,10 @@ class User {
}
}
/**
* @return void
* Unset user variables from session, and set variables to default values - destroying session.
*/
public function logout() {
unset($_SESSION['login']);
unset($_SESSION['uid']);

View File

@@ -9,6 +9,12 @@ class UserDataSet {
$this->_dbInstance = Database::getInstance();
$this->_dbHandle = $this->_dbInstance->getDbConnection();
}
/**
* @param $username
* @return mixed
* Query access level of a username, and return their usertype
*/
public function checkAccessLevel($username) {
$sqlQuery = "SELECT ecoUser.userType FROM ecoUser
LEFT JOIN ecoUsertypes ON ecoUser.userType = ecoUsertypes.userType
@@ -18,26 +24,12 @@ class UserDataSet {
$statement->execute();
return $statement->fetch(PDO::FETCH_ASSOC)['userType'];
}
public function fetchAll(): array
{
$sqlQuery = 'SELECT * FROM ecoUser;';
$statement = $this->_dbHandle->prepare($sqlQuery); // prepare a PDO statement
$statement->execute(); // execute the PDO statement
$dataSet = [];
// loop through and read the results of the query and cast
// them into a matching object
while ($row = $statement->fetch()) {
$dataSet[] = new UserData($row);
}
return $dataSet;
}
/**
* @param $username
* @param $password
* @return array
* Authenticate user with query, and return their details
*/
public function checkUserCredentials($username, $password): array
{
@@ -52,16 +44,4 @@ class UserDataSet {
}
return $dataSet;
}
public function fetchUser($username): array
{
$sqlQuery = 'SELECT * FROM ecoUser WHERE username = ?';
$statement = $this->_dbHandle->prepare($sqlQuery);
$statement->execute([$username]);
$dataSet = [];
while ($row = $statement->fetch()) {
$dataSet[] = new UserData($row);
}
return $dataSet;
}
}

View File

View File

@@ -1,15 +1,15 @@
<?php require('template/header.phtml') ?>
<div class="row">
<div class="col-5">
<div class="col-5 me-auto">
<p><?php echo $view->dbMessage; ?></p>
</div>
<div class="col-auto">
<p>Current script <?php echo $_SERVER["PHP_SELF"]; ?></p>
</div>
<form class="col-auto">
<?php require_once('template/createModal.phtml') ?>
</form>
</div>
<div class="row">
<div class="container-fluid p-3">
<div class="container-fluid p-3" id="facilityContent">
<table class="table table-bordered">
<thead>
<tr>
@@ -28,7 +28,7 @@
</tr>
</thead>
<tbody>
<?php foreach ($view->pageData as $facilityData): ?>
<?php foreach ($view->pageData as $facilityData): ?>
<tr>
<td><?= htmlspecialchars($facilityData->getId() ?? 'N/A') ?></td>
<td><?= htmlspecialchars($facilityData->getTitle() ?? 'N/A') ?></td>

View File

@@ -14,14 +14,14 @@
<input name="titlCreate" class="form-control rounded mb-2" placeholder="Title">
<input name="cateCreate" class="form-control rounded mb-2" placeholder="Category">
<input name="descCreate" class="form-control rounded mb-2" placeholder="Description">
<input name="statCreate" class="form-control rounded mb-2" placeholder="Status">
<input name="hnumCreate" class="form-control rounded mb-2" placeholder="House Number">
<input name="strtCreate" class="form-control rounded mb-2" placeholder="Street Name">
<input name="cntyCreate" class="form-control rounded mb-2" placeholder="County">
<input name="townCreate" class="form-control rounded mb-2" placeholder="Town">
<input name="postCreate" class="form-control rounded mb-2" placeholder="Postcode">
<input name="contCreate" class="form-control rounded mb-2" placeholder="Contributor">
</form>
<button type="submit" class="btn bg-primary btn-outline-primary text-light" name="updateButton">Add</button>
<button type="submit" class="btn bg-primary btn-outline-primary text-light" name="createButton">Add</button>
</form>
</div>
<div class="modal-footer">

View File

@@ -9,8 +9,9 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<button type="submit" class="btn bg-danger btn-outline-danger text-light" name="deleteButton">Yes</button>
<form method="post" action="">
<button type="submit" value="delete" class="btn bg-danger btn-outline-danger text-light" name="deleteButton"">Yes</button>
<input type="hidden" name="id" value="<?= $facilityData->getId()?>">
<button type="button" class="btn btn-outline primary btn-primary" data-bs-dismiss="modal">No</button>
</form>
</div>

View File

@@ -1,5 +1,5 @@
</div>
<div class="fixed-bottom mt-auto">
<div class="site-footer fixed-bottom mt-auto">
<div class="col-auto">
<?php require_once('pagination.phtml'); ?>
</div>

View File

@@ -26,12 +26,6 @@
<a class="navbar-brand" href="/index.php"><img id="navIcon" class="img-thumbnail bg-transparent border-3 border-success border-opacity-25 rounded my-1 me-2" height="64px" width="64px" src="/images/ecoBuddy_x64.png" alt=""/><span class="pt-5 mb-auto">Ecobuddy</span></a>
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="/index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
<form class="row m-0 me-2 align-content-center align-content-center align-items-center" role="search" action="" method="POST">
<div class="col">
@@ -88,9 +82,6 @@
<div class="col-sm" id="loginStatus">
<?php
if ($view->loginError) {
require_once('Views/template/loginError.phtml');
}
if(!$view->user->isLoggedIn()) {
require_once('Views/template/loginModal.phtml');
}
@@ -105,8 +96,7 @@
</nav>
<body role="document">
<div class="container-fluid">
<?php /*require_once("sidebar.phtml");*/?>
<div class="main container-fluid">
<div class="col" id="content">

View File

@@ -0,0 +1,18 @@
<span class="ms-5 me-5 row alert alert-danger" role="alert"><?= $view->loginError ?></span>
<div class="row captcha-container">
<!-- CAPTCHA Display -->
<div class="form-floating mb-3 col">
<input type="text" class="form-control" id="captchaCode" value="<?php
// Generate a simple 5-character CAPTCHA
$captcha = substr(str_shuffle("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"), 0, 5);
echo $captcha;
?>" readonly>
<label for="captchaCode">CAPTCHA Code</label>
</div>
<!-- CAPTCHA Input -->
<div class="form-floating mb-3 col">
<input type="text" class="form-control" id="captchaInput" name="captchaInput" placeholder="Enter CAPTCHA" required>
<label for="captchaInput">Enter CAPTCHA</label>
</div>
</div>

View File

@@ -1,7 +1,11 @@
<button type="button" class="btn bg-primary btn-outline-primary text-light m-auto" data-bs-toggle="modal" data-bs-target="#loginModal">
<button type="button" class="btn bg-primary btn-outline-primary text-light m-auto" data-bs-toggle="modal"
data-bs-target="#loginModal">
Login
</button>
<div class="modal fade" id="loginModal" tabindex="-1" aria-labelledby="loginModalLabel" aria-hidden="true">
<?= isset($view->loginError) ? '<div class="modal-backdrop fade show"></div>' : '' ?>
<div class="modal fade <?= isset($view->loginError) ? 'show' : '' ?>" id="loginModal" tabindex="-1"
aria-labelledby="loginModalLabel" aria-hidden="<?= isset($view->loginError) ? 'false' : 'true' ?>"
style="<?= isset($view->loginError) ? 'display: block;' : '' ?>">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
@@ -12,17 +16,23 @@
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" placeholder="Username" required>
<input type="text" class="form-control" id="username" name="username" placeholder="Username"
required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="Password" required>
<input type="password" class="form-control" id="password" name="password" placeholder="Password"
required>
</div>
<button type="submit" class="btn bg-primary btn-outline-primary text-light" name="loginButton">Login</button>
<?php if (isset($view->loginError)) { include('Views/template/loginError.phtml');} ?>
<button type="submit" class="btn bg-primary btn-outline-primary text-light" name="loginButton">Login
</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-warning btn-outline-warning text-light" data-bs-dismiss="modal">Close</button>
<a href="/index.php <?php unset($_GET['modal'])?>" type="button" class="btn btn-warning btn-outline-warning text-light" data-bs-dismiss="modal">
Close
</a>
</div>
</div>
</div>

View File

@@ -4,24 +4,24 @@
<div id="paginationButtons" class="col-auto m-auto btn-group">
<?php
$params = $_GET;
unset($params['page']); // Remove the page parameter to avoid duping
function buildUrl($page, $params): string
$param = $_GET;
unset($param['page']); // Remove the page parameter to avoid duping
function buildUrl($page, $param): string
{
$params['page'] = $page;
return '?' . http_build_query($params);
$param['page'] = $page;
return '?' . http_build_query($param);
}
?>
<!-- Start Button -->
<a class="btn btn-outline-primary" href="<?= buildUrl(0, $params) ?>0" <?= $view->pageNumber <= 0 ? 'disabled' : '' ?>><i class="bi bi-chevron-double-left"></i> Start</a>
<a class="btn btn-outline-primary" href="<?= buildUrl(0, $param) ?>0" <?= $view->pageNumber <= 0 ? 'disabled' : '' ?>><i class="bi bi-chevron-double-left"></i> Start</a>
<!-- Back Button -->
<a class="btn btn-outline-primary" href="<?= buildUrl(max($view->pageNumber - 1, 0), $params)?> " <?= $view->pageNumber <= 0 ? 'disabled' : '' ?>><i class="bi bi-chevron-left"></i> Back</a>
<a class="btn btn-outline-primary" href="<?= buildUrl(max($view->pageNumber - 1, 0), $param)?> " <?= $view->pageNumber <= 0 ? 'disabled' : '' ?>><i class="bi bi-chevron-left"></i> Back</a>
<!-- Dynamic Page Buttons -->
<?php
$totalPages = $view->paginator->getTotalPages();
for ($i = $view->pageNumber - 2; $i <= $view->pageNumber + 2; $i++) {
if ($i >= 0 && $i < $totalPages): ?>
<a href="<?= buildUrl($i, $params) ?>"
<a href="<?= buildUrl($i, $param) ?>"
class="btn <?= $i === $view->pageNumber ? 'btn-dark' : 'btn-outline-primary' ?>"
<?= $i === $view->pageNumber ? 'disabled' : '' ?>>
<?= $i + 1 ?>
@@ -29,9 +29,9 @@
<?php endif;
} ?>
<!-- Forward Button -->
<a class="btn btn-outline-primary" href="<?=buildUrl(min($view->pageNumber + 1, $totalPages), $params)?>" <?= $view->pageNumber >= $totalPages - 1 ? 'disabled' : '' ?>>Forward <i class="bi bi-chevron-right"></i></a>
<a class="btn btn-outline-primary" href="<?=buildUrl(min($view->pageNumber + 1, $totalPages), $param)?>" <?= $view->pageNumber >= $totalPages - 1 ? 'disabled' : '' ?>>Forward <i class="bi bi-chevron-right"></i></a>
<!-- End Button -->
<a class="btn btn-outline-primary" href="<?= buildUrl($totalPages - 1, $params) ?>"<?= $view->pageNumber >= $totalPages - 1 ? 'disabled' : '' ?>>End <i class="bi bi-chevron-double-right"></i></a>
<a class="btn btn-outline-primary" href="<?= buildUrl($totalPages - 1, $param) ?>"<?= $view->pageNumber >= $totalPages - 1 ? 'disabled' : '' ?>>End <i class="bi bi-chevron-double-right"></i></a>
</div>
</div>
</div>

View File

@@ -1,34 +0,0 @@
<div class="col-2" id="sidebar">
<div class="row mt-1 m-0 p-3 border rounded" id="loginStatus">
<?php
if ($view->loginError) {
require_once('Views/template/loginError.phtml');
}
if(!$user->isLoggedIn()) {
require_once('Views/template/loginModal.phtml');
}
if($user->isLoggedIn()) {
require_once('Views/template/logoutButton.phtml');
}
?>
</div>
<div class="row mt-1 m-4 p-3 border rounded" id="filters">
<h4 class="mb-4 text-center">Filter Options</h4>
<form class="form-inline my-2 my-lg-0" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> ">
<!--<input class="btn bg-primary btn-outline-primary text-light" type="submit" name="addFilter" value="+">-->
<input name="0" class="form-control rounded mb-2" placeholder="Title">
<input name="1" class="form-control rounded mb-2" placeholder="Category">
<input name="2" class="form-control rounded mb-2" placeholder="Description">
<input name="3" class="form-control rounded mb-2" placeholder="Status">
<input name="4" class="form-control rounded mb-2" placeholder="Street Name">
<input name="5" class="form-control rounded mb-2" placeholder="County">
<input name="6" class="form-control rounded mb-2" placeholder="Town">
<input name="7" class="form-control rounded mb-2" placeholder="Postcode">
<input name="8" class="form-control rounded mb-2" placeholder="Contributor">
<button name="applyFilters" class="form-control rounded mb-2 mt-3 btn bg-primary border-primary">Update</button>
<button name="clearFilters" class="form-control rounded mb-2 btn bg-danger border-danger">Clear</button>
</form>
</div>
</div>

View File

@@ -1,6 +1,7 @@
<button type="button" class="col btn bg-primary btn-outline-primary text-light" data-bs-toggle="modal" data-bs-target="#updateModal">
<span class="bi bi-pen-fill"></span>
</button>
<div class="modal fade" id="updateModal" tabindex="-1" aria-labelledby="updateModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
@@ -10,18 +11,17 @@
</div>
<div class="modal-body">
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<form class="form-inline" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> ">
<input name="titlUpdate" class="form-control rounded mb-2" placeholder="Title">
<input name="cateUpdate" class="form-control rounded mb-2" placeholder="Category">
<input name="descUpdate" class="form-control rounded mb-2" placeholder="Description">
<input name="statUpdate" class="form-control rounded mb-2" placeholder="Status">
<input name="strtUpdate" class="form-control rounded mb-2" placeholder="Street Name">
<input name="cntyUpdate" class="form-control rounded mb-2" placeholder="County">
<input name="townUpdate" class="form-control rounded mb-2" placeholder="Town">
<input name="postUpdate" class="form-control rounded mb-2" placeholder="Postcode">
<input name="contUpdate" class="form-control rounded mb-2" placeholder="Contributor">
</form>
<input name="titlUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getTitle() ?? '' ?>" placeholder="Title">
<input name="cateUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getCategory() ?? '' ?>" placeholder="Category">
<input name="descUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getDescription() ?? '' ?>" placeholder="Description">
<input name="hnumUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getHouseNumber() ?? '' ?>" placeholder="House Number">
<input name="strtUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getStreetName() ?? '' ?>" placeholder="Street Name">
<input name="cntyUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getCounty() ?? '' ?>" placeholder="County">
<input name="townUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getTown() ?? '' ?>" placeholder="Town">
<input name="postUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getPostcode() ?? '' ?>" placeholder="Postcode">
<input name="contUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getContributor() ?? '' ?>" placeholder="Contributor">
<button type="submit" class="btn bg-primary btn-outline-primary text-light" name="updateButton">Update</button>
<input type="hidden" name="idUpdate" value="<?= $facilityData->getId()?>">
</form>
</div>
<div class="modal-footer">

View File

@@ -2,10 +2,21 @@ nav, #loginStatus, #filters {
background-color: #3cc471;
color: #111
}
#content.full-height {
/*height: calc(100vh - 413px);*/
flex: 1 0 auto;
}
.main {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.facilityContent {
overflow-y: auto;
}
/*body {
overflow-y: hidden;
}*/
#title {
margin-top: 12px;
background-color: #fff;
@@ -52,3 +63,6 @@ nav, #loginStatus, #filters {
.modal-backdrop {
z-index: 1040;
}
.site-footer {
flex: 0 0 auto;
}

Binary file not shown.

View File

@@ -1,24 +1,16 @@
<?php
// load required classes
// load dataset
require_once('Models/UserDataSet.php');
require_once("logincontroller.php");
// make a view class
$view = new stdClass();
$view->pageTitle = 'Home';
//if (isset($_POST['applyAdvFilters'])) {
// array_push($filterArray, $_POST['titlFilter'], $_POST['cateFilter'],
// $description = $_POST['descFilter'], $status = $_POST['statFilter'],
// $street = $_POST['strtFilter'], $county = $_POST['cntyFilter'],
// $town = $_POST['townFilter'], $postcode = $_POST['postFilter'],
// $contributor = $_POST['contFilter']);
//}
// load login controller and pagination controller
require_once("logincontroller.php");
require_once('paginationcontroller.php');
$view->user = new User();
// load main view
require_once('Views/index.phtml');

View File

@@ -2,23 +2,51 @@
require_once("Models/User.php");
// create user and dataset object
$user = new User();
$userDataSet = new UserDataSet();
if (isset($_POST["loginButton"])) {
$username = $_POST["username"];
$password = hash("sha256", $_POST["password"]);
// hash password
$password = (hash("sha256", $_POST["password"]));
// if login error, show captcha
if (isset($view->loginError)) {
$generatedCaptcha = $_POST["generatedCaptcha"];
$userCaptcha = $_POST["captcha"];
// if captcha wrong, say so
if ($generatedCaptcha !== $userCaptcha) {
$view->loginError = "Incorrect CAPTCHA.";
return;
}
}
// create a new student dataset object that we can generate data from
// Error handling is VERY hacky, because of the lack of JS usage.
if($userDataSet->checkUserCredentials($username, $password)) {
$user->Authenticate($username, $password);
}
else {
echo "Error in Uname / Pass";
// Unset modal boolean to hide it's usage.
unset($_GET['modal']);
} else {
// Add error message and redirect to display modal
$view->loginError = "Invalid username or password.";
// Set modal boolean to header to allow modal to reappear
$queryParams = http_build_query(['modal' => 'true']);
header("Location: {$_SERVER['PHP_SELF']}?$queryParams");
exit;
}
}
if(isset($_POST['closeButton'])) {
unset($_GET['modal']);
}
if (isset($_POST["logoutButton"]))
{
$user->logout();
}
// for login errors; show login modal until captcha solved
if (isset($_GET['modal']) && $_GET['modal'] === 'true') {
$view->loginError = $view->loginError ?? "Please solve the Captcha and try again.";
}

View File

@@ -1,39 +0,0 @@
server {
listen 80;
listen [::]:80;
server_name ecobuddy.local;
root /var/www/html;
index index.html index.php;
location / {
try_files $uri $uri/ /index.php$query_string;
# autoindex on;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/error.log error;
sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass ecobuddy-php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_read_timeout 300;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /.ht {
deny all;
}
}

View File

View File

@@ -1,296 +0,0 @@
2024/11/07 13:16:09 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
2024/11/07 13:17:49 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
2024/11/07 13:19:19 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
2024/11/07 13:20:40 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
2024/11/07 13:21:09 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
2024/11/07 13:21:14 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
2024/11/07 13:24:50 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
2024/11/07 13:26:25 [emerg] 1#1: open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:15
2024/11/07 13:28:14 [emerg] 1#1: open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:15
2024/11/07 13:28:34 [notice] 1#1: using the "epoll" event method
2024/11/07 13:28:34 [notice] 1#1: nginx/1.27.2
2024/11/07 13:28:34 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/11/07 13:28:34 [notice] 1#1: OS: Linux 6.8.0-47-generic
2024/11/07 13:28:34 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/11/07 13:28:34 [notice] 1#1: start worker processes
2024/11/07 13:28:34 [notice] 1#1: start worker process 28
2024/11/07 13:28:34 [notice] 1#1: start worker process 29
2024/11/07 13:28:34 [notice] 1#1: start worker process 30
2024/11/07 13:28:34 [notice] 1#1: start worker process 31
2024/11/07 13:28:34 [notice] 1#1: start worker process 32
2024/11/07 13:28:34 [notice] 1#1: start worker process 33
2024/11/07 13:28:34 [notice] 1#1: start worker process 34
2024/11/07 13:28:34 [notice] 1#1: start worker process 35
2024/11/07 13:28:43 [notice] 1#1: signal 3 (SIGQUIT) received, shutting down
2024/11/07 13:28:43 [notice] 28#28: gracefully shutting down
2024/11/07 13:28:43 [notice] 29#29: gracefully shutting down
2024/11/07 13:28:43 [notice] 31#31: gracefully shutting down
2024/11/07 13:28:43 [notice] 33#33: gracefully shutting down
2024/11/07 13:28:43 [notice] 32#32: gracefully shutting down
2024/11/07 13:28:43 [notice] 29#29: exiting
2024/11/07 13:28:43 [notice] 30#30: gracefully shutting down
2024/11/07 13:28:43 [notice] 31#31: exiting
2024/11/07 13:28:43 [notice] 33#33: exiting
2024/11/07 13:28:43 [notice] 28#28: exiting
2024/11/07 13:28:43 [notice] 32#32: exiting
2024/11/07 13:28:43 [notice] 30#30: exiting
2024/11/07 13:28:43 [notice] 29#29: exit
2024/11/07 13:28:43 [notice] 31#31: exit
2024/11/07 13:28:43 [notice] 28#28: exit
2024/11/07 13:28:43 [notice] 33#33: exit
2024/11/07 13:28:43 [notice] 32#32: exit
2024/11/07 13:28:43 [notice] 30#30: exit
2024/11/07 13:28:43 [notice] 34#34: gracefully shutting down
2024/11/07 13:28:43 [notice] 35#35: gracefully shutting down
2024/11/07 13:28:43 [notice] 34#34: exiting
2024/11/07 13:28:43 [notice] 35#35: exiting
2024/11/07 13:28:43 [notice] 34#34: exit
2024/11/07 13:28:43 [notice] 35#35: exit
2024/11/07 13:28:43 [notice] 1#1: signal 17 (SIGCHLD) received from 29
2024/11/07 13:28:43 [notice] 1#1: worker process 29 exited with code 0
2024/11/07 13:28:43 [notice] 1#1: worker process 31 exited with code 0
2024/11/07 13:28:43 [notice] 1#1: worker process 32 exited with code 0
2024/11/07 13:28:43 [notice] 1#1: signal 29 (SIGIO) received
2024/11/07 13:28:43 [notice] 1#1: signal 17 (SIGCHLD) received from 32
2024/11/07 13:28:43 [notice] 1#1: signal 17 (SIGCHLD) received from 28
2024/11/07 13:28:43 [notice] 1#1: worker process 28 exited with code 0
2024/11/07 13:28:43 [notice] 1#1: worker process 35 exited with code 0
2024/11/07 13:28:43 [notice] 1#1: signal 29 (SIGIO) received
2024/11/07 13:28:43 [notice] 1#1: signal 17 (SIGCHLD) received from 35
2024/11/07 13:28:43 [notice] 1#1: signal 17 (SIGCHLD) received from 34
2024/11/07 13:28:43 [notice] 1#1: worker process 33 exited with code 0
2024/11/07 13:28:43 [notice] 1#1: worker process 34 exited with code 0
2024/11/07 13:28:43 [notice] 1#1: signal 17 (SIGCHLD) received from 33
2024/11/07 13:28:43 [notice] 1#1: worker process 30 exited with code 0
2024/11/07 13:28:43 [notice] 1#1: exit
2024/11/07 13:29:29 [emerg] 1#1: unexpected "}" in /etc/nginx/conf.d/default.conf:13
2024/11/07 13:30:12 [emerg] 1#1: unexpected "}" in /etc/nginx/conf.d/default.conf:13
2024/11/07 13:31:43 [emerg] 1#1: unexpected "}" in /etc/nginx/conf.d/default.conf:13
2024/11/07 13:32:29 [emerg] 1#1: host not found in upstream "php-fpm" in /etc/nginx/conf.d/default.conf:26
2024/11/07 13:33:09 [emerg] 1#1: host not found in upstream "ecobuddy-php-fpm" in /etc/nginx/conf.d/default.conf:26
2024/11/07 13:33:22 [notice] 1#1: using the "epoll" event method
2024/11/07 13:33:22 [notice] 1#1: nginx/1.27.2
2024/11/07 13:33:22 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/11/07 13:33:22 [notice] 1#1: OS: Linux 6.8.0-47-generic
2024/11/07 13:33:22 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/11/07 13:33:22 [notice] 1#1: start worker processes
2024/11/07 13:33:22 [notice] 1#1: start worker process 28
2024/11/07 13:33:22 [notice] 1#1: start worker process 29
2024/11/07 13:33:22 [notice] 1#1: start worker process 30
2024/11/07 13:33:22 [notice] 1#1: start worker process 31
2024/11/07 13:33:22 [notice] 1#1: start worker process 32
2024/11/07 13:33:22 [notice] 1#1: start worker process 33
2024/11/07 13:33:22 [notice] 1#1: start worker process 34
2024/11/07 13:33:22 [notice] 1#1: start worker process 35
2024/11/07 13:39:19 [notice] 1#1: signal 3 (SIGQUIT) received, shutting down
2024/11/07 13:39:19 [notice] 29#29: gracefully shutting down
2024/11/07 13:39:19 [notice] 29#29: exiting
2024/11/07 13:39:19 [notice] 29#29: exit
2024/11/07 13:39:19 [notice] 28#28: gracefully shutting down
2024/11/07 13:39:19 [notice] 28#28: exiting
2024/11/07 13:39:19 [notice] 28#28: exit
2024/11/07 13:39:19 [notice] 32#32: gracefully shutting down
2024/11/07 13:39:19 [notice] 31#31: gracefully shutting down
2024/11/07 13:39:19 [notice] 32#32: exiting
2024/11/07 13:39:19 [notice] 31#31: exiting
2024/11/07 13:39:19 [notice] 34#34: gracefully shutting down
2024/11/07 13:39:19 [notice] 33#33: gracefully shutting down
2024/11/07 13:39:19 [notice] 34#34: exiting
2024/11/07 13:39:19 [notice] 33#33: exiting
2024/11/07 13:39:19 [notice] 31#31: exit
2024/11/07 13:39:19 [notice] 32#32: exit
2024/11/07 13:39:19 [notice] 34#34: exit
2024/11/07 13:39:19 [notice] 33#33: exit
2024/11/07 13:39:19 [notice] 35#35: gracefully shutting down
2024/11/07 13:39:19 [notice] 35#35: exiting
2024/11/07 13:39:19 [notice] 35#35: exit
2024/11/07 13:39:19 [notice] 30#30: gracefully shutting down
2024/11/07 13:39:19 [notice] 30#30: exiting
2024/11/07 13:39:19 [notice] 30#30: exit
2024/11/07 13:39:19 [notice] 1#1: signal 17 (SIGCHLD) received from 29
2024/11/07 13:39:19 [notice] 1#1: worker process 29 exited with code 0
2024/11/07 13:39:19 [notice] 1#1: worker process 33 exited with code 0
2024/11/07 13:39:19 [notice] 1#1: signal 29 (SIGIO) received
2024/11/07 13:39:19 [notice] 1#1: signal 17 (SIGCHLD) received from 28
2024/11/07 13:39:19 [notice] 1#1: worker process 28 exited with code 0
2024/11/07 13:39:19 [notice] 1#1: worker process 30 exited with code 0
2024/11/07 13:39:19 [notice] 1#1: worker process 31 exited with code 0
2024/11/07 13:39:19 [notice] 1#1: worker process 34 exited with code 0
2024/11/07 13:39:19 [notice] 1#1: worker process 35 exited with code 0
2024/11/07 13:39:19 [notice] 1#1: signal 29 (SIGIO) received
2024/11/07 13:39:19 [notice] 1#1: signal 17 (SIGCHLD) received from 32
2024/11/07 13:39:19 [notice] 1#1: worker process 32 exited with code 0
2024/11/07 13:39:19 [notice] 1#1: exit
2024/11/07 13:39:26 [notice] 1#1: using the "epoll" event method
2024/11/07 13:39:26 [notice] 1#1: nginx/1.27.2
2024/11/07 13:39:26 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/11/07 13:39:26 [notice] 1#1: OS: Linux 6.8.0-47-generic
2024/11/07 13:39:26 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/11/07 13:39:26 [notice] 1#1: start worker processes
2024/11/07 13:39:26 [notice] 1#1: start worker process 28
2024/11/07 13:39:26 [notice] 1#1: start worker process 29
2024/11/07 13:39:26 [notice] 1#1: start worker process 30
2024/11/07 13:39:26 [notice] 1#1: start worker process 31
2024/11/07 13:39:26 [notice] 1#1: start worker process 32
2024/11/07 13:39:26 [notice] 1#1: start worker process 33
2024/11/07 13:39:26 [notice] 1#1: start worker process 34
2024/11/07 13:39:26 [notice] 1#1: start worker process 35
2024/11/07 13:45:01 [notice] 1#1: signal 3 (SIGQUIT) received, shutting down
2024/11/07 13:45:01 [notice] 28#28: gracefully shutting down
2024/11/07 13:45:01 [notice] 29#29: gracefully shutting down
2024/11/07 13:45:01 [notice] 28#28: exiting
2024/11/07 13:45:01 [notice] 30#30: gracefully shutting down
2024/11/07 13:45:01 [notice] 31#31: gracefully shutting down
2024/11/07 13:45:01 [notice] 30#30: exiting
2024/11/07 13:45:01 [notice] 31#31: exiting
2024/11/07 13:45:01 [notice] 29#29: exiting
2024/11/07 13:45:01 [notice] 28#28: exit
2024/11/07 13:45:01 [notice] 29#29: exit
2024/11/07 13:45:01 [notice] 30#30: exit
2024/11/07 13:45:01 [notice] 32#32: gracefully shutting down
2024/11/07 13:45:01 [notice] 32#32: exiting
2024/11/07 13:45:01 [notice] 32#32: exit
2024/11/07 13:45:01 [notice] 33#33: gracefully shutting down
2024/11/07 13:45:01 [notice] 33#33: exiting
2024/11/07 13:45:01 [notice] 33#33: exit
2024/11/07 13:45:01 [notice] 31#31: exit
2024/11/07 13:45:01 [notice] 34#34: gracefully shutting down
2024/11/07 13:45:01 [notice] 34#34: exiting
2024/11/07 13:45:01 [notice] 34#34: exit
2024/11/07 13:45:01 [notice] 35#35: gracefully shutting down
2024/11/07 13:45:01 [notice] 35#35: exiting
2024/11/07 13:45:01 [notice] 35#35: exit
2024/11/07 13:45:01 [notice] 1#1: signal 17 (SIGCHLD) received from 29
2024/11/07 13:45:01 [notice] 1#1: worker process 29 exited with code 0
2024/11/07 13:45:01 [notice] 1#1: signal 29 (SIGIO) received
2024/11/07 13:45:01 [notice] 1#1: signal 17 (SIGCHLD) received from 30
2024/11/07 13:45:01 [notice] 1#1: worker process 30 exited with code 0
2024/11/07 13:45:01 [notice] 1#1: signal 29 (SIGIO) received
2024/11/07 13:45:01 [notice] 1#1: signal 17 (SIGCHLD) received from 34
2024/11/07 13:45:01 [notice] 1#1: worker process 34 exited with code 0
2024/11/07 13:45:01 [notice] 1#1: worker process 31 exited with code 0
2024/11/07 13:45:01 [notice] 1#1: worker process 28 exited with code 0
2024/11/07 13:45:01 [notice] 1#1: signal 29 (SIGIO) received
2024/11/07 13:45:01 [notice] 1#1: signal 17 (SIGCHLD) received from 31
2024/11/07 13:45:01 [notice] 1#1: worker process 32 exited with code 0
2024/11/07 13:45:01 [notice] 1#1: signal 29 (SIGIO) received
2024/11/07 13:45:01 [notice] 1#1: signal 17 (SIGCHLD) received from 33
2024/11/07 13:45:01 [notice] 1#1: worker process 33 exited with code 0
2024/11/07 13:45:01 [notice] 1#1: signal 29 (SIGIO) received
2024/11/07 13:45:01 [notice] 1#1: signal 17 (SIGCHLD) received from 35
2024/11/07 13:45:01 [notice] 1#1: worker process 35 exited with code 0
2024/11/07 13:45:01 [notice] 1#1: exit
2024/11/07 13:45:03 [notice] 1#1: using the "epoll" event method
2024/11/07 13:45:03 [notice] 1#1: nginx/1.27.2
2024/11/07 13:45:03 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/11/07 13:45:03 [notice] 1#1: OS: Linux 6.8.0-47-generic
2024/11/07 13:45:03 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/11/07 13:45:03 [notice] 1#1: start worker processes
2024/11/07 13:45:03 [notice] 1#1: start worker process 28
2024/11/07 13:45:03 [notice] 1#1: start worker process 29
2024/11/07 13:45:03 [notice] 1#1: start worker process 30
2024/11/07 13:45:03 [notice] 1#1: start worker process 31
2024/11/07 13:45:03 [notice] 1#1: start worker process 32
2024/11/07 13:45:03 [notice] 1#1: start worker process 33
2024/11/07 13:45:03 [notice] 1#1: start worker process 34
2024/11/07 13:45:03 [notice] 1#1: start worker process 35
2024/11/08 10:26:39 [notice] 1#1: signal 3 (SIGQUIT) received, shutting down
2024/11/08 10:26:39 [notice] 28#28: gracefully shutting down
2024/11/08 10:26:39 [notice] 31#31: gracefully shutting down
2024/11/08 10:26:39 [notice] 29#29: gracefully shutting down
2024/11/08 10:26:39 [notice] 30#30: gracefully shutting down
2024/11/08 10:26:39 [notice] 32#32: gracefully shutting down
2024/11/08 10:26:39 [notice] 28#28: exiting
2024/11/08 10:26:39 [notice] 31#31: exiting
2024/11/08 10:26:39 [notice] 29#29: exiting
2024/11/08 10:26:39 [notice] 33#33: gracefully shutting down
2024/11/08 10:26:39 [notice] 30#30: exiting
2024/11/08 10:26:39 [notice] 32#32: exiting
2024/11/08 10:26:39 [notice] 33#33: exiting
2024/11/08 10:26:39 [notice] 29#29: exit
2024/11/08 10:26:39 [notice] 31#31: exit
2024/11/08 10:26:39 [notice] 28#28: exit
2024/11/08 10:26:39 [notice] 30#30: exit
2024/11/08 10:26:39 [notice] 32#32: exit
2024/11/08 10:26:39 [notice] 33#33: exit
2024/11/08 10:26:39 [notice] 34#34: gracefully shutting down
2024/11/08 10:26:39 [notice] 34#34: exiting
2024/11/08 10:26:39 [notice] 35#35: gracefully shutting down
2024/11/08 10:26:39 [notice] 34#34: exit
2024/11/08 10:26:39 [notice] 35#35: exiting
2024/11/08 10:26:39 [notice] 35#35: exit
2024/11/08 10:26:39 [notice] 1#1: signal 17 (SIGCHLD) received from 31
2024/11/08 10:26:39 [notice] 1#1: worker process 31 exited with code 0
2024/11/08 10:26:39 [notice] 1#1: signal 29 (SIGIO) received
2024/11/08 10:26:39 [notice] 1#1: signal 17 (SIGCHLD) received from 33
2024/11/08 10:26:39 [notice] 1#1: worker process 29 exited with code 0
2024/11/08 10:26:39 [notice] 1#1: worker process 33 exited with code 0
2024/11/08 10:26:39 [notice] 1#1: signal 29 (SIGIO) received
2024/11/08 10:26:39 [notice] 1#1: signal 17 (SIGCHLD) received from 30
2024/11/08 10:26:39 [notice] 1#1: worker process 30 exited with code 0
2024/11/08 10:26:39 [notice] 1#1: worker process 35 exited with code 0
2024/11/08 10:26:39 [notice] 1#1: signal 29 (SIGIO) received
2024/11/08 10:26:39 [notice] 1#1: signal 17 (SIGCHLD) received from 35
2024/11/08 10:26:39 [notice] 1#1: signal 17 (SIGCHLD) received from 32
2024/11/08 10:26:39 [notice] 1#1: worker process 32 exited with code 0
2024/11/08 10:26:39 [notice] 1#1: signal 29 (SIGIO) received
2024/11/08 10:26:39 [notice] 1#1: signal 17 (SIGCHLD) received from 28
2024/11/08 10:26:39 [notice] 1#1: worker process 28 exited with code 0
2024/11/08 10:26:39 [notice] 1#1: signal 29 (SIGIO) received
2024/11/08 10:26:39 [notice] 1#1: signal 17 (SIGCHLD) received from 34
2024/11/08 10:26:39 [notice] 1#1: worker process 34 exited with code 0
2024/11/08 10:26:39 [notice] 1#1: exit
2024/11/08 10:26:44 [notice] 1#1: using the "epoll" event method
2024/11/08 10:26:44 [notice] 1#1: nginx/1.27.2
2024/11/08 10:26:44 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/11/08 10:26:44 [notice] 1#1: OS: Linux 6.8.0-47-generic
2024/11/08 10:26:44 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/11/08 10:26:44 [notice] 1#1: start worker processes
2024/11/08 10:26:44 [notice] 1#1: start worker process 28
2024/11/08 10:26:44 [notice] 1#1: start worker process 29
2024/11/08 10:26:44 [notice] 1#1: start worker process 30
2024/11/08 10:26:44 [notice] 1#1: start worker process 31
2024/11/08 10:26:44 [notice] 1#1: start worker process 32
2024/11/08 10:26:44 [notice] 1#1: start worker process 33
2024/11/08 10:26:44 [notice] 1#1: start worker process 34
2024/11/08 10:26:44 [notice] 1#1: start worker process 35
2024/11/14 12:16:12 [notice] 1#1: signal 3 (SIGQUIT) received, shutting down
2024/11/14 12:16:12 [notice] 28#28: gracefully shutting down
2024/11/14 12:16:12 [notice] 29#29: gracefully shutting down
2024/11/14 12:16:12 [notice] 30#30: gracefully shutting down
2024/11/14 12:16:12 [notice] 31#31: gracefully shutting down
2024/11/14 12:16:12 [notice] 34#34: gracefully shutting down
2024/11/14 12:16:12 [notice] 32#32: gracefully shutting down
2024/11/14 12:16:12 [notice] 28#28: exiting
2024/11/14 12:16:12 [notice] 29#29: exiting
2024/11/14 12:16:12 [notice] 30#30: exiting
2024/11/14 12:16:12 [notice] 33#33: gracefully shutting down
2024/11/14 12:16:12 [notice] 31#31: exiting
2024/11/14 12:16:12 [notice] 34#34: exiting
2024/11/14 12:16:12 [notice] 32#32: exiting
2024/11/14 12:16:12 [notice] 33#33: exiting
2024/11/14 12:16:12 [notice] 29#29: exit
2024/11/14 12:16:12 [notice] 28#28: exit
2024/11/14 12:16:12 [notice] 30#30: exit
2024/11/14 12:16:12 [notice] 31#31: exit
2024/11/14 12:16:12 [notice] 34#34: exit
2024/11/14 12:16:12 [notice] 32#32: exit
2024/11/14 12:16:12 [notice] 33#33: exit
2024/11/14 12:16:12 [notice] 35#35: gracefully shutting down
2024/11/14 12:16:12 [notice] 35#35: exiting
2024/11/14 12:16:12 [notice] 35#35: exit
2024/11/14 12:16:12 [notice] 1#1: signal 17 (SIGCHLD) received from 30
2024/11/14 12:16:12 [notice] 1#1: worker process 28 exited with code 0
2024/11/14 12:16:12 [notice] 1#1: worker process 30 exited with code 0
2024/11/14 12:16:12 [notice] 1#1: worker process 31 exited with code 0
2024/11/14 12:16:12 [notice] 1#1: worker process 32 exited with code 0
2024/11/14 12:16:12 [notice] 1#1: worker process 33 exited with code 0
2024/11/14 12:16:12 [notice] 1#1: worker process 34 exited with code 0
2024/11/14 12:16:12 [notice] 1#1: signal 29 (SIGIO) received
2024/11/14 12:16:12 [notice] 1#1: signal 17 (SIGCHLD) received from 28
2024/11/14 12:16:12 [notice] 1#1: signal 17 (SIGCHLD) received from 35
2024/11/14 12:16:12 [notice] 1#1: worker process 35 exited with code 0
2024/11/14 12:16:12 [notice] 1#1: signal 29 (SIGIO) received
2024/11/14 12:16:12 [notice] 1#1: signal 17 (SIGCHLD) received from 29
2024/11/14 12:16:12 [notice] 1#1: worker process 29 exited with code 0
2024/11/14 12:16:12 [notice] 1#1: exit

View File

@@ -1,32 +0,0 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}

View File

@@ -1,5 +0,0 @@
FROM php:8.3-fpm
RUN apt-get update && apt-get install -y \
php8.3-pdo

View File

@@ -1,490 +0,0 @@
; Start a new pool named 'www'.
; the variable $pool can be used in any directive and will be replaced by the
; pool name ('www' here)
[www]
; Per pool prefix
; It only applies on the following directives:
; - 'access.log'
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or NONE) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool
; Unix user/group of the child processes. This can be used only if the master
; process running user is root. It is set after the child process is created.
; The user and group can be specified either by their name or by their numeric
; IDs.
; Note: If the user is root, the executable needs to be started with
; --allow-to-run-as-root option to work.
; Default Values: The user is set to master process running user by default.
; If the group is not set, the user's group is used.
user = 101
group = 101
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000
; Set listen(2) backlog.
; Default Value: 511 (-1 on Linux, FreeBSD and OpenBSD)
;listen.backlog = 511
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions. The owner
; and group can be specified either by name or by their numeric IDs.
; Default Values: Owner is set to the master process running user. If the group
; is not set, the owner's group is used. Mode is set to 0660.
;listen.owner = www-data
;listen.group = www-data
;listen.mode = 0660
; When POSIX Access Control Lists are supported you can set them using
; these options, value is a comma separated list of user/group names.
; When set, listen.owner and listen.group are ignored
;listen.acl_users =
;listen.acl_groups =
; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
;listen.allowed_clients = 127.0.0.1
; Set the associated the route table (FIB). FreeBSD only
; Default Value: -1
;listen.setfib = 1
; Specify the nice(2) priority to apply to the pool processes (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
; - The pool processes will inherit the master process priority
; unless it specified otherwise
; Default Value: no set
; process.priority = -19
; Set the process dumpable flag (PR_SET_DUMPABLE prctl for Linux or
; PROC_TRACE_CTL procctl for FreeBSD) even if the process user
; or group is different than the master process user. It allows to create process
; core dump and ptrace the process for the pool user.
; Default Value: no
; process.dumpable = yes
; Choose how the process manager will control the number of child processes.
; Possible Values:
; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the
; following directives. With this process management, there will be
; always at least 1 children.
; pm.max_children - the maximum number of children that can
; be alive at the same time.
; pm.start_servers - the number of children created on startup.
; pm.min_spare_servers - the minimum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is less than this
; number then some children will be created.
; pm.max_spare_servers - the maximum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is greater than this
; number then some children will be killed.
; pm.max_spawn_rate - the maximum number of rate to spawn child
; processes at once.
; ondemand - no children are created at startup. Children will be forked when
; new requests will connect. The following parameter are used:
; pm.max_children - the maximum number of children that
; can be alive at the same time.
; pm.process_idle_timeout - The number of seconds after which
; an idle process will be killed.
; Note: This value is mandatory.
pm = dynamic
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 5
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: (min_spare_servers + max_spare_servers) / 2
pm.start_servers = 2
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 1
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 3
; The number of rate to spawn child processes at once.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
; Default Value: 32
;pm.max_spawn_rate = 32
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
;pm.max_requests = 500
; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. It shows the following information:
; pool - the name of the pool;
; process manager - static, dynamic or ondemand;
; start time - the date and time FPM has started;
; start since - number of seconds since FPM has started;
; accepted conn - the number of request accepted by the pool;
; listen queue - the number of request in the queue of pending
; connections (see backlog in listen(2));
; max listen queue - the maximum number of requests in the queue
; of pending connections since FPM has started;
; listen queue len - the size of the socket queue of pending connections;
; idle processes - the number of idle processes;
; active processes - the number of active processes;
; total processes - the number of idle + active processes;
; max active processes - the maximum number of active processes since FPM
; has started;
; max children reached - number of times, the process limit has been reached,
; when pm tries to start more children (works only for
; pm 'dynamic' and 'ondemand');
; Value are updated in real time.
; Example output:
; pool: www
; process manager: static
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 62636
; accepted conn: 190460
; listen queue: 0
; max listen queue: 1
; listen queue len: 42
; idle processes: 4
; active processes: 11
; total processes: 15
; max active processes: 12
; max children reached: 0
;
; By default the status page output is formatted as text/plain. Passing either
; 'html', 'xml' or 'json' in the query string will return the corresponding
; output syntax. Example:
; http://www.foo.bar/status
; http://www.foo.bar/status?json
; http://www.foo.bar/status?html
; http://www.foo.bar/status?xml
;
; By default the status page only outputs short status. Passing 'full' in the
; query string will also return status for each pool process.
; Example:
; http://www.foo.bar/status?full
; http://www.foo.bar/status?json&full
; http://www.foo.bar/status?html&full
; http://www.foo.bar/status?xml&full
; The Full status returns for each process:
; pid - the PID of the process;
; state - the state of the process (Idle, Running, ...);
; start time - the date and time the process has started;
; start since - the number of seconds since the process has started;
; requests - the number of requests the process has served;
; request duration - the duration in µs of the requests;
; request method - the request method (GET, POST, ...);
; request URI - the request URI with the query string;
; content length - the content length of the request (only with POST);
; user - the user (PHP_AUTH_USER) (or '-' if not set);
; script - the main script called (or '-' if not set);
; last request cpu - the %cpu the last request consumed
; it's always 0 if the process is not in Idle state
; because CPU calculation is done when the request
; processing has terminated;
; last request memory - the max amount of memory the last request consumed
; it's always 0 if the process is not in Idle state
; because memory calculation is done when the request
; processing has terminated;
; If the process is in Idle state, then informations are related to the
; last request the process has served. Otherwise informations are related to
; the current request being served.
; Example output:
; ************************
; pid: 31330
; state: Running
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 63087
; requests: 12808
; request duration: 1250261
; request method: GET
; request URI: /test_mem.php?N=10000
; content length: 0
; user: -
; script: /home/fat/web/docs/php/test_mem.php
; last request cpu: 0.00
; last request memory: 0
;
; Note: There is a real-time FPM status monitoring sample web page available
; It's available in: /usr/local/share/php/fpm/status.html
;
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;pm.status_path = /status
; The address on which to accept FastCGI status request. This creates a new
; invisible pool that can handle requests independently. This is useful
; if the main pool is busy with long running requests because it is still possible
; to get the status before finishing the long running requests.
;
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Default Value: value of the listen option
;pm.status_listen = 127.0.0.1:9001
; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;ping.path = /ping
; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong
; The access log file
; Default: not set
;access.log = log/$pool.access.log
; The access log format.
; The following syntax is allowed
; %%: the '%' character
; %C: %CPU used by the request
; it can accept the following format:
; - %{user}C for user CPU only
; - %{system}C for system CPU only
; - %{total}C for user + system CPU (default)
; %d: time taken to serve the request
; it can accept the following format:
; - %{seconds}d (default)
; - %{milliseconds}d
; - %{milli}d
; - %{microseconds}d
; - %{micro}d
; %e: an environment variable (same as $_ENV or $_SERVER)
; it must be associated with embraces to specify the name of the env
; variable. Some examples:
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
; %f: script filename
; %l: content-length of the request (for POST request only)
; %m: request method
; %M: peak of memory allocated by PHP
; it can accept the following format:
; - %{bytes}M (default)
; - %{kilobytes}M
; - %{kilo}M
; - %{megabytes}M
; - %{mega}M
; %n: pool name
; %o: output header
; it must be associated with embraces to specify the name of the header:
; - %{Content-Type}o
; - %{X-Powered-By}o
; - %{Transfert-Encoding}o
; - ....
; %p: PID of the child that serviced the request
; %P: PID of the parent of the child that serviced the request
; %q: the query string
; %Q: the '?' character if query string exists
; %r: the request URI (without the query string, see %q and %Q)
; %R: remote IP address
; %s: status (response code)
; %t: server time the request was received
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; The strftime(3) format must be encapsulated in a %{<strftime_format>}t tag
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
; %T: time the log has been written (the request has finished)
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; The strftime(3) format must be encapsulated in a %{<strftime_format>}t tag
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
; %u: remote user
;
; Default: "%R - %u %t \"%m %r\" %s"
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{milli}d %{kilo}M %C%%"
; A list of request_uri values which should be filtered from the access log.
;
; As a security precuation, this setting will be ignored if:
; - the request method is not GET or HEAD; or
; - there is a request body; or
; - there are query parameters; or
; - the response code is outwith the successful range of 200 to 299
;
; Note: The paths are matched against the output of the access.format tag "%r".
; On common configurations, this may look more like SCRIPT_NAME than the
; expected pre-rewrite URI.
;
; Default Value: not set
;access.suppress_path[] = /ping
;access.suppress_path[] = /health_check.php
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
;slowlog = log/$pool.log.slow
; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0
; Depth of slow log stack trace.
; Default Value: 20
;request_slowlog_trace_depth = 20
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0
; The timeout set by 'request_terminate_timeout' ini option is not engaged after
; application calls 'fastcgi_finish_request' or when application has finished and
; shutdown functions are being called (registered via register_shutdown_function).
; This option will enable timeout limit to be applied unconditionally
; even in such cases.
; Default Value: no
;request_terminate_timeout_track_finished = no
; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024
; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0
; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever
; possible. However, all PHP paths will be relative to the chroot
; (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot =
; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
;chdir = /var/www/html
; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environment, this can cause some delay in the page
; process time (several ms).
; Default Value: no
;catch_workers_output = yes
; Decorate worker output with prefix and suffix containing information about
; the child that writes to the log and if stdout or stderr is used as well as
; log level and time. This options is used only if catch_workers_output is yes.
; Settings to "no" will output data as written to the stdout or stderr.
; Default value: yes
;decorate_workers_output = no
; Clear environment in FPM workers
; Prevents arbitrary environment variables from reaching FPM worker processes
; by clearing the environment in workers before env vars specified in this
; pool configuration are added.
; Setting to "no" will make all environment variables available to PHP code
; via getenv(), $_ENV and $_SERVER.
; Default Value: yes
;clear_env = no
; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; execute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5 .php7
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp
; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can
; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.
; Note: path INI options can be relative and will be expanded with the prefix
; (pool, global or /usr/local)
; Default Value: nothing is defined by default except the values in php.ini and
; specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M

View File

@@ -1,12 +1,8 @@
<?php
require_once('Models/FacilityDataSet.php');
require_once("Models/Paginator.php");
// If page loads empty, set initial headers
//if(empty($_GET)) {
// header("Location: ?sort=1&dir=asc&category=1&term=&page=0");
// exit;
//}
// Default Filters
$filters = [
'category' => $_GET['category'] ?? '1', // Default category
'term' => $_GET['term'] ?? '', // Default term
@@ -20,10 +16,50 @@ if (empty($_GET)) {
redirectWithFilters($filters);
}
$rowLimit = 5;
// Set row limit
$rowLimit = 7;
// create dataset object
$facilityDataSet = new FacilityDataSet();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
/**
* Unfortunately, ZERO time to fix this, too complex.
*/
if(isset($_POST['updateButton'])) {
$data = [
'id' => $_POST['idUpdate'],
'title' => $_POST['titlUpdate'],
'category' => $_POST['cateUpdate'],
'description' => $_POST['descUpdate'],
'houseNumber' => $_POST['hnumUpdate'],
'streetName' => $_POST['strtUpdate'],
'county' => $_POST['cntyUpdate'],
'town' => $_POST['townUpdate'],
'postcode' => $_POST['postUpdate'],
'lng' => $_POST['lngUpdate'],
'lat' => $_POST['latUpdate'],
'contributor' => $_POST['contUpdate'],
];
$facilityDataSet->addFacility($data);
}
if(isset($_POST['createButton'])) {
$data = [
'title' => $_POST['titlCreate'],
'category' => $_POST['cateCreate'],
'description' => $_POST['descCreate'],
'houseNumber' => $_POST['hnumCreate'],
'streetName' => $_POST['strtCreate'],
'county' => $_POST['cntyCreate'],
'town' => $_POST['townCreate'],
'postcode' => $_POST['postCreate'],
'contributor' => $_POST['contCreate'],
];
$facilityDataSet->addFacility($data);
}
// passes id to delete facility
if (isset($_POST['deleteButton'])) {
$facilityDataSet->deleteFacility($_POST['id']);
}
// Check if filters/sorting changed
$filtersChanged = (
$filters['category'] !== ($_POST['filterCat'] ?? $filters['category']) ||
@@ -32,6 +68,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$filters['dir'] !== ($_POST['dir'] ?? $filters['dir'])
);
// load from post if exists and sanitise, otherwise use defaults
$filters['category'] = filter_input(INPUT_POST, 'filterCat', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? $filters['category'];
$filters['term'] = filter_input(INPUT_POST, 'filter', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? $filters['term'];
$filters['sort'] = filter_input(INPUT_POST, 'sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? $filters['sort'];
@@ -42,22 +79,33 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
redirectWithFilters($filters);
}
$view->pageData = $facilityDataSet->fetchAll(
// fetch page data from database
$view->allPageData = $facilityDataSet->fetchAll(
['category' => $filters['category'], 'term' => $filters['term']],
['sort' => $filters['sort'], 'dir' => $filters['dir']]
);
$view->paginator = new Paginator($rowLimit, $view->pageData);
// set total facility count to view
$view->totalResults = $view->allPageData['count'];
// create paginator object
$view->paginator = new Paginator($rowLimit, $view->allPageData);
// assign page number to view
$view->pageNumber = $view->paginator->getPageFromUri();
// get current page
$view->pageData = $view->paginator->getPage($view->pageNumber);
// Send result count to view
// Send result count to view in format "showing x of y results"
$view->dbMessage = $view->paginator->countPageResults($view->pageNumber) == 0
? "No results"
: $view->paginator->countPageResults($view->pageNumber) . " result(s)";
: "Showing " . $view->paginator->countPageResults($view->pageNumber) . " of " . $view->totalResults . " result(s)";
// Redirect function
// Redirect function, adds header parameters
function redirectWithFilters($filters) {
// Ensure no unintended keys are passed
$allowedKeys = ['category', 'term', 'sort', 'dir', 'page'];
$filters = array_filter($filters, function($key) use ($allowedKeys) {
return in_array($key, $allowedKeys);
}, ARRAY_FILTER_USE_KEY);
$queryString = http_build_query($filters);
header("Location: ?" . $queryString);
exit;

View File

@@ -1,10 +0,0 @@
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
echo "Form submitted successfully.<br>";
echo "<pre>";
print_r($_POST);
echo "</pre>";
} else {
echo "No POST request received.";
}