52 lines
1.6 KiB
PHP
52 lines
1.6 KiB
PHP
<?php
|
|
/*
|
|
settings.php
|
|
OpenDRS Online Discrepancy Reporting System
|
|
Copyright (C) 2021 Rod Wright
|
|
|
|
SPDX-License-Identifier: GPL-2.0
|
|
*/
|
|
|
|
$sttl=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"session_ttl_days\""))[0];
|
|
$ostype=strtoupper(substr(php_uname('s'), 0, 3));
|
|
if ($ostype == 'WIN') {
|
|
$sdir=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"win_server_session_dir\""))[0];
|
|
} else {
|
|
$sdir=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"unix_server_session_dir\""))[0];
|
|
}
|
|
$lifetime=60 * 60 * 24 * $sttl;
|
|
if (!is_dir($sdir)) mkdir($sdir, 0700, true);
|
|
ini_set('session.cookie_lifetime', $lifetime);
|
|
ini_set('session.gc_maxlifetime', $lifetime);
|
|
ini_set('session.save_path', $sdir);
|
|
|
|
session_cache_limiter('private, must-revalidate');
|
|
session_cache_expire(60);
|
|
$ss=session_status();
|
|
if ($ss==PHP_SESSION_NONE) session_start();
|
|
|
|
// get config options from database and assign them to constants
|
|
unset($userid);
|
|
if (isset($_SESSION['userid']) && $_SESSION['userid'] != '') {
|
|
$userid=$_SESSION['userid'];
|
|
}
|
|
|
|
$configqry=mysqli_query($drs_db,"select name,value from config");
|
|
while ($configrow = mysqli_fetch_assoc($configqry)) {
|
|
$constname=strtoupper($configrow['name']);
|
|
if (isset($userid)) {
|
|
$usrval=mysqli_fetch_row(mysqli_query($drs_db,"select value from profile where name=\"{$configrow['name']}\" and user=\"$userid\""))[0];
|
|
}
|
|
if ($usrval) {
|
|
$constvalue=$usrval;
|
|
} else {
|
|
$constvalue=$configrow['value'];
|
|
}
|
|
define("$constname","$constvalue");
|
|
}
|
|
|
|
//report no errors
|
|
error_reporting(0);
|
|
|
|
?>
|