Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
3385f0e515 |
.envrc.git-blame-ignore-revs.gitignore.php-cs-fixer.phpDockerfileREADME.mdcomposer.jsoncomposer.lockdev.batdev.sh
dist
authsources_example.phpconfig.local.phpconfig.source-env.phpdataporten_config.phppvv.sqlpvv_mysql.sqlpvv_sqlite.sqlsaml20-idp-remote.phpsimplesamlphp-authsources.phpsimplesamlphp-config.phpsql_config_example.php
flake.lockflake.nixinc
lib
nix
src
_autoload.php
pvv
www
.well-known/autoconfig/mail
admin
aktiviteter
anime
brettspill
css
door
drift
galleri
hendelser
index.phpjs
kalender
kontakt
mail
nerdepitsa
om
paamelding
prosjekt
robots.txtspaceapi.php
1
.envrc
1
.envrc
@ -1 +0,0 @@
|
||||
use flake
|
@ -1,3 +0,0 @@
|
||||
# The formattening
|
||||
c5d308654744e116090e9ba165a968b8bf66006c
|
||||
da8afe735c62e1f8ee9ad5f71291d87102fe126b
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,5 +1,5 @@
|
||||
/result
|
||||
/config.php
|
||||
/sql_config.php
|
||||
/dataporten_config.php
|
||||
*.sqlite
|
||||
/test.sql
|
||||
/vendor/
|
||||
|
@ -1,58 +0,0 @@
|
||||
<?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")
|
||||
;
|
@ -2,6 +2,6 @@
|
||||
FROM php:7.4-cli
|
||||
RUN apt-get update && \
|
||||
apt-get install -y \
|
||||
sqlite3 \
|
||||
sqlite \
|
||||
unzip \
|
||||
git
|
||||
|
@ -13,9 +13,7 @@ Put it in a folder your webserver can find.
|
||||
|
||||
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`.
|
||||
Then make sure PHP has the `curl`, `pdo-sqlite` and `sqlite3` extensions enabled, see `/etc/php/php.ini`.
|
||||
|
||||
./dev.sh
|
||||
|
||||
|
@ -1,16 +1,9 @@
|
||||
{
|
||||
"name": "programvareverkstedet/nettsiden",
|
||||
"description": "Programvareverkstedets nettside",
|
||||
"license": "proprietary",
|
||||
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"simplesamlphp/composer-module-installer": true,
|
||||
"simplesamlphp/composer-xmlprovider-installer": true
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"simplesamlphp/simplesamlphp": "^2.2.1",
|
||||
"erusev/parsedown": "^1.7.4"
|
||||
}
|
||||
"require": {
|
||||
"simplesamlphp/simplesamlphp": "~1",
|
||||
"erusev/parsedown": "^1.7"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-pdo_sqlite": "*"
|
||||
}
|
||||
}
|
||||
|
4465
composer.lock
generated
4465
composer.lock
generated
File diff suppressed because it is too large
Load Diff
11
dev.bat
Normal file
11
dev.bat
Normal file
@ -0,0 +1,11 @@
|
||||
REM php og sqlite3 må være tilgjengelig i PATH
|
||||
|
||||
IF EXIST "sql_config.php" goto config_end
|
||||
cp sql_config_example.php sql_config.php
|
||||
:config_end
|
||||
|
||||
IF EXIST "pvv.sqlite" goto sqlite_end
|
||||
sqlite3 pvv.sqlite < pvv.sql
|
||||
:sqlite_end
|
||||
|
||||
php -S [::1]:1080 -t www/ -c php.ini
|
25
dev.sh
Executable file
25
dev.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
which sqlite3 > /dev/null 2>&1 || (echo ERROR: sqlite not found; false) || exit 1
|
||||
test ! -e pvv.sqlite && sqlite3 pvv.sqlite < dist/pvv.sql
|
||||
test ! -e sql_config.php && cp -v dist/sql_config_example.php sql_config.php
|
||||
|
||||
test ! -e dataporten_config.php && cp -v dist/dataporten_config.php dataporten_config.php
|
||||
|
||||
test -e composer.phar || curl -O https://getcomposer.org/composer.phar
|
||||
|
||||
if test ! -f lib/OAuth2-Client/OAuth2Client.php ; then
|
||||
echo Missing git submodules. Installing...
|
||||
(set -x; git submodule update --init --recursive) || exit $?
|
||||
fi
|
||||
|
||||
if test ! -d vendor; then
|
||||
php composer.phar install || exit $?
|
||||
cp -v dist/authsources_example.php vendor/simplesamlphp/simplesamlphp/config/authsources.php
|
||||
cp -v dist/saml20-idp-remote.php vendor/simplesamlphp/simplesamlphp/metadata/saml20-idp-remote.php
|
||||
# cp -v vendor/simplesamlphp/simplesamlphp/config-templates/config.php vendor/simplesamlphp/simplesamlphp/config/config.php
|
||||
sed -e "s/'trusted.url.domains' => array()/'trusted.url.domains' => array('localhost:1080')/g" < vendor/simplesamlphp/simplesamlphp/config-templates/config.php > vendor/simplesamlphp/simplesamlphp/config/config.php
|
||||
ln -s ../vendor/simplesamlphp/simplesamlphp/www/ www/simplesaml
|
||||
fi
|
||||
|
||||
php -S ${DOCKER_HOST:-[::1]}:${DOCKER_PORT:-1080} -d error_reporting=E_ALL -d display_errors=1 -t www/
|
9
dist/authsources_example.php
vendored
Normal file
9
dist/authsources_example.php
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
<?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/',
|
||||
),
|
||||
);
|
24
dist/config.local.php
vendored
24
dist/config.local.php
vendored
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$DB_DSN = 'sqlite:' . __DIR__ . \DIRECTORY_SEPARATOR . 'pvv.sqlite';
|
||||
$DB_USER = null;
|
||||
$DB_PASS = null;
|
||||
|
||||
$DOOR_SECRET = 'changeme';
|
||||
|
||||
$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_SERVER_PATH = '/images/slideshow/';
|
||||
|
||||
$SAML_COOKIE_SALT = 'changeme';
|
||||
$SAML_COOKIE_SECURE = false;
|
||||
$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';
|
6
dist/config.source-env.php
vendored
6
dist/config.source-env.php
vendored
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$configFile = getenv('PVV_CONFIG_FILE');
|
||||
require_once $configFile;
|
21
dist/dataporten_config.php
vendored
Normal file
21
dist/dataporten_config.php
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
# go to https://auth.dataporten.no/
|
||||
|
||||
$dataportenConfig = [
|
||||
'client_id' => "",
|
||||
'client_secret' => "",
|
||||
//'redirect_uri' => "https://pvv.ntnu.no/paamelding/",
|
||||
'redirect_uri' => "http://localhost:1080/paamelding/",
|
||||
'auth' => "https://auth.dataporten.no/oauth/authorization",#Authorization endpoint
|
||||
'token' => "https://auth.dataporten.no/oauth/token",#Token endpoint
|
||||
|
||||
/* OPTIONAL */
|
||||
|
||||
# 'authorization_type' => "Bearer",
|
||||
# 'session' => false,
|
||||
# 'verify' => 1,
|
||||
# 'grant_type' => "authorization_code",
|
||||
# 'response_type' => "code",
|
||||
# 'scope' => "",
|
||||
];
|
50
dist/pvv.sql
vendored
Normal file
50
dist/pvv.sql
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
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);
|
60
dist/pvv_mysql.sql
vendored
60
dist/pvv_mysql.sql
vendored
@ -1,45 +1,47 @@
|
||||
CREATE TABLE events (
|
||||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||
`name` TEXT,
|
||||
`start` TEXT,
|
||||
`stop` TEXT,
|
||||
`organiser` TEXT,
|
||||
`location` TEXT,
|
||||
`description` TEXT
|
||||
`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 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
|
||||
`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 users (
|
||||
`uname` TEXT,
|
||||
`groups` INT DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE motd (
|
||||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||
`title` TEXT,
|
||||
`content` TEXT
|
||||
`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);
|
||||
CREATE TABLE door (
|
||||
`time` INTEGER PRIMARY KEY,
|
||||
`open` BOOLEAN
|
||||
);
|
||||
INSERT INTO door(time, open) VALUES (0, FALSE);
|
54
dist/pvv_sqlite.sql
vendored
54
dist/pvv_sqlite.sql
vendored
@ -1,54 +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);
|
@ -1,21 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
$metadata['https://idp.pvv.ntnu.no/'] = [
|
||||
$metadata['https://idp.pvv.ntnu.no/'] = array (
|
||||
'metadata-set' => 'saml20-idp-remote',
|
||||
'entityid' => 'https://idp.pvv.ntnu.no/',
|
||||
'SingleSignOnService' => [
|
||||
0 => [
|
||||
'SingleSignOnService' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
||||
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SSOService.php',
|
||||
],
|
||||
],
|
||||
'SingleLogoutService' => [
|
||||
0 => [
|
||||
),
|
||||
),
|
||||
'SingleLogoutService' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'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',
|
||||
];
|
||||
);
|
12
dist/simplesamlphp-authsources.php
vendored
12
dist/simplesamlphp-authsources.php
vendored
@ -1,12 +0,0 @@
|
||||
<?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/',
|
||||
],
|
||||
];
|
1302
dist/simplesamlphp-config.php
vendored
1302
dist/simplesamlphp-config.php
vendored
File diff suppressed because it is too large
Load Diff
6
dist/sql_config_example.php
vendored
Normal file
6
dist/sql_config_example.php
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$dbDsn = 'sqlite:'.__DIR__.DIRECTORY_SEPARATOR.'pvv.sqlite';
|
||||
$dbUser = null;
|
||||
$dbPass = null;
|
||||
|
||||
$doorSensorSecret = "OGJiZTdjZDctMmFkNy00ZjZjLTk3OGItOTA3NzU3ZDM2Yjlm";
|
27
flake.lock
generated
27
flake.lock
generated
@ -1,27 +0,0 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1741678040,
|
||||
"narHash": "sha256-rmBsz7BBcDwfvDkxnKHmolKceGJrr0nyz5PQYZg0kMk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3ee8818da146871cd570b164fc4f438f78479a50",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
37
flake.nix
37
flake.nix
@ -1,37 +0,0 @@
|
||||
{
|
||||
description = "Programvareverkstedet/nettsiden PHP environment";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in f system pkgs);
|
||||
in {
|
||||
packages = forAllSystems (system: pkgs: {
|
||||
default = self.packages.${system}.pvv-nettsiden;
|
||||
pvv-nettsiden = pkgs.callPackage ./nix/package.nix { php = pkgs.php84; };
|
||||
});
|
||||
|
||||
overlays.default = final: prev: {
|
||||
inherit (self.packages.${final.system}) pvv-nettsiden;
|
||||
formats = prev.formats // {
|
||||
php = import ./nix/php-generator.nix { pkgs = prev; lib = prev.lib; };
|
||||
};
|
||||
};
|
||||
|
||||
nixosModules.default = nix/module.nix;
|
||||
|
||||
devShells = forAllSystems (system: pkgs: {
|
||||
default = pkgs.callPackage ./nix/shell.nix { inherit pkgs; };
|
||||
});
|
||||
};
|
||||
}
|
@ -1,13 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
require __DIR__ . '/../src/_autoload.php';
|
||||
require __DIR__ . '/../config.php';
|
||||
require __DIR__ . '/../sql_config.php';
|
||||
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$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,36 +1,34 @@
|
||||
<?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, ['', 'lib', 'OAuth2-Client', 'OAuth2Client.php']);
|
||||
require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'dataporten_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, ['', 'sql_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']);
|
||||
|
||||
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($dbDsn, $dbUser, $dbPass);
|
||||
$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 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),
|
||||
]);
|
||||
use \pvv\side\Agenda;
|
||||
$agenda = new \pvv\side\Agenda([
|
||||
new \pvv\side\social\NerdepitsaActivity,
|
||||
// new \pvv\side\social\AnimekveldActivity,
|
||||
// new \pvv\side\social\DriftkveldActivity,
|
||||
new \pvv\side\DBActivity($pdo),
|
||||
]);
|
||||
|
||||
$months_translations = ['januar', 'februar', 'mars', 'april', 'mai', 'juni', 'juli', 'august', 'september', 'oktober', 'november', 'desember'];
|
||||
|
116
inc/navbar.php
116
inc/navbar.php
@ -1,74 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
function navbar($depth, $active = null) {
|
||||
$result = "\n\t<ul id=\"menu\">\n";
|
||||
$menuItems = [
|
||||
'Hjem' => '',
|
||||
'Hendelser' => 'hendelser',
|
||||
// 'Kalender' => 'kalender',
|
||||
// 'Aktiviteter' => 'aktiviteter',
|
||||
'Prosjekter' => 'prosjekt',
|
||||
'Kontakt' => 'kontakt',
|
||||
'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) {
|
||||
$isActive = $active === $link;
|
||||
if (substr($link, 0, 4) !== 'http') {
|
||||
$link = rtrim(str_repeat('../', $depth) . $link, '/') . '/';
|
||||
}
|
||||
|
||||
// if ($isActive) $link = '#';
|
||||
|
||||
$result .= "\t\t<li" . ($isActive ? ' class="active"' : '') . '>'
|
||||
. '<a href="' . $link . '">'
|
||||
. $caption
|
||||
. "</a></li>\n";
|
||||
}
|
||||
|
||||
return $result . "\t</ul>\n";
|
||||
function navbar($depth, $active = NULL) {
|
||||
$result = "\n\t<ul id=\"menu\">\n";
|
||||
$menuItems = [
|
||||
'Hjem' => '',
|
||||
'Hendelser' => 'hendelser',
|
||||
//'Kalender' => 'kalender',
|
||||
//'Aktiviteter' => 'aktiviteter',
|
||||
'Prosjekter' => 'prosjekt',
|
||||
'Kontakt' => 'kontakt',
|
||||
'Webmail' => 'mail',
|
||||
//'Webmail' => 'https://webmail.pvv.ntnu.no/',
|
||||
'Galleri' => 'galleri',
|
||||
'Wiki' => 'pvv',
|
||||
'Git' => 'https://git.pvv.ntnu.no/',
|
||||
];
|
||||
foreach($menuItems as $caption => $link) {
|
||||
$isActive = $active === $link;
|
||||
if (substr( $link, 0, 4 ) != "http") {
|
||||
$link = rtrim(str_repeat('../', $depth) . $link, '/') . '/';
|
||||
}
|
||||
|
||||
//if ($isActive) $link = '#';
|
||||
|
||||
$result .= "\t\t<li" . ($isActive ? ' class="active"' : '') . '>'
|
||||
. '<a href="' . $link . '">'
|
||||
. $caption
|
||||
. "</a></li>\n"
|
||||
;
|
||||
}
|
||||
return $result . "\t</ul>\n";
|
||||
}
|
||||
|
||||
function loginBar($sp = null, $pdo = null) {
|
||||
if (null === $sp) {
|
||||
$sp = 'default-sp';
|
||||
}
|
||||
$result = "\n";
|
||||
require_once __DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple($sp);
|
||||
if (is_null($sp)) $sp = 'default-sp';
|
||||
$result = "\n";
|
||||
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">
|
||||
$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" />
|
||||
<ellipse cx="32" cy="66" rx="24" ry="28" stroke-width="0" />
|
||||
</svg>
|
||||
';
|
||||
|
||||
$attr = $as->getAttributes();
|
||||
if ($attr) {
|
||||
$uname = $attr['uid'][0];
|
||||
$isAdmin = false;
|
||||
if (isset($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";
|
||||
$attr = $as->getAttributes();
|
||||
if($attr) {
|
||||
$uname = $attr['uid'][0];
|
||||
$isAdmin = false;
|
||||
if (isset($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";
|
||||
|
||||
$result .= "\n\t<ul id=\"usermenu\">\n";
|
||||
$result .= "\n\t\t<li><a id=\"login\" href=\"#\">{$svg}" . htmlspecialchars($uname) . "</a></li>\n";
|
||||
if ($isAdmin) {
|
||||
$result .= "\n\t\t<li><a href=\"/admin/\">Admin</a></li>\n";
|
||||
}
|
||||
$result .= "\n\t\t<li><a href=\"" . htmlspecialchars($as->getLogoutURL()) . "\">Logg ut</a></li>\n";
|
||||
$result .= "\n\t</ul>\n";
|
||||
} else {
|
||||
$result .= "\t<a id=\"login\" href=\"" . htmlspecialchars($as->getLoginURL()) . "\">{$svg}Logg inn</a>\n";
|
||||
}
|
||||
$result .= "\n\t<ul id=\"usermenu\">\n";
|
||||
$result .= "\n\t\t<li><a id=\"login\" href=\"#\">${svg}" . htmlspecialchars($uname) . "</a></li>\n";
|
||||
if ($isAdmin) {
|
||||
$result .= "\n\t\t<li><a href=\"/admin/\">Admin</a></li>\n";
|
||||
}
|
||||
$result .= "\n\t\t<li><a href=\"" . htmlspecialchars($as->getLogoutURL()) . "\">Logg ut</a></li>\n";
|
||||
$result .= "\n\t</ul>\n";
|
||||
} else {
|
||||
$result .= "\t<a id=\"login\" href=\"" . htmlspecialchars($as->getLoginURL()) . "\">${svg}Logg inn</a>\n";
|
||||
}
|
||||
|
||||
$result .= "\n\t<a href=\"#menu\" id=\"menu_toggle\" aria-hidden=\"true\"><big>☰ </big>MENU</a>\n";
|
||||
$result .= "\n\t<a href=\"#menu\" id=\"menu_toggle\" aria-hidden=\"true\"><big>☰ </big>MENU</a>\n";
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
35
inc/ticker.php
Normal file
35
inc/ticker.php
Normal file
@ -0,0 +1,35 @@
|
||||
<ul id="ticker">
|
||||
<?php
|
||||
{
|
||||
require __DIR__ . '/../src/_autoload.php';
|
||||
require __DIR__ . '/../sql_config.php';
|
||||
$translation = ['i dag', 'i morgen', 'denne uken', 'neste uke', 'denne måneden', 'neste måned'];
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$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),
|
||||
]);
|
||||
|
||||
$test = true;
|
||||
foreach($agenda->getNextDays() as $period => $events) {
|
||||
if (!$events) continue;
|
||||
$i = 0;
|
||||
$n = count($events);
|
||||
foreach($events as $event){
|
||||
if ($i == 0){
|
||||
echo '<li style="text-align: center;"><span style="text-transform: uppercase;">' . $translation[$period] . '</span>: ';
|
||||
} else if ($i < $n-1) {
|
||||
echo '<i style="opacity:0.7;">, </i>';
|
||||
} else{
|
||||
echo '<i style="opacity:0.7;"> og </i>';
|
||||
}
|
||||
echo '<a href="' . $event->getURL() . '">' . $event->getName() . '</a>';
|
||||
$i = $i + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
1
lib/OAuth2-Client
Submodule
1
lib/OAuth2-Client
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 7b2dc91100becd0c3d15de8764ad279ded0d3a58
|
254
nix/module.nix
254
nix/module.nix
@ -1,254 +0,0 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.services.pvv-nettsiden;
|
||||
inherit (lib) mkDefault mkEnableOption mkPackageOption mkIf mkOption types mdDoc;
|
||||
format = pkgs.formats.php { };
|
||||
in
|
||||
{
|
||||
options.services.pvv-nettsiden = {
|
||||
enable = mkEnableOption (lib.mdDoc "Enable pvv-nettsiden");
|
||||
|
||||
package = mkPackageOption pkgs "pvv-nettsiden" { };
|
||||
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "pvv-nettsiden";
|
||||
description = mdDoc "User to run php-fpm and own the image directories";
|
||||
};
|
||||
|
||||
group = mkOption {
|
||||
type = types.str;
|
||||
default = "pvv-nettsiden";
|
||||
description = mdDoc "Group to run php-fpm and own the image directories";
|
||||
};
|
||||
|
||||
domainName = mkOption {
|
||||
type = types.str;
|
||||
default = "www.pvv.no";
|
||||
description = mdDoc "Domain name for the website";
|
||||
};
|
||||
|
||||
enableNginx = mkEnableOption "nginx" // { default = true; };
|
||||
useSSL = mkEnableOption "secure cookies" // { default = true; };
|
||||
|
||||
settings = mkOption {
|
||||
description = "Settings for the website";
|
||||
default = { };
|
||||
type = types.submodule {
|
||||
freeformType = format.type;
|
||||
options = lib.mapAttrsRecursiveCond
|
||||
(attrs: !(attrs ? "type"))
|
||||
(_: option: option // { type = types.either option.type format.lib.types.raw; })
|
||||
{
|
||||
DOOR_SECRET = mkOption {
|
||||
type = types.str;
|
||||
description = mdDoc "Secret for the door sensor API";
|
||||
};
|
||||
|
||||
GALLERY = {
|
||||
DIR = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/lib/pvv-nettsiden/gallery";
|
||||
description = mdDoc "Directory where the gallery is located. See documentation at TODO";
|
||||
};
|
||||
|
||||
SERVER_PATH = mkOption {
|
||||
type = types.str;
|
||||
default = "/static/gallery";
|
||||
description = mdDoc "Path to the gallery on the server";
|
||||
};
|
||||
};
|
||||
|
||||
SLIDESHOW = {
|
||||
DIR = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/lib/pvv-nettsiden/slideshow";
|
||||
description = mdDoc "Directory where the slideshow is located. See documentation at TODO";
|
||||
};
|
||||
|
||||
SERVER_PATH = mkOption {
|
||||
type = types.str;
|
||||
default = "/static/slideshow";
|
||||
description = mdDoc "Path to the slideshow on the server";
|
||||
};
|
||||
};
|
||||
|
||||
DB = {
|
||||
DSN = mkOption {
|
||||
type = types.str;
|
||||
default = "sqlite:/var/lib/pvv-nettsiden/pvv-nettsiden.db";
|
||||
example = "pgsql:host=localhost;port=5432;dbname=testdb;user=bruce;password=mypass";
|
||||
description = mdDoc "Database connection string, see https://www.php.net/manual/en/pdo.construct.php";
|
||||
};
|
||||
|
||||
USER = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
example = "pvv-nettsiden";
|
||||
description = mdDoc "Database user";
|
||||
};
|
||||
|
||||
PASS = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
description = mdDoc "Database password. Recommends: null, set in extraConfig";
|
||||
};
|
||||
};
|
||||
|
||||
SAML = {
|
||||
COOKIE_SALT = mkOption {
|
||||
type = types.str;
|
||||
description = mdDoc "Salt for the SAML cookies";
|
||||
};
|
||||
|
||||
COOKIE_SECURE = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = mdDoc "Whether to set the secure flag on the SAML cookies";
|
||||
};
|
||||
|
||||
ADMIN_NAME = mkOption {
|
||||
type = types.str;
|
||||
description = mdDoc "Name for the admin user";
|
||||
};
|
||||
|
||||
ADMIN_EMAIL = mkOption {
|
||||
type = types.str;
|
||||
description = mdDoc "Email for the admin user";
|
||||
};
|
||||
|
||||
ADMIN_PASSWORD = mkOption {
|
||||
type = types.str;
|
||||
description = mdDoc "Password for the admin user";
|
||||
};
|
||||
|
||||
TRUSTED_DOMAINS = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ cfg.domainName ];
|
||||
description = mdDoc "List of trusted domains for the SAML service";
|
||||
};
|
||||
};
|
||||
|
||||
CACHE_DIRECTORY = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/cache/pvv-nettsiden/simplesamlphp";
|
||||
description = mdDoc "List of trusted domains for the SAML service";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
config = mkIf cfg.enable (let
|
||||
# NOTE: This should absolutely not be necessary, but for some reason this file refuses to import
|
||||
# the toplevel configuration file.
|
||||
# NOTE: Nvm, don't this this was the problem after all?
|
||||
finalPackage = cfg.package.overrideAttrs (_: _: {
|
||||
postInstall = let
|
||||
f = x: lib.escapeShellArg (format.lib.valueToString x);
|
||||
in cfg.package.postInstall + ''
|
||||
substituteInPlace $out/${cfg.package.passthru.simplesamlphpPath}/config/config.php \
|
||||
--replace '$SAML_COOKIE_SECURE' ${f cfg.settings.SAML.COOKIE_SECURE} \
|
||||
--replace '$SAML_COOKIE_SALT' ${f cfg.settings.SAML.COOKIE_SALT} \
|
||||
--replace '$SAML_ADMIN_PASSWORD' ${f cfg.settings.SAML.ADMIN_PASSWORD} \
|
||||
--replace '$SAML_ADMIN_NAME' ${f cfg.settings.SAML.ADMIN_NAME} \
|
||||
--replace '$SAML_ADMIN_EMAIL' ${f cfg.settings.SAML.ADMIN_EMAIL} \
|
||||
--replace '$SAML_TRUSTED_DOMAINS' ${f cfg.settings.SAML.TRUSTED_DOMAINS} \
|
||||
--replace '$CACHE_DIRECTORY' ${f cfg.settings.CACHE_DIRECTORY}
|
||||
'';
|
||||
});
|
||||
in {
|
||||
users.users = mkIf (cfg.user == "pvv-nettsiden") {
|
||||
"pvv-nettsiden" = {
|
||||
description = "PVV Website Service User";
|
||||
group = cfg.group;
|
||||
createHome = false;
|
||||
isSystemUser = true;
|
||||
};
|
||||
};
|
||||
|
||||
users.groups = mkIf (cfg.group == "pvv-nettsiden") {
|
||||
"pvv-nettsiden" = { };
|
||||
};
|
||||
|
||||
systemd.tmpfiles.settings."10-pvv-nettsiden".${cfg.settings.CACHE_DIRECTORY}.d = {
|
||||
inherit (cfg) user group;
|
||||
mode = "0770";
|
||||
};
|
||||
|
||||
services.nginx = mkIf cfg.enableNginx {
|
||||
enable = true;
|
||||
|
||||
recommendedGzipSettings = mkDefault true;
|
||||
recommendedProxySettings = mkDefault true;
|
||||
|
||||
virtualHosts."${cfg.domainName}" = {
|
||||
forceSSL = mkDefault cfg.useSSL;
|
||||
enableACME = mkDefault true;
|
||||
locations = {
|
||||
"/" = {
|
||||
root = "${finalPackage}/share/php/pvv-nettsiden/www/";
|
||||
index = "index.php";
|
||||
};
|
||||
|
||||
"~ \\.php$".extraConfig = ''
|
||||
include ${pkgs.nginx}/conf/fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME ${finalPackage}/share/php/pvv-nettsiden/www$fastcgi_script_name;
|
||||
fastcgi_pass unix:${config.services.phpfpm.pools."pvv-nettsiden".socket};
|
||||
'';
|
||||
|
||||
# based on https://simplesamlphp.org/docs/stable/simplesamlphp-install.html#configuring-nginx
|
||||
"^~ /simplesaml/" = {
|
||||
alias = "${finalPackage}/${finalPackage.passthru.simplesamlphpPath}/public/";
|
||||
index = "index.php";
|
||||
|
||||
extraConfig = ''
|
||||
location ~ ^/simplesaml/(?<phpfile>.+?\.php)(?<pathinfo>/.*)?$ {
|
||||
include ${pkgs.nginx}/conf/fastcgi_params;
|
||||
fastcgi_pass unix:${config.services.phpfpm.pools."pvv-nettsiden".socket};
|
||||
fastcgi_param SCRIPT_FILENAME ${finalPackage}/${finalPackage.passthru.simplesamlphpPath}/public/$phpfile;
|
||||
|
||||
# Must be prepended with the baseurlpath
|
||||
fastcgi_param SCRIPT_NAME /simplesaml/$phpfile;
|
||||
|
||||
fastcgi_param PATH_INFO $pathinfo if_not_empty;
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
"^~ ${cfg.settings.GALLERY.SERVER_PATH}" = {
|
||||
root = cfg.settings.GALLERY.DIR;
|
||||
extraConfig = ''
|
||||
rewrite ^${cfg.settings.GALLERY.SERVER_PATH}/(.*)$ /$1 break;
|
||||
'';
|
||||
};
|
||||
|
||||
"^~ ${cfg.settings.SLIDESHOW.SERVER_PATH}" = {
|
||||
root = cfg.settings.SLIDESHOW.DIR;
|
||||
extraConfig = ''
|
||||
rewrite ^${cfg.settings.SLIDESHOW.SERVER_PATH}/(.*)$ /$1 break;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
services.phpfpm.pools.pvv-nettsiden = {
|
||||
user = cfg.user;
|
||||
group = cfg.group;
|
||||
|
||||
phpEnv.PVV_CONFIG_FILE = toString (format.generate "pvv-nettsiden-conf.php" cfg.settings);
|
||||
|
||||
settings = {
|
||||
"listen.owner" = config.services.nginx.user;
|
||||
"listen.group" = config.services.nginx.group;
|
||||
"pm" = mkDefault "ondemand";
|
||||
"pm.max_children" = mkDefault 32;
|
||||
"pm.process_idle_timeout" = mkDefault "10s";
|
||||
"pm.max_requests" = mkDefault 500;
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
{ lib
|
||||
, php
|
||||
, extra_files ? { }
|
||||
}:
|
||||
|
||||
php.buildComposerProject rec {
|
||||
src = ./..;
|
||||
pname = "pvv-nettsiden";
|
||||
version = "0.0.1";
|
||||
vendorHash = "sha256-8UYf7FhrTKgCa2e8GwhU8EF1AfWzZtgseTZqUAGOL0U=";
|
||||
|
||||
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
|
||||
|
||||
${lib.pipe extra_files [
|
||||
(lib.mapAttrsToList (target_path: source_path: ''
|
||||
mkdir -p $(dirname "$out/${target_path}")
|
||||
cp -r "${source_path}" "$out/${target_path}"
|
||||
''))
|
||||
(lib.concatStringsSep "\n")
|
||||
]}
|
||||
'';
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
{ pkgs, lib }:
|
||||
|
||||
with lib;
|
||||
|
||||
{ }: let
|
||||
valueToString = val:
|
||||
if val == null then
|
||||
"null"
|
||||
else if isString val then
|
||||
builtins.toJSON val
|
||||
else if isBool val then
|
||||
boolToString val
|
||||
else if isInt val || isFloat val then
|
||||
toString val
|
||||
else if isList val then
|
||||
"array(${concatMapStringsSep ", " valueToString val})"
|
||||
else if isAttrs val && val ? value && (val._type or "") == "raw" then
|
||||
val.value
|
||||
else if isAttrs val then
|
||||
throw "Found unexpected attrs, that were not created by mkRaw. Have you put attrs in an array?\n${val}"
|
||||
else throw "unsupported :')";
|
||||
in {
|
||||
inherit (pkgs.formats.json { }) type;
|
||||
|
||||
generate = name: value: let
|
||||
flattenStructuredSettings = attrs: let
|
||||
partitionAttrs = pred: attrs: lib.pipe attrs [
|
||||
attrsToList
|
||||
(partition ({ name, value }: pred name value))
|
||||
(mapAttrs (_: listToAttrs))
|
||||
];
|
||||
|
||||
partitionedAttrs = partitionAttrs (_: v: isAttrs v && !(v ? value && (v._type or "") == "raw")) attrs;
|
||||
|
||||
flattenedAttrs = lib.pipe partitionedAttrs.right [
|
||||
(mapAttrs (n1: mapAttrs' (n2: v2: nameValuePair "${n1}_${n2}" v2)))
|
||||
attrValues
|
||||
(map flattenStructuredSettings)
|
||||
(foldl recursiveUpdate { })
|
||||
];
|
||||
in recursiveUpdate flattenedAttrs partitionedAttrs.wrong;
|
||||
|
||||
content = lib.pipe value [
|
||||
flattenStructuredSettings
|
||||
(mapAttrs (_: valueToString))
|
||||
(mapAttrsToList (n: v: ''''$${n} = ${v};''))
|
||||
(concatStringsSep "\n")
|
||||
(content: "<?php\n${content}\n?>")
|
||||
];
|
||||
in pkgs.writeText name content;
|
||||
|
||||
lib = {
|
||||
inherit valueToString;
|
||||
|
||||
mkRaw = value: {
|
||||
inherit value;
|
||||
_type = "raw";
|
||||
};
|
||||
|
||||
types.raw = lib.types.attrs;
|
||||
};
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
{ pkgs, lib }:
|
||||
let
|
||||
phpEnv = pkgs.php84.buildEnv {
|
||||
extensions = { enabled, all }: enabled ++ (with all; [ iconv mbstring pdo_mysql pdo_sqlite ]);
|
||||
};
|
||||
in
|
||||
pkgs.mkShellNoCC {
|
||||
buildInputs = with pkgs; [
|
||||
phpEnv
|
||||
php84Packages.composer
|
||||
php84Packages.php-parallel-lint
|
||||
php84Packages.php-cs-fixer
|
||||
sqlite-interactive
|
||||
sql-formatter
|
||||
];
|
||||
|
||||
# Prepare dev environment with sqlite and config files
|
||||
shellHook = ''
|
||||
alias runDev='php -S localhost:1080 -d error_reporting=E_ALL -d display_errors=1 -t www/'
|
||||
|
||||
declare -a PROJECT_ROOT="$("${lib.getExe pkgs.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/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 $?
|
||||
|
||||
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/public/ www/simplesaml
|
||||
popd "$PROJECT_ROOT"
|
||||
fi
|
||||
'';
|
||||
}
|
@ -1,6 +1,4 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* Copyright (c) 2014-2015, Jørn Åne de Jong <@jornane>
|
||||
*
|
||||
@ -16,7 +14,7 @@ declare(strict_types=1);
|
||||
* 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.
|
||||
*
|
||||
@ -36,6 +34,6 @@ declare(strict_types=1);
|
||||
* @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,138 +1,134 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\admin;
|
||||
|
||||
class UserManager {
|
||||
private $pdo;
|
||||
use \PDO;
|
||||
|
||||
public $usergroups = [
|
||||
'admin' => 1,
|
||||
'prosjekt' => 2,
|
||||
'aktiviteter' => 4,
|
||||
];
|
||||
class UserManager{
|
||||
private $pdo;
|
||||
|
||||
public function __construct($pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
public $usergroups = [
|
||||
'admin' => 1,
|
||||
'prosjekt' => 2,
|
||||
'aktiviteter' => 4
|
||||
];
|
||||
|
||||
public function setupUser($uname, $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->execute();
|
||||
}
|
||||
public function __construct($pdo){
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function updateFlags($uname, $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);
|
||||
}
|
||||
public function setupUser($uname, $groups=0){
|
||||
$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->execute();
|
||||
}
|
||||
|
||||
public function addGroup($uname, $group): void {
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
public function updateFlags($uname, $flags){
|
||||
$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);
|
||||
}
|
||||
|
||||
if ($userFlags) {
|
||||
$newFlags = ($group | $userFlags);
|
||||
$this->updateFlags($uname, $newFlags);
|
||||
}
|
||||
}
|
||||
public function addGroup($uname, $group){
|
||||
$userFlags = $this->getUsergroups();
|
||||
|
||||
public function removeGroup($uname, $group): void {
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
if($userFlags){
|
||||
$newFlags = ($group | $userFlags);
|
||||
$this->updateFlags($uname, $newFlags);
|
||||
}
|
||||
}
|
||||
|
||||
if ($userFlags) {
|
||||
$newFlags = ($userFlags & (~ $group));
|
||||
$this->updateFlags($uname, $newFlags);
|
||||
}
|
||||
}
|
||||
public function removeGroup($uname, $group){
|
||||
$userFlags = $this->getUsergroups();
|
||||
|
||||
public function setGroups($uname, $groups): void {
|
||||
$query = 'SELECT * FROM users WHERE uname=:uname LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
$row = $statement->fetch();
|
||||
if($userFlags){
|
||||
$newFlags = ($userFlags & (~ $group));
|
||||
$this->updateFlags($uname, $newFlags);
|
||||
}
|
||||
}
|
||||
|
||||
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->execute();
|
||||
} else {
|
||||
$this->setupUser($uname, $groups);
|
||||
}
|
||||
}
|
||||
public function setGroups($uname, $groups){
|
||||
$query = 'SELECT * FROM users WHERE uname=:uname LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
$row = $statement->fetch();
|
||||
|
||||
public function hasGroup($uname, $groupName) {
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
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->execute();
|
||||
}else{
|
||||
$this->setupUser($uname, $groups);
|
||||
}
|
||||
}
|
||||
|
||||
return $userFlags & $this->usergroups[$groupName];
|
||||
}
|
||||
public function hasGroup($uname, $groupName){
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
|
||||
// for convenience
|
||||
public function isAdmin($uname) {
|
||||
return $this->hasGroup($uname, 'admin');
|
||||
}
|
||||
return ($userFlags & $this->usergroups[$groupName]);
|
||||
}
|
||||
|
||||
public function getFlagfromNames($names) {
|
||||
$resultFlag = 0;
|
||||
// for convenience
|
||||
public function isAdmin($uname){
|
||||
return $this->hasGroup($uname, 'admin');
|
||||
}
|
||||
|
||||
foreach ($this->usergroups as $name => $flag) {
|
||||
if (\in_array($name, $names, true)) {
|
||||
$resultFlag = ($resultFlag | $flag);
|
||||
}
|
||||
}
|
||||
public function getFlagfromNames($names){
|
||||
$resultFlag = 0;
|
||||
|
||||
return $resultFlag;
|
||||
}
|
||||
foreach($this->usergroups as $name => $flag){
|
||||
if(in_array($name, $names)){
|
||||
$resultFlag = ($resultFlag | $flag);
|
||||
}
|
||||
}
|
||||
|
||||
public function getUsergroups($uname) {
|
||||
$query = 'SELECT groups FROM users WHERE uname=:uname LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
return $resultFlag;
|
||||
}
|
||||
|
||||
$row = $statement->fetch();
|
||||
if ($row === false) {
|
||||
return 0;
|
||||
}
|
||||
public function getUsergroups($uname){
|
||||
$query = 'SELECT groups FROM users WHERE uname=:uname LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
return $row[0];
|
||||
}
|
||||
$row = $statement->fetch();
|
||||
if ($row == false) return 0;
|
||||
return $row[0];
|
||||
}
|
||||
|
||||
public function getUsergroupNames($uname) {
|
||||
$usersGroups = [];
|
||||
public function getUsergroupNames($uname){
|
||||
$usersGroups = [];
|
||||
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
|
||||
foreach ($this->usergroups as $name => $flag) {
|
||||
if ($userFlags & $flag) {
|
||||
$usersGroups[] = $name;
|
||||
}
|
||||
}
|
||||
foreach($this->usergroups as $name => $flag){
|
||||
if($userFlags & $flag){
|
||||
$usersGroups[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
return $usersGroups;
|
||||
}
|
||||
return $usersGroups;
|
||||
}
|
||||
|
||||
public function getAllUserData() {
|
||||
$query = 'SELECT uname FROM users ORDER BY uname ASC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
public function getAllUserData(){
|
||||
$query = 'SELECT uname FROM users ORDER BY uname ASC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
$users = [];
|
||||
foreach ($statement->fetchAll() as $userData) {
|
||||
$uname = $userData['uname'];
|
||||
$users[] = [
|
||||
'name' => $uname,
|
||||
'groups' => $this->getUsergroupNames($uname),
|
||||
];
|
||||
}
|
||||
$users = [];
|
||||
foreach($statement->fetchAll() as $userData){
|
||||
$uname = $userData['uname'];
|
||||
$users[] = [
|
||||
'name' => $uname,
|
||||
'groups' => $this->getUsergroupNames($uname)
|
||||
];
|
||||
}
|
||||
|
||||
return $users;
|
||||
}
|
||||
}
|
||||
return $users;
|
||||
}
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
<?php //declare(strict_types=1);
|
||||
namespace pvv\side;
|
||||
|
||||
interface Activity {
|
||||
public function getNextEventFrom(\DateTimeImmutable $date) /* : Event */;
|
||||
use \DateTimeImmutable;
|
||||
|
||||
interface Activity {
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */;
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */;
|
||||
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date) /* : Event */;
|
||||
}
|
||||
|
@ -1,114 +1,106 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
<?php //declare(strict_types=1);
|
||||
namespace pvv\side;
|
||||
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
|
||||
class Agenda {
|
||||
private $activities;
|
||||
|
||||
public const TODAY = 0;
|
||||
public const TOMORROW = 1;
|
||||
public const THIS_WEEK = 2;
|
||||
public const NEXT_WEEK = 3;
|
||||
public const THIS_MONTH = 4;
|
||||
public const 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) {
|
||||
$this->activities = $activities;
|
||||
}
|
||||
public function __construct($activities) {
|
||||
$this->activities = $activities;
|
||||
}
|
||||
|
||||
public static function getFormattedDate($date) {
|
||||
return $date->format('l j. M H.i');
|
||||
}
|
||||
|
||||
public function getEventsBetween(\DateTimeImmutable $from, \DateTimeImmutable $to) {
|
||||
$results = [];
|
||||
for ($i = 0; $i < \count($this->activities); ++$i) {
|
||||
$result = [];
|
||||
do {
|
||||
$run = false;
|
||||
if (\count($result)) {
|
||||
$date = end($result)->getStop();
|
||||
} else {
|
||||
$date = $from;
|
||||
}
|
||||
$next = $this->activities[$i]->getNextEventFrom($date);
|
||||
if (isset($next) && $next->getStart() < $to) {
|
||||
$result[] = $this->activities[$i]->getNextEventFrom($date);
|
||||
$run = true;
|
||||
}
|
||||
} while ($run);
|
||||
$results[] = $result;
|
||||
}
|
||||
$result = [];
|
||||
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() {
|
||||
$result = [[], [], [], [], [], []];
|
||||
$events = $this->getEventsBetween(
|
||||
(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;
|
||||
}
|
||||
$result[$index][] = $event;
|
||||
public static function getFormattedDate($date) {
|
||||
return trim(strftime('%A %e. %b %H.%M', $date->getTimeStamp()));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
public function getEventsBetween(DateTimeImmutable $from, DateTimeImmutable $to) {
|
||||
$results = [];
|
||||
for($i = 0; $i < sizeof($this->activities); $i++) {
|
||||
$result = [];
|
||||
do {
|
||||
$run = false;
|
||||
if (sizeof($result)) {
|
||||
$date = end($result)->getStop();
|
||||
} else {
|
||||
$date = $from;
|
||||
}
|
||||
$next = $this->activities[$i]->getNextEventFrom($date);
|
||||
if (isset($next) && $next->getStart() < $to) {
|
||||
$result[] = $this->activities[$i]->getNextEventFrom($date);
|
||||
$run = true;
|
||||
}
|
||||
} while ($run);
|
||||
$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;
|
||||
});
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getNextOfEach(\DateTimeImmutable $startDate) {
|
||||
$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
|
||||
);
|
||||
public function getNextDays() {
|
||||
$result = [[], [], [], [], [], []];
|
||||
$events = $this->getEventsBetween(
|
||||
(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;
|
||||
$result[$index][] = $event;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
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())
|
||||
? -1
|
||||
: 1
|
||||
;
|
||||
});
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function isToday(\DateTimeImmutable $date) {
|
||||
return $date->format('dmY') == date('dmY');
|
||||
}
|
||||
public static function isToday(DateTimeImmutable $date) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
return $date->format('mY') == date('mY');
|
||||
}
|
||||
}
|
||||
|
@ -1,83 +1,84 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
use \DateTimeImmutable;
|
||||
use \PDO;
|
||||
|
||||
class DBActivity implements Activity {
|
||||
private $pdo;
|
||||
|
||||
public function __construct(\PDO $pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
public function __construct(PDO $pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function getAllEvents() {
|
||||
$query = 'SELECT * FROM events ORDER BY id DESC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
public function getAllEvents() {
|
||||
$query = 'SELECT * FROM events ORDER BY id DESC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
$events = [];
|
||||
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']),
|
||||
$dbEvent['organiser'],
|
||||
$dbEvent['location'],
|
||||
$dbEvent['description']
|
||||
);
|
||||
$events[] = $event;
|
||||
}
|
||||
$events = [];
|
||||
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']),
|
||||
$dbEvent['organiser'],
|
||||
$dbEvent['location'],
|
||||
$dbEvent['description']
|
||||
);
|
||||
$events[] = $event;
|
||||
}
|
||||
|
||||
return $events;
|
||||
}
|
||||
return $events;
|
||||
}
|
||||
|
||||
public function getEventByID($id) {
|
||||
$query = 'SELECT * FROM events WHERE id=:id LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
public function getEventByID($id) {
|
||||
$query = 'SELECT * FROM events WHERE id=:id LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
$dbEvent = $statement->fetch();
|
||||
$dbEvent = $statement->fetch();
|
||||
$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']),
|
||||
$dbEvent['organiser'],
|
||||
$dbEvent['location'],
|
||||
$dbEvent['description']
|
||||
);
|
||||
|
||||
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']),
|
||||
$dbEvent['organiser'],
|
||||
$dbEvent['location'],
|
||||
$dbEvent['description']
|
||||
);
|
||||
}
|
||||
return $event;
|
||||
}
|
||||
|
||||
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 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) {
|
||||
$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);
|
||||
}
|
||||
|
||||
return $this->retrieve($date, $query);
|
||||
}
|
||||
private function retrieve($date, $query) {
|
||||
$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(
|
||||
$result['id'],
|
||||
$result['name'],
|
||||
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']
|
||||
);
|
||||
return $ev;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function retrieve($date, $query) {
|
||||
$stmt = $this->pdo->prepare($query);
|
||||
$stmt->execute(['date' => $date->format('Y-m-d H:i:s')]);
|
||||
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']),
|
||||
$result['organiser'],
|
||||
$result['location'],
|
||||
$result['description']
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,76 +1,74 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
class Door {
|
||||
private $pdo;
|
||||
use \PDO;
|
||||
|
||||
public function __construct(\PDO $pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
class Door{
|
||||
private $pdo;
|
||||
|
||||
public function getAll() {
|
||||
$query = 'SELECT time, open FROM door ORDER BY time DESC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
public function __construct(PDO $pdo){
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
$doorEvents = [];
|
||||
foreach ($statement->fetchAll() as $row) {
|
||||
$doorEvents[] = [
|
||||
'time' => (int) $row['time'],
|
||||
'open' => (bool) $row['open'],
|
||||
];
|
||||
}
|
||||
public function getAll() {
|
||||
$query = 'SELECT time, open FROM door ORDER BY time DESC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
return $doorEvents;
|
||||
}
|
||||
$doorEvents = [];
|
||||
foreach($statement->fetchAll() as $row){
|
||||
$doorEvents[] = [
|
||||
'time' => (int)$row['time'],
|
||||
'open' => (bool)$row['open']
|
||||
];
|
||||
}
|
||||
|
||||
public function getEntriesAfter($startTime) {
|
||||
$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->execute();
|
||||
return $doorEvents;
|
||||
}
|
||||
|
||||
$doorEvents = [];
|
||||
foreach ($statement->fetchAll() as $row) {
|
||||
$doorEvents[] = [
|
||||
'time' => (int) $row['time'],
|
||||
'open' => (bool) $row['open'],
|
||||
];
|
||||
}
|
||||
public function getEntriesAfter($startTime) {
|
||||
$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->execute();
|
||||
|
||||
return $doorEvents;
|
||||
}
|
||||
$doorEvents = [];
|
||||
foreach($statement->fetchAll() as $row){
|
||||
$doorEvents[] = [
|
||||
'time' => (int)$row['time'],
|
||||
'open' => (bool)$row['open']
|
||||
];
|
||||
}
|
||||
|
||||
public function getCurrent() {
|
||||
$query = 'SELECT time, open FROM door ORDER BY time DESC LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
$row = $statement->fetch();
|
||||
return $doorEvents;
|
||||
}
|
||||
|
||||
return [
|
||||
'time' => (int) $row['time'],
|
||||
'open' => (bool) $row['open'],
|
||||
];
|
||||
}
|
||||
public function getCurrent() {
|
||||
$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']
|
||||
];
|
||||
}
|
||||
|
||||
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->execute();
|
||||
}
|
||||
private function removeOld() {
|
||||
$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->execute();
|
||||
}
|
||||
|
||||
public function createEvent($time, $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->execute();
|
||||
public function createEvent($time, $open) {
|
||||
$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->execute();
|
||||
|
||||
$this->removeOld();
|
||||
}
|
||||
$this->removeOld();
|
||||
}
|
||||
}
|
||||
|
@ -1,55 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
<?php //declare(strict_types=1);
|
||||
namespace pvv\side;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
|
||||
abstract class Event {
|
||||
private $start;
|
||||
|
||||
public function __construct(\DateTimeImmutable $start) {
|
||||
$this->start = $start;
|
||||
}
|
||||
private $start;
|
||||
|
||||
public function getStart() {
|
||||
return $this->start;
|
||||
}
|
||||
public function __construct(DateTimeImmutable $start) {
|
||||
$this->start = $start;
|
||||
}
|
||||
|
||||
public function getRelativeDate() {
|
||||
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::isNextWeek($this->getStart())) {
|
||||
return 'neste uke';
|
||||
}
|
||||
if (Agenda::isThisMonth($this->getStart())) {
|
||||
return 'denne måneden';
|
||||
}
|
||||
public function getStart() {
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
return $this->getStart()->format('j. F');
|
||||
}
|
||||
public function getRelativeDate() {
|
||||
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 strftime('%A', $this->getStart()->getTimestamp());
|
||||
}
|
||||
if (Agenda::isNextWeek($this->getStart())) {
|
||||
return 'neste uke';
|
||||
}
|
||||
if (Agenda::isThisMonth($this->getStart())) {
|
||||
return 'denne måneden';
|
||||
}
|
||||
return trim(strftime('%e. %B', $this->getStart()->getTimestamp()));
|
||||
}
|
||||
|
||||
abstract public function getStop(); /* : DateTimeImmutable */
|
||||
public abstract function getStop(); /* : DateTimeImmutable */
|
||||
|
||||
abstract public function getName();
|
||||
public abstract function getName();
|
||||
|
||||
abstract public function getLocation();
|
||||
public abstract function getLocation();
|
||||
|
||||
abstract public function getOrganiser();
|
||||
public abstract function getOrganiser();
|
||||
|
||||
abstract public function getURL(); /* : string */
|
||||
public abstract function getURL(); /* : string */
|
||||
|
||||
abstract public function getImageURL(); /* : string */
|
||||
public abstract function getImageURL(); /* : string */
|
||||
|
||||
abstract public function getDescription(); /* : string */
|
||||
public abstract function getDescription(); /* : string */
|
||||
|
||||
abstract public function getColor(); /* : string */
|
||||
public abstract function getColor(); /* : string */
|
||||
}
|
||||
|
@ -1,47 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
class MOTD {
|
||||
private $pdo;
|
||||
use \PDO;
|
||||
|
||||
public function __construct($pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
class MOTD{
|
||||
private $pdo;
|
||||
|
||||
public function setMOTD($title, $content): void {
|
||||
if (\is_array($content)) {
|
||||
$content = implode('_', $content);
|
||||
}
|
||||
$query = 'INSERT INTO motd(title, content) VALUES (:title, :content);';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
public function __construct($pdo){
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
$statement->bindParam(':title', $title, \PDO::PARAM_STR);
|
||||
$statement->bindParam(':content', $content, \PDO::PARAM_STR);
|
||||
public function setMOTD($title, $content) {
|
||||
if (is_array($content)) {
|
||||
$content = implode("_", $content);
|
||||
}
|
||||
$query = 'INSERT INTO motd(title, content) VALUES (:title, :content);';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
|
||||
$statement->execute();
|
||||
}
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':content', $content, PDO::PARAM_STR);
|
||||
|
||||
public function getMOTD() {
|
||||
$query = 'SELECT motd.title, motd.content FROM motd ORDER BY motd.id DESC LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
$statement->execute();
|
||||
}
|
||||
|
||||
public function getMOTD() {
|
||||
$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();
|
||||
$data = $statement->fetch();
|
||||
$motd = array("title" => $data[0], "content" => explode("\n", $data[1]));
|
||||
|
||||
return ['title' => $data[0], 'content' => explode("\n", $data[1])];
|
||||
}
|
||||
return $motd;
|
||||
}
|
||||
|
||||
public function getMOTD_history($limit = 5) {
|
||||
$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->execute();
|
||||
|
||||
public function getMOTD_history($limit = 5) {
|
||||
$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->execute();
|
||||
$data = $statement->fetch();
|
||||
$motd = array("title" => $data[0], "content" => explode("\n", $data[1]));
|
||||
|
||||
$data = $statement->fetch();
|
||||
|
||||
return ['title' => $data[0], 'content' => explode("\n", $data[1])];
|
||||
}
|
||||
return $motd;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,35 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
class Project {
|
||||
private $id;
|
||||
private $name;
|
||||
private $descr;
|
||||
private $active;
|
||||
class Project{
|
||||
private $id, $name, $descr, $active;
|
||||
|
||||
public function __construct($id, $name, $descr, $active) {
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->descr = explode("\n", $descr);
|
||||
$this->active = $active;
|
||||
}
|
||||
public function __construct($id, $name, $descr, $active){
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->descr = explode("\n", $descr);
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
public function getID() {
|
||||
return $this->id;
|
||||
}
|
||||
public function getID(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return $this->descr;
|
||||
}
|
||||
public function getDescription(){
|
||||
return $this->descr;
|
||||
}
|
||||
|
||||
public function getActive() {
|
||||
return $this->active;
|
||||
}
|
||||
}
|
||||
public function getActive(){
|
||||
return $this->active;
|
||||
}
|
||||
}
|
@ -1,120 +1,121 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
class ProjectManager {
|
||||
private $pdo;
|
||||
use \PDO;
|
||||
|
||||
public function __construct(\PDO $pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
class ProjectManager{
|
||||
private $pdo;
|
||||
|
||||
public function getAll() {
|
||||
$query = 'SELECT * FROM projects ORDER BY id ASC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
public function __construct(PDO $pdo){
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
$projects = [];
|
||||
foreach ($statement->fetchAll() as $dbProj) {
|
||||
$project = new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active']
|
||||
);
|
||||
$projects[] = $project;
|
||||
}
|
||||
public function getAll() {
|
||||
$query = 'SELECT * FROM projects ORDER BY id ASC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
return $projects;
|
||||
}
|
||||
$projects = [];
|
||||
foreach($statement->fetchAll() as $dbProj){
|
||||
$project = new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active']
|
||||
);
|
||||
$projects[] = $project;
|
||||
}
|
||||
|
||||
public function getByID($id) {
|
||||
$query = 'SELECT * FROM projects WHERE id=:id LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
return $projects;
|
||||
}
|
||||
|
||||
$dbProj = $statement->fetch();
|
||||
if (!$dbProj) {
|
||||
return false;
|
||||
}
|
||||
public function getByID($id){
|
||||
$query = 'SELECT * FROM projects WHERE id=:id LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
return new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active']
|
||||
);
|
||||
}
|
||||
$dbProj = $statement->fetch();
|
||||
if (!$dbProj) {
|
||||
return false;
|
||||
}
|
||||
$project = new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active']
|
||||
);
|
||||
|
||||
public function getByOwner($uname) {
|
||||
$query = 'SELECT projectid FROM projectmembers WHERE uname=:uname';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
return $project;
|
||||
}
|
||||
|
||||
$projectIDs = $statement->fetchAll();
|
||||
$projects = [];
|
||||
foreach ($projectIDs as $id) {
|
||||
$id = $id['projectid'];
|
||||
public function getByOwner($uname){
|
||||
$query = 'SELECT projectid FROM projectmembers WHERE uname=:uname';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$query = 'SELECT * FROM projects WHERE id=:id';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
$projectIDs = $statement->fetchAll();
|
||||
$projects = [];
|
||||
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->execute();
|
||||
|
||||
foreach($statement->fetchAll() as $dbProj){
|
||||
$project = new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active']
|
||||
);
|
||||
$projects[] = $project;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($statement->fetchAll() as $dbProj) {
|
||||
$project = new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active']
|
||||
);
|
||||
$projects[] = $project;
|
||||
}
|
||||
}
|
||||
return $projects;
|
||||
}
|
||||
|
||||
return $projects;
|
||||
}
|
||||
public function getProjectMembers($id){
|
||||
$query = 'SELECT * FROM projectmembers WHERE projectid=:id';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
public function getProjectMembers($id) {
|
||||
$query = 'SELECT * FROM projectmembers WHERE projectid=:id';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
$members = [];
|
||||
foreach($statement->fetchAll() as $dbUsr){
|
||||
$members[] = [
|
||||
'name' => $dbUsr['name'],
|
||||
'uname' => $dbUsr['uname'],
|
||||
'mail' => $dbUsr['mail'],
|
||||
'role' => $dbUsr['role'],
|
||||
'lead' => $dbUsr['lead'],
|
||||
'owner' => $dbUsr['owner']
|
||||
];
|
||||
}
|
||||
|
||||
$members = [];
|
||||
foreach ($statement->fetchAll() as $dbUsr) {
|
||||
$members[] = [
|
||||
'name' => $dbUsr['name'],
|
||||
'uname' => $dbUsr['uname'],
|
||||
'mail' => $dbUsr['mail'],
|
||||
'role' => $dbUsr['role'],
|
||||
'lead' => $dbUsr['lead'],
|
||||
'owner' => $dbUsr['owner'],
|
||||
];
|
||||
}
|
||||
return $members;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
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']
|
||||
];
|
||||
|
||||
$dbOwner = $statement->fetch();
|
||||
|
||||
return [
|
||||
'name' => $dbOwner['name'],
|
||||
'uname' => $dbOwner['uname'],
|
||||
'mail' => $dbOwner['mail'],
|
||||
'role' => $dbOwner['role'],
|
||||
'lead' => $dbOwner['lead'],
|
||||
'owner' => $dbOwner['owner'],
|
||||
];
|
||||
}
|
||||
return $owner;
|
||||
}
|
||||
}
|
||||
|
@ -1,63 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
class SimpleEvent extends Event {
|
||||
private $id;
|
||||
private $name;
|
||||
private $descr;
|
||||
private $start;
|
||||
private $end;
|
||||
private $org;
|
||||
private $loc;
|
||||
|
||||
public function __construct($id, $name, \DateTimeImmutable $start, \DateTimeImmutable $end, $org, $loc, $descr, $_isDBEvent = false) {
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->start = $start;
|
||||
$this->end = $end;
|
||||
$this->org = $org;
|
||||
$this->loc = $loc;
|
||||
$this->descr = explode("\n", $descr);
|
||||
}
|
||||
private $id, $name, $descr, $start, $end, $org, $loc;
|
||||
|
||||
public function getID() {
|
||||
return $this->id;
|
||||
}
|
||||
public function __construct($id, $name,\DateTimeImmutable $start,\DateTimeImmutable $end,$org, $loc, $descr, $isDBEvent = false){
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->start = $start;
|
||||
$this->end = $end;
|
||||
$this->org = $org;
|
||||
$this->loc = $loc;
|
||||
$this->descr = explode("\n", $descr);
|
||||
$this->isDBEvent = $isDBEvent;
|
||||
}
|
||||
|
||||
public function getStart() {
|
||||
return $this->start;
|
||||
}
|
||||
public function getID(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getStop() {
|
||||
return $this->end;
|
||||
}
|
||||
public function getStart(){
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
public function getOrganiser() {
|
||||
return $this->org;
|
||||
}
|
||||
public function getStop(){
|
||||
return $this->end;
|
||||
}
|
||||
|
||||
public function getLocation() {
|
||||
return $this->loc;
|
||||
}
|
||||
public function getOrganiser(){
|
||||
return $this->org;
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
public function getLocation(){
|
||||
return $this->loc;
|
||||
}
|
||||
|
||||
public function getURL() {
|
||||
return '/hendelser/info.php?id=' . $this->id;
|
||||
}
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getImageURL(): void {}
|
||||
public function getURL() {
|
||||
return ('/hendelser/info.php?id=' . $this->id);
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return $this->descr;
|
||||
}
|
||||
public function getImageURL() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return $this->descr;
|
||||
}
|
||||
|
||||
public function isDBEvent() {
|
||||
return $this->isDBEvent;
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#3b7";
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return '#3b7';
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
<?php //declare(strict_types=1);
|
||||
namespace pvv\side\social;
|
||||
|
||||
use pvv\side\Activity;
|
||||
use \pvv\side\Activity;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
|
||||
class AnimekveldActivity implements Activity {
|
||||
public function nextDate(\DateTimeImmutable $date) {
|
||||
if (intval($date->format('H')) > 20 || intval($date->format('H')) === 19 && intval($date->format('i')) > 30) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(19, 30, 0));
|
||||
}
|
||||
$date = $date->setTime(19, 30, 0);
|
||||
if (intval($date->format('N')) !== 5) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
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));
|
||||
$date = $date->setTime(19, 30, 0);
|
||||
if ($date->format('N') != 5)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D')));
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function prevDate(\DateTimeImmutable $date) {
|
||||
if (intval($date->format('H')) < 19 || intval($date->format('H')) === 20 && intval($date->format('i')) < 30) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(19, 30, 0));
|
||||
}
|
||||
$date = $date->setTime(19, 30, 0);
|
||||
if (intval($date->format('N')) !== 5) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
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));
|
||||
$date = $date->setTime(19, 30, 0);
|
||||
if ($date->format('N') != 5)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
||||
return $date;
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new AnimekveldEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new AnimekveldEvent($this->nextDate($date));
|
||||
}
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new AnimekveldEvent($this->prevDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new AnimekveldEvent($this->prevDate($date));
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
<?php //declare(strict_types=1);
|
||||
namespace pvv\side\social;
|
||||
|
||||
use pvv\side\Event;
|
||||
use \pvv\side\Event;
|
||||
|
||||
use \DateInterval;
|
||||
|
||||
class AnimekveldEvent extends Event {
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getName() { /* : string */
|
||||
return 'Animekveld';
|
||||
}
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getLocation() { /* : Location */
|
||||
return 'Koserommet';
|
||||
}
|
||||
public function getName() /* : string */ {
|
||||
return "Animekveld";
|
||||
}
|
||||
|
||||
public function getOrganiser() { /* : User */
|
||||
return 'Christoffer Viken';
|
||||
}
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Koserommet";
|
||||
}
|
||||
|
||||
public function getURL() { /* : string */
|
||||
return '/anime/';
|
||||
}
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "Christoffer Viken";
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
return '/sosiale/animekveld.jpg';
|
||||
}
|
||||
public function getURL() /* : string */ {
|
||||
return '/anime/';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
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!',
|
||||
'',
|
||||
'Alle kan være med på å anbefale eller veto serier.',
|
||||
'',
|
||||
];
|
||||
}
|
||||
public function getImageURL() {
|
||||
return '/sosiale/animekveld.jpg';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
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!',
|
||||
'',
|
||||
'Alle kan være med på å anbefale eller veto serier.',
|
||||
'',
|
||||
'I disse tider blir visningene i all hovedsak holdt online på vår <a href="https://discord.gg/cx4aXU7">Discord server</a>'
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#35a";
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return '#35a';
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
<?php //declare(strict_types=1);
|
||||
namespace pvv\side\social;
|
||||
|
||||
use pvv\side\Activity;
|
||||
use \pvv\side\Activity;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
|
||||
class BrettspillActivity implements Activity {
|
||||
public function nextDate(\DateTimeImmutable $date) {
|
||||
if (intval($date->format('H')) > 17 || intval($date->format('H')) === 16 && intval($date->format('i')) > 15) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(16, 15, 0));
|
||||
}
|
||||
$date = $date->setTime(16, 15, 0);
|
||||
if (intval($date->format('N')) !== 7) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
if (intval($date->format('W')) % 2 - 1) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
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));
|
||||
$date = $date->setTime(19, 30, 0);
|
||||
if ($date->format('N') != 4)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D')));
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function prevDate(\DateTimeImmutable $date) {
|
||||
if (intval($date->format('H')) < 16 || intval($date->format('H')) === 17 && intval($date->format('i')) < 15) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(16, 15, 0));
|
||||
}
|
||||
$date = $date->setTime(16, 15, 0);
|
||||
if (intval($date->format('N')) !== 7) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
if (intval($date->format('W')) % 2 - 1) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||
}
|
||||
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));
|
||||
$date = $date->setTime(19, 30, 0);
|
||||
if ($date->format('N') != 4)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
||||
return $date;
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new BrettspillEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new BrettspillEvent($this->nextDate($date));
|
||||
}
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new BrettspillEvent($this->prevDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new BrettspillEvent($this->prevDate($date));
|
||||
}
|
||||
}
|
||||
|
@ -1,64 +1,65 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
<?php //declare(strict_types=1);
|
||||
namespace pvv\side\social;
|
||||
|
||||
use pvv\side\Event;
|
||||
use \pvv\side\Event;
|
||||
|
||||
use \DateInterval;
|
||||
|
||||
class BrettspillEvent extends Event {
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getName() { /* : string */
|
||||
return 'Brettspillkveld';
|
||||
}
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getLocation() { /* : Location */
|
||||
return 'Programvareverkstedet';
|
||||
}
|
||||
public function getName() /* : string */ {
|
||||
return "Brettspillkveld";
|
||||
}
|
||||
|
||||
public function getOrganiser() { /* : User */
|
||||
return 'Programvareverkstedet';
|
||||
}
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Koserommet";
|
||||
}
|
||||
|
||||
public function getURL() { /* : string */
|
||||
return '/brettspill/';
|
||||
}
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "Robert Maikher";
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
return '/sosiale/brettspill.jpg';
|
||||
}
|
||||
public function getURL() /* : string */ {
|
||||
return '/brettspill/';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
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!',
|
||||
'',
|
||||
'## Vår samling',
|
||||
'',
|
||||
'* Dominion\*',
|
||||
'* Three cheers for master',
|
||||
'* Avalon',
|
||||
'* Hanabi',
|
||||
'* Cards aginst humanity\*',
|
||||
'* Citadels',
|
||||
'* Munchkin\*\*',
|
||||
'* Exploding kittens\*\*',
|
||||
'* Aye dark overlord',
|
||||
'* Settlers of catan\*',
|
||||
'* Risk\*\*',
|
||||
'* og mange flere...',
|
||||
'',
|
||||
'\* Vi har flere ekspansjoner til spillet',
|
||||
'',
|
||||
'\*\* Vi har flere varianter av spillet',
|
||||
];
|
||||
}
|
||||
public function getImageURL() {
|
||||
return '/sosiale/brettspill.jpg';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
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!',
|
||||
'',
|
||||
'## Vår samling',
|
||||
'',
|
||||
'* Dominion\*',
|
||||
'* Three cheers for master',
|
||||
'* Avalon',
|
||||
'* Hanabi',
|
||||
'* Cards aginst humanity\*',
|
||||
'* Citadels',
|
||||
'* Munchkin\*\*',
|
||||
'* Exploding kittens\*\*',
|
||||
'* Aye dark overlord',
|
||||
'* Settlers of catan\*',
|
||||
'* Risk\*\*',
|
||||
'* og mange flere...',
|
||||
'',
|
||||
'\* Vi har flere ekspansjoner til spillet',
|
||||
'',
|
||||
'\*\* Vi har flere varianter av spillet',
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#000";
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return '#000';
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
<?php //declare(strict_types=1);
|
||||
namespace pvv\side\social;
|
||||
|
||||
use pvv\side\Activity;
|
||||
use \pvv\side\Activity;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
|
||||
class DriftkveldActivity implements Activity {
|
||||
public function nextDate(\DateTimeImmutable $date) {
|
||||
if (intval($date->format('H')) > 18 || intval($date->format('H')) === 17 && intval($date->format('i')) > 30) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
}
|
||||
$date = $date->setTime(18, 15, 0);
|
||||
if (intval($date->format('N')) !== 6) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
if (intval($date->format('W')) % 2 - 1) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
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));
|
||||
$date = $date->setTime(18, 15, 0);
|
||||
if ($date->format('N') != 2)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D')));
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function prevDate(\DateTimeImmutable $date) {
|
||||
if (intval($date->format('H')) < 17 || intval($date->format('H')) === 18 && intval($date->format('i')) < 30) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
}
|
||||
$date = $date->setTime(18, 15, 0);
|
||||
if (intval($date->format('N')) !== 6) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
if (intval($date->format('W')) % 2 - 1) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||
}
|
||||
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));
|
||||
$date = $date->setTime(18, 15, 0);
|
||||
if ($date->format('N') != 2)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
||||
return $date;
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new DriftkveldEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new DriftkveldEvent($this->nextDate($date));
|
||||
}
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new DriftkveldEvent($this->prevDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new DriftkveldEvent($this->prevDate($date));
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
<?php //declare(strict_types=1);
|
||||
namespace pvv\side\social;
|
||||
|
||||
use pvv\side\Event;
|
||||
use \pvv\side\Event;
|
||||
|
||||
use \DateInterval;
|
||||
|
||||
class DriftkveldEvent extends Event {
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getName() { /* : string */
|
||||
return 'Driftkveld';
|
||||
}
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getLocation() { /* : Location */
|
||||
return 'Terminalrommet / Discord / IRC';
|
||||
}
|
||||
public function getName() /* : string */ {
|
||||
return "Driftkveld";
|
||||
}
|
||||
|
||||
public function getOrganiser() { /* : User */
|
||||
return 'Torstein Nordgård-Hansen';
|
||||
}
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Terminalrommet / Discord / IRC";
|
||||
}
|
||||
|
||||
public function getURL() { /* : string */
|
||||
return '/driftkveld/';
|
||||
}
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "Torstein Nordgård-Hansen";
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
return '/sosiale/drift.jpg';
|
||||
}
|
||||
public function getURL() /* : string */ {
|
||||
return '/drift/';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
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!',
|
||||
];
|
||||
}
|
||||
public function getImageURL() {
|
||||
return '/sosiale/drift.jpg';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return [
|
||||
'Vil du drifte?',
|
||||
'Vil du være kul kis TM?',
|
||||
'Kom på driftkveld!',
|
||||
'',
|
||||
'Vi møtes en gang i uka for å ta unna driftarbeid og drikke kaffe.',
|
||||
'Alle PVVere er velkommene, enten de er erfarne driftere eller helt utenforstående!'
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#35a";
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return '#35a';
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use pvv\side\Activity;
|
||||
|
||||
class HackekveldActivity implements Activity {
|
||||
public function nextDate(\DateTimeImmutable $date) {
|
||||
if (intval($date->format('H')) > 18 || intval($date->format('H')) === 17 && intval($date->format('i')) > 30) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
}
|
||||
$date = $date->setTime(16, 15, 0);
|
||||
if (intval($date->format('N')) !== 6) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
if (intval($date->format('W')) % 2) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function prevDate(\DateTimeImmutable $date) {
|
||||
if (intval($date->format('H')) < 17 || intval($date->format('H')) === 18 && intval($date->format('i')) < 30) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
}
|
||||
$date = $date->setTime(18, 15, 0);
|
||||
if (intval($date->format('N')) !== 6) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
if (intval($date->format('W')) % 2) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new HackekveldEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new HackekveldEvent($this->prevDate($date));
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use pvv\side\Event;
|
||||
|
||||
class HackekveldEvent extends Event {
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getName() { /* : string */
|
||||
return 'Hackekveld';
|
||||
}
|
||||
|
||||
public function getLocation() { /* : Location */
|
||||
return 'Terminalrommet / Discord / IRC';
|
||||
}
|
||||
|
||||
public function getOrganiser() { /* : User */
|
||||
return 'PVV';
|
||||
}
|
||||
|
||||
public function getURL() { /* : string */
|
||||
return '#';
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
return '/pvv-logo.png';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
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.',
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return '#35a';
|
||||
}
|
||||
}
|
@ -1,47 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
<?php //declare(strict_types=1);
|
||||
namespace pvv\side\social;
|
||||
|
||||
use pvv\side\Activity;
|
||||
use \pvv\side\Activity;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
|
||||
class NerdepitsaActivity implements Activity {
|
||||
public function nextDate(\DateTimeImmutable $date) {
|
||||
if (intval($date->format('H')) > 19) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
||||
}
|
||||
$date = $date->setTime(19, 0, 0);
|
||||
if (intval($date->format('N')) !== 5) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
if (intval($date->format('W')) % 2) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
public function nextDate(DateTimeImmutable $date) {
|
||||
if ($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')));
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function prevDate(\DateTimeImmutable $date) {
|
||||
if (intval($date->format('H')) < 19) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
||||
}
|
||||
$date = $date->setTime(19, 0, 0);
|
||||
if (intval($date->format('N')) !== 5) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
if (intval($date->format('W')) % 2) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||
}
|
||||
public function prevDate(DateTimeImmutable $date) {
|
||||
if ($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')));
|
||||
return $date;
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new NerdepitsaEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new NerdepitsaEvent($this->nextDate($date));
|
||||
}
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new NerdepitsaEvent($this->prevDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new NerdepitsaEvent($this->prevDate($date));
|
||||
}
|
||||
}
|
||||
|
@ -1,49 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
<?php //declare(strict_types=1);
|
||||
namespace pvv\side\social;
|
||||
|
||||
use pvv\side\Event;
|
||||
use \pvv\side\Event;
|
||||
|
||||
use \DateInterval;
|
||||
|
||||
class NerdepitsaEvent extends Event {
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new \DateInterval('PT2H1800S'));
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return 'Nerdepitsa';
|
||||
}
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new DateInterval('PT2H1800S'));
|
||||
}
|
||||
|
||||
public function getLocation() { /* : Location */
|
||||
return 'Peppes Kjøpmansgata';
|
||||
}
|
||||
public function getName() {
|
||||
return "Nerdepitsa";
|
||||
}
|
||||
|
||||
public function getOrganiser() { /* : User */
|
||||
return 'Anders Christensen';
|
||||
}
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Peppes Kjøpmansgata";
|
||||
}
|
||||
|
||||
public function getURL() { /* : string */
|
||||
return '/nerdepitsa/';
|
||||
}
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "Anders Christensen";
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
return '/sosiale/nerdepitsa.jpg';
|
||||
}
|
||||
public function getURL() /* : string */ {
|
||||
return '/nerdepitsa/';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
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!',
|
||||
'',
|
||||
'Vi er en trivelig gjeng hvis der fellestrekk er en viss interesse for data, samt har eller har hatt en tilknytning til studentmiljøet ved NTNU. For å treffe andre som også faller inn under disse kriteriene treffes vi over pizza på Peppes annenhver fredag. (Definisjon: En fredag er annenhver dersom den ligger i en partallsuke). Vi har reservasjon under navnet Christensen med storkunderabatt.',
|
||||
'',
|
||||
'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!',
|
||||
];
|
||||
}
|
||||
public function getImageURL() {
|
||||
return '/sosiale/nerdepitsa.jpg';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
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!',
|
||||
'',
|
||||
'Vi er en trivelig gjeng hvis der fellestrekk er en viss interesse for data, samt har eller har hatt en tilknytning til studentmiljøet ved NTNU. For å treffe andre som også faller inn under disse kriteriene treffes vi over pizza på Peppes annenhver fredag. (Definisjon: En fredag er annenhver dersom den ligger i en partallsuke). Vi har reservasjon under navnet Christensen med storkunderabatt.',
|
||||
'',
|
||||
'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!'
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#c35";
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return '#c35';
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
<?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(__DIR__, 3), '', '_autoload.php']);
|
||||
require implode(DIRECTORY_SEPARATOR, [dirname(dirname(dirname(__DIR__))), '', '_autoload.php']);
|
||||
|
||||
$c = new AnimekveldActivity();
|
||||
exit($c->nextDate(new \DateTimeImmutable())->format(\DATE_RFC2822));
|
||||
$c = new AnimekveldActivity;
|
||||
die($c->nextDate(new \DateTimeImmutable)->format(DATE_RFC2822));
|
||||
|
@ -1,12 +1,9 @@
|
||||
<?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(__DIR__, 3), '', '_autoload.php']);
|
||||
require implode(DIRECTORY_SEPARATOR, [dirname(dirname(dirname(__DIR__))), '', '_autoload.php']);
|
||||
|
||||
$c = new NerdepitsaActivity();
|
||||
exit($c->prevDate(new \DateTimeImmutable())->format(\DATE_RFC2822));
|
||||
$c = new NerdepitsaActivity;
|
||||
die($c->prevDate(new \DateTimeImmutable)->format(DATE_RFC2822));
|
||||
|
@ -1,31 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<clientConfig version="1.1">
|
||||
<emailProvider id="pvv.ntnu.no">
|
||||
<domain>pvv.ntnu.no</domain>
|
||||
<domain>pvv.org</domain>
|
||||
|
||||
<displayName>Programvareverkstedet</displayName>
|
||||
|
||||
<incomingServer type="imap">
|
||||
<hostname>imap.pvv.ntnu.no</hostname>
|
||||
<port>993</port>
|
||||
<socketType>SSL</socketType>
|
||||
<username>%EMAILLOCALPART%</username>
|
||||
<authentication>password-cleartext</authentication>
|
||||
</incomingServer>
|
||||
|
||||
<outgoingServer type="smtp">
|
||||
<hostname>smtp.pvv.ntnu.no</hostname>
|
||||
<port>587</port>
|
||||
<socketType>STARTTLS</socketType>
|
||||
<username>%EMAILLOCALPART%</username>
|
||||
<authentication>password-cleartext</authentication>
|
||||
<useGlobalPreferredServer>true</useGlobalPreferredServer>
|
||||
</outgoingServer>
|
||||
|
||||
<documentation url="https://www.pvv.ntnu.no/pvv/Drift/Mail/IMAP_POP3">
|
||||
<descr lang="en">Setup programvareverkstedet email user with IMAP or POP3</descr>
|
||||
<descr lang="nb">Sett opp programvareverkstedet email bruker med IMAP eller POP3</descr>
|
||||
</documentation>
|
||||
</emailProvider>
|
||||
</clientConfig>
|
@ -1,19 +1,19 @@
|
||||
<?php
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$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')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit;
|
||||
if(!$userManager->hasGroup($uname, 'aktiviteter')){
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
}
|
||||
|
||||
$eventID = $_GET['id'];
|
||||
|
@ -1,60 +1,61 @@
|
||||
<?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';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$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')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit;
|
||||
if(!$userManager->hasGroup($uname, 'aktiviteter')){
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
}
|
||||
|
||||
$customActivity = new pvv\side\DBActivity($pdo);
|
||||
$customActivity = new \pvv\side\DBActivity($pdo);
|
||||
|
||||
$new = 0;
|
||||
if (isset($_GET['new'])) {
|
||||
$new = $_GET['new'];
|
||||
if(isset($_GET['new'])){
|
||||
$new = $_GET['new'];
|
||||
}
|
||||
|
||||
$eventID = 0;
|
||||
if (isset($_GET['id'])) {
|
||||
$eventID = $_GET['id'];
|
||||
} elseif ($new == 0) {
|
||||
echo "\nID not set";
|
||||
exit;
|
||||
if(isset($_GET['id'])){
|
||||
$eventID = $_GET['id'];
|
||||
}else if($new == 0){
|
||||
echo "\nID not set";
|
||||
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");
|
||||
|
||||
|
||||
if ($new == 0) {
|
||||
$event = $customActivity->getEventByID($eventID);
|
||||
} else {
|
||||
$event = new pvv\side\SimpleEvent(
|
||||
0,
|
||||
'',
|
||||
$today,
|
||||
$inTwoHours,
|
||||
'',
|
||||
'',
|
||||
''
|
||||
);
|
||||
$event;
|
||||
if($new == 0){
|
||||
$event = $customActivity->getEventByID($eventID);
|
||||
}
|
||||
else {
|
||||
$event = new \pvv\side\SimpleEvent(
|
||||
0,
|
||||
'',
|
||||
$today,
|
||||
$inTwoHours,
|
||||
'',
|
||||
'',
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -85,49 +86,49 @@ if ($new == 0) {
|
||||
<h2>Aktivietsadministrasjon</h2>
|
||||
<hr class="ruler">
|
||||
|
||||
<h2><?php echo $new == 1 ? 'Ny hendelse' : 'Rediger hendelse'; ?></h2>
|
||||
<h2><?= ($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="<?php echo $event->getName(); ?>" class="boxinput" required placeholder="En kul hendelse"><br>
|
||||
|
||||
<input type="text" name="title" value="<?= $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="<?php echo $event->getOrganiser(); ?>" class="boxinput" required placeholder="<?php echo $name; ?>"><br>
|
||||
<input type="text" name="organiser" value="<?= $event->getOrganiser() ?>" class="boxinput" required placeholder="<?= $name ?>"><br>
|
||||
</div>
|
||||
<div class="gridr noborder">
|
||||
<p class="subtitle">Sted</p>
|
||||
<input type="text" name="location" value="<?php echo $event->getLocation(); ?>" class="boxinput" required placeholder="Terminalrommet"><br>
|
||||
<input type="text" name="location" value="<?= $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><?php echo implode("\n", $event->getDescription()); ?></textarea>
|
||||
|
||||
|
||||
<textarea name="desc" rows="8" class="boxinput" placeholder="Beskrivese" required><?= implode($event->getDescription(), "\n"); ?></textarea>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<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="<?php echo $event->getStart()->format('Y-m'); ?>"><br>
|
||||
<input name="start_mon" type="month" class="boxinput" required value="<?= $event->getStart()->format('Y-m') ?>"><br>
|
||||
<i>Dag:</i><br>
|
||||
<input name="start_day" type="number" min="1" max="31" required class="boxinput" value="<?php echo $event->getStart()->format('d'); ?>"><br>
|
||||
<input name="start_day" type="number" min="1" max="31" required class="boxinput" value="<?= $event->getStart()->format('d') ?>"><br>
|
||||
<i>Klokkeslett:</i><br>
|
||||
<input name="start_time" type="time" class="boxinput" required value="<?php echo $event->getStart()->format('H:i:s'); ?>"><br>
|
||||
<input name="start_time" type="time" class="boxinput" required value="<?= $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="<?php echo $diff->h; ?>"><br>
|
||||
<input name="lasts_hours" type="number" min="0" class="boxinput" required value="<?= $diff->h ?>"><br>
|
||||
<i>Minutter:</i><br>
|
||||
<input name="lasts_minutes" type="number" min="0" max="59" class="boxinput" required value="<?php echo $diff->i; ?>"><br>
|
||||
|
||||
<input name="lasts_minutes" type="number" min="0" max="59" class="boxinput" required value="<?= $diff->i ?>"><br>
|
||||
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="id" value="<?php echo $event->getID(); ?>" />
|
||||
<input type="hidden" name="id" value="<?= $event->getID() ?>" />
|
||||
|
||||
<div class="allgrids" style="margin-top: 2em;">
|
||||
<hr class="ruler">
|
||||
@ -135,7 +136,7 @@ if ($new == 0) {
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
</main>
|
||||
|
@ -1,47 +1,49 @@
|
||||
<?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';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$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')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit;
|
||||
if(!$userManager->hasGroup($uname, 'aktiviteter')){
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
}
|
||||
|
||||
$customActivity = new pvv\side\DBActivity($pdo);
|
||||
$customActivity = new \pvv\side\DBActivity($pdo);
|
||||
$events = $customActivity->getAllEvents();
|
||||
|
||||
$page = 1;
|
||||
if (isset($_GET['page'])) {
|
||||
$page = $_GET['page'];
|
||||
if(isset($_GET['page'])){
|
||||
$page = $_GET['page'];
|
||||
}
|
||||
|
||||
$filterTitle = '';
|
||||
if (isset($_GET['title'])) {
|
||||
$filterTitle = $_GET['title'];
|
||||
if(isset($_GET['title'])){
|
||||
$filterTitle = $_GET['title'];
|
||||
}
|
||||
|
||||
$filterOrganiser = '';
|
||||
if (isset($_GET['organiser'])) {
|
||||
$filterOrganiser = $_GET['organiser'];
|
||||
if(isset($_GET['organiser'])){
|
||||
$filterOrganiser = $_GET['organiser'];
|
||||
}
|
||||
|
||||
// filter
|
||||
$events = array_values(array_filter(
|
||||
$events,
|
||||
static fn($event) => (preg_match('/.*' . $filterTitle . '.*/i', $event->getName()) && preg_match('/.*' . $filterOrganiser . '.*/i', $event->getOrganiser()))
|
||||
$events,
|
||||
function($event) use ($filterTitle, $filterOrganiser){
|
||||
return (preg_match('/.*'.$filterTitle.'.*/i', $event->getName()) and preg_match('/.*'.$filterOrganiser.'.*/i', $event->getOrganiser()));
|
||||
}
|
||||
));
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@ -60,7 +62,7 @@ $events = array_values(array_filter(
|
||||
<header>Aktivitets­administrasjons­verk­stedet</header>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
<nav>
|
||||
<?php echo navbar(2, 'admin'); ?>
|
||||
<?php echo loginbar(null, $pdo); ?>
|
||||
@ -77,53 +79,53 @@ $events = array_values(array_filter(
|
||||
|
||||
<ul class="event-list">
|
||||
<?php
|
||||
$counter = 0;
|
||||
$pageLimit = 10;
|
||||
$counter = 0;
|
||||
$pageLimit = 10;
|
||||
|
||||
for ($i = ($pageLimit * ($page - 1)); $i < count($events); ++$i) {
|
||||
if ($counter == $pageLimit) {
|
||||
break;
|
||||
}
|
||||
for($i = ($pageLimit * ($page - 1)); $i < count($events) ;$i++){
|
||||
if($counter == $pageLimit){
|
||||
break;
|
||||
}
|
||||
|
||||
$event = $events[$i];
|
||||
$eventID = $event->getID();
|
||||
?>
|
||||
$event = $events[$i];
|
||||
$eventID = $event->getID();
|
||||
?>
|
||||
|
||||
<li>
|
||||
<div class="event admin">
|
||||
<div class="event-info">
|
||||
<h3 class="no-chin"><?php echo $event->getName() . ' (ID: ' . $eventID . ')'; ?></h3>
|
||||
<h3 class="no-chin"><?= $event->getName() . " (ID: " . $eventID . ")"; ?></h3>
|
||||
<p class="subnote">
|
||||
<?php echo $event->getStart()->format('(Y-m-d H:i:s)') . ' - ' . $event->getStop()->format('(Y-m-d H:i:s)'); ?>
|
||||
<?= $event->getStart()->format("(Y-m-d H:i:s)") . " - " . $event->getStop()->format("(Y-m-d H:i:s)"); ?>
|
||||
</p>
|
||||
<?php
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $event->getDescription()));
|
||||
?>
|
||||
$Parsedown = new \Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $event->getDescription()));
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="event-actions">
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php
|
||||
++$counter;
|
||||
}
|
||||
?>
|
||||
$counter++;
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
if ($page != 1) {
|
||||
echo '<a class="btn float-left" href="?page=' . ($page - 1) . '&title=' . urlencode($filterTitle) . '&organiser=' . urlencode($filterOrganiser) . '">Forrige side</a>';
|
||||
}
|
||||
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) && (($pageLimit * $page) < count($events))) {
|
||||
echo '<a class="btn float-right" href="?page=' . ($page + 1) . '&title=' . urlencode($filterTitle) . '&organiser=' . urlencode($filterOrganiser) . '">Neste side</a>';
|
||||
}
|
||||
?>
|
||||
if(($counter == $pageLimit) and (($pageLimit * $page) < count($events))){
|
||||
echo '<a class="btn float-right" href="?page=' . ($page + 1) . '&title=' . urlencode($filterTitle) . '&organiser=' . urlencode($filterOrganiser) . '">Neste side</a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="gridr">
|
||||
@ -132,9 +134,9 @@ $events = array_values(array_filter(
|
||||
<h2>Filter</h2>
|
||||
<form action="." method="get">
|
||||
<p class="no-chin">Navn</p>
|
||||
<?php echo '<input type="text" name="title" class="boxinput" value="' . $filterTitle . '">'; ?><br>
|
||||
<?= '<input type="text" name="title" class="boxinput" value="' . $filterTitle . '">' ?><br>
|
||||
<p class="no-chin">Organisator</p>
|
||||
<?php echo '<input type="text" name="organiser" class="boxinput" value="' . $filterOrganiser . '">'; ?><br>
|
||||
<?= '<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);
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$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')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit;
|
||||
if(!$userManager->hasGroup($uname, 'aktiviteter')){
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
}
|
||||
|
||||
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;
|
||||
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']))) {
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$id = 0;
|
||||
if (isset($_POST['id'])) {
|
||||
$id = $_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 (count(explode(':', $date_part_start_time)) == 2) {
|
||||
$start .= ':00';
|
||||
$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 = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $start);
|
||||
@ -64,32 +64,32 @@ $start = $start_date->format('Y-m-d H:i:s');
|
||||
$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;
|
||||
echo 'Invalid dates. End date must come after the start date!';
|
||||
exit();
|
||||
}
|
||||
|
||||
$statement;
|
||||
if($id == 0){
|
||||
$query = 'INSERT INTO events (name, start, stop, organiser, location, description) VALUES (:title, :start, :stop, :organiser, :loc, :desc)';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
if ($id == 0) {
|
||||
$query = 'INSERT INTO events (name, start, stop, organiser, location, description) VALUES (:title, :start, :stop, :organiser, :loc, :desc)';
|
||||
$statement = $pdo->prepare($query);
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':start', $start, PDO::PARAM_STR);
|
||||
$statement->bindParam(':stop', $stop, PDO::PARAM_STR);
|
||||
$statement->bindParam(':organiser', $organiser, PDO::PARAM_STR);
|
||||
$statement->bindParam(':loc', $location, PDO::PARAM_STR);
|
||||
}else{
|
||||
$query = 'UPDATE events SET name=:title, start=:start, stop=:stop, organiser=:organiser, location=:loc, description=:desc WHERE id=:id';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':start', $start, PDO::PARAM_STR);
|
||||
$statement->bindParam(':stop', $stop, PDO::PARAM_STR);
|
||||
$statement->bindParam(':organiser', $organiser, PDO::PARAM_STR);
|
||||
$statement->bindParam(':loc', $location, PDO::PARAM_STR);
|
||||
} else {
|
||||
$query = 'UPDATE events SET name=:title, start=:start, stop=:stop, organiser=:organiser, location=:loc, description=:desc WHERE id=:id';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':start', $start, PDO::PARAM_STR);
|
||||
$statement->bindParam(':stop', $stop, PDO::PARAM_STR);
|
||||
$statement->bindParam(':organiser', $organiser, PDO::PARAM_STR);
|
||||
$statement->bindParam(':loc', $location, PDO::PARAM_STR);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':start', $start, PDO::PARAM_STR);
|
||||
$statement->bindParam(':stop', $stop, PDO::PARAM_STR);
|
||||
$statement->bindParam(':organiser', $organiser, PDO::PARAM_STR);
|
||||
$statement->bindParam(':loc', $location, PDO::PARAM_STR);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
}
|
||||
|
||||
$statement->execute();
|
||||
|
@ -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 __DIR__ . '/../../../sql_config.php';
|
||||
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($dbDsn, $dbUser, $dbPass);
|
||||
$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)) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit;
|
||||
if(!$userManager->isAdmin($uname)){
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
}
|
||||
|
||||
$users = $userManager->getAllUserData();
|
||||
@ -59,38 +59,38 @@ $users = $userManager->getAllUserData();
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
$users_to_update = [];
|
||||
foreach ($users as $i => $data) {
|
||||
$uname = $data['name'];
|
||||
$groupFlag = $userManager->getUsergroups($uname);
|
||||
$users_to_update = array();
|
||||
foreach($users as $i => $data){
|
||||
$uname = $data['name'];
|
||||
$groupFlag = $userManager->getUsergroups($uname);
|
||||
|
||||
$users_to_update[] = $uname;
|
||||
?>
|
||||
array_push($users_to_update, $uname);
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $uname; ?></td>
|
||||
<td><?= $uname ?></td>
|
||||
<?php
|
||||
foreach ($userManager->usergroups as $name => $group) {
|
||||
echo '<td><input type="checkbox" ' . (($groupFlag & $group) ? 'checked' : '') . ' name="' . $uname . '_' . $name . '" class="usergroupcheckbox">' . $name . '</td>';
|
||||
}
|
||||
?>
|
||||
foreach($userManager->usergroups as $name => $group){
|
||||
echo '<td><input type="checkbox" ' . (($groupFlag & $group) ? 'checked' : '') . ' name="' . $uname . '_' . $name . '" class="usergroupcheckbox">' . $name . '</td>';
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
foreach ($users_to_update as $uname) {
|
||||
echo '<input type="hidden" name="user_to_update" value="' . $uname . '" />';
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
foreach($users_to_update as $uname) {
|
||||
echo '<input type="hidden" name="user_to_update" value="' . $uname . '" />';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<tr class="newuserrow">
|
||||
<td class="newuserelement"><input type="text" name="newuser" class="newuserinput"></td>
|
||||
<?php
|
||||
foreach ($userManager->usergroups as $name => $group) {
|
||||
echo '<td><input type="checkbox" name="newuser_' . $name . '" class="usergroupcheckbox">' . $name . '</td>';
|
||||
}
|
||||
?>
|
||||
foreach($userManager->usergroups as $name => $group){
|
||||
echo '<td><input type="checkbox" name="newuser_' . $name . '" class="usergroupcheckbox">' . $name . '</td>';
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="submit" class="btn" value="Lagre">
|
||||
|
@ -1,73 +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);
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$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)) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit;
|
||||
if(!$userManager->isAdmin($uname)){
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
if (isset($_POST['newuser'])) {
|
||||
$newUser = $_POST['newuser'];
|
||||
unset($_POST['newuser']);
|
||||
$newUser;
|
||||
if(isset($_POST['newuser'])){
|
||||
$newUser = $_POST['newuser'];
|
||||
unset($_POST['newuser']);
|
||||
}
|
||||
|
||||
// $updatingUsers = explode('_', $_POST['users']);
|
||||
$updatingUsers = [];
|
||||
foreach ($_POST as $key => $value) {
|
||||
if ($key === 'user_to_update') {
|
||||
$updatingUsers[] = $value;
|
||||
}
|
||||
//$updatingUsers = explode('_', $_POST['users']);
|
||||
$updatingUsers = array();
|
||||
foreach ($_POST as $key => $value) { if ($key === "user_to_update") {
|
||||
array_push($updatingUsers, $value);
|
||||
}
|
||||
}
|
||||
unset($_POST['user_to_update']);
|
||||
|
||||
// 2d array of usernames and their corresponding group flags
|
||||
$userFlags = [];
|
||||
if ($newUser) {
|
||||
$userFlags[$newUser] = 0;
|
||||
if($newUser){
|
||||
$userFlags[$newUser] = 0;
|
||||
}
|
||||
|
||||
foreach ($_POST as $namegroup => $info) {
|
||||
$data = explode('_', $namegroup);
|
||||
$group = array_pop($data);
|
||||
$uname = implode('_', $data);
|
||||
if ($uname == 'newuser') {
|
||||
if (!$newUser) {
|
||||
continue;
|
||||
}
|
||||
foreach($_POST as $namegroup => $info){
|
||||
$data = explode('_', $namegroup);
|
||||
$group = array_pop($data);
|
||||
$uname = implode("_", $data);
|
||||
if($uname == 'newuser'){
|
||||
if(!$newUser){
|
||||
continue;
|
||||
}
|
||||
|
||||
$uname = $newUser;
|
||||
}
|
||||
$uname = $newUser;
|
||||
}
|
||||
|
||||
if (!isset($userFlags[$uname])) {
|
||||
$userFlags[$uname] = 0;
|
||||
}
|
||||
if(!isset($userFlags[$uname])){
|
||||
$userFlags[$uname] = 0;
|
||||
}
|
||||
|
||||
$userFlags[$uname] = ($userFlags[$uname] | $userManager->usergroups[$group]);
|
||||
$userFlags[$uname] = ($userFlags[$uname] | $userManager->usergroups[$group]);
|
||||
}
|
||||
|
||||
foreach ($updatingUsers as $uname) {
|
||||
if (!array_key_exists($uname, $userFlags)) {
|
||||
$userFlags[$uname] = 0;
|
||||
}
|
||||
foreach($updatingUsers as $uname) {
|
||||
if(!array_key_exists($uname, $userFlags)){
|
||||
$userFlags[$uname] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($userFlags as $uname => $flag) {
|
||||
$userManager->setGroups($uname, $flag);
|
||||
foreach($userFlags as $uname => $flag){
|
||||
$userManager->setGroups($uname, $flag);
|
||||
}
|
||||
|
||||
header('Location: .');
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$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)) {
|
||||
header('Content-Type: text/plain', true, 403);
|
||||
echo "Her har du ikke lov't'å'værra!!!\r\n";
|
||||
exit;
|
||||
if(!($isAdmin | $projectGroup | $activityGroup)){
|
||||
header('Content-Type: text/plain', true, 403);
|
||||
echo "Her har du ikke lov't'å'værra!!!\r\n";
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@ -45,22 +45,22 @@ if (!($isAdmin | $projectGroup | $activityGroup)) {
|
||||
<h2>Administrasjon</h2>
|
||||
<ul class="tools">
|
||||
<?php
|
||||
if ($isAdmin | $activityGroup) {
|
||||
echo '<li><a class="btn" href="aktiviteter/?page=1">Aktiviteter/Hendelser</a></li>';
|
||||
}
|
||||
if($isAdmin | $activityGroup){
|
||||
echo '<li><a class="btn" href="aktiviteter/?page=1">Aktiviteter/Hendelser</a></li>';
|
||||
}
|
||||
|
||||
if ($isAdmin | $projectGroup) {
|
||||
echo '<li><a class="btn" href="prosjekter/">Prosjekter</a></li>';
|
||||
}
|
||||
if($isAdmin | $projectGroup){
|
||||
echo '<li><a class="btn" href="prosjekter/">Prosjekter</a></li>';
|
||||
}
|
||||
|
||||
if ($isAdmin) {
|
||||
echo '<li><a class="btn" href="motd/">Dagens melding</a></li>';
|
||||
}
|
||||
if($isAdmin) {
|
||||
echo '<li><a class="btn" href="motd/">Dagens melding</a></li>';
|
||||
}
|
||||
|
||||
if ($isAdmin) {
|
||||
echo '<li><a class="btn" href="brukere/">Brukerrettigheter</a></li>';
|
||||
}
|
||||
?>
|
||||
if($isAdmin){
|
||||
echo '<li><a class="btn" href="brukere/">Brukerrettigheter</a></li>';
|
||||
}
|
||||
?>
|
||||
<ul>
|
||||
</main>
|
||||
</body>
|
||||
|
@ -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 __DIR__ . '/../../../sql_config.php';
|
||||
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($dbDsn, $dbUser, $dbPass);
|
||||
$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)) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit;
|
||||
if(!$userManager->isAdmin($uname)){
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
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="<?php echo $motd['title']; ?>" class="boxinput" style="width:66%;"><br>
|
||||
<input type="text" name="title" value="<?= $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"><?php echo implode("\n", $motd['content']); ?></textarea>
|
||||
<textarea name="content" style="width:100%" rows="8" class="boxinput"><?= implode("\n", $motd["content"]) ?></textarea>
|
||||
|
||||
<div style="margin-top: 2em;">
|
||||
<hr class="ruler">
|
||||
|
||||
<?php echo '<input type="submit" class="btn" value="Lagre endringer"></a>'; ?>
|
||||
<?= '<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);
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$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']) || !isset($_POST['content'])) {
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
exit;
|
||||
if(!isset($_POST['title']) or !isset($_POST['content'])){
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!$userManager->isAdmin($uname)) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit;
|
||||
if(!$userManager->isAdmin($uname)){
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
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);
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$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')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit;
|
||||
if(!$userManager->hasGroup($uname, 'prosjekt')){
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
}
|
||||
|
||||
$projectID = $_GET['id'];
|
||||
|
@ -1,64 +1,64 @@
|
||||
<?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';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$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')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit;
|
||||
if(!$userManager->hasGroup($uname, 'prosjekt')){
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
}
|
||||
|
||||
$projectManager = new pvv\side\ProjectManager($pdo);
|
||||
$projectManager = new \pvv\side\ProjectManager($pdo);
|
||||
$projects = $projectManager->getAll();
|
||||
|
||||
$new = 0;
|
||||
if (isset($_GET['new'])) {
|
||||
$new = $_GET['new'];
|
||||
if(isset($_GET['new'])){
|
||||
$new = $_GET['new'];
|
||||
}
|
||||
|
||||
$projectID = 0;
|
||||
if (isset($_GET['id'])) {
|
||||
$projectID = $_GET['id'];
|
||||
} elseif ($new == 0) {
|
||||
echo "\nID not set";
|
||||
exit;
|
||||
if(isset($_GET['id'])){
|
||||
$projectID = $_GET['id'];
|
||||
}else if($new == 0){
|
||||
echo "\nID not set";
|
||||
exit();
|
||||
}
|
||||
|
||||
$project = new pvv\side\Project(
|
||||
0,
|
||||
'Kult Prosjekt',
|
||||
'',
|
||||
'kåre knoll',
|
||||
'pvvadmin',
|
||||
'drift@pvv.ntnu.no',
|
||||
0
|
||||
$project = new \pvv\side\Project(
|
||||
0,
|
||||
'Kult Prosjekt',
|
||||
'',
|
||||
'kåre knoll',
|
||||
'pvvadmin',
|
||||
'drift@pvv.ntnu.no',
|
||||
0
|
||||
);
|
||||
if ($new == 0) {
|
||||
$project = $projectManager->getByID($projectID);
|
||||
if($new == 0){
|
||||
$project = $projectManager->getByID($projectID);
|
||||
}
|
||||
|
||||
$members = $projectManager->getProjectMembers($projectID);
|
||||
$owner = [
|
||||
'name' => '',
|
||||
'uname' => '',
|
||||
'mail' => '',
|
||||
'name' => '',
|
||||
'uname' => '',
|
||||
'mail' => '',
|
||||
];
|
||||
foreach ($members as $i => $data) {
|
||||
if ($data['owner']) {
|
||||
$owner = $data;
|
||||
}
|
||||
foreach($members as $i => $data){
|
||||
if($data['owner']){
|
||||
$owner = $data;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@ -85,34 +85,34 @@ foreach ($members as $i => $data) {
|
||||
<h2>Prosjektadministrasjon</h2>
|
||||
<hr class="ruler">
|
||||
|
||||
<h2><?php echo $new == 1 ? 'Nytt prosjekt' : 'Rediger prosjekt'; ?></h2>
|
||||
<h2><?= ($new == 1 ? "Nytt prosjekt" : "Rediger prosjekt"); ?></h2>
|
||||
|
||||
<form action="update.php", method="post" class="gridsplit5050">
|
||||
<div class="gridl">
|
||||
<p class="subtitle">Tittel</p>
|
||||
<?php echo '<input type="text" name="title" value="' . $project->getName() . '" class="boxinput">'; ?><br>
|
||||
<?= '<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"><?php echo implode("\n", $project->getDescription()); ?></textarea>
|
||||
<textarea name="desc" cols="40" rows="5" class="boxinput"><?= implode($project->getDescription(), "\n"); ?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="gridr noborder">
|
||||
<p class="subtitle">Prosjektleder (Brukernavn)</p>
|
||||
<?php echo '<input type="text" name="organiser" value="' . $owner['uname'] . '" class="boxinput">'; ?><br>
|
||||
<?= '<input type="text" name="organiser" value="' . $owner['uname'] . '" class="boxinput">' ?><br>
|
||||
|
||||
<p class="subtitle">Prosjektleder (Navn)</p>
|
||||
<?php echo '<input type="text" name="organisername" value="' . $owner['name'] . '" class="boxinput">'; ?>
|
||||
<?= '<input type="text" name="organisername" value="' . $owner['name'] . '" class="boxinput">' ?>
|
||||
|
||||
<p class="subtitle">Prosjektleder E-post</p>
|
||||
<?php echo '<input type="text" name="organiseremail" value="' . $owner['mail'] . '" class="boxinput">'; ?><br>
|
||||
<?= '<input type="text" name="organiseremail" value="' . $owner['mail'] . '" class="boxinput">' ?><br>
|
||||
|
||||
<p class="subtitle">Aktiv</p>
|
||||
<?php echo '<input type="checkbox" ' . ($project->getActive() ? 'checked' : '') . ' name="active"/>'; ?>
|
||||
<?= '<input type="checkbox" '. ($project->getActive() ? 'checked' : '') . ' name="active"/>' ?>
|
||||
</div>
|
||||
|
||||
<?php echo '<input type="hidden" name="id" value="' . $project->getID() . '" />'; ?>
|
||||
<?= '<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><?php echo $data['uname']; ?></td>
|
||||
<td><?php echo $data['name']; ?></td>
|
||||
<td><?php echo $data['role']; ?></td>
|
||||
<td><?= $data['uname']; ?></td>
|
||||
<td><?= $data['name']; ?></td>
|
||||
<td><?= $data['role']; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
@ -136,7 +136,7 @@ foreach ($members as $i => $data) {
|
||||
</tr>
|
||||
</table>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<div class="allgrids" style="margin-top: 2em;">
|
||||
<hr class="ruler">
|
||||
|
||||
|
@ -1,49 +1,51 @@
|
||||
<?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';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$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')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit;
|
||||
if(!$userManager->hasGroup($uname, 'prosjekt')){
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
}
|
||||
|
||||
$projectManager = new pvv\side\ProjectManager($pdo);
|
||||
$projectManager = new \pvv\side\ProjectManager($pdo);
|
||||
$projects = $projectManager->getAll();
|
||||
|
||||
$page = 1;
|
||||
if (isset($_GET['page'])) {
|
||||
$page = $_GET['page'];
|
||||
if(isset($_GET['page'])){
|
||||
$page = $_GET['page'];
|
||||
}
|
||||
|
||||
$filterTitle = '';
|
||||
if (isset($_POST['title'])) {
|
||||
$filterTitle = $_POST['title'];
|
||||
if(isset($_POST['title'])){
|
||||
$filterTitle = $_POST['title'];
|
||||
}
|
||||
|
||||
/* Temporarily out of service :<
|
||||
$filterOrganiser = '';
|
||||
if(isset($_POST['organiser'])){
|
||||
$filterOrganiser = $_POST['organiser'];
|
||||
$filterOrganiser = $_POST['organiser'];
|
||||
}
|
||||
*/
|
||||
|
||||
// filter
|
||||
$projects = array_values(array_filter(
|
||||
$projects,
|
||||
static fn($project) => preg_match('/.*' . $filterTitle . '.*/i', $project->getName())
|
||||
$projects,
|
||||
function($project) use ($filterTitle){
|
||||
return (preg_match('/.*'.$filterTitle.'.*/i', $project->getName()));
|
||||
}
|
||||
));
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@ -77,52 +79,52 @@ $projects = array_values(array_filter(
|
||||
|
||||
<ul class="event-list">
|
||||
<?php
|
||||
$counter = 0;
|
||||
$pageLimit = 4;
|
||||
$counter = 0;
|
||||
$pageLimit = 4;
|
||||
|
||||
for ($i = ($pageLimit * ($page - 1)); $i < count($projects); ++$i) {
|
||||
if ($counter == $pageLimit) {
|
||||
break;
|
||||
}
|
||||
for($i = ($pageLimit * ($page - 1)); $i < count($projects); $i++){
|
||||
if($counter == $pageLimit){
|
||||
break;
|
||||
}
|
||||
|
||||
$project = $projects[$i];
|
||||
$projectID = $project->getID();
|
||||
$owner = $projectManager->getProjectOwner($projectID);
|
||||
?>
|
||||
$project = $projects[$i];
|
||||
$projectID = $project->getID();
|
||||
$owner = $projectManager->getProjectOwner($projectID);
|
||||
?>
|
||||
|
||||
<li>
|
||||
<div class="event admin">
|
||||
<div class="event-info">
|
||||
<h3 class="no-chin"><?php echo $project->getName() . ' (ID: ' . $projectID . ')'; ?></h3>
|
||||
<p class="subnote"><?php echo 'Organisert av: ' . $owner['name']; ?></p>
|
||||
<h3 class="no-chin"><?= $project->getName() . " (ID: " . $projectID . ")"; ?></h3>
|
||||
<p class="subnote"><?= 'Organisert av: ' . $owner['name']; ?></p>
|
||||
<?php
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $project->getDescription()));
|
||||
?>
|
||||
$Parsedown = new \Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $project->getDescription()));
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="event-actions">
|
||||
<?php echo '<a href="edit.php?id=' . $projectID . '">🖊</a>'; ?>
|
||||
<?php echo '<a href="delete.php?id=' . $projectID . '" onclick="return confirm(\'Knallsikker? (ID: ' . $projectID . ')\');">🗑</a>'; ?>
|
||||
<?= '<a href="edit.php?id=' . $projectID . '">🖊</a>'; ?>
|
||||
<?= '<a href="delete.php?id=' . $projectID . '" onclick="return confirm(\'Knallsikker? (ID: ' . $projectID . ')\');">🗑</a>'; ?>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php
|
||||
++$counter;
|
||||
}
|
||||
?>
|
||||
$counter++;
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
if ($page != 1) {
|
||||
echo '<a class="btn float-left" href="?page=' . ($page - 1) . '">Forrige side</a>';
|
||||
}
|
||||
if($page != 1){
|
||||
echo '<a class="btn float-left" href="?page=' . ($page - 1) . '">Forrige side</a>';
|
||||
}
|
||||
|
||||
if (($counter == $pageLimit) && (($pageLimit * $page) < count($projects))) {
|
||||
echo '<a class="btn float-right" href="?page=' . ($page + 1) . '">Neste side</a>';
|
||||
}
|
||||
?>
|
||||
if(($counter == $pageLimit) and (($pageLimit * $page) < count($projects))){
|
||||
echo '<a class="btn float-right" href="?page=' . ($page + 1) . '">Neste side</a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="gridr">
|
||||
@ -131,9 +133,9 @@ $projects = array_values(array_filter(
|
||||
<h2>Filter</h2>
|
||||
<form action="." method="post">
|
||||
<p class="no-chin">Prosjektnavn</p>
|
||||
<?php echo '<input type="text" name="title" class="boxinput" value="' . $filterTitle . '">'; ?><br>
|
||||
<?= '<input type="text" name="title" class="boxinput" value="' . $filterTitle . '">' ?><br>
|
||||
<p class="no-chin">Leders brukernavn</p>
|
||||
<?php echo '<input type="text" name="organiser" class="boxinput" value="">'; ?><br>
|
||||
<?= '<input type="text" name="organiser" class="boxinput" value="">' ?><br>
|
||||
|
||||
<div style="margin-top: 2em;">
|
||||
<input type="submit" class="btn" value="Filtrer"></input>
|
||||
|
@ -1,31 +1,31 @@
|
||||
<?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);
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$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')) {
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit;
|
||||
if(!$userManager->hasGroup($uname, 'prosjekt')){
|
||||
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!isset($_POST['title']) || !isset($_POST['desc']) || !isset($_POST['organisername']) || !isset($_POST['organiser'])) {
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
exit;
|
||||
if(!isset($_POST['title']) or !isset($_POST['desc']) or !isset($_POST['organisername']) or !isset($_POST['organiser'])){
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$id = 0;
|
||||
if (isset($_POST['id'])) {
|
||||
$id = $_POST['id'];
|
||||
if(isset($_POST['id'])){
|
||||
$id = $_POST['id'];
|
||||
}
|
||||
|
||||
$title = $_POST['title'];
|
||||
@ -33,45 +33,45 @@ $desc = $_POST['desc'];
|
||||
$name = $_POST['organisername'];
|
||||
$uname = $_POST['organiser'];
|
||||
$mail = $_POST['organiseremail'];
|
||||
$active = ($_POST['active'] ?? 0);
|
||||
$active = (isset($_POST['active']) ? $_POST['active'] : 0);
|
||||
|
||||
$statement;
|
||||
if($id == 0){
|
||||
$query = 'INSERT INTO projects (name, description, active) VALUES (:title, :desc, :active)';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
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(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':active', $active, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
$statement->execute();
|
||||
$ownerQuery = 'INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (last_insert_rowid(), :owner, :owneruname, :owneremail, \'Prosjektleder\', 1, 1)';
|
||||
$statement = $pdo->prepare($ownerQuery);
|
||||
$statement->bindParam(':owner', $name, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneruname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneremail', $mail, PDO::PARAM_STR);
|
||||
|
||||
$ownerQuery = 'INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (last_insert_rowid(), :owner, :owneruname, :owneremail, \'Prosjektleder\', 1, 1)';
|
||||
$statement = $pdo->prepare($ownerQuery);
|
||||
$statement->bindParam(':owner', $name, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneruname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneremail', $mail, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
}else{
|
||||
$query = 'UPDATE projects SET name=:title, description=:desc, active=:active WHERE id=:id';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
$statement->execute();
|
||||
} 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(':id', $id, PDO::PARAM_INT);
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':active', $active, PDO::PARAM_INT);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
$statement->execute();
|
||||
$query = 'UPDATE projectmembers SET name=:name, uname=:uname, mail=:mail';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
$query = 'UPDATE projectmembers SET name=:name, uname=:uname, mail=:mail';
|
||||
$statement = $pdo->prepare($query);
|
||||
$statement->bindParam(':name', $name, PDO::PARAM_STR);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':mail', $mail, PDO::PARAM_STR);
|
||||
|
||||
$statement->bindParam(':name', $name, PDO::PARAM_STR);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':mail', $mail, PDO::PARAM_STR);
|
||||
|
||||
$statement->execute();
|
||||
$statement->execute();
|
||||
}
|
||||
|
||||
header('Location: .');
|
||||
|
@ -1,18 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
require_once \dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
<?php namespace pvv\side;
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$year = (isset($_GET['year']))
|
||||
? $_GET['year']
|
||||
: date('Y');
|
||||
? $_GET['year']
|
||||
: date("Y");
|
||||
$month = (isset($_GET['month']))
|
||||
? $_GET['month']
|
||||
: date('m');
|
||||
? $_GET['month']
|
||||
: date("m");
|
||||
$day = (isset($_GET['day']))
|
||||
? $_GET['day']
|
||||
: -1;
|
||||
? $_GET['day']
|
||||
: -1;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@ -37,46 +34,42 @@ $day = (isset($_GET['day']))
|
||||
|
||||
<main>
|
||||
<?php
|
||||
use 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"));
|
||||
|
||||
$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")
|
||||
);
|
||||
|
||||
$limit = 0;
|
||||
foreach ($events as $event) {
|
||||
?>
|
||||
$limit = 0;
|
||||
foreach($events as $event) {
|
||||
?>
|
||||
<article>
|
||||
<h2>
|
||||
<?php if (Agenda::isToday($event->getStart())) { ?><strong><?php } ?>
|
||||
<em><?php echo $event->getRelativeDate(); ?></em>
|
||||
<?php if (Agenda::isToday($event->getStart())) { ?></strong><?php } ?>
|
||||
<?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 ($event->getURL()) { ?>
|
||||
<a href="<?php echo $event->getURL(); ?>"><?php echo $event->getName(); ?></a>
|
||||
<a href="<?= $event->getURL() ?>"><?= $event->getName() ?></a>
|
||||
<?php } else { ?>
|
||||
<?php echo $event->getName(); ?>
|
||||
<?= $event->getName() ?>
|
||||
<?php } ?>
|
||||
<?php if ($event->getImageURL()) { ?>
|
||||
<img src="<?php echo $event->getImageURL(); ?>">
|
||||
<img src="<?= $event->getImageURL() ?>">
|
||||
<?php } ?>
|
||||
</h2>
|
||||
<ul class="subtext">
|
||||
<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>
|
||||
<li>Tid: <strong><?= Agenda::getFormattedDate($event->getStart()) ?></strong></li>
|
||||
<li>Sted: <strong><?= $event->getLocation() ?></strong></li>
|
||||
<li>Arrangør: <strong><?= $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));
|
||||
?>
|
||||
$Parsedown = new \Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $description));
|
||||
?>
|
||||
</article>
|
||||
|
||||
<?php } ?>
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use pvv\side\Agenda;
|
||||
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use \pvv\side\Agenda;
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
@ -21,40 +20,40 @@ 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><?php echo $nextEvent->getRelativeDate(); ?></em> Animekveld
|
||||
<h2><em><?= $nextEvent->getRelativeDate()?></em> Animekveld
|
||||
<?php if ($nextEvent->getImageURL()) { ?>
|
||||
<img src="<?php echo $nextEvent->getImageURL(); ?>">
|
||||
<img src="<?= $nextEvent->getImageURL() ?>">
|
||||
<?php } ?>
|
||||
</h2>
|
||||
<ul class="subtext">
|
||||
<li>Tid:
|
||||
<strong>
|
||||
<?php echo Agenda::getFormattedDate($nextEvent->getStart()); ?>
|
||||
<?= Agenda::getFormattedDate($nextEvent->getStart());?>
|
||||
</strong>
|
||||
<li>Sted:
|
||||
<strong>
|
||||
<?php echo $nextEvent->getLocation(); ?>
|
||||
<?= $nextEvent->getLocation();?>
|
||||
</strong>
|
||||
<li>Arrangør:
|
||||
<strong>
|
||||
<?php echo $nextEvent->getOrganiser(); ?>
|
||||
<?= $nextEvent->getOrganiser();?>
|
||||
</strong>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
|
||||
?>
|
||||
$Parsedown = new \Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
|
||||
?>
|
||||
</article>
|
||||
|
||||
</main>
|
||||
|
||||
<nav>
|
||||
<?php echo navbar(1, 'aktiviteter'); ?>
|
||||
<?php echo loginbar($sp, $pdo); ?>
|
||||
<?= navbar(1, 'aktiviteter'); ?>
|
||||
<?= loginbar($sp, $pdo); ?>
|
||||
</nav>
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use pvv\side\Agenda;
|
||||
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use \pvv\side\Agenda;
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
@ -21,41 +20,41 @@ 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><?php echo $nextEvent->getRelativeDate(); ?></em> Brettspillkveld
|
||||
<h2><em><?= $nextEvent->getRelativeDate()?></em> Brettspillkveld
|
||||
<?php if ($nextEvent->getImageURL()) { ?>
|
||||
<img src="<?php echo $nextEvent->getImageURL(); ?>">
|
||||
<img src="<?= $nextEvent->getImageURL() ?>">
|
||||
<?php } ?>
|
||||
</h2>
|
||||
<ul class="subtext">
|
||||
<li>Tid:
|
||||
<strong>
|
||||
<?php echo Agenda::getFormattedDate($nextEvent->getStart()); ?>
|
||||
<?= Agenda::getFormattedDate($nextEvent->getStart());?>
|
||||
</strong>
|
||||
<li>Sted:
|
||||
<strong>
|
||||
<?php echo $nextEvent->getLocation(); ?>
|
||||
<?= $nextEvent->getLocation();?>
|
||||
</strong>
|
||||
<li>Arrangør:
|
||||
<strong>
|
||||
<?php echo $nextEvent->getOrganiser(); ?>
|
||||
<?= $nextEvent->getOrganiser();?>
|
||||
</strong>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
|
||||
?>
|
||||
$Parsedown = new \Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
|
||||
?>
|
||||
</article>
|
||||
|
||||
</main>
|
||||
|
||||
<nav>
|
||||
<?php echo navbar(1, 'aktiviteter'); ?>
|
||||
<?php echo loginbar($sp, $pdo); ?>
|
||||
<?= navbar(1, 'aktiviteter'); ?>
|
||||
<?= loginbar($sp, $pdo); ?>
|
||||
</nav>
|
||||
|
@ -51,9 +51,11 @@ main {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
/* #region modal */
|
||||
|
||||
.modal-target:hover {opacity: 0.7;}
|
||||
|
||||
/* Modal Background */
|
||||
/* The Modal (background) */
|
||||
.modal {
|
||||
display: none; /* Hidden by default */
|
||||
position: fixed; /* Stay in place */
|
||||
@ -68,12 +70,14 @@ main {
|
||||
background-color: rgba(0,0,0,0.8); /* Black w/ opacity */
|
||||
}
|
||||
|
||||
/* Modal Content (image) */
|
||||
.modal-content {
|
||||
margin: auto;
|
||||
display: block;
|
||||
object-fit: scale-down;
|
||||
overflow: visible;
|
||||
|
||||
/* yolo, it all goes down from here */
|
||||
min-width: 60vw;
|
||||
max-width: 90vw !important;
|
||||
min-height: 60vh;
|
||||
@ -84,6 +88,7 @@ main {
|
||||
opacity: 1 !important;
|
||||
}
|
||||
|
||||
/* Caption of Modal Image */
|
||||
.modal-caption {
|
||||
margin: auto;
|
||||
display: block;
|
||||
@ -128,7 +133,9 @@ main {
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
/* #endregion modal */
|
||||
|
||||
/* #region screen-size media-rules */
|
||||
@media only screen and (min-width:320px) {
|
||||
.gallery-container { grid-template-columns: repeat(1, minmax(0, 1fr)) !important; }
|
||||
main { padding: 1em; }
|
||||
@ -143,3 +150,4 @@ main {
|
||||
@media only screen and (min-width: 1281px) {
|
||||
.gallery-container { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
|
||||
}
|
||||
/* #endregion */
|
@ -1,131 +1,154 @@
|
||||
header.landing {
|
||||
display: block;
|
||||
margin: 0;
|
||||
margin-top: 3em;
|
||||
padding: 3vh 15vw;
|
||||
width: 70vw;
|
||||
background-color: #002244;
|
||||
color: #fff;
|
||||
display:block;
|
||||
margin: 0;
|
||||
margin-top: 3em;
|
||||
padding: 3vh 15vw;
|
||||
width: 70vw;
|
||||
background-color: #002244;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
header.landing .logo {
|
||||
display: block;
|
||||
width: 24vh;
|
||||
height: 24vh;
|
||||
margin: auto;
|
||||
display: block;
|
||||
width: 24vh;
|
||||
height: 24vh;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
main {
|
||||
margin-top: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.info {
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
overflow-y: hidden;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
.essentials {
|
||||
width: 100%;
|
||||
margin: 1em 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
margin: 1em 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.essentials li {
|
||||
display: inline-block;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.essentials a {
|
||||
margin: 0 2em;
|
||||
height: 100%;
|
||||
margin: 0 2em;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.essentials .focus {
|
||||
padding: 0.8em;
|
||||
font-size: 1.2em;
|
||||
padding: 0.8em;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
img.float-right {
|
||||
float: right;
|
||||
max-width: 12em;
|
||||
max-height: 12em;
|
||||
vertical-align: baseline;
|
||||
float: right;
|
||||
max-width: 12em;
|
||||
max-height: 12em;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
.calendar-events {
|
||||
padding: 0;
|
||||
margin-bottom: 1.5em;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin-bottom: 1.5em;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.calendar-events ul li :not(.date):not(.time) {
|
||||
display: inline-block;
|
||||
width: calc(100% - 7em);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.calendar-events ul .date {
|
||||
color: rgba(0,0,0,.5);
|
||||
font-size: 0.8em;
|
||||
margin-top: .2em;
|
||||
}
|
||||
|
||||
.calendar-events > li > p {
|
||||
border-bottom: .1em dotted rgba(0,0,0,.2);
|
||||
}
|
||||
|
||||
.calendar-events ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.calendar-events a {
|
||||
color: rgba(0,0,0, 0.85);
|
||||
.calendar-events a, #ticker a {
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.calendar-events ul .datetime {
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
float: right;
|
||||
margin-left: 0.2em;
|
||||
.calendar-events a:hover, #ticker a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.calendar-events ul li {
|
||||
margin-bottom: 0.4em;
|
||||
.calendar-events ul .time {
|
||||
color: rgba(0,0,0,.5);
|
||||
float: right;
|
||||
}
|
||||
|
||||
.calendar-events ul .icon, .calendar-events ul .date {
|
||||
float: right;
|
||||
margin-right: .5em;
|
||||
}
|
||||
|
||||
main.contentsplit {
|
||||
padding-top: 1em;
|
||||
padding-top: 1em;
|
||||
}
|
||||
|
||||
.contentsplit {
|
||||
display: grid;
|
||||
grid-template-columns: 2.5fr 2fr;
|
||||
display: grid;
|
||||
grid-template-columns: 2.5fr 2fr;
|
||||
}
|
||||
|
||||
.gridr {
|
||||
border-left: 0;
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 50rem) {
|
||||
.essentials {
|
||||
flex-direction: column;
|
||||
}
|
||||
.essentials {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.essentials a {
|
||||
margin: 0.2em 0;
|
||||
}
|
||||
.essentials a {
|
||||
margin: .2em 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 65rem) {
|
||||
.contentsplit {
|
||||
display: block;
|
||||
}
|
||||
.contentsplit {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.gridr {
|
||||
height: auto;
|
||||
padding: 0;
|
||||
margin-left: 0;
|
||||
margin-bottom: 3em;
|
||||
}
|
||||
.gridr {
|
||||
height: auto;
|
||||
padding: 0;
|
||||
margin-left: 0;
|
||||
margin-bottom: 3em;
|
||||
}
|
||||
|
||||
.gridr br {
|
||||
margin: 0;
|
||||
height: 0px;
|
||||
}
|
||||
.gridr br {
|
||||
margin: 0;
|
||||
height: 0px;
|
||||
}
|
||||
|
||||
.gridl {
|
||||
margin-top: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.gridl {
|
||||
margin-top: 0;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,93 +0,0 @@
|
||||
main {
|
||||
margin: 0px !important;
|
||||
padding: 0px !important;
|
||||
width: 100vw;
|
||||
}
|
||||
|
||||
.serviceWrapper {
|
||||
width: 80%;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: 1em;
|
||||
|
||||
margin: auto auto;
|
||||
margin-top: 4em;
|
||||
}
|
||||
|
||||
.categoryContainer {
|
||||
border: 4px solid #002244;
|
||||
border-radius: 5px;
|
||||
|
||||
box-shadow : 0 0 20px #002244;
|
||||
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.categoryLabel {
|
||||
background-color: #002244;
|
||||
color: white;
|
||||
|
||||
padding-left: 10px;
|
||||
|
||||
font-family: monospace;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.service {
|
||||
border: 2px solid #002244;
|
||||
border-radius: 5px;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.serviceContent {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.serviceTitle {
|
||||
margin: 0.2em !important;
|
||||
}
|
||||
|
||||
.serviceDescription {
|
||||
margin-top: 0px !important;
|
||||
}
|
||||
|
||||
.serviceDescription::before {
|
||||
content: " - ";
|
||||
font-size: 18px;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.serviceLink {
|
||||
width: 70%;
|
||||
padding-bottom: 5px;
|
||||
border-radius: 5px;
|
||||
border: 2px solid #002244;
|
||||
padding: 7px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.serviceLink > a {
|
||||
margin-bottom: 10px;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.serviceImage {
|
||||
flex-shrink: 1;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
|
||||
margin: auto auto;
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
.serviceWrapper {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.categoryContainer {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
@ -1,95 +1,93 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
require_once dirname(dirname(__DIR__)) . 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'])) {
|
||||
[$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"}';
|
||||
exit;
|
||||
}
|
||||
if($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (isset($_SERVER["HTTP_AUTHORIZATION"])) {
|
||||
list($type, $data) = explode(" ", $_SERVER["HTTP_AUTHORIZATION"], 2);
|
||||
if (strcasecmp($type, "Bearer") == 0) {
|
||||
if (hash_equals($data, $doorSensorSecret)) {
|
||||
handleSetState();
|
||||
} else {
|
||||
echo '{"status": "error", "message": "Invalid authentication key"}';
|
||||
die();
|
||||
}
|
||||
} else {
|
||||
echo '{"status": "error", "message": "Invalid authentication method"}';
|
||||
die();
|
||||
}
|
||||
} else {
|
||||
echo '{"status": "error", "message": "Invalid authentication method"}';
|
||||
exit;
|
||||
echo '{"status": "error", "message": "Missing authentication"}';
|
||||
die();
|
||||
}
|
||||
} else {
|
||||
echo '{"status": "error", "message": "Missing authentication"}';
|
||||
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);
|
||||
} else {
|
||||
echo '{"status": "error", "message": "Invalid period"}';
|
||||
die();
|
||||
}
|
||||
|
||||
if ($period == 'day') {
|
||||
$startTime = time() - (60 * 60 * 24);
|
||||
} elseif ($period == 'week') {
|
||||
$startTime = time() - (60 * 60 * 24 * 7);
|
||||
$lines = $door->getEntriesAfter($startTime);
|
||||
if (isset($_GET["edgeonly"]) && (bool)htmlspecialchars($_GET["edgeonly"])) {
|
||||
//Ignore repeats
|
||||
$lines = getChanges($lines);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'status' => "OK",
|
||||
'entries' => $lines
|
||||
]);
|
||||
} else {
|
||||
echo '{"status": "error", "message": "Invalid period"}';
|
||||
exit;
|
||||
//Only last entry
|
||||
$line = (object)$door->getCurrent();
|
||||
echo json_encode([
|
||||
'status' => "OK",
|
||||
'time' => $line->time,
|
||||
'open' => $line->open
|
||||
]);
|
||||
}
|
||||
|
||||
$lines = $door->getEntriesAfter($startTime);
|
||||
if (isset($_GET['edgeonly']) && (bool) htmlspecialchars($_GET['edgeonly'])) {
|
||||
// Ignore repeats
|
||||
$lines = getChanges($lines);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'status' => 'OK',
|
||||
'entries' => $lines,
|
||||
]);
|
||||
} else {
|
||||
// Only last entry
|
||||
$line = (object) $door->getCurrent();
|
||||
echo json_encode([
|
||||
'status' => 'OK',
|
||||
'time' => $line->time,
|
||||
'open' => $line->open,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function handleSetState(): void {
|
||||
global $door;
|
||||
function handleSetState() {
|
||||
global $door;
|
||||
|
||||
$jsonobj = file_get_contents('php://input');
|
||||
$event = json_decode($jsonobj);
|
||||
$jsonobj = file_get_contents('php://input');
|
||||
$event = json_decode($jsonobj);
|
||||
|
||||
if ((!isset($event->time)) || (!is_numeric($event->time))) {
|
||||
echo '{"status": "error", "message": "Invalid timestamp"}';
|
||||
exit;
|
||||
}
|
||||
if ((!isset($event->isDoorOpen)) || (!is_bool($event->isDoorOpen))) {
|
||||
echo '{"status": "error", "message": "Invalid door state"}';
|
||||
exit;
|
||||
}
|
||||
if ((!isset($event->time)) || (!is_numeric($event->time))) {
|
||||
echo '{"status": "error", "message": "Invalid timestamp"}';
|
||||
die();
|
||||
}
|
||||
if ((!isset($event->isDoorOpen)) || (!is_bool($event->isDoorOpen))) {
|
||||
echo '{"status": "error", "message": "Invalid door state"}';
|
||||
die();
|
||||
}
|
||||
|
||||
$door->createEvent((int) $event->time, $event->isDoorOpen ? 1 : 0);
|
||||
echo '{"status": "OK"}';
|
||||
}
|
||||
$door->createEvent((int)($event->time), (bool)($event->isDoorOpen));
|
||||
echo '{"status": "OK"}';
|
||||
}
|
||||
|
||||
function getChanges($items) {
|
||||
$prevState = 2;
|
||||
$res = [];
|
||||
$prevState = 2;
|
||||
$res = [];
|
||||
|
||||
foreach ($items as $item) {
|
||||
if ($item['open'] !== $prevState) {
|
||||
$res[] = $item;
|
||||
$prevState = $item['open'];
|
||||
foreach($items as $item) {
|
||||
if ($item["open"] !== $prevState) {
|
||||
array_push($res, $item);
|
||||
$prevState = $item["open"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
return $res;
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use pvv\side\Agenda;
|
||||
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use \pvv\side\Agenda;
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
@ -15,46 +14,46 @@ use pvv\side\Agenda;
|
||||
<meta name="theme-color" content="#024" />
|
||||
<title>Drifterverkstedet</title>
|
||||
|
||||
<header>Drift­verk­stedet</header>
|
||||
<header>Sosial­verk­stedet</header>
|
||||
|
||||
|
||||
<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><?php echo $nextEvent->getRelativeDate(); ?></em> Driftkveld
|
||||
<h2><em><?= $nextEvent->getRelativeDate()?></em> Driftkveld
|
||||
<?php if ($nextEvent->getImageURL()) { ?>
|
||||
<img src="<?php echo $nextEvent->getImageURL(); ?>">
|
||||
<img src="<?= $nextEvent->getImageURL() ?>">
|
||||
<?php } ?>
|
||||
</h2>
|
||||
<ul class="subtext">
|
||||
<li>Tid:
|
||||
<strong>
|
||||
<?php echo Agenda::getFormattedDate($nextEvent->getStart()); ?>
|
||||
<?= Agenda::getFormattedDate($nextEvent->getStart());?>
|
||||
</strong>
|
||||
<li>Sted:
|
||||
<strong>
|
||||
<?php echo $nextEvent->getLocation(); ?>
|
||||
<?= $nextEvent->getLocation();?>
|
||||
</strong>
|
||||
<li>Arrangør:
|
||||
<strong>
|
||||
<?php echo $nextEvent->getOrganiser(); ?>
|
||||
<?= $nextEvent->getOrganiser();?>
|
||||
</strong>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
|
||||
?>
|
||||
$Parsedown = new \Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
|
||||
?>
|
||||
</article>
|
||||
|
||||
</main>
|
||||
|
||||
<nav>
|
||||
<?php echo navbar(1, 'aktiviteter'); ?>
|
||||
<?php echo loginbar($sp, $pdo); ?>
|
||||
<?= navbar(1, 'aktiviteter'); ?>
|
||||
<?= loginbar($sp, $pdo); ?>
|
||||
</nav>
|
0
www/galleri/bilder/slideshow/.gitkeep
Normal file
0
www/galleri/bilder/slideshow/.gitkeep
Normal file
@ -1,23 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
outfolder="bilder/pvv-photos"
|
||||
|
||||
echo "Fetching user list"
|
||||
# Note: `~pvv/.ssh/authorized_keys` forces the command as such
|
||||
folders="$(ssh pvv@microbel.pvv.ntnu.no -i /home/pvv/c/pvv/.ssh/photofetcher 'cat /etc/passwd' | while read line; do test `echo "$line" | cut -d: -f 3` -gt 1000 && echo "$(echo $line | cut -d: -f 6)/pvv-photos" ; done)"
|
||||
|
||||
folders=$(ssh pvv@microbel.pvv.ntnu.no -i /home/pvv/c/pvv/.ssh/photofetcher 'find /home/pvv -maxdepth 3 -name "pvv-photos" 2>/dev/null')
|
||||
unamefile="usernames.txt"
|
||||
> $unamefile # Empty the file
|
||||
|
||||
for imgfolder in $folders; do
|
||||
if ! test -d "$imgfolder"; then continue; fi
|
||||
echo found $imgfolder
|
||||
|
||||
user="$(echo $imgfolder | cut -d "/" -f5)"
|
||||
user=$(echo $imgfolder | cut -d "/" -f5)
|
||||
realname="$(getent passwd $user | cut -d ':' -f 5)"
|
||||
echo "$user:$realname" >> "$unamefile"
|
||||
echo "$user:$realname" >> $unamefile
|
||||
destination="$outfolder/$user"
|
||||
mkdir -p "$destination"
|
||||
mkdir -p $destination
|
||||
rsync -rtvz --delete "$imgfolder/" "$destination" # Copy and keep timestamps
|
||||
|
||||
echo
|
||||
done
|
||||
done
|
7
www/galleri/fetchPicsCron.sh
Executable file
7
www/galleri/fetchPicsCron.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
#fetchPics.sh 1> /dev/null
|
||||
|
||||
cd /usr/local/www/www_pvv_ntnu_no/www/galleri/
|
||||
./fetchPics.sh 1>/dev/null
|
||||
|
@ -1,73 +1,60 @@
|
||||
<?php
|
||||
error_reporting(0);
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$loginname = $attrs['uid'][0];
|
||||
|
||||
if (!$loginname) {
|
||||
header('Content-Type: text/plain', true, 403);
|
||||
echo "Du må være logget inn for å se bildegalleriet.\r\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Sourced from config.php through include.php
|
||||
$galleryDir = $GALLERY_DIR;
|
||||
$serverPath = $GALLERY_SERVER_PATH;
|
||||
|
||||
#$userManager = new \pvv\admin\UserManager($pdo);
|
||||
#
|
||||
#$as = new SimpleSAML_Auth_Simple('default-sp');
|
||||
#$as->requireAuth();
|
||||
#$attrs = $as->getAttributes();
|
||||
#$loginname = $attrs['uid'][0];
|
||||
#
|
||||
#if(!$loginname) {
|
||||
# header('Content-Type: text/plain', true, 403);
|
||||
# echo "Du må være logget inn for å se bildegalleriet.\r\n";
|
||||
# exit();
|
||||
#}
|
||||
#
|
||||
#
|
||||
$unamefile = __DIR__ . '/usernames.txt';
|
||||
$relativePath = "/bilder/pvv-photos/";
|
||||
$allowedExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg', 'webp'];
|
||||
$unamefile = $galleryDir . '/usernames.txt';
|
||||
|
||||
$unamepairs = file($unamefile);
|
||||
$fullPath = getcwd() . $relativePath;
|
||||
|
||||
function getDirContents($dir, &$results = []) {
|
||||
$files = scandir($dir);
|
||||
foreach ($files as $key => $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']);
|
||||
if ($pos !== false) {
|
||||
$cleanPath = substr_replace($path, '', $pos, strlen($GLOBALS['galleryDir']));
|
||||
}
|
||||
function getDirContents($dir, &$results = array()) {
|
||||
$files = scandir($dir);
|
||||
foreach ($files as $key => $value) {
|
||||
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
|
||||
if (!is_dir($path)) {
|
||||
//Remove the full path on disk, keep username and relative path to image. ( $results[] = str_replace($GLOBALS["fullPath"], "", $path); is insecure.)
|
||||
$pos = strpos($path, $GLOBALS["fullPath"]);
|
||||
if ($pos !== false) {
|
||||
$cleanPath = substr_replace($path, "", $pos, strlen($GLOBALS["fullPath"]));
|
||||
}
|
||||
|
||||
// Check if the file is an image
|
||||
$ext = strtolower(pathinfo($path, \PATHINFO_EXTENSION));
|
||||
if (in_array($ext, $GLOBALS['allowedExtensions'], true)) {
|
||||
$results[] = $cleanPath;
|
||||
}
|
||||
} elseif ($value != '.' && $value != '..' && $value != '.thumbnails') {
|
||||
// recursively scan directories
|
||||
getDirContents($path, $results);
|
||||
//Check if the file is an image
|
||||
$ext = pathinfo($path, PATHINFO_EXTENSION);
|
||||
if (in_array($ext, $GLOBALS["allowedExtensions"])) {
|
||||
$results[] = $cleanPath;
|
||||
}
|
||||
} else if ($value != "." && $value != "..") {
|
||||
//recursively scan directories
|
||||
getDirContents($path, $results);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
return $results;
|
||||
}
|
||||
$images = getDirContents($galleryDir);
|
||||
|
||||
function cmpModifyTime($a, $b) {
|
||||
global $galleryDir;
|
||||
|
||||
$mtime_a = filemtime($galleryDir . $a);
|
||||
$mtime_b = filemtime($galleryDir . $b);
|
||||
|
||||
return ($mtime_a > $mtime_b) ? -1 : 1;
|
||||
}
|
||||
|
||||
usort($images, 'cmpModifyTime');
|
||||
$images = getDirContents($fullPath);
|
||||
|
||||
$imageTemplate = '
|
||||
<div class="card">
|
||||
<div class="card-image-div">
|
||||
<img src="%thumbnail" data-fullsrc="%path" alt="%name" class="card-image modal-target">
|
||||
<img src="%path" alt="%name" class="card-image modal-target">
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="card-title">%realname</p>
|
||||
@ -78,7 +65,7 @@ $imageTemplate = '
|
||||
<p class="card-footer-item">%time</p>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
'
|
||||
|
||||
|
||||
?>
|
||||
@ -91,6 +78,7 @@ $imageTemplate = '
|
||||
<link rel="stylesheet" href="../css/normalize.css">
|
||||
<link rel="stylesheet" href="../css/style.css">
|
||||
<link rel="stylesheet" href="../css/gallery.css">
|
||||
<link rel="stylesheet" href="../css/bulma.min.css">
|
||||
<meta name="theme-color" content="#024" />
|
||||
<title>Fotoverkstedet</title>
|
||||
</head>
|
||||
@ -102,34 +90,29 @@ $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';
|
||||
foreach ($unamepairs as $unamepair) {
|
||||
$unamepair = explode(':', $unamepair);
|
||||
if ($unamepair[0] == $imguser) {
|
||||
$realname = $unamepair[1];
|
||||
break;
|
||||
$modTime = date("d.m.Y H:i", filemtime($fullPath . $value));
|
||||
$imguser = explode("/", $value)[0];
|
||||
$displaypath = substr($value, strpos($value, "/")+1);
|
||||
$realname = "Ukjent";
|
||||
foreach ($unamepairs as $unamepair) {
|
||||
$unamepair = explode(":", $unamepair);
|
||||
if ($unamepair[0] == $imguser) {
|
||||
$realname = $unamepair[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$vars = [
|
||||
'%user' => htmlspecialchars($imguser),
|
||||
'%time' => $modTime,
|
||||
'%name' => htmlspecialchars($displaypath),
|
||||
'%path' => $serverPath . $value,
|
||||
'%thumbnail' => $serverPath . '/.thumbnails' . $value . '.png',
|
||||
'%realname' => htmlspecialchars($realname),
|
||||
];
|
||||
echo strtr($imageTemplate, $vars);
|
||||
$vars = [
|
||||
"%user" => htmlspecialchars($imguser),
|
||||
"%time" => $modTime,
|
||||
"%timestamp" => filemtime($fullPath . $value),
|
||||
"%name" => htmlspecialchars($displaypath),
|
||||
"%path" => "/galleri/" . $relativePath .$value,
|
||||
"%realname" => htmlspecialchars($realname)
|
||||
];
|
||||
echo strtr($imageTemplate, $vars);
|
||||
}
|
||||
|
||||
if (count($images) == 0) {
|
||||
echo "<h3 class='no-images'>Det er dessverre ingen bilder å vise.</h3>";
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
</main>
|
||||
<div id="modal" class="modal">
|
||||
<span id="modal-close" class="modal-close">✖</span>
|
||||
|
@ -1,36 +1,30 @@
|
||||
<?php
|
||||
<?php
|
||||
//Short path to search folder, full to display in <img>
|
||||
$relativePath = "/bilder/slideshow/";
|
||||
$absolutePath = "/galleri" . $relativePath;
|
||||
//Path to first image in slideshow and fallback image if no others are present
|
||||
$splashImg = "/PNG/PVV-logo-big-bluebg.png";
|
||||
|
||||
declare(strict_types=1);
|
||||
$filenames = sCaNdIr(__DIR__ . $relativePath);
|
||||
|
||||
require __DIR__ . '/../../config.php';
|
||||
|
||||
$searchDir = $SLIDESHOW_DIR;
|
||||
$serverPath = $SLIDESHOW_SERVER_PATH;
|
||||
|
||||
$splashImg = '/PNG/PVV-logo-big-bluebg.png';
|
||||
|
||||
// Note: This does not support nested directories
|
||||
$filenames = scandir($searchDir);
|
||||
|
||||
// Remove the expected non-images
|
||||
foreach ($filenames as $k => $value) {
|
||||
if (in_array($value, ['.', '..'], true)) {
|
||||
unset($filenames[$k]);
|
||||
}
|
||||
//Remove the expected non-images
|
||||
foreach($filenames as $k => $value) {
|
||||
if(in_array($value, [".gitkeep", ".", ".."])) {
|
||||
unset($filenames[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
function getFullPath($fname) {
|
||||
return $GLOBALS['serverPath'] . '/' . $fname;
|
||||
}
|
||||
function getFullPath($fname) { return ($GLOBALS["absolutePath"] . $fname ); }
|
||||
|
||||
// Sort filenames alphabetically and prepend the path prefix to each item.
|
||||
//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
|
||||
//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] . '">';
|
||||
// Store list of file names in a globel JS variable
|
||||
EchO '<script> const slideshowFnames =' . jSoN_eNcOdE($slideshowimagefilenames) . '; </script>';
|
||||
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>");
|
||||
?>
|
@ -1,8 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
require_once \dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
<?php namespace pvv\side;
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$translation = ['I dag', 'I morgen', 'Denne uka', 'Neste uke', 'Denne måneden', 'Neste måned'];
|
||||
?>
|
||||
@ -21,8 +18,8 @@ $translation = ['I dag', 'I morgen', 'Denne uka', 'Neste uke', 'Denne måneden',
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<?php echo navbar(1, 'hendelser'); ?>
|
||||
<?php echo loginbar($sp, $pdo); ?>
|
||||
<?= navbar(1, 'hendelser'); ?>
|
||||
<?= loginbar($sp, $pdo); ?>
|
||||
</nav>
|
||||
<main>
|
||||
<h1 style="pointer-events:none; text-align: left;">Hendelser</h1>
|
||||
@ -30,45 +27,43 @@ $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) {
|
||||
if ($events) { ?>
|
||||
<h2 style="text-align: left;"><?php echo $translation[$period]; ?></h2>
|
||||
$description_paragraphs = 2; //description length
|
||||
foreach($agenda->getNextDays() as $period => $events) {
|
||||
if ($events) { ?>
|
||||
<h2 style="text-align: left;"><?= $translation[$period] ?></h2>
|
||||
<ul class="events">
|
||||
<?php foreach ($events as $event) {?>
|
||||
<li style="border-color: <?php echo $event->getColor(); ?>">
|
||||
<?php foreach($events as $event) {?>
|
||||
<li style="border-color: <?= $event->getColor() ?>">
|
||||
<h4><strong>
|
||||
<?php if ($event->getURL()) { ?>
|
||||
<a href="<?php echo $event->getURL(); ?>"><?php echo $event->getName(); ?></a>
|
||||
<a href="<?= $event->getURL() ?>"><?= $event->getName() ?></a>
|
||||
<?php } else { ?>
|
||||
<?php echo $event->getName(); ?>
|
||||
<?= $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();
|
||||
echo $Parsedown->text(implode("\n", $description));
|
||||
?>
|
||||
$Parsedown = new \Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $description));
|
||||
?>
|
||||
|
||||
<ul class="subtext">
|
||||
<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>
|
||||
<li>Tid: <strong><?= Agenda::getFormattedDate($event->getStart()) ?></strong></li>
|
||||
<li>Sted: <strong><?= $event->getLocation() ?></strong></li>
|
||||
<li>Arrangør: <strong><?= $event->getOrganiser() ?></strong></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?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(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use pvv\side\Agenda;
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use \pvv\side\Agenda;
|
||||
|
||||
$eventID = 0;
|
||||
if (isset($_GET['id'])) {
|
||||
$eventID = $_GET['id'];
|
||||
} else {
|
||||
echo 'No event ID provided';
|
||||
exit;
|
||||
if(isset($_GET['id'])){
|
||||
$eventID = $_GET['id'];
|
||||
}else{
|
||||
echo 'No event ID provided';
|
||||
exit();
|
||||
}
|
||||
|
||||
$dbActivity = new pvv\side\DBActivity($pdo);
|
||||
$dbActivity = new \pvv\side\DBActivity($pdo);
|
||||
$event = $dbActivity->getEventByID($eventID);
|
||||
if (!$event) {
|
||||
echo 'Failed to retrieve event info';
|
||||
exit;
|
||||
if(!$event){
|
||||
echo 'Failed to retrieve event info';
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@ -34,23 +34,23 @@ if (!$event) {
|
||||
<main>
|
||||
<article>
|
||||
<h2>
|
||||
<?php if (Agenda::isToday($event->getStart())) { ?><strong><?php } ?>
|
||||
<em><?php echo $event->getRelativeDate(); ?></em>
|
||||
<?php if (Agenda::isToday($event->getStart())) { ?></strong><?php } ?>
|
||||
|
||||
<?php echo $event->getName(); ?>
|
||||
<?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() ?>
|
||||
</h2>
|
||||
<ul class="subtext">
|
||||
<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>
|
||||
<li>Tid: <strong><?= Agenda::getFormattedDate($event->getStart()) ?></strong></li>
|
||||
<li>Sted: <strong><?= $event->getLocation() ?></strong></li>
|
||||
<li>Arrangør: <strong><?= $event->getOrganiser() ?></strong></li>
|
||||
</ul>
|
||||
|
||||
<?php $description = $event->getDescription(); ?>
|
||||
<?php
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $description));
|
||||
?>
|
||||
$Parsedown = new \Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $description));
|
||||
?>
|
||||
</article>
|
||||
</main>
|
||||
|
||||
|
102
www/index.php
102
www/index.php
@ -1,25 +1,22 @@
|
||||
<?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($dbDsn, $dbUser, $dbPass);
|
||||
$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">
|
||||
@ -43,10 +40,11 @@ $doorTime = date('H:i', $doorEntry->time);
|
||||
</nav>
|
||||
|
||||
<header class="landing">
|
||||
<div id="imageSlideshow">
|
||||
<?php include 'galleri/slideshow.php'; ?>
|
||||
<div id="imageSlideshow">
|
||||
<?php include("galleri/slideshow.php"); ?>
|
||||
<script src="js/slideshow.js"></script>
|
||||
</div>
|
||||
|
||||
<div class="info">
|
||||
<h2>Velkommen til Programvare­verkstedet</h2>
|
||||
<p>Programvareverkstedet (PVV) er en studentorganisasjon ved NTNU som vil skape et miljø for datainteresserte personer tilknyttet universitetet.</p>
|
||||
@ -55,9 +53,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>
|
||||
@ -69,60 +67,52 @@ $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"><?php echo $translation[$period]; ?></p>
|
||||
<?php foreach($agenda->getNextDays() as $period => $events) if ($events && $counter1 < 3 && $counter2 < 10) { $counter1++ ?>
|
||||
<p class="no-chin"><?= $translation[$period] ?></p>
|
||||
<hr>
|
||||
<ul>
|
||||
<?php foreach ($events as $event) {
|
||||
$counter2++; ?>
|
||||
<?php foreach($events as $event) { $counter2++ ?>
|
||||
<li>
|
||||
<?php if ($event->getURL()) { ?>
|
||||
<a href="<?php echo htmlspecialchars($event->getURL()); ?>"><?php echo $event->getName(); ?></a>
|
||||
<a href="<?= htmlspecialchars($event->getURL()) ?>"><?= $event->getName(); ?></a>
|
||||
<?php } else { ?>
|
||||
<strong><?php echo $event->getName(); ?></strong>
|
||||
<strong><?= $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()) {
|
||||
echo $event->getStart()->format('D');
|
||||
} else {
|
||||
echo $event->getStart()->format('j. F');
|
||||
}
|
||||
} else {
|
||||
echo $event->getStart()->format('H:i');
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
<?php /* <a class="icon subscribe">+</a> */ ?>
|
||||
<?php if ($period !== \pvv\side\Agenda::TODAY) {
|
||||
echo '<span class="time">' . $event->getStart()->format('H:i') . '</span>';
|
||||
if (\pvv\side\Agenda::isThisWeek($event->getStart()) || $event->getStart()->sub(new DateInterval('P3D'))->getTimestamp() < time()) {
|
||||
echo '<span class="date">' . strftime('%a', $event->getStart()->getTimestamp()) . '</span>';
|
||||
} else {
|
||||
echo '<span class="date">' . strftime('%e. %b', $event->getStart()->getTimestamp()) . '</span>';
|
||||
}
|
||||
} else {
|
||||
echo '<span class="time">' . $event->getStart()->format('H:i') . '</span>';
|
||||
}
|
||||
?>
|
||||
</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 $title;
|
||||
}
|
||||
echo '</h1>';
|
||||
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $motd['content']));
|
||||
?>
|
||||
echo "<h1>";
|
||||
if($title == ""){
|
||||
echo "Dagens melding";
|
||||
}else{
|
||||
echo $title;
|
||||
}
|
||||
echo "</h1>";
|
||||
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $motd["content"]));
|
||||
?>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
|
@ -1,17 +1,22 @@
|
||||
const modal = document.getElementById('modal');
|
||||
const modalImg = document.getElementById("modal-content");
|
||||
const captionText = document.getElementById("modal-caption");
|
||||
// #region Modal
|
||||
var modal = document.getElementById('modal');
|
||||
|
||||
// global handler
|
||||
document.addEventListener('click', function (e) {
|
||||
if (e.target.className.indexOf('modal-target') !== -1) {
|
||||
// Open modal
|
||||
const img = e.target;
|
||||
var img = e.target;
|
||||
var modalImg = document.getElementById("modal-content");
|
||||
var captionText = document.getElementById("modal-caption");
|
||||
modal.style.display = "block";
|
||||
modalImg.src = img.dataset.fullsrc;
|
||||
modalImg.src = img.src;
|
||||
captionText.innerHTML = img.alt;
|
||||
} else if (modal.style.display != "none") {
|
||||
// Close modal
|
||||
modal.style.display = "none";
|
||||
modalImg.src = "";
|
||||
}
|
||||
});
|
||||
// #endregion
|
||||
|
||||
// #region sorting
|
||||
|
||||
|
||||
// #endregion
|
@ -21,7 +21,7 @@ function stepSlideshow(imgs) {
|
||||
//Change source to next picture after it is faded out
|
||||
slideshowIndex = (slideshowIndex + 1) % imgs.length;
|
||||
ssi2.src = slideshowFnames[slideshowIndex];
|
||||
}, 1000);
|
||||
}, 800);
|
||||
}
|
||||
|
||||
//Initialize slideshow, start interval
|
||||
@ -29,4 +29,4 @@ if (slideshowFnames.length > 1) {
|
||||
slideshowInterval = setInterval(()=>{
|
||||
stepSlideshow(slideshowFnames);
|
||||
}, SLIDESHOWDELAYMS);
|
||||
}
|
||||
}
|
@ -1,19 +1,17 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$year = (isset($_GET['year']))
|
||||
? $_GET['year']
|
||||
: date('Y');
|
||||
? $_GET['year']
|
||||
: 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')
|
||||
: -1;
|
||||
? $_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")
|
||||
: -1;
|
||||
$days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
|
||||
|
||||
?><!DOCTYPE html>
|
||||
@ -38,27 +36,20 @@ $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
<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;
|
||||
}
|
||||
?>
|
||||
<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>
|
||||
<h2 style="text-align:center;">PVV Kalender for <?=$months_translations[$month-1]?> <?=$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++;}
|
||||
?>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
|
||||
<figure class="calendar">
|
||||
<ul>
|
||||
<li class="header noselect">mandag
|
||||
@ -68,32 +59,32 @@ $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
|
||||
<li class="header noselect">fredag
|
||||
<li class="header noselect">lørdag
|
||||
<li class="header noselect">søndag
|
||||
|
||||
|
||||
<?php if ($days_before_the_first != 0) { ?>
|
||||
<li class="outOfMonth" style="grid-column: 1/<?php echo $days_before_the_first + 1; ?>;">
|
||||
<li class="outOfMonth" style="grid-column: 1/<?=$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 (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 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 } ?>
|
||||
</div></a>
|
||||
<?php } else { ?>
|
||||
<span class="noselect day"><?php echo $day; ?>.</span>
|
||||
<span class="noselect day"><?= $day ?>.</span>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
</ul>
|
||||
</figure>
|
||||
</main>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
@ -9,7 +9,7 @@ require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'in
|
||||
<link rel="stylesheet" href="../css/normalize.css">
|
||||
<link rel="stylesheet" href="../css/style.css">
|
||||
<link rel="stylesheet" href="../css/events.css">
|
||||
<meta name="theme-color" content="#024" >
|
||||
<meta name="theme-color" content="#024" />
|
||||
<title>Kommunikasjonsverkstedet</title>
|
||||
|
||||
<header>Kommunikasjons­verk­stedet</header>
|
||||
@ -22,32 +22,22 @@ require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'in
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
<h2>
|
||||
Kontaktinformasjon
|
||||
<a href="https://en.wikipedia.org/wiki/IP_over_Avian_Carriers">
|
||||
<img style="width: 8em" src="kontakt.jpg">
|
||||
</a>
|
||||
</h2>
|
||||
<h2>Kommunikasjon<br><img style="width: 8em" src="kontakt.jpg"></img></h2>
|
||||
|
||||
<p>
|
||||
Vi kan kontaktes på følgende e-postadresser:
|
||||
<ul>
|
||||
<li><a href="mailto:pvv@pvv.ntnu.no">pvv@pvv.ntnu.no</a> for hendvendelser til styret</li>
|
||||
<li><a href="mailto:drift@pvv.ntnu.no">drift@pvv.ntnu.no</a> for hendvendelser anngående våre datasystemer</li>
|
||||
</ul>
|
||||
</p>
|
||||
<p> Det er flere ulike måter å kommunisere med PVV og deres medlemmer på.
|
||||
|
||||
<p>Det er også mulig å ta kontakt med oss ved å møte opp <a href="https://link.mazemap.com/JqgWGSnh">på våre lokaler i oppredning/gruvedrift</a>.</p>
|
||||
<p> Du kan registrere deg på våre <a href="http://list.pvv.org/mailman/listinfo/aktive">Aktive epostlister</a> for å få informasjon om de kommende aktivitetene våre.
|
||||
|
||||
<h2>Kommunikasjonskanaler</h2>
|
||||
<p> Kontaktinformasjonen til Styret og Drift funner du på vår <a href="../pvv/Kontaktinformasjon">Wiki</a>
|
||||
|
||||
<p>Vi har en <a href="http://list.pvv.org/mailman/listinfo/aktive">e-postliste for aktive medlemmer</a>. All offisiell informasjon blir sendt på denne listen, og alle arrengementer blir også annonsert her.</p>
|
||||
<p> Vi har en IRC-kanal på <a href="http://webchat.ircnet.net/">IRCnet</a> kalt #pvv.
|
||||
|
||||
<p>Vi har et <a target="_blank" href="https://matrix.to/#/#pvv:pvv.ntnu.no">Matrix Space™</a> for chat, memes, og all annen kommunikasjon. Den er bridget med IRC-kanalen og Discord-serveren vår. Hvis du er medlem kan du bruke vår egen instans av <a href="https://chat.pvv.ntnu.no">Element web</a>.</p>
|
||||
<p> Vi har også en Discord-kanal. Denne kanalen er satt opp slik at man i Discord-kanalen ser hva som skrives i IRC-kanalen, og vice versa. For å bli med i Discord-kanalen, <a href="https://discord.gg/8VTBr6Q">klikk her</a>.
|
||||
<!--
|
||||
<i>(Denne broen for øyeblikket ute av drift)</i>
|
||||
-->
|
||||
|
||||
<p>Vi har en IRC-kanal på <a href="http://webchat.ircnet.net/">IRCnet</a> kalt #pvv.</p>
|
||||
|
||||
<p>Vi har en <a target="_blank" href="https://discord.gg/8VTBr6Q">Discord-server</a> for de som foretrekker Discord over Matrix. </p>
|
||||
<p> Det er også mulig å ta i bruk analog kontakt ved å møte opp <a href="https://bit.ly/31P6yr5">på våre lokaler i oppredning/gruvedrift</a>.
|
||||
|
||||
</main>
|
||||
</body>
|
||||
|
35
www/mail/index.php
Normal file
35
www/mail/index.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
<style>
|
||||
p {hyphens: auto;}
|
||||
</style>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" href="../css/normalize.css">
|
||||
<link rel="stylesheet" href="../css/style.css">
|
||||
<link rel="stylesheet" href="../css/mail.css">
|
||||
<meta name="theme-color" content="#024" />
|
||||
<title>Mailverkstedet</title>
|
||||
|
||||
<header>Mail­verk­stedet</header>
|
||||
|
||||
|
||||
<main>
|
||||
|
||||
<ul id="webmail">
|
||||
<li id="afterlogic"><div><a href="https://webmail.pvv.ntnu.no/afterlogic_lite/"><span class="mailname" style="user-select: none"> </span></a>
|
||||
<li id="rainloop"><div><a href="https://webmail.pvv.ntnu.no/rainloop/"><span class="mailname">RainLoop</span></a>
|
||||
<li id="squirrelmail"><div><a href="https://webmail.pvv.ntnu.no/squirrelmail/"><span class="mailname">SquirrelMail</span></a>
|
||||
<li id="roundcube"><div><a href="https://webmail.pvv.ntnu.no/roundcube/"><span class="mailname">Roundcube</span></a>
|
||||
</ul>
|
||||
|
||||
</main>
|
||||
|
||||
<nav>
|
||||
<?= navbar(1, "mail"); ?>
|
||||
<?= loginbar($sp, $pdo); ?>
|
||||
</nav>
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use pvv\side\Agenda;
|
||||
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
use \pvv\side\Agenda;
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
@ -35,40 +34,40 @@ use pvv\side\Agenda;
|
||||
<main>
|
||||
<div id="outDatedBanner"><p><br>Denne siden er trolig utdatert! Hvis du er interessert, ta kontakt i discord-kanalen. <br> This page is probably outdated! If you're interested, check in with someone in our discord-channel. </p></div>
|
||||
<?php
|
||||
$activity = new pvv\side\social\NerdepitsaActivity();
|
||||
$nextEvent = $activity->getNextEventFrom(new DateTimeImmutable());
|
||||
$activity = new \pvv\side\social\NerdepitsaActivity;
|
||||
$nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
|
||||
?>
|
||||
|
||||
<article>
|
||||
<h2><em><?php echo $nextEvent->getRelativeDate(); ?></em> Nerdepitsa
|
||||
<h2><em><?= $nextEvent->getRelativeDate()?></em> Nerdepitsa
|
||||
<?php if ($nextEvent->getImageURL()) { ?>
|
||||
<img src="<?php echo $nextEvent->getImageURL(); ?>">
|
||||
<img src="<?= $nextEvent->getImageURL() ?>">
|
||||
<?php } ?>
|
||||
</h2>
|
||||
<ul class="subtext">
|
||||
<li>Tid:
|
||||
<strong>
|
||||
<?php echo Agenda::getFormattedDate($nextEvent->getStart()); ?>
|
||||
<?= Agenda::getFormattedDate($nextEvent->getStart());?>
|
||||
</strong>
|
||||
<li>Sted:
|
||||
<strong>
|
||||
<?php echo $nextEvent->getLocation(); ?>
|
||||
<?= $nextEvent->getLocation();?>
|
||||
</strong>
|
||||
<li>Arrangør:
|
||||
<strong>
|
||||
<?php echo $nextEvent->getOrganiser(); ?>
|
||||
<?= $nextEvent->getOrganiser();?>
|
||||
</strong>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
|
||||
?>
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
|
||||
?>
|
||||
</article>
|
||||
|
||||
</main>
|
||||
|
||||
<nav>
|
||||
<?php echo navbar(1, 'aktiviteter'); ?>
|
||||
<?php echo loginbar($sp, $pdo); ?>
|
||||
<?= navbar(1, 'aktiviteter'); ?>
|
||||
<?= loginbar($sp, $pdo); ?>
|
||||
</nav>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
<?php
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
@ -34,7 +34,7 @@ p {hyphens: auto;}
|
||||
width: 100%;
|
||||
padding-top: 56.25%; /* 16:9 Aspect Ratio (divide 9 by 16 = 0.5625) */
|
||||
}
|
||||
|
||||
|
||||
/* Then style the iframe to fit in the container div with full height and width */
|
||||
.responsive-iframe {
|
||||
position: absolute;
|
||||
@ -45,10 +45,10 @@ p {hyphens: auto;}
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
<div class="iframe-container" style="max-width: 100em;">
|
||||
<iframe class="responsive-iframe" src="https://www.youtube.com/embed/Uy6HAvMdeuA" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen ></iframe>
|
||||
</div>
|
||||
<iframe class="responsive-iframe" src="https://www.youtube.com/embed/l-iEkaQNQdk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen ></iframe>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article>
|
||||
@ -66,7 +66,7 @@ p {hyphens: auto;}
|
||||
|
||||
<p>PVV har også en del brettspill du kan prøve.
|
||||
|
||||
<p><a href="https://wiki.pvv.ntnu.no/wiki/Dokumentasjon">Her</a> er en oversikt over hva du kan gjøre når du har fått PVV bruker.
|
||||
<p><a href="../pvv/Dokumentasjon">Her</a> er en oversikt over hva du kan gjøre når du har fått PVV bruker.
|
||||
|
||||
</article>
|
||||
|
||||
@ -89,6 +89,6 @@ p {hyphens: auto;}
|
||||
</main>
|
||||
|
||||
<nav>
|
||||
<?php echo navbar(1); ?>
|
||||
<?php echo loginbar($sp, $pdo); ?>
|
||||
<?= navbar(1); ?>
|
||||
<?= loginbar($sp, $pdo); ?>
|
||||
</nav>
|
||||
|
@ -1,10 +1,29 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
session_start();
|
||||
|
||||
$attrs = $as->getAttributes();
|
||||
|
||||
$oauth2 = new Kasperrt\Oauth2($dataportenConfig);
|
||||
|
||||
if (isset($_GET['logout'])) {
|
||||
session_destroy();
|
||||
header('Location: ' . $dataportenConfig["redirect_uri"]);
|
||||
die();
|
||||
}
|
||||
if (isset($_GET['login'])) {
|
||||
$oauth2 -> redirect();
|
||||
die();
|
||||
}
|
||||
if (isset($_GET['code'])) {
|
||||
$token = $oauth2 -> get_access_token(htmlspecialchars($_GET['state']), htmlspecialchars($_GET['code']));
|
||||
$_SESSION['userdata'] = $oauth2 -> get_identity($token, 'https://auth.dataporten.no/userinfo');
|
||||
|
||||
header('Location: ' . $dataportenConfig["redirect_uri"]);
|
||||
die();
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
@ -28,10 +47,10 @@ $attrs = $as->getAttributes();
|
||||
|
||||
<main>
|
||||
<h2>Å bli medlem på PVV</h2>
|
||||
|
||||
|
||||
<p>
|
||||
Første steg for å bli medlem i PVV er å betale
|
||||
<a href="https://wiki.pvv.ntnu.no/wiki/Medlemskontingent">medlemskontingent</a> på 50kr per år.
|
||||
<a href="../pvv/Medlemskontingent">medlemskontingent</a> på 50kr per år.
|
||||
Disse pengene brukes for å drifte PVV. Se lenken for kontonummeret.
|
||||
</p>
|
||||
<p>
|
||||
@ -42,24 +61,24 @@ $attrs = $as->getAttributes();
|
||||
å man møte opp på lokalene slik at man får satt passord.
|
||||
</p>
|
||||
<p>
|
||||
Mer informasjon om medlemskap finner du <a href="https://wiki.pvv.ntnu.no/wiki/Medlem">her</a>.
|
||||
Mer informasjon om medlemskap finner du <a href="../pvv/Medlem">her</a>.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>Registrer deg som bruker</h2>
|
||||
|
||||
|
||||
<p>
|
||||
PVV har for øyeblikket et manuelt system for å legge til nye brukere.
|
||||
Se lenkene over for mer informasjon.
|
||||
Vi foretrekker at du kommer inn på besøk på <a href="https://link.mazemap.com/aKDz8eu8">våre lokaler i Oppredning/Gruvedrift, rom 247</a>
|
||||
for å sette sette opp din PVV bruker. Hvis du ikke har mulighet til det, kan du <a href="https://wiki.pvv.ntnu.no/wiki/Kontaktinformasjon">finne oss her</a> og sende en epost.
|
||||
for å sette sette opp din PVV bruker. Hvis du ikke har mulighet til det, kan du <a href="../pvv/Kontaktinformasjon">finne oss her</a> og sende en epost.
|
||||
For å aktivere din brukerkonto på PVV, må du alikevell møte opp på
|
||||
lokalene våre slik at vi kan få satt ditt passord.
|
||||
</p>
|
||||
<iframe id="mazeMapper" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://use.mazemap.com/embed.html#v=1&zlevel=2¢er=10.406194,63.417143&zoom=18&campusid=1&sharepoitype=poi&sharepoi=38159&utm_medium=iframe" style="border: 1px solid grey" allow="geolocation"></iframe><br/>
|
||||
|
||||
<?php if ($attrs) { // logged in with pvv account?>
|
||||
|
||||
<?php if($attrs) { //logged in with pvv account?>
|
||||
<p>
|
||||
Du er nå logget in som <i><?php echo htmlspecialchars($attrs['uid'][0]); ?></i>,
|
||||
Du er nå logget in som <i><?= htmlspecialchars($attrs['uid'][0]) ?></i>,
|
||||
og trenger klart ikke sende melding om å få ny PVV bruker.
|
||||
</p>
|
||||
<?php } ?>
|
||||
|
@ -1,50 +1,50 @@
|
||||
<?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';
|
||||
require __DIR__ . '/../../sql_config.php';
|
||||
|
||||
require_once __DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple('default-sp');
|
||||
$as = new SimpleSAML_Auth_Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$projectManager = new pvv\side\ProjectManager($pdo);
|
||||
$projectManager = new \pvv\side\ProjectManager($pdo);
|
||||
|
||||
$new = 0;
|
||||
if (isset($_GET['new'])) {
|
||||
$new = $_GET['new'];
|
||||
if(isset($_GET['new'])){
|
||||
$new = $_GET['new'];
|
||||
}
|
||||
|
||||
$projectID = 0;
|
||||
if (isset($_GET['id'])) {
|
||||
$projectID = $_GET['id'];
|
||||
} elseif ($new == 0) {
|
||||
echo "\nID not set";
|
||||
exit;
|
||||
if(isset($_GET['id'])){
|
||||
$projectID = $_GET['id'];
|
||||
}else if($new == 0){
|
||||
echo "\nID not set";
|
||||
exit();
|
||||
}
|
||||
|
||||
$project = new pvv\side\Project(
|
||||
0,
|
||||
'Nytt Prosjekt',
|
||||
'',
|
||||
$attrs['cn'][0],
|
||||
$attrs['uid'][0],
|
||||
$attrs['mail'][0],
|
||||
1
|
||||
$project = new \pvv\side\Project(
|
||||
0,
|
||||
'Nytt Prosjekt',
|
||||
'',
|
||||
$attrs["cn"][0],
|
||||
$attrs["uid"][0],
|
||||
$attrs["mail"][0],
|
||||
1
|
||||
);
|
||||
if ($new == 0) {
|
||||
$project = $projectManager->getByID($projectID);
|
||||
$owner = $projectManager->getProjectOwner($projectID);
|
||||
if($new == 0){
|
||||
$project = $projectManager->getByID($projectID);
|
||||
$owner = $projectManager->getProjectOwner($projectID);
|
||||
|
||||
if ($owner['uname'] != $attrs['uid'][0]) {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
echo 'wrong user';
|
||||
exit;
|
||||
}
|
||||
if($owner['uname'] != $attrs["uid"][0]){
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
echo "wrong user";
|
||||
exit();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@ -74,20 +74,20 @@ if ($new == 0) {
|
||||
<form action="update.php", method="post">
|
||||
<p class="subtitle no-chin">Prosjektnavn</p>
|
||||
<p class="subnote">Gi prosjektet ditt et passende navn</p>
|
||||
<input class="wide" type="text" name="title" value="<?php echo $project->getName(); ?>" class="boxinput"><br>
|
||||
<input class="wide" type="text" name="title" value="<?= $project->getName() ?>" class="boxinput"><br>
|
||||
|
||||
<p class="subtitle no-chin">Beskrivelse (<i style="opacity:0.5;">markdown</i>)</p>
|
||||
<p class="subnote no-chin">Hva går prosjektet ditt ut på?</p>
|
||||
<p class="subnote">De første to linjene blir vist på prosjektkortet, prøv å gjøre de til et fint sammendrag eller intro!</p>
|
||||
<textarea class="tall" name="desc" style="width:100%" rows="8" class="boxinput"><?php echo implode("\n", $project->getDescription()); ?></textarea>
|
||||
<textarea class="tall" name="desc" style="width:100%" rows="8" class="boxinput"><?= implode($project->getDescription(), "\n"); ?></textarea>
|
||||
|
||||
<?php echo '<input type="hidden" name="id" value="' . $project->getID() . '" />'; ?>
|
||||
<?= '<input type="hidden" name="id" value="' . $project->getID() . '" />' ?>
|
||||
<input type="hidden" name="active" value="1"/>
|
||||
|
||||
<div style="margin-top: 0.2em;">
|
||||
<hr class="ruler">
|
||||
<input type="submit" class="btn" value="<?php echo $new ? 'Opprett prosjekt' : 'Lagre endringer'; ?>"></input>
|
||||
<?php if (!$new) {?><input type="submit" class="btn" name="delete" value="Slett"></input><?php } ?>
|
||||
<input type="submit" class="btn" value="<?= ($new ? 'Opprett prosjekt' : 'Lagre endringer') ?>"></input>
|
||||
<?php if (!$new){?><input type="submit" class="btn" name="delete" value="Slett"></input><?php } ?>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$translation = ['i dag', 'i morgen', 'denne uka', 'neste uke', 'denne måneden', 'neste måned'];
|
||||
$projectManager = new pvv\side\ProjectManager($pdo);
|
||||
$projectManager = new \pvv\side\ProjectManager($pdo);
|
||||
$projects = $projectManager->getAll();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@ -43,7 +43,7 @@ $projects = $projectManager->getAll();
|
||||
<p>
|
||||
Styret har ansvaret for den daglige driften av PVV, og har myndighet som gitt i PVVs lover.
|
||||
Lederen for PVV velges om høsten og sitter i et år. Resten av styret velges for et halvår om
|
||||
gangen, selv om praksis er at bare mindre justeringer gjøres i vårsemesteret.
|
||||
gangen, selv om praksis er at bare mindre justeringer gjøres i vårsemesteret.
|
||||
</p>
|
||||
<p class="project-organizer">Organisert av Styreleder</p>
|
||||
</div>
|
||||
@ -52,7 +52,7 @@ $projects = $projectManager->getAll();
|
||||
<div class="card-content">
|
||||
<h4 class="project-title">Drift</h4>
|
||||
<p>
|
||||
Drift har ansvaret for å drive maskinene på PVV.
|
||||
Drift har ansvaret for å drive maskinene på PVV.
|
||||
Driftsgruppen har ingen strenge krav til aktivitet eller erfaring for å bli medlem,
|
||||
så selv om du er ny i virket går det fint an å bare observere og absorbere i begynnelsen.
|
||||
Vi vil gjøre vårt beste for å gi god hjelp og service til våre brukere.
|
||||
@ -60,13 +60,13 @@ $projects = $projectManager->getAll();
|
||||
<p class="project-organizer">Organisert av Driftskordinator</p>
|
||||
</div>
|
||||
</div></a>
|
||||
<?php /* Her kan vi legge til PR og TriKom hvis det er ønskelig */ ?>
|
||||
<?php /*Her kan vi legge til PR og TriKom hvis det er ønskelig*/ ?>
|
||||
</div>
|
||||
|
||||
|
||||
<h2>Medlems-prosjekter</h2>
|
||||
<?php
|
||||
if (count($projects) == 0) {
|
||||
?>
|
||||
if(count($projects) == 0){
|
||||
?>
|
||||
<p>PVV har for øyeblikket ingen aktive prosjekter. Tenker du at noe bør gjøres? Har du en kul ide for noe PVV kan samarbeide om? Sett opp et prosjekt!</p>
|
||||
<br>
|
||||
<center>
|
||||
@ -75,8 +75,8 @@ $projects = $projectManager->getAll();
|
||||
</center>
|
||||
<br>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
}else{
|
||||
?>
|
||||
<p>
|
||||
Lyst til å gjøre noe kult? Her er et utvalg av de prosjektene som PVVere har holder på med. Mangler det noe, eller brenner du for noe annet?<br>
|
||||
Sett opp et eget prosjekt da vel!
|
||||
@ -84,24 +84,24 @@ $projects = $projectManager->getAll();
|
||||
<div class="projects-container">
|
||||
|
||||
<?php
|
||||
$randProjects = array_rand($projects, min(6, count($projects)));
|
||||
if (!is_array($randProjects)) {
|
||||
$randProjects = [$randProjects];
|
||||
}
|
||||
foreach ($randProjects as $i) {
|
||||
$project = $projects[$i];
|
||||
$owner = $projectManager->getProjectOwner($project->getID());
|
||||
?>
|
||||
$randProjects = array_rand($projects, min(6, count($projects)));
|
||||
if (!is_array($randProjects)) {
|
||||
$randProjects = [$randProjects];
|
||||
};
|
||||
foreach($randProjects as $i) {
|
||||
$project = $projects[$i];
|
||||
$owner = $projectManager->getProjectOwner($project->getID());
|
||||
?>
|
||||
|
||||
<a class="nostyle" href="info.php?id=<?php echo $project->getID(); ?>"><div class="project-card">
|
||||
<a class="nostyle" href="info.php?id=<?= $project->getID() ?>"><div class="project-card">
|
||||
<div class="card-content">
|
||||
<h4 class="project-title"><?php echo $project->getName(); ?></h4>
|
||||
<h4 class="project-title"><?= $project->getName(); ?></h4>
|
||||
<?php
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", array_slice($project->getDescription(), 0, 2)));
|
||||
?>
|
||||
$Parsedown = new \Parsedown();
|
||||
echo $Parsedown->text(implode("\n", array_slice($project->getDescription(), 0, 2)));
|
||||
?>
|
||||
</div>
|
||||
<p class="project-organizer">Organisert av <?php echo $owner['name']; ?></p>
|
||||
<p class="project-organizer">Organisert av <?= $owner['name']; ?></p>
|
||||
</div></a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
@ -110,7 +110,7 @@ $projects = $projectManager->getAll();
|
||||
<a class="btn" href="mine.php">Mine prosjekter</a>
|
||||
</center>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
}
|
||||
?>
|
||||
</main>
|
||||
</body>
|
||||
|
@ -1,46 +1,47 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__, 2) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$projectID = 0;
|
||||
if (isset($_GET['id'])) {
|
||||
$projectID = $_GET['id'];
|
||||
} else {
|
||||
echo 'No project ID provided';
|
||||
exit;
|
||||
if(isset($_GET['id'])){
|
||||
$projectID = $_GET['id'];
|
||||
}else{
|
||||
echo 'No project ID provided';
|
||||
exit();
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
$projectManager = new pvv\side\ProjectManager($pdo);
|
||||
$projectManager = new \pvv\side\ProjectManager($pdo);
|
||||
$project = $projectManager->getByID($projectID);
|
||||
if (!$project) {
|
||||
echo ':^)';
|
||||
exit;
|
||||
echo ":^)";
|
||||
exit();
|
||||
}
|
||||
|
||||
$members = $projectManager->getProjectMembers($projectID);
|
||||
$normal_members = $members;
|
||||
foreach ($normal_members as $i => $data) {
|
||||
if ($data['lead']) {
|
||||
unset($normal_members[$i]);
|
||||
}
|
||||
foreach($normal_members as $i => $data){
|
||||
if($data['lead']){
|
||||
unset($normal_members[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$is_owner = false;
|
||||
$is_member = false;
|
||||
if ($attrs) {
|
||||
$uname = $attrs['uid'][0];
|
||||
foreach ($members as $member) {
|
||||
if ($member['uname'] == $uname) {
|
||||
if ($member['owner'] == 1) {
|
||||
$is_owner = true;
|
||||
} elseif ($member['owner'] == 0) {
|
||||
$is_member = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$is_owner = False;
|
||||
$is_member = False;
|
||||
if ($attrs){
|
||||
$uname = $attrs['uid'][0];
|
||||
foreach($members as $member){
|
||||
if ($member['uname'] == $uname){
|
||||
if ($member['owner']==1){
|
||||
$is_owner = True;
|
||||
}
|
||||
else if ($member['owner']==0){
|
||||
$is_member = True;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@ -65,11 +66,11 @@ if ($attrs) {
|
||||
|
||||
<main class="contentsplit">
|
||||
<div class="gridr">
|
||||
<h2><?php echo $project->getName(); ?></h2>
|
||||
<h2><?= $project->getName(); ?></h2>
|
||||
<?php
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $project->getDescription()));
|
||||
?>
|
||||
$Parsedown = new \Parsedown();
|
||||
echo $Parsedown->text(implode("\n", $project->getDescription()));
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="gridl">
|
||||
@ -78,49 +79,49 @@ if ($attrs) {
|
||||
<div class="projectlead">
|
||||
<h2>Prosjektledelsen</h2>
|
||||
<div class="projectmember">
|
||||
<?php foreach ($members as $i => $data) {
|
||||
if ($data['lead']) {
|
||||
?>
|
||||
<p><?php echo $data['name']; ?></p>
|
||||
<p class="memberrole"><?php echo $data['role']; ?></p>
|
||||
<p class="memberuname"><?php echo $data['uname']; ?></p>
|
||||
<p class="memberemail"><?php echo $data['mail']; ?></p>
|
||||
<?php foreach($members as $i => $data){
|
||||
if($data['lead']){
|
||||
?>
|
||||
<p><?= $data['name']; ?></p>
|
||||
<p class="memberrole"><?= $data['role'] ?></p>
|
||||
<p class="memberuname"><?= $data['uname']; ?></p>
|
||||
<p class="memberemail"><?= $data['mail']; ?></p>
|
||||
<?php }
|
||||
} ?>
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if (count($normal_members) > 0) {
|
||||
?>
|
||||
if(sizeof($normal_members) > 0){
|
||||
?>
|
||||
<div class="projectmembers">
|
||||
<h2>Medlemmer</h2>
|
||||
<?php foreach ($normal_members as $i => $data) {
|
||||
?>
|
||||
<?php foreach($normal_members as $i => $data){
|
||||
?>
|
||||
<div class="projectmember" style="border-color: #6a0;">
|
||||
<p><?php echo $data['name']; ?></p>
|
||||
<p class="memberrole"><?php echo $data['role'] ?: 'Deltaker'; ?></p>
|
||||
<p class="memberuname"><?php echo $data['uname']; ?></p>
|
||||
<p class="memberemail"><?php echo $data['mail']; ?></p>
|
||||
<p><?= $data['name']; ?></p>
|
||||
<p class="memberrole"><?= $data['role'] ? $data['role'] : 'Deltaker' ?></p>
|
||||
<p class="memberuname"><?= $data['uname']; ?></p>
|
||||
<p class="memberemail"><?= $data['mail']; ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if (!$is_owner) {
|
||||
?>
|
||||
if(!$is_owner){
|
||||
?>
|
||||
|
||||
<form action="update.php", method="post"><p>
|
||||
<input type="hidden" name="title" value="derp"/>
|
||||
<input type="hidden" name="desc" value="derp"/>
|
||||
<input type="hidden" name="active" value="derp"/>
|
||||
<input type="hidden" name="id" value="<?php echo $projectID; ?>"/>
|
||||
<input type="submit" class="btn" name="join_or_leave" value="<?php echo $is_member ? 'Forlat' : 'Bli med!'; ?>"></input>
|
||||
<input type="hidden" name="id" value="<?= $projectID ?>"/>
|
||||
<input type="submit" class="btn" name="join_or_leave" value="<?= ($is_member ? 'Forlat' : 'Bli med!') ?>"></input>
|
||||
</p></form>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
@ -1,34 +1,36 @@
|
||||
<?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';
|
||||
require __DIR__ . '/../../sql_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');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$projectManager = new pvv\side\ProjectManager($pdo);
|
||||
$projectManager = new \pvv\side\ProjectManager($pdo);
|
||||
$projects = $projectManager->getByOwner($attrs['uid'][0]);
|
||||
|
||||
$page = 1;
|
||||
if (isset($_GET['page'])) {
|
||||
$page = $_GET['page'];
|
||||
if(isset($_GET['page'])){
|
||||
$page = $_GET['page'];
|
||||
}
|
||||
|
||||
$filter = '';
|
||||
if (isset($_GET['filter'])) {
|
||||
$filter = $_GET['filter'];
|
||||
if(isset($_GET['filter'])){
|
||||
$filter = $_GET['filter'];
|
||||
}
|
||||
|
||||
// filter
|
||||
$projects = array_values(array_filter(
|
||||
$projects,
|
||||
static fn($project) => (preg_match('/.*' . $filter . '.*/i', $project->getName()) || preg_match('/.*' . $filter . '.*/i', implode(' ', $project->getDescription())))
|
||||
$projects,
|
||||
function($project) use ($filter){
|
||||
return (preg_match('/.*'.$filter.'.*/i', $project->getName()) or preg_match('/.*'.$filter.'.*/i', implode(" ", $project->getDescription())));
|
||||
}
|
||||
));
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@ -48,8 +50,8 @@ $projects = array_values(array_filter(
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<?php echo navbar(1, 'prosjekt'); ?>
|
||||
<?php echo loginbar(); ?>
|
||||
<?= navbar(1, 'prosjekt'); ?>
|
||||
<?= loginbar(); ?>
|
||||
</nav>
|
||||
|
||||
<main class="gridsplit">
|
||||
@ -58,49 +60,49 @@ $projects = array_values(array_filter(
|
||||
|
||||
<ul class="event-list">
|
||||
<?php
|
||||
$counter = 0;
|
||||
$pageLimit = 8;
|
||||
$counter = 0;
|
||||
$pageLimit = 8;
|
||||
|
||||
for ($i = ($pageLimit * ($page - 1)); $i < count($projects); ++$i) {
|
||||
if ($counter == $pageLimit) {
|
||||
break;
|
||||
}
|
||||
for($i = ($pageLimit * ($page - 1)); $i < count($projects); $i++){
|
||||
if($counter == $pageLimit){
|
||||
break;
|
||||
}
|
||||
|
||||
$project = $projects[$i];
|
||||
$projectID = $project->getID();
|
||||
$project = $projects[$i];
|
||||
$projectID = $project->getID();
|
||||
|
||||
$owner = $projectManager->getProjectOwner($projectID);
|
||||
if ($owner['uname'] != $attrs['uid'][0]) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
$owner = $projectManager->getProjectOwner($projectID);
|
||||
if($owner['uname'] != $attrs['uid'][0]){
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
|
||||
<li>
|
||||
<div class="event">
|
||||
<div class="event-info">
|
||||
<a href="edit.php?id=<?php echo $project->getID(); ?>">
|
||||
<h3 class="no-chin"><?php echo $project->getName(); ?></h3>
|
||||
<a href="edit.php?id=<?= $project->getID() ?>">
|
||||
<h3 class="no-chin"><?= $project->getName()?></h3>
|
||||
</a>
|
||||
<p style="text-decoration: none;"><?php echo implode('<br>', array_slice($project->getDescription(), 0, 4)); ?></p>
|
||||
<p style="text-decoration: none;"><?= implode("<br>", array_slice($project->getDescription(), 0, 4)); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php
|
||||
++$counter;
|
||||
}
|
||||
?>
|
||||
$counter++;
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
if ($page != 1) {
|
||||
echo '<a class="btn float-left" href="?page=' . ($page - 1) . '&filter=' . urlencode($filter) . '">Forrige side</a>';
|
||||
}
|
||||
if($page != 1){
|
||||
echo '<a class="btn float-left" href="?page=' . ($page - 1) . '&filter=' . urlencode($filter) . '">Forrige side</a>';
|
||||
}
|
||||
|
||||
if (($counter == $pageLimit) && (($pageLimit * $page) < count($projects))) {
|
||||
echo '<a class="btn float-right" href="?page=' . ($page + 1) . '&filter=' . urlencode($filter) . '">Neste side</a>';
|
||||
}
|
||||
?>
|
||||
if(($counter == $pageLimit) and (($pageLimit * $page) < count($projects))){
|
||||
echo '<a class="btn float-right" href="?page=' . ($page + 1) . '&filter=' . urlencode($filter) . '">Neste side</a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="gridr">
|
||||
@ -109,7 +111,7 @@ $projects = array_values(array_filter(
|
||||
<h2>Filter</h2>
|
||||
<form action="mine.php" method="get">
|
||||
<p class="no-chin">Navn</p>
|
||||
<?php echo '<input type="text" name="filter" class="boxinput" value="' . $filter . '">'; ?><br>
|
||||
<?= '<input type="text" name="filter" class="boxinput" value="' . $filter . '">' ?><br>
|
||||
|
||||
<div style="margin-top: 2em;">
|
||||
<input type="submit" class="btn" value="Filtrer"></input>
|
||||
|
@ -1,18 +1,18 @@
|
||||
<?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);
|
||||
require __DIR__ . '/../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
if (!isset($_POST['title']) || !isset($_POST['desc']) || !isset($_POST['active'])) {
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
exit;
|
||||
if(!isset($_POST['title']) or !isset($_POST['desc']) or !isset($_POST['active'])){
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
exit();
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@ -28,93 +28,95 @@ $name = $attrs['cn'][0];
|
||||
$uname = $attrs['uid'][0];
|
||||
$mail = $attrs['mail'][0];
|
||||
|
||||
$statement;
|
||||
if($id == 0){
|
||||
$query = 'INSERT INTO projects (name, description, active) VALUES (:title, :desc, 1)';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
if ($id == 0) {
|
||||
$query = 'INSERT INTO projects (name, description, active) VALUES (:title, :desc, 1)';
|
||||
$statement = $pdo->prepare($query);
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
$new_id = $pdo->lastInsertId();
|
||||
|
||||
$statement->execute();
|
||||
$new_id = $pdo->lastInsertId();
|
||||
$ownerQuery = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :owner, :owneruname, :owneremail, 'Prosjektleder', 1, 1)";
|
||||
$statement = $pdo->prepare($ownerQuery);
|
||||
$statement->bindParam(':id', $new_id, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owner', $name, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneruname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneremail', $mail, PDO::PARAM_STR);
|
||||
|
||||
$ownerQuery = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :owner, :owneruname, :owneremail, 'Prosjektleder', 1, 1)";
|
||||
$statement = $pdo->prepare($ownerQuery);
|
||||
$statement->bindParam(':id', $new_id, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owner', $name, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneruname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneremail', $mail, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
}
|
||||
else {
|
||||
$projectManager = new \pvv\side\ProjectManager($pdo);
|
||||
$owner = $projectManager->getProjectOwner($id);
|
||||
$members = $projectManager->getProjectMembers($id);
|
||||
|
||||
$statement->execute();
|
||||
} else {
|
||||
$projectManager = new pvv\side\ProjectManager($pdo);
|
||||
$owner = $projectManager->getProjectOwner($id);
|
||||
$members = $projectManager->getProjectMembers($id);
|
||||
//if ($do_join_or_leave and $owner['uname'] != $uname) {
|
||||
if ($do_join_or_leave) {
|
||||
$is_member = False;
|
||||
foreach($members as $member){
|
||||
if ($member['uname'] == $uname and $member['owner']==0){
|
||||
$is_member = True;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($is_member){//leave
|
||||
$query = "DELETE FROM projectmembers WHERE projectid=:id AND uname=:uname and lead=0 and owner=0;";
|
||||
$statement = $pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
|
||||
// if ($do_join_or_leave and $owner['uname'] != $uname) {
|
||||
if ($do_join_or_leave) {
|
||||
$is_member = false;
|
||||
foreach ($members as $member) {
|
||||
if ($member['uname'] == $uname && $member['owner'] == 0) {
|
||||
$is_member = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($is_member) {// leave
|
||||
$query = 'DELETE FROM projectmembers WHERE projectid=:id AND uname=:uname and lead=0 and owner=0;';
|
||||
$statement = $pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
print("leave");
|
||||
}
|
||||
else{//join
|
||||
$query = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :name, :uname, :mail, 'Medlem', 0, 0)";
|
||||
$statement = $pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$statement->bindParam(':name', $name, PDO::PARAM_STR);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':mail', $mail, PDO::PARAM_STR);
|
||||
|
||||
$statement->execute();
|
||||
echo 'leave';
|
||||
} else {// join
|
||||
$query = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :name, :uname, :mail, 'Medlem', 0, 0)";
|
||||
$statement = $pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$statement->bindParam(':name', $name, PDO::PARAM_STR);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':mail', $mail, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
print("join");
|
||||
}
|
||||
header('Location: ./info.php?id=' . $id);
|
||||
exit();
|
||||
}
|
||||
|
||||
$statement->execute();
|
||||
echo 'join';
|
||||
}
|
||||
header('Location: ./info.php?id=' . $id);
|
||||
exit;
|
||||
}
|
||||
if($uname != $owner['uname']){
|
||||
header('Content-Type: text/plain', true, 403);
|
||||
echo "Illegal action, you're not the project owner for project with ID " . $id . "\r\n";
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($do_delete) {
|
||||
// this should be done as a transaction...
|
||||
$pdo->beginTransaction();
|
||||
|
||||
$query = 'DELETE FROM projects WHERE id=:id';
|
||||
$statement = $pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
$query = 'DELETE FROM projectmembers WHERE projectid=:id';
|
||||
$statement = $pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
$pdo->commit();
|
||||
}else{
|
||||
$query = 'UPDATE projects SET name=:title, description=:desc WHERE id=:id';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
if ($uname != $owner['uname']) {
|
||||
header('Content-Type: text/plain', true, 403);
|
||||
echo "Illegal action, you're not the project owner for project with ID " . $id . "\r\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($do_delete) {
|
||||
// this should be done as a transaction...
|
||||
$pdo->beginTransaction();
|
||||
|
||||
$query = 'DELETE FROM projects WHERE id=:id';
|
||||
$statement = $pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
$query = 'DELETE FROM projectmembers WHERE projectid=:id';
|
||||
$statement = $pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
$pdo->commit();
|
||||
} else {
|
||||
$query = 'UPDATE projects SET name=:title, description=:desc WHERE id=:id';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
|
||||
$statement->execute();
|
||||
}
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
|
||||
$statement->execute();
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: ./mine.php');
|
||||
|
@ -1,18 +0,0 @@
|
||||
# This file set up by fredj according to proposed Standard of Robot
|
||||
# Exclusion at http://web.nexor.co.uk/mak/doc/robots/norobots.html
|
||||
#
|
||||
# Currently: allow all robots.
|
||||
# (An empty 'Disallow' line, looking like this:)
|
||||
# User-agent: * # Means: All robots.
|
||||
# Disallow: # Means: Disallow nothing.
|
||||
|
||||
User-agent: *
|
||||
Disallow: /usage
|
||||
Disallow: /news_archive
|
||||
Disallow: /cgi
|
||||
Disallow: /finger
|
||||
Disallow: /cgi-bin
|
||||
Disallow: /~pallo/usage/
|
||||
Disallow: /~pallo/historic/
|
||||
Disallow: /~meldahl/
|
||||
Disallow: /w/index.php?
|
@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once dirname(__DIR__) . implode(\DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
header('Content-Type: application/json');
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$door = new pvv\side\Door($pdo);
|
||||
$doorEntry = (object) $door->getCurrent();
|
||||
|
||||
?>
|
||||
{
|
||||
"api_compatibility": ["14"],
|
||||
"space": "Programvareverkstedet",
|
||||
"logo": "https://git.pvv.ntnu.no/assets/img/logo.png",
|
||||
"url": "https://www.pvv.ntnu.no/",
|
||||
"location": {
|
||||
"ext_campus": "NTNU Gløshaugen",
|
||||
"ext_room_name": "Oppredning/Gruvedrift, Floor 2, Room 247",
|
||||
"ext_mazemap": "https://link.mazemap.com/2n2HWa7H",
|
||||
"address": "Sem Sælands vei 1, 7034 Trondheim, Norway",
|
||||
"timezone": "Europe/Oslo",
|
||||
"lon": 10.4063852,
|
||||
"lat": 63.4170226
|
||||
},
|
||||
"contact": {
|
||||
"irc": "irc://irc.pvv.ntnu.no/pvv",
|
||||
"email": "pvv@pvv.ntnu.no",
|
||||
"ext_discord": "https://discord.gg/8VTBr6Q",
|
||||
"gopher": "gopher://isvegg.pvv.ntnu.no",
|
||||
"matrix": "#pvv:pvv.ntnu.no"
|
||||
},
|
||||
"issue_report_channels": ["email"],
|
||||
"state": {
|
||||
"open": <?php echo $doorEntry->open ? 'true' : 'false'; ?>,
|
||||
"lastchange": <?php echo $doorEntry->time ? $doorEntry->time : 0; ?>,
|
||||
"message": "<?php echo $doorEntry->open ? 'open for public, members are present' : 'closed'; ?>"
|
||||
},
|
||||
"feeds": {
|
||||
"wiki": {
|
||||
"type": "atom",
|
||||
"url": "https://wiki.pvv.ntnu.no/w/api.php?hidebots=1&urlversion=1&action=feedrecentchanges&feedformat=atom"
|
||||
},
|
||||
"calendar": {
|
||||
"type": "html",
|
||||
"url": "https://www.pvv.ntnu.no/hendelser/"
|
||||
}
|
||||
},
|
||||
"projects": [
|
||||
"https://github.com/Programvareverkstedet/",
|
||||
"https://git.pvv.ntnu.no/",
|
||||
"https://www.pvv.ntnu.no/prosjekt/"
|
||||
],
|
||||
"links": [
|
||||
{
|
||||
"name": "YouTube",
|
||||
"url": "https://www.youtube.com/@pvvntnu5640"
|
||||
},
|
||||
{
|
||||
"name": "LinkedIn",
|
||||
"url": "https://www.linkedin.com/company/pvvntnu/"
|
||||
},
|
||||
{
|
||||
"name": "Facebook",
|
||||
"url": "https://www.facebook.com/pvvntnu/"
|
||||
}
|
||||
]
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user