Working: Auth, DB, view ticket

Signed-off-by: Luke Tainton <luke@tainton.uk>
This commit is contained in:
2020-08-04 14:19:10 +01:00
parent 184510e097
commit f64b585230
18 changed files with 1367 additions and 1 deletions

3
.gitignore vendored
View File

@@ -1,5 +1,6 @@
composer.phar composer.phar
/vendor/ /app/vendor/
/app/.env
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file

9
Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM composer as build
COPY app /srv
RUN composer --working-dir=/srv install
FROM php:apache
LABEL maintainer="Luke Tainton <luke@tainton.uk>"
RUN docker-php-ext-install pdo_mysql && a2enmod rewrite remoteip
COPY vhost.conf /etc/apache2/sites-enabled/000-default.conf
COPY --from=build /srv /srv

14
app/.env.sample Normal file
View File

@@ -0,0 +1,14 @@
APP_NAME = "FHeD"
APP_VERSION = "0.0.1"
ATTACHMENTS_PATH = ""
MYSQL_USER = ""
MYSQL_PASS = ""
MYSQL_HOST = ""
MYSQL_DB = ""
OIDC_HOST = ""
OIDC_CLIENT_ID = ""
OIDC_CLIENT_SECRET = ""
OIDC_DISABLE_SSL = ""

7
app/composer.json Normal file
View File

@@ -0,0 +1,7 @@
{
"require": {
"ramsey/uuid": "^4.0",
"vlucas/phpdotenv": "^5.0",
"jumbojett/openid-connect-php": "^0.9.0"
}
}

798
app/composer.lock generated Normal file
View File

