Compare commits
10 Commits
92fae34292
...
4d3adf7258
Author | SHA1 | Date |
---|---|---|
Oystein Kristoffer Tveit | 4d3adf7258 | |
Oystein Kristoffer Tveit | a28715f126 | |
Oystein Kristoffer Tveit | 321846d2da | |
Oystein Kristoffer Tveit | ad8ecc4935 | |
Felix Albrigtsen | a8fb2af3e7 | |
Felix Albrigtsen | 968048496a | |
Felix Albrigtsen | 573d19681b | |
Felix Albrigtsen | 5da6bd8961 | |
Felix Albrigtsen | b429b84301 | |
Felix Albrigtsen | fef79575a7 |
|
@ -1,4 +1,5 @@
|
|||
/sql_config.php
|
||||
/result
|
||||
/config.php
|
||||
*.sqlite
|
||||
/test.sql
|
||||
/vendor/
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
{
|
||||
"require": {
|
||||
"simplesamlphp/simplesamlphp": "1.19.8",
|
||||
"erusev/parsedown": "^1.7",
|
||||
"gettext/gettext": "4.8.7",
|
||||
"simplesamlphp/saml2": "4.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-pdo_sqlite": "*"
|
||||
},
|
||||
"name": "programvareverkstedet/nettsiden",
|
||||
"description": "Programvareverkstedets nettside",
|
||||
"license": "proprietary",
|
||||
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"simplesamlphp/composer-module-installer": true
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"simplesamlphp/simplesamlphp": "^2.2"
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
11
dev.bat
11
dev.bat
|
@ -1,11 +0,0 @@
|
|||
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
|
18
dev.sh
18
dev.sh
|
@ -1,18 +0,0 @@
|
|||
#!/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 composer.phar || curl -O https://getcomposer.org/composer.phar
|
||||
|
||||
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/
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
$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 = array("localhost:1080");
|
||||
$SAML_ADMIN_PASSWORD = "changeme";
|
||||
|
||||
?>
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
$configFile = getenv('PVV_CONFIG_FILE');
|
||||
require_once($configFile);
|
||||
|
||||
?>
|
|
@ -36,7 +36,7 @@ CREATE TABLE "motd" (
|
|||
"content" TEXT
|
||||
);
|
||||
INSERT INTO motd (title, content)
|
||||
VALUES ("MOTD ./dev.sh", "du kan endre motd i admin panelet");
|
||||
VALUES ('MOTD ./dev.sh', 'du kan endre motd i admin panelet');
|
||||
|
||||
CREATE TABLE "door" (
|
||||
"time" INTEGER PRIMARY KEY,
|
||||
|
@ -47,4 +47,4 @@ VALUES (0, FALSE);
|
|||
|
||||
|
||||
INSERT INTO users (uname, groups)
|
||||
VALUES ("min_test_bruker", 1);
|
||||
VALUES ('min_test_bruker', 1);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
$dbDsn = 'sqlite:'.__DIR__.DIRECTORY_SEPARATOR.'pvv.sqlite';
|
||||
$dbUser = null;
|
||||
$dbPass = null;
|
||||
|
||||
$doorSensorSecret = "OGJiZTdjZDctMmFkNy00ZjZjLTk3OGItOTA3NzU3ZDM2Yjlm";
|
|
@ -2,11 +2,11 @@
|
|||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1692463654,
|
||||
"narHash": "sha256-F8hZmsQINI+S6UROM4jyxAMbQLtzE44pI8Nk6NtMdao=",
|
||||
"lastModified": 1707939175,
|
||||
"narHash": "sha256-D1xan0lgxbmXDyzVqXTiSYHLmAMrMRdD+alKzEO/p3w=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ca3c9ac9f4cdd4bea19f592b32bb59b74ab7d783",
|
||||
"rev": "f7e8132daca31b1e3859ac0fb49741754375ac3d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
57
flake.nix
57
flake.nix
|
@ -12,49 +12,30 @@
|
|||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in f system pkgs);
|
||||
in {
|
||||
devShells = forAllSystems (system: rec {
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
default = pkgs.mkShellNoCC {
|
||||
buildInputs = with pkgs; [
|
||||
php82
|
||||
(with php82Extensions; [
|
||||
iconv
|
||||
mbstring
|
||||
pdo_mysql
|
||||
pdo_sqlite
|
||||
])
|
||||
sqlite
|
||||
git
|
||||
];
|
||||
shellHook = ''
|
||||
export PHPHOST=localhost
|
||||
export PHPPORT=1080
|
||||
alias runDev='php -S $PHPHOST:$PHPPORT -d error_reporting=E_ALL -d display_errors=1 -t www/'
|
||||
packages = forAllSystems (system: pkgs: {
|
||||
default = self.packages.${system}.pvv-nettsiden;
|
||||
pvv-nettsiden = pkgs.callPackage ./nix/package.nix { php = pkgs.php82; };
|
||||
});
|
||||
|
||||
# Prepare dev environment with sqlite and config files
|
||||
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
|
||||
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; };
|
||||
};
|
||||
};
|
||||
|
||||
test -e composer.phar || curl -O https://getcomposer.org/composer.phar
|
||||
nixosModules.default = nix/module.nix;
|
||||
|
||||
if [ ! -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(\"$PHPHOST:$PHPPORT\")/g" < vendor/simplesamlphp/simplesamlphp/config-templates/config.php > vendor/simplesamlphp/simplesamlphp/config/config.php
|
||||
ln -s ../vendor/simplesamlphp/simplesamlphp/www/ www/simplesaml
|
||||
fi
|
||||
'';
|
||||
devShells = forAllSystems (system: pkgs: {
|
||||
default = pkgs.callPackage ./nix/shell.nix { inherit pkgs; };
|
||||
});
|
||||
|
||||
# TODO:
|
||||
# - Integrate with docker config
|
||||
# - Make "trusted.url.domains" dynamic based on the current host:port
|
||||
# - Do not download composer.phar with curl
|
||||
|
||||
};
|
||||
});
|
||||
# - Relicense the project to GPL or something
|
||||
# - Write a module for the project
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
require __DIR__ . '/../src/_autoload.php';
|
||||
require __DIR__ . '/../sql_config.php';
|
||||
require __DIR__ . '/../config.php';
|
||||
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$agenda = new \pvv\side\Agenda([
|
||||
new \pvv\side\social\NerdepitsaActivity,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'agenda.php';
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'navbar.php';
|
||||
|
||||
require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'sql_config.php']);
|
||||
require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'config.php']);
|
||||
|
||||
require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'src', '_autoload.php']);
|
||||
require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'vendor', 'simplesamlphp', 'simplesamlphp', 'lib', '_autoload.php']);
|
||||
|
@ -13,12 +13,12 @@ require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'vendor', 'sim
|
|||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'nb_NO');
|
||||
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
|
||||
$sp = 'default-sp';
|
||||
$as = new SimpleSAML_Auth_Simple($sp);
|
||||
$as = new \SimpleSAML\Auth\Simple($sp);
|
||||
|
||||
use \pvv\side\Agenda;
|
||||
$agenda = new \pvv\side\Agenda([
|
||||
|
|
|
@ -35,7 +35,7 @@ function loginBar($sp = null, $pdo = null) {
|
|||
if (is_null($sp)) $sp = 'default-sp';
|
||||
$result = "\n";
|
||||
require_once(__DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new SimpleSAML_Auth_Simple($sp);
|
||||
$as = new \SimpleSAML\Auth\Simple($sp);
|
||||
|
||||
$svg = '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 64 64">
|
||||
<circle cx="32" cy="27" r="14" stroke-width="0" />
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<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>
|
|
@ -0,0 +1,228 @@
|
|||
{ 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_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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
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 = cfg.package.postInstall + ''
|
||||
substituteInPlace $out/${cfg.package.passthru.simplesamlphpPath}/config/config.php \
|
||||
--replace '$SAML_COOKIE_SECURE' '${format.lib.valueToString cfg.settings.SAML.COOKIE_SECURE}' \
|
||||
--replace '$SAML_COOKIE_SALT' '${format.lib.valueToString cfg.settings.SAML.COOKIE_SALT}' \
|
||||
--replace '$SAML_ADMIN_PASSWORD' '${format.lib.valueToString cfg.settings.SAML.ADMIN_PASSWORD}' \
|
||||
--replace '$SAML_TRUSTED_DOMAINS' '${format.lib.valueToString cfg.settings.SAML.TRUSTED_DOMAINS}'
|
||||
'';
|
||||
});
|
||||
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" = { };
|
||||
};
|
||||
|
||||
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}/www/";
|
||||
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}/www/$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;
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{ php }:
|
||||
|
||||
php.buildComposerProject rec {
|
||||
src = ./..;
|
||||
pname = "pvv-nettsiden";
|
||||
version = "0.0.1";
|
||||
vendorHash = "sha256-W+8tLv6X2l13LmN4e1mvGn23MDMhANUCoH3pQBNViQc=";
|
||||
|
||||
passthru.simplesamlphpPath = "share/php/pvv-nettsiden/vendor/simplesamlphp/simplesamlphp";
|
||||
|
||||
postInstall = ''
|
||||
install -Dm444 dist/simplesamlphp-config.php $out/${passthru.simplesamlphpPath}/config/config.php
|
||||
install -Dm444 dist/simplesamlphp-authsources.php $out/${passthru.simplesamlphpPath}/config/authsources.php
|
||||
install -Dm444 dist/simplesamlphp-idp.php $out/${passthru.simplesamlphpPath}/metadata/saml20-idp-remote.php
|
||||
|
||||
install -Dm444 dist/config.source-env.php $out/share/php/pvv-nettsiden/config.php
|
||||
'';
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
{ 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;
|
||||
};
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
{ pkgs }:
|
||||
let
|
||||
phpEnv = pkgs.php82.buildEnv {
|
||||
extensions = { enabled, all }: enabled ++ (with all; [ iconv mbstring pdo_mysql pdo_sqlite ]);
|
||||
};
|
||||
in
|
||||
pkgs.mkShellNoCC {
|
||||
buildInputs = with pkgs; [
|
||||
phpEnv
|
||||
php82Packages.composer
|
||||
|
||||
sqlite
|
||||
git
|
||||
];
|
||||
shellHook = ''
|
||||
alias runDev='php -S localhost:1080 -d error_reporting=E_ALL -d display_errors=1 -t www/'
|
||||
|
||||
# Prepare dev environment with sqlite and config files
|
||||
test -e pvv.sqlite || sqlite3 pvv.sqlite < dist/pvv.sql
|
||||
test -e config.php || cp -v dist/config.local.php config.php
|
||||
|
||||
|
||||
if [ ! -d vendor ] ; then
|
||||
composer install || exit $?
|
||||
|
||||
cp dist/simplesamlphp-authsources.php vendor/simplesamlphp/simplesamlphp/config/authsources.php
|
||||
cp dist/simplesamlphp-idp.php vendor/simplesamlphp/simplesamlphp/metadata/saml20-idp-remote.php
|
||||
cp dist/simplesamlphp-config.php vendor/simplesamlphp/simplesamlphp/config/config.php
|
||||
|
||||
cp dist/config.local.php config.php
|
||||
|
||||
ln -s ../vendor/simplesamlphp/simplesamlphp/www/ www/simplesaml
|
||||
fi
|
||||
'';
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
require __DIR__ . '/../../../config.php';
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
|
||||
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();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
|
|
@ -3,14 +3,14 @@ date_default_timezone_set('Europe/Oslo');
|
|||
setlocale(LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../../inc/navbar.php';
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
|
||||
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();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
|
|
@ -3,14 +3,14 @@ date_default_timezone_set('Europe/Oslo');
|
|||
setlocale(LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../../inc/navbar.php';
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
|
||||
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();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
require __DIR__ . '/../../../config.php';
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
|
||||
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();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
|
|
@ -5,17 +5,17 @@ setlocale(LC_ALL, 'nb_NO');
|
|||
error_reporting(E_ALL);
|
||||
require __DIR__ . '/../../../inc/navbar.php';
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
require __DIR__ . '/../../../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');
|
||||
$attrs = $as->getAttributes();
|
||||
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
|
||||
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();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
|
|
@ -4,13 +4,13 @@ date_default_timezone_set('Europe/Oslo');
|
|||
setlocale(LC_ALL, 'nb_NO');
|
||||
error_reporting(E_ALL);
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
require __DIR__ . '/../../../config.php';
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
|
||||
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();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$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];
|
||||
|
|
|
@ -5,17 +5,17 @@ setlocale(LC_ALL, 'no_NO');
|
|||
error_reporting(E_ALL);
|
||||
require __DIR__ . '/../../../inc/navbar.php';
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
require __DIR__ . '/../../../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');
|
||||
$attrs = $as->getAttributes();
|
||||
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
|
||||
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();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
|
|
@ -4,13 +4,13 @@ date_default_timezone_set('Europe/Oslo');
|
|||
setlocale(LC_ALL, 'no_NO');
|
||||
error_reporting(E_ALL);
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
require __DIR__ . '/../../../config.php';
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
|
||||
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();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
require __DIR__ . '/../../../config.php';
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
|
||||
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();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
|
|
@ -3,14 +3,14 @@ date_default_timezone_set('Europe/Oslo');
|
|||
setlocale(LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../../inc/navbar.php';
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
|
||||
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();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
|
|
@ -3,14 +3,14 @@ date_default_timezone_set('Europe/Oslo');
|
|||
setlocale(LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../../inc/navbar.php';
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
require __DIR__ . '/../../../config.php';
|
||||
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
|
||||
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();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../../src/_autoload.php';
|
||||
require __DIR__ . '/../../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
require __DIR__ . '/../../../config.php';
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
|
||||
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();
|
||||
$uname = $attrs['uid'][0];
|
||||
|
|
|
@ -88,16 +88,6 @@ img.float-right {
|
|||
}
|
||||
|
||||
.calendar-events a,
|
||||
#ticker a {
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.calendar-events a:hover,
|
||||
#ticker a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.calendar-events ul .time {
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
|
|
|
@ -9,7 +9,7 @@ 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)) {
|
||||
if (hash_equals($data, $DOOR_SECRET)) {
|
||||
handleSetState();
|
||||
} else {
|
||||
echo '{"status": "error", "message": "Invalid authentication key"}';
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
error_reporting(0);
|
||||
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
|
||||
$as = new SimpleSAML_Auth_Simple('default-sp');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
$as->requireAuth();
|
||||
$attrs = $as->getAttributes();
|
||||
$loginname = $attrs['uid'][0];
|
||||
|
@ -18,23 +18,24 @@ if(!$loginname) {
|
|||
exit();
|
||||
}
|
||||
|
||||
# Sourced from config.php through include.php
|
||||
$galleryDir = $GALLERY_DIRECTORY;
|
||||
$serverPath = $GALLERY_SERVER_PATH;
|
||||
|
||||
$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 = 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"]);
|
||||
//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["fullPath"]));
|
||||
$cleanPath = substr_replace($path, "", $pos, strlen($GLOBALS["galleryDir"]));
|
||||
}
|
||||
|
||||
//Check if the file is an image
|
||||
|
@ -49,7 +50,7 @@ function getDirContents($dir, &$results = array()) {
|
|||
}
|
||||
return $results;
|
||||
}
|
||||
$images = getDirContents($fullPath);
|
||||
$images = getDirContents($galleryDir);
|
||||
|
||||
$imageTemplate = '
|
||||
<div class="card">
|
||||
|
@ -89,7 +90,7 @@ $imageTemplate = '
|
|||
<main class="gallery-container">
|
||||
<?php
|
||||
foreach ($images as $key => $value) {
|
||||
$modTime = date("d.m.Y H:i", filemtime($fullPath . $value));
|
||||
$modTime = date("d.m.Y H:i", filemtime($galleryDir . $value));
|
||||
$imguser = explode("/", $value)[0];
|
||||
$displaypath = substr($value, strpos($value, "/")+1);
|
||||
$realname = "Ukjent";
|
||||
|
@ -104,9 +105,9 @@ $imageTemplate = '
|
|||
$vars = [
|
||||
"%user" => htmlspecialchars($imguser),
|
||||
"%time" => $modTime,
|
||||
"%timestamp" => filemtime($fullPath . $value),
|
||||
"%timestamp" => filemtime($galleryDir . $value),
|
||||
"%name" => htmlspecialchars($displaypath),
|
||||
"%path" => "/galleri/" . $relativePath .$value,
|
||||
"%path" => $serverPath . $value,
|
||||
"%realname" => htmlspecialchars($realname)
|
||||
];
|
||||
echo strtr($imageTemplate, $vars);
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
<?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
|
||||
|
||||
require __DIR__ . '/../../config.php';
|
||||
|
||||
$searchDir = $SLIDESHOW_DIR;
|
||||
$serverPath = $SLIDESHOW_SERVER_PATH;
|
||||
|
||||
$splashImg = "/PNG/PVV-logo-big-bluebg.png";
|
||||
|
||||
$filenames = sCaNdIr(__DIR__ . $relativePath);
|
||||
// Note: This does not support nested directories
|
||||
$filenames = sCaNdIr($searchDir);
|
||||
|
||||
//Remove the expected non-images
|
||||
foreach($filenames as $k => $value) {
|
||||
if(in_array($value, [".gitkeep", ".", ".."])) {
|
||||
if(in_array($value, [".", ".."])) {
|
||||
unset($filenames[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
function getFullPath($fname) { return ($GLOBALS["absolutePath"] . $fname ); }
|
||||
function getFullPath($fname) { return ($GLOBALS["serverPath"] . "/" . $fname ); }
|
||||
|
||||
// Sort filenames alphabetically and prepend the path prefix to each item.
|
||||
asort($filenames);
|
||||
|
@ -27,4 +30,5 @@ eChO('<img class="slideshowimg slideshowactive" id="slideshowImage1" src="' . $s
|
|||
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>");
|
||||
|
||||
?>
|
|
@ -2,7 +2,7 @@
|
|||
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($dbDsn, $dbUser, $dbPass);
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$motdfetcher = new \pvv\side\MOTD($pdo);
|
||||
|
|
|
@ -3,14 +3,14 @@ date_default_timezone_set('Europe/Oslo');
|
|||
setlocale(LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../inc/navbar.php';
|
||||
require __DIR__ . '/../../src/_autoload.php';
|
||||
require __DIR__ . '/../../sql_config.php';
|
||||
require __DIR__ . '/../../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($dbDsn, $dbUser, $dbPass);
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$projectManager = new \pvv\side\ProjectManager($pdo);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ if(isset($_GET['id'])){
|
|||
}
|
||||
|
||||
require_once(__DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new SimpleSAML_Auth_Simple('default-sp');
|
||||
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
||||
$attrs = $as->getAttributes();
|
||||
|
||||
$projectManager = new \pvv\side\ProjectManager($pdo);
|
||||
|
|
|
@ -3,14 +3,14 @@ date_default_timezone_set('Europe/Oslo');
|
|||
setlocale(LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../inc/navbar.php';
|
||||
require __DIR__ . '/../../src/_autoload.php';
|
||||
require __DIR__ . '/../../sql_config.php';
|
||||
require __DIR__ . '/../../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($dbDsn, $dbUser, $dbPass);
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$projectManager = new \pvv\side\ProjectManager($pdo);
|
||||
$projects = $projectManager->getByOwner($attrs['uid'][0]);
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'nb_NO');
|
||||
require __DIR__ . '/../../src/_autoload.php';
|
||||
require __DIR__ . '/../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
require __DIR__ . '/../../config.php';
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
if(!isset($_POST['title']) or !isset($_POST['desc']) or !isset($_POST['active'])){
|
||||
|
@ -12,7 +12,7 @@ if(!isset($_POST['title']) or !isset($_POST['desc']) or !isset($_POST['active'])
|
|||
}
|
||||
|
||||
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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue