7 Commits

33 changed files with 478 additions and 1234 deletions

7
.idea/dataSources.xml generated
View File

@@ -16,5 +16,12 @@
</library> </library>
</libraries> </libraries>
</data-source> </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> </component>
</project> </project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

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

View File

@@ -2,10 +2,12 @@
require_once ('Database.php'); require_once ('Database.php');
require_once ('FacilityData.php'); require_once ('FacilityData.php');
class FacilityDataSet { class FacilityDataSet
{
protected $_dbHandle, $_dbInstance; protected $_dbHandle, $_dbInstance;
public function __construct() { public function __construct()
{
$this->_dbInstance = Database::getInstance(); $this->_dbInstance = Database::getInstance();
$this->_dbHandle = $this->_dbInstance->getDbConnection(); $this->_dbHandle = $this->_dbInstance->getDbConnection();
} }
@@ -13,11 +15,23 @@ class FacilityDataSet {
/** /**
* @param $data * @param $data
* @return bool * @return bool
* Broken last minute, dont have time to fix.
* add / update facility to database from array of columns
*/ */
public function addFacility($data) : bool { 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 = " $sqlQuery = "
INSERT INTO ecoFacilities INSERT OR REPLACE INTO ecoFacilities
(title, (id,
title,
category, category,
description, description,
houseNumber, houseNumber,
@@ -28,181 +42,161 @@ class FacilityDataSet {
lng, lng,
lat, lat,
contributor) 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); $stmt = $this->_dbHandle->prepare($sqlQuery);
// Ensures only one value is returned per column name // Ensures only one value is returned per column name
$stmt->setFetchMode(\PDO::FETCH_ASSOC); $stmt->setFetchMode(\PDO::FETCH_ASSOC);
if (isset($data['id'])) {
// Initialize index for binding $stmt->bindParam(1, $data['id']);
$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);
} }
$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()); return !($stmt->rowCount());
} }
public function deleteFacility($id) : bool {
$sqlQuery = "DELETE FROM ecoFacilities WHERE id = ?"; /**
* @param $id
* @return bool
* Deletes Facility Records being passed a facility id.
*/
public function deleteFacility($id): bool
{
$sqlQuery = "DELETE FROM ecoFacilities WHERE ecoFacilities.id = :id;";
$stmt = $this->_dbHandle->prepare($sqlQuery); $stmt = $this->_dbHandle->prepare($sqlQuery);
$stmt->setFetchMode(\PDO::FETCH_ASSOC); $stmt->bindValue(':id', (int)$id, \PDO::PARAM_INT);
$stmt->bindValue(1, $id, \PDO::PARAM_INT);
$stmt->execute(); $stmt->execute();
var_dump($stmt);
echo $stmt->rowCount();
return !($stmt->rowCount() == 0); return !($stmt->rowCount() == 0);
} }
/** /**
* @param $filterArray * @param $filterArray
* @param $sortArray
* @return array * @return array
* Function to allow fetching of facility data. Data objects are created and held in an array * Fetch all records depending on filters, and sort by defined column
* Count of rows for pagination returned alongside data objects.
*/ */
public function fetchAll($filterArray): array public function fetchAll($filterArray, $sortArray): array
{ {
/** // Define columns for filtering and sorting
* COUNT(DISTINCT ecoFacilities.id) required due to multiple status comments possible. $filterColumns = [
*/ 0 => 'ecoFacilityStatus.statusComment',
$sqlCount = "SELECT COUNT(DISTINCT ecoFacilities.id) AS total FROM ecoFacilities"; 1 => 'ecoFacilities.title',
2 => 'ecoCategories.name',
3 => 'ecoFacilities.description',
4 => 'ecoFacilities.streetName',
5 => 'ecoFacilities.county',
6 => 'ecoFacilities.town',
7 => 'ecoFacilities.postcode',
8 => 'ecoUser.username'
];
/** $sortColumns = [
* DISTINCT used again for prior reasoning, although data is handled properly regardless later. 0 => 'ecoFacilityStatus.statusComment',
* GROUP_CONCAT is used to handle multiple status comments under one facility. Without this, DISTINCT 1 => 'ecoFacilities.title',
* drops the additional comment. 2 => 'ecoCategories.name',
*/ 3 => 'ecoFacilities.description',
$sqlData = "SELECT DISTINCT ecoFacilities.id, 4 => 'ecoFacilities.streetName',
title, 5 => 'ecoFacilities.county',
6 => 'ecoFacilities.town',
7 => 'ecoFacilities.postcode',
8 => 'ecoUser.username'
];
// Validate and select the filter column
$selectedFilterColumn = $filterColumns[$filterArray['category']] ?? 'ecoFacilities.title';
// Validate and select the sort column
$selectedSortColumn = $sortColumns[$sortArray['sort']] ?? 'ecoFacilities.title';
// Validate sort direction
$direction = strtolower($sortArray['dir']) === 'desc' ? 'DESC' : 'ASC';
// Base query for filtering and sorting
$baseQuery = "
FROM ecoFacilities
LEFT JOIN ecoCategories ON ecoCategories.id = ecoFacilities.category
LEFT JOIN ecoUser ON ecoUser.id = ecoFacilities.contributor
LEFT JOIN ecoFacilityStatus ON ecoFacilityStatus.facilityid = ecoFacilities.id
WHERE {$selectedFilterColumn} LIKE :term
";
// Query to count total results
$countQuery = "SELECT COUNT(DISTINCT ecoFacilities.id) AS total {$baseQuery}";
// Query to fetch filtered and sorted results
$dataQuery = "
SELECT DISTINCT ecoFacilities.id,
ecoFacilities.title,
GROUP_CONCAT(ecoFacilityStatus.statusComment, ', ') AS status, GROUP_CONCAT(ecoFacilityStatus.statusComment, ', ') AS status,
ecoCategories.name AS category, ecoCategories.name AS category,
description, ecoFacilities.description,
houseNumber, ecoFacilities.houseNumber,
streetName, ecoFacilities.streetName,
county, ecoFacilities.county,
town, ecoFacilities.town,
postcode, ecoFacilities.postcode,
lng, ecoFacilities.lng,
lat, ecoFacilities.lat,
ecoUser.username AS contributor ecoUser.username AS contributor
FROM ecoFacilities"; {$baseQuery}
GROUP BY ecoFacilities.id, ecoFacilities.title, ecoCategories.name,
ecoFacilities.description, ecoFacilities.streetName,
ecoFacilities.county, ecoFacilities.town, ecoFacilities.postcode,
ecoUser.username
ORDER BY {$selectedSortColumn} {$direction};
";
// Surround 'term' with % to allow usage with LIKE
$filterArray['term'] = '%' . $filterArray['term'] . '%' ?? '%';
// 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
* ? Parameters used here over named parameters so logic can be modular, more $dataStmt = $this->_dbHandle->prepare($dataQuery);
* columns can be added in the future $dataStmt->bindValue(':term', $filterArray['term'], PDO::PARAM_STR);
*/ $dataStmt->execute();
$sqlWhere = "
LEFT JOIN ecoCategories ON ecoCategories.id = ecoFacilities.category
LEFT JOIN ecoUser ON ecoUser.id = ecoFacilities.contributor
LEFT JOIN ecoFacilityStatus ON ecoFacilityStatus.facilityid = ecoFacilities.id
WHERE (ecoFacilityStatus.statusComment LIKE ? OR ? IS NULL)
AND ecoFacilities.title LIKE ?
AND ecoCategories.name LIKE ?
AND ecoFacilities.description LIKE ?
AND ecoFacilities.streetName LIKE ?
AND ecoFacilities.county LIKE ?
AND ecoFacilities.town LIKE ?
AND ecoFacilities.postcode LIKE ?
AND ecoUser.username LIKE ?
";
/** // Fetch results into FacilityData objects
* GROUP BY required to ensure status comments are displayed under the same ID
* Named parameters used here for prior reasoning, columns can be added above without
* effecting the bindIndex.
*/
$sqlLimits = "
GROUP BY ecoFacilities.id
LIMIT :limit OFFSET :offset;";
$sqlLimits = "
GROUP BY ecoFacilities.id
;";
// Concatenate query snippets for data and row count
$dataQuery = $sqlData . $sqlWhere . $sqlLimits;
$countQuery = $sqlCount . $sqlWhere . ";";
// Prepare, bind and execute data query
$stmt = $this->populateFields($dataQuery, $filterArray);
$stmt->execute();
// Create data objects
$dataSet = []; $dataSet = [];
while ($row = $stmt->fetch()) { while ($row = $dataStmt->fetch()) {
$dataSet[] = new FacilityData($row); $dataSet[] = new FacilityData($row);
} }
// Prepare, bind then execute count query
$stmt = $this->populateFields($countQuery, $filterArray);
$stmt->execute();
$totalCount = $stmt->fetch()['total'];
return [ return [
'dataset' => $dataSet, 'dataset' => $dataSet,
'count' => $totalCount '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)
{
$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 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;
}
public function setFilterUri($term, $category)
{
$uri = $_SERVER['REQUEST_URI'];
$uriComp = parse_url($uri);
$params = [];
// Parse existing query parameters
if (isset($uriComp['query'])) {
parse_str($uriComp['query'], $params);
} else {
$params = array();
}
// Avoid unnecessary redirection if the filter is already correct
if ((isset($params['category']) && $params['category'] === $category) && (isset($params['term']) && $params['term'] === $term)) {
exit; // Do nothing if filter already applied
}
// Update the 'page' parameter
$params['category'] = $category;
$params['term'] = $term;
// Rebuild the query string
$newUri = http_build_query($params);
var_dump($newUri);
// Redirect to the updated URI
// Use the current path or root
return
[
'newUri' => $newUri,
'path' => $uriComp['path'] ?? '/'
]; }
} }

