prep for 2023. Fixed many bugs. Added pdf guide

This commit is contained in:
2023-03-29 22:47:51 +02:00
parent 7f97a60334
commit e6025e3be1
589 changed files with 172718 additions and 212 deletions

View File

@@ -3,21 +3,25 @@
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL & ~E_NOTICE );
$cfg = include('accred_config.php');
// start session
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$cfg = include('accred_config.php');
//
// Load the auth module, this will redirect us to login if we aren't already logged in.
include '../inc/auth.php';
$Auth = new modAuth();
// Load the graph class so we can get user info
include '../inc/graph.php';
$Graph = new modGraph();
$uInfo = $Graph->getProfile();
//
// var_dump($uInfo);
// die("tztz");r_dump($uInfo);
$userid = $uInfo->id;
$givenName = $uInfo->givenName;//
// CSRF Counter-measure
$token = md5(uniqid(rand(), TRUE));
$_SESSION['state'] = $token;
$userid = $_SESSION['uid'];
$isAdmin = $_SESSION['admin']==1;
$isAdmin = $uInfo->userPrincipalName==$cfg['admin'];
$isEditable = $cfg['editmode']==1;
// Bail out if not logged in
if($userid=='') {
header("location: index?");
}
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
@@ -145,9 +149,9 @@ foreach (range('A','E') as $col) {
// Add totals
//
$highestRow = $spreadsheet->getActiveSheet()->getHighestRow();
$coord = 'O' . ($highestRow+2);
$coord = 'N' . ($highestRow+2);
$spreadsheet->getActiveSheet()->setCellValue($coord, 'TOTAL');
foreach(range('P','Z') as $col) {
foreach(range('O','Z') as $col) {
$spreadsheet->getActiveSheet()->setCellValue($col.($highestRow+2), '=SUM('.$col.'2:'.$col.($highestRow).')');
}
foreach(range('A','B') as $col) {
@@ -319,7 +323,6 @@ exit();
</head>
<?php
$mysqli = new mysqli($cfg['host'], $cfg['user'],$cfg['pass'], $cfg['name']);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
@@ -327,13 +330,15 @@ if ($mysqli->connect_errno) {
?>
<body <?php if($isAdmin) echo 'class="admin" '; else echo 'class="user" '; ?>>
<div class="right-blob"><span id="identification">Bienvenue <?php echo $_SESSION['name']; if($isAdmin) echo ", tu es admin";?></span><br>
<div class="right-blob"><span id="identification">Bienvenue <?php echo $givenName; if($isAdmin) echo ", tu es admin";?></span><br>
<?php if($isEditable) { ?>
<span class="identification">Le formulaire est ouvert, les utilisateurs peuvent modifier ou ajouter des demandes</span><br>
<?php } else { ?>
<span class="identification">Le formulaire est fermé, les utilisateurs ne peuvent plus modifier ou ajouter des demandes</span><br>
<?php } ?>
<br>
<span class="identification"><a href="guide-accred-v1.pdf" target="_blank">Guide d'utilisation</a></span>
<div id="uid" style="display:none"><?php echo $userid;?></div></div>
<h1>Commande</h1>
<div id="tblContent">
@@ -526,21 +531,7 @@ table.page( 5 ).draw( false );
<div class="g-signin2" data-onsuccess="onSignIn" style="display:none"></div>
<br>
<a href="#" onclick="signOut();">Déconnexion</a>
<script>
function signOut() {
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
console.log('User signed out.');
$.post('tokensignin',
{ mode: "logout" }, // data
function(data) { // callback function
location.href="./index?";
}
);
});
}
</script>
<a href="/?action=logout">Déconnexion</a>
</body>
</html>