nettsiden/www/admin/motd/update.php

36 lines
1015 B
PHP
Raw Normal View History

2018-02-13 16:58:54 +01:00
<?php
ini_set('display_errors', '1');
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
error_reporting(E_ALL);
require __DIR__ . '/../../../src/_autoload.php';
2024-02-15 22:57:03 +01:00
require __DIR__ . '/../../../config.php';
2024-03-12 19:33:09 +01:00
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
2018-02-13 16:58:54 +01:00
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new \pvv\admin\UserManager($pdo);
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
2024-04-08 22:11:43 +02:00
$as = new \SimpleSAML\Auth\Simple('default-sp');
2018-02-13 16:58:54 +01:00
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];
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();
}
$motdfetcher = new \pvv\side\MOTD($pdo);
$motdfetcher->setMOTD($_POST['title'], $_POST['content']);
2018-02-13 16:58:54 +01:00
header('Location: .');
?>
<a href=".">Om du ikke ble automatisk omdirigert tilbake klikk her</a>