@@ -0,0 +1,798 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "05a17cb0c779441ddd23e664703c898f",
"packages": [
{
"name": "brick/math",
"version": "0.8.15",
"source": {
"type": "git",
"url": "https://github.com/brick/math.git",
"reference": "9b08d412b9da9455b210459ff71414de7e6241cd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/brick/math/zipball/9b08d412b9da9455b210459ff71414de7e6241cd",
"reference": "9b08d412b9da9455b210459ff71414de7e6241cd",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": "^7.1|^8.0"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.2",
"phpunit/phpunit": "^7.5.15|^8.5",
"vimeo/psalm": "^3.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Brick\\Math\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Arbitrary-precision arithmetic library",
"keywords": [
"Arbitrary-precision",
"BigInteger",
"BigRational",
"arithmetic",
"bigdecimal",
"bignum",
"brick",
"math"
],
"funding": [
{
"url": "https://tidelift.com/funding/github/packagist/brick/math",
"type": "tidelift"
}
],
"time": "2020-04-15T15:59:35+00:00"
},
{
"name": "graham-campbell/result-type",
"version": "v1.0.1",
"source": {
"type": "git",
"url": "https://github.com/GrahamCampbell/Result-Type.git",
"reference": "7e279d2cd5d7fbb156ce46daada972355cea27bb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/7e279d2cd5d7fbb156ce46daada972355cea27bb",
"reference": "7e279d2cd5d7fbb156ce46daada972355cea27bb",
"shasum": ""
},
"require": {
"php": "^7.0|^8.0",
"phpoption/phpoption": "^1.7.3"
},
"require-dev": {
"phpunit/phpunit": "^6.5|^7.5|^8.5|^9.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"GrahamCampbell\\ResultType\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "graham@alt-three.com"
}
],
"description": "An Implementation Of The Result Type",
"keywords": [
"Graham Campbell",
"GrahamCampbell",
"Result Type",
"Result-Type",
"result"
],
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type",
"type": "tidelift"
}
],
"time": "2020-04-13T13:17:36+00:00"
},
{
"name": "jumbojett/openid-connect-php",
"version": "v0.9.0",
"source": {
"type": "git",
"url": "https://github.com/jumbojett/OpenID-Connect-PHP.git",
"reference": "87eefea40abd9cea0290aa9b6cdb314fd0037fe2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jumbojett/OpenID-Connect-PHP/zipball/87eefea40abd9cea0290aa9b6cdb314fd0037fe2",
"reference": "87eefea40abd9cea0290aa9b6cdb314fd0037fe2",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-json": "*",
"php": ">=5.4",
"phpseclib/phpseclib": "~2.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"roave/security-advisories": "dev-master"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"description": "Bare-bones OpenID Connect client",
"time": "2020-03-09T13:26:39+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.7.4",
"source": {
"type": "git",
"url": "https://github.com/schmittjoh/php-option.git",
"reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/schmittjoh/php-option/zipball/b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3",
"reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3",
"shasum": ""
},
"require": {
"php": "^5.5.9 || ^7.0 || ^8.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.3",
"phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.7-dev"
}
},
"autoload": {
"psr-4": {
"PhpOption\\": "src/PhpOption/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Johannes M. Schmitt",
"email": "schmittjoh@gmail.com"
},
{
"name": "Graham Campbell",
"email": "graham@alt-three.com"
}
],
"description": "Option Type for PHP",
"keywords": [
"language",
"option",
"php",
"type"
],
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption",
"type": "tidelift"
}
],
"time": "2020-06-07T10:40:07+00:00"
},
{
"name": "phpseclib/phpseclib",
"version": "2.0.28",
"source": {
"type": "git",
"url": "https://github.com/phpseclib/phpseclib.git",
"reference": "d1ca58cf33cb21046d702ae3a7b14fdacd9f3260"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/d1ca58cf33cb21046d702ae3a7b14fdacd9f3260",
"reference": "d1ca58cf33cb21046d702ae3a7b14fdacd9f3260",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phing/phing": "~2.7",
"phpunit/phpunit": "^4.8.35|^5.7|^6.0",
"sami/sami": "~2.0",
"squizlabs/php_codesniffer": "~2.0"
},
"suggest": {
"ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
"ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.",
"ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
"ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations."
},
"type": "library",
"autoload": {
"files": [
"phpseclib/bootstrap.php"
],
"psr-4": {
"phpseclib\\": "phpseclib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jim Wigginton",
"email": "terrafrost@php.net",
"role": "Lead Developer"
},
{
"name": "Patrick Monnerat",
"email": "pm@datasphere.ch",
"role": "Developer"
},
{
"name": "Andreas Fischer",
"email": "bantu@phpbb.com",
"role": "Developer"
},
{
"name": "Hans-Jürgen Petrich",
"email": "petrich@tronic-media.com",
"role": "Developer"
},
{
"name": "Graham Campbell",
"email": "graham@alt-three.com",
"role": "Developer"
}
],
"description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
"homepage": "http://phpseclib.sourceforge.net",
"keywords": [
"BigInteger",
"aes",
"asn.1",
"asn1",
"blowfish",
"crypto",
"cryptography",
"encryption",
"rsa",
"security",
"sftp",
"signature",
"signing",
"ssh",
"twofish",
"x.509",
"x509"
],
"funding": [
{
"url": "https://github.com/terrafrost",
"type": "github"
},
{
"url": "https://www.patreon.com/phpseclib",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib",
"type": "tidelift"
}
],
"time": "2020-07-08T09:08:33+00:00"
},
{
"name": "ramsey/collection",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/ramsey/collection.git",
"reference": "925ad8cf55ba7a3fc92e332c58fd0478ace3e1ca"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ramsey/collection/zipball/925ad8cf55ba7a3fc92e332c58fd0478ace3e1ca",
"reference": "925ad8cf55ba7a3fc92e332c58fd0478ace3e1ca",
"shasum": ""
},
"require": {
"php": "^7.2"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"fzaninotto/faker": "^1.5",
"jakub-onderka/php-parallel-lint": "^1",
"jangregor/phpstan-prophecy": "^0.6",
"mockery/mockery": "^1.3",
"phpstan/extension-installer": "^1",
"phpstan/phpdoc-parser": "0.4.1",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-mockery": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^8.5",
"slevomat/coding-standard": "^6.0",
"squizlabs/php_codesniffer": "^3.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Ramsey\\Collection\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ben Ramsey",
"email": "ben@benramsey.com",
"homepage": "https://benramsey.com"
}
],
"description": "A PHP 7.2+ library for representing and manipulating collections.",
"homepage": "https://github.com/ramsey/collection",
"keywords": [
"array",
"collection",
"hash",
"map",
"queue",
"set"
],
"time": "2020-01-05T00:22:59+00:00"
},
{
"name": "ramsey/uuid",
"version": "4.0.1",
"source": {
"type": "git",
"url": "https://github.com/ramsey/uuid.git",
"reference": "ba8fff1d3abb8bb4d35a135ed22a31c6ef3ede3d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/ba8fff1d3abb8bb4d35a135ed22a31c6ef3ede3d",
"reference": "ba8fff1d3abb8bb4d35a135ed22a31c6ef3ede3d",
"shasum": ""
},
"require": {
"brick/math": "^0.8",
"ext-json": "*",
"php": "^7.2 || ^8",
"ramsey/collection": "^1.0",
"symfony/polyfill-ctype": "^1.8"
},
"replace": {
"rhumsaa/uuid": "self.version"
},
"require-dev": {
"codeception/aspect-mock": "^3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2",
"doctrine/annotations": "^1.8",
"goaop/framework": "^2",
"mockery/mockery": "^1.3",
"moontoast/math": "^1.1",
"paragonie/random-lib": "^2",
"php-mock/php-mock-mockery": "^1.3",
"php-mock/php-mock-phpunit": "^2.5",
"php-parallel-lint/php-parallel-lint": "^1.1",
"phpstan/extension-installer": "^1.0",
"phpstan/phpdoc-parser": "0.4.3",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-mockery": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^8.5",
"psy/psysh": "^0.10.0",
"slevomat/coding-standard": "^6.0",
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "3.9.4"
},
"suggest": {
"ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.",
"ext-ctype": "Enables faster processing of character classification using ctype functions.",
"ext-gmp": "Enables faster math with arbitrary-precision integers using GMP.",
"ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.",
"paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter",
"ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.x-dev"
}
},
"autoload": {
"psr-4": {
"Ramsey\\Uuid\\": "src/"
},
"files": [
"src/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A PHP library for generating and working with universally unique identifiers (UUIDs).",
"homepage": "https://github.com/ramsey/uuid",
"keywords": [
"guid",
"identifier",
"uuid"
],
"funding": [
{
"url": "https://github.com/ramsey",
"type": "github"
}
],
"time": "2020-03-29T20:13:32+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.17.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d",
"reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.17-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-06-06T08:46:27+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.17.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "7110338d81ce1cbc3e273136e4574663627037a7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7110338d81ce1cbc3e273136e4574663627037a7",
"reference": "7110338d81ce1cbc3e273136e4574663627037a7",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.17-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
],
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-06-06T08:46:27+00:00"
},
{
"name": "symfony/polyfill-php80",
"version": "v1.17.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4a5b6bba3259902e386eb80dd1956181ee90b5b2",
"reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2",
"shasum": ""
},
"require": {
"php": ">=7.0.8"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.17-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php80\\": ""
},
"files": [
"bootstrap.php"
],
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ion Bazan",
"email": "ion.bazan@gmail.com"
},
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-06-06T08:46:27+00:00"
},
{
"name": "vlucas/phpdotenv",
"version": "v5.0.0",
"source": {
"type": "git",
"url": "https://github.com/vlucas/phpdotenv.git",
"reference": "fbb6a5f65512f21d0db9e21bd49e67f70a9bbd5e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/fbb6a5f65512f21d0db9e21bd49e67f70a9bbd5e",
"reference": "fbb6a5f65512f21d0db9e21bd49e67f70a9bbd5e",
"shasum": ""
},
"require": {
"ext-pcre": "*",
"graham-campbell/result-type": "^1.0.1",
"php": "^7.1.3 || ^8.0",
"phpoption/phpoption": "^1.7.4",
"symfony/polyfill-ctype": "^1.17",
"symfony/polyfill-mbstring": "^1.17",
"symfony/polyfill-php80": "^1.17"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4.1",
"ext-filter": "*",
"phpunit/phpunit": "^7.5.20 || ^8.5.2 || ^9.0"
},
"suggest": {
"ext-filter": "Required to use the boolean validator."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
}
},
"autoload": {
"psr-4": {
"Dotenv\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Graham Campbell",
"email": "graham@alt-three.com",
"homepage": "https://gjcampbell.co.uk/"
},
{
"name": "Vance Lucas",
"email": "vance@vancelucas.com",
"homepage": "https://vancelucas.com/"
}
],
"description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.",
"keywords": [
"dotenv",
"env",
"environment"
],
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv",
"type": "tidelift"
}
],
"time": "2020-06-07T19:04:14+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "1.1.0"
}

