Bring in distfiles from OpenDRS to use as a new starting point
This commit is contained in:
61
distfiles/settings.php
Normal file
61
distfiles/settings.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/*
|
||||
settings.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
// determine today's date and time and assign them to variables
|
||||
$today = date("Y-m-d");
|
||||
$now = date("H:i:s");
|
||||
|
||||
$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)) {
|
||||
$usrvalqry=mysqli_query($drs_db,"select value from profile where name=\"{$configrow['name']}\" and user=\"$userid\"");
|
||||
if (mysqli_num_rows($usrvalqry) > 0) {
|
||||
$usrrow=mysqli_fetch_row($usrvalqry);
|
||||
$usrval=$usrrow[0];
|
||||
}
|
||||
}
|
||||
if (isset($usrval)) {
|
||||
$constvalue=$usrval;
|
||||
unset($usrval);
|
||||
} else {
|
||||
$constvalue=$configrow['value'];
|
||||
}
|
||||
if (!defined("$constname")) define("$constname","$constvalue");
|
||||
}
|
||||
|
||||
// level of error reporting. Set to 0 for production or E_ALL for development/troubleshooting
|
||||
//error_reporting(0);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user