View File

@@ -10,6 +10,10 @@ class User {
public function getUserId() { public function getUserId() {
return $this->_userId; return $this->_userId;
} }
/**
* Open session, set field variables
*/
public function __construct() { public function __construct() {
session_start(); session_start();
@@ -17,7 +21,7 @@ class User {
$this->_loggedIn = false; $this->_loggedIn = false;
$this->_userId = "0"; $this->_userId = "0";
$this->_accessLevel = null; $this->_accessLevel = null;
// if user logged in, set variables.
if(isset($_SESSION['login'])) { if(isset($_SESSION['login'])) {
$this->_username = $_SESSION['login']; $this->_username = $_SESSION['login'];
$this->_userId = $_SESSION['uid']; $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) { private function setAccessLevel($level) {
$this->_accessLevel = $level; $this->_accessLevel = $level;
$_SESSION['accessLevel'] = $level; $_SESSION['accessLevel'] = $level;
@@ -44,6 +37,13 @@ class User {
public function getAccessLevel() { public function getAccessLevel() {
return $this->_accessLevel; 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 public function Authenticate($username, $password): bool
{ {
$users = new UserDataSet(); $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() { public function logout() {
unset($_SESSION['login']); unset($_SESSION['login']);
unset($_SESSION['uid']); unset($_SESSION['uid']);

View File

@@ -9,6 +9,12 @@ class UserDataSet {
$this->_dbInstance = Database::getInstance(); $this->_dbInstance = Database::getInstance();
$this->_dbHandle = $this->_dbInstance->getDbConnection(); $this->_dbHandle = $this->_dbInstance->getDbConnection();
} }
/**
* @param $username
* @return mixed
* Query access level of a username, and return their usertype
*/
public function checkAccessLevel($username) { public function checkAccessLevel($username) {
$sqlQuery = "SELECT ecoUser.userType FROM ecoUser $sqlQuery = "SELECT ecoUser.userType FROM ecoUser
LEFT JOIN ecoUsertypes ON ecoUser.userType = ecoUsertypes.userType LEFT JOIN ecoUsertypes ON ecoUser.userType = ecoUsertypes.userType
@@ -18,26 +24,12 @@ class UserDataSet {
$statement->execute(); $statement->execute();
return $statement->fetch(PDO::FETCH_ASSOC)['userType']; 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 $username
* @param $password * @param $password
* @return array * @return array
* Authenticate user with query, and return their details
*/ */
public function checkUserCredentials($username, $password): array public function checkUserCredentials($username, $password): array
{ {
@@ -52,16 +44,4 @@ class UserDataSet {
} }
return $dataSet; 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') ?> <?php require('template/header.phtml') ?>
<div class="row"> <div class="row">
<div class="col-5"> <div class="col-5 me-auto">
<p><?php echo $view->dbMessage; ?></p> <p><?php echo $view->dbMessage; ?></p>
</div> </div>
<div class="col-auto"> <form class="col-auto">
<p>Current script <?php echo $_SERVER["PHP_SELF"]; ?></p> <?php require_once('template/createModal.phtml') ?>
</div> </form>
</div> </div>
<div class="row"> <div class="row">
<div class="container-fluid p-3"> <div class="container-fluid p-3" id="facilityContent">
<table class="table table-bordered"> <table class="table table-bordered">
<thead> <thead>
<tr> <tr>
@@ -28,7 +28,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($view->pageData as $facilityData): ?> <?php foreach ($view->pageData as $facilityData): ?>
<tr> <tr>
<td><?= htmlspecialchars($facilityData->getId() ?? 'N/A') ?></td> <td><?= htmlspecialchars($facilityData->getId() ?? 'N/A') ?></td>
<td><?= htmlspecialchars($facilityData->getTitle() ?? 'N/A') ?></td> <td><?= htmlspecialchars($facilityData->getTitle() ?? 'N/A') ?></td>

View File

@@ -0,0 +1,32 @@
<button type="button" class="col btn bg-primary btn-outline-primary text-light" data-bs-toggle="modal" data-bs-target="#createModal">
<span class="bi bi-pen-fill"></span>
</button>
<div class="modal fade" id="createModal" tabindex="-1" aria-labelledby="updateModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="updateModalLabel">Add Facility</h5>
<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']); ?>">
<form class="form-inline" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> ">
<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="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="createButton">Add</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-warning" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

View File

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

View File

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

View File

@@ -7,8 +7,6 @@
<meta name="description" content=""> <meta name="description" content="">
<meta name="author" content=""> <meta name="author" content="">
<link rel="icon" type="image/x-icon" href="/images/ecoBuddy_x32.png" <link rel="icon" type="image/x-icon" href="/images/ecoBuddy_x32.png"
<!-- Bootstrap core CSS --> <!-- Bootstrap core CSS -->
<link href="/css/bootstrap.css" rel="stylesheet"> <link href="/css/bootstrap.css" rel="stylesheet">
<!-- Bootstrap theme --> <!-- Bootstrap theme -->
@@ -28,39 +26,55 @@
<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> <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"> <div class="collapse navbar-collapse" id="navbarTogglerDemo03">
<ul class="navbar-nav me-auto mb-2 mb-lg-0"> <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> </ul>
<form class="row m-0 me-2 align-content-center align-content-center align-items-center" role="search" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <form class="row m-0 me-2 align-content-center align-content-center align-items-center" role="search" action="" method="POST">
<div class="col"> <div class="col">
<div class="form-floating input-group"> <div class="form-floating input-group">
<select name="filter" class="form-select border-3 border-success-subtle" id="filter"> <select name="sort" class="form-select border-3 border-success-subtle" id="sort">
<option selected></option> <option value="1" <?php if(isset($_GET['sort']) && $_GET['sort'] == '1') echo 'selected'; ?>>Title</option>
<option value="1">Title</option> <option value="2" <?php if(isset($_GET['sort']) && $_GET['sort'] == '2') echo 'selected'; ?>>Category</option>
<option value="2">Category</option> <option value="0" <?php if(isset($_GET['sort']) && $_GET['sort'] == '0') echo 'selected'; ?>>Status</option>
<option value="0">Status</option> <option value="3" <?php if(isset($_GET['sort']) && $_GET['sort'] == '3') echo 'selected'; ?>>Description</option>
<option value="3">Description</option> <option value="4" <?php if(isset($_GET['sort']) && $_GET['sort'] == '4') echo 'selected'; ?>>Street Name</option>
<option value="4">Street Name</option> <option value="5" <?php if(isset($_GET['sort']) && $_GET['sort'] == '5') echo 'selected'; ?>>County</option>
<option value="5">County</option> <option value="6" <?php if(isset($_GET['sort']) && $_GET['sort'] == '6') echo 'selected'; ?>>Town</option>
<option value="6">Town</option> <option value="7" <?php if(isset($_GET['sort']) && $_GET['sort'] == '7') echo 'selected'; ?>>Postcode</option>
<option value="7">Postcode</option> <option value="8" <?php if(isset($_GET['sort']) && $_GET['sort'] == '8') echo 'selected'; ?>>Contributor</option>
<option value="8">Contributor</option>
</select> </select>
<span class="input-group-text bi bi-filter-circle bg-success-subtle border-0 rounded-end" id="filter"></span> <span class="form-floating input-group">
<label for="filter">Column Filter</label> <select class="form-select border-3 border-start-0 rounded-end border-success-subtle" name="dir" id="dir">
<option value="asc" <?php if($_GET['dir'] == 'asc') echo 'selected'; ?>>Asc</option>
<option value="desc" <?php if($_GET['dir'] == 'desc') echo 'selected'; ?>>Desc</option>
</select>
<label for="dir">Order</label>
</span>
<label for="sort">Sort By</label>
</div> </div>
</div> </div>
<div class="col"> <div class="col">
<div class="form-floating input-group"> <div class="form-floating input-group">
<input class="form-control border-3 border-success-subtle" id="search" type="search" name="applyFilters" aria-label="Search"> <select name="filterCat" class="form-select border-3 border-success-subtle" id="filterCat">
<option value="1" <?php if(isset($_GET['category']) && $_GET['category'] == '1') echo 'selected'; ?>>Title</option>
<option value="2" <?php if(isset($_GET['category']) && $_GET['category'] == '2') echo 'selected'; ?>>Category</option>
<option value="0" <?php if(isset($_GET['category']) && $_GET['category'] == '0') echo 'selected'; ?>>Status</option>
<option value="3" <?php if(isset($_GET['category']) && $_GET['category'] == '3') echo 'selected'; ?>>Description</option>
<option value="4" <?php if(isset($_GET['category']) && $_GET['category'] == '4') echo 'selected'; ?>>Street Name</option>
<option value="5" <?php if(isset($_GET['category']) && $_GET['category'] == '5') echo 'selected'; ?>>County</option>
<option value="6" <?php if(isset($_GET['category']) && $_GET['category'] == '6') echo 'selected'; ?>>Town</option>
<option value="7" <?php if(isset($_GET['category']) && $_GET['category'] == '7') echo 'selected'; ?>>Postcode</option>
<option value="8" <?php if(isset($_GET['category']) && $_GET['category'] == '8') echo 'selected'; ?>>Contributor</option>
</select>
<span class="input-group-text bi bi-filter-circle bg-success-subtle border-0 rounded-end" id="filterCat"></span>
<label for="filterCat">Column Filter</label>
</div>
</div>
<div class="col">
<div class="form-floating input-group">
<label for="search"></label>
<input placeholder="<?php if(isset($_GET['filter'])) echo $_GET['filter']; ?>" class="form-control border-3 border-success-subtle" id="search" type="search" name="filter" aria-label="Search">
<span class="input-group-text bg-success-subtle border-0 rounded-end" id="search"> <span class="input-group-text bg-success-subtle border-0 rounded-end" id="search">
<button class="btn bg-light bg-success-subtle" type="submit"><span class="bi bi-search"></span></button> <button class="btn bg-light bg-success-subtle" type="submit"><span class="bi bi-search"></span></button>
</span> </span>
<label for="search">Search</label>
</div> </div>
</div> </div>
</form> </form>
@@ -68,9 +82,6 @@
<div class="col-sm" id="loginStatus"> <div class="col-sm" id="loginStatus">
<?php <?php
if ($view->loginError) {
require_once('Views/template/loginError.phtml');
}
if(!$view->user->isLoggedIn()) { if(!$view->user->isLoggedIn()) {
require_once('Views/template/loginModal.phtml'); require_once('Views/template/loginModal.phtml');
} }
@@ -85,8 +96,7 @@
</nav> </nav>
<body role="document"> <body role="document">
<div class="container-fluid"> <div class="main container-fluid">
<?php /*require_once("sidebar.phtml");*/?>
<div class="col" id="content"> <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 Login
</button> </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-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@@ -12,17 +16,23 @@
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>"> <form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<div class="mb-3"> <div class="mb-3">
<label for="username" class="form-label">Username</label> <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>
<div class="mb-3"> <div class="mb-3">
<label for="password" class="form-label">Password</label> <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> </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> </form>
</div> </div>
<div class="modal-footer"> <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> </div>
</div> </div>

View File

@@ -2,17 +2,26 @@
<div class="row mb-2"> <div class="row mb-2">
<!-- Form for Pagination --> <!-- Form for Pagination -->
<div id="paginationButtons" class="col-auto m-auto btn-group"> <div id="paginationButtons" class="col-auto m-auto btn-group">
<?php
$param = $_GET;
unset($param['page']); // Remove the page parameter to avoid duping
function buildUrl($page, $param): string
{
$param['page'] = $page;
return '?' . http_build_query($param);
}
?>
<!-- Start Button --> <!-- Start Button -->
<a class="btn btn-outline-primary" href="?page=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 --> <!-- Back Button -->
<a class="btn btn-outline-primary" href="?page=<?=max($view->pageNumber - 1, 0)?> " <?= $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 --> <!-- Dynamic Page Buttons -->
<?php <?php
$totalPages = $view->paginator->getTotalPages(); $totalPages = $view->paginator->getTotalPages();
var_dump($totalPages);
for ($i = $view->pageNumber - 2; $i <= $view->pageNumber + 2; $i++) { for ($i = $view->pageNumber - 2; $i <= $view->pageNumber + 2; $i++) {
if ($i >= 0 && $i < $totalPages): ?> if ($i >= 0 && $i < $totalPages): ?>
<a href="?page=<?= $i ?>" <a href="<?= buildUrl($i, $param) ?>"
class="btn <?= $i === $view->pageNumber ? 'btn-dark' : 'btn-outline-primary' ?>" class="btn <?= $i === $view->pageNumber ? 'btn-dark' : 'btn-outline-primary' ?>"
<?= $i === $view->pageNumber ? 'disabled' : '' ?>> <?= $i === $view->pageNumber ? 'disabled' : '' ?>>
<?= $i + 1 ?> <?= $i + 1 ?>
@@ -20,9 +29,9 @@
<?php endif; <?php endif;
} ?> } ?>
<!-- Forward Button --> <!-- Forward Button -->
<a class="btn btn-outline-primary" href="?page=<?=min($view->pageNumber + 1, $totalPages)?> " <?= $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 --> <!-- End Button -->
<a class="btn btn-outline-primary" href="?page=<?= $totalPages - 1 ?>"<?= $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> </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"> <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> <span class="bi bi-pen-fill"></span>
</button> </button>
<div class="modal fade" id="updateModal" tabindex="-1" aria-labelledby="updateModalLabel" aria-hidden="true"> <div class="modal fade" id="updateModal" tabindex="-1" aria-labelledby="updateModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
@@ -10,18 +11,17 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>"> <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" value="<?= $facilityData->getTitle() ?? '' ?>" placeholder="Title">
<input name="titlUpdate" class="form-control rounded mb-2" placeholder="Title"> <input name="cateUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getCategory() ?? '' ?>" placeholder="Category">
<input name="cateUpdate" class="form-control rounded mb-2" placeholder="Category"> <input name="descUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getDescription() ?? '' ?>" placeholder="Description">
<input name="descUpdate" class="form-control rounded mb-2" placeholder="Description"> <input name="hnumUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getHouseNumber() ?? '' ?>" placeholder="House Number">
<input name="statUpdate" class="form-control rounded mb-2" placeholder="Status"> <input name="strtUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getStreetName() ?? '' ?>" placeholder="Street Name">
<input name="strtUpdate" class="form-control rounded mb-2" placeholder="Street Name"> <input name="cntyUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getCounty() ?? '' ?>" placeholder="County">
<input name="cntyUpdate" class="form-control rounded mb-2" placeholder="County"> <input name="townUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getTown() ?? '' ?>" placeholder="Town">
<input name="townUpdate" class="form-control rounded mb-2" placeholder="Town"> <input name="postUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getPostcode() ?? '' ?>" placeholder="Postcode">
<input name="postUpdate" class="form-control rounded mb-2" placeholder="Postcode"> <input name="contUpdate" class="form-control rounded mb-2" value="<?= $facilityData->getContributor() ?? '' ?>" placeholder="Contributor">
<input name="contUpdate" class="form-control rounded mb-2" placeholder="Contributor">
</form>
<button type="submit" class="btn bg-primary btn-outline-primary text-light" name="updateButton">Update</button> <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> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@@ -2,10 +2,21 @@ nav, #loginStatus, #filters {
background-color: #3cc471; background-color: #3cc471;
color: #111 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 { #title {
margin-top: 12px; margin-top: 12px;
background-color: #fff; background-color: #fff;
@@ -52,3 +63,6 @@ nav, #loginStatus, #filters {
.modal-backdrop { .modal-backdrop {
z-index: 1040; z-index: 1040;
} }
.site-footer {
flex: 0 0 auto;
}

Binary file not shown.

View File

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

View File

@@ -2,23 +2,51 @@
require_once("Models/User.php"); require_once("Models/User.php");
// create user and dataset object
$user = new User(); $user = new User();
$userDataSet = new UserDataSet(); $userDataSet = new UserDataSet();
if (isset($_POST["loginButton"])) { if (isset($_POST["loginButton"])) {
$username = $_POST["username"]; $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 // 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)) { if($userDataSet->checkUserCredentials($username, $password)) {
$user->Authenticate($username, $password); $user->Authenticate($username, $password);
} // Unset modal boolean to hide it's usage.
else { unset($_GET['modal']);
echo "Error in Uname / Pass"; } 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"])) if (isset($_POST["logoutButton"]))
{ {
$user->logout(); $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

@@ -2,61 +2,111 @@
require_once('Models/FacilityDataSet.php'); require_once('Models/FacilityDataSet.php');
require_once("Models/Paginator.php"); require_once("Models/Paginator.php");
if(!isset($_GET['page'])) { // Default Filters
header("location: ?page=0"); $filters = [
} 'category' => $_GET['category'] ?? '1', // Default category
'term' => $_GET['term'] ?? '', // Default term
$filterArray = [ 'sort' => $_GET['sort'] ?? '1', // Default sort
0 => "", 'dir' => $_GET['dir'] ?? 'asc', // Default direction
1 => "", 'page' => $_GET['page'] ?? 0 // Default to first page
2 => "",
3 => "",
4 => "",
5 => "",
6 => "",
7 => "",
8 => ""
]; ];
$rowLimit = 5; //$_POST['rowCount']; // If no query parameters exist (initial page load), redirect to set default ones
if (empty($_GET)) {
$facilityDataSet = new FacilityDataSet(); redirectWithFilters($filters);
if (isset($_POST['applyFilters']) && isset($_POST['filter'])) {
var_dump($_POST);
$applyFilters = filter_input(INPUT_POST, 'applyFilters', FILTER_SANITIZE_STRING);
$filterKey = filter_input(INPUT_POST, 'filter', FILTER_SANITIZE_STRING);
$filterArray[$filterKey] = $applyFilters;
// Set the filter and generate the new URI
$filterSet = $facilityDataSet->setFilterUri($applyFilters, array_search($applyFilters, $filterArray));
// Parse the existing query string
parse_str($filterSet["newUri"], $queryParams);
// Add or overwrite the 'page' parameter
$queryParams['page'] = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, [
'options' => ['default' => 0, 'min_range' => 0] // Default to 0 for the first page
]);
// Build the updated query string
$newQueryString = http_build_query($queryParams);
// Redirect with the updated URI
header("Location: {$filterSet["path"]}?{$newQueryString}");
exit;
} }
// Set row limit
$rowLimit = 7;
// create dataset object
$facilityDataSet = new FacilityDataSet();
$filterArray[$_GET['category'] ?? null] = $_GET['term'] ?? null; 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']) ||
$filters['term'] !== ($_POST['filter'] ?? $filters['term']) ||
$filters['sort'] !== ($_POST['sort'] ?? $filters['sort']) ||
$filters['dir'] !== ($_POST['dir'] ?? $filters['dir'])
);
$view->pageData = $facilityDataSet->fetchAll($filterArray); // load from post if exists and sanitise, otherwise use defaults
$view->paginator = new Paginator($rowLimit, $view->pageData); $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'];
$filters['dir'] = filter_input(INPUT_POST, 'dir', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? $filters['dir'];
// Initialize paginator // Reset page if filters changed
$filters['page'] = $filtersChanged ? 0 : $_POST['paginationButton'] ?? $filters['page'];
redirectWithFilters($filters);
}
// fetch page data from database
$view->allPageData = $facilityDataSet->fetchAll(
['category' => $filters['category'], 'term' => $filters['term']],
['sort' => $filters['sort'], 'dir' => $filters['dir']]
);
// 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(); $view->pageNumber = $view->paginator->getPageFromUri();
// get current page
$view->pageData = $view->paginator->getPage($view->pageNumber); $view->pageData = $view->paginator->getPage($view->pageNumber);
// Send result count to view in format "showing x of y results"
// Send result count to view
$view->dbMessage = $view->paginator->countPageResults($view->pageNumber) == 0 $view->dbMessage = $view->paginator->countPageResults($view->pageNumber) == 0
? "No results" ? "No results"
: $view->paginator->countPageResults($view->pageNumber) . " result(s)"; : "Showing " . $view->paginator->countPageResults($view->pageNumber) . " of " . $view->totalResults . " result(s)";
// 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.";
}