Compare commits
62 Commits
readd-webm
...
revamp-pro
| Author | SHA1 | Date | |
|---|---|---|---|
|
bdc0f22182
|
|||
|
f47ce08760
|
|||
|
961f021d27
|
|||
|
158e816ed0
|
|||
|
42cb584ef4
|
|||
|
1eabf809f0
|
|||
|
bb5b013d31
|
|||
|
a366769fb9
|
|||
|
19c49b4a00
|
|||
|
3d07547f80
|
|||
|
fc8ca571fb
|
|||
|
6fd4a0599c
|
|||
|
f782d20e56
|
|||
|
0a77f46fe1
|
|||
|
ed720af80b
|
|||
|
f8acc4b815
|
|||
| da1113341a | |||
| cd31bd4476 | |||
| 77e5d336eb | |||
| 403afdc472 | |||
| 86816489e3 | |||
| c38c502598 | |||
| 3d843667ad | |||
| 617a799ad8 | |||
| 0be8e51af4 | |||
| 381f67189a | |||
| 2e56c7aed4 | |||
| 5b7a04dc69 | |||
| 485110bf43 | |||
| 3498cb7d8e | |||
| ed3f307b9b | |||
| 7070a12e16 | |||
| 6bda1a91bd | |||
| 559b7ec03b | |||
| 602ae1f396 | |||
| f3c439d038 | |||
| 2b3a9dd6ec | |||
| 59b071d8be | |||
| f732582d0d | |||
| de72342018 | |||
| b54bbda71f | |||
|
20bab54235
|
|||
|
c3d8ce017d
|
|||
|
02cfe9feaa
|
|||
|
4d4ec78ea3
|
|||
|
a74ea31356
|
|||
|
0653672a17
|
|||
|
8a1ff1a265
|
|||
|
c1802e7cf2
|
|||
|
84de16fc25
|
|||
|
23b8e91a6c
|
|||
|
da8afe735c
|
|||
|
b6697e5750
|
|||
|
ece3c8ab80
|
|||
|
7297c83cea
|
|||
|
74662af3ef
|
|||
|
32e147fd02
|
|||
|
d5c28d4e0f
|
|||
|
f1b3c63311
|
|||
| a4ebe6ded0 | |||
| 2930f9863f | |||
| e7b66b4bc6 |
3
.git-blame-ignore-revs
Normal file
@@ -0,0 +1,3 @@
|
||||
# The formattening
|
||||
c5d308654744e116090e9ba165a968b8bf66006c
|
||||
da8afe735c62e1f8ee9ad5f71291d87102fe126b
|
||||
5
.gitignore
vendored
@@ -1,6 +1,7 @@
|
||||
/result
|
||||
/config.php
|
||||
*.sqlite
|
||||
/cache
|
||||
/config.php
|
||||
/result
|
||||
/test.sql
|
||||
/vendor/
|
||||
/www/simplesaml
|
||||
|
||||
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
||||
[submodule "lib/OAuth2-Client"]
|
||||
path = lib/OAuth2-Client
|
||||
url = https://github.com/UNINETT/OAuth2-Client.git
|
||||
58
.php-cs-fixer.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
$finder = (new PhpCsFixer\Finder())
|
||||
->ignoreDotFiles(false)
|
||||
->ignoreVCSIgnored(true)
|
||||
->in([
|
||||
'inc',
|
||||
'src',
|
||||
'dist',
|
||||
])
|
||||
->exclude([
|
||||
'vendor',
|
||||
])
|
||||
->append([
|
||||
__DIR__ . '/config.php',
|
||||
__DIR__ . '/.php-cs-fixer',
|
||||
])
|
||||
;
|
||||
|
||||
return (new PhpCsFixer\Config())
|
||||
->setRiskyAllowed(true)
|
||||
->setRules([
|
||||
'@PhpCsFixer' => true,
|
||||
'@Symfony' => true,
|
||||
'@PER-CS' => true,
|
||||
'@PHP71Migration' => true,
|
||||
'@PHP73Migration' => true,
|
||||
'@PHP74Migration' => true,
|
||||
'@PHP80Migration' => true,
|
||||
'@PHP81Migration' => true,
|
||||
'@PHP82Migration' => true,
|
||||
'@PHP83Migration' => true,
|
||||
'@PHP84Migration' => true,
|
||||
|
||||
'@PhpCsFixer:risky' => true,
|
||||
'@Symfony:risky' => true,
|
||||
'@PER-CS:risky' => true,
|
||||
'@PHP74Migration:risky' => true,
|
||||
'@PHP80Migration:risky' => true,
|
||||
'@PHP82Migration:risky' => true,
|
||||
|
||||
'strict_param' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'braces_position' => [
|
||||
'functions_opening_brace' => 'same_line',
|
||||
'classes_opening_brace' => 'same_line',
|
||||
],
|
||||
'simplified_if_return' => true,
|
||||
'simplified_null_return' => true,
|
||||
'yoda_style' => false,
|
||||
|
||||
// TODO: fix these
|
||||
'psr_autoloading' => false,
|
||||
])
|
||||
->setFinder($finder)
|
||||
->setIndent(" ")
|
||||
->setLineEnding("\n")
|
||||
;
|
||||
@@ -1,7 +0,0 @@
|
||||
# this is a development container, not hardened for hosting
|
||||
FROM php:7.4-cli
|
||||
RUN apt-get update && \
|
||||
apt-get install -y \
|
||||
sqlite3 \
|
||||
unzip \
|
||||
git
|
||||
76
README.md
@@ -1,79 +1,11 @@
|
||||
|
||||
# Programvareverkstedets nettside
|
||||
|
||||
A website created with the latest and greatest web technologies.
|
||||
May contain blackjack and other things one tends to include in awesome projects.
|
||||
|
||||
## Installation
|
||||
|
||||
git clone --recursive https://github.com/Programvareverkstedet/nettsiden.git
|
||||
|
||||
Put it in a folder your webserver can find.
|
||||
|
||||
## Development setup
|
||||
|
||||
Make sure you have `sqlite3`, `php` and `pdo-sqlite` installed.
|
||||
These can be obtained from your package manager.
|
||||
Then make sure PHP has the `curl`, `pdo-sqlite`, `ext-dom` and `sqlite3` extensions enabled, see `/etc/php/php.ini`.
|
||||
|
||||
To install all mentioned requirements on debian: `apt install composer sqlite3 php8.1-sqlite3 simplesamlphp php-xml`, followed by `composer update`.
|
||||
|
||||
./dev.sh
|
||||
|
||||
On Windows you can use chocolatey and git bash to run `./dev.sh`.
|
||||
Install `php` and `sqlite`, then enable these extensions in `C:\tools\php80\php.ini`:
|
||||
`mbstring`, `openssl`, `curl`, `pdo-sqlite` and `sqlite3`
|
||||
|
||||
Alternatively you may use `cmd` on Windows.
|
||||
In this case you'll have to perform a `composer install` manually beforehand.
|
||||
Good luck.
|
||||
|
||||
dev.bat
|
||||
|
||||
|
||||
### Dependency management
|
||||
|
||||
`dev.sh` will ensure the git submodules have been properly pulled, then download the `composer` package manager to a php archive file named `composer.phar`, then run it.
|
||||
Composer will then check for the php extensions needed, such as `pdo_sqlite`, which must be enabled on your system.
|
||||
This usually includes installing a php-sqlite3 package and enabling it in `/etc/php/php.ini`:
|
||||
|
||||
[PHP]
|
||||
extension=pdo_sqlite
|
||||
extension=sqlite3
|
||||
extension=ext-curl
|
||||
|
||||
Composer is used as such:
|
||||
|
||||
php composer.phar update
|
||||
php composer.phar install
|
||||
|
||||
|
||||
### Docker
|
||||
|
||||
We provide a simple docker-compose setup for local development.
|
||||
First ensure that docker is running:
|
||||
|
||||
sudo systemctl start docker
|
||||
|
||||
then
|
||||
|
||||
DOCKER_USER=$(id -u):$(id -g) docker-compose up
|
||||
|
||||
|
||||
### Admin account
|
||||
|
||||
Login goes through `idp.pvv.ntnu.no` via SAML, so you have to use your PVV account.
|
||||
(This only works if you use access the local development site via the the hostname `localhost`)
|
||||
To make your account into an admin account, run:
|
||||
|
||||
sqlite3 pvv.sqlite 'INSERT INTO users (uname, groups) VALUES ("YOUR_USERNAME", 1);'
|
||||
|
||||
If using docker, when already running:
|
||||
|
||||
DOCKER_USER=$(id -u):$(id -g) docker-compose exec nettside sqlite3 pvv.sqlite 'INSERT INTO users (uname, groups) VALUES ("YOUR_USERNAME", 1);'
|
||||
|
||||
If not already running:
|
||||
|
||||
DOCKER_USER=$(id -u):$(id -g) docker-compose run nettside sqlite3 pvv.sqlite 'INSERT INTO users (uname, groups) VALUES ("YOUR_USERNAME", 1);'
|
||||
|
||||
See [Getting Started](./docs/getting-started.md) for help to hack on the project.
|
||||
|
||||
## Hosting
|
||||
|
||||