15
app/includes/footer.php Normal file
View File

@@ -0,0 +1,15 @@
<footer class="footer mt-auto py-3">
<div class="container">
<span class="text-muted">
<?php
echo( $_ENV['APP_NAME'] . " v" . $_ENV['APP_VERSION']);
if ($_ENV['APP_NAME'] != "FHeD") {echo(", powered by FHeD");};
?>
</span>
</div>
</footer>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</body>
</html>

59
app/includes/header.php Normal file
View File

@@ -0,0 +1,59 @@
<?php
$PAGE_TITLE = $PAGE_NAME . " :: " . $_ENV['APP_NAME'];
?>
<!doctype html>
<html lang="en" class="h-100">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#563d7c">
<title><?php echo( $PAGE_TITLE ); ?></title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/5.3.45/css/materialdesignicons.min.css">
<link rel="stylesheet" href="/css/custom.css">
</head>
<body class="d-flex flex-column h-100">
<header>
<!-- Fixed navbar -->
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="/"><?php echo($_ENV['APP_NAME']); ?></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link <?php if (!is_signed_in()) {echo(' disabled');} ?>" href="/new">New request</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if (!is_signed_in()) {echo(' disabled');} ?>" href="/open">Existing requests</a>
</li>
</ul>
<div class="mt-2 mt-md-0">
<ul class="navbar-nav">
<?php
if (is_signed_in()) { ?>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<?php echo($_SESSION['full_name']); ?>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="/profile">Profile</a>
<!-- <div class="dropdown-divider"></div> -->
<a class="dropdown-item" href="/logout">Log out</a>
</div>
</li>
<?php } else { ?>
<li class="nav-item">
<a class="nav-link" href="/login">Log in</a>
</li>
<?php } ?>
</ul>
</div>
</div>
</nav>
</header>