|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"simplesamlphp/composer-module-installer": true
|
||||
"simplesamlphp/composer-module-installer": true,
|
||||
"simplesamlphp/composer-xmlprovider-installer": true
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"simplesamlphp/simplesamlphp": "^2.2",
|
||||
"erusev/parsedown": "^1.7"
|
||||
"simplesamlphp/simplesamlphp": "^2.2.1",
|
||||
"erusev/parsedown": "^1.7.4"
|
||||
}
|
||||
}
|
||||
|
||||
1854
composer.lock
generated
18
dist/config.local.php
vendored
@@ -1,24 +1,24 @@
|
||||
<?php
|
||||
|
||||
$DB_DSN = 'sqlite:'.__DIR__.DIRECTORY_SEPARATOR.'pvv.sqlite';
|
||||
declare(strict_types=1);
|
||||
|
||||
$DB_DSN = 'sqlite:' . __DIR__ . \DIRECTORY_SEPARATOR . 'pvv.sqlite';
|
||||
$DB_USER = null;
|
||||
$DB_PASS = null;
|
||||
|
||||
$DOOR_SECRET = "changeme";
|
||||
$DOOR_SECRET = 'changeme';
|
||||
|
||||
$GALLERY_DIR = __DIR__.DIRECTORY_SEPARATOR.'www'.DIRECTORY_SEPARATOR.'galleri'.DIRECTORY_SEPARATOR.'bilder'.DIRECTORY_SEPARATOR.'gallery';
|
||||
$GALLERY_DIR = __DIR__ . \DIRECTORY_SEPARATOR . 'www' . \DIRECTORY_SEPARATOR . 'galleri' . \DIRECTORY_SEPARATOR . 'bilder' . \DIRECTORY_SEPARATOR . 'gallery';
|
||||
$GALLERY_SERVER_PATH = '/images/gallery/';
|
||||
|
||||
$SLIDESHOW_DIR = __DIR__.DIRECTORY_SEPARATOR.'www'.DIRECTORY_SEPARATOR.'galleri'.DIRECTORY_SEPARATOR.'bilder'.DIRECTORY_SEPARATOR.'slideshow';
|
||||
$SLIDESHOW_DIR = __DIR__ . \DIRECTORY_SEPARATOR . 'www' . \DIRECTORY_SEPARATOR . 'galleri' . \DIRECTORY_SEPARATOR . 'bilder' . \DIRECTORY_SEPARATOR . 'slideshow';
|
||||
$SLIDESHOW_SERVER_PATH = '/images/slideshow/';
|
||||
|
||||
$SAML_COOKIE_SALT = 'changeme';
|
||||
$SAML_COOKIE_SECURE = false;
|
||||
$SAML_TRUSTED_DOMAINS = array("localhost:1080");
|
||||
$SAML_ADMIN_PASSWORD = "changeme";
|
||||
$SAML_TRUSTED_DOMAINS = ['localhost:1080'];
|
||||
$SAML_ADMIN_PASSWORD = 'changeme';
|
||||
$SAML_ADMIN_NAME = 'PVV Drift';
|
||||
$SAML_ADMIN_EMAIL = 'drift@pvv.ntnu.no';
|
||||
|
||||
$CACHE_DIRECTORY = __DIR__.DIRECTORY_SEPARATOR.'cache';
|
||||
|
||||
?>
|
||||
$CACHE_DIRECTORY = __DIR__ . \DIRECTORY_SEPARATOR . 'cache';
|
||||
|
||||
6
dist/config.source-env.php
vendored
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$configFile = getenv('PVV_CONFIG_FILE');
|
||||
require_once($configFile);
|
||||
declare(strict_types=1);
|
||||
|
||||
?>
|
||||
$configFile = getenv('PVV_CONFIG_FILE');
|
||||
require_once $configFile;
|
||||
|
||||
50
dist/pvv.sql
vendored
@@ -1,50 +0,0 @@
|
||||
CREATE TABLE "events" (
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
"name" TEXT,
|
||||
"start" TEXT,
|
||||
"stop" TEXT,
|
||||
"organiser" TEXT,
|
||||
"location" TEXT,
|
||||
"description" TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE "projects" (
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
"name" TEXT,
|
||||
"description" TEXT,
|
||||
"active" BOOLEAN
|
||||
);
|
||||
|
||||
CREATE TABLE "projectmembers" (
|
||||
"projectid" INTEGER,
|
||||
"name" TEXT,
|
||||
"uname" TEXT,
|
||||
"mail" TEXT,
|
||||
"role" TEXT,
|
||||
"lead" BOOLEAN DEFAULT 0,
|
||||
"owner" BOOLEAN DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE "users" (
|
||||
"uname" TEXT,
|
||||
"groups" INT DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE "motd" (
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
"title" TEXT,
|
||||
"content" TEXT
|
||||
);
|
||||
INSERT INTO motd (title, content)
|
||||
VALUES ('MOTD ./dev.sh', 'du kan endre motd i admin panelet');
|
||||
|
||||
CREATE TABLE "door" (
|
||||
"time" INTEGER PRIMARY KEY,
|
||||
"open" BOOLEAN
|
||||
);
|
||||
INSERT INTO door (time, open)
|
||||
VALUES (0, FALSE);
|
||||
|
||||
|
||||
INSERT INTO users (uname, groups)
|
||||
VALUES ('min_test_bruker', 1);
|
||||
47
dist/pvv_mysql.sql
vendored
@@ -1,47 +0,0 @@
|
||||
CREATE TABLE events (
|
||||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||
`name` TEXT,
|
||||
`start` TEXT,
|
||||
`stop` TEXT,
|
||||
`organiser` TEXT,
|
||||
`location` TEXT,
|
||||
`description` TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE projects (
|
||||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||
`name` TEXT,
|
||||
`description` TEXT,
|
||||
`active` BOOLEAN
|
||||
);
|
||||
|
||||
CREATE TABLE projectmembers (
|
||||
`projectid` INTEGER,
|
||||
`name` TEXT,
|
||||
`uname` TEXT,
|
||||
`mail` TEXT,
|
||||
`role` TEXT,
|
||||
`lead` BOOLEAN DEFAULT 0,
|
||||
`owner` BOOLEAN DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE users (
|
||||
`uname` TEXT,
|
||||
`groups` INT DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE motd (
|
||||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||
`title` TEXT,
|
||||
`content` TEXT
|
||||
);
|
||||
/*
|
||||
INSERT INTO motd (title, content)
|
||||
VALUES ("MOTD ./dev.sh", "du kan endre motd i admin panelet");
|
||||
*/
|
||||
|
||||
CREATE TABLE door (
|
||||
`time` INTEGER PRIMARY KEY,
|
||||
`open` BOOLEAN
|
||||
);
|
||||
INSERT INTO door(time, open) VALUES (0, FALSE);
|
||||
36
dist/simplesaml-dev/authsources.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
$config = [
|
||||
// This is used by the service provider to contact the identity provider
|
||||
'default-sp' => [
|
||||
'saml:SP',
|
||||
'entityID' => 'http://localhost:1080/simplesaml/sp',
|
||||
'idp' => 'http://localhost:1080/simplesaml/idp',
|
||||
],
|
||||
|
||||
// This is used by the identity provider to authenticate users
|
||||
'example-userpass' => [
|
||||
'exampleauth:UserPass',
|
||||
'users' => [
|
||||
'user:user' => [
|
||||
'uid' => ['user'],
|
||||
'group' => ['users'],
|
||||
'cn' => 'Ole Petter',
|
||||
'mail' => 'user+test@pvv.ntnu.no',
|
||||
],
|
||||
'admin:admin' => [
|
||||
'uid' => ['admin'],
|
||||
'group' => ['admin'],
|
||||
'cn' => 'Admin Adminsson',
|
||||
'mail' => 'admin+test@pvv.ntnu.no',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
// This is also used by the identity provider to authenticate IDP admins
|
||||
// See http://localhost:1080/simplesaml/admin/
|
||||
'admin' => [
|
||||
'core:AdminPassword',
|
||||
],
|
||||
];
|
||||
1416
dist/simplesaml-dev/config.php
vendored
Normal file
10
dist/simplesaml-dev/saml20-idp-hosted.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$metadata['http://localhost:1080/simplesaml/idp'] = [
|
||||
'host' => '__DEFAULT__',
|
||||
'privatekey' => 'localhost.pem',
|
||||
'certificate' => 'localhost.crt',
|
||||
'auth' => 'example-userpass',
|
||||
];
|
||||
50
dist/simplesaml-dev/saml20-idp-remote.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$metadata['https://idp.pvv.ntnu.no/'] = [
|
||||
'metadata-set' => 'saml20-idp-remote',
|
||||
'entityid' => 'https://idp.pvv.ntnu.no/',
|
||||
'SingleSignOnService' => [
|
||||
0 => [
|
||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
||||
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SSOService.php',
|
||||
],
|
||||
],
|
||||
'SingleLogoutService' => [
|
||||
0 => [
|
||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
||||
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SingleLogoutService.php',
|
||||
],
|
||||
],
|
||||
'certData' => 'MIIDpTCCAo2gAwIBAgIJAJIgibrB7NvsMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNVBAYTAk5PMR4wHAYDVQQKDBVQcm9ncmFtdmFyZXZlcmtzdGVkZXQxGDAWBgNVBAMMD2lkcC5wdnYubnRudS5ubzEgMB4GCSqGSIb3DQEJARYRZHJpZnRAcHZ2Lm50bnUubm8wHhcNMTcxMTEzMjI0NTQyWhcNMjcxMTEzMjI0NTQyWjBpMQswCQYDVQQGEwJOTzEeMBwGA1UECgwVUHJvZ3JhbXZhcmV2ZXJrc3RlZGV0MRgwFgYDVQQDDA9pZHAucHZ2Lm50bnUubm8xIDAeBgkqhkiG9w0BCQEWEWRyaWZ0QHB2di5udG51Lm5vMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAveLujCsgVCRA360y5yezy8FcSPhaqodggDqY12UTkYOMQLBFaph6uUL4oCUlXZqxScrAYVRt9yw+7BYpcm0p51VZzVCsfMxRVkn+O1eUvsaXq3f13f87QHKYP2f0uqkGf5PvnKIdSaI/ix8WJhD8XT+h0OkHEcaBvUtSG7zbEhvG21WPHwgw2rvZSneArQ8tOitZC0u8VXSfdhtf6ynRseo0xC95634UwQAZivhQ2v4A6Tp57QG5DCXIJ9/z3PkINx3KB/hOeh0EP6Dpbp+7V0/t9778E3whpm4llrH144kzROhA7EgUgkZOjAVjxGCYlcj3xQPnnItihVOZ5B5qLwIDAQABo1AwTjAdBgNVHQ4EFgQUPLhrB+Qb/Kzz7Car9GJkKmEkz6swHwYDVR0jBBgwFoAUPLhrB+Qb/Kzz7Car9GJkKmEkz6swDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAd+4E6t0j8/p8rbZE8y/gZ9GsiRhxkR4l6JbMRUfEpqHKi415qstChRcP2Lo3Yd5qdmj9tLDWoPsqet1QgyTTmQTgUmPhhMOQDqSh90LuqEJseKWafXGS/SfWLH6MWVmzDV5YofJEw2ThPiU58GiS06OLS2poq1eAesa2LQ22J8yYisXM4sxImIFte+LYQ1+1evfBWcvU1vrGsQ0VLJHdef9WoXp1swUFhq4Zk0c7gjHiB1CFVlExAAlk9L6W3CVXmKIYlf4eUnEBGkC061Ir42+uhAMWO9Y/L1NEuboTyd2KAI/6JdKdzpmfk7zPVxWlNxNCZ7OPNuvOKp6VlpB2EA==',
|
||||
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
|
||||
];
|
||||
|
||||
function getCertData(string $path): string
|
||||
{
|
||||
$cert = file_get_contents($path);
|
||||
$cert = str_replace("-----BEGIN CERTIFICATE-----", "", $cert);
|
||||
$cert = str_replace("-----END CERTIFICATE-----", "", $cert);
|
||||
$cert = str_replace(["\r", "\n"], "", $cert);
|
||||
return $cert;
|
||||
}
|
||||
|
||||
$metadata['http://localhost:1080/simplesaml/idp'] = [
|
||||
'metadata-set' => 'saml20-idp-remote',
|
||||
'entityid' => 'https://localhost:1080/simplesaml/idp',
|
||||
'SingleSignOnService' => [
|
||||
0 => [
|
||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
||||
'Location' => 'http://localhost:1080/simplesaml/saml2/idp/SSOService.php',
|
||||
],
|
||||
],
|
||||
'SingleLogoutService' => [
|
||||
0 => [
|
||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
||||
'Location' => 'http://localhost:1080/simplesaml/saml2/idp/SingleLogoutService.php',
|
||||
],
|
||||
],
|
||||
'certData' => getCertData(__DIR__ . '/../cert/localhost.crt'),
|
||||
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
|
||||
];
|
||||
16
dist/simplesaml-dev/saml20-sp-remote.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
$metadata['http://localhost:1080/simplesaml/sp'] = [
|
||||
'AssertionConsumerService' => [
|
||||
[
|
||||
'Location' => 'http://localhost:1080/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp',
|
||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
|
||||
],
|
||||
],
|
||||
'SingleLogoutService' => [
|
||||
[
|
||||
'Location' => 'http://localhost:1080/simplesaml/module.php/saml/sp/saml2-logout.php/default-sp',
|
||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
||||
],
|
||||
],
|
||||
];
|
||||
12
dist/simplesaml-prod/authsources.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
$config = [
|
||||
|
||||
/* This is the name of this authentication source, and will be used to access it later. */
|
||||
'default-sp' => [
|
||||
'saml:SP',
|
||||
'entityID' => 'https://www.pvv.ntnu.no/simplesaml/',
|
||||
'idp' => 'https://idp.pvv.ntnu.no/',
|
||||
],
|
||||
];
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR . 'config.php');
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 4) . \DIRECTORY_SEPARATOR . 'config.php';
|
||||
|
||||
/**
|
||||
* The configuration of SimpleSAMLphp
|
||||
@@ -64,15 +66,12 @@ $config = [
|
||||
* - 'loggingdir': Where to write logs. MUST be set to NULL when using a logging
|
||||
* handler other than `file`.
|
||||
* - 'datadir': Storage of general data.
|
||||
* - 'tempdir': Saving temporary files. SimpleSAMLphp will attempt to create
|
||||
* this directory if it doesn't exist. DEPRECATED - replaced by cachedir.
|
||||
* When specified as a relative path, this is relative to the SimpleSAMLphp
|
||||
* root directory.
|
||||
*/
|
||||
'cachedir' => $CACHE_DIRECTORY,
|
||||
//'loggingdir' => '/var/log/',
|
||||
//'datadir' => '/var/data/',
|
||||
//'tempdir' => '/tmp/simplesamlphp',
|
||||
|
||||
/*
|
||||
* Certificate and key material can be loaded from different possible
|
||||
@@ -198,6 +197,10 @@ $config = [
|
||||
* This password will give access to the installation page of SimpleSAMLphp with
|
||||
* metadata listing and diagnostics pages.
|
||||
* You can also put a hash here; run "bin/pwgen.php" to generate one.
|
||||
*
|
||||
* If you are using Ansible you might like to use
|
||||
* ansible.builtin.password_hash(hashtype='blowfish', ident='2y', rounds=13)
|
||||
* to generate this hashed value.
|
||||
*/
|
||||
'auth.adminpassword' => $SAML_ADMIN_PASSWORD,
|
||||
|
||||
@@ -279,7 +282,17 @@ $config = [
|
||||
* Whenever you change any of these headers, make sure to validate your config by running your
|
||||
* hostname through a security-test like https://en.internet.nl
|
||||
'headers.security' => [
|
||||
'Content-Security-Policy' => "default-src 'none'; frame-ancestors 'self'; object-src 'none'; script-src 'self'; style-src 'self'; font-src 'self'; connect-src 'self'; img-src 'self' data:; base-uri 'none'",
|
||||
'Content-Security-Policy' =>
|
||||
"default-src 'none'; " .
|
||||
"frame-ancestors 'self'; " .
|
||||
"object-src 'none'; " .
|
||||
"script-src 'self'; " .
|
||||
"style-src 'self'; " .
|
||||
"font-src 'self'; " .
|
||||
"connect-src 'self'; " .
|
||||
"media-src data:; " .
|
||||
"img-src 'self' data:; " .
|
||||
"base-uri 'none'",
|
||||
'X-Frame-Options' => 'SAMEORIGIN',
|
||||
'X-Content-Type-Options' => 'nosniff',
|
||||
'Referrer-Policy' => 'origin-when-cross-origin',
|
||||
@@ -335,9 +348,69 @@ $config = [
|
||||
* When 'errorreporting' is enabled, a form will be presented for the user to report
|
||||
* the error to 'technicalcontact_email'.
|
||||
*/
|
||||
'showerrors' => true,
|
||||
'showerrors' => false,
|
||||
'errorreporting' => true,
|
||||
|
||||
/*
|
||||
* When showerrors is true, this is an array of which errors
|
||||
* should still be shown to the user. By default an error will
|
||||
* always be shown if showerrors==true and this setting is at the default value to allow all.
|
||||
*
|
||||
* If you list anything in this option you have to explicitly list each error
|
||||
* you would like to be shown to the user. You can also set the value to false
|
||||
* to hide that error. If this setting is used with anything other than the default
|
||||
* value and an error is not listed in the list then a backtrace for that error
|
||||
* will not be shown.
|
||||
*
|
||||
* These can be any of the error codes in
|
||||
* src/SimpleSAML/Error/ErrorCodes.php
|
||||
*
|
||||
*/
|
||||
'showerrors.whitelist' => [ '*' => true ],
|
||||
/*
|
||||
some of the many possibilities for this setting
|
||||
|
||||
'showerrors.whitelist' => [
|
||||
'ACSPARAMS' => true,
|
||||
'ADMINNOTHASHED' => true,
|
||||
'ARSPARAMS' => true,
|
||||
'AUTHSOURCEERROR' => true,
|
||||
'BADREQUEST' => true,
|
||||
'CASERROR' => true,
|
||||
'CONFIG' => true,
|
||||
'CREATEREQUEST' => true,
|
||||
'DISCOPARAMS' => true,
|
||||
'GENERATEAUTHNRESPONSE' => true,
|
||||
'INVALIDCERT' => true,
|
||||
'LDAPERROR' => true,
|
||||
'LOGOUTINFOLOST' => true,
|
||||
'LOGOUTREQUEST' => true,
|
||||
'MEMCACHEDOWN' => true,
|
||||
'METADATA' => true,
|
||||
'METADATANOTFOUND' => true,
|
||||
'METHODNOTALLOWED' => true,
|
||||
'NOACCESS' => true,
|
||||
'NOCERT' => true,
|
||||
'NORELAYSTATE' => true,
|
||||
'NOSTATE' => true,
|
||||
'NOTFOUND' => true,
|
||||
'NOTFOUNDREASON' => true,
|
||||
'NOTSET' => true,
|
||||
'NOTVALIDCERT' => true,
|
||||
'NOTVALIDCERTSIGNATURE' => true,
|
||||
'PROCESSASSERTION' => true,
|
||||
'PROCESSAUTHNREQUEST' => true,
|
||||
'RESPONSESTATUSNOSUCCESS' => true,
|
||||
'SLOSERVICEPARAMS' => true,
|
||||
'SSOPARAMS' => true,
|
||||
'UNHANDLEDEXCEPTION' => true,
|
||||
'UNKNOWNCERT' => true,
|
||||
'USERABORTED' => true,
|
||||
'WRONGUSERPASS' => true,
|
||||
],
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Custom error show function called from SimpleSAML\Error\Error::show.
|
||||
* See docs/simplesamlphp-errorhandling.md for function code example.
|
||||
@@ -453,7 +526,7 @@ $config = [
|
||||
* Proxy to use for retrieving URLs.
|
||||
*
|
||||
* Example:
|
||||
* 'proxy' => 'tcp://proxy.example.com:5100'
|
||||
* 'proxy' => 'http://proxy.example.com:5100'
|
||||
*/
|
||||
'proxy' => null,
|
||||
|
||||
@@ -547,22 +620,20 @@ $config = [
|
||||
***********/
|
||||
|
||||
/*
|
||||
* Configuration for enabling/disabling modules. By default the 'core', 'admin' and 'saml' modules are enabled.
|
||||
* Configuration for enabling/disabling modules. By default, the 'core', 'admin' and 'saml' modules are enabled.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* 'module.enable' => [
|
||||
* 'exampleauth' => true, // Setting to TRUE enables.
|
||||
* 'consent' => false, // Setting to FALSE disables.
|
||||
* 'core' => null, // Unset or NULL uses default.
|
||||
* 'core' => null, // Unset or NULL uses default from \SimpleSAML\Module::$core_modules.
|
||||
* ],
|
||||
*/
|
||||
|
||||
'module.enable' => [
|
||||
'exampleauth' => false,
|
||||
'core' => true,
|
||||
'admin' => true,
|
||||
'saml' => true
|
||||
'saml' => true,
|
||||
],
|
||||
|
||||
|
||||
@@ -823,7 +894,7 @@ $config = [
|
||||
*/
|
||||
'language.available' => [
|
||||
'en', 'no', 'nn', 'se', 'da', 'de', 'sv', 'fi', 'es', 'ca', 'fr', 'it', 'nl', 'lb',
|
||||
'cs', 'sk', 'sl', 'lt', 'hr', 'hu', 'pl', 'pt', 'pt-br', 'tr', 'ja', 'zh', 'zh-tw',
|
||||
'cs', 'sk', 'sl', 'lt', 'hr', 'hu', 'pl', 'pt', 'pt_BR', 'tr', 'ja', 'zh', 'zh_TW',
|
||||
'ru', 'et', 'he', 'id', 'sr', 'lv', 'ro', 'eu', 'el', 'af', 'zu', 'xh', 'st',
|
||||
],
|
||||
'language.rtl' => ['ar', 'dv', 'fa', 'ur', 'he'],
|
||||
@@ -899,6 +970,14 @@ $config = [
|
||||
*/
|
||||
'template.auto_reload' => false,
|
||||
|
||||
|
||||
/*
|
||||
* Set the 'template.debug' to true to enable debugging for Twig templates.
|
||||
* This is useful during development as it provides better error messages.
|
||||
* Defaults to false.
|
||||
*/
|
||||
//'template.debug' => false,
|
||||
|
||||
/*
|
||||
* Set this option to true to indicate that your installation of SimpleSAMLphp
|
||||
* is running in a production environment. This will affect the way resources
|
||||
@@ -916,6 +995,19 @@ $config = [
|
||||
* The serving of the resources can be configured through these settings.
|
||||
*/
|
||||
'assets' => [
|
||||
/*
|
||||
* Used to generate cache buster tags. This salt is only used for this purpose.
|
||||
* You should set this in the same way as secretsalt.
|
||||
*
|
||||
* You can change this salt at any time. This will have the effect of explicit
|
||||
* cache busting as the tags for resources will change and thus all resources
|
||||
* will be fetched again.
|
||||
*
|
||||
* Leaving the default value in place can allow an attacker the opportunity
|
||||
* to work out the version of SSP you have installed.
|
||||
*/
|
||||
'salt' => 'assets.salt.default',
|
||||
|
||||
/*
|
||||
* These settings adjust the caching headers that are sent
|
||||
* when serving static resources.
|
||||
@@ -1129,6 +1221,21 @@ $config = [
|
||||
* ['type' => 'xml', 'file' => 'idp.example.org-idpMeta.xml'],
|
||||
* ],
|
||||
*
|
||||
* This example defines a remote xml-file with optional connection context.
|
||||
* See PHP documentation for possible context options: https://www.php.net/manual/en/context.php
|
||||
*
|
||||
* 'metadata.sources' => [
|
||||
* [
|
||||
* 'type' => 'xml',
|
||||
* 'url' => 'https://example.org/idp.example.org-idpMeta.xml',
|
||||
* 'context' => [
|
||||
* 'ssl' => [
|
||||
* 'verify_peer' => true,
|
||||
* ],
|
||||
* ],
|
||||
* ],
|
||||
* ],
|
||||
*
|
||||
* This example defines an mdq source.
|
||||
* 'metadata.sources' => [
|
||||
* [
|
||||
@@ -1,23 +1,21 @@
|
||||
<?php
|
||||
$metadata['https://idp.pvv.ntnu.no/'] = array (
|
||||
|
||||
declare(strict_types=1);
|
||||
$metadata['https://idp.pvv.ntnu.no/'] = [
|
||||
'metadata-set' => 'saml20-idp-remote',
|
||||
'entityid' => 'https://idp.pvv.ntnu.no/',
|
||||
'SingleSignOnService' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'SingleSignOnService' => [
|
||||
0 => [
|
||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
||||
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SSOService.php',
|
||||
),
|
||||
),
|
||||
'SingleLogoutService' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
],
|
||||
],
|
||||
'SingleLogoutService' => [
|
||||
0 => [
|
||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
||||
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SingleLogoutService.php',
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
'certData' => 'MIIDpTCCAo2gAwIBAgIJAJIgibrB7NvsMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNVBAYTAk5PMR4wHAYDVQQKDBVQcm9ncmFtdmFyZXZlcmtzdGVkZXQxGDAWBgNVBAMMD2lkcC5wdnYubnRudS5ubzEgMB4GCSqGSIb3DQEJARYRZHJpZnRAcHZ2Lm50bnUubm8wHhcNMTcxMTEzMjI0NTQyWhcNMjcxMTEzMjI0NTQyWjBpMQswCQYDVQQGEwJOTzEeMBwGA1UECgwVUHJvZ3JhbXZhcmV2ZXJrc3RlZGV0MRgwFgYDVQQDDA9pZHAucHZ2Lm50bnUubm8xIDAeBgkqhkiG9w0BCQEWEWRyaWZ0QHB2di5udG51Lm5vMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAveLujCsgVCRA360y5yezy8FcSPhaqodggDqY12UTkYOMQLBFaph6uUL4oCUlXZqxScrAYVRt9yw+7BYpcm0p51VZzVCsfMxRVkn+O1eUvsaXq3f13f87QHKYP2f0uqkGf5PvnKIdSaI/ix8WJhD8XT+h0OkHEcaBvUtSG7zbEhvG21WPHwgw2rvZSneArQ8tOitZC0u8VXSfdhtf6ynRseo0xC95634UwQAZivhQ2v4A6Tp57QG5DCXIJ9/z3PkINx3KB/hOeh0EP6Dpbp+7V0/t9778E3whpm4llrH144kzROhA7EgUgkZOjAVjxGCYlcj3xQPnnItihVOZ5B5qLwIDAQABo1AwTjAdBgNVHQ4EFgQUPLhrB+Qb/Kzz7Car9GJkKmEkz6swHwYDVR0jBBgwFoAUPLhrB+Qb/Kzz7Car9GJkKmEkz6swDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAd+4E6t0j8/p8rbZE8y/gZ9GsiRhxkR4l6JbMRUfEpqHKi415qstChRcP2Lo3Yd5qdmj9tLDWoPsqet1QgyTTmQTgUmPhhMOQDqSh90LuqEJseKWafXGS/SfWLH6MWVmzDV5YofJEw2ThPiU58GiS06OLS2poq1eAesa2LQ22J8yYisXM4sxImIFte+LYQ1+1evfBWcvU1vrGsQ0VLJHdef9WoXp1swUFhq4Zk0c7gjHiB1CFVlExAAlk9L6W3CVXmKIYlf4eUnEBGkC061Ir42+uhAMWO9Y/L1NEuboTyd2KAI/6JdKdzpmfk7zPVxWlNxNCZ7OPNuvOKp6VlpB2EA==',
|
||||
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
|
||||
);
|
||||
];
|
||||
9
dist/simplesamlphp-authsources.php
vendored
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
$config = array(
|
||||
|
||||
/* This is the name of this authentication source, and will be used to access it later. */
|
||||
'default-sp' => array(
|
||||
'saml:SP',
|
||||
'idp' => 'https://idp.pvv.ntnu.no/',
|
||||
),
|
||||
);
|
||||
63
dist/sql/pvv_mysql.sql
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
CREATE TABLE events (
|
||||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||
`name` TEXT,
|
||||
`start` TEXT,
|
||||
`stop` TEXT,
|
||||
`organiser` TEXT,
|
||||
`location` TEXT,
|
||||
`description` TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE project_group (
|
||||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||
`title` TEXT NOT NULL,
|
||||
`description_en` TEXT NOT NULL,
|
||||
`description_no` TEXT NOT NULL,
|
||||
`gitea_link` TEXT NOT NULL,
|
||||
`wiki_link` TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE project (
|
||||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||
`group_id` INTEGER NOT NULL REFERENCES project_group (id),
|
||||
`title` TEXT NOT NULL,
|
||||
`description_en` TEXT NOT NULL,
|
||||
`description_no` TEXT NOT NULL,
|
||||
`gitea_link` TEXT NOT NULL,
|
||||
`issue_board_link` TEXT NOT NULL,
|
||||
`wiki_link` TEXT,
|
||||
`languages` TEXT,
|
||||
`technologies` TEXT,
|
||||
`keywords` TEXT,
|
||||
`license` TEXT,
|
||||
`logo_url` TEXT,
|
||||
FOREIGN KEY (group_id) REFERENCES project_group (id)
|
||||
);
|
||||
|
||||
CREATE TABLE project_maintainer (
|
||||
`uname` TEXT PRIMARY KEY,
|
||||
`name` TEXT NOT NULL,
|
||||
`link` TEXT NOT NULL,
|
||||
`mail` TEXT NOT NULL,
|
||||
FOREIGN KEY (project_id) REFERENCES project (id),
|
||||
FOREIGN KEY (uname) REFERENCES maintainer (uname),
|
||||
);
|
||||
|
||||
CREATE TABLE users (`uname` TEXT, `groups` INT DEFAULT 0);
|
||||
|
||||
CREATE TABLE motd (
|
||||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||
`title` TEXT,
|
||||
`content` TEXT
|
||||
);
|
||||
|
||||
/*
|
||||
INSERT INTO motd (title, content)
|
||||
VALUES ("MOTD ./dev.sh", "du kan endre motd i admin panelet");
|
||||
*/
|
||||
CREATE TABLE door (`time` INTEGER PRIMARY KEY, `open` BOOLEAN);
|
||||
|
||||
INSERT INTO
|
||||
door (time, open)
|
||||
VALUES
|
||||
(0, FALSE);
|
||||
75
dist/sql/pvv_sqlite.sql
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
CREATE TABLE "events" (
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
"name" TEXT,
|
||||
"start" TEXT,
|
||||
"stop" TEXT,
|
||||
"organiser" TEXT,
|
||||
"location" TEXT,
|
||||
"description" TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE "project_group" (
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
"title" TEXT NOT NULL,
|
||||
"description_en" TEXT NOT NULL,
|
||||
"description_no" TEXT NOT NULL,
|
||||
"gitea_link" TEXT NOT NULL,
|
||||
"wiki_link" TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE "project" (
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
"group_id" INTEGER NOT NULL REFERENCES project_group (id),
|
||||
"title" TEXT NOT NULL,
|
||||
"description_en" TEXT NOT NULL,
|
||||
"description_no" TEXT NOT NULL,
|
||||
"gitea_link" TEXT NOT NULL,
|
||||
"issue_board_link" TEXT NOT NULL,
|
||||
"wiki_link" TEXT,
|
||||
"languages" TEXT,
|
||||
"technologies" TEXT,
|
||||
"keywords" TEXT,
|
||||
"license" TEXT,
|
||||
"logo_url" TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE "project_maintainer" (
|
||||
"uname" TEXT PRIMARY KEY,
|
||||
"name" TEXT NOT NULL,
|
||||
"link" TEXT NOT NULL,
|
||||
"mail" TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE "project__project_maintainer" (
|
||||
"project_id" INTEGER REFERENCES project (id),
|
||||
"uname" TEXT REFERENCES maintainer (uname),
|
||||
PRIMARY KEY (project_id, uname)
|
||||
);
|
||||
|
||||
CREATE TABLE "users" ("uname" TEXT, "groups" INT DEFAULT 0);
|
||||
|
||||
CREATE TABLE "motd" (
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
"title" TEXT,
|
||||
"content" TEXT
|
||||
);
|
||||
|
||||
INSERT INTO
|
||||
motd (title, content)
|
||||
VALUES
|
||||
(
|
||||
'MOTD ./dev.sh',
|
||||
'du kan endre motd i admin panelet'
|
||||
);
|
||||
|
||||
CREATE TABLE "door" ("time" INTEGER PRIMARY KEY, "open" BOOLEAN);
|
||||
|
||||
INSERT INTO
|
||||
door (time, open)
|
||||
VALUES
|
||||
(0, FALSE);
|
||||
|
||||
INSERT INTO
|
||||
users (uname, groups)
|
||||
VALUES
|
||||
('min_test_bruker', 1);
|
||||
7
dist/sql/test_data_sqlite.sql
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
-- See users in ../authsources.php
|
||||
INSERT INTO
|
||||
users (uname, groups)
|
||||
VALUES
|
||||
('admin', 1 | 2 | 4),
|
||||
('user', 0);
|
||||
@@ -1,21 +0,0 @@
|
||||
version: "3.9"
|
||||
|
||||
# cleanup:
|
||||
|
||||
# docker container prune -f && docker volume prune -f
|
||||
# docker system prune -a
|
||||
|
||||
services:
|
||||
nettside: # https://hub.docker.com/_/php
|
||||
#image: php:7.4-cli
|
||||
build: .
|
||||
volumes:
|
||||
- .:/usr/src/nettside
|
||||
working_dir: /usr/src/nettside
|
||||
command: ./dev.sh
|
||||
environment:
|
||||
- DOCKER_HOST=0.0.0.0
|
||||
- DOCKER_PORT=1080
|
||||
ports:
|
||||
- 1080:1080
|
||||
user: "${DOCKER_USER}"
|
||||
|
Before Width: | Height: | Size: 477 KiB After Width: | Height: | Size: 477 KiB |
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
72
docs/getting-started.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# Getting started
|
||||
|
||||
Let's get you up and running.
|
||||
|
||||
## List of dependencies
|
||||
|
||||
You will need to install the following pieces of software:
|
||||
|
||||
- Git
|
||||
- SQLite3
|
||||
- PHP
|
||||
- Composer
|
||||
- OpenSSL
|
||||
|
||||
If you are running Ubuntu or Debian, you can install these dependencies with:
|
||||
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install git sqlite3 php composer openssl
|
||||
```
|
||||
|
||||
## Automatic setup
|
||||
|
||||
You can use the scripts in the `scripts/` directory to quickly set up a development environment.
|
||||
|
||||
By running the `./scripts/setup.sh`, all dependencies will be installed, in addition to other miscellaneous setup tasks. You can then run `./scripts/run.sh` to start the webserver.
|
||||
|
||||
You should now be able to access the site at [http://localhost:1080](http://localhost:1080).
|
||||
|
||||
Sometimes it is useful to completely reset the state of the project, deleting the data, redownloading dependencies, etc. You can do this by running `./scripts/reset.sh`. Be careful, as this will delete all data in the database!
|
||||
|
||||
> [!WARN]
|
||||
> Even when resetting the project with the reset script, there are some situation where you need to clear your cookies or your browser cache to get a clean state.
|
||||
> How to do this varies between browsers, so please refer to your browser's documentation for instructions.
|
||||
|
||||
## Setup with nix
|
||||
|
||||
We provide a devshell with all dependencies included. We do recommend still using the scripts for setup tasks.
|
||||
|
||||
```bash
|
||||
nix develop
|
||||
./scripts/setup.sh
|
||||
./scripts/run.sh
|
||||
```
|
||||
|
||||
## Logging in
|
||||
|
||||
We have a development configuration for SimpleSAMLphp (which we use as our authentication system), that lets you log in with dummy users while developing.
|
||||
|
||||
The available users are:
|
||||
|
||||
- `admin` (password: `admin`) - An admin user
|
||||
- `user` (password: `user`) - A normal user
|
||||
|
||||
In addition, if you need to look into the SAML setup, you can log into the SimpleSAMLphp admin interface at [http://localhost:1080/simplesaml/admin](http://localhost:1080/simplesaml/admin) with username `admin` and password `123`.
|
||||
|
||||
## The codebase
|
||||
|
||||
In the codebase, you will find the following directories:
|
||||
|
||||
- `dist`: Contains files related to deployment, hosting and packaging.
|
||||
- `docs`: Documentation for the project.
|
||||
- `inc`: PHP include files, containing a base set of useful classes, functions and constants.
|
||||
- `nix`: Nix config for packaging, devshells, NixOS modules, etc.
|
||||
- `scripts`: Helper scripts for setting up development environments, running the server, etc.
|
||||
- `src`: The main library code for the project. This contains raw PHP code with business logic and database access.
|
||||
- `vendor`: Third-party dependencies installed with composer.
|
||||
- `www`: The webroot for the project. This contains public assets, styling, javascript and PHP code concerned with routing and rendering webpages.
|
||||
|
||||
## How SimpleSAMLphp is set up in the development environment
|
||||
|
||||
It used to be the case that we would connect to our production instance of SimpleSAMLphp for authentication even in development environments. This is no longer the case, as we now use our local SimpleSAMLphp instance both as a service provider and as an identity provider in development. The `config.php` and `authsources.php` files are written in a way where one single instance of SimpleSAMLphp acts as both parts. It will send authentication requests to itself. See `dist/simplesaml-dev` for implementation details.
|
||||
BIN
docs/hosting.jpg
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
6
flake.lock
generated
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1707939175,
|
||||
"narHash": "sha256-D1xan0lgxbmXDyzVqXTiSYHLmAMrMRdD+alKzEO/p3w=",
|
||||
"lastModified": 1765803225,
|
||||
"narHash": "sha256-xwaZV/UgJ04+ixbZZfoDE8IsOWjtvQZICh9aamzPnrg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f7e8132daca31b1e3859ac0fb49741754375ac3d",
|
||||
"rev": "ac9a217389ee622d4e1e727c4efcc9c4bc9089ba",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
in {
|
||||
packages = forAllSystems (system: pkgs: {
|
||||
default = self.packages.${system}.pvv-nettsiden;
|
||||
pvv-nettsiden = pkgs.callPackage ./nix/package.nix { php = pkgs.php82; };
|
||||
pvv-nettsiden = pkgs.callPackage ./nix/package.nix { php = pkgs.php84; };
|
||||
});
|
||||
|
||||
overlays.default = final: prev: {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
require __DIR__ . '/../src/_autoload.php';
|
||||
require __DIR__ . '/../config.php';
|
||||
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$agenda = new \pvv\side\Agenda([
|
||||
new \pvv\side\social\NerdepitsaActivity,
|
||||
new \pvv\side\social\AnimekveldActivity,
|
||||
new \pvv\side\DBActivity($pdo),
|
||||
]);
|
||||
$agenda = new pvv\side\Agenda([
|
||||
new pvv\side\social\NerdepitsaActivity(),
|
||||
new pvv\side\social\AnimekveldActivity(),
|
||||
new pvv\side\DBActivity($pdo),
|
||||
]);
|
||||
|
||||
@@ -1,33 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
// Set up database and user system,
|
||||
// and include common files such as HTML includes or SimplSAMLphp.
|
||||
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'agenda.php';
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'navbar.php';
|
||||
require_once __DIR__ . \DIRECTORY_SEPARATOR . 'agenda.php';
|
||||
require_once __DIR__ . \DIRECTORY_SEPARATOR . 'navbar.php';
|
||||
|
||||
require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'config.php']);
|
||||
require_once dirname(__DIR__) . implode(\DIRECTORY_SEPARATOR, ['', 'config.php']);
|
||||
|
||||
require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'src', '_autoload.php']);
|
||||
require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'vendor', 'simplesamlphp', 'simplesamlphp', 'lib', '_autoload.php']);
|
||||
require_once dirname(__DIR__) . implode(\DIRECTORY_SEPARATOR, ['', 'src', '_autoload.php']);
|
||||
require_once dirname(__DIR__) . implode(\DIRECTORY_SEPARATOR, ['', 'vendor', 'simplesamlphp', 'simplesamlphp', 'lib', '_autoload.php']);
|
||||
|
||||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'nb_NO');
|
||||
setlocale(\LC_ALL, 'nb_NO');
|
||||
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
$sp = 'default-sp';
|
||||
$as = new \SimpleSAML\Auth\Simple($sp);
|
||||
$as = new SimpleSAML\Auth\Simple($sp);
|
||||
|
||||
use \pvv\side\Agenda;
|
||||
$agenda = new \pvv\side\Agenda([
|
||||
use pvv\side\Agenda;
|
||||
|
||||
$agenda = new Agenda([
|
||||
// new \pvv\side\social\NerdepitsaActivity,
|
||||
// new \pvv\side\social\AnimekveldActivity,
|
||||
// new \pvv\side\social\HackekveldActivity,
|
||||
// new \pvv\side\social\BrettspillActivity,
|
||||
// new \pvv\side\social\DriftkveldActivity,
|
||||
new \pvv\side\DBActivity($pdo),
|
||||
new pvv\side\social\HackekveldActivity(),
|
||||
new pvv\side\social\BrettspillActivity(),
|
||||
new pvv\side\social\DriftkveldActivity(),
|
||||
new pvv\side\DBActivity($pdo),
|
||||
]);
|
||||
|
||||
$months_translations = ['januar', 'februar', 'mars', 'april', 'mai', 'juni', 'juli', 'august', 'september', 'oktober', 'november', 'desember'];
|
||||
|
||||
@@ -1,41 +1,45 @@
|
||||
<?php
|
||||
function navbar($depth, $active = NULL) {
|
||||
|
||||
declare(strict_types=1);
|
||||
function navbar($depth, $active = null) {
|
||||
$result = "\n\t<ul id=\"menu\">\n";
|
||||
$menuItems = [
|
||||
'Hjem' => '',
|
||||
'Hendelser' => 'hendelser',
|
||||
//'Kalender' => 'kalender',
|
||||
//'Aktiviteter' => 'aktiviteter',
|
||||
// 'Kalender' => 'kalender',
|
||||
// 'Aktiviteter' => 'aktiviteter',
|
||||
'Prosjekter' => 'prosjekt',
|
||||
'Kontakt' => 'kontakt',
|
||||
'Webmail' => 'webmail',
|
||||
'Webmail' => 'https://webmail.pvv.ntnu.no/roundcube/',
|
||||
'Galleri' => 'galleri',
|
||||
'Wiki' => 'https://wiki.pvv.ntnu.no/',
|
||||
'Git' => 'https://git.pvv.ntnu.no/',
|
||||
'Tjenester' => 'tjenester',
|
||||
];
|
||||
foreach($menuItems as $caption => $link) {
|
||||
foreach ($menuItems as $caption => $link) {
|
||||
$isActive = $active === $link;
|
||||
if (substr( $link, 0, 4 ) != "http") {
|
||||
if (substr($link, 0, 4) !== 'http') {
|
||||
$link = rtrim(str_repeat('../', $depth) . $link, '/') . '/';
|
||||
}
|
||||
|
||||
//if ($isActive) $link = '#';
|
||||
// if ($isActive) $link = '#';
|
||||
|
||||
$result .= "\t\t<li" . ($isActive ? ' class="active"' : '') . '>'
|
||||
. '<a href="' . $link . '">'
|
||||
. $caption
|
||||
. "</a></li>\n"
|
||||
;
|
||||
. "</a></li>\n";
|
||||
}
|
||||
|
||||
return $result . "\t</ul>\n";
|
||||
}
|
||||
|
||||
function loginBar($sp = null, $pdo = null) {
|
||||
if (is_null($sp)) $sp = 'default-sp';
|
||||
if (null === $sp) {
|
||||
$sp = 'default-sp';
|
||||
}
|
||||
$result = "\n";
|
||||
require_once(__DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple($sp);
|
||||
require_once __DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple($sp);
|
||||
|
||||
$svg = '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 64 64">
|
||||
<circle cx="32" cy="27" r="14" stroke-width="0" />
|
||||
@@ -44,11 +48,11 @@ function loginBar($sp = null, $pdo = null) {
|
||||
';
|
||||
|
||||
$attr = $as->getAttributes();
|
||||
if($attr) {
|
||||
if ($attr) {
|
||||
$uname = $attr['uid'][0];
|
||||
$isAdmin = false;
|
||||
if (isset($pdo)) {
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
$isAdmin = $userManager->isAdmin($uname);
|
||||
}
|
||||
$result .= "\t<a id=\"login\" href=\"#usermenu\" aria-hidden=\"true\">{$svg}" . htmlspecialchars($uname) . "</a>\n";
|
||||
|
||||
@@ -4,18 +4,33 @@
|
||||
}:
|
||||
|
||||
php.buildComposerProject rec {
|
||||
src = ./..;
|
||||
src = lib.fileset.toSource {
|
||||
root = ./..;
|
||||
fileset = lib.fileset.difference
|
||||
(lib.fileset.unions [
|
||||
../dist
|
||||
../inc
|
||||
../src
|
||||
../www
|
||||
../composer.json
|
||||
../composer.lock
|
||||
])
|
||||
(lib.fileset.unions [
|
||||
(lib.fileset.maybeMissing ../www/simplesaml)
|
||||
(lib.fileset.maybeMissing ../www/simplesaml-idp)
|
||||
]);
|
||||
};
|
||||
pname = "pvv-nettsiden";
|
||||
version = "0.0.1";
|
||||
vendorHash = "sha256-sWC5E60toa95re2NugvHVPT+vKYXc1I6Z3rSqXxTUu0=";
|
||||
vendorHash = "sha256-7I7Fdp5DvCwCdYY66Mv0hZ+a8xRzQt+WMUKG544k7Fc=";
|
||||
|
||||
passthru.simplesamlphpPath = "share/php/pvv-nettsiden/vendor/simplesamlphp/simplesamlphp";
|
||||
|
||||
postInstall = ''
|
||||
install -Dm644 dist/simplesamlphp-config.php $out/${passthru.simplesamlphpPath}/config/config.php
|
||||
install -Dm644 dist/simplesamlphp-authsources.php $out/${passthru.simplesamlphpPath}/config/authsources.php
|
||||
install -Dm644 dist/simplesamlphp-idp.php $out/${passthru.simplesamlphpPath}/metadata/saml20-idp-remote.php
|
||||
install -Dm644 dist/config.source-env.php $out/share/php/pvv-nettsiden/config.php
|
||||
install -Dm644 dist/simplesaml-prod/config.php "$out"/${passthru.simplesamlphpPath}/config/config.php
|
||||
install -Dm644 dist/simplesaml-prod/authsources.php "$$out/${passthru.simplesamlphpPath}/config/authsources.php
|
||||
install -Dm644 dist/simplesaml-prod/saml20-idp-remote.php "$$out/${passthru.simplesamlphpPath}/metadata/saml20-idp-remote.php
|
||||
install -Dm644 dist/config.source-env.php "$$out/share/php/pvv-nettsiden/config.php
|
||||
|
||||
${lib.pipe extra_files [
|
||||
(lib.mapAttrsToList (target_path: source_path: ''
|
||||
|
||||
@@ -1,39 +1,17 @@
|
||||
{ pkgs }:
|
||||
let
|
||||
phpEnv = pkgs.php82.buildEnv {
|
||||
phpEnv = pkgs.php84.buildEnv {
|
||||
extensions = { enabled, all }: enabled ++ (with all; [ iconv mbstring pdo_mysql pdo_sqlite ]);
|
||||
};
|
||||
in
|
||||
pkgs.mkShellNoCC {
|
||||
buildInputs = with pkgs; [
|
||||
phpEnv
|
||||
php82Packages.composer
|
||||
|
||||
sqlite
|
||||
git
|
||||
php84Packages.composer
|
||||
php84Packages.php-parallel-lint
|
||||
php84Packages.php-cs-fixer
|
||||
sqlite-interactive
|
||||
sql-formatter
|
||||
openssl
|
||||
];
|
||||
shellHook = ''
|
||||
alias runDev='php -S localhost:1080 -d error_reporting=E_ALL -d display_errors=1 -t www/'
|
||||
|
||||
# Prepare dev environment with sqlite and config files
|
||||
test -e pvv.sqlite || sqlite3 pvv.sqlite < dist/pvv.sql
|
||||
test -e config.php || cp -v dist/config.local.php config.php
|
||||
|
||||
|
||||
if [ ! -d www/galleri/bilder/slideshow ] ; then
|
||||
mkdir -p www/galleri/bilder/slideshow
|
||||
fi
|
||||
|
||||
if [ ! -d vendor ] ; then
|
||||
composer install || exit $?
|
||||
|
||||
cp dist/simplesamlphp-authsources.php vendor/simplesamlphp/simplesamlphp/config/authsources.php
|
||||
cp dist/simplesamlphp-idp.php vendor/simplesamlphp/simplesamlphp/metadata/saml20-idp-remote.php
|
||||
cp dist/simplesamlphp-config.php vendor/simplesamlphp/simplesamlphp/config/config.php
|
||||
|
||||
cp dist/config.local.php config.php
|
||||
|
||||
ln -s ../vendor/simplesamlphp/simplesamlphp/www/ www/simplesaml
|
||||
fi
|
||||
'';
|
||||
}
|
||||
|
||||
36
scripts/clean.sh
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REQUIRED_COMMANDS=(git grep)
|
||||
MISSING_COMMANDS=false
|
||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
||||
if ! command -v "$cmd" &> /dev/null; then
|
||||
echo "$cmd could not be found" >&2
|
||||
MISSING_COMMANDS=true
|
||||
fi
|
||||
done
|
||||
if [ "$MISSING_COMMANDS" = true ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -r GIT_TREE_IS_DIRTY="$(
|
||||
if ! git diff --quiet --ignore-submodules \
|
||||
|| git ls-files --others --exclude-standard | grep -q .; then
|
||||
echo 1
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
)"
|
||||
|
||||
if [ "$GIT_TREE_IS_DIRTY" == "1" ]; then
|
||||
echo "Git working tree is dirty, refusing to reset" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -r PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
||||
|
||||
(
|
||||
cd "$PROJECT_ROOT"
|
||||
git clean -fdx
|
||||
)
|
||||
21
scripts/reset.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REQUIRED_COMMANDS=(git)
|
||||
MISSING_COMMANDS=false
|
||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
||||
if ! command -v "$cmd" &> /dev/null; then
|
||||
echo "$cmd could not be found" >&2
|
||||
MISSING_COMMANDS=true
|
||||
fi
|
||||
done
|
||||
if [ "$MISSING_COMMANDS" = true ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -r PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
||||
|
||||
"$PROJECT_ROOT/scripts/clean.sh"
|
||||
"$PROJECT_ROOT/scripts/setup.sh"
|
||||
"$PROJECT_ROOT/scripts/seed-test-data.sh"
|
||||
37
scripts/run.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REQUIRED_COMMANDS=(
|
||||
php
|
||||
)
|
||||
MISSING_COMMANDS=false
|
||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
||||
if ! command -v "$cmd" &> /dev/null; then
|
||||
echo "$cmd could not be found" >&2
|
||||
MISSING_COMMANDS=true
|
||||
fi
|
||||
done
|
||||
if [ "$MISSING_COMMANDS" = true ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -r PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
||||
|
||||
# Check for hints that our project might not be correctly set up
|
||||
if [ ! -d "$PROJECT_ROOT/vendor" ] \
|
||||
|| [ ! -f "$PROJECT_ROOT/config.php" ] \
|
||||
|| [ ! -d "$PROJECT_ROOT/www/simplesaml" ] \
|
||||
|| [ ! -d "$PROJECT_ROOT/www/galleri/bilder" ]; then
|
||||
echo "It looks like the project is not correctly set up." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -a PHP_ARGS=(
|
||||
-S localhost:1080
|
||||
-d error_reporting=E_ALL
|
||||
-d display_errors=1
|
||||
-t www/
|
||||
)
|
||||
|
||||
(cd "$PROJECT_ROOT" && php "${PHP_ARGS[@]}")
|
||||
26
scripts/seed-test-data.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REQUIRED_COMMANDS=(
|
||||
sqlite3
|
||||
)
|
||||
MISSING_COMMANDS=false
|
||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
||||
if ! command -v "$cmd" &> /dev/null; then
|
||||
echo "$cmd could not be found" >&2
|
||||
MISSING_COMMANDS=true
|
||||
fi
|
||||
done
|
||||
if [ "$MISSING_COMMANDS" = true ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -r PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
||||
|
||||
if [ ! -f "$PROJECT_ROOT/pvv.sqlite" ] ; then
|
||||
echo "Database file $PROJECT_ROOT/pvv.sqlite does not exist. Please run setup.sh first." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sqlite3 "$PROJECT_ROOT/pvv.sqlite" < "$PROJECT_ROOT/dist/sql/test_data_sqlite.sql"
|
||||
57
scripts/setup.sh
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REQUIRED_COMMANDS=(
|
||||
git
|
||||
composer
|
||||
sqlite3
|
||||
openssl
|
||||
install
|
||||
)
|
||||
MISSING_COMMANDS=false
|
||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
||||
if ! command -v "$cmd" &> /dev/null; then
|
||||
echo "$cmd could not be found" >&2
|
||||
MISSING_COMMANDS=true
|
||||
fi
|
||||
done
|
||||
if [ "$MISSING_COMMANDS" = true ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -r PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
||||
|
||||
mkdir -p "$PROJECT_ROOT/www/galleri/bilder/slideshow"
|
||||
test -e "$PROJECT_ROOT/pvv.sqlite" || sqlite3 "$PROJECT_ROOT/pvv.sqlite" < "$PROJECT_ROOT/dist/sql/pvv_sqlite.sql"
|
||||
test -e "$PROJECT_ROOT/config.php" || cp -v "$PROJECT_ROOT/dist/config.local.php" "$PROJECT_ROOT/config.php"
|
||||
|
||||
if [ ! -d "$PROJECT_ROOT/vendor" ] ; then
|
||||
pushd "$PROJECT_ROOT"
|
||||
composer install || exit $?
|
||||
|
||||
# Set up SimpleSAMLphp identity provider (for local testing)
|
||||
install -m644 dist/simplesaml-dev/authsources.php -t vendor/simplesamlphp/simplesamlphp/config/
|
||||
install -m644 dist/simplesaml-dev/config.php -t vendor/simplesamlphp/simplesamlphp/config/
|
||||
install -m644 dist/simplesaml-dev/saml20-idp-remote.php -t vendor/simplesamlphp/simplesamlphp/metadata/
|
||||
install -m644 dist/simplesaml-dev/saml20-idp-hosted.php -t vendor/simplesamlphp/simplesamlphp/metadata/
|
||||
install -m644 dist/simplesaml-dev/saml20-sp-remote.php -t vendor/simplesamlphp/simplesamlphp/metadata/
|
||||
|
||||
# See session.phpsession.savepath in config.php
|
||||
mkdir -p vendor/simplesamlphp/simplesamlphp/sessions/
|
||||
|
||||
openssl req \
|
||||
-newkey rsa:4096 \
|
||||
-new \
|
||||
-x509 \
|
||||
-days 3652 \
|
||||
-nodes \
|
||||
-out vendor/simplesamlphp/simplesamlphp/cert/localhost.crt \
|
||||
-keyout vendor/simplesamlphp/simplesamlphp/cert/localhost.pem \
|
||||
-subj "/C=NO/ST=Trondheim/L=Trondheim/O=Programvareverkstedet/CN=localhost"
|
||||
|
||||
cp dist/config.local.php config.php
|
||||
|
||||
ln -s ../vendor/simplesamlphp/simplesamlphp/public/ www/simplesaml
|
||||
popd
|
||||
fi
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* Copyright (c) 2014-2015, Jørn Åne de Jong <@jornane>
|
||||
*
|
||||
@@ -14,7 +16,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/**
|
||||
/*
|
||||
* Register SPL autoloading for classes and interfaces. Put this file in your
|
||||
* namespace root and make sure it gets included from your PHP entry-point.
|
||||
*
|
||||
@@ -34,6 +36,6 @@
|
||||
* @link http://php.net/manual/en/function.spl-autoload.php
|
||||
* @license http://choosealicense.com/licenses/isc/ ISC license
|
||||
*/
|
||||
spl_autoload_extensions( '.php' );
|
||||
spl_autoload_register( 'spl_autoload' );
|
||||
set_include_path( realpath( __DIR__ ) . PATH_SEPARATOR . get_include_path() );
|
||||
spl_autoload_extensions('.php');
|
||||
spl_autoload_register('spl_autoload');
|
||||
set_include_path(realpath(__DIR__) . \PATH_SEPARATOR . get_include_path());
|
||||
|
||||
@@ -1,88 +1,89 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\admin;
|
||||
|
||||
use \PDO;
|
||||
class UserManager {
|
||||
private \PDO $pdo;
|
||||
|
||||
class UserManager{
|
||||
private $pdo;
|
||||
|
||||
public $usergroups = [
|
||||
public array $usergroups = [
|
||||
'admin' => 1,
|
||||
'prosjekt' => 2,
|
||||
'aktiviteter' => 4
|
||||
'aktiviteter' => 4,
|
||||
];
|
||||
|
||||
public function __construct($pdo){
|
||||
public function __construct(\PDO $pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function setupUser($uname, $groups=0){
|
||||
public function setupUser(string $uname, int $groups = 0): void {
|
||||
$query = 'INSERT INTO users (uname, groups) VALUES (:uname, :groups)';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':groups', $groups, PDO::PARAM_INT);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->bindParam(':groups', $groups, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
}
|
||||
|
||||
public function updateFlags($uname, $flags){
|
||||
public function updateFlags(string $uname, int $flags): void {
|
||||
$query = 'UPDATE users set groups=:groups WHERE uname=:uname';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':groups', $flags, PDO::PARAM_INT);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':groups', $flags, \PDO::PARAM_INT);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
}
|
||||
|
||||
public function addGroup($uname, $group){
|
||||
public function addGroup(string $uname, int $group): void {
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
|
||||
if($userFlags){
|
||||
if ($userFlags) {
|
||||
$newFlags = ($group | $userFlags);
|
||||
$this->updateFlags($uname, $newFlags);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeGroup($uname, $group){
|
||||
public function removeGroup(string $uname, int $group): void {
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
|
||||
if($userFlags){
|
||||
if ($userFlags) {
|
||||
$newFlags = ($userFlags & (~ $group));
|
||||
$this->updateFlags($uname, $newFlags);
|
||||
}
|
||||
}
|
||||
|
||||
public function setGroups($uname, $groups){
|
||||
public function setGroups(string $uname, int $groups): void {
|
||||
$query = 'SELECT * FROM users WHERE uname=:uname LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
$row = $statement->fetch();
|
||||
|
||||
if($row){
|
||||
if ($row) {
|
||||
$query = 'UPDATE users set groups=:groups WHERE uname=:uname';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':groups', $groups, PDO::PARAM_INT);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':groups', $groups, \PDO::PARAM_INT);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
}else{
|
||||
} else {
|
||||
$this->setupUser($uname, $groups);
|
||||
}
|
||||
}
|
||||
|
||||
public function hasGroup($uname, $groupName){
|
||||
public function hasGroup(string $uname, string $groupName): bool {
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
|
||||
return ($userFlags & $this->usergroups[$groupName]);
|
||||
return (bool) ($userFlags & $this->usergroups[$groupName]);
|
||||
}
|
||||
|
||||
// for convenience
|
||||
public function isAdmin($uname){
|
||||
public function isAdmin(string $uname): bool {
|
||||
return $this->hasGroup($uname, 'admin');
|
||||
}
|
||||
|
||||
public function getFlagfromNames($names){
|
||||
public function getFlagfromNames(array $names): int {
|
||||
$resultFlag = 0;
|
||||
|
||||
foreach($this->usergroups as $name => $flag){
|
||||
if(in_array($name, $names)){
|
||||
foreach ($this->usergroups as $name => $flag) {
|
||||
if (\in_array($name, $names, true)) {
|
||||
$resultFlag = ($resultFlag | $flag);
|
||||
}
|
||||
}
|
||||
@@ -90,24 +91,30 @@ class UserManager{
|
||||
return $resultFlag;
|
||||
}
|
||||
|
||||
public function getUsergroups($uname){
|
||||
public function getUsergroups(string $uname): int {
|
||||
$query = 'SELECT groups FROM users WHERE uname=:uname LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$row = $statement->fetch();
|
||||
if ($row == false) return 0;
|
||||
if ($row === false) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $row[0];
|
||||
}
|
||||
|
||||
public function getUsergroupNames($uname){
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getUsergroupNames($uname): array {
|
||||
$usersGroups = [];
|
||||
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
|
||||
foreach($this->usergroups as $name => $flag){
|
||||
if($userFlags & $flag){
|
||||
foreach ($this->usergroups as $name => $flag) {
|
||||
if ($userFlags & $flag) {
|
||||
$usersGroups[] = $name;
|
||||
}
|
||||
}
|
||||
@@ -115,17 +122,20 @@ class UserManager{
|
||||
return $usersGroups;
|
||||
}
|
||||
|
||||
public function getAllUserData(){
|
||||
/**
|
||||
* @return array<int,array{name:string,groups:string[]}>
|
||||
*/
|
||||
public function getAllUserData(): array {
|
||||
$query = 'SELECT uname FROM users ORDER BY uname ASC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
$users = [];
|
||||
foreach($statement->fetchAll() as $userData){
|
||||
foreach ($statement->fetchAll() as $userData) {
|
||||
$uname = $userData['uname'];
|
||||
$users[] = [
|
||||
'name' => $uname,
|
||||
'groups' => $this->getUsergroupNames($uname)
|
||||
'groups' => $this->getUsergroupNames($uname),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
use \DateTimeImmutable;
|
||||
|
||||
interface Activity {
|
||||
public function getNextEventFrom(\DateTimeImmutable $date): ?Event;
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */;
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */;
|
||||
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date): ?Event;
|
||||
}
|
||||
|
||||
@@ -1,35 +1,43 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
|
||||
class Agenda {
|
||||
private array $activities;
|
||||
|
||||
private $activities;
|
||||
public const int TODAY = 0;
|
||||
public const int TOMORROW = 1;
|
||||
public const int THIS_WEEK = 2;
|
||||
public const int NEXT_WEEK = 3;
|
||||
public const int THIS_MONTH = 4;
|
||||
public const int NEXT_MONTH = 5;
|
||||
|
||||
const TODAY = 0;
|
||||
const TOMORROW = 1;
|
||||
const THIS_WEEK = 2;
|
||||
const NEXT_WEEK = 3;
|
||||
const THIS_MONTH = 4;
|
||||
const NEXT_MONTH = 5;
|
||||
|
||||
public function __construct($activities) {
|
||||
/**
|
||||
* @param array<int,DBActivity> $activities
|
||||
*/
|
||||
public function __construct(array $activities) {
|
||||
$this->activities = $activities;
|
||||
}
|
||||
|
||||
public static function getFormattedDate($date) {
|
||||
return $date->format("l j. M H.i");
|
||||
public static function getFormattedDate(\DateTimeImmutable $date): string {
|
||||
return $date->format('l j. M H.i');
|
||||
}
|
||||
|
||||
public function getEventsBetween(DateTimeImmutable $from, DateTimeImmutable $to) {
|
||||
/**
|
||||
* @return array<Event>
|
||||
*/
|
||||
public function getEventsBetween(
|
||||
\DateTimeImmutable $from,
|
||||
\DateTimeImmutable $to,
|
||||
) {
|
||||
$results = [];
|
||||
for($i = 0; $i < sizeof($this->activities); $i++) {
|
||||
for ($i = 0; $i < \count($this->activities); ++$i) {
|
||||
$result = [];
|
||||
do {
|
||||
$run = false;
|
||||
if (sizeof($result)) {
|
||||
if (\count($result)) {
|
||||
$date = end($result)->getStop();
|
||||
} else {
|
||||
$date = $from;
|
||||
@@ -43,66 +51,86 @@ class Agenda {
|
||||
$results[] = $result;
|
||||
}
|
||||
$result = [];
|
||||
foreach($results as $a) foreach($a as $b) $result[] = $b;
|
||||
usort($result, function($a, $b) {
|
||||
return ($a->getStart() < $b->getStart()) ? -1 : 1;
|
||||
});
|
||||
foreach ($results as $a) {
|
||||
foreach ($a as $b) {
|
||||
$result[] = $b;
|
||||
}
|
||||
}
|
||||
usort(
|
||||
$result,
|
||||
static fn($a, $b) => $a->getStart() < $b->getStart() ? -1 : 1,
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getNextDays() {
|
||||
/**
|
||||
* @return array<int,array>
|
||||
*/
|
||||
public function getNextDays(): array {
|
||||
$result = [[], [], [], [], [], []];
|
||||
$events = $this->getEventsBetween(
|
||||
(new DateTimeImmutable)->setTime(0, 0),
|
||||
(new DateTimeImmutable)->setTime(23, 59)->add(new DateInterval('P1M'))
|
||||
new \DateTimeImmutable()->setTime(0, 0),
|
||||
new \DateTimeImmutable()->setTime(23, 59)->add(new \DateInterval('P1M')),
|
||||
);
|
||||
foreach ($events as $event) {
|
||||
$index = self::NEXT_MONTH;
|
||||
if (self::isToday($event->getStart())) $index = self::TODAY;
|
||||
elseif (self::isTomorrow($event->getStart())) $index = self::TOMORROW;
|
||||
elseif (self::isThisWeek($event->getStart())) $index = self::THIS_WEEK;
|
||||
elseif (self::isNextWeek($event->getStart())) $index = self::NEXT_WEEK;
|
||||
elseif (self::isThisMonth($event->getStart())) $index = self::THIS_MONTH;
|
||||
if (self::isToday($event->getStart())) {
|
||||
$index = self::TODAY;
|
||||
} elseif (self::isTomorrow($event->getStart())) {
|
||||
$index = self::TOMORROW;
|
||||
} elseif (self::isThisWeek($event->getStart())) {
|
||||
$index = self::THIS_WEEK;
|
||||
} elseif (self::isNextWeek($event->getStart())) {
|
||||
$index = self::NEXT_WEEK;
|
||||
} elseif (self::isThisMonth($event->getStart())) {
|
||||
$index = self::THIS_MONTH;
|
||||
}
|
||||
$result[$index][] = $event;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getNextOfEach(DateTimeImmutable $startDate) {
|
||||
$result = array_filter(array_map(
|
||||
function($a) use ($startDate){
|
||||
return $a->getNextEventFrom($startDate);
|
||||
}, $this->activities
|
||||
), function($a){
|
||||
return isset($a);
|
||||
});
|
||||
usort($result, function($a, $b) {
|
||||
return ($a->getStart()->getTimeStamp() < $b->getStart()->getTimeStamp())
|
||||
/**
|
||||
* @return array<Event>
|
||||
*/
|
||||
public function getNextOfEach(\DateTimeImmutable $startDate): array {
|
||||
$result = array_filter(
|
||||
array_map(
|
||||
static fn($a) => $a->getNextEventFrom($startDate),
|
||||
$this->activities,
|
||||
),
|
||||
static fn($a) => isset($a),
|
||||
);
|
||||
usort(
|
||||
$result,
|
||||
static fn($a, $b) => $a->getStart()->getTimeStamp()
|
||||
< $b->getStart()->getTimeStamp()
|
||||
? -1
|
||||
: 1
|
||||
;
|
||||
});
|
||||
: 1,
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function isToday(DateTimeImmutable $date) {
|
||||
return $date->format('dmY') == date('dmY');
|
||||
public static function isToday(\DateTimeImmutable $date): bool {
|
||||
return $date->format('dmY') === date('dmY');
|
||||
}
|
||||
|
||||
public static function isTomorrow(DateTimeImmutable $date) {
|
||||
return $date->sub(new DateInterval('P1D'))->format('dmY') == date('dmY');
|
||||
public static function isTomorrow(\DateTimeImmutable $date): bool {
|
||||
return $date->sub(new \DateInterval('P1D'))->format('dmY') === date('dmY');
|
||||
}
|
||||
|
||||
public static function isThisWeek(DateTimeImmutable $date) {
|
||||
return $date->format('WY') == date('WY');
|
||||
public static function isThisWeek(\DateTimeImmutable $date): bool {
|
||||
return $date->format('WY') === date('WY');
|
||||
}
|
||||
|
||||
public static function isNextWeek(DateTimeImmutable $date) {
|
||||
return $date->sub(new DateInterval('P7D'))->format('WY') == date('WY');
|
||||
public static function isNextWeek(\DateTimeImmutable $date): bool {
|
||||
return $date->sub(new \DateInterval('P7D'))->format('WY') === date('WY');
|
||||
}
|
||||
|
||||
public static function isThisMonth(DateTimeImmutable $date) {
|
||||
return $date->format('mY') == date('mY');
|
||||
public static function isThisMonth(\DateTimeImmutable $date): bool {
|
||||
return $date->format('mY') === date('mY');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,31 +1,34 @@
|
||||
<?php
|
||||
namespace pvv\side;
|
||||
|
||||
use \DateTimeImmutable;
|
||||
use \PDO;
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
class DBActivity implements Activity {
|
||||
private $pdo;
|
||||
|
||||
public function __construct(PDO $pdo) {
|
||||
public function __construct(\PDO $pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function getAllEvents() {
|
||||
/**
|
||||
* @return SimpleEvent[]
|
||||
*/
|
||||
public function getAllEvents(): array {
|
||||
$query = 'SELECT * FROM events ORDER BY id DESC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
$events = [];
|
||||
foreach($statement->fetchAll() as $dbEvent){
|
||||
foreach ($statement->fetchAll() as $dbEvent) {
|
||||
$event = new SimpleEvent(
|
||||
$dbEvent['id'],
|
||||
$dbEvent['name'],
|
||||
DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['start']),
|
||||
DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['stop']),
|
||||
\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['start']),
|
||||
\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['stop']),
|
||||
$dbEvent['organiser'],
|
||||
$dbEvent['location'],
|
||||
$dbEvent['description']
|
||||
$dbEvent['description'],
|
||||
);
|
||||
$events[] = $event;
|
||||
}
|
||||
@@ -33,53 +36,58 @@ class DBActivity implements Activity {
|
||||
return $events;
|
||||
}
|
||||
|
||||
public function getEventByID($id) {
|
||||
public function getEventByID(int $id): SimpleEvent {
|
||||
$query = 'SELECT * FROM events WHERE id=:id LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
$dbEvent = $statement->fetch();
|
||||
$event = new SimpleEvent(
|
||||
|
||||
return new SimpleEvent(
|
||||
$dbEvent['id'],
|
||||
$dbEvent['name'],
|
||||
DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['start']),
|
||||
DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['stop']),
|
||||
\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['start']),
|
||||
\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['stop']),
|
||||
$dbEvent['organiser'],
|
||||
$dbEvent['location'],
|
||||
$dbEvent['description']
|
||||
$dbEvent['description'],
|
||||
);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
public function getNextEventFrom(\DateTimeImmutable $date): ?Event {
|
||||
$query
|
||||
= 'SELECT id,name,start,stop,organiser,location,description FROM events WHERE start > :date ORDER BY start ASC LIMIT 1';
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) {
|
||||
$query = 'SELECT id,name,start,stop,organiser,location,description FROM events WHERE start > :date ORDER BY start ASC LIMIT 1';
|
||||
return $this->retrieve($date, $query);
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) {
|
||||
$query = 'SELECT id,name,start,stop,organiser,location,description FROM events WHERE start < :date ORDER BY start DESC LIMIT 1';
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date): ?Event {
|
||||
$query
|
||||
= 'SELECT id,name,start,stop,organiser,location,description FROM events WHERE start < :date ORDER BY start DESC LIMIT 1';
|
||||
|
||||
return $this->retrieve($date, $query);
|
||||
}
|
||||
|
||||
private function retrieve($date, $query) {
|
||||
private function retrieve(
|
||||
\DateTimeImmutable $date,
|
||||
string $query,
|
||||
): ?SimpleEvent {
|
||||
$stmt = $this->pdo->prepare($query);
|
||||
$stmt->execute(['date' => $date->format('Y-m-d H:i:s')]);
|
||||
if ($result = $stmt->fetch(PDO::FETCH_ASSOC)){
|
||||
$ev = new SimpleEvent(
|
||||
if ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
return new SimpleEvent(
|
||||
$result['id'],
|
||||
$result['name'],
|
||||
DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $result['start']),
|
||||
DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $result['stop']),
|
||||
\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $result['start']),
|
||||
\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $result['stop']),
|
||||
$result['organiser'],
|
||||
$result['location'],
|
||||
$result['description']
|
||||
$result['description'],
|
||||
);
|
||||
return $ev;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,72 +1,84 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
use \PDO;
|
||||
|
||||
class Door{
|
||||
class Door {
|
||||
private $pdo;
|
||||
|
||||
public function __construct(PDO $pdo){
|
||||
public function __construct(\PDO $pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function getAll() {
|
||||
/**
|
||||
* @return array{time: int, open: bool}[]
|
||||
*/
|
||||
public function getAll(): array {
|
||||
$query = 'SELECT time, open FROM door ORDER BY time DESC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
$doorEvents = [];
|
||||
foreach($statement->fetchAll() as $row){
|
||||
foreach ($statement->fetchAll() as $row) {
|
||||
$doorEvents[] = [
|
||||
'time' => (int)$row['time'],
|
||||
'open' => (bool)$row['open']
|
||||
'time' => (int) $row['time'],
|
||||
'open' => (bool) $row['open'],
|
||||
];
|
||||
}
|
||||
|
||||
return $doorEvents;
|
||||
}
|
||||
|
||||
public function getEntriesAfter($startTime) {
|
||||
$query = 'SELECT time, open FROM door WHERE time > :startTime ORDER BY time DESC';
|
||||
/**
|
||||
* @return array{time: int, open: bool}[]
|
||||
*/
|
||||
public function getEntriesAfter(\DateTimeImmutable $startTime): array {
|
||||
$query
|
||||
= 'SELECT time, open FROM door WHERE time > :startTime ORDER BY time DESC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':startTime', $startTime, PDO::PARAM_STR);
|
||||
$statement->bindParam(':startTime', $startTime, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$doorEvents = [];
|
||||
foreach($statement->fetchAll() as $row){
|
||||
foreach ($statement->fetchAll() as $row) {
|
||||
$doorEvents[] = [
|
||||
'time' => (int)$row['time'],
|
||||
'open' => (bool)$row['open']
|
||||
'time' => (int) $row['time'],
|
||||
'open' => (bool) $row['open'],
|
||||
];
|
||||
}
|
||||
|
||||
return $doorEvents;
|
||||
}
|
||||
|
||||
public function getCurrent() {
|
||||
/**
|
||||
* @return array{time: int, open: bool}
|
||||
*/
|
||||
public function getCurrent(): array {
|
||||
$query = 'SELECT time, open FROM door ORDER BY time DESC LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
$row = $statement->fetch();
|
||||
|
||||
return [
|
||||
'time' => (int)$row['time'],
|
||||
'open' => (bool)$row['open']
|
||||
'time' => (int) $row['time'],
|
||||
'open' => (bool) $row['open'],
|
||||
];
|
||||
}
|
||||
|
||||
private function removeOld() {
|
||||
$firstValidTime = time() - 60*60*24*7; //One week before now
|
||||
private function removeOld(): void {
|
||||
$firstValidTime = time() - 60 * 60 * 24 * 7; // One week before now
|
||||
$query = 'DELETE FROM door WHERE time < :firstValid';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':firstValid', $firstValidTime, PDO::PARAM_STR);
|
||||
$statement->bindParam(':firstValid', $firstValidTime, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
}
|
||||
|
||||
public function createEvent($time, $open) {
|
||||
public function createEvent(\DateTimeImmutable $time, bool $open): void {
|
||||
$query = 'INSERT INTO door(time, open) VALUES (:time, :open)';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':time', $time, PDO::PARAM_STR);
|
||||
$statement->bindParam(':open', $open, PDO::PARAM_STR);
|
||||
$statement->bindParam(':time', $time, \PDO::PARAM_STR);
|
||||
$statement->bindParam(':open', $open, \PDO::PARAM_BOOL);
|
||||
$statement->execute();
|
||||
|
||||
$this->removeOld();
|
||||
|
||||
@@ -1,30 +1,32 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
|
||||
abstract class Event {
|
||||
private \DateTimeImmutable $start;
|
||||
|
||||
private $start;
|
||||
|
||||
public function __construct(DateTimeImmutable $start) {
|
||||
public function __construct(\DateTimeImmutable $start) {
|
||||
$this->start = $start;
|
||||
}
|
||||
|
||||
public function getStart() {
|
||||
public function getStart(): \DateTimeImmutable {
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
public function getRelativeDate() {
|
||||
public function getRelativeDate(): string {
|
||||
if (Agenda::isToday($this->getStart())) {
|
||||
return 'i dag';
|
||||
}
|
||||
if (Agenda::isTomorrow($this->getStart())) {
|
||||
return 'i morgen';
|
||||
}
|
||||
if (Agenda::isThisWeek($this->getStart()) || $this->getStart()->sub(new DateInterval('P4D'))->getTimestamp() < time()) {
|
||||
return $this->getStart()->format("l");
|
||||
if (
|
||||
Agenda::isThisWeek($this->getStart())
|
||||
|| $this->getStart()->sub(new \DateInterval('P4D'))->getTimestamp() < time()
|
||||
) {
|
||||
return $this->getStart()->format('l');
|
||||
}
|
||||
if (Agenda::isNextWeek($this->getStart())) {
|
||||
return 'neste uke';
|
||||
@@ -32,22 +34,26 @@ abstract class Event {
|
||||
if (Agenda::isThisMonth($this->getStart())) {
|
||||
return 'denne måneden';
|
||||
}
|
||||
return $this->getStart()->format("j. F");
|
||||
|
||||
return $this->getStart()->format('j. F');
|
||||
}
|
||||
|
||||
public abstract function getStop(); /* : DateTimeImmutable */
|
||||
abstract public function getStop(): \DateTimeImmutable;
|
||||
|
||||
public abstract function getName();
|
||||
abstract public function getName(): string;
|
||||
|
||||
public abstract function getLocation();
|
||||
abstract public function getLocation(): string;
|
||||
|
||||
public abstract function getOrganiser();
|
||||
abstract public function getOrganiser(): string;
|
||||
|
||||
public abstract function getURL(); /* : string */
|
||||
abstract public function getURL(): string;
|
||||
|
||||
public abstract function getImageURL(); /* : string */
|
||||
abstract public function getImageURL(): string;
|
||||
|
||||
public abstract function getDescription(); /* : string */
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
abstract public function getDescription(): array;
|
||||
|
||||
public abstract function getColor(); /* : string */
|
||||
abstract public function getColor(): string;
|
||||
}
|
||||
|
||||
@@ -1,49 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
use \PDO;
|
||||
|
||||
class MOTD{
|
||||
class MOTD {
|
||||
private $pdo;
|
||||
|
||||
public function __construct($pdo){
|
||||
public function __construct(\PDO $pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function setMOTD($title, $content) {
|
||||
if (is_array($content)) {
|
||||
$content = implode("_", $content);
|
||||
public function setMOTD(string $title, string $content): void {
|
||||
if (\is_array($content)) {
|
||||
$content = implode('_', $content);
|
||||
}
|
||||
$query = 'INSERT INTO motd(title, content) VALUES (:title, :content);';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':content', $content, PDO::PARAM_STR);
|
||||
$statement->bindParam(':title', $title, \PDO::PARAM_STR);
|
||||
$statement->bindParam(':content', $content, \PDO::PARAM_STR);
|
||||
|
||||
$statement->execute();
|
||||
}
|
||||
|
||||
public function getMOTD() {
|
||||
$query = 'SELECT motd.title, motd.content FROM motd ORDER BY motd.id DESC LIMIT 1';
|
||||
/**
|
||||
* @return array{title: string, content: string[]}
|
||||
*/
|
||||
public function getMOTD(): array {
|
||||
$query
|
||||
= 'SELECT motd.title, motd.content FROM motd ORDER BY motd.id DESC LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
$data = $statement->fetch();
|
||||
$motd = array("title" => $data[0], "content" => explode("\n", $data[1]));
|
||||
|
||||
return $motd;
|
||||
return ['title' => $data[0], 'content' => explode("\n", $data[1])];
|
||||
}
|
||||
|
||||
public function getMOTD_history($limit = 5) {
|
||||
$query = 'SELECT motd.title, motd.content FROM motd ORDER BY motd.id DESC LIMIT :limit';
|
||||
/**
|
||||
* @return array{title: string, content: string[]}
|
||||
*/
|
||||
public function getMOTD_history(int $limit = 5): array {
|
||||
$query
|
||||
= 'SELECT motd.title, motd.content FROM motd ORDER BY motd.id DESC LIMIT :limit';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':limit', $limit, PDO::PARAM_STR);
|
||||
$statement->bindParam(':limit', $limit, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$data = $statement->fetch();
|
||||
$motd = array("title" => $data[0], "content" => explode("\n", $data[1]));
|
||||
|
||||
return $motd;
|
||||
return ['title' => $data[0], 'content' => explode("\n", $data[1])];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +1,110 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
class Project{
|
||||
private $id, $name, $descr, $active;
|
||||
class Project {
|
||||
private int $id;
|
||||
private string $title;
|
||||
private array $description_en;
|
||||
private array $description_no;
|
||||
private ?string $gitea_link;
|
||||
private ?string $issue_board_link;
|
||||
private ?string $wiki_link;
|
||||
private array $programming_languages;
|
||||
private array $technologies;
|
||||
private array $keywords;
|
||||
// NOTE: spdx identifier
|
||||
private ?string $license;
|
||||
private ?string $logo_url;
|
||||
|
||||
public function __construct($id, $name, $descr, $active){
|
||||
public function __construct(
|
||||
int $id,
|
||||
string $title,
|
||||
?string $description_en,
|
||||
?string $description_no,
|
||||
?string $gitea_link,
|
||||
?string $issue_board_link,
|
||||
?string $wiki_link,
|
||||
?string $programming_languages,
|
||||
?string $technologies,
|
||||
?string $keywords,
|
||||
?string $license,
|
||||
?string $logo_url,
|
||||
) {
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->descr = explode("\n", $descr);
|
||||
$this->active = $active;
|
||||
$this->title = $title;
|
||||
$this->description_en
|
||||
= $description_en === null || $description_en === ''
|
||||
? []
|
||||
: explode("\n", $description_en);
|
||||
$this->description_no
|
||||
= $description_no === null || $description_no === ''
|
||||
? []
|
||||
: explode("\n", $description_no);
|
||||
$this->gitea_link = $gitea_link;
|
||||
$this->issue_board_link = $issue_board_link;
|
||||
$this->wiki_link = $wiki_link;
|
||||
$this->programming_languages
|
||||
= $programming_languages === null || $programming_languages === ''
|
||||
? []
|
||||
: explode(',', $programming_languages);
|
||||
$this->technologies
|
||||
= $technologies === null || $technologies === ''
|
||||
? []
|
||||
: explode(',', $technologies);
|
||||
$this->keywords
|
||||
= $keywords === null || $keywords === '' ? [] : explode(',', $keywords);
|
||||
$this->license = $license;
|
||||
$this->logo_url = $logo_url;
|
||||
}
|
||||
|
||||
public function getID(){
|
||||
public function getID(): int {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
public function getTitle(): string {
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function getDescription(){
|
||||
return $this->descr;
|
||||
public function getDescriptionEn(): array {
|
||||
return $this->description_en;
|
||||
}
|
||||
|
||||
public function getActive(){
|
||||
return $this->active;
|
||||
public function getDescriptionNo(): array {
|
||||
return $this->description_no;
|
||||
}
|
||||
|
||||
public function getGiteaLink(): ?string {
|
||||
return $this->gitea_link;
|
||||
}
|
||||
|
||||
public function getIssueBoardLink(): ?string {
|
||||
return $this->issue_board_link;
|
||||
}
|
||||
|
||||
public function getWikiLink(): ?string {
|
||||
return $this->wiki_link;
|
||||
}
|
||||
|
||||
public function getProgrammingLanguages(): array {
|
||||
return $this->programming_languages;
|
||||
}
|
||||
|
||||
public function getTechnologies(): array {
|
||||
return $this->technologies;
|
||||
}
|
||||
|
||||
public function getKeywords(): array {
|
||||
return $this->keywords;
|
||||
}
|
||||
|
||||
public function getLicense(): ?string {
|
||||
return $this->license;
|
||||
}
|
||||
|
||||
public function getLogoURL(): ?string {
|
||||
return $this->logo_url;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
use \PDO;
|
||||
|
||||
class ProjectManager{
|
||||
class ProjectManager {
|
||||
private $pdo;
|
||||
|
||||
public function __construct(PDO $pdo){
|
||||
public function __construct(\PDO $pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function getAll() {
|
||||
$query = 'SELECT * FROM projects ORDER BY id ASC';
|
||||
/**
|
||||
* @return Project[]
|
||||
*/
|
||||
public function getAll(): array {
|
||||
$query = 'SELECT * FROM project ORDER BY id ASC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
$projects = [];
|
||||
foreach($statement->fetchAll() as $dbProj){
|
||||
foreach ($statement->fetchAll() as $dbProj) {
|
||||
$project = new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active']
|
||||
$dbProj['title'],
|
||||
$dbProj['description_en'],
|
||||
$dbProj['description_no'],
|
||||
$dbProj['gitea_link'],
|
||||
$dbProj['issue_board_link'],
|
||||
$dbProj['wiki_link'],
|
||||
$dbProj['languages'],
|
||||
$dbProj['technologies'],
|
||||
$dbProj['keywords'],
|
||||
$dbProj['license'],
|
||||
$dbProj['logo_url']
|
||||
);
|
||||
$projects[] = $project;
|
||||
}
|
||||
@@ -29,48 +41,72 @@ class ProjectManager{
|
||||
return $projects;
|
||||
}
|
||||
|
||||
public function getByID($id){
|
||||
$query = 'SELECT * FROM projects WHERE id=:id LIMIT 1';
|
||||
public function getByID(int $id): ?Project {
|
||||
$query = 'SELECT * FROM project WHERE id=:id LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
$dbProj = $statement->fetch();
|
||||
if (!$dbProj) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
$project = new Project(
|
||||
|
||||
return new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active']
|
||||
$dbProj['title'],
|
||||
$dbProj['description_en'],
|
||||
$dbProj['description_no'],
|
||||
$dbProj['gitea_link'],
|
||||
$dbProj['issue_board_link'],
|
||||
$dbProj['wiki_link'],
|
||||
$dbProj['languages'],
|
||||
$dbProj['technologies'],
|
||||
$dbProj['keywords'],
|
||||
$dbProj['license'],
|
||||
$dbProj['logo_url']
|
||||
);
|
||||
|
||||
return $project;
|
||||
}
|
||||
|
||||
public function getByOwner($uname){
|
||||
$query = 'SELECT projectid FROM projectmembers WHERE uname=:uname';
|
||||
/**
|
||||
* @return Project[]
|
||||
*/
|
||||
public function getByOwner(string $uname): array {
|
||||
$query = '
|
||||
SELECT projectid FROM project
|
||||
JOIN project__project_maintainer ON project.id = project__project_maintainer.project_id
|
||||
JOIN project_maintainer ON project__project_maintainer.uname = project_maintainer.uname
|
||||
WHERE project_maintainer.uname = :uname
|
||||
';
|
||||
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$projectIDs = $statement->fetchAll();
|
||||
$projects = [];
|
||||
foreach($projectIDs as $id){
|
||||
foreach ($projectIDs as $id) {
|
||||
$id = $id['projectid'];
|
||||
|
||||
$query = 'SELECT * FROM projects WHERE id=:id';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
foreach($statement->fetchAll() as $dbProj){
|
||||
foreach ($statement->fetchAll() as $dbProj) {
|
||||
$project = new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active']
|
||||
$dbProj['title'],
|
||||
$dbProj['description_en'],
|
||||
$dbProj['description_no'],
|
||||
$dbProj['gitea_link'],
|
||||
$dbProj['issue_board_link'],
|
||||
$dbProj['wiki_link'],
|
||||
$dbProj['languages'],
|
||||
$dbProj['technologies'],
|
||||
$dbProj['keywords'],
|
||||
$dbProj['license'],
|
||||
$dbProj['logo_url']
|
||||
);
|
||||
$projects[] = $project;
|
||||
}
|
||||
@@ -79,43 +115,31 @@ class ProjectManager{
|
||||
return $projects;
|
||||
}
|
||||
|
||||
public function getProjectMembers($id){
|
||||
$query = 'SELECT * FROM projectmembers WHERE projectid=:id';
|
||||
/**
|
||||
* @return array<int,array>
|
||||
*/
|
||||
public function getProjectMembers(int $id): array {
|
||||
$query = '
|
||||
SELECT id FROM project
|
||||
JOIN project__project_maintainer ON project.id = project__project_maintainer.project_id
|
||||
JOIN project_maintainer ON project__project_maintainer.uname = project_maintainer.uname
|
||||
WHERE project.id = :id
|
||||
';
|
||||
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$members = [];
|
||||
foreach($statement->fetchAll() as $dbUsr){
|
||||
$members[] = [
|
||||
$maintainers = [];
|
||||
foreach ($statement->fetchAll() as $dbUsr) {
|
||||
$maintainers[] = [
|
||||
'name' => $dbUsr['name'],
|
||||
'uname' => $dbUsr['uname'],
|
||||
'link' => $dbUsr['link'],
|
||||
'mail' => $dbUsr['mail'],
|
||||
'role' => $dbUsr['role'],
|
||||
'lead' => $dbUsr['lead'],
|
||||
'owner' => $dbUsr['owner']
|
||||
];
|
||||
}
|
||||
|
||||
return $members;
|
||||
}
|
||||
|
||||
public function getProjectOwner($id){
|
||||
$query = 'SELECT * FROM projectmembers WHERE (projectid=:id AND owner=1)';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$dbOwner = $statement->fetch();
|
||||
$owner = [
|
||||
'name' => $dbOwner['name'],
|
||||
'uname' => $dbOwner['uname'],
|
||||
'mail' => $dbOwner['mail'],
|
||||
'role' => $dbOwner['role'],
|
||||
'lead' => $dbOwner['lead'],
|
||||
'owner' => $dbOwner['owner']
|
||||
];
|
||||
|
||||
return $owner;
|
||||
return $maintainers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
class SimpleEvent extends Event {
|
||||
private int $id;
|
||||
private string $name;
|
||||
private array $descr;
|
||||
private \DateTimeImmutable $start;
|
||||
private \DateTimeImmutable $end;
|
||||
private string $org;
|
||||
private string $loc;
|
||||
|
||||
private $id, $name, $descr, $start, $end, $org, $loc;
|
||||
|
||||
public function __construct($id, $name,\DateTimeImmutable $start,\DateTimeImmutable $end,$org, $loc, $descr, $_isDBEvent = false){
|
||||
public function __construct(
|
||||
int $id,
|
||||
string $name,
|
||||
\DateTimeImmutable $start,
|
||||
\DateTimeImmutable $end,
|
||||
string $org,
|
||||
string $loc,
|
||||
string $descr,
|
||||
bool $_isDBEvent = false,
|
||||
) {
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->start = $start;
|
||||
@@ -15,44 +32,43 @@ class SimpleEvent extends Event {
|
||||
$this->descr = explode("\n", $descr);
|
||||
}
|
||||
|
||||
public function getID(){
|
||||
public function getID(): int {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getStart(){
|
||||
public function getStart(): \DateTimeImmutable {
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
public function getStop(){
|
||||
public function getStop(): \DateTimeImmutable {
|
||||
return $this->end;
|
||||
}
|
||||
|
||||
public function getOrganiser(){
|
||||
public function getOrganiser(): string {
|
||||
return $this->org;
|
||||
}
|
||||
|
||||
public function getLocation(){
|
||||
public function getLocation(): string {
|
||||
return $this->loc;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
public function getName(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getURL() {
|
||||
return ('/hendelser/info.php?id=' . $this->id);
|
||||
public function getURL(): string {
|
||||
return '/hendelser/info.php?id=' . $this->id;
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
return null;
|
||||
public function getImageURL(): string {
|
||||
return '/';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
public function getDescription(): array {
|
||||
return $this->descr;
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#3b7";
|
||||
public function getColor(): string {
|
||||
return '#3b7';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,36 +1,53 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Activity;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
use pvv\side\Activity;
|
||||
|
||||
class AnimekveldActivity implements Activity {
|
||||
|
||||
public function nextDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 20 || $date->format('H') == 19 && $date->format('i') > 30)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D'))->setTime(19, 30, 0));
|
||||
public function nextDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||
if (
|
||||
(int) $date->format('H') > 20
|
||||
|| ((int) $date->format('H') === 19 && (int) $date->format('i') > 30)
|
||||
) {
|
||||
return $this->nextDate(
|
||||
$date->add(new \DateInterval('P1D'))->setTime(19, 30, 0),
|
||||
);
|
||||
}
|
||||
$date = $date->setTime(19, 30, 0);
|
||||
if ($date->format('N') != 5)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D')));
|
||||
if ((int) $date->format('N') !== 5) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function prevDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 19 || $date->format('H') == 20 && $date->format('i') < 30)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D'))->setTime(19, 30, 0));
|
||||
public function prevDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||
if (
|
||||
(int) $date->format('H') < 19
|
||||
|| ((int) $date->format('H') === 20 && (int) $date->format('i') < 30)
|
||||
) {
|
||||
return $this->prevDate(
|
||||
$date->sub(new \DateInterval('P1D'))->setTime(19, 30, 0),
|
||||
);
|
||||
}
|
||||
$date = $date->setTime(19, 30, 0);
|
||||
if ($date->format('N') != 5)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
||||
if ((int) $date->format('N') !== 5) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
public function getNextEventFrom(\DateTimeImmutable $date): AnimekveldEvent {
|
||||
return new AnimekveldEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
public function getPreviousEventFrom(
|
||||
\DateTimeImmutable $date,
|
||||
): AnimekveldEvent {
|
||||
return new AnimekveldEvent($this->prevDate($date));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,37 +1,38 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Event;
|
||||
|
||||
use \DateInterval;
|
||||
use pvv\side\Event;
|
||||
|
||||
class AnimekveldEvent extends Event {
|
||||
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
||||
public function getStop(): \DateTimeImmutable {
|
||||
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getName() /* : string */ {
|
||||
return "Animekveld";
|
||||
public function getName(): string {
|
||||
return 'Animekveld';
|
||||
}
|
||||
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Koserommet";
|
||||
public function getLocation(): string {
|
||||
/* : Location */
|
||||
return 'Koserommet';
|
||||
}
|
||||
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "Christoffer Viken";
|
||||
public function getOrganiser(): string {
|
||||
return 'Christoffer Viken';
|
||||
}
|
||||
|
||||
public function getURL() /* : string */ {
|
||||
public function getURL(): string {
|
||||
return '/anime/';
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
public function getImageURL(): string {
|
||||
return '/sosiale/animekveld.jpg';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
public function getDescription(): array {
|
||||
return [
|
||||
'Er du glad i japanske tegneserier eller bare nysgjerrig på hva anime er?',
|
||||
'Bli med oss hver fredag, der vi finner frem de nyeste episodene for sesongen!',
|
||||
@@ -41,8 +42,7 @@ class AnimekveldEvent extends Event {
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#35a";
|
||||
public function getColor(): string {
|
||||
return '#35a';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,41 +1,59 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Activity;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
use pvv\side\Activity;
|
||||
|
||||
class BrettspillActivity implements Activity {
|
||||
|
||||
public function nextDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 17 || $date->format('H') == 16 && $date->format('i') > 15)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D'))->setTime(16, 15, 0));
|
||||
$date = $date->setTime(16, 15, 0);
|
||||
if ($date->format('N') != 7)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2 - 1)
|
||||
return $this->nextDate($date->add(new DateInterval('P7D')));
|
||||
return $date;
|
||||
public function nextDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||
if (
|
||||
(int) $date->format('H') > 17
|
||||
|| ((int) $date->format('H') === 16 && (int) $date->format('i') > 15)
|
||||
) {
|
||||
return $this->nextDate(
|
||||
$date->add(new \DateInterval('P1D'))->setTime(16, 15, 0),
|
||||
);
|
||||
}
|
||||
|
||||
public function prevDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 16 || $date->format('H') == 17 && $date->format('i') < 15)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D'))->setTime(16, 15, 0));
|
||||
$date = $date->setTime(16, 15, 0);
|
||||
if ($date->format('N') != 7)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2 - 1)
|
||||
return $this->prevDate($date->sub(new DateInterval('P7D')));
|
||||
if ((int) $date->format('N') !== 7) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
if (((int) $date->format('W') % 2) - 1) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
public function prevDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||
if (
|
||||
(int) $date->format('H') < 16
|
||||
|| ((int) $date->format('H') === 17 && (int) $date->format('i') < 15)
|
||||
) {
|
||||
return $this->prevDate(
|
||||
$date->sub(new \DateInterval('P1D'))->setTime(16, 15, 0),
|
||||
);
|
||||
}
|
||||
$date = $date->setTime(16, 15, 0);
|
||||
if ((int) $date->format('N') !== 7) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
if (((int) $date->format('W') % 2) - 1) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function getNextEventFrom(\DateTimeImmutable $date): BrettspillEvent {
|
||||
return new BrettspillEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
public function getPreviousEventFrom(
|
||||
\DateTimeImmutable $date,
|
||||
): BrettspillEvent {
|
||||
return new BrettspillEvent($this->prevDate($date));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Event;
|
||||
|
||||
use \DateInterval;
|
||||
use pvv\side\Event;
|
||||
|
||||
class BrettspillEvent extends Event {
|
||||
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
||||
public function getStop(): \DateTimeImmutable {
|
||||
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getName() /* : string */ {
|
||||
return "Brettspillkveld";
|
||||
public function getName(): string {
|
||||
return 'Brettspillkveld';
|
||||
}
|
||||
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Programvareverkstedet";
|
||||
public function getLocation(): string {
|
||||
return 'Programvareverkstedet';
|
||||
}
|
||||
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "Programvareverkstedet";
|
||||
public function getOrganiser(): string {
|
||||
return 'Programvareverkstedet';
|
||||
}
|
||||
|
||||
public function getURL() /* : string */ {
|
||||
public function getURL(): string {
|
||||
return '/brettspill/';
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
public function getImageURL(): string {
|
||||
return '/sosiale/brettspill.jpg';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
public function getDescription(): array {
|
||||
return [
|
||||
'Er du en hardcore brettspillentusiast eller en nybegynner som har så vidt spilt ludo? '.
|
||||
'Da er vår brettspillkveld noe for deg! ' .
|
||||
'Vi tar ut et par spill fra vårt samling of spiller så mye vi orker. Kom innom!',
|
||||
'Er du en hardcore brettspillentusiast eller en nybegynner som har så vidt spilt ludo? '
|
||||
. 'Da er vår brettspillkveld noe for deg! '
|
||||
. 'Vi tar ut et par spill fra vårt samling of spiller så mye vi orker. Kom innom!',
|
||||
'',
|
||||
'## Vår samling',
|
||||
'',
|
||||
@@ -58,8 +58,7 @@ class BrettspillEvent extends Event {
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#000";
|
||||
public function getColor(): string {
|
||||
return '#000';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,40 +1,59 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Activity;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
use pvv\side\Activity;
|
||||
|
||||
class DriftkveldActivity implements Activity {
|
||||
|
||||
public function nextDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 18 || $date->format('H') == 17 && $date->format('i') > 30)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
public function nextDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||
if (
|
||||
(int) $date->format('H') > 18
|
||||
|| ((int) $date->format('H') === 17 && (int) $date->format('i') > 30)
|
||||
) {
|
||||
return $this->nextDate(
|
||||
$date->add(new \DateInterval('P1D'))->setTime(18, 15, 0),
|
||||
);
|
||||
}
|
||||
$date = $date->setTime(18, 15, 0);
|
||||
if ($date->format('N') != 6)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2 - 1)
|
||||
return $this->nextDate($date->add(new DateInterval('P7D')));
|
||||
if ((int) $date->format('N') !== 6) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
if (((int) $date->format('W') % 2) - 1) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function prevDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 17 || $date->format('H') == 18 && $date->format('i') < 30)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
public function prevDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||
if (
|
||||
(int) $date->format('H') < 17
|
||||
|| ((int) $date->format('H') === 18 && (int) $date->format('i') < 30)
|
||||
) {
|
||||
return $this->prevDate(
|
||||
$date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0),
|
||||
);
|
||||
}
|
||||
$date = $date->setTime(18, 15, 0);
|
||||
if ($date->format('N') != 6)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2 - 1)
|
||||
return $this->prevDate($date->sub(new DateInterval('P7D')));
|
||||
if ((int) $date->format('N') !== 6) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
if (((int) $date->format('W') % 2) - 1) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
public function getNextEventFrom(\DateTimeImmutable $date): DriftkveldEvent {
|
||||
return new DriftkveldEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
public function getPreviousEventFrom(
|
||||
\DateTimeImmutable $date,
|
||||
): DriftkveldEvent {
|
||||
return new DriftkveldEvent($this->prevDate($date));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,49 +1,48 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Event;
|
||||
|
||||
use \DateInterval;
|
||||
use pvv\side\Event;
|
||||
|
||||
class DriftkveldEvent extends Event {
|
||||
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
||||
public function getStop(): \DateTimeImmutable {
|
||||
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getName() /* : string */ {
|
||||
return "Driftkveld";
|
||||
public function getName(): string {
|
||||
return 'Driftkveld';
|
||||
}
|
||||
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Terminalrommet / Discord / IRC";
|
||||
public function getLocation(): string {
|
||||
return 'Terminalrommet / Discord / IRC';
|
||||
}
|
||||
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "Torstein Nordgård-Hansen";
|
||||
public function getOrganiser(): string {
|
||||
return 'Torstein Nordgård-Hansen';
|
||||
}
|
||||
|
||||
public function getURL() /* : string */ {
|
||||
public function getURL(): string {
|
||||
return '/driftkveld/';
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
public function getImageURL(): string {
|
||||
return '/sosiale/drift.jpg';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
public function getDescription(): array {
|
||||
return [
|
||||
'Vil du drifte?',
|
||||
'Vil du være kul kis TM?',
|
||||
'Kom på driftkveld!',
|
||||
'',
|
||||
'Vi møtes annenhver uke for å ta unna driftarbeid og drikke kaffe.',
|
||||
'Alle PVVere er velkommene, enten de er erfarne driftere eller helt utenforstående!'
|
||||
'Alle PVVere er velkommene, enten de er erfarne driftere eller helt utenforstående!',
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#35a";
|
||||
public function getColor(): string {
|
||||
return '#35a';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,40 +1,47 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Activity;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
use pvv\side\Activity;
|
||||
|
||||
class HackekveldActivity implements Activity {
|
||||
|
||||
public function nextDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 18 || $date->format('H') == 17 && $date->format('i') > 30)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
public function nextDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||
if ((int) $date->format('H') > 18 || (int) $date->format('H') === 17 && (int) $date->format('i') > 30) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
}
|
||||
$date = $date->setTime(16, 15, 0);
|
||||
if ($date->format('N') != 6)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2)
|
||||
return $this->nextDate($date->add(new DateInterval('P7D')));
|
||||
if ((int) $date->format('N') !== 6) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
if ((int) $date->format('W') % 2) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function prevDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 17 || $date->format('H') == 18 && $date->format('i') < 30)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
public function prevDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||
if ((int) $date->format('H') < 17 || (int) $date->format('H') === 18 && (int) $date->format('i') < 30) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
}
|
||||
$date = $date->setTime(18, 15, 0);
|
||||
if ($date->format('N') != 6)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2)
|
||||
return $this->prevDate($date->sub(new DateInterval('P7D')));
|
||||
if ((int) $date->format('N') !== 6) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
if ((int) $date->format('W') % 2) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
public function getNextEventFrom(\DateTimeImmutable $date): HackekveldEvent {
|
||||
return new HackekveldEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date): HackekveldEvent {
|
||||
return new HackekveldEvent($this->prevDate($date));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,45 +1,44 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Event;
|
||||
|
||||
use \DateInterval;
|
||||
use pvv\side\Event;
|
||||
|
||||
class HackekveldEvent extends Event {
|
||||
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
||||
public function getStop(): \DateTimeImmutable {
|
||||
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getName() /* : string */ {
|
||||
return "Hackekveld";
|
||||
public function getName(): string {
|
||||
return 'Hackekveld';
|
||||
}
|
||||
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Terminalrommet / Discord / IRC";
|
||||
public function getLocation(): string {
|
||||
return 'Terminalrommet / Discord / IRC';
|
||||
}
|
||||
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "PVV";
|
||||
public function getOrganiser(): string {
|
||||
return 'PVV';
|
||||
}
|
||||
|
||||
public function getURL() /* : string */ {
|
||||
public function getURL(): string {
|
||||
return '#';
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
public function getImageURL(): string {
|
||||
return '/pvv-logo.png';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
public function getDescription(): array {
|
||||
return [
|
||||
'Mange PVV-medlemmer liker å programmere.',
|
||||
'Hvis du også liker å programmere, så bli med! Her kan du jobbe med dine egne prosjekter eller starte noe med andre nerder her på huset. Vi møtes for en hyggelig prat, mye god programmering og delsponset pizza.'
|
||||
'Hvis du også liker å programmere, så bli med! Her kan du jobbe med dine egne prosjekter eller starte noe med andre nerder her på huset. Vi møtes for en hyggelig prat, mye god programmering og delsponset pizza.',
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#35a";
|
||||
public function getColor(): string {
|
||||
return '#35a';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,40 +1,48 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Activity;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
use pvv\side\Activity;
|
||||
use pvv\side\Event;
|
||||
|
||||
class NerdepitsaActivity implements Activity {
|
||||
|
||||
public function nextDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 19)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D'))->setTime(19, 0, 0));
|
||||
public function nextDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||
if ((int) $date->format('H') > 19) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
||||
}
|
||||
$date = $date->setTime(19, 0, 0);
|
||||
if ($date->format('N') != 5)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2)
|
||||
return $this->nextDate($date->add(new DateInterval('P7D')));
|
||||
if ((int) $date->format('N') !== 5) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
if ((int) $date->format('W') % 2) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function prevDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 19)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D'))->setTime(19, 0, 0));
|
||||
public function prevDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||
if ((int) $date->format('H') < 19) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
||||
}
|
||||
$date = $date->setTime(19, 0, 0);
|
||||
if ($date->format('N') != 5)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2)
|
||||
return $this->prevDate($date->sub(new DateInterval('P7D')));
|
||||
if ((int) $date->format('N') !== 5) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
if ((int) $date->format('W') % 2) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
public function getNextEventFrom(\DateTimeImmutable $date): ?Event {
|
||||
return new NerdepitsaEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date): ?Event {
|
||||
return new NerdepitsaEvent($this->prevDate($date));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Event;
|
||||
|
||||
use \DateInterval;
|
||||
use pvv\side\Event;
|
||||
|
||||
class NerdepitsaEvent extends Event {
|
||||
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new DateInterval('PT2H1800S'));
|
||||
public function getStop(): \DateTimeImmutable {
|
||||
return $this->getStart()->add(new \DateInterval('PT2H1800S'));
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return "Nerdepitsa";
|
||||
public function getName(): string {
|
||||
return 'Nerdepitsa';
|
||||
}
|
||||
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Peppes Kjøpmansgata";
|
||||
public function getLocation(): string {
|
||||
return 'Peppes Kjøpmansgata';
|
||||
}
|
||||
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "Anders Christensen";
|
||||
public function getOrganiser(): string {
|
||||
return 'Anders Christensen';
|
||||
}
|
||||
|
||||
public function getURL() /* : string */ {
|
||||
public function getURL(): string {
|
||||
return '/nerdepitsa/';
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
public function getImageURL(): string {
|
||||
return '/sosiale/nerdepitsa.jpg';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
public function getDescription(): array {
|
||||
return [
|
||||
'Hei, har du lyst til å bli med på pizzaspising annenhver fredag? Vi møtes på Peppes i Kjøpmannsgata fredag klokken 19.00 hver partallsuke!',
|
||||
'',
|
||||
@@ -39,12 +39,11 @@ class NerdepitsaEvent extends Event {
|
||||
'',
|
||||
'Det er ikke noe krav at du er nerd... noen av oss virker faktisk nesten normale! Det er heller ikke noe krav at du kjenner noen fra før. Det er ikke engang et krav at du må like pizza! (selv om det hjelper) Dersom du har lyst til å treffe personer fra datamiljøet ved NTNU så bare still opp! Vi biter ikke, vel, bortsett fra pizzaen da.',
|
||||
'',
|
||||
'Vi bestiller så mye pizza som vi i fellesskap klarer å stappe i oss, og splitter dermed pizza-regningen broderlig, mens hver enkelt betaler for sin egen drikke, dessert mm. Vell møtt!'
|
||||
'Vi bestiller så mye pizza som vi i fellesskap klarer å stappe i oss, og splitter dermed pizza-regningen broderlig, mens hver enkelt betaler for sin egen drikke, dessert mm. Vell møtt!',
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#c35";
|
||||
public function getColor(): string {
|
||||
return '#c35';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
ini_set('date.timezone', 'Europe/Oslo');
|
||||
|
||||
require implode(DIRECTORY_SEPARATOR, [dirname(dirname(dirname(__DIR__))), '', '_autoload.php']);
|
||||
require implode(\DIRECTORY_SEPARATOR, [\dirname(__DIR__, 3), '', '_autoload.php']);
|
||||
|
||||
$c = new AnimekveldActivity;
|
||||
die($c->nextDate(new \DateTimeImmutable)->format(DATE_RFC2822));
|
||||
$c = new AnimekveldActivity();
|
||||
exit($c->nextDate(new \DateTimeImmutable())->format(\DATE_RFC2822));
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
ini_set('date.timezone', 'Europe/Oslo');
|
||||
|
||||
require implode(DIRECTORY_SEPARATOR, [dirname(dirname(dirname(__DIR__))), '', '_autoload.php']);
|
||||
require implode(\DIRECTORY_SEPARATOR, [\dirname(__DIR__, 3), '', '_autoload.php']);
|
||||
|
||||
$c = new NerdepitsaActivity;
|
||||
die($c->prevDate(new \DateTimeImmutable)->format(DATE_RFC2822));
|
||||
$c = new NerdepitsaActivity();
|
||||
exit($c->prevDate(new \DateTimeImmutable())->format(\DATE_RFC2822));
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
<?php
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
||||
if(!$userManager->hasGroup($uname, 'aktiviteter')){
|
||||
if (!$userManager->hasGroup($uname, 'aktiviteter')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$eventID = $_GET['id'];
|
||||
|
||||
@@ -1,53 +1,52 @@
|
||||
<?php
|
||||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'nb_NO');
|
||||
setlocale(\LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../../inc/navbar.php';
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$uname = $attrs['uid'][0];
|
||||
$name = $attrs['cn'][0];
|
||||
|
||||
if(!$userManager->hasGroup($uname, 'aktiviteter')){
|
||||
if (!$userManager->hasGroup($uname, 'aktiviteter')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$customActivity = new \pvv\side\DBActivity($pdo);
|
||||
$customActivity = new pvv\side\DBActivity($pdo);
|
||||
|
||||
$new = 0;
|
||||
if(isset($_GET['new'])){
|
||||
if (isset($_GET['new'])) {
|
||||
$new = $_GET['new'];
|
||||
}
|
||||
|
||||
$eventID = 0;
|
||||
if(isset($_GET['id'])){
|
||||
if (isset($_GET['id'])) {
|
||||
$eventID = $_GET['id'];
|
||||
}else if($new == 0){
|
||||
} elseif ($new == 0) {
|
||||
echo "\nID not set";
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$today = new DateTimeImmutable;
|
||||
$today = new DateTimeImmutable();
|
||||
$today = $today->setTime(18, 15);
|
||||
$defaultStart = $today->format("Y-m-d H:15:00");
|
||||
$defaultStart = $today->format('Y-m-d H:15:00');
|
||||
$inTwoHours = $today->add(new DateInterval('PT1H45M'));
|
||||
$defaultEnd = $inTwoHours->format("Y-m-d H:00:00");
|
||||
$defaultEnd = $inTwoHours->format('Y-m-d H:00:00');
|
||||
|
||||
$event;
|
||||
if($new == 0){
|
||||
|
||||
if ($new == 0) {
|
||||
$event = $customActivity->getEventByID($eventID);
|
||||
}
|
||||
else {
|
||||
$event = new \pvv\side\SimpleEvent(
|
||||
} else {
|
||||
$event = new pvv\side\SimpleEvent(
|
||||
0,
|
||||
'',
|
||||
$today,
|
||||
@@ -86,26 +85,26 @@ else {
|
||||
<h2>Aktivietsadministrasjon</h2>
|
||||
<hr class="ruler">
|
||||
|
||||
<h2><?= ($new == 1 ? "Ny hendelse" : "Rediger hendelse"); ?></h2>
|
||||
<h2><?php echo $new == 1 ? 'Ny hendelse' : 'Rediger hendelse'; ?></h2>
|
||||
|
||||
<form action="update.php", method="post" class="gridsplit fullwidth_inputs">
|
||||
<div class="gridl">
|
||||
<p class="subtitle">Tittel</p>
|
||||
<input type="text" name="title" value="<?= $event->getName() ?>" class="boxinput" required placeholder="En kul hendelse"><br>
|
||||
<input type="text" name="title" value="<?php echo $event->getName(); ?>" class="boxinput" required placeholder="En kul hendelse"><br>
|
||||
|
||||
<div class="gridsplit5050">
|
||||
<div class="gridl">
|
||||
<p class="subtitle">Arrangør</p>
|
||||
<input type="text" name="organiser" value="<?= $event->getOrganiser() ?>" class="boxinput" required placeholder="<?= $name ?>"><br>
|
||||
<input type="text" name="organiser" value="<?php echo $event->getOrganiser(); ?>" class="boxinput" required placeholder="<?php echo $name; ?>"><br>
|
||||
</div>
|
||||
<div class="gridr noborder">
|
||||
<p class="subtitle">Sted</p>
|
||||
<input type="text" name="location" value="<?= $event->getLocation() ?>" class="boxinput" required placeholder="Terminalrommet"><br>
|
||||
<input type="text" name="location" value="<?php echo $event->getLocation(); ?>" class="boxinput" required placeholder="Terminalrommet"><br>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="subtitle">Beskrivelse (<i>markdown</i>)</p>
|
||||
<textarea name="desc" rows="8" class="boxinput" placeholder="Beskrivelse" required><?= implode("\n", $event->getDescription()); ?></textarea>
|
||||
<textarea name="desc" rows="8" class="boxinput" placeholder="Beskrivelse" required><?php echo implode("\n", $event->getDescription()); ?></textarea>
|
||||
|
||||
|
||||
</div>
|
||||
@@ -113,22 +112,22 @@ else {
|
||||
<div class="gridr" style="line-height: 1.3em;">
|
||||
<h4>Starttid</h4><br>
|
||||
<i>Måned:</i><br>
|
||||
<input name="start_mon" type="month" class="boxinput" required value="<?= $event->getStart()->format('Y-m') ?>"><br>
|
||||
<input name="start_mon" type="month" class="boxinput" required value="<?php echo $event->getStart()->format('Y-m'); ?>"><br>
|
||||
<i>Dag:</i><br>
|
||||
<input name="start_day" type="number" min="1" max="31" required class="boxinput" value="<?= $event->getStart()->format('d') ?>"><br>
|
||||
<input name="start_day" type="number" min="1" max="31" required class="boxinput" value="<?php echo $event->getStart()->format('d'); ?>"><br>
|
||||
<i>Klokkeslett:</i><br>
|
||||
<input name="start_time" type="time" class="boxinput" required value="<?= $event->getStart()->format('H:i:s') ?>"><br>
|
||||
<input name="start_time" type="time" class="boxinput" required value="<?php echo $event->getStart()->format('H:i:s'); ?>"><br>
|
||||
<br>
|
||||
<h4>Varighet</h4><br>
|
||||
<?php $diff = $event->getStart()->diff($event->getStop()); ?>
|
||||
<i>Timer:</i><br>
|
||||
<input name="lasts_hours" type="number" min="0" class="boxinput" required value="<?= $diff->h ?>"><br>
|
||||
<input name="lasts_hours" type="number" min="0" class="boxinput" required value="<?php echo $diff->h; ?>"><br>
|
||||
<i>Minutter:</i><br>
|
||||
<input name="lasts_minutes" type="number" min="0" max="59" class="boxinput" required value="<?= $diff->i ?>"><br>
|
||||
<input name="lasts_minutes" type="number" min="0" max="59" class="boxinput" required value="<?php echo $diff->i; ?>"><br>
|
||||
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="id" value="<?= $event->getID() ?>" />
|
||||
<input type="hidden" name="id" value="<?php echo $event->getID(); ?>" />
|
||||
|
||||
<div class="allgrids" style="margin-top: 2em;">
|
||||
<hr class="ruler">
|
||||
|
||||
@@ -1,49 +1,47 @@
|
||||
<?php
|
||||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'nb_NO');
|
||||
setlocale(\LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../../inc/navbar.php';
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
||||
if(!$userManager->hasGroup($uname, 'aktiviteter')){
|
||||
if (!$userManager->hasGroup($uname, 'aktiviteter')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$customActivity = new \pvv\side\DBActivity($pdo);
|
||||
$customActivity = new pvv\side\DBActivity($pdo);
|
||||
$events = $customActivity->getAllEvents();
|
||||
|
||||
$page = 1;
|
||||
if(isset($_GET['page'])){
|
||||
if (isset($_GET['page'])) {
|
||||
$page = $_GET['page'];
|
||||
}
|
||||
|
||||
$filterTitle = '';
|
||||
if(isset($_GET['title'])){
|
||||
if (isset($_GET['title'])) {
|
||||
$filterTitle = $_GET['title'];
|
||||
}
|
||||
|
||||
$filterOrganiser = '';
|
||||
if(isset($_GET['organiser'])){
|
||||
if (isset($_GET['organiser'])) {
|
||||
$filterOrganiser = $_GET['organiser'];
|
||||
}
|
||||
|
||||
// filter
|
||||
$events = array_values(array_filter(
|
||||
$events,
|
||||
function($event) use ($filterTitle, $filterOrganiser){
|
||||
return (preg_match('/.*'.$filterTitle.'.*/i', $event->getName()) and preg_match('/.*'.$filterOrganiser.'.*/i', $event->getOrganiser()));
|
||||
}
|
||||
static fn($event) => (preg_match('/.*' . $filterTitle . '.*/i', $event->getName()) && preg_match('/.*' . $filterOrganiser . '.*/i', $event->getOrganiser()))
|
||||
));
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@@ -82,8 +80,8 @@ $events = array_values(array_filter(
|
||||
$counter = 0;
|
||||
$pageLimit = 10;
|
||||
|
||||
for($i = ($pageLimit * ($page - 1)); $i < count($events) ;$i++){
|
||||
if($counter == $pageLimit){
|
||||
for ($i = ($pageLimit * ($page - 1)); $i < count($events); ++$i) {
|
||||
if ($counter == $pageLimit) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -94,35 +92,35 @@ $events = array_values(array_filter(
|
||||
<li>
|
||||
<div class="event admin">
|
||||
<div class="event-info">
|
||||
<h3 class="no-chin"><?= $event->getName() . " (ID: " . $eventID . ")"; ?></h3>
|
||||
<h3 class="no-chin"><?php echo $event->getName() . ' (ID: ' . $eventID . ')'; ?></h3>
|
||||
<p class="subnote">
|
||||
<?= $event->getStart()->format("(Y-m-d H:i:s)") . " - " . $event->getStop()->format("(Y-m-d H:i:s)"); ?>
|
||||
<?php echo $event->getStart()->format('(Y-m-d H:i:s)') . ' - ' . $event->getStop()->format('(Y-m-d H:i:s)'); ?>
|
||||
</p>
|
||||
<?php
|
||||
$Parsedown = new \Parsedown();
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $event->getDescription()));
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="event-actions">
|
||||
<a class="btn" href="edit.php?id=<?= $eventID ?>">Rediger</a><br>
|
||||
<a class="btn" href="delete.php?id=<?= $eventID ?>" onclick="return confirm('Knallsikker? (ID: <?= $eventID ?>)');">Slett</a>
|
||||
<a class="btn" href="edit.php?id=<?php echo $eventID; ?>">Rediger</a><br>
|
||||
<a class="btn" href="delete.php?id=<?php echo $eventID; ?>" onclick="return confirm('Knallsikker? (ID: <?php echo $eventID; ?>)');">Slett</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php
|
||||
$counter++;
|
||||
++$counter;
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
if($page != 1){
|
||||
if ($page != 1) {
|
||||
echo '<a class="btn float-left" href="?page=' . ($page - 1) . '&title=' . urlencode($filterTitle) . '&organiser=' . urlencode($filterOrganiser) . '">Forrige side</a>';
|
||||
}
|
||||
|
||||
if(($counter == $pageLimit) and (($pageLimit * $page) < count($events))){
|
||||
if (($counter == $pageLimit) && (($pageLimit * $page) < count($events))) {
|
||||
echo '<a class="btn float-right" href="?page=' . ($page + 1) . '&title=' . urlencode($filterTitle) . '&organiser=' . urlencode($filterOrganiser) . '">Neste side</a>';
|
||||
}
|
||||
?>
|
||||
@@ -134,9 +132,9 @@ $events = array_values(array_filter(
|
||||
<h2>Filter</h2>
|
||||
<form action="." method="get">
|
||||
<p class="no-chin">Navn</p>
|
||||
<?= '<input type="text" name="title" class="boxinput" value="' . $filterTitle . '">' ?><br>
|
||||
<?php echo '<input type="text" name="title" class="boxinput" value="' . $filterTitle . '">'; ?><br>
|
||||
<p class="no-chin">Organisator</p>
|
||||
<?= '<input type="text" name="organiser" class="boxinput" value="' . $filterOrganiser . '">' ?><br>
|
||||
<?php echo '<input type="text" name="organiser" class="boxinput" value="' . $filterOrganiser . '">'; ?><br>
|
||||
|
||||
<div style="margin-top: 2em;">
|
||||
<input type="submit" class="btn" value="Filtrer"></input>
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
<?php
|
||||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'nb_NO');
|
||||
setlocale(\LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
||||
if(!$userManager->hasGroup($uname, 'aktiviteter')){
|
||||
if (!$userManager->hasGroup($uname, 'aktiviteter')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
if((!isset($_POST['title']))
|
||||
or (!isset($_POST['desc']))
|
||||
or (!isset($_POST['organiser']))
|
||||
or (!isset($_POST['location']))
|
||||
or (!isset($_POST['start_mon']))
|
||||
or (!isset($_POST['start_day']))
|
||||
or (!isset($_POST['start_time']))
|
||||
or (!isset($_POST['lasts_hours']))
|
||||
or (!isset($_POST['lasts_minutes']))) {
|
||||
if ((!isset($_POST['title']))
|
||||
|| (!isset($_POST['desc']))
|
||||
|| (!isset($_POST['organiser']))
|
||||
|| (!isset($_POST['location']))
|
||||
|| (!isset($_POST['start_mon']))
|
||||
|| (!isset($_POST['start_day']))
|
||||
|| (!isset($_POST['start_time']))
|
||||
|| (!isset($_POST['lasts_hours']))
|
||||
|| (!isset($_POST['lasts_minutes']))) {
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = 0;
|
||||
if(isset($_POST['id'])){
|
||||
if (isset($_POST['id'])) {
|
||||
$id = $_POST['id'];
|
||||
}
|
||||
|
||||
$title = $_POST['title'];
|
||||
$desc = $_POST['desc'];
|
||||
//$start = $_POST['start'];
|
||||
//$stop = $_POST['end'];
|
||||
// $start = $_POST['start'];
|
||||
// $stop = $_POST['end'];
|
||||
$organiser = $_POST['organiser'];
|
||||
$location = $_POST['location'];
|
||||
|
||||
@@ -50,12 +50,12 @@ $date_part_lasts_hours = $_POST['lasts_hours'];
|
||||
$date_part_lasts_minutes = $_POST['lasts_minutes'];
|
||||
|
||||
while (strlen($date_part_start_day) < 2) {
|
||||
$date_part_start_day = "0" . $date_part_start_day;
|
||||
$date_part_start_day = '0' . $date_part_start_day;
|
||||
}
|
||||
|
||||
$start = ($date_part_start_mon . "-" . $date_part_start_day . " " . $date_part_start_time);
|
||||
if (sizeof(explode(":", $date_part_start_time))==2) {
|
||||
$start .= ":00";
|
||||
$start = ($date_part_start_mon . '-' . $date_part_start_day . ' ' . $date_part_start_time);
|
||||
if (count(explode(':', $date_part_start_time)) == 2) {
|
||||
$start .= ':00';
|
||||
}
|
||||
|
||||
$start_date = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $start);
|
||||
@@ -65,11 +65,11 @@ $stop = $stop_date->format('Y-m-d H:i:s');
|
||||
|
||||
if ($start_date >= $stop_date) {
|
||||
echo 'Invalid dates. End date must come after the start date!';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$statement;
|
||||
if($id == 0){
|
||||
|
||||
if ($id == 0) {
|
||||
$query = 'INSERT INTO events (name, start, stop, organiser, location, description) VALUES (:title, :start, :stop, :organiser, :loc, :desc)';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
@@ -79,7 +79,7 @@ if($id == 0){
|
||||
$statement->bindParam(':stop', $stop, PDO::PARAM_STR);
|
||||
$statement->bindParam(':organiser', $organiser, PDO::PARAM_STR);
|
||||
$statement->bindParam(':loc', $location, PDO::PARAM_STR);
|
||||
}else{
|
||||
} else {
|
||||
$query = 'UPDATE events SET name=:title, start=:start, stop=:stop, organiser=:organiser, location=:loc, description=:desc WHERE id=:id';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
<?php
|
||||
ini_set('display_errors', '1');
|
||||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'nb_NO');
|
||||
error_reporting(E_ALL);
|
||||
setlocale(\LC_ALL, 'nb_NO');
|
||||
error_reporting(\E_ALL);
|
||||
require __DIR__ . '/../../../inc/navbar.php';
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$attrs = $as->getAttributes();
|
||||
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
||||
if(!$userManager->isAdmin($uname)){
|
||||
if (!$userManager->isAdmin($uname)) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$users = $userManager->getAllUserData();
|
||||
@@ -59,18 +59,18 @@ $users = $userManager->getAllUserData();
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
$users_to_update = array();
|
||||
foreach($users as $i => $data){
|
||||
$users_to_update = [];
|
||||
foreach ($users as $i => $data) {
|
||||
$uname = $data['name'];
|
||||
$groupFlag = $userManager->getUsergroups($uname);
|
||||
|
||||
array_push($users_to_update, $uname);
|
||||
$users_to_update[] = $uname;
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><?= $uname ?></td>
|
||||
<td><?php echo $uname; ?></td>
|
||||
<?php
|
||||
foreach($userManager->usergroups as $name => $group){
|
||||
foreach ($userManager->usergroups as $name => $group) {
|
||||
echo '<td><input type="checkbox" ' . (($groupFlag & $group) ? 'checked' : '') . ' name="' . $uname . '_' . $name . '" class="usergroupcheckbox">' . $name . '</td>';
|
||||
}
|
||||
?>
|
||||
@@ -78,7 +78,7 @@ $users = $userManager->getAllUserData();
|
||||
|
||||
<?php
|
||||
}
|
||||
foreach($users_to_update as $uname) {
|
||||
foreach ($users_to_update as $uname) {
|
||||
echo '<input type="hidden" name="user_to_update" value="' . $uname . '" />';
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ $users = $userManager->getAllUserData();
|
||||
<tr class="newuserrow">
|
||||
<td class="newuserelement"><input type="text" name="newuser" class="newuserinput"></td>
|
||||
<?php
|
||||
foreach($userManager->usergroups as $name => $group){
|
||||
foreach ($userManager->usergroups as $name => $group) {
|
||||
echo '<td><input type="checkbox" name="newuser_' . $name . '" class="usergroupcheckbox">' . $name . '</td>';
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,71 +1,72 @@
|
||||
<?php
|
||||
ini_set('display_errors', '1');
|
||||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'nb_NO');
|
||||
error_reporting(E_ALL);
|
||||
setlocale(\LC_ALL, 'nb_NO');
|
||||
error_reporting(\E_ALL);
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
||||
if(!$userManager->isAdmin($uname)){
|
||||
if (!$userManager->isAdmin($uname)) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$newUser;
|
||||
if(isset($_POST['newuser'])){
|
||||
|
||||
if (isset($_POST['newuser'])) {
|
||||
$newUser = $_POST['newuser'];
|
||||
unset($_POST['newuser']);
|
||||
}
|
||||
|
||||
//$updatingUsers = explode('_', $_POST['users']);
|
||||
$updatingUsers = array();
|
||||
foreach ($_POST as $key => $value) { if ($key === "user_to_update") {
|
||||
array_push($updatingUsers, $value);
|
||||
// $updatingUsers = explode('_', $_POST['users']);
|
||||
$updatingUsers = [];
|
||||
foreach ($_POST as $key => $value) {
|
||||
if ($key === 'user_to_update') {
|
||||
$updatingUsers[] = $value;
|
||||
}
|
||||
}
|
||||
unset($_POST['user_to_update']);
|
||||
|
||||
// 2d array of usernames and their corresponding group flags
|
||||
$userFlags = [];
|
||||
if($newUser){
|
||||
if ($newUser) {
|
||||
$userFlags[$newUser] = 0;
|
||||
}
|
||||
|
||||
foreach($_POST as $namegroup => $info){
|
||||
foreach ($_POST as $namegroup => $info) {
|
||||
$data = explode('_', $namegroup);
|
||||
$group = array_pop($data);
|
||||
$uname = implode("_", $data);
|
||||
if($uname == 'newuser'){
|
||||
if(!$newUser){
|
||||
$uname = implode('_', $data);
|
||||
if ($uname == 'newuser') {
|
||||
if (!$newUser) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$uname = $newUser;
|
||||
}
|
||||
|
||||
if(!isset($userFlags[$uname])){
|
||||
if (!isset($userFlags[$uname])) {
|
||||
$userFlags[$uname] = 0;
|
||||
}
|
||||
|
||||
$userFlags[$uname] = ($userFlags[$uname] | $userManager->usergroups[$group]);
|
||||
}
|
||||
|
||||
foreach($updatingUsers as $uname) {
|
||||
if(!array_key_exists($uname, $userFlags)){
|
||||
foreach ($updatingUsers as $uname) {
|
||||
if (!array_key_exists($uname, $userFlags)) {
|
||||
$userFlags[$uname] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($userFlags as $uname => $flag){
|
||||
foreach ($userFlags as $uname => $flag) {
|
||||
$userManager->setGroups($uname, $flag);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$uname = $attrs['uid'][0];
|
||||
@@ -14,10 +14,10 @@ $isAdmin = $userManager->isAdmin($uname);
|
||||
$projectGroup = $userManager->hasGroup($uname, 'prosjekt');
|
||||
$activityGroup = $userManager->hasGroup($uname, 'aktiviteter');
|
||||
|
||||
if(!($isAdmin | $projectGroup | $activityGroup)){
|
||||
if (!($isAdmin | $projectGroup | $activityGroup)) {
|
||||
header('Content-Type: text/plain', true, 403);
|
||||
echo "Her har du ikke lov't'å'værra!!!\r\n";
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@@ -45,19 +45,19 @@ if(!($isAdmin | $projectGroup | $activityGroup)){
|
||||
<h2>Administrasjon</h2>
|
||||
<ul class="tools">
|
||||
<?php
|
||||
if($isAdmin | $activityGroup){
|
||||
if ($isAdmin | $activityGroup) {
|
||||
echo '<li><a class="btn" href="aktiviteter/?page=1">Aktiviteter/Hendelser</a></li>';
|
||||
}
|
||||
|
||||
if($isAdmin | $projectGroup){
|
||||
if ($isAdmin | $projectGroup) {
|
||||
echo '<li><a class="btn" href="prosjekter/">Prosjekter</a></li>';
|
||||
}
|
||||
|
||||
if($isAdmin) {
|
||||
if ($isAdmin) {
|
||||
echo '<li><a class="btn" href="motd/">Dagens melding</a></li>';
|
||||
}
|
||||
|
||||
if($isAdmin){
|
||||
if ($isAdmin) {
|
||||
echo '<li><a class="btn" href="brukere/">Brukerrettigheter</a></li>';
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
<?php
|
||||
ini_set('display_errors', '1');
|
||||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'no_NO');
|
||||
error_reporting(E_ALL);
|
||||
setlocale(\LC_ALL, 'no_NO');
|
||||
error_reporting(\E_ALL);
|
||||
require __DIR__ . '/../../../inc/navbar.php';
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$attrs = $as->getAttributes();
|
||||
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
||||
if(!$userManager->isAdmin($uname)){
|
||||
if (!$userManager->isAdmin($uname)) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$motdfetcher = new \pvv\side\MOTD($pdo);
|
||||
$motdfetcher = new pvv\side\MOTD($pdo);
|
||||
$motd = $motdfetcher->getMOTD();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@@ -56,15 +56,15 @@ $motd = $motdfetcher->getMOTD();
|
||||
<form action="update.php", method="post">
|
||||
<p class="subtitle no-chin">Tittel</p>
|
||||
<p class="subnote">Ikke nødvendig</p>
|
||||
<input type="text" name="title" value="<?= $motd['title'] ?>" class="boxinput" style="width:66%;"><br>
|
||||
<input type="text" name="title" value="<?php echo $motd['title']; ?>" class="boxinput" style="width:66%;"><br>
|
||||
|
||||
<p class="subtitle no-chin">Innhold (<i>markdown</i>)</p>
|
||||
<textarea name="content" style="width:100%" rows="8" class="boxinput"><?= implode("\n", $motd["content"]) ?></textarea>
|
||||
<textarea name="content" style="width:100%" rows="8" class="boxinput"><?php echo implode("\n", $motd['content']); ?></textarea>
|
||||
|
||||
<div style="margin-top: 2em;">
|
||||
<hr class="ruler">
|
||||
|
||||
<?= '<input type="submit" class="btn" value="Lagre endringer"></a>'; ?>
|
||||
<?php echo '<input type="submit" class="btn" value="Lagre endringer"></a>'; ?>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
<?php
|
||||
ini_set('display_errors', '1');
|
||||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'no_NO');
|
||||
error_reporting(E_ALL);
|
||||
setlocale(\LC_ALL, 'no_NO');
|
||||
error_reporting(\E_ALL);
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
||||
if(!isset($_POST['title']) or !isset($_POST['content'])){
|
||||
if (!isset($_POST['title']) || !isset($_POST['content'])) {
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!$userManager->isAdmin($uname)){
|
||||
if (!$userManager->isAdmin($uname)) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$motdfetcher = new \pvv\side\MOTD($pdo);
|
||||
$motdfetcher = new pvv\side\MOTD($pdo);
|
||||
$motdfetcher->setMOTD($_POST['title'], $_POST['content']);
|
||||
|
||||
header('Location: .');
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
<?php
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
||||
if(!$userManager->hasGroup($uname, 'prosjekt')){
|
||||
if (!$userManager->hasGroup($uname, 'prosjekt')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$projectID = $_GET['id'];
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
<?php
|
||||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'nb_NO');
|
||||
setlocale(\LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../../inc/navbar.php';
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
||||
if(!$userManager->hasGroup($uname, 'prosjekt')){
|
||||
if (!$userManager->hasGroup($uname, 'prosjekt')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$projectManager = new \pvv\side\ProjectManager($pdo);
|
||||
$projectManager = new pvv\side\ProjectManager($pdo);
|
||||
$projects = $projectManager->getAll();
|
||||
|
||||
$new = 0;
|
||||
if(isset($_GET['new'])){
|
||||
if (isset($_GET['new'])) {
|
||||
$new = $_GET['new'];
|
||||
}
|
||||
|
||||
$projectID = 0;
|
||||
if(isset($_GET['id'])){
|
||||
if (isset($_GET['id'])) {
|
||||
$projectID = $_GET['id'];
|
||||
}else if($new == 0){
|
||||
} elseif ($new == 0) {
|
||||
echo "\nID not set";
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$project = new \pvv\side\Project(
|
||||
$project = new pvv\side\Project(
|
||||
0,
|
||||
'Kult Prosjekt',
|
||||
'',
|
||||
@@ -45,7 +45,7 @@ $project = new \pvv\side\Project(
|
||||
'drift@pvv.ntnu.no',
|
||||
0
|
||||
);
|
||||
if($new == 0){
|
||||
if ($new == 0) {
|
||||
$project = $projectManager->getByID($projectID);
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ $owner = [
|
||||
'uname' => '',
|
||||
'mail' => '',
|
||||
];
|
||||
foreach($members as $i => $data){
|
||||
if($data['owner']){
|
||||
foreach ($members as $i => $data) {
|
||||
if ($data['owner']) {
|
||||
$owner = $data;
|
||||
}
|
||||
}
|
||||
@@ -85,34 +85,34 @@ foreach($members as $i => $data){
|
||||
<h2>Prosjektadministrasjon</h2>
|
||||
<hr class="ruler">
|
||||
|
||||
<h2><?= ($new == 1 ? "Nytt prosjekt" : "Rediger prosjekt"); ?></h2>
|
||||
<h2><?php echo $new == 1 ? 'Nytt prosjekt' : 'Rediger prosjekt'; ?></h2>
|
||||
|
||||
<form action="update.php", method="post" class="gridsplit5050">
|
||||
<div class="gridl">
|
||||
<p class="subtitle">Tittel</p>
|
||||
<?= '<input type="text" name="title" value="' . $project->getName() . '" class="boxinput">' ?><br>
|
||||
<?php echo '<input type="text" name="title" value="' . $project->getName() . '" class="boxinput">'; ?><br>
|
||||
|
||||
<p class="subtitle">Beskrivelse (<i>markdown</i>)</p>
|
||||
<textarea name="desc" cols="40" rows="5" class="boxinput"><?= implode("\n", $project->getDescription()); ?></textarea>
|
||||
<textarea name="desc" cols="40" rows="5" class="boxinput"><?php echo implode("\n", $project->getDescription()); ?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="gridr noborder">
|
||||
<p class="subtitle">Prosjektleder (Brukernavn)</p>
|
||||
<?= '<input type="text" name="organiser" value="' . $owner['uname'] . '" class="boxinput">' ?><br>
|
||||
<?php echo '<input type="text" name="organiser" value="' . $owner['uname'] . '" class="boxinput">'; ?><br>
|
||||
|
||||
<p class="subtitle">Prosjektleder (Navn)</p>
|
||||
<?= '<input type="text" name="organisername" value="' . $owner['name'] . '" class="boxinput">' ?>
|
||||
<?php echo '<input type="text" name="organisername" value="' . $owner['name'] . '" class="boxinput">'; ?>
|
||||
|
||||
<p class="subtitle">Prosjektleder E-post</p>
|
||||
<?= '<input type="text" name="organiseremail" value="' . $owner['mail'] . '" class="boxinput">' ?><br>
|
||||
<?php echo '<input type="text" name="organiseremail" value="' . $owner['mail'] . '" class="boxinput">'; ?><br>
|
||||
|
||||
<p class="subtitle">Aktiv</p>
|
||||
<?= '<input type="checkbox" '. ($project->getActive() ? 'checked' : '') . ' name="active"/>' ?>
|
||||
<?php echo '<input type="checkbox" ' . ($project->getActive() ? 'checked' : '') . ' name="active"/>'; ?>
|
||||
</div>
|
||||
|
||||
<?= '<input type="hidden" name="id" value="' . $project->getID() . '" />' ?>
|
||||
<?php echo '<input type="hidden" name="id" value="' . $project->getID() . '" />'; ?>
|
||||
|
||||
<?php if(!$new){ ?>
|
||||
<?php if (!$new) { ?>
|
||||
<div style="grid-column: span 2;">
|
||||
<hr class="ruler">
|
||||
</div>
|
||||
@@ -121,11 +121,11 @@ foreach($members as $i => $data){
|
||||
|
||||
<table class="userlist" style="grid-column: span 2;">
|
||||
<tr><th>Brukernavn</th><th>Navn</th><th>Rolle</th></tr>
|
||||
<?php foreach($members as $i => $data) { ?>
|
||||
<?php foreach ($members as $i => $data) { ?>
|
||||
<tr>
|
||||
<td><?= $data['uname']; ?></td>
|
||||
<td><?= $data['name']; ?></td>
|
||||
<td><?= $data['role']; ?></td>
|
||||
<td><?php echo $data['uname']; ?></td>
|
||||
<td><?php echo $data['name']; ?></td>
|
||||
<td><?php echo $data['role']; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
<?php
|
||||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'nb_NO');
|
||||
setlocale(\LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../../inc/navbar.php';
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
||||
if(!$userManager->hasGroup($uname, 'prosjekt')){
|
||||
if (!$userManager->hasGroup($uname, 'prosjekt')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$projectManager = new \pvv\side\ProjectManager($pdo);
|
||||
$projectManager = new pvv\side\ProjectManager($pdo);
|
||||
$projects = $projectManager->getAll();
|
||||
|
||||
$page = 1;
|
||||
if(isset($_GET['page'])){
|
||||
if (isset($_GET['page'])) {
|
||||
$page = $_GET['page'];
|
||||
}
|
||||
|
||||
$filterTitle = '';
|
||||
if(isset($_POST['title'])){
|
||||
if (isset($_POST['title'])) {
|
||||
$filterTitle = $_POST['title'];
|
||||
}
|
||||
|
||||
@@ -43,9 +43,7 @@ if(isset($_POST['organiser'])){
|
||||
// filter
|
||||
$projects = array_values(array_filter(
|
||||
$projects,
|
||||
function($project) use ($filterTitle){
|
||||
return (preg_match('/.*'.$filterTitle.'.*/i', $project->getName()));
|
||||
}
|
||||
static fn($project) => preg_match('/.*' . $filterTitle . '.*/i', $project->getName())
|
||||
));
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@@ -82,8 +80,8 @@ $projects = array_values(array_filter(
|
||||
$counter = 0;
|
||||
$pageLimit = 4;
|
||||
|
||||
for($i = ($pageLimit * ($page - 1)); $i < count($projects); $i++){
|
||||
if($counter == $pageLimit){
|
||||
for ($i = ($pageLimit * ($page - 1)); $i < count($projects); ++$i) {
|
||||
if ($counter == $pageLimit) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -95,33 +93,33 @@ $projects = array_values(array_filter(
|
||||
<li>
|
||||
<div class="event admin">
|
||||
<div class="event-info">
|
||||
<h3 class="no-chin"><?= $project->getName() . " (ID: " . $projectID . ")"; ?></h3>
|
||||
<p class="subnote"><?= 'Organisert av: ' . $owner['name']; ?></p>
|
||||
<h3 class="no-chin"><?php echo $project->getName() . ' (ID: ' . $projectID . ')'; ?></h3>
|
||||
<p class="subnote"><?php echo 'Organisert av: ' . $owner['name']; ?></p>
|
||||
<?php
|
||||
$Parsedown = new \Parsedown();
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $project->getDescription()));
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="event-actions">
|
||||
<?= '<a href="edit.php?id=' . $projectID . '">🖊</a>'; ?>
|
||||
<?= '<a href="delete.php?id=' . $projectID . '" onclick="return confirm(\'Knallsikker? (ID: ' . $projectID . ')\');">🗑</a>'; ?>
|
||||
<?php echo '<a href="edit.php?id=' . $projectID . '">🖊</a>'; ?>
|
||||
<?php echo '<a href="delete.php?id=' . $projectID . '" onclick="return confirm(\'Knallsikker? (ID: ' . $projectID . ')\');">🗑</a>'; ?>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php
|
||||
$counter++;
|
||||
++$counter;
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
if($page != 1){
|
||||
if ($page != 1) {
|
||||
echo '<a class="btn float-left" href="?page=' . ($page - 1) . '">Forrige side</a>';
|
||||
}
|
||||
|
||||
if(($counter == $pageLimit) and (($pageLimit * $page) < count($projects))){
|
||||
if (($counter == $pageLimit) && (($pageLimit * $page) < count($projects))) {
|
||||
echo '<a class="btn float-right" href="?page=' . ($page + 1) . '">Neste side</a>';
|
||||
}
|
||||
?>
|
||||
@@ -133,9 +131,9 @@ $projects = array_values(array_filter(
|
||||
<h2>Filter</h2>
|
||||
<form action="." method="post">
|
||||
<p class="no-chin">Prosjektnavn</p>
|
||||
<?= '<input type="text" name="title" class="boxinput" value="' . $filterTitle . '">' ?><br>
|
||||
<?php echo '<input type="text" name="title" class="boxinput" value="' . $filterTitle . '">'; ?><br>
|
||||
<p class="no-chin">Leders brukernavn</p>
|
||||
<?= '<input type="text" name="organiser" class="boxinput" value="">' ?><br>
|
||||
<?php echo '<input type="text" name="organiser" class="boxinput" value="">'; ?><br>
|
||||
|
||||
<div style="margin-top: 2em;">
|
||||
<input type="submit" class="btn" value="Filtrer"></input>
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
<?php
|
||||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'nb_NO');
|
||||
setlocale(\LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
||||
if(!$userManager->hasGroup($uname, 'prosjekt')){
|
||||
if (!$userManager->hasGroup($uname, 'prosjekt')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!isset($_POST['title']) or !isset($_POST['desc']) or !isset($_POST['organisername']) or !isset($_POST['organiser'])){
|
||||
if (!isset($_POST['title']) || !isset($_POST['desc']) || !isset($_POST['organisername']) || !isset($_POST['organiser'])) {
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = 0;
|
||||
if(isset($_POST['id'])){
|
||||
if (isset($_POST['id'])) {
|
||||
$id = $_POST['id'];
|
||||
}
|
||||
|
||||
@@ -33,16 +33,16 @@ $desc = $_POST['desc'];
|
||||
$name = $_POST['organisername'];
|
||||
$uname = $_POST['organiser'];
|
||||
$mail = $_POST['organiseremail'];
|
||||
$active = (isset($_POST['active']) ? $_POST['active'] : 0);
|
||||
$active = ($_POST['active'] ?? false);
|
||||
|
||||
$statement;
|
||||
if($id == 0){
|
||||
|
||||
if ($id == 0) {
|
||||
$query = 'INSERT INTO projects (name, description, active) VALUES (:title, :desc, :active)';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':active', $active, PDO::PARAM_INT);
|
||||
$statement->bindParam(':active', $active, PDO::PARAM_BOOL);
|
||||
|
||||
$statement->execute();
|
||||
|
||||
@@ -53,13 +53,13 @@ if($id == 0){
|
||||
$statement->bindParam(':owneremail', $mail, PDO::PARAM_STR);
|
||||
|
||||
$statement->execute();
|
||||
}else{
|
||||
} else {
|
||||
$query = 'UPDATE projects SET name=:title, description=:desc, active=:active WHERE id=:id';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':active', $active, PDO::PARAM_INT);
|
||||
$statement->bindParam(':active', $active, PDO::PARAM_BOOL);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
|
||||
$statement->execute();
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
<?php namespace pvv\side;
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
<?php
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
require_once \dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$year = (isset($_GET['year']))
|
||||
? $_GET['year']
|
||||
: date("Y");
|
||||
: date('Y');
|
||||
$month = (isset($_GET['month']))
|
||||
? $_GET['month']
|
||||
: date("m");
|
||||
: date('m');
|
||||
$day = (isset($_GET['day']))
|
||||
? $_GET['day']
|
||||
: -1;
|
||||
@@ -34,38 +37,43 @@ $day = (isset($_GET['day']))
|
||||
|
||||
<main>
|
||||
<?php
|
||||
use \DateTimeImmutable;
|
||||
$events = ($day==-1)
|
||||
? $agenda->getNextOfEach(new \DateTimeImmutable)
|
||||
use DateTimeImmutable;
|
||||
|
||||
$events = ($day == -1)
|
||||
? $agenda->getNextOfEach(new DateTimeImmutable())
|
||||
: $agenda->getEventsBetween(
|
||||
new DateTimeImmutable("$year-$month-$day 00:00:00"),
|
||||
new DateTimeImmutable("$year-$month-$day 23:59:59"));
|
||||
new DateTimeImmutable("{$year}-{$month}-{$day} 00:00:00"),
|
||||
new DateTimeImmutable("{$year}-{$month}-{$day} 23:59:59")
|
||||
);
|
||||
|
||||
$limit = 0;
|
||||
foreach($events as $event) {
|
||||
foreach ($events as $event) {
|
||||
?>
|
||||
<article>
|
||||
<h2>
|
||||
<?php if (\pvv\side\Agenda::isToday($event->getStart())) { ?><strong><?php } ?>
|
||||
<em><?= $event->getRelativeDate() ?></em>
|
||||
<?php if (\pvv\side\Agenda::isToday($event->getStart())) { ?></strong><?php } ?>
|
||||
<?php if (Agenda::isToday($event->getStart())) { ?><strong><?php } ?>
|
||||
<em><?php echo $event->getRelativeDate(); ?></em>
|
||||
<?php if (Agenda::isToday($event->getStart())) { ?></strong><?php } ?>
|
||||
<?php if ($event->getURL()) { ?>
|
||||
<a href="<?= $event->getURL() ?>"><?= $event->getName() ?></a>
|
||||
<br>
|
||||
<a href="<?php echo $event->getURL(); ?>"><?php echo $event->getName(); ?></a>
|
||||
<?php } else { ?>
|
||||
<?= $event->getName() ?>
|
||||
<?php echo $event->getName(); ?>
|
||||
<?php } ?>
|
||||
<?php if ($event->getImageURL()) { ?>
|
||||
<img src="<?= $event->getImageURL() ?>">
|
||||
<img src="<?php echo $event->getImageURL(); ?>">
|
||||
<?php } ?>
|
||||
</h2>
|
||||
<ul class="subtext">
|
||||
<li>Tid: <strong><?= Agenda::getFormattedDate($event->getStart()) ?></strong></li>
|
||||
<li>Sted: <strong><?= $event->getLocation() ?></strong></li>
|
||||
<li>Arrangør: <strong><?= $event->getOrganiser() ?></strong></li>
|
||||
<li>Tid: <strong><?php echo Agenda::getFormattedDate($event->getStart()); ?></strong></li>
|
||||
<li>Sted: <strong><?php echo $event->getLocation(); ?></strong></li>
|
||||
<li>Arrangør: <strong><?php echo $event->getOrganiser(); ?></strong></li>
|
||||
</ul>
|
||||
|
||||
<?php $description = $event->getDescription(); ?>
|
||||
<?php if ($limit) array_splice($description, $limit); ?>
|
||||
<?php if ($limit) {
|
||||
array_splice($description, $limit);
|
||||
} ?>
|
||||
<?php
|
||||
$Parsedown = new \Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $description));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use \pvv\side\Agenda;
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use pvv\side\Agenda;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
@@ -20,33 +21,33 @@ use \pvv\side\Agenda;
|
||||
<main>
|
||||
|
||||
<?php
|
||||
$activity = new \pvv\side\social\AnimekveldActivity;
|
||||
$nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
|
||||
$activity = new pvv\side\social\AnimekveldActivity();
|
||||
$nextEvent = $activity->getNextEventFrom(new DateTimeImmutable());
|
||||
?>
|
||||
|
||||
<article>
|
||||
<h2><em><?= $nextEvent->getRelativeDate()?></em> Animekveld
|
||||
<h2><em><?php echo $nextEvent->getRelativeDate(); ?></em> Animekveld
|
||||
<?php if ($nextEvent->getImageURL()) { ?>
|
||||
<img src="<?= $nextEvent->getImageURL() ?>">
|
||||
<img src="<?php echo $nextEvent->getImageURL(); ?>">
|
||||
<?php } ?>
|
||||
</h2>
|
||||
<ul class="subtext">
|
||||
<li>Tid:
|
||||
<strong>
|
||||
<?= Agenda::getFormattedDate($nextEvent->getStart());?>
|
||||
<?php echo Agenda::getFormattedDate($nextEvent->getStart()); ?>
|
||||
</strong>
|
||||
<li>Sted:
|
||||
<strong>
|
||||
<?= $nextEvent->getLocation();?>
|
||||
<?php echo $nextEvent->getLocation(); ?>
|
||||
</strong>
|
||||
<li>Arrangør:
|
||||
<strong>
|
||||
<?= $nextEvent->getOrganiser();?>
|
||||
<?php echo $nextEvent->getOrganiser(); ?>
|
||||
</strong>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
$Parsedown = new \Parsedown();
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
|
||||
?>
|
||||
</article>
|
||||
@@ -54,6 +55,6 @@ $nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
|
||||
</main>
|
||||
|
||||
<nav>
|
||||
<?= navbar(1, 'aktiviteter'); ?>
|
||||
<?= loginbar($sp, $pdo); ?>
|
||||
<?php echo navbar(1, 'aktiviteter'); ?>
|
||||
<?php echo loginbar($sp, $pdo); ?>
|
||||
</nav>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use \pvv\side\Agenda;
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use pvv\side\Agenda;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
@@ -20,34 +21,34 @@ use \pvv\side\Agenda;
|
||||
<main>
|
||||
|
||||
<?php
|
||||
$activity = new \pvv\side\social\BrettspillActivity;
|
||||
$nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
|
||||
$activity = new pvv\side\social\BrettspillActivity();
|
||||
$nextEvent = $activity->getNextEventFrom(new DateTimeImmutable());
|
||||
?>
|
||||
|
||||
<article>
|
||||
|
||||
<h2><em><?= $nextEvent->getRelativeDate()?></em> Brettspillkveld
|
||||
<h2><em><?php echo $nextEvent->getRelativeDate(); ?></em> Brettspillkveld
|
||||
<?php if ($nextEvent->getImageURL()) { ?>
|
||||
<img src="<?= $nextEvent->getImageURL() ?>">
|
||||
<img src="<?php echo $nextEvent->getImageURL(); ?>">
|
||||
<?php } ?>
|
||||
</h2>
|
||||
<ul class="subtext">
|
||||
<li>Tid:
|
||||
<strong>
|
||||
<?= Agenda::getFormattedDate($nextEvent->getStart());?>
|
||||
<?php echo Agenda::getFormattedDate($nextEvent->getStart()); ?>
|
||||
</strong>
|
||||
<li>Sted:
|
||||
<strong>
|
||||
<?= $nextEvent->getLocation();?>
|
||||
<?php echo $nextEvent->getLocation(); ?>
|
||||
</strong>
|
||||
<li>Arrangør:
|
||||
<strong>
|
||||
<?= $nextEvent->getOrganiser();?>
|
||||
<?php echo $nextEvent->getOrganiser(); ?>
|
||||
</strong>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
$Parsedown = new \Parsedown();
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
|
||||
?>
|
||||
</article>
|
||||
@@ -55,6 +56,6 @@ $nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
|
||||
</main>
|
||||
|
||||
<nav>
|
||||
<?= navbar(1, 'aktiviteter'); ?>
|
||||
<?= loginbar($sp, $pdo); ?>
|
||||
<?php echo navbar(1, 'aktiviteter'); ?>
|
||||
<?php echo loginbar($sp, $pdo); ?>
|
||||
</nav>
|
||||
|
||||
1
www/css/afterlogic.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17.01 14.258" enable-background="new 0 0 17.01 14.258"><style type="text/css">.st0{fill:#004166;}</style><path class="st0" d="M14.009 8.551l.01-.019.005-.023.003-.014-.001-.006-.004-.022-.007-.021-.002-.006-4.629-8.382-.006-.006-.009-.013-.01-.01-.012-.009-.006-.005-.006-.002-.013-.005-.015-.004-.016-.002-.006-.002h-1.642l-.015.003-.021.004-.02.01-.017.012-.015.017-.009.011-4.233 7.425-.002.006-.007.021-.005.022-.001.006v2.86l.003.014.005.023.009.019.012.018.017.015.011.009.008.003.009.004.039.008h1.421l.038-.008.009-.004.031-.021.001-.001.019-.025 1.017-1.844h5.067l1.007 1.844.019.025.002.001.03.02.009.004.038.008h1.125l.04-.008.011-.005.023-.015.01-.009.015-.023.006-.011.002-.004.649-1.869.009-.014zm-.843 1.734h-.859l.582-1.678h.859l-.582 1.678zm-1.996-1.855l-.015-.018-.017-.012-.019-.01-.023-.005-.014-.003h-5.2l-.015.003-.023.005-.019.01-.018.012-.015.018-.01.011-1.017 1.844h-1.161l5.679-9.944 4.44 8.041h-.846l-3.426-6.236-.006-.007-.014-.017-.018-.015-.006-.006-.012-.003-.022-.007-.021-.002-.021.002-.021.007-.012.003-.007.006-.017.014-.014.018-.006.006-2.776 5.035-.002.005-.006.021-.005.023-.001.005.003.014.005.024.009.018.012.018.017.015.012.01.007.003.008.003.039.007h3.788l.039-.008.009-.004.007-.003.011-.009.018-.015.012-.017.01-.019.005-.023.003-.015-.001-.006-.004-.022-.007-.022-.002-.005-1.842-3.315-.037-.038.768-1.392 3.335 6.073-.572 1.649-.936-1.714-.01-.011zm-7.647-.863l4.186-7.342h1.383l-5.569 9.75v-2.408zm3.619-1.127h2.653l.378.682h-3.407l.376-.682zm.124-.225l1.198-2.173 1.206 2.173h-2.404zM1.197 14.258l-.13-.325h-.729l-.13.325h-.208l.588-1.464h.226l.591 1.464h-.208zm-.494-1.276l-.312.788h.621l-.309-.788zM2.123 14.258v-1.464h.959v.162h-.776v.472h.762v.162h-.762v.667h-.183zM4.22 14.258v-1.302h-.463v-.162h1.111v.162h-.465v1.302h-.183zM5.637 14.258v-1.464h.959v.162h-.777v.472h.762v.162h-.762v.505h.777v.162h-.959zM8.261 14.258l-.373-.582h-.292v.582h-.183v-1.464h.588c.268 0 .459.171.459.441 0 .263-.18.408-.38.426l.395.597h-.214zm.011-1.023c0-.165-.119-.279-.292-.279h-.384v.56h.384c.173 0 .292-.117.292-.281zM9.275 14.258v-1.464h.182v1.302h.681v.162h-.863zM10.613 13.527c0-.433.292-.757.727-.757.432 0 .727.325.727.757 0 .433-.294.758-.727.758-.435-.001-.727-.326-.727-.758zm1.264 0c0-.342-.211-.595-.538-.595-.329 0-.538.252-.538.595 0 .34.209.595.538.595.328 0 .538-.255.538-.595zM12.644 13.527c0-.454.336-.757.753-.757.259 0 .439.114.569.275l-.145.09c-.092-.119-.248-.202-.424-.202-.321 0-.564.246-.564.595 0 .347.244.597.564.597.176 0 .321-.086.393-.158v-.299h-.503v-.162h.685v.529c-.136.151-.336.252-.575.252-.417-.001-.753-.306-.753-.76zM14.84 14.258v-1.464h.182v1.464h-.182zM15.699 13.527c0-.45.332-.757.753-.757.259 0 .439.125.555.29l-.154.086c-.083-.123-.235-.213-.402-.213-.321 0-.564.246-.564.595 0 .347.244.595.564.595.167 0 .318-.088.402-.213l.156.086c-.123.167-.299.29-.558.29-.421-.002-.752-.309-.752-.759z"/></svg>
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
@@ -11,7 +11,6 @@ h2 em {
|
||||
font-size: .5em;
|
||||
line-height: 2em;
|
||||
float: left;
|
||||
margin-right: 1em;
|
||||
border: .1em solid gray;
|
||||
padding: 0 1em;
|
||||
border-radius: .25em;
|
||||
@@ -107,7 +106,6 @@ p + .subtext {
|
||||
}
|
||||
@media screen and (max-width: 50rem) {
|
||||
h2 {
|
||||
text-align: center;
|
||||
position: relative;
|
||||
border-bottom-left-radius: 0.3em;
|
||||
border-bottom-right-radius: 0.3em;
|
||||
@@ -133,4 +131,8 @@ p + .subtext {
|
||||
article >.subtext {
|
||||
margin-top: -1em !important;
|
||||
}
|
||||
|
||||
.subtext li {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
73
www/css/mail.css
Normal file
@@ -0,0 +1,73 @@
|
||||
ul#webmail {
|
||||
margin-top: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
table-layout: fixed;
|
||||
display: table;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
}
|
||||
ul#webmail li {
|
||||
display: table-cell;
|
||||
text-align: center;
|
||||
}
|
||||
ul#webmail li .mailname {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
@media all and (min-width: 980px) {
|
||||
ul#webmail {
|
||||
max-width: 1280px;
|
||||
}
|
||||
ul#webmail li {
|
||||
display: table-cell;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
@media all and (max-width: 980px) {
|
||||
ul#webmail {
|
||||
max-width: 650px;
|
||||
}
|
||||
ul#webmail li {
|
||||
display: table-row;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
ul#webmail li div {
|
||||
position: relative;
|
||||
background: white;
|
||||
margin: 1em 1em;
|
||||
box-shadow: rgba(0,0,0,.3) 0 .1em .17em;
|
||||
border-radius: .5rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
ul#webmail li:hover div {
|
||||
box-shadow: rgba(0,0,0,.5) 0 .15em .2em;
|
||||
}
|
||||
ul#webmail li div a {
|
||||
padding-top: 10em;
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
ul#webmail li#afterlogic div {
|
||||
background: white url('afterlogic.png') no-repeat;
|
||||
background: white url('afterlogic.svg') no-repeat;
|
||||
background-size: auto 8em;
|
||||
background-position: 50% 60%;
|
||||
}
|
||||
ul#webmail li#squirrelmail div {
|
||||
background: white url('squirrelmail.png') no-repeat;
|
||||
background-size: auto 10em;
|
||||
background-position: 50% 0;
|
||||
}
|
||||
ul#webmail li#roundcube div {
|
||||
background: white url('roundcube.png') no-repeat;
|
||||
background-size: auto 10em;
|
||||
background-position: 50% 0;
|
||||
}
|
||||
ul#webmail li#rainloop div {
|
||||
background: white url('rainloop.png') no-repeat;
|
||||
background-size: auto 10em;
|
||||
background-position: 50% 0;
|
||||
}
|
||||
BIN
www/css/rainloop.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
@@ -24,6 +24,7 @@ main {
|
||||
}
|
||||
|
||||
.categoryLabel {
|
||||
padding-top: 5px;
|
||||
background-color: #002244;
|
||||
color: white;
|
||||
|
||||
@@ -45,6 +46,7 @@ main {
|
||||
|
||||
.serviceContent {
|
||||
flex-grow: 1;
|
||||
margin-right: 4%;
|
||||
}
|
||||
|
||||
.serviceTitle {
|
||||
@@ -91,3 +93,27 @@ main {
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.categoryContainer {
|
||||
border-radius: unset;
|
||||
border: unset;
|
||||
box-shadow: unset;
|
||||
margin-bottom: unset;
|
||||
}
|
||||
.serviceWrapper {
|
||||
width: 100%;
|
||||
}
|
||||
.serviceImage {
|
||||
width: 25%;
|
||||
height: auto;
|
||||
}
|
||||
.serviceContent {
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 360px) {
|
||||
.serviceContent {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
BIN
www/css/squirrelmail.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
@@ -67,7 +67,6 @@ nav {
|
||||
height: 3em;
|
||||
display: table;
|
||||
white-space: nowrap;
|
||||
border: #024 0.1em solid;
|
||||
}
|
||||
nav #menu, nav #login {
|
||||
display: table-cell;
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
ul#webmail {
|
||||
margin-top: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
table-layout: fixed;
|
||||
display: table;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
}
|
||||
ul#webmail li {
|
||||
display: table-cell;
|
||||
text-align: center;
|
||||
}
|
||||
ul#webmail li .mailname {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
@media all and (min-width: 980px) {
|
||||
ul#webmail {
|
||||
max-width: 1280px;
|
||||
}
|
||||
ul#webmail li {
|
||||
display: table-cell;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
@media all and (max-width: 980px) {
|
||||
ul#webmail {
|
||||
max-width: 650px;
|
||||
}
|
||||
ul#webmail li {
|
||||
display: table-row;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
ul#webmail li div {
|
||||
position: relative;
|
||||
background: white;
|
||||
margin: 1em 1em;
|
||||
box-shadow: rgba(0,0,0,.3) 0 .1em .17em;
|
||||
border-radius: .5rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
ul#webmail li:hover div {
|
||||
box-shadow: rgba(0,0,0,.5) 0 .15em .2em;
|
||||
}
|
||||
ul#webmail li div a {
|
||||
padding-top: 10em;
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
ul#webmail li#roundcube div {
|
||||
background: white url('/webmail/roundcube.png') no-repeat;
|
||||
background-size: auto 10em;
|
||||
background-position: 50% 0;
|
||||
}
|
||||
ul#webmail li#snappymail div {
|
||||
background: white url('/webmail/snappymail.png') no-repeat;
|
||||
background-size: auto 10em;
|
||||
background-position: 50% 0;
|
||||
}
|
||||
|
||||
div#lokalmail {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
@@ -1,65 +1,67 @@
|
||||
<?php
|
||||
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$door = new \pvv\side\Door($pdo);
|
||||
$door = new pvv\side\Door($pdo);
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (isset($_SERVER["HTTP_AUTHORIZATION"])) {
|
||||
list($type, $data) = explode(" ", $_SERVER["HTTP_AUTHORIZATION"], 2);
|
||||
if (strcasecmp($type, "Bearer") == 0) {
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
|
||||
[$type, $data] = explode(' ', $_SERVER['HTTP_AUTHORIZATION'], 2);
|
||||
if (strcasecmp($type, 'Bearer') == 0) {
|
||||
if (hash_equals($data, $DOOR_SECRET)) {
|
||||
handleSetState();
|
||||
} else {
|
||||
echo '{"status": "error", "message": "Invalid authentication key"}';
|
||||
die();
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo '{"status": "error", "message": "Invalid authentication method"}';
|
||||
die();
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo '{"status": "error", "message": "Missing authentication"}';
|
||||
die();
|
||||
exit;
|
||||
}
|
||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
|
||||
if (isset($_GET["period"])) {
|
||||
$period = (string)htmlspecialchars($_GET["period"]);
|
||||
if (isset($_GET['period'])) {
|
||||
$period = (string) htmlspecialchars($_GET['period']);
|
||||
|
||||
if ($period == "day") {
|
||||
$startTime = time() - (60*60*24);
|
||||
} else if ($period == "week") {
|
||||
$startTime = time() - (60*60*24*7);
|
||||
if ($period == 'day') {
|
||||
$startTime = time() - (60 * 60 * 24);
|
||||
} elseif ($period == 'week') {
|
||||
$startTime = time() - (60 * 60 * 24 * 7);
|
||||
} else {
|
||||
echo '{"status": "error", "message": "Invalid period"}';
|
||||
die();
|
||||
exit;
|
||||
}
|
||||
|
||||
$lines = $door->getEntriesAfter($startTime);
|
||||
if (isset($_GET["edgeonly"]) && (bool)htmlspecialchars($_GET["edgeonly"])) {
|
||||
//Ignore repeats
|
||||
if (isset($_GET['edgeonly']) && (bool) htmlspecialchars($_GET['edgeonly'])) {
|
||||
// Ignore repeats
|
||||
$lines = getChanges($lines);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'status' => "OK",
|
||||
'entries' => $lines
|
||||
'status' => 'OK',
|
||||
'entries' => $lines,
|
||||
]);
|
||||
} else {
|
||||
//Only last entry
|
||||
$line = (object)$door->getCurrent();
|
||||
// Only last entry
|
||||
$line = (object) $door->getCurrent();
|
||||
echo json_encode([
|
||||
'status' => "OK",
|
||||
'status' => 'OK',
|
||||
'time' => $line->time,
|
||||
'open' => $line->open
|
||||
'open' => $line->open,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function handleSetState() {
|
||||
function handleSetState(): void {
|
||||
global $door;
|
||||
|
||||
$jsonobj = file_get_contents('php://input');
|
||||
@@ -67,14 +69,14 @@ function handleSetState() {
|
||||
|
||||
if ((!isset($event->time)) || (!is_numeric($event->time))) {
|
||||
echo '{"status": "error", "message": "Invalid timestamp"}';
|
||||
die();
|
||||
exit;
|
||||
}
|
||||
if ((!isset($event->isDoorOpen)) || (!is_bool($event->isDoorOpen))) {
|
||||
echo '{"status": "error", "message": "Invalid door state"}';
|
||||
die();
|
||||
exit;
|
||||
}
|
||||
|
||||
$door->createEvent((int)($event->time), $event->isDoorOpen ? 1 : 0);
|
||||
$door->createEvent((int) $event->time, $event->isDoorOpen ? 1 : 0);
|
||||
echo '{"status": "OK"}';
|
||||
}
|
||||
|
||||
@@ -82,10 +84,10 @@ function getChanges($items) {
|
||||
$prevState = 2;
|
||||
$res = [];
|
||||
|
||||
foreach($items as $item) {
|
||||
if ($item["open"] !== $prevState) {
|
||||
array_push($res, $item);
|
||||
$prevState = $item["open"];
|
||||
foreach ($items as $item) {
|
||||
if ($item['open'] !== $prevState) {
|
||||
$res[] = $item;
|
||||
$prevState = $item['open'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use \pvv\side\Agenda;
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use pvv\side\Agenda;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
@@ -20,33 +21,33 @@ use \pvv\side\Agenda;
|
||||
<main>
|
||||
|
||||
<?php
|
||||
$activity = new \pvv\side\social\DriftkveldActivity;
|
||||
$nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
|
||||
$activity = new pvv\side\social\DriftkveldActivity();
|
||||
$nextEvent = $activity->getNextEventFrom(new DateTimeImmutable());
|
||||
?>
|
||||
|
||||
<article>
|
||||
<h2><em><?= $nextEvent->getRelativeDate()?></em> Driftkveld
|
||||
<h2><em><?php echo $nextEvent->getRelativeDate(); ?></em> Driftkveld
|
||||
<?php if ($nextEvent->getImageURL()) { ?>
|
||||
<img src="<?= $nextEvent->getImageURL() ?>">
|
||||
<img src="<?php echo $nextEvent->getImageURL(); ?>">
|
||||
<?php } ?>
|
||||
</h2>
|
||||
<ul class="subtext">
|
||||
<li>Tid:
|
||||
<strong>
|
||||
<?= Agenda::getFormattedDate($nextEvent->getStart());?>
|
||||
<?php echo Agenda::getFormattedDate($nextEvent->getStart()); ?>
|
||||
</strong>
|
||||
<li>Sted:
|
||||
<strong>
|
||||
<?= $nextEvent->getLocation();?>
|
||||
<?php echo $nextEvent->getLocation(); ?>
|
||||
</strong>
|
||||
<li>Arrangør:
|
||||
<strong>
|
||||
<?= $nextEvent->getOrganiser();?>
|
||||
<?php echo $nextEvent->getOrganiser(); ?>
|
||||
</strong>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
$Parsedown = new \Parsedown();
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
|
||||
?>
|
||||
</article>
|
||||
@@ -54,6 +55,6 @@ $nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
|
||||
</main>
|
||||
|
||||
<nav>
|
||||
<?= navbar(1, 'aktiviteter'); ?>
|
||||
<?= loginbar($sp, $pdo); ?>
|
||||
<?php echo navbar(1, 'aktiviteter'); ?>
|
||||
<?php echo loginbar($sp, $pdo); ?>
|
||||
</nav>
|
||||
|
||||
@@ -1,53 +1,54 @@
|
||||
<?php
|
||||
error_reporting(0);
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$loginname = $attrs['uid'][0];
|
||||
|
||||
if(!$loginname) {
|
||||
if (!$loginname) {
|
||||
header('Content-Type: text/plain', true, 403);
|
||||
echo "Du må være logget inn for å se bildegalleriet.\r\n";
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
# Sourced from config.php through include.php
|
||||
// Sourced from config.php through include.php
|
||||
$galleryDir = $GALLERY_DIR;
|
||||
$serverPath = $GALLERY_SERVER_PATH;
|
||||
|
||||
$allowedExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg', 'webp'];
|
||||
$unamefile = $galleryDir . "/usernames.txt";
|
||||
$unamefile = $galleryDir . '/usernames.txt';
|
||||
|
||||
$unamepairs = file($unamefile);
|
||||
|
||||
function getDirContents($dir, &$results = array()) {
|
||||
function getDirContents($dir, &$results = []) {
|
||||
$files = scandir($dir);
|
||||
foreach ($files as $key => $value) {
|
||||
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
|
||||
$path = realpath($dir . \DIRECTORY_SEPARATOR . $value);
|
||||
if (!is_dir($path)) {
|
||||
//Remove the full path on disk, keep username and relative path to image.
|
||||
$pos = strpos($path, $GLOBALS["galleryDir"]);
|
||||
// Remove the full path on disk, keep username and relative path to image.
|
||||
$pos = strpos($path, $GLOBALS['galleryDir']);
|
||||
if ($pos !== false) {
|
||||
$cleanPath = substr_replace($path, "", $pos, strlen($GLOBALS["galleryDir"]));
|
||||
$cleanPath = substr_replace($path, '', $pos, strlen($GLOBALS['galleryDir']));
|
||||
}
|
||||
|
||||
//Check if the file is an image
|
||||
$ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||
if (in_array($ext, $GLOBALS["allowedExtensions"])) {
|
||||
// Check if the file is an image
|
||||
$ext = strtolower(pathinfo($path, \PATHINFO_EXTENSION));
|
||||
if (in_array($ext, $GLOBALS['allowedExtensions'], true)) {
|
||||
$results[] = $cleanPath;
|
||||
}
|
||||
} else if ($value != "." && $value != ".." && $value != ".thumbnails") {
|
||||
//recursively scan directories
|
||||
} elseif ($value != '.' && $value != '..' && $value != '.thumbnails') {
|
||||
// recursively scan directories
|
||||
getDirContents($path, $results);
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
$images = getDirContents($galleryDir);
|
||||
@@ -61,7 +62,7 @@ function cmpModifyTime($a, $b) {
|
||||
return ($mtime_a > $mtime_b) ? -1 : 1;
|
||||
}
|
||||
|
||||
usort($images, "cmpModifyTime");
|
||||
usort($images, 'cmpModifyTime');
|
||||
|
||||
$imageTemplate = '
|
||||
<div class="card">
|
||||
@@ -77,7 +78,7 @@ $imageTemplate = '
|
||||
<p class="card-footer-item">%time</p>
|
||||
</div>
|
||||
</div>
|
||||
'
|
||||
';
|
||||
|
||||
|
||||
?>
|
||||
@@ -101,12 +102,12 @@ $imageTemplate = '
|
||||
<main class="gallery-container">
|
||||
<?php
|
||||
foreach ($images as $key => $value) {
|
||||
$modTime = date("d.m.Y H:i", filemtime($galleryDir . $value));
|
||||
$imguser = explode("/", $value)[1];
|
||||
$displaypath = implode("/", array_slice(explode("/", $value), 2));
|
||||
$realname = "Ukjent";
|
||||
$modTime = date('d.m.Y H:i', filemtime($galleryDir . $value));
|
||||
$imguser = explode('/', $value)[1];
|
||||
$displaypath = implode('/', array_slice(explode('/', $value), 2));
|
||||
$realname = 'Ukjent';
|
||||
foreach ($unamepairs as $unamepair) {
|
||||
$unamepair = explode(":", $unamepair);
|
||||
$unamepair = explode(':', $unamepair);
|
||||
if ($unamepair[0] == $imguser) {
|
||||
$realname = $unamepair[1];
|
||||
break;
|
||||
@@ -114,12 +115,12 @@ $imageTemplate = '
|
||||
}
|
||||
|
||||
$vars = [
|
||||
"%user" => htmlspecialchars($imguser),
|
||||
"%time" => $modTime,
|
||||
"%name" => htmlspecialchars($displaypath),
|
||||
"%path" => $serverPath . $value,
|
||||
"%thumbnail" => $serverPath . "/.thumbnails" . $value . ".png",
|
||||
"%realname" => htmlspecialchars($realname)
|
||||
'%user' => htmlspecialchars($imguser),
|
||||
'%time' => $modTime,
|
||||
'%name' => htmlspecialchars($displaypath),
|
||||
'%path' => $serverPath . $value,
|
||||
'%thumbnail' => $serverPath . '/.thumbnails' . $value . '.png',
|
||||
'%realname' => htmlspecialchars($realname),
|
||||
];
|
||||
echo strtr($imageTemplate, $vars);
|
||||
}
|
||||
|
||||
@@ -1,34 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require __DIR__ . '/../../config.php';
|
||||
|
||||
$searchDir = $SLIDESHOW_DIR;
|
||||
$serverPath = $SLIDESHOW_SERVER_PATH;
|
||||
|
||||
$splashImg = "/PNG/PVV-logo-big-bluebg.png";
|
||||
$splashImg = '/PNG/PVV-logo-big-bluebg.png';
|
||||
|
||||
// Note: This does not support nested directories
|
||||
$filenames = sCaNdIr($searchDir);
|
||||
$filenames = scandir($searchDir);
|
||||
|
||||
//Remove the expected non-images
|
||||
foreach($filenames as $k => $value) {
|
||||
if(in_array($value, [".", ".."])) {
|
||||
// Remove the expected non-images
|
||||
foreach ($filenames as $k => $value) {
|
||||
if (in_array($value, ['.', '..'], true)) {
|
||||
unset($filenames[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
function getFullPath($fname) { return ($GLOBALS["serverPath"] . "/" . $fname ); }
|
||||
function getFullPath($fname) {
|
||||
return $GLOBALS['serverPath'] . '/' . $fname;
|
||||
}
|
||||
|
||||
// Sort filenames alphabetically and prepend the path prefix to each item.
|
||||
asort($filenames);
|
||||
$slideshowimagefilenames = aRrAy_MaP("getFullPath", $filenames);
|
||||
$slideshowimagefilenames = aRrAy_MaP('getFullPath', $filenames);
|
||||
|
||||
// Prepend the cover photo
|
||||
ArRaY_uNsHiFt($slideshowimagefilenames, $splashImg);
|
||||
|
||||
eChO('<img class="slideshowimg slideshowactive" id="slideshowImage1" src="' . $slideshowimagefilenames[0] . '">');
|
||||
ecHo('<img class="slideshowimg" id="slideshowImage2" src="' . $slideshowimagefilenames[1] . '">');
|
||||
eChO '<img class="slideshowimg slideshowactive" id="slideshowImage1" src="' . $slideshowimagefilenames[0] . '">';
|
||||
ecHo '<img class="slideshowimg" id="slideshowImage2" src="' . $slideshowimagefilenames[1] . '">';
|
||||
// Store list of file names in a globel JS variable
|
||||
EchO("<script> const slideshowFnames =" . jSoN_eNcOdE($slideshowimagefilenames) . "; </script>");
|
||||
|
||||
?>
|
||||
EchO '<script> const slideshowFnames =' . jSoN_eNcOdE($slideshowimagefilenames) . '; </script>';
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php namespace pvv\side;
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
<?php
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
require_once \dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$translation = ['I dag', 'I morgen', 'Denne uka', 'Neste uke', 'Denne måneden', 'Neste måned'];
|
||||
?>
|
||||
@@ -18,8 +21,8 @@ $translation = ['I dag', 'I morgen', 'Denne uka', 'Neste uke', 'Denne måneden',
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<?= navbar(1, 'hendelser'); ?>
|
||||
<?= loginbar($sp, $pdo); ?>
|
||||
<?php echo navbar(1, 'hendelser'); ?>
|
||||
<?php echo loginbar($sp, $pdo); ?>
|
||||
</nav>
|
||||
<main>
|
||||
<h1 style="pointer-events:none; text-align: left;">Hendelser</h1>
|
||||
@@ -27,23 +30,25 @@ $translation = ['I dag', 'I morgen', 'Denne uka', 'Neste uke', 'Denne måneden',
|
||||
<a style="padding-left: 2em; padding-right: 2em;" class="btn" style="" href="../kalender/">Kalender</a>
|
||||
</center>
|
||||
<?php
|
||||
$description_paragraphs = 2; //description length
|
||||
foreach($agenda->getNextDays() as $period => $events) {
|
||||
$description_paragraphs = 2; // description length
|
||||
foreach ($agenda->getNextDays() as $period => $events) {
|
||||
if ($events) { ?>
|
||||
<h2 style="text-align: left;"><?= $translation[$period] ?></h2>
|
||||
<h2 style="text-align: left;"><?php echo $translation[$period]; ?></h2>
|
||||
<ul class="events">
|
||||
<?php foreach($events as $event) {?>
|
||||
<li style="border-color: <?= $event->getColor() ?>">
|
||||
<?php foreach ($events as $event) {?>
|
||||
<li style="border-color: <?php echo $event->getColor(); ?>">
|
||||
<h4><strong>
|
||||
<?php if ($event->getURL()) { ?>
|
||||
<a href="<?= $event->getURL() ?>"><?= $event->getName() ?></a>
|
||||
<a href="<?php echo $event->getURL(); ?>"><?php echo $event->getName(); ?></a>
|
||||
<?php } else { ?>
|
||||
<?= $event->getName() ?>
|
||||
<?php echo $event->getName(); ?>
|
||||
<?php } ?>
|
||||
</strong></h4>
|
||||
|
||||
<?php $description = $event->getDescription(); ?>
|
||||
<?php if ($description_paragraphs) array_splice($description, $description_paragraphs); ?>
|
||||
<?php if ($description_paragraphs) {
|
||||
array_splice($description, $description_paragraphs);
|
||||
} ?>
|
||||
|
||||
<?php
|
||||
$Parsedown = new \Parsedown();
|
||||
@@ -51,9 +56,9 @@ $translation = ['I dag', 'I morgen', 'Denne uka', 'Neste uke', 'Denne måneden',
|
||||
?>
|
||||
|
||||
<ul class="subtext">
|
||||
<li>Tid: <strong><?= Agenda::getFormattedDate($event->getStart()) ?></strong></li>
|
||||
<li>Sted: <strong><?= $event->getLocation() ?></strong></li>
|
||||
<li>Arrangør: <strong><?= $event->getOrganiser() ?></strong></li>
|
||||
<li>Tid: <strong><?php echo Agenda::getFormattedDate($event->getStart()); ?></strong></li>
|
||||
<li>Sted: <strong><?php echo $event->getLocation(); ?></strong></li>
|
||||
<li>Arrangør: <strong><?php echo $event->getOrganiser(); ?></strong></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
@@ -61,9 +66,5 @@ $translation = ['I dag', 'I morgen', 'Denne uka', 'Neste uke', 'Denne måneden',
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<div style="text-align: center; margin-bottom: 2em;">
|
||||
<a style="padding-left: 2em; padding-right: 2em;" class="btn" style="" href="../kalender/">Kalender</a>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
</body>
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
<?php
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use \pvv\side\Agenda;
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use pvv\side\Agenda;
|
||||
|
||||
$eventID = 0;
|
||||
if(isset($_GET['id'])){
|
||||
if (isset($_GET['id'])) {
|
||||
$eventID = $_GET['id'];
|
||||
}else{
|
||||
} else {
|
||||
echo 'No event ID provided';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
|
||||
$dbActivity = new \pvv\side\DBActivity($pdo);
|
||||
$dbActivity = new pvv\side\DBActivity($pdo);
|
||||
$event = $dbActivity->getEventByID($eventID);
|
||||
if(!$event){
|
||||
if (!$event) {
|
||||
echo 'Failed to retrieve event info';
|
||||
exit();
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@@ -34,21 +34,21 @@ if(!$event){
|
||||
<main>
|
||||
<article>
|
||||
<h2>
|
||||
<?php if (\pvv\side\Agenda::isToday($event->getStart())) { ?><strong><?php } ?>
|
||||
<em><?= $event->getRelativeDate() ?></em>
|
||||
<?php if (\pvv\side\Agenda::isToday($event->getStart())) { ?></strong><?php } ?>
|
||||
|
||||
<?= $event->getName() ?>
|
||||
<?php if (Agenda::isToday($event->getStart())) { ?><strong><?php } ?>
|
||||
<em><?php echo $event->getRelativeDate(); ?></em>
|
||||
<?php if (Agenda::isToday($event->getStart())) { ?></strong><?php } ?>
|
||||
<br>
|
||||
<?php echo $event->getName(); ?>
|
||||
</h2>
|
||||
<ul class="subtext">
|
||||
<li>Tid: <strong><?= Agenda::getFormattedDate($event->getStart()) ?></strong></li>
|
||||
<li>Sted: <strong><?= $event->getLocation() ?></strong></li>
|
||||
<li>Arrangør: <strong><?= $event->getOrganiser() ?></strong></li>
|
||||
<li>Tid: <strong><?php echo Agenda::getFormattedDate($event->getStart()); ?></strong></li>
|
||||
<li>Sted: <strong><?php echo $event->getLocation(); ?></strong></li>
|
||||
<li>Arrangør: <strong><?php echo $event->getOrganiser(); ?></strong></li>
|
||||
</ul>
|
||||
|
||||
<?php $description = $event->getDescription(); ?>
|
||||
<?php
|
||||
$Parsedown = new \Parsedown();
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $description));
|
||||
?>
|
||||
</article>
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
require_once dirname(__DIR__) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$translation = ['I dag', 'I morgen', 'Denne uka', 'Neste uke', 'Denne måneden', 'Neste måned'];
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$motdfetcher = new \pvv\side\MOTD($pdo);
|
||||
$motdfetcher = new pvv\side\MOTD($pdo);
|
||||
$motd = $motdfetcher->getMOTD();
|
||||
|
||||
$door = new \pvv\side\Door($pdo);
|
||||
$doorEntry = (object)($door->getCurrent());
|
||||
if ($doorEntry->time < (time() - 60*30)) {
|
||||
$doorStateText = "Ingen data fra dørsensor";
|
||||
$door = new pvv\side\Door($pdo);
|
||||
$doorEntry = (object) $door->getCurrent();
|
||||
if ($doorEntry->time < (time() - 60 * 30)) {
|
||||
$doorStateText = 'Ingen data fra dørsensor';
|
||||
} else {
|
||||
if ($doorEntry->open) { $doorStateText = "Døren er <b>åpen</b>";
|
||||
} else { $doorStateText = "Døren er <b>ikke åpen</b>"; }
|
||||
if ($doorEntry->open) {
|
||||
$doorStateText = 'Døren er <b>åpen</b>';
|
||||
} else {
|
||||
$doorStateText = 'Døren er <b>ikke åpen</b>';
|
||||
}
|
||||
}
|
||||
$doorTime = date("H:i", $doorEntry->time);
|
||||
$doorTime = date('H:i', $doorEntry->time);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
@@ -41,7 +44,7 @@ $doorTime = date("H:i", $doorEntry->time);
|
||||
|
||||
<header class="landing">
|
||||
<div id="imageSlideshow">
|
||||
<?php include("galleri/slideshow.php"); ?>
|
||||
<?php include 'galleri/slideshow.php'; ?>
|
||||
<script src="js/slideshow.js"></script>
|
||||
</div>
|
||||
<div class="info">
|
||||
@@ -52,9 +55,9 @@ $doorTime = date("H:i", $doorEntry->time);
|
||||
<a class="btn" href="om/"><li>Om PVV</li></a>
|
||||
<a class="btn focus" href="paamelding/"><li>Bli medlem!</li></a>
|
||||
<a class="btn" href="https://use.mazemap.com/#config=ntnu&v=1&zlevel=2¢er=10.406281,63.417093&zoom=19.5&campuses=ntnu&campusid=1&sharepoitype=poi&sharepoi=38159&utm_medium=longurl">Veibeskrivelse</li></a>
|
||||
<div id="doorIndicator" class="<?php echo($doorEntry->open ? "doorIndicator_OPEN" : "doorIndicator_CLOSED"); ?>" onclick="location.href='/door/graph.html'">
|
||||
<p class="doorStateText"><?php echo($doorStateText) ?></p>
|
||||
<p class="doorStateTime">(Oppdatert <?php echo($doorTime) ?>)</p>
|
||||
<div id="doorIndicator" class="<?php echo $doorEntry->open ? 'doorIndicator_OPEN' : 'doorIndicator_CLOSED'; ?>" onclick="location.href='/door/graph.html'">
|
||||
<p class="doorStateText"><?php echo $doorStateText; ?></p>
|
||||
<p class="doorStateTime">(Oppdatert <?php echo $doorTime; ?>)</p>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -66,22 +69,25 @@ $doorTime = date("H:i", $doorEntry->time);
|
||||
<div class="calendar-events">
|
||||
<?php $counter1 = 0; ?>
|
||||
<?php $counter2 = 0; ?>
|
||||
<?php foreach($agenda->getNextDays() as $period => $events) if ($events && $counter1 < 3 && $counter2 < 10) { $counter1++ ?>
|
||||
<p class="no-chin"><?= $translation[$period] ?></p>
|
||||
<?php foreach ($agenda->getNextDays() as $period => $events) {
|
||||
if ($events && $counter1 < 3 && $counter2 < 10) {
|
||||
$counter1++; ?>
|
||||
<p class="no-chin"><?php echo $translation[$period]; ?></p>
|
||||
<hr>
|
||||
<ul>
|
||||
<?php foreach($events as $event) { $counter2++ ?>
|
||||
<?php foreach ($events as $event) {
|
||||
$counter2++; ?>
|
||||
<li>
|
||||
<?php if ($event->getURL()) { ?>
|
||||
<a href="<?= htmlspecialchars($event->getURL()) ?>"><?= $event->getName(); ?></a>
|
||||
<a href="<?php echo htmlspecialchars($event->getURL()); ?>"><?php echo $event->getName(); ?></a>
|
||||
<?php } else { ?>
|
||||
<strong><?= $event->getName(); ?></strong>
|
||||
<strong><?php echo $event->getName(); ?></strong>
|
||||
<?php } ?>
|
||||
|
||||
<span class="datetime">
|
||||
<?php if ($period !== \pvv\side\Agenda::TODAY) {
|
||||
echo $event->getStart()->format('H:i') . " " ;
|
||||
if (\pvv\side\Agenda::isThisWeek($event->getStart()) || $event->getStart()->sub(new DateInterval('P3D'))->getTimestamp() < time()) {
|
||||
<?php if ($period !== pvv\side\Agenda::TODAY) {
|
||||
echo $event->getStart()->format('H:i') . ' ';
|
||||
if (pvv\side\Agenda::isThisWeek($event->getStart()) || $event->getStart()->sub(new DateInterval('P3D'))->getTimestamp() < time()) {
|
||||
echo $event->getStart()->format('D');
|
||||
} else {
|
||||
echo $event->getStart()->format('j. F');
|
||||
@@ -94,25 +100,28 @@ $doorTime = date("H:i", $doorEntry->time);
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php } ?>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<p><a class="btn" href="hendelser/">Flere aktiviteter</a></p>
|
||||
</div>
|
||||
|
||||
<div class="gridl">
|
||||
<?php
|
||||
$title = $motd["title"];
|
||||
$title = $motd['title'];
|
||||
|
||||
echo "<h1>";
|
||||
if($title == ""){
|
||||
echo "Dagens melding";
|
||||
}else{
|
||||
echo '<h1>';
|
||||
if ($title == '') {
|
||||
echo 'Dagens melding';
|
||||
} else {
|
||||
echo $title;
|
||||
}
|
||||
echo "</h1>";
|
||||
echo '</h1>';
|
||||
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $motd["content"]));
|
||||
echo $Parsedown->text(implode("\n", $motd['content']));
|
||||
?>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
<?php
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$year = (isset($_GET['year']))
|
||||
? $_GET['year']
|
||||
: date("Y");
|
||||
: date('Y');
|
||||
$month = (isset($_GET['month']))
|
||||
? $_GET['month']
|
||||
: date("m");
|
||||
$days_before_the_first = (new DateTime($year."-".$month."-01"))->format("w") - 1;
|
||||
if ($days_before_the_first==-1) {$days_before_the_first = 6;}
|
||||
$day_of_month = ($month == date("m"))
|
||||
? date("j")
|
||||
: date('m');
|
||||
$days_before_the_first = (new DateTime($year . '-' . $month . '-01'))->format('w') - 1;
|
||||
if ($days_before_the_first == -1) {
|
||||
$days_before_the_first = 6;
|
||||
}
|
||||
$day_of_month = ($month == date('m'))
|
||||
? date('j')
|
||||
: -1;
|
||||
$days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
|
||||
|
||||
@@ -36,18 +38,25 @@ $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
<h2 style="text-align:center;">PVV Kalender for <?=$months_translations[$month-1]?> <?=$year?></h2>
|
||||
<h2 style="text-align:center;">PVV Kalender for <?php echo $months_translations[$month - 1]; ?> <?php echo $year; ?></h2>
|
||||
|
||||
<div class="pagination_bar"><?php
|
||||
$pmonth = $month-1;
|
||||
$nmonth = $month+1;
|
||||
$pyear=$year;
|
||||
$nyear=$year;
|
||||
if ($pmonth==0) {$pmonth=12; $pyear--;}
|
||||
if ($nmonth==13) {$nmonth=1; $nyear++;}
|
||||
<div class="pagination_bar">
|
||||
<?php
|
||||
$pmonth = $month - 1;
|
||||
$nmonth = $month + 1;
|
||||
$pyear = $year;
|
||||
$nyear = $year;
|
||||
if ($pmonth == 0) {
|
||||
$pmonth = 12;
|
||||
--$pyear;
|
||||
}
|
||||
if ($nmonth == 13) {
|
||||
$nmonth = 1;
|
||||
++$nyear;
|
||||
}
|
||||
?>
|
||||
<a class="btn noselect" href="../kalender?year=<?=$pyear?>&month=<?=$pmonth?>">Forrige måned</a>
|
||||
<a class="btn noselect" href="../kalender?year=<?=$nyear?>&month=<?=$nmonth?>">Neste måned</a>
|
||||
<a class="btn noselect" href="../kalender?year=<?php echo $pyear; ?>&month=<?php echo $pmonth; ?>">Forrige måned</a>
|
||||
<a class="btn noselect" href="../kalender?year=<?php echo $nyear; ?>&month=<?php echo $nmonth; ?>">Neste måned</a>
|
||||
</div>
|
||||
|
||||
<figure class="calendar">
|
||||
@@ -61,30 +70,30 @@ $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
|
||||
<li class="header noselect">søndag
|
||||
|
||||
<?php if ($days_before_the_first != 0) { ?>
|
||||
<li class="outOfMonth" style="grid-column: 1/<?=$days_before_the_first+1?>;">
|
||||
<li class="outOfMonth" style="grid-column: 1/<?php echo $days_before_the_first + 1; ?>;">
|
||||
<?php } ?>
|
||||
|
||||
<?php for ($day=1; $day <= $days_in_month; $day++) { ?>
|
||||
<?php for ($day = 1; $day <= $days_in_month; ++$day) { ?>
|
||||
<?php $events = $agenda->getEventsBetween(
|
||||
new DateTimeImmutable("$year-$month-$day 00:00:00"),
|
||||
new DateTimeImmutable("$year-$month-$day 23:59:59")); ?>
|
||||
<?php if ($day==$day_of_month) { ?>
|
||||
new DateTimeImmutable("{$year}-{$month}-{$day} 00:00:00"),
|
||||
new DateTimeImmutable("{$year}-{$month}-{$day} 23:59:59")
|
||||
); ?>
|
||||
<?php if ($day == $day_of_month) { ?>
|
||||
<li class="active">
|
||||
<?php } else { ?>
|
||||
<li>
|
||||
<?php } ?>
|
||||
<?php if (sizeof($events)!=0) { ?>
|
||||
<a href="../aktiviteter/?<?="year=$year&month=$month&day=$day"?>"><div>
|
||||
<span class="noselect day"><?= $day ?>.</span>
|
||||
<?php foreach($events as $event) { ?>
|
||||
<section style="background: <?=$event->getColor()?>"><?=$event->getName()?></section>
|
||||
<?php if (count($events) != 0) { ?>
|
||||
<a href="../aktiviteter/?<?php echo "year={$year}&month={$month}&day={$day}"; ?>"><div>
|
||||
<span class="noselect day"><?php echo $day; ?>.</span>
|
||||
<?php foreach ($events as $event) { ?>
|
||||
<section style="background: <?php echo $event->getColor(); ?>"><?php echo $event->getName(); ?></section>
|
||||
<?php } ?>
|
||||
</div></a>
|
||||
<?php } else { ?>
|
||||
<span class="noselect day"><?= $day ?>.</span>
|
||||
<span class="noselect day"><?php echo $day; ?>.</span>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
</ul>
|
||||
</figure>
|
||||
</main>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
|
||||