41
app/includes/prereqs.php Normal file
View File

@@ -0,0 +1,41 @@
<?php
// Composer
require_once __DIR__ . "/../vendor/autoload.php";
// PHPDotEnv
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . "/..");
$dotenv->load();
// Session
session_start();
// Database
$db = new PDO("mysql:host=".$_ENV['MYSQL_HOST'].";dbname=".$_ENV['MYSQL_DB'], $_ENV['MYSQL_USER'], $_ENV['MYSQL_PASS']);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// OpenID Connect
use Jumbojett\OpenIDConnectClient;
$oidc = new OpenIDConnectClient($_ENV['OIDC_HOST'], $_ENV['OIDC_CLIENT_ID'], $_ENV['OIDC_CLIENT_SECRET']);
if ($_ENV['OIDC_DISABLE_SSL'] == "true") {
$oidc->setVerifyHost(false);
$oidc->setVerifyPeer(false);
}
// Custom functions
function oidc_set_vars($sub, $uid, $fname, $lname, $email) {
$_SESSION['uuid'] = $sub;
$_SESSION['username'] = $uid;
$_SESSION['given_name'] = $fname;
$_SESSION['family_name'] = $lname;
$_SESSION['full_name'] = $fname . " " . $lname;
$_SESSION['email'] = $email;
}
function is_signed_in() {
if (isset($_SESSION['is_signed_in'])) {
return true;
} else {
return false;
}
}

7
app/public/css/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

66
app/public/css/custom.css Normal file
View File

@@ -0,0 +1,66 @@
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
main > .container {
padding: 60px 15px 0;
}
.footer {
background-color: #f5f5f5;
}
.footer > .container {
padding-right: 15px;
padding-left: 15px;
}
code {
font-size: 80%;
}
.jumbotron {
padding-top: 3rem;
padding-bottom: 3rem;
margin-bottom: 0;
background-color: #fff;
}
@media (min-width: 768px) {
.jumbotron {
padding-top: 6rem;
padding-bottom: 6rem;
}
}
.jumbotron p:last-child {
margin-bottom: 0;
}
.jumbotron h1 {
font-weight: 300;
}
.jumbotron .container {
max-width: 40rem;
}
footer {
padding-top: 3rem;
padding-bottom: 3rem;
}
footer p {
margin-bottom: .25rem;
}

3
app/public/css/mdi.min.css vendored Normal file

File diff suppressed because one or more lines are too long

131
app/public/index.php Normal file
View File

@@ -0,0 +1,131 @@
<?php
$PAGE_NAME = "Home";
require_once __DIR__ . "/../includes/prereqs.php";
require_once __DIR__ . "/../includes/header.php";
if (is_signed_in()) {
// Get user's own tickets
try {
$user_tickets_stmt = "SELECT uuid, id, title, description, status FROM tickets WHERE created_by=:uuid";
$user_tickets_sql = $db->prepare($user_tickets_stmt);
$user_tickets_sql->bindParam(':uuid', $_SESSION['uuid']);
$user_tickets_sql->execute();
$user_tickets_sql->setFetchMode(PDO::FETCH_ASSOC);
$user_tickets_result = $user_tickets_sql->fetchAll();
} catch (PDOException $e) {
echo("Error: " . $e->getMessage());
}
// Get tickets user has subscribed to
try {
$sub_tickets_stmt = "SELECT ticket_uuid FROM ticket_subscribers WHERE user_uuid=:uuid";
$sub_tickets_sql = $db->prepare($sub_tickets_stmt);
$sub_tickets_sql->bindParam(':uuid', $_SESSION['uuid']);
$sub_tickets_sql->execute();
$sub_tickets_sql->setFetchMode(PDO::FETCH_ASSOC);
$sub_tickets_result = $sub_tickets_sql->fetchAll();
} catch (PDOException $e) {
echo("Error: " . $e->getMessage());
}
$user_tickets_sub = 0; // Force 'no subbed tickets' msg until the code works
}
?>
<!-- Begin page content -->
<main role="main" class="flex-shrink-0">
<section class="jumbotron text-center">
<div class="container">
<h1>Welcome to <?php echo($_ENV['APP_NAME']); ?></h1>
<p class="lead text-muted">
<?php
if ($_ENV['APP_NAME'] == "FHeD") {echo("The Free HelpDesk");} else {echo($_ENV['APP_NAME']);};
?>
is the one-stop shop for all of your IT-related needs. Let us know how we can help you by opening a request.
</p>
<p>
<?php
if (is_signed_in()) {
echo("
<a href='/new' class='btn btn-primary my-2'>Create a request</a>
<a href='/open' class='btn btn-secondary my-2'>View existing requests</a>
");
} else {
echo("<b>Please log in to create or view tickets.</b>");
}
?>
</p>
</div>
</section>
<?php if (is_signed_in()) { ?>
<section>
<div class="card mx-auto" style="width: 80%;">
<div class="card-header">
<span class="mdi mdi-ticket-outline"></span> My Open Requests
</div>
<ul class="list-group list-group-flush">
<?php
if (count($user_tickets_result) == 0) {
echo("<center><b>No open tickets</b></center>");
} else {
foreach($user_tickets_result as $tkt) {
?>
<li class="list-group-item">
<div class="container">
<div class="row">
<div class="col-10">
<span style="display: inline;" class="text-muted">#<?php echo(sprintf("%'.05d\n", $tkt["id"])); ?> </span><span><b><?php echo($tkt['title']); ?></b></span>
<p class="m-0"><?php echo($tkt['description']); ?></p>
</div>
<div class="col-2">
<a class="btn btn-success float-right" href="view?rid=<?php echo($tkt["uuid"]); ?>" role="button">Go</a>
</div>
</div>
</div>
</li>
<?php } } ?>
</ul>
</div>
</section>
<section style="margin-top: 1%;">
<div class="card mx-auto" style="width: 80%;">
<div class="card-header">
<span class="mdi mdi-rss"></span> My Subscribed Requests
</div>
<ul class="list-group list-group-flush">
<?php
if ($user_tickets_sub == 0) {
// if (count($sub_tickets_result) == 0) {
echo("<center><b>No subscribed tickets</b></center>");
} else {
foreach($sub_tickets_result as $tkt) {
?>
<li class="list-group-item">
<div class="container">
<div class="row">
<div class="col-10">
<span style="display: inline;" class="text-muted">#<?php echo sprintf("%'.05d\n", $tkt["id"]); ?> </span><span><b><?php echo($tkt['title']); ?></b></span>
<p class="m-0"><?php echo($tkt['description']); ?></p>
</div>
<div class="col-2">
<a class="btn btn-success float-right" href="view?rid=<?php echo($tkt["uuid"]); ?>" role="button">Go</a>
</div>
</div>
</div>
</li>
<?php } } ?>
</ul>
</div>
</section>
<?php } ?>
</main>
<?php
require_once __DIR__ . "/../includes/footer.php";
?>

65
app/public/login.php Normal file
View File

@@ -0,0 +1,65 @@
<?php
$PAGE_NAME = "Logging in...";
require_once __DIR__ . "/../includes/prereqs.php";
// Perform the OIDC authentication
try {
$oidc->authenticate();
$oidc_user = array(
'sub' => $oidc->requestUserInfo('sub'),
'username' => $oidc->requestUserInfo('preferred_username'),
'given_name' => $oidc->requestUserInfo('given_name'),
'family_name' => $oidc->requestUserInfo('family_name'),
'email' => $oidc->requestUserInfo('email'),
);
} catch (Jumbojett\OpenIDConnectClientException $e) {
echo("Error during OpenID Connect authentication: " . $e->getMessage() . "<br>");
}
// Check if the user already exists
try {
$user_exist_sql = $db->prepare("SELECT uuid FROM users WHERE uuid=:uuid");
$user_exist_sql->bindParam(':uuid', $oidc_user['sub']);
$user_exist_sql->execute();
$result = $user_exist_sql->setFetchMode(PDO::FETCH_ASSOC); // If user doesn't exist, $result will be null
} catch (PDOException $e) {
echo("Error: " . $e->getMessage() . "<br>");
}
if ($result != null) {
// User already exists
try {
$stmt = "UPDATE users SET uid=:username, given_name=:given, family_name=:family, email=:email WHERE uuid=:sub";
$sql = $db->prepare($stmt);
$sql->bindParam(':sub', $oidc_user['sub']);
$sql->bindParam(':username', $oidc_user['username']);
$sql->bindParam(':given', $oidc_user['given_name']);
$sql->bindParam(':family', $oidc_user['family_name']);
$sql->bindParam(':email', $oidc_user['email']);
$sql->execute();
} catch (PDOException $e) {
echo("Error running SQL (Update existing user): <br>" . $e->getMessage() . "<br>");
}
} else {
// User doesn't already exist
try {
$stmt = "INSERT INTO users (uuid, uid, given_name, family_name, email) VALUES (:sub, :username, :given, :family, :email)";
$sql = $db->prepare($stmt);
$sql->bindParam(':sub', $oidc_user['sub']);
$sql->bindParam(':username', $oidc_user['username']);
$sql->bindParam(':given', $oidc_user['given_name']);
$sql->bindParam(':family', $oidc_user['family_name']);
$sql->bindParam(':email', $oidc_user['email']);
$sql->execute();
} catch (PDOException $e) {
echo("Error running SQL (Add new user): <br>" . $e->getMessage() . "<br>");
}
}
oidc_set_vars($oidc_user['sub'], $oidc_user['username'], $oidc_user['given_name'], $oidc_user['family_name'], $oidc_user['email']);
unset($oidc_user);
$_SESSION['is_signed_in'] = "true";
header('Location: /');
?>

8
app/public/logout.php Normal file
View File

@@ -0,0 +1,8 @@
<?php
$PAGE_NAME = "Logging out...";
require_once __DIR__ . "/../includes/prereqs.php";
session_destroy();
header('Location: /');
?>

33
app/public/new.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
$PAGE_NAME = "New request";
require_once __DIR__ . "/../includes/prereqs.php";
require_once __DIR__ . "/../includes/header.php";
if (!is_signed_in()) {
header('Location: /login');
}
?>
<!-- Begin page content -->
<main role="main" class="flex-shrink-0">
<section class="jumbotron text-center">
<div class="container">
<h1>Create a new request</h1>
<p class="lead text-muted">
Fill in the form below to create a new request. We'll respond to it as soon as we can.
</p>
</div>
</section>
<section>
<p>This page is currently under construction.</p>
</section>
</main>
<?php
require_once __DIR__ . "/../includes/footer.php";
?>

33
app/public/open.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
$PAGE_NAME = "Open requests";
require_once __DIR__ . "/../includes/prereqs.php";
require_once __DIR__ . "/../includes/header.php";
if (!is_signed_in()) {
header('Location: /login');
}
?>
<!-- Begin page content -->
<main role="main" class="flex-shrink-0">
<section class="jumbotron text-center">
<div class="container">
<h1>Open requests</h1>
<p class="lead text-muted">
Here you can find all of your requests, and other requests that you are subscribed to.
</p>
</div>
</section>
<section>
<p>This page is currently under construction.</p>
</section>
</main>
<?php
require_once __DIR__ . "/../includes/footer.php";
?>

53
app/public/view.php Normal file
View File

@@ -0,0 +1,53 @@
<?php
$PAGE_NAME = "Home";
require_once __DIR__ . "/../includes/prereqs.php";
require_once __DIR__ . "/../includes/header.php";
if (is_signed_in()) {
try {
$user_tickets_stmt = "SELECT * FROM tickets WHERE uuid=:uuid";
$user_tickets_sql = $db->prepare($user_tickets_stmt);
$user_tickets_sql->bindParam(':uuid', $_GET['rid']);
$user_tickets_sql->execute();
$user_tickets_sql->setFetchMode(PDO::FETCH_ASSOC);
$user_tickets_result = $user_tickets_sql->fetchAll();
$request = $user_tickets_result[0];
} catch (PDOException $e) {
echo("Error: " . $e->getMessage());
}
}
?>
<!-- Begin page content -->
<main role="main" class="flex-shrink-0">
<?php if (is_signed_in()) { ?>
<section class="jumbotron text-center">
<div class="container">
<h1><?php echo($request['title']); ?></h1>
<p style="color: gray; font-style: italic;"><?php echo("#" . sprintf("%'.05d\n", $request["id"])); ?></p>
<p class="lead text-muted">
<?php echo($request['description']); ?>
</p>
<p>
<?php print_r($request); ?>
</p>
</div>
</section>
<?php } else { ?>
<section class="jumbotron text-center">
<div class="container">
<h1>You need to be logged in to see this page.</h1>
</div>
</section>
<?php } ?>
</main>
<?php
require_once __DIR__ . "/../includes/footer.php";
?>

23
vhost.conf Normal file
View File

@@ -0,0 +1,23 @@
<VirtualHost *:80>
DocumentRoot /srv/public
<Directory /srv/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
Order allow,deny
allow from all
</Directory>
<IfModule mod_rewrite.c>
AddType application/x-httpd-php .php
Options +MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
</IfModule>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
ErrorDocument 404 /errors/404.php
ErrorDocument 500 /errors/500.php
ErrorDocument 503 /errors/503.php
</VirtualHost>